コード例 #1
0
ファイル: lua.cpp プロジェクト: parisfuja/RR-source
    bool Environment::init() {
        getGlobal("_E");

        if (!isTable(-1)) {
            newTable(regFunctions->length());
            lua_setglobal(L, "_E");
        }
        pop(1);


        loopv(*regFunctions) {
            (*regFunctions)[i]();

        }

        delete regFunctions;

    luvit_init(L, uv_default_loop());
#ifdef SERVER

      /* Pull up the preload table */
    select("package", "preload");

    pushRow("native_server", server::lua::luaopen_server);

    pop(2);
#endif
#ifdef LUA_PANIC_DEBUG
    #pragma message("Using lua atpanic crasher.")
    lua_atpanic(L, crash);
#endif
        isInitialized = true;

        return true;
    }
コード例 #2
0
ファイル: luvit_main.c プロジェクト: sousoux/luvit
int main(int argc, char *argv[])
{
  lua_State *L;
  uv_loop_t *loop;

  argv = uv_setup_args(argc, argv);

  L = luaL_newstate();
  if (L == NULL) {
    fprintf(stderr, "luaL_newstate has failed\n");
    return 1;
  }

  luaL_openlibs(L);

  loop = uv_default_loop();

#ifdef LUV_EXPORTS
  luvit__suck_in_symbols();
#endif

#ifdef USE_OPENSSL
  luvit_init_ssl();
#endif

  if (luvit_init(L, loop, argc, argv)) {
    fprintf(stderr, "luvit_init has failed\n");
    return 1;
  }

  /* Run the main lua script */
  if (luvit_run(L)) {
    int saved_flags = fcntl(STDOUT_FILENO, F_GETFL);
    fcntl(STDOUT_FILENO, F_SETFL, saved_flags & ~O_NONBLOCK);
    fprintf(stderr, "%s\n", lua_tostring(L, -1));
    lua_pop(L, 1);
    lua_close(L);
    return -1;
  }

  lua_close(L);
  int saved_flags = fcntl(STDOUT_FILENO, F_GETFL);
  fcntl(STDOUT_FILENO, F_SETFL, saved_flags & ~O_NONBLOCK);
  return 0;
}
コード例 #3
0
ファイル: virgo_lua.c プロジェクト: cp16net/virgo-base
static void
virgo__lua_luvit_init(virgo_t *v) {
  /* Hack to keep the linker from killing symbols that luajit pulls in at runtime :( */
  lua_State *L;
  virgo__suck_in_symbols();
  luvit__suck_in_symbols();
  L = v->L;

  luvit_init(L, uv_default_loop(), v->argc, v->argv);

  /* Pull up the preload table */
  lua_getglobal(L, "package");
  lua_getfield(L, -1, "preload");
  lua_remove(L, -2);

  /* Register constants */
  lua_pushcfunction(L, virgo__lua_logging_open);
  lua_setfield(L, -2, "logging");

  lua_pop(L, 1);
}