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

C++ IOTJS_ASSERT函数代码示例

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

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



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

示例1: jbuffer

size_t BufferWrap::length() {
#ifndef NDEBUG
  int length = jbuffer().GetProperty("length").GetInt32();
  IOTJS_ASSERT(static_cast<size_t>(length) == _length);
#endif
  return _length;
}
开发者ID:0-T-0,项目名称:iotjs,代码行数:7,代码来源:iotjs_module_buffer.cpp


示例2: IOTJS_ASSERT

JResult JObject::Call(JObject& this_, JArgList& arg) {
  IOTJS_ASSERT(IsFunction());

  JRawObjectType* this_obj_p = this_.IsNull() ? NULL
                                              : this_.raw_value().u.v_object;
  JRawValueType res;
  JRawValueType* val_args = NULL;
  uint16_t val_argv = 0;

  if (arg.GetLength() > 0) {
    val_argv = arg.GetLength();
    val_args = new JRawValueType[val_argv];
    for (int i = 0; i < val_argv; ++i) {
      val_args[i] = arg.Get(i)->raw_value();
    }
  }

  bool is_ok = jerry_api_call_function(_obj_val.u.v_object,
                                       this_obj_p,
                                       &res,
                                       val_args,
                                       val_argv);

  if (val_args) {
    delete [] val_args;
  }

  JResultType type = is_ok ? JRESULT_OK : JRESULT_EXCEPTION;

  return JResult(&res, type);
}
开发者ID:akosthekiss,项目名称:iotjs,代码行数:31,代码来源:iotjs_binding.cpp


示例3: RunIoTjs

static bool RunIoTjs(JObject* process) {
  // Evaluating 'iotjs.js' returns a function.
#ifndef ENABLE_SNAPSHOT
  JResult jmain = JObject::Eval(String(iotjs_s, iotjs_l), false, false);
#else
  JResult jmain = JObject::ExecSnapshot(iotjs_s, iotjs_l);
#endif
  IOTJS_ASSERT(jmain.IsOk());

  // Run the entry function passing process builtin.
  // The entry function will continue initializing process module, global, and
  // other native modules, and finally load and run application.
  JArgList args(1);
  args.Add(*process);

  JObject global(JObject::Global());
  JResult jmain_res = jmain.value().Call(global, args);

  if (jmain_res.IsException()) {
    UncaughtException(jmain_res.value());
    return false;
  } else {
    return true;
  }
}
开发者ID:2bright,项目名称:iotjs,代码行数:25,代码来源:iotjs.cpp


示例4: CreateBuffer

JObject CreateBuffer(size_t len) {
  JObject jglobal(JObject::Global());
  IOTJS_ASSERT(jglobal.IsObject());

  JObject jBuffer(jglobal.GetProperty("Buffer"));
  IOTJS_ASSERT(jBuffer.IsFunction());

  JArgList jargs(1);
  jargs.Add(JVal::Number((int)len));

  JResult jres(jBuffer.Call(JObject::Null(), jargs));
  IOTJS_ASSERT(jres.IsOk());
  IOTJS_ASSERT(jres.value().IsObject());

  return jres.value();
}
开发者ID:0-T-0,项目名称:iotjs,代码行数:16,代码来源:iotjs_module_buffer.cpp


示例5: iotjs_uart_destroy_platform_data

void iotjs_uart_destroy_platform_data(
    iotjs_uart_platform_data_t* platform_data) {
  IOTJS_ASSERT(platform_data);

  iotjs_string_destroy(&platform_data->device_path);
  IOTJS_RELEASE(platform_data);
}
开发者ID:MoonkiHong,项目名称:iotjs,代码行数:7,代码来源:iotjs_module_uart-tizenrt.c


示例6: iotjs_i2c_open

bool iotjs_i2c_open(iotjs_i2c_t* i2c) {
  IOTJS_VALIDATED_STRUCT_METHOD(iotjs_i2c_t, i2c)
  iotjs_i2c_platform_data_t* platform_data = _this->platform_data;
  IOTJS_ASSERT(platform_data);

  // Init i2c context
  platform_data->i2c_context = iotbus_i2c_init(platform_data->bus);
  if (!platform_data->i2c_context) {
    DLOG("%s: cannot open I2C", __func__);
    return false;
  }

  // Set i2c frequency
  int ret =
      iotbus_i2c_set_frequency(platform_data->i2c_context, IOTBUS_I2C_STD);
  if (ret < 0) {
    DLOG("%s: cannot set frequency", __func__);
    return false;
  }

  if (iotbus_i2c_set_address(platform_data->i2c_context, _this->address) < 0) {
    DLOG("%s: cannot set address", __func__);
    return false;
  }

  return true;
}
开发者ID:ziransun,项目名称:iotjs,代码行数:27,代码来源:iotjs_module_i2c-tizenrt.c


示例7: iotjs_https_jcallback

