@@ -23,6 +23,32 @@ namespace Python.Runtime
23
23
/// </summary>
24
24
internal class NativeCall
25
25
{
26
+ #if NETCOREAPP
27
+ [ UnmanagedFunctionPointer ( CallingConvention . Cdecl ) ]
28
+ private delegate void Void_1_Delegate ( IntPtr a1 ) ;
29
+
30
+ [ UnmanagedFunctionPointer ( CallingConvention . Cdecl ) ]
31
+ private delegate IntPtr IntPtr_3_Delegate ( IntPtr a1 , IntPtr a2 , IntPtr a3 ) ;
32
+
33
+ [ UnmanagedFunctionPointer ( CallingConvention . Cdecl ) ]
34
+ private delegate int Int_3_Delegate ( IntPtr a1 , IntPtr a2 , IntPtr a3 ) ;
35
+
36
+ public static void Void_Call_1 ( IntPtr fp , IntPtr a1 )
37
+ {
38
+ ( ( Void_1_Delegate ) Marshal . GetDelegateForFunctionPointer ( fp , typeof ( Void_1_Delegate ) ) ) ( a1 ) ;
39
+ }
40
+
41
+ public static IntPtr Call_3 ( IntPtr fp , IntPtr a1 , IntPtr a2 , IntPtr a3 )
42
+ {
43
+ return ( ( IntPtr_3_Delegate ) Marshal . GetDelegateForFunctionPointer ( fp , typeof ( IntPtr_3_Delegate ) ) ) ( a1 , a2 , a3 ) ;
44
+ }
45
+
46
+
47
+ public static int Int_Call_3 ( IntPtr fp , IntPtr a1 , IntPtr a2 , IntPtr a3 )
48
+ {
49
+ return ( ( Int_3_Delegate ) Marshal . GetDelegateForFunctionPointer ( fp , typeof ( Int_3_Delegate ) ) ) ( a1 , a2 , a3 ) ;
50
+ }
51
+ #else
26
52
private static AssemblyBuilder aBuilder ;
27
53
private static ModuleBuilder mBuilder ;
28
54
@@ -106,19 +132,12 @@ private static void GenerateThunk(TypeBuilder tb, MethodInfo method)
106
132
107
133
il . Emit ( OpCodes . Ldarg_1 ) ;
108
134
109
- #if NETCOREAPP
110
- il . EmitCalli ( OpCodes . Calli ,
111
- CallingConventions . ExplicitThis ,
112
- method . ReturnType ,
113
- nargs , null
114
- ) ;
115
- #else
116
135
il . EmitCalli ( OpCodes . Calli ,
117
136
CallingConvention . Cdecl ,
118
137
method . ReturnType ,
119
138
nargs
120
139
) ;
121
- #endif
140
+
122
141
il . Emit ( OpCodes . Ret ) ;
123
142
124
143
tb . DefineMethodOverride ( mb , method ) ;
@@ -139,9 +158,10 @@ public static int Int_Call_3(IntPtr fp, IntPtr a1, IntPtr a2, IntPtr a3)
139
158
{
140
159
return Impl . Int_Call_3 ( fp , a1 , a2 , a3 ) ;
141
160
}
161
+ #endif
142
162
}
143
163
144
-
164
+ #if ! NETCORAPP
145
165
/// <summary>
146
166
/// Defines native call signatures to be generated by NativeCall.
147
167
/// </summary>
@@ -155,4 +175,5 @@ public interface INativeCall
155
175
156
176
IntPtr Call_3 ( IntPtr funcPtr , IntPtr a1 , IntPtr a2 , IntPtr a3 ) ;
157
177
}
178
+ #endif
158
179
}
0 commit comments