Merge branch '1.5' into dotnet7

# Conflicts:
#	Source/Platforms/DotNet/NUnit/agents/net40/nunit-agent.exe
#	Source/Platforms/DotNet/NUnit/agents/net40/nunit.engine.api.dll
#	Source/Platforms/DotNet/NUnit/agents/net40/nunit.engine.core.dll
#	Source/Platforms/DotNet/NUnit/agents/net7.0/nunit.agent.addins
#	Source/Platforms/DotNet/NUnit/nunit.engine.api.dll
#	Source/Platforms/DotNet/NUnit/nunit.engine.core.dll
#	Source/Platforms/DotNet/NUnit/nunit.engine.dll
#	Source/Platforms/DotNet/NUnit/nunit3-console.exe
#	Source/Platforms/DotNet/NUnit/nunit3-console.exe.config
#	Source/Platforms/DotNet/NUnit/testcentric.engine.metadata.dll
#	Source/Tools/Flax.Build/Deps/Downloader.cs
#	Source/Tools/Flax.Stats/CodeFrame.cs
#	Source/Tools/Flax.Stats/CodeFrameNode.cs
#	Source/Tools/Flax.Stats/Flax.Stats.Build.cs
#	Source/Tools/Flax.Stats/Languages.cs
#	Source/Tools/Flax.Stats/Program.cs
#	Source/Tools/Flax.Stats/TaskType.cs
#	Source/Tools/Flax.Stats/Tools.cs
#	Source/Tools/FlaxEngine.Tests/TestEditorUtils.cs
This commit is contained in:
Wojciech Figat
2023-01-10 15:49:44 +01:00
2631 changed files with 2879 additions and 2756 deletions

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
#include "ScriptingObject.h"
#include "Scripting.h"
@@ -112,21 +112,33 @@ ScriptingObject* ScriptingObject::FromInterface(void* interfaceObj, const Script
if (type.Type != ScriptingTypes::Script)
continue;
auto interfaceImpl = type.GetInterface(interfaceType);
if (interfaceImpl && interfaceImpl->IsNative)
if (!interfaceImpl || !interfaceImpl->IsNative)
continue;
// Get vtable for this type
void* vtable = type.Script.VTable;
if (!vtable && type.GetDefaultInstance())
{
ScriptingObject* predictedObj = (ScriptingObject*)((byte*)interfaceObj - interfaceImpl->VTableOffset);
void* predictedVTable = *(void***)predictedObj;
void* vtable = type.Script.VTable;
if (!vtable && type.GetDefaultInstance())
{
// Use vtable from default instance of this type
vtable = *(void***)type.GetDefaultInstance();
}
if (vtable == predictedVTable)
{
ASSERT(predictedObj->GetType().GetInterface(interfaceType));
return predictedObj;
}
// Use vtable from default instance of this type
vtable = *(void***)type.GetDefaultInstance();
}
// Check if object interface vtable matches the type interface vtable value
ScriptingObject* predictedObj = (ScriptingObject*)((byte*)interfaceObj - interfaceImpl->VTableOffset);
void* predictedVTable = *(void***)predictedObj;
if (vtable == predictedVTable)
{
ASSERT(predictedObj->GetType().GetInterface(interfaceType));
return predictedObj;
}
// Check for case of passing object directly
predictedObj = (ScriptingObject*)interfaceObj;
predictedVTable = *(void***)predictedObj;
if (vtable == predictedVTable)
{
ASSERT(predictedObj->GetType().GetInterface(interfaceType));
return predictedObj;
}
}
}