MCPcopy Create free account
hub / github.com/defold/defold / InitializeModule

Function InitializeModule

engine/script/src/script_module.cpp:215–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

213 }
214
215 void InitializeModule(lua_State* L)
216 {
217 int top = lua_gettop(L);
218 (void) top;
219 lua_getfield(L, LUA_GLOBALSINDEX, "package");
220 if (lua_istable(L, -1))
221 {
222 assert(lua_istable(L, -1));
223
224 // NOTE: We replace package.loaders table
225 // only our custom loader
226 lua_newtable(L);
227 lua_pushcfunction(L, LoadModule);
228 lua_rawseti(L, -2, 1);
229 lua_setfield(L, -2, "loaders");
230 lua_pop(L, 1);
231 }
232 else
233 {
234 // Bare-bone lua, no libs opened. We don't created the package table.
235 lua_pop(L, 1);
236 }
237 assert(top == lua_gettop(L));
238 }
239
240}

Callers 1

InitializeFunction · 0.85

Calls 5

lua_gettopFunction · 0.85
lua_getfieldFunction · 0.85
lua_rawsetiFunction · 0.85
lua_setfieldFunction · 0.85
assertFunction · 0.50

Tested by

no test coverage detected