Merge remote-tracking branch 'origin/master' into dotnet7

This commit is contained in:
Wojtek Figat
2023-02-13 10:05:51 +01:00
52 changed files with 1020 additions and 212 deletions

View File

@@ -681,6 +681,16 @@ void* BinaryModule::FindMethod(const ScriptingTypeHandle& typeHandle, const Scri
void BinaryModule::Destroy(bool isReloading)
{
// Destroy any default script instances
for (const auto& type : Types)
{
if (type.Type == ScriptingTypes::Script && type.Script.DefaultInstance)
{
Delete(type.Script.DefaultInstance);
type.Script.DefaultInstance = nullptr;
}
}
// Unregister
GetModules().RemoveKeepOrder(this);
}
@@ -1443,6 +1453,10 @@ void NativeBinaryModule::Destroy(bool isReloading)
{
ManagedBinaryModule::Destroy(isReloading);
// Skip native code unloading from core libs
if (this == GetBinaryModuleCorlib() || this == GetBinaryModuleFlaxEngine())
return;
// Release native library
const auto library = Library;
if (library)

View File

@@ -127,6 +127,15 @@ bool MClass::IsSubClassOf(const MonoClass* monoClass) const
}
#endif
bool MClass::HasInterface(const MClass* klass) const
{
#if USE_MONO
return klass && mono_class_is_assignable_from(klass->GetNative(), _monoClass) != 0;
#else
return false;
#endif
}
bool MClass::IsInstanceOfType(MObject* object) const
{
if (object == nullptr)

View File

@@ -154,6 +154,13 @@ public:
bool IsSubClassOf(const MonoClass* monoClass) const;
#endif
/// <summary>
/// Checks if this class implements the specified interface (including any base types).
/// </summary>
/// <param name="klass">The interface class.</param>
/// <returns>True if this class implements the specified interface.</returns>
bool HasInterface(const MClass* klass) const;
/// <summary>
/// Checks is the provided object instance of this class' type.
/// </summary>

View File

@@ -530,13 +530,6 @@ void Scripting::Release()
for (int32 i = modules.Count() - 1; i >= 0; i--)
{
auto module = modules[i];
if (module == GetBinaryModuleCorlib() || module == GetBinaryModuleFlaxEngine())
{
// Just C# assembly unload for in-build modules
((ManagedBinaryModule*)module)->Assembly->Unload();
continue;
}
module->Destroy(false);
}
_nonNativeModules.ClearDelete();