Beispiel #1
0
        public void FloatingPointStretTrampolineTest()
        {
            CGRect rect, rect2, rect3, rect4;

#if !__TVOS__
            MKCoordinateRegion mkregion;
            MKMapRect          mkmaprect;
#endif
            FloatingPointStretTrampolines obj = new FloatingPointStretTrampolines();
            IntPtr   class_ptr = Class.GetHandle("FloatingPointStretTrampolines");
            NSString tmp_obj   = obj.StringObj;
#if !__WATCHOS__
            Matrix3       matrix3;
            Matrix4       matrix4;
            CATransform3D catransform3d;
#endif // !__WATCHOS__
            int i;

            rect2 = new CGRect(1.2f, 2.3f, 3.4f, 4.5f);
            if (IsArm64CallingConvention || IsArmv7k)
            {
                rect = CGRect_objc_msgSend_IntPtr_IntPtr_CGRect(obj.Handle, new Selector("testCGRect_string_string_CGRect:b:c:").Handle, new NSString("a").Handle, new NSString("b").Handle, rect2);
            }
            else
            {
                CGRect_objc_msgSend_stret_IntPtr_IntPtr_CGRect(out rect, obj.Handle, new Selector("testCGRect_string_string_CGRect:b:c:").Handle, new NSString("a").Handle, new NSString("b").Handle, rect2);
            }
            Assert.That(rect == new CGRect(rect2.X * pi, rect2.Y * pi, rect2.Width * pi, rect2.Height * pi), "#testCGRect_string_string_CGRect:b:c:");

            if (IsArm64CallingConvention || IsArmv7k)
            {
                rect = Messaging.CGRect_objc_msgSend(obj.Handle, new Selector("testCGRect").Handle);
            }
            else
            {
                Messaging.CGRect_objc_msgSend_stret(out rect, obj.Handle, new Selector("testCGRect").Handle);
            }
            Assert.That(rect == new CGRect(1.2f, 2.3f, 3.4f, 4.5f), "#testCGRect");

            if (IsArm64CallingConvention || IsArmv7k)
            {
                rect = Messaging.CGRect_objc_msgSend(class_ptr, new Selector("staticTestCGRect").Handle);
            }
            else
            {
                Messaging.CGRect_objc_msgSend_stret(out rect, class_ptr, new Selector("staticTestCGRect").Handle);
            }
            Assert.That(rect == new CGRect(1.2f, 2.3f, 3.4f, 4.5f), "#static testCGRect");

            i = 152;
            if (IsArm64CallingConvention || IsArmv7k)
            {
                rect = Messaging.CGRect_objc_msgSend_int(obj.Handle, new Selector("testCGRect_int:").Handle, 152);
            }
            else
            {
                Messaging.CGRect_objc_msgSend_stret_int(out rect, obj.Handle, new Selector("testCGRect_int:").Handle, 152);
            }
            Assert.That(rect == new CGRect(i + .1f, i + .2f, i + .3f, i + .4f), "#ret RectF-int", "#testCGRect_int:");

            if (IsArm64CallingConvention || IsArmv7k)
            {
                rect = Messaging.CGRect_objc_msgSend_IntPtr(obj.Handle, new Selector("testCGRect_IntPtr:").Handle, tmp_obj.Handle);
            }
            else
            {
                Messaging.CGRect_objc_msgSend_stret_IntPtr(out rect, obj.Handle, new Selector("testCGRect_IntPtr:").Handle, tmp_obj.Handle);
            }
            AreAlmostEqual(rect, new CGRect(pi + 0.4f, pi + 0.3f, pi + 0.2f, pi + 0.1f), "#ret RectF-IntPtr");

#if !__TVOS__
            mkregion = new MKCoordinateRegion(new CLLocationCoordinate2D(123.456, 345.678), new MKCoordinateSpan(987.654, 654.321));
            if (IsArm64CallingConvention || IsArmv7k)
            {
                rect = Messaging.CGRect_objc_msgSend_MKCoordinateRegion_IntPtr(obj.Handle, new Selector("testCGRect_MCCoordinateRegion_IntPtr:str:").Handle, mkregion, tmp_obj.Handle);
            }
            else
            {
                Messaging.CGRect_objc_msgSend_stret_MKCoordinateRegion_IntPtr(out rect, obj.Handle, new Selector("testCGRect_MCCoordinateRegion_IntPtr:str:").Handle, mkregion, tmp_obj.Handle);
            }
            Assert.That(rect == new CGRect(123.456f + pi, 345.678f - pi, 987.654f * pi, 654.321f / pi), "#testCGRect_MCCoordinateRegion_IntPtr:str:");

            mkmaprect = new MKMapRect(111.1, 222.2, 333.3, 444.4);
            if (IsArm64CallingConvention || IsArmv7k)
            {
                rect = Messaging.CGRect_objc_msgSend_MKMapRect(obj.Handle, new Selector("testCGRect_MKMapRect:").Handle, mkmaprect);
            }
            else
            {
                Messaging.CGRect_objc_msgSend_stret_MKMapRect(out rect, obj.Handle, new Selector("testCGRect_MKMapRect:").Handle, mkmaprect);
            }
            Assert.That(rect == new CGRect(111.1f, 222.2f, 333.3f, 444.4f), "#testCGRect_MKMapRect:");
#endif // !__TVOS__

            rect2 = new CGRect(9.9f, 8.8f, 7.7f, 6.6f);
            if (IsArm64CallingConvention || IsArmv7k)
            {
                rect = Messaging.CGRect_objc_msgSend_CGRect(obj.Handle, new Selector("testCGRect_CGRect:").Handle, rect2);
            }
            else
            {
                Messaging.CGRect_objc_msgSend_stret_CGRect(out rect, obj.Handle, new Selector("testCGRect_CGRect:").Handle, rect2);
            }
            Assert.That(rect == rect2, "#testCGRect_CGRect:");

            rect2 = new CGRect(5.44f, 4.33f, 3.22f, 2.11f);
            i     = 8;
            if (IsArm64CallingConvention || IsArmv7k)
            {
                rect = Messaging.CGRect_objc_msgSend_CGRect_int(obj.Handle, new Selector("testCGRect_CGRect_int:i:").Handle, rect2, 8);
            }
            else
            {
                Messaging.CGRect_objc_msgSend_stret_CGRect_int(out rect, obj.Handle, new Selector("testCGRect_CGRect_int:i:").Handle, rect2, 8);
            }
            AreAlmostEqual(rect, new CGRect(5.44f * i, 4.33f + i, 3.22f - i, 2.11f / i), "testCGRect_CGRect_int:i:");

            rect2 = new CGRect(5.4f, 4.3f, 3.2f, 2.1f);
            if (IsArm64CallingConvention || IsArmv7k)
            {
                rect = Messaging.CGRect_objc_msgSend_CGRect_IntPtr(obj.Handle, new Selector("testCGRect_CGRect_IntPtr:str:").Handle, rect2, tmp_obj.Handle);
            }
            else
            {
                Messaging.CGRect_objc_msgSend_stret_CGRect_IntPtr(out rect, obj.Handle, new Selector("testCGRect_CGRect_IntPtr:str:").Handle, rect2, tmp_obj.Handle);
            }
            Assert.That(rect == new CGRect(5.4f * pi, 4.3f + pi, 3.2f - pi, 2.1f / pi));

            rect2 = new CGRect(1, 2, 3, 4);
            rect3 = new CGRect(9, 8, 7, 6);
            if (IsArm64CallingConvention || IsArmv7k)
            {
                rect = Messaging.CGRect_objc_msgSend_CGRect_CGRect_float(obj.Handle, new Selector("testCGRect_CGRect_CGRect_float:b:c:").Handle, rect2, rect3, (float)pi);
            }
            else
            {
                Messaging.CGRect_objc_msgSend_stret_CGRect_CGRect_float(out rect, obj.Handle, new Selector("testCGRect_CGRect_CGRect_float:b:c:").Handle, rect2, rect3, (float)pi);
            }
            Assert.That(rect == new CGRect(1 * 9 * pi, 2 * 8 * pi, 3 * 7 * pi, 4 * 6 * pi), "#testCGRect_CGRect_CGRect_float:b:c:");

            rect2 = new CGRect(1, 2, 3, 4);
            rect3 = new CGRect(9, 8, 7, 6);
            rect4 = new CGRect(10, 20, 30, 40);
            if (IsArm64CallingConvention || IsArmv7k)
            {
                rect = Messaging.CGRect_objc_msgSend_CGRect_CGRect_CGRect(obj.Handle, new Selector("testCGRect_CGRect_CGRect_CGRect:b:c:").Handle, rect2, rect3, rect4);
            }
            else
            {
                Messaging.CGRect_objc_msgSend_stret_CGRect_CGRect_CGRect(out rect, obj.Handle, new Selector("testCGRect_CGRect_CGRect_CGRect:b:c:").Handle, rect2, rect3, rect4);
            }
            Assert.That(rect == new CGRect(20, 30, 40, 50), "#testCGRect_CGRect_CGRect_CGRect:b:c:");

#if !__WATCHOS__
            if (IsArm64CallingConvention)
            {
                matrix3 = Messaging.Matrix3_objc_msgSend(obj.Handle, new Selector("testMatrix3").Handle);
            }
            else
            {
                Messaging.Matrix3_objc_msgSend_stret(out matrix3, obj.Handle, new Selector("testMatrix3").Handle);
            }
            Assert.That(matrix3.Equals(new Matrix3(1, 2, 3, 4, 5, 6, 7, 8, 9)), "#testMatrix3");

            if (IsArm64CallingConvention)
            {
                matrix4 = Matrix4_objc_msgSend(obj.Handle, new Selector("testMatrix4").Handle);
            }
            else
            {
                Matrix4_objc_msgSend_stret(out matrix4, obj.Handle, new Selector("testMatrix4").Handle);
            }
            Assert.That(matrix4.Equals(new Matrix4(9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3)), "#testMatrix4");

            if (IsArm64CallingConvention)
            {
                catransform3d = Messaging.CATransform3D_objc_msgSend(obj.Handle, new Selector("testCATransform3D").Handle);
            }
            else
            {
                Messaging.CATransform3D_objc_msgSend_stret(out catransform3d, obj.Handle, new Selector("testCATransform3D").Handle);
            }
            CATransform3D res = new CATransform3D();
            res.m11 = 11.1f;
            res.m22 = 22.2f;
            res.m33 = 33.3f;
            res.m44 = 44.4f;
            Assert.That(catransform3d.Equals(res), "#testCATransform3D");
#endif // !__WATCHOS__

            CGPoint point;
            CGSize  size;

            if (IsArm32)
            {
                Messaging.CGPoint_objc_msgSend_stret(out point, obj.Handle, new Selector("testCGPoint").Handle);
            }
            else
            {
                point = Messaging.CGPoint_objc_msgSend(obj.Handle, new Selector("testCGPoint").Handle);
            }
            Assert.That(point == new CGPoint(pi * 2, pi * 20), "#testCGPoint");

            if (IsArm32)
            {
                Messaging.CGSize_objc_msgSend_stret(out size, obj.Handle, new Selector("testCGSize").Handle);
            }
            else
            {
                size = Messaging.CGSize_objc_msgSend(obj.Handle, new Selector("testCGSize").Handle);
            }
            Assert.That(size == new CGSize(pi * 3, pi * 30), "#testCGSize");
        }