Ejemplo n.º 1
0
static bool StartIoTjs(JObject* process) {

  // Get jerry global object.
  JObject global = JObject::Global();

  // Create environtment.
  Environment env(uv_default_loop());

  // Bind environment to global object.
  global.SetNative((uintptr_t)(&env), NULL);

  // Call the entry.
  // load and call iotjs.js
  InitIoTjs(process);

  bool more;
  do {
    more = uv_run(env.loop(), UV_RUN_ONCE);
    more |= ProcessNextTick();
    if (more == false) {
      more = uv_loop_alive(env.loop());
    }
  } while (more);

  ProcessEmitExit(0);

  return true;
}
Ejemplo n.º 2
0
static bool StartIoTjs(Environment* env) {
  // Get jerry global object.
  JObject global = JObject::Global();

  // Bind environment to global object.
  global.SetNative((uintptr_t)(env), NULL);

  // Initialize builtin modules.
  JObject* process = InitModules();

  // Call the entry.
  // load and call iotjs.js
  env->GoStateRunningMain();

  RunIoTjs(process);

  // Run event loop.
  env->GoStateRunningLoop();

  bool more;
  do {
    more = uv_run(env->loop(), UV_RUN_ONCE);
    more |= ProcessNextTick();
    if (more == false) {
      more = uv_loop_alive(env->loop());
    }
  } while (more);

  env->GoStateExiting();

  // Emit 'exit' event.
  ProcessEmitExit(0);

  // Release bulitin modules.
  CleanupModules();

  return true;
}