Always run default init script

This commit is contained in:
Yevgen Muntyan 2011-01-22 01:34:49 -08:00
parent 8f5c0615de
commit e5328da2b7
5 changed files with 17 additions and 17 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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))