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


Python POINTER.from_param方法代码示例

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


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

示例1: test_byref_pointer

# 需要导入模块: from ctypes import POINTER [as 别名]
# 或者: from ctypes.POINTER import from_param [as 别名]
 def test_byref_pointer(self):
     from ctypes import c_short, c_uint, c_int, c_long, pointer, POINTER, byref
     LPINT = POINTER(c_int)
     LPINT.from_param(byref(c_int(42)))
     self.assertRaises(TypeError, LPINT.from_param, byref(c_short(22)))
     if c_int != c_long:
         self.assertRaises(TypeError, LPINT.from_param, byref(c_long(22)))
     self.assertRaises(TypeError, LPINT.from_param, byref(c_uint(22)))
开发者ID:webiumsk,项目名称:WOT-0.9.15-CT,代码行数:10,代码来源:test_parameters.py

示例2: test_byref_pointerpointer

# 需要导入模块: from ctypes import POINTER [as 别名]
# 或者: from ctypes.POINTER import from_param [as 别名]
    def test_byref_pointerpointer(self):
        # See above
        from ctypes import c_short, c_uint, c_int, c_long, pointer, POINTER, byref

        LPLPINT = POINTER(POINTER(c_int))
        LPLPINT.from_param(byref(pointer(c_int(42))))

        raises(TypeError, LPLPINT.from_param, byref(pointer(c_short(22))))
        if c_int != c_long:
            raises(TypeError, LPLPINT.from_param, byref(pointer(c_long(22))))
        raises(TypeError, LPLPINT.from_param, byref(pointer(c_uint(22))))
开发者ID:Qointum,项目名称:pypy,代码行数:13,代码来源:test_parameters.py

示例3: test_array_pointers

# 需要导入模块: from ctypes import POINTER [as 别名]
# 或者: from ctypes.POINTER import from_param [as 别名]
 def test_array_pointers(self):
     from ctypes import c_short, c_uint, c_int, c_long, POINTER
     INTARRAY = c_int * 3
     ia = INTARRAY()
     self.assertEqual(len(ia), 3)
     self.assertEqual([ ia[i] for i in range(3) ], [0, 0, 0])
     LPINT = POINTER(c_int)
     LPINT.from_param((c_int * 3)())
     self.assertRaises(TypeError, LPINT.from_param, c_short * 3)
     self.assertRaises(TypeError, LPINT.from_param, c_long * 3)
     self.assertRaises(TypeError, LPINT.from_param, c_uint * 3)
开发者ID:webiumsk,项目名称:WOT-0.9.15-CT,代码行数:13,代码来源:test_parameters.py

示例4: test_byref_pointer

# 需要导入模块: from ctypes import POINTER [as 别名]
# 或者: from ctypes.POINTER import from_param [as 别名]
    def test_byref_pointer(self):
        # The from_param class method of POINTER(typ) classes accepts what is
        # returned by byref(obj), it type(obj) == typ
        from ctypes import c_short, c_uint, c_int, c_long, pointer, POINTER, byref
        LPINT = POINTER(c_int)

        LPINT.from_param(byref(c_int(42)))

        self.assertRaises(TypeError, LPINT.from_param, byref(c_short(22)))
        if c_int != c_long:
            self.assertRaises(TypeError, LPINT.from_param, byref(c_long(22)))
        self.assertRaises(TypeError, LPINT.from_param, byref(c_uint(22)))
开发者ID:timm,项目名称:timmnix,代码行数:14,代码来源:test_parameters.py

示例5: test_int_pointers

# 需要导入模块: from ctypes import POINTER [as 别名]
# 或者: from ctypes.POINTER import from_param [as 别名]
 def test_int_pointers(self):
     from ctypes import c_short, c_uint, c_int, c_long, POINTER, pointer
     LPINT = POINTER(c_int)
     x = LPINT.from_param(pointer(c_int(42)))
     self.assertEqual(x.contents.value, 42)
     self.assertEqual(LPINT(c_int(42)).contents.value, 42)
     self.assertEqual(LPINT.from_param(None), None)
     if c_int != c_long:
         self.assertRaises(TypeError, LPINT.from_param, pointer(c_long(42)))
     self.assertRaises(TypeError, LPINT.from_param, pointer(c_uint(42)))
     self.assertRaises(TypeError, LPINT.from_param, pointer(c_short(42)))
     return
开发者ID:webiumsk,项目名称:WOT-0.9.15-CT,代码行数:14,代码来源:test_parameters.py

