• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ NAPI_CALL函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中NAPI_CALL函数的典型用法代码示例。如果您正苦于以下问题:C++ NAPI_CALL函数的具体用法?C++ NAPI_CALL怎么用?C++ NAPI_CALL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NAPI_CALL函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: testGetVersion

static napi_value testGetVersion(napi_env env, napi_callback_info info) {
  uint32_t version;
  napi_value result;
  NAPI_CALL(env, napi_get_version(env, &version));
  NAPI_CALL(env, napi_create_uint32(env, version, &result));
  return result;
}
开发者ID:dnalborczyk,项目名称:node,代码行数:7,代码来源:test_general.c


示例2: Get

napi_value Get(napi_env env, napi_callback_info info) {
  size_t argc = 2;
  napi_value args[2];
  NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));

  NAPI_ASSERT(env, argc >= 2, "Wrong number of arguments");

  napi_valuetype valuetype0;
  NAPI_CALL(env, napi_typeof(env, args[0], &valuetype0));

  NAPI_ASSERT(env, valuetype0 == napi_object,
    "Wrong type of arguments. Expects an object as first argument.");

  napi_valuetype valuetype1;
  NAPI_CALL(env, napi_typeof(env, args[1], &valuetype1));

  NAPI_ASSERT(env, valuetype1 == napi_string || valuetype1 == napi_symbol,
    "Wrong type of arguments. Expects a string or symbol as second.");

  napi_value object = args[0];
  napi_value output;
  NAPI_CALL(env, napi_get_property(env, object, args[1], &output));

  return output;
}
开发者ID:BazisSoft,项目名称:node-delphi,代码行数:25,代码来源:test_object.c


示例3: CreateDataViewFromJSDataView

static napi_value CreateDataViewFromJSDataView(napi_env env, napi_callback_info info) {
  size_t argc = 1;
  napi_value args [1];
  NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));

  NAPI_ASSERT(env, argc == 1, "Wrong number of arguments");

  napi_valuetype valuetype;
  napi_value input_dataview = args[0];

  NAPI_CALL(env, napi_typeof(env, input_dataview, &valuetype));
  NAPI_ASSERT(env, valuetype == napi_object,
              "Wrong type of arguments. Expects a DataView as the first "
              "argument.");

  bool is_dataview;
  NAPI_CALL(env, napi_is_dataview(env, input_dataview, &is_dataview));
  NAPI_ASSERT(env, is_dataview,
              "Wrong type of arguments. Expects a DataView as the first "
              "argument.");
  size_t byte_offset = 0;
  size_t length = 0;
  napi_value buffer;
  NAPI_CALL(env,
            napi_get_dataview_info(env, input_dataview, &length, NULL,
                                   &buffer, &byte_offset));

  napi_value output_dataview;
  NAPI_CALL(env,
            napi_create_dataview(env, length, buffer,
                                 byte_offset, &output_dataview));


  return output_dataview;
}
开发者ID:asbeane,项目名称:node,代码行数:35,代码来源:test_dataview.c


示例4: Set

napi_value Set(napi_env env, napi_callback_info info) {
  size_t argc = 3;
  napi_value args[3];
  NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));

  NAPI_ASSERT(env, argc >= 3, "Wrong number of arguments");

  napi_valuetype valuetype0;
  NAPI_CALL(env, napi_typeof(env, args[0], &valuetype0));

  NAPI_ASSERT(env, valuetype0 == napi_object,
    "Wrong type of arguments. Expects an object as first argument.");

  napi_valuetype valuetype1;
  NAPI_CALL(env, napi_typeof(env, args[1], &valuetype1));

  NAPI_ASSERT(env, valuetype1 == napi_string || valuetype1 == napi_symbol,
    "Wrong type of arguments. Expects a string or symbol as second.");

  NAPI_CALL(env, napi_set_property(env, args[0], args[1], args[2]));

  napi_value valuetrue;
  NAPI_CALL(env, napi_get_boolean(env, true, &valuetrue));

  return valuetrue;
}
开发者ID:BazisSoft,项目名称:node-delphi,代码行数:26,代码来源:test_object.c


示例5: testNapiTypeof

napi_value testNapiTypeof(napi_env env, napi_callback_info info) {
  size_t argc = 1;
  napi_value args[1];
  NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));

  napi_valuetype argument_type;
  NAPI_CALL(env, napi_typeof(env, args[0], &argument_type));

  napi_value result = NULL;
  if (argument_type == napi_number) {
    NAPI_CALL(env, napi_create_string_utf8(env, "number", -1, &result));
  } else if (argument_type == napi_string) {
    NAPI_CALL(env, napi_create_string_utf8(env, "string", -1, &result));
  } else if (argument_type == napi_function) {
    NAPI_CALL(env, napi_create_string_utf8(env, "function", -1, &result));
  } else if (argument_type == napi_object) {
    NAPI_CALL(env, napi_create_string_utf8(env, "object", -1, &result));
  } else if (argument_type == napi_boolean) {
    NAPI_CALL(env, napi_create_string_utf8(env, "boolean", -1, &result));
  } else if (argument_type == napi_undefined) {
    NAPI_CALL(env, napi_create_string_utf8(env, "undefined", -1, &result));
  } else if (argument_type == napi_symbol) {
    NAPI_CALL(env, napi_create_string_utf8(env, "symbol", -1, &result));
  } else if (argument_type == napi_null) {
    NAPI_CALL(env, napi_create_string_utf8(env, "null", -1, &result));
  }
  return result;
}
开发者ID:BazisSoft,项目名称:node-delphi,代码行数:28,代码来源:test_general.c


