Rename gchandle to MGCHandle

This commit is contained in:
Wojciech Figat
2022-12-22 13:02:00 +01:00
parent 75130fcca3
commit 94c5211ee6
7 changed files with 26 additions and 26 deletions

View File

@@ -50,10 +50,10 @@ public:
static const char* GetClassFullname(void* klass);
static void* Allocate(int size);
static void Free(void* ptr);
static gchandle NewGCHandle(void* obj, bool pinned);
static gchandle NewGCHandleWeakref(void* obj, bool track_resurrection);
static void* GetGCHandleTarget(const gchandle& gchandle);
static void FreeGCHandle(const gchandle& gchandle);
static MGCHandle NewGCHandle(void* obj, bool pinned);
static MGCHandle NewGCHandleWeakref(void* obj, bool track_resurrection);
static void* GetGCHandleTarget(const MGCHandle& MGCHandle);
static void FreeGCHandle(const MGCHandle& MGCHandle);
static bool HasCustomAttribute(void* klass, void* attribClass);
static bool HasCustomAttribute(void* klass);

View File

@@ -563,27 +563,27 @@ CoreCLRClass* GetOrCreateClass(void* type)
return klass;
}
gchandle CoreCLR::NewGCHandle(void* obj, bool pinned)
MGCHandle CoreCLR::NewGCHandle(void* obj, bool pinned)
{
static void* NewGCHandlePtr = CoreCLR::GetStaticMethodPointer(TEXT("NewGCHandle"));
return (gchandle)CoreCLR::CallStaticMethod<void*, void*, bool>(NewGCHandlePtr, obj, pinned);
return (MGCHandle)CoreCLR::CallStaticMethod<void*, void*, bool>(NewGCHandlePtr, obj, pinned);
}
gchandle CoreCLR::NewGCHandleWeakref(void* obj, bool track_resurrection)
MGCHandle CoreCLR::NewGCHandleWeakref(void* obj, bool track_resurrection)
{
static void* NewGCHandleWeakrefPtr = CoreCLR::GetStaticMethodPointer(TEXT("NewGCHandleWeakref"));
return (gchandle)CoreCLR::CallStaticMethod<void*, void*, bool>(NewGCHandleWeakrefPtr, obj, track_resurrection);
return (MGCHandle)CoreCLR::CallStaticMethod<void*, void*, bool>(NewGCHandleWeakrefPtr, obj, track_resurrection);
}
void* CoreCLR::GetGCHandleTarget(const gchandle& gchandle)
void* CoreCLR::GetGCHandleTarget(const MGCHandle& MGCHandle)
{
return (void*)gchandle;
return (void*)MGCHandle;
}
void CoreCLR::FreeGCHandle(const gchandle& gchandle)
void CoreCLR::FreeGCHandle(const MGCHandle& MGCHandle)
{
static void* FreeGCHandlePtr = CoreCLR::GetStaticMethodPointer(TEXT("FreeGCHandle"));
CoreCLR::CallStaticMethod<void, void*>(FreeGCHandlePtr, (void*)gchandle);
CoreCLR::CallStaticMethod<void, void*>(FreeGCHandlePtr, (void*)MGCHandle);
}
const char* CoreCLR::GetClassFullname(void* klass)

View File

@@ -622,7 +622,7 @@ namespace MUtils
}
#endif
FORCE_INLINE gchandle NewGCHandle(MonoObject* obj, bool pinned)
FORCE_INLINE MGCHandle NewGCHandle(MonoObject* obj, bool pinned)
{
#if USE_NETCORE
return CoreCLR::NewGCHandle(obj, pinned);
@@ -631,7 +631,7 @@ namespace MUtils
#endif
}
FORCE_INLINE gchandle NewGCHandleWeakref(MonoObject* obj, bool track_resurrection)
FORCE_INLINE MGCHandle NewGCHandleWeakref(MonoObject* obj, bool track_resurrection)
{
#if USE_NETCORE
return CoreCLR::NewGCHandleWeakref(obj, track_resurrection);
@@ -640,7 +640,7 @@ namespace MUtils
#endif
}
FORCE_INLINE MonoObject* GetGCHandleTarget(const gchandle& handle)
FORCE_INLINE MonoObject* GetGCHandleTarget(const MGCHandle& handle)
{
#if USE_NETCORE
return (MonoObject*)CoreCLR::GetGCHandleTarget(handle);
@@ -649,7 +649,7 @@ namespace MUtils
#endif
}
FORCE_INLINE void FreeGCHandle(const gchandle& handle)
FORCE_INLINE void FreeGCHandle(const MGCHandle& handle)
{
#if USE_NETCORE
CoreCLR::FreeGCHandle(handle);

View File

@@ -69,9 +69,9 @@ ScriptingObject* ScriptingObject::NewObject(const ScriptingTypeHandle& typeHandl
MObject* ScriptingObject::GetManagedInstance() const
{
#if USE_NETCORE
const gchandle handle = Platform::AtomicRead((int64*)&_gcHandle);
const MGCHandle handle = Platform::AtomicRead((int64*)&_gcHandle);
#elif USE_MONO
const gchandle handle = Platform::AtomicRead((int32*)&_gcHandle);
const MGCHandle handle = Platform::AtomicRead((int32*)&_gcHandle);
#endif
#if USE_MONO
return handle ? MUtils::GetGCHandleTarget(handle) : nullptr;
@@ -242,7 +242,7 @@ bool ScriptingObject::CreateManaged()
// Prevent from object GC destruction
#if USE_NETCORE
auto handle = (gchandle)managedInstance;
auto handle = (MGCHandle)managedInstance;
auto oldHandle = Platform::InterlockedCompareExchange((int64*)&_gcHandle, *(int64*)&handle, 0);
if (*(uint64*)&oldHandle != 0)
#else
@@ -459,7 +459,7 @@ bool ManagedScriptingObject::CreateManaged()
// Cache the GC handle to the object (used to track the target object because it can be moved in a memory)
#if USE_NETCORE
auto handle = (gchandle)managedInstance;
auto handle = (MGCHandle)managedInstance;
auto oldHandle = Platform::InterlockedCompareExchange((int64*)&_gcHandle, *(int64*)&handle, 0);
if (*(uint64*)&oldHandle != 0)
#else
@@ -645,7 +645,7 @@ public:
{
// Managed
#if USE_NETCORE
managedScriptingObject->_gcHandle = (gchandle)managedInstance;
managedScriptingObject->_gcHandle = (MGCHandle)managedInstance;
#else
managedScriptingObject->_gcHandle = MUtils::NewGCHandleWeakref(managedInstance, false);
#endif
@@ -654,7 +654,7 @@ public:
{
// Persistent
#if USE_NETCORE
obj->_gcHandle = (gchandle)managedInstance;
obj->_gcHandle = (MGCHandle)managedInstance;
#else
obj->_gcHandle = MUtils::NewGCHandle(managedInstance, false);
#endif

View File

@@ -21,7 +21,7 @@ public:
protected:
gchandle _gcHandle;
MGCHandle _gcHandle;
ScriptingTypeHandle _type;
Guid _id;

View File

@@ -55,9 +55,9 @@ struct _MonoThread {};
#endif
#if USE_NETCORE
typedef unsigned long long gchandle;
typedef unsigned long long MGCHandle;
#else
typedef uint32 gchandle;
typedef uint32 MGCHandle;
#endif
// Mono types declarations