// Call any property of ClientRequest._Incoming
bool iotjs_https_jcallback(iotjs_https_t* https_data, const char* property,
                           const iotjs_jargs_t* jarg, bool resultvalue) {
  iotjs_jval_t* jthis = iotjs_https_jthis_from_https(https_data);
  bool retval = true;
  if (iotjs_jval_is_null(jthis))
    return retval;

  iotjs_jval_t jincoming =
      iotjs_jval_get_property(jthis, IOTJS_MAGIC_STRING__INCOMING);
  iotjs_jval_t cb = iotjs_jval_get_property(&jincoming, property);

  IOTJS_ASSERT(iotjs_jval_is_function(&cb));
  if (!resultvalue) {
    iotjs_make_callback(&cb, &jincoming, jarg);
  } else {
    iotjs_jval_t result =
        iotjs_make_callback_with_result(&cb, &jincoming, jarg);
    retval = iotjs_jval_as_boolean(&result);
    iotjs_jval_destroy(&result);
  }

  iotjs_jval_destroy(&jincoming);
  iotjs_jval_destroy(&cb);
  return retval;
}
开发者ID:drashti304,项目名称:TizenRT,代码行数:26,代码来源:iotjs_module_https.c


示例8: IOTJS_ASSERT

JObject::JObject(const String& v) {
  IOTJS_ASSERT(!v.IsEmpty());
  _obj_val.type = JERRY_API_DATA_TYPE_STRING;
  _obj_val.v_string = jerry_api_create_string(
      reinterpret_cast<const jerry_api_char_t*>(v.data()));
  _unref_at_close = true;
}
开发者ID:nunobrito,项目名称:iotjs,代码行数:7,代码来源:iotjs_binding.cpp


示例9: MakeStatObject