示例6: HasOwn

napi_value HasOwn(napi_env env, napi_callback_info info) {
  size_t argc = 2;
  napi_value args[2];
  NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));

  NAPI_ASSERT(env, argc == 2, "Wrong number of arguments");

  napi_valuetype valuetype0;
  NAPI_CALL(env, napi_typeof(env, args[0], &valuetype0));

  NAPI_ASSERT(env, valuetype0 == napi_object,
    "Wrong type of arguments. Expects an object as first argument.");

  // napi_valuetype valuetype1;
  // NAPI_CALL(env, napi_typeof(env, args[1], &valuetype1));
  //
  // NAPI_ASSERT(env, valuetype1 == napi_string || valuetype1 == napi_symbol,
  //   "Wrong type of arguments. Expects a string or symbol as second.");

  bool has_property;
  NAPI_CALL(env, napi_has_own_property(env, args[0], args[1], &has_property));

  napi_value ret;
  NAPI_CALL(env, napi_get_boolean(env, has_property, &ret));

  return ret;
}
开发者ID:BazisSoft,项目名称:node-delphi,代码行数:27,代码来源:test_object.c


示例7: Init

napi_value Init(napi_env env, napi_value exports) {
  napi_value number;
  NAPI_CALL(env, napi_create_double(env, value_, &number));

  napi_property_descriptor properties[] = {
    { "echo", 0, Echo, 0, 0, 0, napi_enumerable, 0 },
    { "readwriteValue", 0, 0, 0, 0, number, napi_enumerable | napi_writable, 0 },
    { "readonlyValue", 0, 0, 0, 0, number, napi_enumerable, 0},
    { "hiddenValue", 0, 0, 0, 0, number, napi_default, 0},
    { "readwriteAccessor1", 0, 0, GetValue, SetValue, 0, napi_default, 0},
    { "readwriteAccessor2", 0, 0, GetValue, SetValue, 0, napi_writable, 0},
    { "readonlyAccessor1", 0, 0, GetValue, NULL, 0, napi_default, 0},
    { "readonlyAccessor2", 0, 0, GetValue, NULL, 0, napi_writable, 0},
    { "staticReadonlyAccessor1", 0, 0, GetStaticValue, NULL, 0,
        napi_default | napi_static, 0},
  };

  napi_value cons;
  NAPI_CALL(env, napi_define_class(env, "MyObject", -1, New,
      NULL, sizeof(properties)/sizeof(*properties), properties, &cons));

  NAPI_CALL(env, napi_create_reference(env, cons, 1, &constructor_));

  return cons;
}
开发者ID:kahwee,项目名称:node,代码行数:25,代码来源:test_constructor.c


示例8: TestLatin1Insufficient

napi_value TestLatin1Insufficient(napi_env env, napi_callback_info info) {
  size_t argc = 1;
  napi_value args[1];
  NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));

  NAPI_ASSERT(env, argc >= 1, "Wrong number of arguments");

  napi_valuetype valuetype;
  NAPI_CALL(env, napi_typeof(env, args[0], &valuetype));

  NAPI_ASSERT(env, valuetype == napi_string,
    "Wrong type of argment. Expects a string.");

  char buffer[4];
  size_t buffer_size = 4;
  size_t copied;

  NAPI_CALL(env,
    napi_get_value_string_latin1(env, args[0], buffer, buffer_size, &copied));

  napi_value output;
  NAPI_CALL(env, napi_create_string_latin1(env, buffer, copied, &output));

  return output;
}
开发者ID:bammons,项目名称:node,代码行数:25,代码来源:test_string.c


示例9: NewScope

static napi_value NewScope(napi_env env, napi_callback_info info) {
  napi_handle_scope scope;
  napi_value output = NULL;

  NAPI_CALL(env, napi_open_handle_scope(env, &scope));
  NAPI_CALL(env, napi_create_object(env, &output));
  NAPI_CALL(env, napi_close_handle_scope(env, scope));
  return NULL;
}
开发者ID:dnalborczyk,项目名称:node,代码行数:9,代码来源:test_handle_scope.c


示例10: Init

