Various minor cleanups
This commit is contained in:
@@ -165,9 +165,8 @@ extern MDomain* MActiveDomain;
|
||||
extern Array<MDomain*, FixedAllocation<4>> MDomains;
|
||||
|
||||
Dictionary<String, void*> CachedFunctions;
|
||||
|
||||
Dictionary<void*, MClass*> classHandles;
|
||||
Dictionary<void*, MAssembly*> assemblyHandles;
|
||||
Dictionary<void*, MClass*> CachedClassHandles;
|
||||
Dictionary<void*, MAssembly*> CachedAssemblyHandles;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the function pointer to the managed static method in NativeInterop class.
|
||||
@@ -672,7 +671,7 @@ bool MAssembly::LoadCorlib()
|
||||
return true;
|
||||
}
|
||||
_hasCachedClasses = false;
|
||||
assemblyHandles.Add(_handle, this);
|
||||
CachedAssemblyHandles.Add(_handle, this);
|
||||
|
||||
// End
|
||||
OnLoaded(startTime);
|
||||
@@ -696,7 +695,7 @@ bool MAssembly::LoadImage(const String& assemblyPath, const StringView& nativePa
|
||||
Log::CLRInnerException(TEXT(".NET assembly image is invalid at ") + assemblyPath);
|
||||
return true;
|
||||
}
|
||||
assemblyHandles.Add(_handle, this);
|
||||
CachedAssemblyHandles.Add(_handle, this);
|
||||
|
||||
// Provide new path of hot-reloaded native library path for managed DllImport
|
||||
if (nativePath.HasChars())
|
||||
@@ -722,7 +721,7 @@ bool MAssembly::UnloadImage(bool isReloading)
|
||||
CallStaticMethod<void, const void*>(CloseAssemblyPtr, _handle);
|
||||
}
|
||||
|
||||
assemblyHandles.Remove(_handle);
|
||||
CachedAssemblyHandles.Remove(_handle);
|
||||
_handle = nullptr;
|
||||
}
|
||||
return false;
|
||||
@@ -780,7 +779,7 @@ MClass::MClass(const MAssembly* parentAssembly, void* handle, const char* name,
|
||||
static void* TypeIsEnumPtr = GetStaticMethodPointer(TEXT("TypeIsEnum"));
|
||||
_isEnum = CallStaticMethod<bool, void*>(TypeIsEnumPtr, handle);
|
||||
|
||||
classHandles.Add(handle, this);
|
||||
CachedClassHandles.Add(handle, this);
|
||||
}
|
||||
|
||||
bool MAssembly::ResolveMissingFile(String& assemblyPath) const
|
||||
@@ -800,7 +799,7 @@ MClass::~MClass()
|
||||
_properties.ClearDelete();
|
||||
_events.ClearDelete();
|
||||
|
||||
classHandles.Remove(_handle);
|
||||
CachedClassHandles.Remove(_handle);
|
||||
}
|
||||
|
||||
StringAnsiView MClass::GetName() const
|
||||
@@ -1018,11 +1017,7 @@ const Array<MObject*>& MClass::GetAttributes() const
|
||||
int numAttributes;
|
||||
static void* GetClassAttributesPtr = GetStaticMethodPointer(TEXT("GetClassAttributes"));
|
||||
CallStaticMethod<void, void*, MObject***, int*>(GetClassAttributesPtr, _handle, &attributes, &numAttributes);
|
||||
_attributes.Resize(numAttributes);
|
||||
for (int i = 0; i < numAttributes; i++)
|
||||
{
|
||||
_attributes[i] = attributes[i];
|
||||
}
|
||||
_attributes.Set(attributes, numAttributes);
|
||||
MCore::GC::FreeMemory(attributes);
|
||||
|
||||
_hasCachedAttributes = true;
|
||||
@@ -1444,7 +1439,7 @@ const Array<MObject*>& MProperty::GetAttributes() const
|
||||
MAssembly* GetAssembly(void* assemblyHandle)
|
||||
{
|
||||
MAssembly* assembly;
|
||||
if (assemblyHandles.TryGet(assemblyHandle, assembly))
|
||||
if (CachedAssemblyHandles.TryGet(assemblyHandle, assembly))
|
||||
return assembly;
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1452,7 +1447,7 @@ MAssembly* GetAssembly(void* assemblyHandle)
|
||||
MClass* GetClass(MType* typeHandle)
|
||||
{
|
||||
MClass* klass = nullptr;
|
||||
classHandles.TryGet(typeHandle, klass);
|
||||
CachedClassHandles.TryGet(typeHandle, klass);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -1461,7 +1456,7 @@ MClass* GetOrCreateClass(MType* typeHandle)
|
||||
if (!typeHandle)
|
||||
return nullptr;
|
||||
MClass* klass;
|
||||
if (!classHandles.TryGet(typeHandle, klass))
|
||||
if (!CachedClassHandles.TryGet(typeHandle, klass))
|
||||
{
|
||||
NativeClassDefinitions classInfo;
|
||||
void* assemblyHandle;
|
||||
|
||||
Reference in New Issue
Block a user