jerry_value_t MakeStatObject(uv_stat_t* statbuf) {
  const jerry_value_t fs = iotjs_module_get("fs");

  jerry_value_t stat_prototype =
      iotjs_jval_get_property(fs, IOTJS_MAGIC_STRING_STATS);
  IOTJS_ASSERT(jerry_value_is_object(stat_prototype));

  jerry_value_t jstat = jerry_create_object();
  iotjs_jval_set_prototype(jstat, stat_prototype);

  jerry_release_value(stat_prototype);


#define X(statobj, name) \
  iotjs_jval_set_property_number(statobj, #name, statbuf->st_##name);

  X(jstat, dev)
  X(jstat, mode)
  X(jstat, nlink)
  X(jstat, uid)
  X(jstat, gid)
  X(jstat, rdev)
  X(jstat, blksize)
  X(jstat, ino)
  X(jstat, size)
  X(jstat, blocks)

#undef X

  return jstat;
}
开发者ID:MoonkiHong,项目名称:iotjs,代码行数:31,代码来源:iotjs_module_fs.c


示例10: iotjs_uart_handlewrap_close_cb

void iotjs_uart_handlewrap_close_cb(uv_handle_t* handle) {
  iotjs_uart_t* uart = (iotjs_uart_t*)handle->data;

  if (close(uart->device_fd) < 0) {
    DLOG(iotjs_periph_error_str(kUartOpClose));
    IOTJS_ASSERT(0);
  }
}
开发者ID:MoonkiHong,项目名称:iotjs,代码行数:8,代码来源:iotjs_module_uart-tizenrt.c


示例11: JObjectWrap

BufferWrap::BufferWrap(JObject& jbuiltin,
                       size_t length)
    : JObjectWrap(jbuiltin)
    , _buffer(NULL)
    , _length(length) {
  _buffer = AllocBuffer(length);
  IOTJS_ASSERT(_buffer != NULL);
}
开发者ID:VandeurenGlenn,项目名称:iotjs,代码行数:8,代码来源:iotjs_module_buffer.cpp


示例12: IOTJS_ASSERT

void JHandlerInfo::Throw(JObject& ret) {
  IOTJS_ASSERT(_thrown == false);

  ret.Ref();
  *_ret_val_p = ret.raw_value();

  _thrown = true;
}
开发者ID:0-T-0,项目名称:iotjs,代码行数:8,代码来源:iotjs_binding.cpp


示例13: iotjs_spi_set_buffer

static void iotjs_spi_set_buffer(iotjs_spi_t* spi, const iotjs_jval_t* jtx_buf,
                                 const iotjs_jval_t* jrx_buf) {
  IOTJS_VALIDATED_STRUCT_METHOD(iotjs_spi_t, spi);

  iotjs_bufferwrap_t* tx_buf = iotjs_bufferwrap_from_jbuffer(jtx_buf);
  iotjs_bufferwrap_t* rx_buf = iotjs_bufferwrap_from_jbuffer(jrx_buf);

  _this->tx_buf_data = iotjs_bufferwrap_buffer(tx_buf);
  uint8_t tx_buf_len = iotjs_bufferwrap_length(tx_buf);
  _this->rx_buf_data = iotjs_bufferwrap_buffer(rx_buf);
  uint8_t rx_buf_len = iotjs_bufferwrap_length(rx_buf);

  IOTJS_ASSERT(_this->tx_buf_data != NULL && _this->rx_buf_data != NULL);
  IOTJS_ASSERT(tx_buf_len > 0 && rx_buf_len > 0 && tx_buf_len == rx_buf_len);

  _this->buf_len = tx_buf_len;
}
开发者ID:drashti304,项目名称:TizenRT,代码行数:17,代码来源:iotjs_module_spi.c


示例14: iotjs_bufferwrap_from_jbuffer

iotjs_bufferwrap_t* iotjs_bufferwrap_from_jbuffer(const iotjs_jval_t* jbuffer) {
  IOTJS_ASSERT(iotjs_jval_is_object(jbuffer));
  iotjs_jval_t jbuiltin =
      iotjs_jval_get_property(jbuffer, IOTJS_MAGIC_STRING__BUILTIN);
  iotjs_bufferwrap_t* buffer = iotjs_bufferwrap_from_jbuiltin(&jbuiltin);
  iotjs_jval_destroy(&jbuiltin);
  return buffer;
}
开发者ID:drashti304,项目名称:TizenRT,代码行数:8,代码来源:iotjs_module_buffer.c


示例15: JObjectWrap

JObjectWrap::JObjectWrap(JObject& jobject, JObject& jholder)
    : JObjectWrap(jobject) {
  IOTJS_ASSERT(jholder.IsObject() || jholder.IsNull() || jholder.IsUndefined());

  if (jholder.IsObject()) {
    set_jholder(jholder);
  }
}
开发者ID:codemeow5,项目名称:iotjs,代码行数:8,代码来源:iotjs_objectwrap.cpp


示例16: JHANDLER_FUNCTION

JHANDLER_FUNCTION(Close, handler) {
  IOTJS_ASSERT(handler.GetThis()->IsObject());
  IOTJS_ASSERT(handler.GetArgLength() >= 1);
  IOTJS_ASSERT(handler.GetArg(0)->IsNumber());

  Environment* env = Environment::GetEnv();

  int fd = handler.GetArg(0)->GetInt32();

  if (handler.GetArgLength() > 1 && handler.GetArg(1)->IsFunction()) {
    FS_ASYNC(env, close, handler.GetArg(1), fd);
  } else {
    FS_SYNC(env, close, fd);
  }

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


示例17: AfterShutdown

static void AfterShutdown(uv_shutdown_t* req, int status) {
  ShutdownReqWrap* req_wrap = reinterpret_cast<ShutdownReqWrap*>(req->data);
  TcpWrap* tcp_wrap = reinterpret_cast<TcpWrap*>(req->handle->data);
  IOTJS_ASSERT(req_wrap != NULL);
  IOTJS_ASSERT(tcp_wrap != NULL);

  // function onShutdown(status)
  JObject jonshutdown(req_wrap->jcallback());
  IOTJS_ASSERT(jonshutdown.IsFunction());

  JArgList args(1);
  args.Add(JVal::Number(status));

  MakeCallback(jonshutdown, JObject::Null(), args);

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


示例18: iotjs_jhelper_call_ok

iotjs_jval_t iotjs_jhelper_call_ok(const iotjs_jval_t* jfunc,
                                   const iotjs_jval_t* jthis,
                                   const iotjs_jargs_t* jargs) {
  bool throws;
  iotjs_jval_t jres = iotjs_jhelper_call(jfunc, jthis, jargs, &throws);
  IOTJS_ASSERT(!throws);
  return jres;
}
开发者ID:esevan,项目名称:iotjs,代码行数:8,代码来源:iotjs_binding.c


示例19: iotjs_jval_get_object_native_handle

uintptr_t iotjs_jval_get_object_native_handle(const iotjs_jval_t* jobj) {
  const IOTJS_VALIDATED_STRUCT_METHOD(iotjs_jval_t, jobj);
  IOTJS_ASSERT(iotjs_jval_is_object(jobj));

  uintptr_t ptr;
  jerry_get_object_native_handle(_this->value, &ptr);
  return ptr;
}
开发者ID:esevan,项目名称:iotjs,代码行数:8,代码来源:iotjs_binding.c


示例20: iotjs_jval_set_object_native_handle

void iotjs_jval_set_object_native_handle(const iotjs_jval_t* jobj,
                                         uintptr_t ptr,
                                         JFreeHandlerType free_handler) {
  const IOTJS_VALIDATED_STRUCT_METHOD(iotjs_jval_t, jobj);
  IOTJS_ASSERT(iotjs_jval_is_object(jobj));

  jerry_set_object_native_handle(_this->value, ptr, free_handler);
}
开发者ID:esevan,项目名称:iotjs,代码行数:8,代码来源:iotjs_binding.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ IOTJS_VALIDATED_STRUCT_METHOD函数代码示例发布时间:2022-05-30
下一篇:
C++ IOSleep函数代码示例发布时间: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