Example #1
0
        public static void run()
        {
            martin.Test.Foo foo_1 = new martin.Test.Foo();
            foo_1.hello = 128;
            foo_1.a     = new int[] { 3, 5, 11, 28 };
            hello(foo_1.a);
            if (foo_1.a[0] != 999)
            {
                throw new System.InvalidOperationException();
            }
            foo(foo_1);
            martin.Test.Foo[] bar_1 = new martin.Test.Foo[] { foo_1 };
            bar(bar_1);
            outFunc(foo_1);
            java.io.Console.Out.printf("%x\n", foo_1.hello);
            if (foo_1.hello != unchecked ((int)(0x87654321)))
            {
                throw new System.InvalidOperationException();
            }
            martin.Test.Foo ret = retFunc();
            java.io.Console.Out.printf("%x\n", ret.hello);
            if (ret.hello != unchecked ((int)(0xdeadbeaf)))
            {
                throw new System.InvalidOperationException();
            }
            martin.Test.Blittable blittable = new martin.Test.Blittable();
            blittable.hello = unchecked ((int)(0x12345678));
            java.io.Console.Out.println("Blittable test!");
            blittableFunc(blittable);
            java.io.Console.Out.printf("%x\n", blittable.hello);
            blittableRef(blittable);
            java.io.Console.Out.printf("%x\n", blittable.hello);
            if (blittable.hello != unchecked ((int)(0xdeadbeaf)))
            {
                throw new System.InvalidOperationException();
            }
            martin.Test.Complex c = complexRet();
            complex(c);
            stringFunc("Hello World!");
            java.io.Console.Out.println("Calling stringArray()");
            dumpMemoryUsage();
            stringArray(new string[] { "Hello", "World" });
            java.io.Console.Out.println("Done calling stringArray()");
            dumpMemoryUsage();
            string testStr = returnString();

            java.io.Console.Out.printf("Got string: |%s|\n", testStr);
            dumpMemoryUsage();
            string[] strArray = returnStringArray();
            java.io.Console.Out.printf("Got string array: %d\n", strArray.Length);
            foreach (string str in strArray)
            {
                java.io.Console.Out.println(str);
            }
            dumpMemoryUsage();
            int[] intArray = returnIntArray();
            java.io.Console.Out.printf("Got int array: %d (%d,%d)\n", intArray.Length, intArray
                                       [0], intArray[1]);
            dumpMemoryUsage();
        }
Example #2
0
                public static void MarshalOut(System.IntPtr ptr, martin.Test.Complex arg)
                {
                    Complex_Struct obj = (Complex_Struct)Marshal.PtrToStructure(ptr, typeof(Complex_Struct
                                                                                            ));

                    arg.foo = Array_Foo_Helper.NativeToManaged(obj.foo);
                    arg.str = XobotOS.Runtime.MarshalGlue.String_Helper.NativeToManaged(obj.str);
                }
Example #3
0
 internal static martin.Test.Complex complexRet()
 {
     System.IntPtr       _retval_ptr = libxobotos_Test_complexRet();
     martin.Test.Complex _retval     = martin.Test.Complex.Complex_Helper.NativeToManaged(
         _retval_ptr);
     martin.Test.Complex.Complex_Helper.FreeNativePtr(_retval_ptr);
     return(_retval);
 }
Example #4
0
                public static void MarshalIn(System.IntPtr ptr, martin.Test.Complex arg)
                {
                    Complex_Struct obj = new Complex_Struct();

                    obj._owner = 0x972f3813;
                    obj.foo    = Array_Foo_Helper.ManagedToNative(arg.foo);
                    obj.str    = XobotOS.Runtime.MarshalGlue.String_Helper.ManagedToNative(arg.str);
                    Marshal.StructureToPtr(obj, ptr, false);
                }
Example #5
0
 public static System.IntPtr ManagedToNative(martin.Test.Complex arg)
 {
     if (arg == null)
     {
         return(System.IntPtr.Zero);
     }
     System.IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Complex_Struct)));
     martin.Test.Complex.Complex_Helper.MarshalIn(ptr, arg);
     return(ptr);
 }
Example #6
0
 internal static void complex(martin.Test.Complex arg)
 {
     System.IntPtr arg_ptr = System.IntPtr.Zero;
     try
     {
         arg_ptr = martin.Test.Complex.Complex_Helper.ManagedToNative(arg);
         libxobotos_Test_complex(arg_ptr);
     }
     finally
     {
         martin.Test.Complex.Complex_Helper.FreeManagedPtr(arg_ptr);
     }
 }
Example #7
0
                public static martin.Test.Complex NativeToManaged(System.IntPtr ptr)
                {
                    if (ptr == System.IntPtr.Zero)
                    {
                        return(null);
                    }
                    Complex_Struct obj = (Complex_Struct)Marshal.PtrToStructure(ptr, typeof(Complex_Struct
                                                                                            ));

                    martin.Test.Complex arg = new martin.Test.Complex();
                    arg.foo = Array_Foo_Helper.NativeToManaged(obj.foo);
                    arg.str = XobotOS.Runtime.MarshalGlue.String_Helper.NativeToManaged(obj.str);
                    return(arg);
                }
Example #8
0
				public static martin.Test.Complex NativeToManaged(System.IntPtr ptr)
				{
					if (ptr == System.IntPtr.Zero)
					{
						return null;
					}
					Complex_Struct obj = (Complex_Struct)Marshal.PtrToStructure(ptr, typeof(Complex_Struct
						));
					martin.Test.Complex arg = new martin.Test.Complex();
					arg.foo = Array_Foo_Helper.NativeToManaged(obj.foo);
					arg.str = XobotOS.Runtime.MarshalGlue.String_Helper.NativeToManaged(obj.str);
					return arg;
				}