예제 #1
0
JResult JObject::Call(JObject& this_, JArgList& arg) {
  IOTJS_ASSERT(IsFunction());

  JRawObjectType* this_obj_p = this_.IsNull() ? NULL
                                              : this_.raw_value().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.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);
}
예제 #2
0
JObjectWrap::JObjectWrap(JObject& jobject, JObject& jholder)
    : JObjectWrap(jobject) {
  IOTJS_ASSERT(jholder.IsObject() || jholder.IsNull() || jholder.IsUndefined());

  if (jholder.IsObject()) {
    set_jholder(jholder);
  }
}