diff options
Diffstat (limited to 'src/tools.c')
-rw-r--r-- | src/tools.c | 43 |
1 files changed, 0 insertions, 43 deletions
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_ | |||
64 | char const* const CONFIG_REGKEY = "ee932492-a654-4506-9da8-f16540bdb5d4"; | 64 | char const* const CONFIG_REGKEY = "ee932492-a654-4506-9da8-f16540bdb5d4"; |
65 | char const* const LOOKUP_REGKEY = "ddea37aa-50c7-4d3f-8e0b-fb7a9d62bac5"; | 65 | char const* const LOOKUP_REGKEY = "ddea37aa-50c7-4d3f-8e0b-fb7a9d62bac5"; |
66 | 66 | ||
67 | /* | ||
68 | * ############################################################################################### | ||
69 | * ######################################### Lua 5.1/5.2 ######################################### | ||
70 | * ############################################################################################### | ||
71 | */ | ||
72 | |||
73 | /* | ||
74 | ** Copied from Lua 5.2 loadlib.c | ||
75 | */ | ||
76 | #if LUA_VERSION_NUM == 501 | ||
77 | static int luaL_getsubtable (lua_State *L, int idx, const char *fname) | ||
78 | { | ||
79 | lua_getfield(L, idx, fname); | ||
80 | if (lua_istable(L, -1)) | ||
81 | return 1; /* table already there */ | ||
82 | else | ||
83 | { | ||
84 | lua_pop(L, 1); /* remove previous result */ | ||
85 | idx = lua_absindex(L, idx); | ||
86 | lua_newtable(L); | ||
87 | lua_pushvalue(L, -1); /* copy to be left at top */ | ||
88 | lua_setfield(L, idx, fname); /* assign new table to field */ | ||
89 | return 0; /* false, because did not find table there */ | ||
90 | } | ||
91 | } | ||
92 | |||
93 | void luaL_requiref (lua_State *L, const char *modname, lua_CFunction openf, int glb) | ||
94 | { | ||
95 | lua_pushcfunction(L, openf); | ||
96 | lua_pushstring(L, modname); /* argument to open function */ | ||
97 | lua_call(L, 1, 1); /* open module */ | ||
98 | luaL_getsubtable(L, LUA_REGISTRYINDEX, "_LOADED"); | ||
99 | lua_pushvalue(L, -2); /* make copy of module (call result) */ | ||
100 | lua_setfield(L, -2, modname); /* _LOADED[modname] = module */ | ||
101 | lua_pop(L, 1); /* remove _LOADED table */ | ||
102 | if (glb) | ||
103 | { | ||
104 | lua_pushvalue(L, -1); /* copy of 'mod' */ | ||
105 | lua_setglobal(L, modname); /* _G[modname] = module */ | ||
106 | } | ||
107 | } | ||
108 | #endif // LUA_VERSION_NUM | ||
109 | |||
110 | DEBUGSPEW_CODE( char const* debugspew_indent = "----+----!----+----!----+----!----+----!----+----!----+----!----+----!----+"); | 67 | DEBUGSPEW_CODE( char const* debugspew_indent = "----+----!----+----!----+----!----+----!----+----!----+----!----+----!----+"); |
111 | 68 | ||
112 | 69 | ||