diff --git a/moo/moolua/medit-lua.cpp b/moo/moolua/medit-lua.cpp index 6eaf2db3..270975c6 100644 --- a/moo/moolua/medit-lua.cpp +++ b/moo/moolua/medit-lua.cpp @@ -30,7 +30,7 @@ moo_lua_state_init (MooLuaState *lua) { try { - lua->L = medit_lua_new (true); + lua->L = medit_lua_new (); } catch (...) { @@ -141,9 +141,8 @@ add_raw_api (lua_State *L) return true; } -bool -medit_lua_setup (lua_State *L, - bool default_init) +static bool +medit_lua_setup (lua_State *L) { try { @@ -154,8 +153,11 @@ medit_lua_setup (lua_State *L, g_assert (lua_gettop (L) == 0); - if (default_init) - medit_lua_do_string (L, LUA_DEFAULT_INIT); + if (!medit_lua_do_string (L, LUA_DEFAULT_INIT)) + { + g_critical ("oops"); + return false; + } return true; } @@ -195,7 +197,7 @@ lua_panic (lua_State *L) } lua_State * -medit_lua_new (bool default_init) +medit_lua_new () { lua_State *L = luaL_newstate (); g_return_val_if_fail (L != NULL, NULL); @@ -211,7 +213,7 @@ medit_lua_new (bool default_init) moo_assert (lua_gettop (L) == 0); - if (!medit_lua_setup (L, default_init)) + if (!medit_lua_setup (L)) { medit_lua_data_free (data); lua_close (L); @@ -341,7 +343,7 @@ extern "C" void medit_lua_run_string (const char *string) { g_return_if_fail (string != NULL); - lua_State *L = medit_lua_new (TRUE); + lua_State *L = medit_lua_new (); if (L) medit_lua_do_string (L, string); medit_lua_free (L); @@ -351,7 +353,7 @@ extern "C" void medit_lua_run_file (const char *filename) { g_return_if_fail (filename != NULL); - lua_State *L = medit_lua_new (TRUE); + lua_State *L = medit_lua_new (); if (L) medit_lua_do_file (L, filename); medit_lua_free (L); diff --git a/moo/moolua/medit-lua.h b/moo/moolua/medit-lua.h index 99c8c089..f0e206d7 100644 --- a/moo/moolua/medit-lua.h +++ b/moo/moolua/medit-lua.h @@ -7,10 +7,7 @@ #include "moolua/lua/moolua.h" -bool medit_lua_setup (lua_State *L, - bool default_init); - -lua_State *medit_lua_new (bool default_init); +lua_State *medit_lua_new (void); void medit_lua_ref (lua_State *L); void medit_lua_unref (lua_State *L); void medit_lua_free (lua_State *L); diff --git a/moo/moolua/moolua-tests.cpp b/moo/moolua/moolua-tests.cpp index cf06f353..0aa895e0 100644 --- a/moo/moolua/moolua-tests.cpp +++ b/moo/moolua/moolua-tests.cpp @@ -66,7 +66,7 @@ moo_test_run_lua_file (const char *basename) if ((contents = moo_test_load_data_file (filename))) { - lua_State *L = medit_lua_new (true); + lua_State *L = medit_lua_new (); g_return_if_fail (L != NULL); g_assert (lua_gettop (L) == 0); diff --git a/moo/moolua/mooluaplugin.cpp b/moo/moolua/mooluaplugin.cpp index 75d7bd60..47a54f4f 100644 --- a/moo/moolua/mooluaplugin.cpp +++ b/moo/moolua/mooluaplugin.cpp @@ -40,7 +40,8 @@ struct MooLuaPlugin { static MooLuaModule * moo_lua_module_load (const char *filename) { - lua_State *L = medit_lua_new (true); + lua_State *L = medit_lua_new (); + if (!L) return NULL; diff --git a/moo/plugins/usertools/moocommand-script.cpp b/moo/plugins/usertools/moocommand-script.cpp index 8a6a4a67..35922e3a 100644 --- a/moo/plugins/usertools/moocommand-script.cpp +++ b/moo/plugins/usertools/moocommand-script.cpp @@ -58,7 +58,7 @@ moo_command_script_run_lua (MooCommandScript *cmd, g_return_if_fail (cmd->code != NULL); - L = medit_lua_new (TRUE); + L = medit_lua_new (); g_return_if_fail (L != NULL); if (!medit_lua_do_string (L, LUA_TOOL_SETUP_LUA))