napi_value Init(napi_env env, napi_value exports) {
  napi_value cons;
  NAPI_CALL(env, napi_define_class(
      env, "MyObject_Extra", 8, New, NULL, 0, NULL, &cons));

  NAPI_CALL(env,
      napi_create_reference(env, cons, 1, &constructor_));
  return cons;
}
开发者ID:Frrank1,项目名称:node,代码行数:9,代码来源:test_constructor_name.c


示例11: testAdjustExternalMemory

static napi_value testAdjustExternalMemory(napi_env env, napi_callback_info info) {
  napi_value result;
  int64_t adjustedValue;

  NAPI_CALL(env, napi_adjust_external_memory(env, 1, &adjustedValue));
  NAPI_CALL(env, napi_create_double(env, (double)adjustedValue, &result));

  return result;
}
开发者ID:dnalborczyk,项目名称:node,代码行数:9,代码来源:test_general.c


示例12: test_finalize_wrap

static napi_value test_finalize_wrap(napi_env env, napi_callback_info info) {
  size_t argc = 1;
  napi_value js_object;

  NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &js_object, NULL, NULL));
  NAPI_CALL(env, napi_wrap(env, js_object, NULL, test_finalize, NULL, NULL));

  return NULL;
}
开发者ID:dnalborczyk,项目名称:node,代码行数:9,代码来源:test_general.c


示例13: Wrap

napi_value Wrap(napi_env env, napi_callback_info info) {
  size_t argc = 1;
  napi_value arg;
  NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &arg, NULL, NULL));

  int32_t* data = malloc(sizeof(int32_t));
  *data = test_value;
  NAPI_CALL(env, napi_wrap(env, arg, data, NULL, NULL, NULL));
  return NULL;
}
开发者ID:BazisSoft,项目名称:node-delphi,代码行数:10,代码来源:test_object.c


示例14: remove_wrap

static napi_value remove_wrap(napi_env env, napi_callback_info info) {
  size_t argc = 1;
  napi_value wrapped;
  void* data;

  NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &wrapped, NULL, NULL));
  NAPI_CALL(env, napi_remove_wrap(env, wrapped, &data));

  return NULL;
}
开发者ID:dnalborczyk,项目名称:node,代码行数:10,代码来源:test_general.c


示例15: testNapiErrorCleanup

static napi_value testNapiErrorCleanup(napi_env env, napi_callback_info info) {
  const napi_extended_error_info *error_info = 0;
  NAPI_CALL(env, napi_get_last_error_info(env, &error_info));

  napi_value result;
  bool is_ok = error_info->error_code == napi_ok;
  NAPI_CALL(env, napi_get_boolean(env, is_ok, &result));

  return result;
}
开发者ID:dnalborczyk,项目名称:node,代码行数:10,代码来源:test_general.c


示例16: RunCallbackWithRecv

napi_value RunCallbackWithRecv(napi_env env, napi_callback_info info) {
  size_t argc = 2;
  napi_value args[2];
  NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));

  napi_value cb = args[0];
  napi_value recv = args[1];
  NAPI_CALL(env, napi_call_function(env, recv, cb, 0, NULL, NULL));
  return NULL;
}
开发者ID:Frrank1,项目名称:node,代码行数:10,代码来源:binding.c


示例17: testNapiRun

static napi_value testNapiRun(napi_env env, napi_callback_info info) {
  napi_value script, result;
  size_t argc = 1;

  NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &script, NULL, NULL));

  NAPI_CALL(env, napi_run_script(env, script, &result));

  return result;
}
开发者ID:dnalborczyk,项目名称:node,代码行数:10,代码来源:test_general.c


示例18: SayHello

napi_value SayHello(napi_env env, napi_callback_info info) {
  size_t argc = 0;
  // test if `napi_get_cb_info` tolerants NULL pointers.
  NAPI_CALL(env, napi_get_cb_info(env, info, &argc, NULL, NULL, NULL));

  napi_value str;
  NAPI_CALL(env, napi_create_string_utf8(env, "Hello", 5, &str));

  return str;
}
开发者ID:Samsung,项目名称:iotjs,代码行数:10,代码来源:test_napi_strictequal_and_instanceof.c


示例19: testGetPrototype

static napi_value testGetPrototype(napi_env env, napi_callback_info info) {
  size_t argc = 1;
  napi_value args[1];
  NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));

  napi_value result;
  NAPI_CALL(env, napi_get_prototype(env, args[0], &result));

  return result;
}
开发者ID:dnalborczyk,项目名称:node,代码行数:10,代码来源:test_general.c


示例20: Test

static napi_value Test(napi_env env, napi_callback_info info) {
  napi_value err;
  size_t argc = 1;

  NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &err, NULL, NULL));

  NAPI_CALL(env, napi_fatal_exception(env, err));

  return NULL;
}
开发者ID:asbeane,项目名称:node,代码行数:10,代码来源:test_fatal_exception.c



注:本文中的NAPI_CALL函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ NAS_ERROR_LOG函数代码示例发布时间:2022-05-30
下一篇:
C++ NAME函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap