示例#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();
        }
示例#2
0
                public static void MarshalOut(System.IntPtr ptr, martin.Test.Blittable arg)
                {
                    Blittable_Struct obj = (Blittable_Struct)Marshal.PtrToStructure(ptr, typeof(Blittable_Struct
                                                                                                ));

                    arg.hello = obj.hello;
                }
示例#3
0
文件: Test.cs 项目: hakeemsm/XobotOS
		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();
		}
示例#4
0
                public static void MarshalIn(System.IntPtr ptr, martin.Test.Blittable arg)
                {
                    Blittable_Struct obj = new Blittable_Struct();

                    obj._owner = 0x972f3813;
                    obj.hello  = arg.hello;
                    Marshal.StructureToPtr(obj, ptr, false);
                }
示例#5
0
 public static System.IntPtr ManagedToNative(martin.Test.Blittable arg)
 {
     if (arg == null)
     {
         return(System.IntPtr.Zero);
     }
     System.IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Blittable_Struct))
                                              );
     martin.Test.Blittable.Blittable_Helper.MarshalIn(ptr, arg);
     return(ptr);
 }
示例#6
0
                public static martin.Test.Blittable NativeToManaged(System.IntPtr ptr)
                {
                    if (ptr == System.IntPtr.Zero)
                    {
                        return(null);
                    }
                    Blittable_Struct obj = (Blittable_Struct)Marshal.PtrToStructure(ptr, typeof(Blittable_Struct
                                                                                                ));

                    martin.Test.Blittable arg = new martin.Test.Blittable();
                    arg.hello = obj.hello;
                    return(arg);
                }
示例#7
0
 internal static void blittableFunc(martin.Test.Blittable arg)
 {
     System.IntPtr arg_ptr = System.IntPtr.Zero;
     try
     {
         arg_ptr = martin.Test.Blittable.Blittable_Helper.ManagedToNative(arg);
         libxobotos_Test_blittableFunc(arg_ptr);
     }
     finally
     {
         martin.Test.Blittable.Blittable_Helper.FreeManagedPtr(arg_ptr);
     }
 }
示例#8
0
文件: Test.cs 项目: hakeemsm/XobotOS
				public static martin.Test.Blittable NativeToManaged(System.IntPtr ptr)
				{
					if (ptr == System.IntPtr.Zero)
					{
						return null;
					}
					Blittable_Struct obj = (Blittable_Struct)Marshal.PtrToStructure(ptr, typeof(Blittable_Struct
						));
					martin.Test.Blittable arg = new martin.Test.Blittable();
					arg.hello = obj.hello;
					return arg;
				}