当前位置: 首页>>代码示例>>C++>>正文


C++ JObject::SetMethod方法代码示例

本文整理汇总了C++中JObject::SetMethod方法的典型用法代码示例。如果您正苦于以下问题:C++ JObject::SetMethod方法的具体用法?C++ JObject::SetMethod怎么用?C++ JObject::SetMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JObject的用法示例。


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

示例1: InitTcp

JObject* InitTcp() {
  Module* module = GetBuiltinModule(MODULE_TCP);
  JObject* tcp = module->module;

  if (tcp == NULL) {
    tcp = new JObject(TCP);

    JObject prototype;
    tcp->SetProperty("prototype", prototype);

    prototype.SetMethod("open", Open);
    prototype.SetMethod("close", Close);
    prototype.SetMethod("connect", Connect);
    prototype.SetMethod("bind", Bind);
    prototype.SetMethod("listen", Listen);
    prototype.SetMethod("write", Write);
    prototype.SetMethod("readStart", ReadStart);
    prototype.SetMethod("shutdown", Shutdown);
    prototype.SetMethod("setKeepAlive", SetKeepAlive);

    module->module = tcp;
  }

  return tcp;
}
开发者ID:0-T-0,项目名称:iotjs,代码行数:25,代码来源:iotjs_module_tcp.cpp

示例2: InitFs

JObject* InitFs() {
  Module* module = GetBuiltinModule(MODULE_FS);
  JObject* fs = module->module;

  if (fs == NULL) {
    fs = new JObject();
    fs->SetMethod("close", Close);
    fs->SetMethod("open", Open);
    fs->SetMethod("read", Read);
    fs->SetMethod("write", Write);
    fs->SetMethod("stat", Stat);

    module->module = fs;
  }

  return fs;
}
开发者ID:Vincent2015,项目名称:iotjs,代码行数:17,代码来源:iotjs_module_fs.cpp

示例3: InitBuffer

JObject* InitBuffer() {
  Module* module = GetBuiltinModule(MODULE_BUFFER);
  JObject* buffer = module->module;

  if (buffer == NULL) {
    buffer = new JObject(Buffer);

    JObject prototype;
    buffer->SetProperty("prototype", prototype);

    prototype.SetMethod("compare", Compare);
    prototype.SetMethod("copy", Copy);
    prototype.SetMethod("write", Write);
    prototype.SetMethod("slice", Slice);
    prototype.SetMethod("toString", ToString);

    module->module = buffer;
  }

  return buffer;
}
开发者ID:no-problemo,项目名称:iotjs,代码行数:21,代码来源:iotjs_module_buffer.cpp

示例4: InitGpio

JObject* InitGpio() {
    Module* module = GetBuiltinModule(MODULE_GPIO);
    JObject* jgpio = module->module;

    if (jgpio == NULL) {
        jgpio = new JObject();

        jgpio->SetMethod("initialize", Initialize);
        jgpio->SetMethod("release", Release);
        jgpio->SetMethod("setPin", SetPin);
        jgpio->SetMethod("writePin", WritePin);
        jgpio->SetMethod("readPin", ReadPin);
        jgpio->SetMethod("setPort", SetPort);
        jgpio->SetMethod("writePort", WritePort);
        jgpio->SetMethod("readPort", ReadPort);
        jgpio->SetMethod("query", Query);

#define SET_CONSTANT(object, name, constant) \
  do { \
    JObject value(constant); \
    object->SetProperty(name, value); \
  } while (0)

        SET_CONSTANT(jgpio, "kGpioDirectionNone", kGpioDirectionNone);
        SET_CONSTANT(jgpio, "kGpioDirectionIn", kGpioDirectionIn);
        SET_CONSTANT(jgpio, "kGpioDirectionOut", kGpioDirectionOut);

        SET_CONSTANT(jgpio, "kGpioModeNone", kGpioModeNone);
        SET_CONSTANT(jgpio, "kGpioModePullup", kGpioModePullup);
        SET_CONSTANT(jgpio, "kGpioModePulldown", kGpioModePulldown);
        SET_CONSTANT(jgpio, "kGpioModeFloat", kGpioModeFloat);
        SET_CONSTANT(jgpio, "kGpioModePushpull", kGpioModePushpull);
        SET_CONSTANT(jgpio, "kGpioModeOpendrain", kGpioModeOpendrain);

        SET_CONSTANT(jgpio, "kGpioErrOk", kGpioErrOk);
        SET_CONSTANT(jgpio, "kGpioErrInitialize", kGpioErrInitialize);
        SET_CONSTANT(jgpio, "kGpioErrNotInitialized", kGpioErrNotInitialized);
        SET_CONSTANT(jgpio, "kGpioErrWrongUse", kGpioErrWrongUse);
        SET_CONSTANT(jgpio, "kGpioErrSysErr", kGpioErrSys);

#undef SET_CONSTANT

        Gpio* gpio = Gpio::Create(*jgpio);
        IOTJS_ASSERT(gpio == reinterpret_cast<Gpio*>(jgpio->GetNative()));

        module->module = jgpio;
    }

    return jgpio;
}
开发者ID:ILyoan,项目名称:iotjs,代码行数:50,代码来源:iotjs_module_gpio.cpp


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