当前位置: 首页>>代码示例>>Python>>正文


Python VirtualMethods.virtualMethod0方法代码示例

本文整理汇总了Python中sample.VirtualMethods.virtualMethod0方法的典型用法代码示例。如果您正苦于以下问题:Python VirtualMethods.virtualMethod0方法的具体用法?Python VirtualMethods.virtualMethod0怎么用?Python VirtualMethods.virtualMethod0使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sample.VirtualMethods的用法示例。


在下文中一共展示了VirtualMethods.virtualMethod0方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testForInfiniteRecursion

# 需要导入模块: from sample import VirtualMethods [as 别名]
# 或者: from sample.VirtualMethods import virtualMethod0 [as 别名]
 def testForInfiniteRecursion(self):
     def myVirtualMethod0(obj, pt, val, cpx, b):
         self.call_counter += 1
         return VirtualMethods.virtualMethod0(obj, pt, val, cpx, b)
     vm = VirtualMethods()
     vm.virtualMethod0 = types.MethodType(myVirtualMethod0, vm, VirtualMethods)
     pt, val, cpx, b = Point(1.1, 2.2), 4, complex(3.3, 4.4), True
     vm.virtualMethod0(pt, val, cpx, b)
     self.assertEqual(self.call_counter, 1)
开发者ID:OdyX,项目名称:Shiboken,代码行数:11,代码来源:duck_punching_test.py

示例2: testMonkeyPatchOnVirtualMethod

# 需要导入模块: from sample import VirtualMethods [as 别名]
# 或者: from sample.VirtualMethods import virtualMethod0 [as 别名]
    def testMonkeyPatchOnVirtualMethod(self):
        '''Injects new 'virtualMethod0' on a VirtualMethods instance and makes C++ call it.'''
        vm = VirtualMethods()
        pt, val, cpx, b = Point(1.1, 2.2), 4, complex(3.3, 4.4), True

        result1 = vm.virtualMethod0(pt, val, cpx, b)
        result2 = vm.callVirtualMethod0(pt, val, cpx, b)
        self.assertEqual(result1, result2)
        self.assertEqual(result1, VirtualMethods.virtualMethod0(vm, pt, val, cpx, b))

        def myVirtualMethod0(obj, pt, val, cpx, b):
            self.duck_method_called = True
            return VirtualMethods.virtualMethod0(obj, pt, val, cpx, b) * self.multiplier
        vm.virtualMethod0 = types.MethodType(myVirtualMethod0, vm, VirtualMethods)

        result1 = vm.callVirtualMethod0(pt, val, cpx, b)
        self.assert_(self.duck_method_called)

        result2 = vm.virtualMethod0(pt, val, cpx, b)
        self.assertEqual(result1, result2)
        self.assertEqual(result1, VirtualMethods.virtualMethod0(vm, pt, val, cpx, b) * self.multiplier)

        # This is done to decrease the refcount of the vm object
        # allowing the object wrapper to be deleted before the
        # BindingManager. This is useful when compiling Shiboken
        # for debug, since the BindingManager destructor has an
        # assert that checks if the wrapper mapper is empty.
        vm.virtualMethod0 = None
开发者ID:OdyX,项目名称:Shiboken,代码行数:30,代码来源:duck_punching_test.py

示例3: testMonkeyPatchOnVirtualMethodWithInheritance

# 需要导入模块: from sample import VirtualMethods [as 别名]
# 或者: from sample.VirtualMethods import virtualMethod0 [as 别名]
    def testMonkeyPatchOnVirtualMethodWithInheritance(self):
        '''Injects new 'virtualMethod0' on an object that inherits from VirtualMethods and makes C++ call it.'''
        duck = Duck()
        pt, val, cpx, b = Point(1.1, 2.2), 4, complex(3.3, 4.4), True

        result1 = duck.virtualMethod0(pt, val, cpx, b)
        result2 = duck.callVirtualMethod0(pt, val, cpx, b)
        self.assertEqual(result1, result2)
        self.assertEqual(result1, VirtualMethods.virtualMethod0(duck, pt, val, cpx, b))

        def myVirtualMethod0(obj, pt, val, cpx, b):
            self.duck_method_called = True
            return VirtualMethods.virtualMethod0(obj, pt, val, cpx, b) * self.multiplier
        duck.virtualMethod0 = types.MethodType(myVirtualMethod0, duck, Duck)

        result1 = duck.callVirtualMethod0(pt, val, cpx, b)
        self.assert_(self.duck_method_called)

        result2 = duck.virtualMethod0(pt, val, cpx, b)
        self.assertEqual(result1, result2)
        self.assertEqual(result1, VirtualMethods.virtualMethod0(duck, pt, val, cpx, b) * self.multiplier)

        duck.virtualMethod0 = None
开发者ID:OdyX,项目名称:Shiboken,代码行数:25,代码来源:duck_punching_test.py

示例4: myVirtualMethod0

# 需要导入模块: from sample import VirtualMethods [as 别名]
# 或者: from sample.VirtualMethods import virtualMethod0 [as 别名]
 def myVirtualMethod0(obj, pt, val, cpx, b):
     self.duck_method_called = True
     return VirtualMethods.virtualMethod0(obj, pt, val, cpx, b) * self.multiplier
开发者ID:OdyX,项目名称:Shiboken,代码行数:5,代码来源:duck_punching_test.py


注:本文中的sample.VirtualMethods.virtualMethod0方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。