Esempio n. 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();
        }
Esempio n. 2
0
 internal static martin.Test.Foo retFunc()
 {
     System.IntPtr   _retval_ptr = libxobotos_Test_retFunc();
     martin.Test.Foo _retval     = martin.Test.Foo.Foo_Helper.NativeToManaged(_retval_ptr);
     martin.Test.Foo.Foo_Helper.FreeNativePtr(_retval_ptr);
     return(_retval);
 }
Esempio n. 3
0
                public static void MarshalOut(System.IntPtr ptr, martin.Test.Foo arg)
                {
                    Foo_Struct obj = (Foo_Struct)Marshal.PtrToStructure(ptr, typeof(Foo_Struct));

                    arg.hello = obj.hello;
                    arg.a     = XobotOS.Runtime.MarshalGlue.Array_int_Helper.NativeToManaged(obj.a);
                }
Esempio n. 4
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();
		}
Esempio n. 5
0
                public static void MarshalIn(System.IntPtr ptr, martin.Test.Foo arg)
                {
                    Foo_Struct obj = new Foo_Struct();

                    obj._owner = 0x972f3813;
                    obj.hello  = arg.hello;
                    obj.a      = XobotOS.Runtime.MarshalGlue.Array_int_Helper.ManagedToNative(arg.a);
                    Marshal.StructureToPtr(obj, ptr, false);
                }
Esempio n. 6
0
 public static System.IntPtr ManagedToNative(martin.Test.Foo arg)
 {
     if (arg == null)
     {
         return(System.IntPtr.Zero);
     }
     System.IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Foo_Struct)));
     martin.Test.Foo.Foo_Helper.MarshalIn(ptr, arg);
     return(ptr);
 }
Esempio n. 7
0
                public static martin.Test.Foo NativeToManaged(System.IntPtr ptr)
                {
                    if (ptr == System.IntPtr.Zero)
                    {
                        return(null);
                    }
                    Foo_Struct obj = (Foo_Struct)Marshal.PtrToStructure(ptr, typeof(Foo_Struct));

                    martin.Test.Foo arg = new martin.Test.Foo();
                    arg.hello = obj.hello;
                    arg.a     = XobotOS.Runtime.MarshalGlue.Array_int_Helper.NativeToManaged(obj.a);
                    return(arg);
                }
Esempio n. 8
0
 internal static void outFunc(martin.Test.Foo arg)
 {
     System.IntPtr arg_ptr = System.IntPtr.Zero;
     try
     {
         libxobotos_Test_outFunc(out arg_ptr);
         martin.Test.Foo.Foo_Helper.MarshalOut(arg_ptr, arg);
     }
     finally
     {
         martin.Test.Foo.Foo_Helper.FreeNativePtr(arg_ptr);
     }
 }
Esempio n. 9
0
 internal static void foo(martin.Test.Foo arg)
 {
     System.IntPtr arg_ptr = System.IntPtr.Zero;
     try
     {
         arg_ptr = martin.Test.Foo.Foo_Helper.ManagedToNative(arg);
         libxobotos_Test_foo(arg_ptr);
     }
     finally
     {
         martin.Test.Foo.Foo_Helper.FreeManagedPtr(arg_ptr);
     }
 }
Esempio n. 10
0
 internal static void refFunc(martin.Test.Foo arg)
 {
     System.IntPtr arg_ptr = System.IntPtr.Zero;
     try
     {
         arg_ptr = martin.Test.Foo.Foo_Helper.ManagedToNative(arg);
         libxobotos_Test_refFunc(arg_ptr);
         martin.Test.Foo.Foo_Helper.MarshalOut(arg_ptr, arg);
     }
     finally
     {
         martin.Test.Foo.Foo_Helper.FreeManagedPtr(arg_ptr);
     }
 }
Esempio n. 11
0
            public static martin.Test.Foo[] NativeToManaged(System.IntPtr ptr)
            {
                if (ptr == System.IntPtr.Zero)
                {
                    return(null);
                }
                Array_Foo_Struct obj = (Array_Foo_Struct)Marshal.PtrToStructure(ptr, typeof(Array_Foo_Struct
                                                                                            ));

                martin.Test.Foo[] arg = new martin.Test.Foo[obj.length];
                if (obj.length != arg.Length)
                {
                    throw new System.InvalidOperationException();
                }
                {
                    System.IntPtr addr = obj.ptr;
                    for (int i = 0; i < obj.length; i++, addr += martin.Test.Foo.Foo_Helper.NativeSize)
                    {
                        arg[i] = martin.Test.Foo.Foo_Helper.NativeToManaged(addr);
                    }
                }
                return(arg);
            }
Esempio n. 12
0
			public static martin.Test.Foo[] NativeToManaged(System.IntPtr ptr)
			{
				if (ptr == System.IntPtr.Zero)
				{
					return null;
				}
				Array_Foo_Struct obj = (Array_Foo_Struct)Marshal.PtrToStructure(ptr, typeof(Array_Foo_Struct
					));
				martin.Test.Foo[] arg = new martin.Test.Foo[obj.length];
				if (obj.length != arg.Length)
				{
					throw new System.InvalidOperationException();
				}
				{
					System.IntPtr addr = obj.ptr;
					for (int i = 0; i < obj.length; i++, addr += martin.Test.Foo.Foo_Helper.NativeSize)
					{
						arg[i] = martin.Test.Foo.Foo_Helper.NativeToManaged(addr);
					}
				}
				return arg;
			}
Esempio n. 13
0
				public static martin.Test.Foo NativeToManaged(System.IntPtr ptr)
				{
					if (ptr == System.IntPtr.Zero)
					{
						return null;
					}
					Foo_Struct obj = (Foo_Struct)Marshal.PtrToStructure(ptr, typeof(Foo_Struct));
					martin.Test.Foo arg = new martin.Test.Foo();
					arg.hello = obj.hello;
					arg.a = XobotOS.Runtime.MarshalGlue.Array_int_Helper.NativeToManaged(obj.a);
					return arg;
				}