[meta] Add GCHandle embedding API v2 with pointer-sized handles (#35197)
authorRyan Lucia <rylucia@microsoft.com>
Thu, 23 Apr 2020 12:36:16 +0000 (08:36 -0400)
committerGitHub <noreply@github.com>
Thu, 23 Apr 2020 12:36:16 +0000 (08:36 -0400)
src/mono/mono/metadata/external-only.c
src/mono/mono/metadata/object.h

index 8e3c782..0ccb35a 100644 (file)
@@ -45,6 +45,12 @@ mono_gchandle_new (MonoObject *obj, mono_bool pinned)
        MONO_EXTERNAL_ONLY_GC_UNSAFE (uint32_t, (uint32_t)(size_t)mono_gchandle_new_internal (obj, pinned));
 }
 
+MonoGCHandle
+mono_gchandle_new_v2 (MonoObject *obj, mono_bool pinned)
+{
+       MONO_EXTERNAL_ONLY_GC_UNSAFE (MonoGCHandle, mono_gchandle_new_internal (obj, pinned));
+}
+
 /**
  * mono_gchandle_new_weakref:
  * \param obj managed object to get a handle for
@@ -72,6 +78,12 @@ mono_gchandle_new_weakref (MonoObject *obj, mono_bool track_resurrection)
        MONO_EXTERNAL_ONLY_GC_UNSAFE (uint32_t, (uint32_t)(size_t)mono_gchandle_new_weakref_internal (obj, track_resurrection));
 }
 
+MonoGCHandle
+mono_gchandle_new_weakref_v2 (MonoObject *obj, mono_bool track_resurrection)
+{
+       MONO_EXTERNAL_ONLY_GC_UNSAFE (MonoGCHandle, mono_gchandle_new_weakref_internal (obj, track_resurrection));
+}
+
 /**
  * mono_gchandle_get_target:
  * \param gchandle a GCHandle's handle.
@@ -88,6 +100,12 @@ mono_gchandle_get_target (uint32_t gchandle)
        MONO_EXTERNAL_ONLY_GC_UNSAFE (MonoObject*, mono_gchandle_get_target_internal ((MonoGCHandle)(size_t)gchandle));
 }
 
+MonoObject*
+mono_gchandle_get_target_v2 (MonoGCHandle gchandle)
+{
+       MONO_EXTERNAL_ONLY_GC_UNSAFE (MonoObject*, mono_gchandle_get_target_internal (gchandle));
+}
+
 /**
  * mono_gchandle_free:
  * \param gchandle a GCHandle's handle.
@@ -107,6 +125,12 @@ mono_gchandle_free (uint32_t gchandle)
        MONO_EXTERNAL_ONLY_VOID (mono_gchandle_free_internal ((MonoGCHandle)(size_t)gchandle));
 }
 
+void
+mono_gchandle_free_v2 (MonoGCHandle gchandle)
+{
+       MONO_EXTERNAL_ONLY_VOID (mono_gchandle_free_internal (gchandle));
+}
+
 /* GC write barriers support */
 
 /**
index da19d3d..f421c6c 100644 (file)
@@ -372,6 +372,11 @@ MONO_API MONO_RT_EXTERNAL_ONLY uint32_t     mono_gchandle_new_weakref (MonoObjec
 MONO_API MONO_RT_EXTERNAL_ONLY MonoObject*  mono_gchandle_get_target  (uint32_t gchandle);
 MONO_API MONO_RT_EXTERNAL_ONLY void         mono_gchandle_free        (uint32_t gchandle);
 
+MONO_API MONO_RT_EXTERNAL_ONLY MonoGCHandle mono_gchandle_new_v2         (MonoObject *obj, mono_bool pinned);
+MONO_API MONO_RT_EXTERNAL_ONLY MonoGCHandle mono_gchandle_new_weakref_v2 (MonoObject *obj, mono_bool track_resurrection);
+MONO_API MONO_RT_EXTERNAL_ONLY MonoObject*  mono_gchandle_get_target_v2  (MonoGCHandle gchandle);
+MONO_API MONO_RT_EXTERNAL_ONLY void         mono_gchandle_free_v2        (MonoGCHandle gchandle);
+
 /* Reference queue support
  *
  * A reference queue is used to get notifications of when objects are collected.