Merge branch 'master' into 1.5
This commit is contained in:
@@ -697,6 +697,7 @@ ManagedBinaryModule::ManagedBinaryModule(MAssembly* assembly)
|
||||
// Bind for C# assembly events
|
||||
assembly->Loading.Bind<ManagedBinaryModule, &ManagedBinaryModule::OnLoading>(this);
|
||||
assembly->Loaded.Bind<ManagedBinaryModule, &ManagedBinaryModule::OnLoaded>(this);
|
||||
assembly->Unloading.Bind<ManagedBinaryModule, &ManagedBinaryModule::OnUnloading>(this);
|
||||
assembly->Unloaded.Bind<ManagedBinaryModule, &ManagedBinaryModule::OnUnloaded>(this);
|
||||
|
||||
if (Assembly->IsLoaded())
|
||||
@@ -1117,17 +1118,24 @@ void ManagedBinaryModule::InitType(MClass* mclass)
|
||||
#endif
|
||||
}
|
||||
|
||||
void ManagedBinaryModule::OnUnloaded(MAssembly* assembly)
|
||||
void ManagedBinaryModule::OnUnloading(MAssembly* assembly)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
|
||||
// Clear managed-only types
|
||||
// Clear managed types typenames
|
||||
for (int32 i = _firstManagedTypeIndex; i < Types.Count(); i++)
|
||||
{
|
||||
const ScriptingType& type = Types[i];
|
||||
const MString typeName(type.Fullname.Get(), type.Fullname.Length());
|
||||
TypeNameToTypeIndex.Remove(typeName);
|
||||
}
|
||||
}
|
||||
|
||||
void ManagedBinaryModule::OnUnloaded(MAssembly* assembly)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
|
||||
// Clear managed-only types
|
||||
Types.Resize(_firstManagedTypeIndex);
|
||||
for (int32 i = 0; i < _managedMemoryBlocks.Count(); i++)
|
||||
Allocator::Free(_managedMemoryBlocks[i]);
|
||||
|
||||
@@ -309,6 +309,7 @@ private:
|
||||
void OnLoading(MAssembly* assembly);
|
||||
void OnLoaded(MAssembly* assembly);
|
||||
void InitType(MClass* mclass);
|
||||
void OnUnloading(MAssembly* assembly);
|
||||
void OnUnloaded(MAssembly* assembly);
|
||||
|
||||
public:
|
||||
|
||||
@@ -868,6 +868,20 @@ ScriptingObject* Scripting::TryFindObject(Guid id, MClass* type)
|
||||
return result;
|
||||
}
|
||||
|
||||
ScriptingObject* Scripting::TryFindObject(MClass* mclass)
|
||||
{
|
||||
if (mclass == nullptr)
|
||||
return nullptr;
|
||||
ScopeLock lock(_objectsLocker);
|
||||
for (auto i = _objectsDictionary.Begin(); i.IsNotEnd(); ++i)
|
||||
{
|
||||
const auto obj = i->Value;
|
||||
if (obj->GetClass() == mclass)
|
||||
return obj;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ScriptingObject* Scripting::FindObject(const MObject* managedInstance)
|
||||
{
|
||||
if (managedInstance == nullptr)
|
||||
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
/// <param name="fullname">The full name of the type eg: System.Int64.</param>
|
||||
/// <returns>The MClass object or null if missing.</returns>
|
||||
static MClass* FindClass(const StringAnsiView& fullname);
|
||||
|
||||
|
||||
#if USE_MONO
|
||||
/// <summary>
|
||||
/// Finds the class from the given Mono class object within whole assembly.
|
||||
@@ -144,6 +144,12 @@ public:
|
||||
/// <returns>The found object or null if missing.</returns>
|
||||
static ScriptingObject* FindObject(Guid id, MClass* type = nullptr);
|
||||
|
||||
/// <summary>
|
||||
/// Tries to find the object by the given class.
|
||||
/// </summary>
|
||||
/// <returns>The found object or null if missing.</returns>
|
||||
static ScriptingObject* TryFindObject(MClass* type);
|
||||
|
||||
/// <summary>
|
||||
/// Tries to find the object by the given identifier.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user