| 612 | } |
| 613 | |
| 614 | DEFINE_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 | |
| 651 | DEFINE_INTERNAL_CALL(void) ObjectInternal_ManagedInstanceCreated(MObject* managedInstance, MClass* typeClass) |
| 652 | { |
nothing calls this directly
no test coverage detected