From: Zoltan Varga Date: Thu, 15 Jun 2006 17:39:15 +0000 (-0000) Subject: 2006-06-15 Zoltan Varga X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=3fe5409741be0d9a071b6465d1b49068c587bf9c;p=mono.git 2006-06-15 Zoltan Varga * pinvoke-2.cs: Rename to pinvoke-2.2.cs. * Makefile.am (TEST_CS2_SRC): Add pinvoke-2.2.cs * pinvoke-2.2.cs libtest.c: Add Marshal.GetDelegateForFunctionPointer () tests. svn path=/trunk/mono/; revision=61762 --- 3fe5409741be0d9a071b6465d1b49068c587bf9c diff --cc mono/tests/Makefile.am index c4719fa570b,c4719fa570b..a155ee01909 --- a/mono/tests/Makefile.am +++ b/mono/tests/Makefile.am @@@ -253,7 -253,7 +253,7 @@@ TEST_IL_SRC= test-enum-indstoreil.il \ even-odd.il --TEST_CS2_SRC = interlocked-2.2.cs ++TEST_CS2_SRC = interlocked-2.2.cs pinvoke-2.2.cs TEST_IL2_SRC = find-method.2.il TESTSI_CS=$(TEST_CS_SRC:.cs=.exe) diff --cc mono/tests/libtest.c index fbb54efe79b,fbb54efe79b..96fd60c2958 --- a/mono/tests/libtest.c +++ b/mono/tests/libtest.c @@@ -1822,6 -1822,6 +1822,18 @@@ mono_test_marshal_return_string_array_d return res; } ++STDCALL int ++add_delegate (int i, int j) ++{ ++ return i + j; ++} ++ ++STDCALL gpointer ++mono_test_marshal_return_fnptr (void) ++{ ++ return &add_delegate; ++} ++ /* * COM INTEROP TESTS */ diff --cc mono/tests/pinvoke-2.2.cs index 00000000000,00000000000..039bcda994e new file mode 100644 --- /dev/null +++ b/mono/tests/pinvoke-2.2.cs @@@ -1,0 -1,0 +1,44 @@@ ++// ++// pinvoke-2.cs: ++// ++// Tests for net 2.0 pinvoke features ++// ++ ++using System; ++using System.Runtime.InteropServices; ++ ++public class Tests { ++ ++ public static int Main () { ++ return TestDriver.RunTests (typeof (Tests)); ++ } ++ ++ [UnmanagedFunctionPointerAttribute (CallingConvention.Cdecl)] ++ public delegate int CdeclDelegate (int i, int j); ++ ++ [DllImport ("libtest", EntryPoint="mono_test_marshal_cdecl_delegate")] ++ public static extern int mono_test_marshal_cdecl_delegate (CdeclDelegate d); ++ ++ public static int cdecl_delegate (int i, int j) { ++ return i + j; ++ } ++ ++ static int test_0_marshal_cdecl_delegate () { ++ CdeclDelegate d = new CdeclDelegate (cdecl_delegate); ++ ++ return mono_test_marshal_cdecl_delegate (d); ++ } ++ ++ [DllImport ("libtest", EntryPoint="mono_test_marshal_return_fnptr")] ++ public static extern IntPtr mono_test_marshal_return_fnptr (); ++ ++ delegate int AddDelegate (int i, int j); ++ ++ static int test_4_get_delegate_for_function_pointer () { ++ IntPtr ptr = mono_test_marshal_return_fnptr (); ++ ++ AddDelegate d = (AddDelegate)Marshal.GetDelegateForFunctionPointer (ptr, typeof (AddDelegate)); ++ ++ return d (2, 2); ++ } ++} diff --cc mono/tests/pinvoke-2.cs index 9b76e49ba2a,9b76e49ba2a..00000000000 deleted file mode 100644,100644 --- a/mono/tests/pinvoke-2.cs +++ /dev/null @@@ -1,31 -1,31 +1,0 @@@ --// --// pinvoke-2.cs: --// --// Tests for net 2.0 pinvoke features --// -- --using System; --using System.Runtime.InteropServices; -- --public class Tests { -- -- public static int Main () { -- return TestDriver.RunTests (typeof (Tests)); -- } -- -- [UnmanagedFunctionPointerAttribute (CallingConvention.Cdecl)] -- public delegate int CdeclDelegate (int i, int j); -- -- [DllImport ("libtest", EntryPoint="mono_test_marshal_cdecl_delegate")] -- public static extern int mono_test_marshal_cdecl_delegate (CdeclDelegate d); -- -- public static int cdecl_delegate (int i, int j) { -- return i + j; -- } -- -- static int test_0_marshal_cdecl_delegate () { -- CdeclDelegate d = new CdeclDelegate (cdecl_delegate); -- -- return mono_test_marshal_cdecl_delegate (d); -- } --}