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

Function RegisterTypes

engine/resource/src/resource_type.cpp:142–180  ·  view source on GitHub ↗

add already registered types

Source from the content-addressed store, hash-verified

140
141// add already registered types
142Result RegisterTypes(HFactory factory, dmHashTable64<void*>* contexts)
143{
144 const TypeCreatorDesc* desc = GetFirstTypeCreatorDesc();
145 while (desc)
146 {
147 if (contexts->Full()) {
148 uint32_t capacity = contexts->Capacity() + 8;
149 contexts->SetCapacity(capacity/2, capacity);
150 }
151
152 ResourceTypeContext ctx;
153 ctx.m_Factory = factory;
154 ctx.m_Contexts = contexts;
155
156 HResourceType type = dmResource::AllocateResourceType(factory, desc->m_Name);
157 type->m_Extension = desc->m_Name;
158 type->m_ExtensionHash = dmHashString64(desc->m_Name);
159
160 Result result = (Result)desc->m_RegisterFn(&ctx, type);
161 if (result != RESULT_OK)
162 {
163 dmLogError("Failed to register type '%s': %s", desc->m_Name, ResultToString(result));
164 return result;
165 }
166
167 result = dmResource::ValidateResourceType(type);
168 if (dmResource::RESULT_OK != result)
169 {
170 dmResource::FreeResourceType(factory, type);
171 dmLogDebug("Failed to register type '%s'", desc->m_Name);
172 }
173 else
174 {
175 dmLogDebug("Registered type '%s'", desc->m_Name);
176 }
177 desc = desc->m_Next;
178 }
179 return RESULT_OK;
180}
181
182Result DeregisterTypes(HFactory factory, dmHashTable64<void*>* contexts)
183{

Callers 15

SetUpMethod · 0.85
SetUpMethod · 0.85
SetUpMethod · 0.85
SetUpMethod · 0.85
SetUpMethod · 0.85
SetUpMethod · 0.85
TESTFunction · 0.85
SetUpMethod · 0.85
SetUpMethod · 0.85
SetUpMethod · 0.85
SetUpMethod · 0.85
SetUpMethod · 0.85

Calls 8

GetFirstTypeCreatorDescFunction · 0.85
AllocateResourceTypeFunction · 0.85
ValidateResourceTypeFunction · 0.85
FreeResourceTypeFunction · 0.85
ResultToStringFunction · 0.70
FullMethod · 0.45
CapacityMethod · 0.45
SetCapacityMethod · 0.45

Tested by 15

SetUpMethod · 0.68
SetUpMethod · 0.68
SetUpMethod · 0.68
SetUpMethod · 0.68
SetUpMethod · 0.68
SetUpMethod · 0.68
TESTFunction · 0.68
SetUpMethod · 0.68
SetUpMethod · 0.68
SetUpMethod · 0.68
SetUpMethod · 0.68
SetUpMethod · 0.68