projects
/
mono.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #5210 from alexrp/profiler-runtime-settings
[mono.git]
/
mono
/
tests
/
marshal.cs
diff --git
a/mono/tests/marshal.cs
b/mono/tests/marshal.cs
index 166a4d1de2c08d3d6f530905e62d409740b177f1..1213f8c5cbf6ec4746c6d26c5157f403ef680bb1 100644
(file)
--- a/
mono/tests/marshal.cs
+++ b/
mono/tests/marshal.cs
@@
-8,12
+8,18
@@
using System.Runtime.InteropServices;
public class Tests {
public class Tests {
+ [AttributeUsage (AttributeTargets.Method)]
+ sealed class MonoPInvokeCallbackAttribute : Attribute {
+ public MonoPInvokeCallbackAttribute (Type t) {}
+ }
+
public static int Main (string[] args) {
return TestDriver.RunTests (typeof (Tests), args);
}
public delegate int SimpleDelegate (int a);
public static int Main (string[] args) {
return TestDriver.RunTests (typeof (Tests), args);
}
public delegate int SimpleDelegate (int a);
+ [MonoPInvokeCallback (typeof (SimpleDelegate))]
public static int delegate_test (int a)
{
return a + 1;
public static int delegate_test (int a)
{
return a + 1;
@@
-29,12
+35,7
@@
public class Tests {
public static extern IntPtr mono_test_marshal_return_delegate_2 ();
static int test_0_get_function_pointer_for_delegate () {
public static extern IntPtr mono_test_marshal_return_delegate_2 ();
static int test_0_get_function_pointer_for_delegate () {
- // This is a 2.0 feature
- MethodInfo mi = typeof (Marshal).GetMethod ("GetFunctionPointerForDelegate");
- if (mi == null)
- return 0;
-
- IntPtr fnPtr = (IntPtr)mi.Invoke (null, new object [] { new SimpleDelegate (delegate_test)});
+ IntPtr fnPtr = Marshal.GetFunctionPointerForDelegate (new SimpleDelegate (delegate_test));
if (mono_test_marshal_delegate (fnPtr) != 3)
return 1;
if (mono_test_marshal_delegate (fnPtr) != 3)
return 1;
@@
-43,28
+44,18
@@
public class Tests {
}
static int test_0_get_delegate_for_function_pointer () {
}
static int test_0_get_delegate_for_function_pointer () {
- // This is a 2.0 feature
- MethodInfo mi = typeof (Marshal).GetMethod ("GetDelegateForFunctionPointer");
- if (mi == null)
- return 0;
-
IntPtr ptr = mono_test_marshal_return_delegate (new SimpleDelegate (delegate_test));
IntPtr ptr = mono_test_marshal_return_delegate (new SimpleDelegate (delegate_test));
-
- SimpleDelegate d = (SimpleDelegate)
mi.Invoke (null, new object [] { ptr, typeof (SimpleDelegate) }
);
+
+ SimpleDelegate d = (SimpleDelegate)
Marshal.GetDelegateForFunctionPointer (ptr, typeof (SimpleDelegate)
);
return d (5) == 6 ? 0 : 1;
}
/* Obtain a delegate from a native function pointer */
static int test_0_get_delegate_for_ftnptr_native () {
return d (5) == 6 ? 0 : 1;
}
/* Obtain a delegate from a native function pointer */
static int test_0_get_delegate_for_ftnptr_native () {
- // This is a 2.0 feature
- MethodInfo mi = typeof (Marshal).GetMethod ("GetDelegateForFunctionPointer");
- if (mi == null)
- return 0;
-
IntPtr ptr = mono_test_marshal_return_delegate_2 ();
IntPtr ptr = mono_test_marshal_return_delegate_2 ();
- SimpleDelegate d = (SimpleDelegate)
mi.Invoke (null, new object [] { ptr, typeof (SimpleDelegate) }
);
+ SimpleDelegate d = (SimpleDelegate)
Marshal.GetDelegateForFunctionPointer (ptr, typeof (SimpleDelegate)
);
return d (5) == 6 ? 0 : 1;
}
return d (5) == 6 ? 0 : 1;
}