[runtime] Add GCHandle pointer-sized API.
This commit is contained in:
Родитель
1c33bff5b3
Коммит
54bc2f1dfe
|
@ -294,6 +294,16 @@ bool
|
|||
<#= export.EntryPoint #>_exists ();
|
||||
|
||||
<# } #>
|
||||
|
||||
/*
|
||||
* Wrapper GCHandle functions that takes pointer sized handles instead of ints,
|
||||
* so that we can adapt our code incrementally to use pointers instead of ints
|
||||
* until Mono's pointer-sized API is available for us.
|
||||
* Ref: https://github.com/dotnet/runtime/commit/3886a63841434af716292172737a42757a15c6a6
|
||||
*/
|
||||
#define INVALID_GCHANDLE 0
|
||||
typedef void* GCHandle;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
|
|
@ -2666,6 +2666,48 @@ xamarin_get_managed_method_for_token (guint32 token_ref, guint32 *exception_gcha
|
|||
return xamarin_get_reflection_method_method (reflection_method);
|
||||
}
|
||||
|
||||
GCHandle
|
||||
xamarin_gchandle_new (MonoObject *obj, bool track_resurrection)
|
||||
{
|
||||
if (obj == NULL)
|
||||
return INVALID_GCHANDLE;
|
||||
return GINT_TO_POINTER (mono_gchandle_new (obj, track_resurrection));
|
||||
}
|
||||
|
||||
GCHandle
|
||||
xamarin_gchandle_new_weakref (MonoObject *obj, bool pinned)
|
||||
{
|
||||
if (obj == NULL)
|
||||
return INVALID_GCHANDLE;
|
||||
return GINT_TO_POINTER (mono_gchandle_new_weakref (obj, pinned));
|
||||
}
|
||||
|
||||
MonoObject *
|
||||
xamarin_gchandle_get_target (GCHandle handle)
|
||||
{
|
||||
if (handle == INVALID_GCHANDLE)
|
||||
return NULL;
|
||||
return mono_gchandle_get_target (GPOINTER_TO_UINT (handle));
|
||||
}
|
||||
|
||||
void
|
||||
xamarin_gchandle_free (GCHandle handle)
|
||||
{
|
||||
if (handle == INVALID_GCHANDLE)
|
||||
return;
|
||||
mono_gchandle_free (GPOINTER_TO_UINT (handle));
|
||||
}
|
||||
|
||||
MonoObject *
|
||||
xamarin_gchandle_unwrap (GCHandle handle)
|
||||
{
|
||||
if (handle == INVALID_GCHANDLE)
|
||||
return NULL;
|
||||
MonoObject *rv = mono_gchandle_get_target (GPOINTER_TO_UINT (handle));
|
||||
mono_gchandle_free (GPOINTER_TO_UINT (handle));
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*
|
||||
* Object unregistration:
|
||||
*
|
||||
|
|
|
@ -260,6 +260,18 @@ void xamarin_printf (const char *format, ...);
|
|||
void xamarin_vprintf (const char *format, va_list args);
|
||||
void xamarin_install_log_callbacks ();
|
||||
|
||||
/*
|
||||
* Wrapper GCHandle functions that takes pointer sized handles instead of ints,
|
||||
* so that we can adapt our code incrementally to use pointers instead of ints
|
||||
* until Mono's pointer-sized API is available for us.
|
||||
* Ref: https://github.com/dotnet/runtime/commit/3886a63841434af716292172737a42757a15c6a6
|
||||
*/
|
||||
GCHandle xamarin_gchandle_new (MonoObject *obj, bool track_resurrection);
|
||||
GCHandle xamarin_gchandle_new_weakref (MonoObject *obj, bool pinned);
|
||||
MonoObject * xamarin_gchandle_get_target (GCHandle handle);
|
||||
void xamarin_gchandle_free (GCHandle handle);
|
||||
MonoObject * xamarin_gchandle_unwrap (GCHandle handle); // Will get the target and free the GCHandle
|
||||
|
||||
/*
|
||||
* Look for an assembly in the app and open it.
|
||||
*
|
||||
|
|
Загрузка…
Ссылка в новой задаче