示例#1
0
int Start(char* src) {
  if (!InitJerry()) {
    DLOG("InitJerry failed");
    return 1;
  }

  JObject* process = InitModules();

  // FIXME: this should be moved to seperate function
  {
    JObject argv;
    argv.SetProperty("1", JObject(src));
    process->SetProperty("argv", argv);
  }

  if (!StartIoTjs(process)) {
    DLOG("StartIoTJs failed");
    return 1;
  }

  CleanupModules();

  ReleaseJerry();

  return 0;
}
示例#2
0
文件: iotjs.cpp 项目: 2bright/iotjs
int Start(int argc, char** argv) {
  // Initialize debug print.
  InitDebugSettings();

  // Create environtment.
  Environment* env = Environment::GetEnv();

  // Parse command line arguemnts.
  if (!env->ParseCommandLineArgument(argc, argv)) {
    DLOG("ParseCommandLineArgument failed");
    return 1;
  }

  // Set event loop.
  env->set_loop(uv_default_loop());

  // Initalize JerryScript engine.
  if (!InitJerry(env)) {
    DLOG("InitJerry failed");
    return 1;
  }

  // Start IoT.js
  if (!StartIoTjs(env)) {
    DLOG("StartIoTJs failed");
    return 1;
  }

  // close uv loop.
  //uv_stop(env->loop());
  uv_walk(env->loop(), UvWalkToCloseCallback, NULL);
  uv_run(env->loop(), UV_RUN_DEFAULT);

  int res = uv_loop_close(env->loop());
  IOTJS_ASSERT(res == 0);

  // Release JerryScript engine.
  ReleaseJerry();

  // Release environment.
  Environment::Release();

  // Release debug print setting.
  ReleaseDebugSettings();

  return 0;
}
示例#3
0
文件: iotjs.cpp 项目: bozzmob/iotjs
int Start(int argc, char** argv) {
  InitDebugSettings();

  // Initalize JerryScript engine.
  if (!InitJerry()) {
    DLOG("InitJerry failed");
    return 1;
  }

  // Create environtment.
  Environment* env = Environment::GetEnv();

  // Init environment with argument and uv loop.
  env->Init(argc, argv, uv_default_loop());

  // Start IoT.js
  if (!StartIoTjs(env)) {
    DLOG("StartIoTJs failed");
    return 1;
  }

  // close uv loop.
  //uv_stop(env->loop());
  uv_walk(env->loop(), UvWalkToCloseCallback, NULL);
  uv_run(env->loop(), UV_RUN_DEFAULT);

  int res = uv_loop_close(env->loop());
  IOTJS_ASSERT(res == 0);

  // Release JerryScript engine.
  ReleaseJerry();

  ReleaseDebugSettings();

  return 0;
}