From d8cfb248939a9b6e1cbc9bb4c05b216daf9a0e3a Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Thu, 3 Apr 2014 16:23:52 +0200 Subject: moved compatibility code in a separate file --- src/tools.c | 43 ------------------------------------------- 1 file changed, 43 deletions(-) (limited to 'src/tools.c') diff --git a/src/tools.c b/src/tools.c index ea7662b..d2b316b 100644 --- a/src/tools.c +++ b/src/tools.c @@ -64,49 +64,6 @@ void ASSERT_IMPL( lua_State* L, bool_t cond_, char const* file_, int const line_ char const* const CONFIG_REGKEY = "ee932492-a654-4506-9da8-f16540bdb5d4"; char const* const LOOKUP_REGKEY = "ddea37aa-50c7-4d3f-8e0b-fb7a9d62bac5"; -/* - * ############################################################################################### - * ######################################### Lua 5.1/5.2 ######################################### - * ############################################################################################### - */ - -/* -** Copied from Lua 5.2 loadlib.c -*/ -#if LUA_VERSION_NUM == 501 -static int luaL_getsubtable (lua_State *L, int idx, const char *fname) -{ - lua_getfield(L, idx, fname); - if (lua_istable(L, -1)) - return 1; /* table already there */ - else - { - lua_pop(L, 1); /* remove previous result */ - idx = lua_absindex(L, idx); - lua_newtable(L); - lua_pushvalue(L, -1); /* copy to be left at top */ - lua_setfield(L, idx, fname); /* assign new table to field */ - return 0; /* false, because did not find table there */ - } -} - -void luaL_requiref (lua_State *L, const char *modname, lua_CFunction openf, int glb) -{ - lua_pushcfunction(L, openf); - lua_pushstring(L, modname); /* argument to open function */ - lua_call(L, 1, 1); /* open module */ - luaL_getsubtable(L, LUA_REGISTRYINDEX, "_LOADED"); - lua_pushvalue(L, -2); /* make copy of module (call result) */ - lua_setfield(L, -2, modname); /* _LOADED[modname] = module */ - lua_pop(L, 1); /* remove _LOADED table */ - if (glb) - { - lua_pushvalue(L, -1); /* copy of 'mod' */ - lua_setglobal(L, modname); /* _G[modname] = module */ - } -} -#endif // LUA_VERSION_NUM - DEBUGSPEW_CODE( char const* debugspew_indent = "----+----!----+----!----+----!----+----!----+----!----+----!----+----!----+"); -- cgit v1.2.3-55-g6feb