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

Function RegisterType

engine/resource/src/resource.cpp:489–527  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

487
488
489Result RegisterType(HFactory factory,
490 const char* extension,
491 void* context,
492 FResourcePreload preload_function,
493 FResourceCreate create_function,
494 FResourcePostCreate post_create_function,
495 FResourceDestroy destroy_function,
496 FResourceRecreate recreate_function)
497{
498 HResourceType type = FindResourceType(factory, extension);
499 if (type != 0)
500 {
501 dmLogError("Resource type %s already registered!", extension);
502 return RESULT_ALREADY_REGISTERED;
503 }
504
505 type = AllocateResourceType(factory, extension);
506 if (!type)
507 {
508 return RESULT_INVAL;
509 }
510
511 type->m_ExtensionHash = dmHashString64(extension);
512 type->m_Extension = extension;
513 type->m_Context = context;
514 type->m_PreloadFunction = (::FResourcePreload)preload_function;
515 type->m_CreateFunction = (::FResourceCreate)create_function;
516 type->m_PostCreateFunction = (::FResourcePostCreate)post_create_function;
517 type->m_DestroyFunction = (::FResourceDestroy)destroy_function;
518 type->m_RecreateFunction = (::FResourceRecreate)recreate_function;
519
520 Result result = ValidateResourceType(type);
521 if (result != RESULT_OK)
522 {
523 FreeResourceType(factory, type);
524 }
525
526 return result;
527}
528
529Result SetupType(HResourceTypeContext ctx,
530 HResourceType type,

Callers 15

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
SetUpMethod · 0.85
SetUpMethod · 0.85

Calls 4

FindResourceTypeFunction · 0.85
AllocateResourceTypeFunction · 0.85
ValidateResourceTypeFunction · 0.85
FreeResourceTypeFunction · 0.85

Tested by 15

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
SetUpMethod · 0.68
SetUpMethod · 0.68