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; } }
static bool InitIoTjs(JObject* process) { JResult jmain = JObject::Eval(String(mainjs), false, false); IOTJS_ASSERT(jmain.IsOk()); 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; } }
JObject JObject::CallOk(JObject& this_, JArgList& arg) { JResult jres = Call(this_, arg); IOTJS_ASSERT(jres.IsOk()); return jres.value(); }