示例6: test_array_pointers

# 需要导入模块: from ctypes import POINTER [as 别名]
# 或者: from ctypes.POINTER import from_param [as 别名]
    def test_array_pointers(self):
        from ctypes import c_short, c_uint, c_int, c_long, POINTER
        INTARRAY = c_int * 3
        ia = INTARRAY()
        self.assertEqual(len(ia), 3)
        self.assertEqual([ia[i] for i in range(3)], [0, 0, 0])

        # Pointers are only compatible with arrays containing items of
        # the same type!
        LPINT = POINTER(c_int)
        LPINT.from_param((c_int*3)())
        self.assertRaises(TypeError, LPINT.from_param, c_short*3)
        self.assertRaises(TypeError, LPINT.from_param, c_long*3)
        self.assertRaises(TypeError, LPINT.from_param, c_uint*3)
开发者ID:timm,项目名称:timmnix,代码行数:16,代码来源:test_parameters.py

示例7: test_int_pointers

# 需要导入模块: from ctypes import POINTER [as 别名]
# 或者: from ctypes.POINTER import from_param [as 别名]
    def test_int_pointers(self):
        from ctypes import c_short, c_uint, c_int, c_long, POINTER, pointer
        LPINT = POINTER(c_int)

##        p = pointer(c_int(42))
##        x = LPINT.from_param(p)
        x = LPINT.from_param(pointer(c_int(42)))
        assert x.contents.value == 42
        assert LPINT(c_int(42)).contents.value == 42

        assert not LPINT.from_param(None)

        if c_int != c_long:
            raises(TypeError, LPINT.from_param, pointer(c_long(42)))
        raises(TypeError, LPINT.from_param, pointer(c_uint(42)))
        raises(TypeError, LPINT.from_param, pointer(c_short(42)))
开发者ID:Qointum,项目名称:pypy,代码行数:18,代码来源:test_parameters.py

示例8: test_int_pointers

# 需要导入模块: from ctypes import POINTER [as 别名]
# 或者: from ctypes.POINTER import from_param [as 别名]
    def test_int_pointers(self):
        from ctypes import c_short, c_uint, c_int, c_long, POINTER, pointer
        LPINT = POINTER(c_int)

##        p = pointer(c_int(42))
##        x = LPINT.from_param(p)
        x = LPINT.from_param(pointer(c_int(42)))
        self.assertEqual(x.contents.value, 42)
        self.assertEqual(LPINT(c_int(42)).contents.value, 42)

        if not due_to_ironpython_bug("http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=24755"):
            self.assertEqual(LPINT.from_param(None), None)

        if c_int != c_long:
            self.assertRaises(TypeError, LPINT.from_param, pointer(c_long(42)))
        self.assertRaises(TypeError, LPINT.from_param, pointer(c_uint(42)))
        self.assertRaises(TypeError, LPINT.from_param, pointer(c_short(42)))
开发者ID:BillyboyD,项目名称:main,代码行数:19,代码来源:test_parameters.py

示例9: test_pointer_subclasses

# 需要导入模块: from ctypes import POINTER [as 别名]
# 或者: from ctypes.POINTER import from_param [as 别名]
    def test_pointer_subclasses(self):
        from ctypes import POINTER, c_void_p

        Void_pp = POINTER(c_void_p)
        class My_void_p(c_void_p):
            pass

        My_void_pp = POINTER(My_void_p)
        o = My_void_pp()

        assert Void_pp.from_param(o) is o
开发者ID:Qointum,项目名称:pypy,代码行数:13,代码来源:test_parameters.py

示例10: _POINTER

# 需要导入模块: from ctypes import POINTER [as 别名]
# 或者: from ctypes.POINTER import from_param [as 别名]
def _POINTER(cls):
    cls = POINTER(cls)
    cls.from_param = classmethod(allow_void_p_param(cls.from_param))
    cls.get_void_p = get_void_p
    return cls
开发者ID:lhl,项目名称:pyglfw,代码行数:7,代码来源:c_helper.py

示例11: _RAMPPTR

# 需要导入模块: from ctypes import POINTER [as 别名]
# 或者: from ctypes.POINTER import from_param [as 别名]
def _RAMPPTR(cls):
    cls = POINTER(cls)
    cls.from_param = classmethod(cast_from_tuple(cls.from_param))
    return cls
开发者ID:lhl,项目名称:pyglfw,代码行数:6,代码来源:c_helper.py


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