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

Function AddModule

engine/script/src/script_module.cpp:114–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112 }
113
114 Result AddModule(HContext context, dmLuaDDF::LuaSource *source, const char *script_name, void* resource, dmhash_t path_hash)
115 {
116 dmhash_t module_hash = dmHashString64(script_name);
117
118
119 Module module;
120 module.m_Name = strdup(script_name);
121
122 const char *buf;
123 uint32_t size;
124 GetLuaSource(source, &buf, &size);
125
126 module.m_Script = (char*) malloc(size);
127 module.m_ScriptSize = size;
128 memcpy(module.m_Script, buf, size);
129
130 module.m_Resource = resource;
131 module.m_Filename = strdup(source->m_Filename);
132
133 if (context->m_Modules.Full())
134 {
135 context->m_Modules.SetCapacity(127, context->m_Modules.Capacity() + 128);
136 context->m_PathToModule.SetCapacity(127, context->m_PathToModule.Capacity() + 128);
137 }
138
139 context->m_Modules.Put(module_hash, module);
140 Module* module_handle = context->m_Modules.Get(module_hash);
141 context->m_PathToModule.Put(path_hash, module_handle);
142
143 return RESULT_OK;
144 }
145
146 Result ReloadModule(HContext context, dmLuaDDF::LuaSource *source, dmhash_t path_hash)
147 {

Callers 2

RegisterSubModulesFunction · 0.85
TEST_FFunction · 0.85

Calls 7

GetLuaSourceFunction · 0.85
mallocFunction · 0.85
FullMethod · 0.45
SetCapacityMethod · 0.45
CapacityMethod · 0.45
PutMethod · 0.45
GetMethod · 0.45

Tested by 1

TEST_FFunction · 0.68