diff options
-rw-r--r-- | mcs/build/profiles/winaot.make | 1 | ||||
-rw-r--r-- | mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs | 12 | ||||
-rw-r--r-- | mono/metadata/cominterop.c | 27 | ||||
-rw-r--r-- | mono/metadata/icall-def.h | 6 |
4 files changed, 37 insertions, 9 deletions
diff --git a/mcs/build/profiles/winaot.make b/mcs/build/profiles/winaot.make index d893f976f91..7e0bfb507c4 100644 --- a/mcs/build/profiles/winaot.make +++ b/mcs/build/profiles/winaot.make @@ -23,6 +23,7 @@ PROFILE_MCS_FLAGS = \ -d:FULL_AOT_RUNTIME \ -d:DISABLE_COM \ -d:WIN_PLATFORM \ + -d:WINAOT \ -nowarn:1699 \ -nostdlib \ $(PLATFORM_DEBUG_FLAGS) diff --git a/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs b/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs index e01abcadbed..923525b3664 100644 --- a/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs +++ b/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs @@ -53,14 +53,14 @@ namespace System.Runtime.InteropServices public static readonly int SystemMaxDBCSCharSize = 2; // don't know what this is public static readonly int SystemDefaultCharSize = Environment.IsRunningOnWindows ? 2 : 1; -#if !MOBILE +#if !MOBILE || WINAOT [MethodImplAttribute (MethodImplOptions.InternalCall)] private extern static int AddRefInternal (IntPtr pUnk); #endif public static int AddRef (IntPtr pUnk) { -#if !MOBILE +#if !MOBILE || WINAOT if (pUnk == IntPtr.Zero) throw new ArgumentException ("Value cannot be null.", "pUnk"); return AddRefInternal (pUnk); @@ -926,14 +926,14 @@ namespace System.Runtime.InteropServices return (T) PtrToStructure (ptr, typeof (T)); } -#if !MOBILE +#if !MOBILE || WINAOT [MethodImplAttribute (MethodImplOptions.InternalCall)] private extern static int QueryInterfaceInternal (IntPtr pUnk, ref Guid iid, out IntPtr ppv); #endif public static int QueryInterface (IntPtr pUnk, ref Guid iid, out IntPtr ppv) { -#if !MOBILE +#if !MOBILE || WINAOT if (pUnk == IntPtr.Zero) throw new ArgumentException ("Value cannot be null.", "pUnk"); return QueryInterfaceInternal (pUnk, ref iid, out ppv); @@ -1097,7 +1097,7 @@ namespace System.Runtime.InteropServices [MethodImplAttribute(MethodImplOptions.InternalCall)] public extern static IntPtr ReAllocHGlobal (IntPtr pv, IntPtr cb); -#if !MOBILE +#if !MOBILE || WINAOT [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)] [MethodImplAttribute (MethodImplOptions.InternalCall)] private extern static int ReleaseInternal (IntPtr pUnk); @@ -1106,7 +1106,7 @@ namespace System.Runtime.InteropServices [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)] public static int Release (IntPtr pUnk) { -#if !MOBILE +#if !MOBILE || WINAOT if (pUnk == IntPtr.Zero) throw new ArgumentException ("Value cannot be null.", "pUnk"); diff --git a/mono/metadata/cominterop.c b/mono/metadata/cominterop.c index 5078bce01a9..65178406650 100644 --- a/mono/metadata/cominterop.c +++ b/mono/metadata/cominterop.c @@ -53,7 +53,7 @@ static void mono_System_ComObject_ReleaseInterfaces (MonoComObjectHandle obj); -#ifndef DISABLE_COM +#if !defined (DISABLE_COM) || defined (HOST_WIN32) static int mono_IUnknown_QueryInterface (MonoIUnknown *pUnk, gconstpointer riid, gpointer* ppv) @@ -3623,6 +3623,29 @@ mono_marshal_free_ccw (MonoObject* object) return FALSE; } +#ifdef HOST_WIN32 + +int +ves_icall_System_Runtime_InteropServices_Marshal_AddRefInternal (MonoIUnknown *pUnk) +{ + return mono_IUnknown_AddRef (pUnk); +} + +int +ves_icall_System_Runtime_InteropServices_Marshal_ReleaseInternal (MonoIUnknown *pUnk) +{ + g_assert (pUnk); + return mono_IUnknown_Release (pUnk); +} + +int +ves_icall_System_Runtime_InteropServices_Marshal_QueryInterfaceInternal (MonoIUnknown *pUnk, gconstpointer riid, gpointer* ppv) +{ + return mono_IUnknown_QueryInterface (pUnk, riid, ppv); +} + +#else /* HOST_WIN32 */ + int ves_icall_System_Runtime_InteropServices_Marshal_AddRefInternal (MonoIUnknown *pUnk) { @@ -3637,6 +3660,7 @@ ves_icall_System_Runtime_InteropServices_Marshal_ReleaseInternal (MonoIUnknown * return 0; } + int ves_icall_System_Runtime_InteropServices_Marshal_QueryInterfaceInternal (MonoIUnknown *pUnk, gconstpointer riid, gpointer* ppv) { @@ -3644,6 +3668,7 @@ ves_icall_System_Runtime_InteropServices_Marshal_QueryInterfaceInternal (MonoIUn return 0; } +#endif /* HOST_WIN32 */ #endif /* DISABLE_COM */ MonoStringHandle diff --git a/mono/metadata/icall-def.h b/mono/metadata/icall-def.h index 93d6876c532..c9f93b01f8a 100644 --- a/mono/metadata/icall-def.h +++ b/mono/metadata/icall-def.h @@ -825,7 +825,7 @@ HANDLES(GCH_4, "GetTarget", ves_icall_System_GCHandle_GetTarget, MonoObject, 1, HANDLES(GCH_5, "GetTargetHandle", ves_icall_System_GCHandle_GetTargetHandle, guint32, 3, (MonoObject, guint32, gint32)) #endif -#ifndef DISABLE_COM +#if !defined(DISABLE_COM) || defined (HOST_WIN32) ICALL_TYPE(MARSHAL, "System.Runtime.InteropServices.Marshal", MARSHAL_1) NOHANDLES(ICALL(MARSHAL_1, "AddRefInternal", ves_icall_System_Runtime_InteropServices_Marshal_AddRefInternal)) #else @@ -880,13 +880,15 @@ HANDLES(MARSHAL_20, "PtrToStructureInternal", ves_icall_System_Runtime_InteropSe HANDLES(MARSHAL_20, "PtrToStructure(intptr,System.Type)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStructure_type, MonoObject, 2, (gconstpointer, MonoReflectionType)) HANDLES(MARSHAL_21, "PtrToStructure(intptr,object)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStructure, void, 2, (gconstpointer, MonoObject)) #endif -#ifndef DISABLE_COM +#if !defined (DISABLE_COM) || defined (HOST_WIN32) NOHANDLES(ICALL(MARSHAL_22, "QueryInterfaceInternal", ves_icall_System_Runtime_InteropServices_Marshal_QueryInterfaceInternal)) #endif HANDLES(MARSHAL_43, "ReAllocCoTaskMem", ves_icall_System_Runtime_InteropServices_Marshal_ReAllocCoTaskMem, gpointer, 2, (gpointer, int)) HANDLES(MARSHAL_23, "ReAllocHGlobal", ves_icall_System_Runtime_InteropServices_Marshal_ReAllocHGlobal, gpointer, 2, (gpointer, gsize)) #ifndef DISABLE_COM HANDLES(MARSHAL_49, "ReleaseComObjectInternal", ves_icall_System_Runtime_InteropServices_Marshal_ReleaseComObjectInternal, gint32, 1, (MonoObject)) +#endif +#if !defined (DISABLE_COM) || defined (HOST_WIN32) NOHANDLES(ICALL(MARSHAL_29, "ReleaseInternal", ves_icall_System_Runtime_InteropServices_Marshal_ReleaseInternal)) #endif HANDLES(MARSHAL_30, "SizeOf", ves_icall_System_Runtime_InteropServices_Marshal_SizeOf, guint32, 1, (MonoReflectionType)) |