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

Function LoadModule

engine/script/src/script_module.cpp:88–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86 }
87
88 static int LoadModule(lua_State *L) {
89 int top = lua_gettop(L);
90 (void) top;
91
92 HContext context = dmScript::GetScriptContext(L);
93
94 const char *name = luaL_checkstring(L, 1);
95 dmhash_t name_hash = dmHashString64(name);
96 Module* module = context->m_Modules.Get(name_hash);
97
98 if (module == NULL)
99 {
100 lua_pushfstring(L, "\n\tno file '%s'", name);
101 assert(top + 1 == lua_gettop(L));
102 return 1;
103 }
104
105 if (!LuaLoadModule(L, module->m_Script, module->m_ScriptSize, module->m_Filename))
106 {
107 luaL_error(L, "error loading module '%s'from file '%s':\n\t%s",
108 lua_tostring(L, 1), name, lua_tostring(L, -1));
109 }
110 assert(top + 1 == lua_gettop(L));
111 return 1;
112 }
113
114 Result AddModule(HContext context, dmLuaDDF::LuaSource *source, const char *script_name, void* resource, dmhash_t path_hash)
115 {

Callers

nothing calls this directly

Calls 7

lua_gettopFunction · 0.85
lua_pushfstringFunction · 0.85
LuaLoadModuleFunction · 0.85
luaL_errorFunction · 0.85
GetScriptContextFunction · 0.70
assertFunction · 0.50
GetMethod · 0.45

Tested by

no test coverage detected