示例#1
0
// Make a callback for the given `function` with `this_` binding and `args`
// arguments. The next tick callbacks registered via `process.nextTick()`
// will be called after the callback function `function` returns.
void iotjs_make_callback(const iotjs_jval_t* jfunction,
                         const iotjs_jval_t* jthis,
                         const iotjs_jargs_t* jargs) {
  iotjs_jval_t result =
      iotjs_make_callback_with_result(jfunction, jthis, jargs);
  iotjs_jval_destroy(&result);
}
示例#2
0
// 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;
}