MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / ObjectInternal_Create2

Function ObjectInternal_Create2

Source/Engine/Scripting/ScriptingObject.cpp:614–649  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

612}
613
614DEFINE_INTERNAL_CALL(MObject*) ObjectInternal_Create2(MString* typeNameObj)
615{
616 // Get typename
617 if (typeNameObj == nullptr)
618 DebugLog::ThrowArgumentNull("typeName");
619 const StringView typeNameChars = MCore::String::GetChars(typeNameObj);
620 const StringAsANSI<100> typeNameData(typeNameChars.Get(), typeNameChars.Length());
621 const StringAnsiView typeName(typeNameData.Get(), typeNameChars.Length());
622
623 // Try to find the scripting type for this typename
624 const ScriptingTypeHandle type = Scripting::FindScriptingType(typeName);
625 if (!type)
626 {
627 LOG(Error, "Cannot find scripting type for \'{0}\'.", String(typeName));
628 return nullptr;
629 }
630
631 // Create unmanaged object
632 const ScriptingObjectSpawnParams params(Guid::New(), type);
633 ScriptingObject* obj = type.GetType().Script.Spawn(params);
634 if (obj == nullptr)
635 {
636 LOG(Error, "Failed to spawn object of type \'{0}\'.", String(typeName));
637 return nullptr;
638 }
639
640 // Create managed object
641 MObject* managedInstance = obj->GetOrCreateManagedInstance();
642 if (managedInstance == nullptr)
643 {
644 LOG(Error, "Cannot create managed instance for type \'{0}\'.", String(typeName));
645 Delete(obj);
646 }
647
648 return managedInstance;
649}
650
651DEFINE_INTERNAL_CALL(void) ObjectInternal_ManagedInstanceCreated(MObject* managedInstance, MClass* typeClass)
652{

Callers

nothing calls this directly

Calls 9

FindScriptingTypeFunction · 0.85
DeleteFunction · 0.85
StringFunction · 0.50
NewFunction · 0.50
GetMethod · 0.45
LengthMethod · 0.45
SpawnMethod · 0.45
GetTypeMethod · 0.45

Tested by

no test coverage detected