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


Python ctypes.POINTER类代码示例

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


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

示例1: test_byref_pointer

 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,代码行数:8,代码来源:test_parameters.py

示例2: test_array_pointers

 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,代码行数:11,代码来源:test_parameters.py

示例3: test_pointer_subclasses

    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,代码行数:11,代码来源:test_parameters.py

示例4: test_byref_pointerpointer

    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,代码行数:11,代码来源:test_parameters.py

示例5: test_int_pointers

 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,代码行数:12,代码来源:test_parameters.py

示例6: test_byref_pointer

    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,代码行数:12,代码来源:test_parameters.py

示例7: test_array_pointers

    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,代码行数:14,代码来源:test_parameters.py

示例8: test_int_pointers

    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,代码行数:16,代码来源:test_parameters.py

示例9: test_int_pointers

    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,代码行数:17,代码来源:test_parameters.py

示例10: __debug_create

 def __debug_create(self):
     """create IDebugClient"""
     
     self.__idebug_client = POINTER(DbgEng.IDebugClient)()
     hr = DebugCreate(byref(DbgEng.IDebugClient._iid_), byref(self.__idebug_client))
     if S_OK != hr:
         raise Exception('DebugCreate() fail.')
     else:
         logger.debug('[D] DebugClient: ' + str(self.__idebug_client))
开发者ID:z3r0zh0u,项目名称:pydbgx,代码行数:9,代码来源:pydbgx.py

示例11: fn

 def fn():
     p = POINTER(c_int)()
     assert not p
     p.contents = c_int(12)
     assert p
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:5,代码来源:test_rpointer.py

示例12: LibraryNotFoundError

if not security_path:
    raise LibraryNotFoundError('The library Security could not be found')

Security = CDLL(security_path, use_errno=True)

Boolean = c_bool
CFIndex = c_long
CFData = c_void_p
CFString = c_void_p
CFArray = c_void_p
CFDictionary = c_void_p
CFError = c_void_p
CFType = c_void_p
CFTypeID = c_ulong

CFTypeRef = POINTER(CFType)
CFAllocatorRef = c_void_p

OSStatus = c_int32

CFDataRef = POINTER(CFData)
CFStringRef = POINTER(CFString)
CFArrayRef = POINTER(CFArray)
CFDictionaryRef = POINTER(CFDictionary)
CFErrorRef = POINTER(CFError)

SecKeyRef = POINTER(c_void_p)
SecCertificateRef = POINTER(c_void_p)
SecTransformRef = POINTER(c_void_p)
SecRandomRef = c_void_p
SecTrustSettingsDomain = c_uint32
开发者ID:doncisco,项目名称:sublime-text-2-settings,代码行数:31,代码来源:_security_ctypes.py

示例13: _RAMPPTR

def _RAMPPTR(cls):
    cls = POINTER(cls)
    cls.from_param = classmethod(cast_from_tuple(cls.from_param))
    return cls
开发者ID:lhl,项目名称:pyglfw,代码行数:4,代码来源:c_helper.py

示例14: CFUNCTYPE

FT_Int = c_int
FT_UInt = c_uint
FT_F2Dot14 = c_short
FT_Pos = FT_Fixed = FT_Long = c_long
FT_Glyph_Format = c_int
FT_String_p = c_char_p
FT_Short = c_short  # A typedef for signed short.
FT_UShort = c_ushort  # A typedef for unsigned short.
FT_Generic_Finalizer = CFUNCTYPE(None, c_void_p)
FT_Encoding = c_int


class FT_LibraryRec(Structure):
    _fields_ = []
FT_Library = POINTER(FT_LibraryRec)


class FT_Vector(Structure):
    _fields_ = [('x', FT_Pos), ('y', FT_Pos)]


class FT_UnitVector(Structure):
    _fields_ = [('x', FT_F2Dot14), ('y', FT_F2Dot14)]


