示例#1
0
    def test_byref_out(self):
        o = OC_TestDecimal.alloc().init()
        self.assertArgIsOut(o.getDecimal_, 0)
        r = o.getDecimal_(None)

        self.assertIsInstance(r, tuple)
        self.assertEqual(r[0], 1)
        d = r[1]
        self.assertIsInstance(d, objc.NSDecimal)
        self.assertEqual(str(d), "2.5")

        objc._updatingMetadata(True)
        objc.registerMetaDataForSelector(
            b"OC_TestDecimal",
            b"getDecimal:",
            {
                "arguments": {
                    2 + 0: {
                        "type_modifier": objc._C_OUT,
                        "type": b"^{_NSDecimal=b8b4b1b1b18[8S]}",
                        "null_accepted": False,
                    }
                }
            },
        )
        objc._updatingMetadata(False)
        self.assertArgIsOut(o.getDecimal_, 0)
        r = o.getDecimal_(None)
        self.assertIsInstance(r, tuple)
        self.assertEqual(r[0], 1)
        d = r[1]
        self.assertIsInstance(d, objc.NSDecimal)
        self.assertEqual(str(d), "2.5")
示例#2
0
    def test_byref_out(self):
        o = OC_TestDecimal.alloc().init()
        self.assertArgIsOut(o.getDecimal_, 0)
        r = o.getDecimal_(None)

        self.assertIsInstance(r, tuple)
        self.assertEqual(r[0], 1)
        d = r[1]
        self.assertIsInstance(d, objc.NSDecimal)
        self.assertEqual(str(d), "2.5")

        objc._updatingMetadata(True)
        objc.registerMetaDataForSelector(b"OC_TestDecimal", b"getDecimal:",
            dict(
                arguments={
                    2+0:  dict(type_modifier=objc._C_OUT, type=b'^{_NSDecimal=b8b4b1b1b18[8S]}', null_accepted=False),
                    #2+0:  dict(type=b'o^{_NSDecimal=b8b4b1b1b18[8S]}', null_accepted=False),
                }
            )
        )
        objc._updatingMetadata(False)
        self.assertArgIsOut(o.getDecimal_, 0)
        r = o.getDecimal_(None)
        self.assertIsInstance(r, tuple)
        self.assertEqual(r[0], 1)
        d = r[1]
        self.assertIsInstance(d, objc.NSDecimal)
        self.assertEqual(str(d), "2.5")
示例#3
0
    def test_byref_out(self):
        o = OC_TestDecimal.alloc().init()
        self.assertArgIsOut(o.getDecimal_, 0)
        r = o.getDecimal_(None)

        self.assertIsInstance(r, tuple)
        self.assertEqual(r[0], 1)
        d = r[1]
        self.assertIsInstance(d, objc.NSDecimal)
        self.assertEqual(str(d), "2.5")

        objc._updatingMetadata(True)
        objc.registerMetaDataForSelector(
            b"OC_TestDecimal",
            b"getDecimal:",
            dict(
                arguments={
                    2 + 0:
                    dict(type_modifier=objc._C_OUT,
                         type=b'^{_NSDecimal=b8b4b1b1b18[8S]}',
                         null_accepted=False),
                    #2+0:  dict(type=b'o^{_NSDecimal=b8b4b1b1b18[8S]}', null_accepted=False),
                }))
        objc._updatingMetadata(False)
        self.assertArgIsOut(o.getDecimal_, 0)
        r = o.getDecimal_(None)
        self.assertIsInstance(r, tuple)
        self.assertEqual(r[0], 1)
        d = r[1]
        self.assertIsInstance(d, objc.NSDecimal)
        self.assertEqual(str(d), "2.5")
示例#4
0
    def test_byref_in(self):
        d = objc.NSDecimal("1.5")

        o = OC_TestDecimal.alloc().init()
        self.assertArgIsIn(o.stringFromDecimal_, 0)
        r = o.stringFromDecimal_(d)

        self.assertIsInstance(r, unicode)
        self.assertEqual(r, "1.5")
示例#5
0
    def test_byref_in(self):
        d = objc.NSDecimal("1.5")

        o = OC_TestDecimal.alloc().init()
        self.assertArgIsIn(o.stringFromDecimal_, 0)
        r = o.stringFromDecimal_(d)

        self.assertIsInstance(r, str)
        self.assertEqual(r, "1.5")
示例#6
0
    def test_byref_inout(self):
        d1 = objc.NSDecimal("1.25")
        o = OC_TestDecimal.alloc().init()
        self.assertArgIsInOut(o.doubleDecimal_, 0)

        d2 = o.doubleDecimal_(d1)
        self.assertIsNot(d1, d2)
        self.assertEqual(str(d1), "1.25")
        self.assertIsInstance(d2, objc.NSDecimal)
        self.assertEqual(str(d2), "2.5")
示例#7
0
    def test_byref_inout(self):
        d1 = objc.NSDecimal("1.25")
        o = OC_TestDecimal.alloc().init()
        self.assertArgIsInOut(o.doubleDecimal_, 0)

        d2 = o.doubleDecimal_(d1)
        self.assertIsNot(d1, d2)
        self.assertEqual(str(d1), "1.25")
        self.assertIsInstance(d2, objc.NSDecimal)
        self.assertEqual(str(d2), "2.5")
示例#8
0
    def test_byref_out(self):
        o = OC_TestDecimal.alloc().init()
        self.assertArgIsOut(o.getDecimal_, 0)
        r = o.getDecimal_(None)

        self.assertIsInstance(r, tuple)
        self.assertEqual(r[0], 1)
        d = r[1]
        self.assertIsInstance(d, objc.NSDecimal)
        self.assertEqual(str(d), "2.5")