* TextControl.cs: Make this operation undoable.
[mono-project.git] / mono / tests / pinvoke-2.2.cs
blob039bcda994eabe1816fe9d2b2fadceb29eb66e25
1 //
2 // pinvoke-2.cs:
3 //
4 // Tests for net 2.0 pinvoke features
5 //
7 using System;
8 using System.Runtime.InteropServices;
10 public class Tests {
12 public static int Main () {
13 return TestDriver.RunTests (typeof (Tests));
16 [UnmanagedFunctionPointerAttribute (CallingConvention.Cdecl)]
17 public delegate int CdeclDelegate (int i, int j);
19 [DllImport ("libtest", EntryPoint="mono_test_marshal_cdecl_delegate")]
20 public static extern int mono_test_marshal_cdecl_delegate (CdeclDelegate d);
22 public static int cdecl_delegate (int i, int j) {
23 return i + j;
26 static int test_0_marshal_cdecl_delegate () {
27 CdeclDelegate d = new CdeclDelegate (cdecl_delegate);
29 return mono_test_marshal_cdecl_delegate (d);
32 [DllImport ("libtest", EntryPoint="mono_test_marshal_return_fnptr")]
33 public static extern IntPtr mono_test_marshal_return_fnptr ();
35 delegate int AddDelegate (int i, int j);
37 static int test_4_get_delegate_for_function_pointer () {
38 IntPtr ptr = mono_test_marshal_return_fnptr ();
40 AddDelegate d = (AddDelegate)Marshal.GetDelegateForFunctionPointer (ptr, typeof (AddDelegate));
42 return d (2, 2);