class FT_Matrix(Structure):
    _fields_ = [('xx', FT_Fixed), ('xy', FT_Fixed),
                ('yx', FT_Fixed), ('yy', FT_Fixed)]

开发者ID:shjoshi,项目名称:vispy,代码行数:28,代码来源:freetype.py

示例15: __init__

class DebugClient:
    """IDebugClient Wrapper"""
    
    def __init__(self):
        """DebugClient initialization"""

        self.__debug_create()


    def __debug_create(self):
        """create IDebugClient"""
        
        self.__idebug_client = POINTER(DbgEng.IDebugClient)()
        hr = DebugCreate(byref(DbgEng.IDebugClient._iid_), byref(self.__idebug_client))
        if S_OK != hr:
            raise Exception('DebugCreate() fail.')
        else:
            logger.debug('[D] DebugClient: ' + str(self.__idebug_client))

    def query_interface(self, interface):
        """IDebugClient::QueryInterface method"""

        return self.__idebug_client.QueryInterface(interface)


    def get_indentity(self):
        """IDebugClient::GetIdentity method"""

        buffer_size = 0x100
        identity_size = c_ulong(0)
        hr = self.__idebug_client._IDebugClient__com_GetIdentity(None, buffer_size, byref(identity_size))
        if S_OK != hr:
            raise Exception('GetIdentity() fail.')

        buffer_size = identity_size.value + 1
        buffer = create_string_buffer(buffer_size)
        hr = self.__idebug_client._IDebugClient__com_GetIdentity(buffer, buffer_size, byref(identity_size))
        if S_OK != hr:
            raise Exception('GetIdentity() fail.')
        
        return buffer.value

    def set_event_callbacks(self, event_callbacks):
        """IDebugClient::SetEventCallbacks method"""

        hr = self.__idebug_client.SetEventCallbacks(event_callbacks)
        if S_OK != hr:
            raise Exception('SetEventCallbacks() fail.')

    def get_event_callbacks(self):
        """IDebugClient::GetEventCallbacks method"""

        return self.__idebug_client.GetEventCallbacks()

    def set_output_callbacks(self, output_callbacks):
        """IDebugClient::SetOutputCallbacks method"""

        hr = self.__idebug_client.SetOutputCallbacks(output_callbacks)
        if S_OK != hr:
            raise Exception('SetOutputCallbacks() fail.')

    def get_output_callbacks(self):
        """IDebugClient::GetOutputCallbacks method"""

        return self.__idebug_client.GetOutputCallbacks()

    def get_running_process_ids(self):
        """IDebugClient::GetRunningProcessSystemIds method"""

        server = 0
        count = 256
        ids = (c_ulong * count)()
        actual_count = c_ulong(0)
        hr = self.__idebug_client._IDebugClient__com_GetRunningProcessSystemIds(server, ids, count, byref(actual_count))
        if S_OK != hr:
            raise Exception('GetRunningProcessSystemIds() fail.')

        return ids, actual_count.value

    def get_running_process_desc(self, sysid):
        """IDebugClient::GetRunningProcessDescription method"""

        try:
            server = 0
            flags  = DbgEng.DEBUG_PROC_DESC_NO_PATHS
            exename_size = 0x100
            exename = create_string_buffer(exename_size)
            actual_exename_size = c_ulong(0)
            description_size = 0x100
            description = create_string_buffer(description_size)
            actual_description_size = c_ulong(0)
                
            hr = self.__idebug_client._IDebugClient__com_GetRunningProcessDescription(
                server, sysid, flags,
                exename, exename_size, byref(actual_exename_size),
                description, description_size, byref(actual_description_size))
                
            if S_OK != hr:
                if S_FALSE == hr:
                    exename_size = actual_exename_size.value + 1
#.........这里部分代码省略.........
开发者ID:z3r0zh0u,项目名称:pydbgx,代码行数:101,代码来源:pydbgx.py


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