In metadata/
[mono.git] / mono / tests / libtest.c
index 70d1f718e478802741f718524dde9487fbdfb594..f45e4f051dc55c5fc309837f1b321d2b0f0159ac 100644 (file)
@@ -256,6 +256,12 @@ mono_invoke_delegate (SimpleDelegate3 delegate)
        return res;
 }
 
+LIBTEST_API int STDCALL
+mono_invoke_simple_delegate (SimpleDelegate d)
+{
+       return d (4);
+}
+
 LIBTEST_API int STDCALL  
 mono_test_marshal_char (short a1)
 {
@@ -469,7 +475,7 @@ mono_test_marshal_out_struct (int a, simplestruct *ss, int b, OutVTypeDelegate f
 
 typedef struct {
        int a;
-       SimpleDelegate func, func2;
+       SimpleDelegate func, func2, func3;
 } DelegateStruct;
 
 LIBTEST_API DelegateStruct STDCALL 
@@ -477,9 +483,10 @@ mono_test_marshal_delegate_struct (DelegateStruct ds)
 {
        DelegateStruct res;
 
-       res.a = ds.func (ds.a) + ds.func2 (ds.a);
+       res.a = ds.func (ds.a) + ds.func2 (ds.a) + (ds.func3 == NULL ? 0 : 1);
        res.func = ds.func;
        res.func2 = ds.func2;
+       res.func3 = NULL;
 
        return res;
 }
@@ -1412,6 +1419,21 @@ marshal_test_bool_struct(struct BoolStruct *s)
     return res;
 }
 
+typedef struct {
+       gint64 l;
+} LongStruct2;
+
+typedef struct {
+       int i;
+       LongStruct2 l;
+} LongStruct;
+
+LIBTEST_API int STDCALL
+mono_test_marshal_long_struct (LongStruct *s)
+{
+       return s->i + s->l.l;
+}
+
 LIBTEST_API void STDCALL
 mono_test_last_error (int err)
 {
@@ -2072,6 +2094,28 @@ mono_test_marshal_return_string_array_delegate (ReturnStringArrayDelegate d)
        return res;
 }
 
+typedef int (STDCALL *ByrefStringDelegate) (char **s);
+
+LIBTEST_API int STDCALL 
+mono_test_marshal_byref_string_delegate (ByrefStringDelegate d)
+{
+       char *s = (char*)"ABC";
+       int res;
+
+       res = d (&s);
+       if (res != 0)
+               return res;
+
+       if (!strcmp (s, "DEF"))
+               res = 0;
+       else
+               res = 2;
+
+       marshal_free (s);
+
+       return res;
+}
+
 LIBTEST_API int STDCALL 
 add_delegate (int i, int j)
 {