當前位置: 首頁>>代碼示例>>Python>>正文


Python ctypes._CFuncPtr方法代碼示例

本文整理匯總了Python中ctypes._CFuncPtr方法的典型用法代碼示例。如果您正苦於以下問題:Python ctypes._CFuncPtr方法的具體用法?Python ctypes._CFuncPtr怎麽用?Python ctypes._CFuncPtr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ctypes的用法示例。


在下文中一共展示了ctypes._CFuncPtr方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: WINFUNCTYPE

# 需要導入模塊: import ctypes [as 別名]
# 或者: from ctypes import _CFuncPtr [as 別名]
def WINFUNCTYPE(restype, *argtypes, **kw):
        flags = _FUNCFLAG_STDCALL
        if kw.pop("use_errno", False):
            flags |= ctypes._FUNCFLAG_USE_ERRNO
        if kw.pop("use_last_error", False):
            flags |= ctypes._FUNCFLAG_USE_LASTERROR
        if kw:
            raise ValueError("unexpected keyword argument(s) %s" % kw.keys())
        try:
            return ctypes._win_functype_cache[(restype, argtypes, flags)]
        except KeyError:
            class WinFunctionType(ctypes._CFuncPtr):
                _argtypes_ = argtypes
                _restype_ = restype
                _flags_ = flags
            ctypes._win_functype_cache[(restype, argtypes, flags)] = WinFunctionType
            return WinFunctionType 
開發者ID:debasishm89,項目名稱:OpenXMolar,代碼行數:19,代碼來源:__init__.py

示例2: enumerate_winfuncs

# 需要導入模塊: import ctypes [as 別名]
# 或者: from ctypes import _CFuncPtr [as 別名]
def enumerate_winfuncs(self):
        for obj in vars(windows.generated_def.winfuncs):
            instance = eval("windows.generated_def.winfuncs." + obj)

            if hasattr(instance, '__bases__') and instance.__bases__[0] is _CFuncPtr:
                function_name = obj[0:-1 * len('Prototype')]
                if not function_name in self.function_prototypes:
                    self.function_prototypes[function_name] = {}

                self.function_prototypes[function_name]['restype'] = instance._restype_.__name__
                argtypes = []
                for argtype in instance._argtypes_:
                    argtypes.append(argtype.__name__)

                    if not argtype in self.argtypes:
                        self.argtypes[argtype.__name__] = 1

                self.function_prototypes[function_name]['arg_types'] = argtypes

            elif obj.endswith('Params'):
                function_name = obj[0:-1 * len('Params')]
                if not function_name in self.function_prototypes:
                    self.function_prototypes[function_name] = {}

                self.function_prototypes[function_name]['arg_names'] = instance 
開發者ID:ohjeongwook,項目名稱:windbgtool,代碼行數:27,代碼來源:enumerate_windef.py

示例3: test_abstract

# 需要導入模塊: import ctypes [as 別名]
# 或者: from ctypes import _CFuncPtr [as 別名]
def test_abstract(self):
        from ctypes import _CFuncPtr

        self.assertRaises(TypeError, _CFuncPtr, 13, "name", 42, "iid") 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:6,代碼來源:test_funcptr.py

示例4: duplicate

# 需要導入模塊: import ctypes [as 別名]
# 或者: from ctypes import _CFuncPtr [as 別名]
def duplicate(self, other):
		if callable(other):
			if isinstance(other, ctypes._CFuncPtr):
				other = ctypes.cast(other, ctypes.c_void_p).value
		elif not isinstance(other, int):
			other = ctypes.cast(other, ctypes.c_void_p).value
		return self.__class__(other) 
開發者ID:zeroSteiner,項目名稱:mayhem,代碼行數:9,代碼來源:common.py

示例5: generate_callback_decorator

# 需要導入模塊: import ctypes [as 別名]
# 或者: from ctypes import _CFuncPtr [as 別名]
def generate_callback_decorator(self, flags, restype, *argtypes, **kwargs):

		_memsync_ = kwargs.pop('memsync', [])

		if not(flags & _FUNCFLAG_STDCALL):
			func_type_key = _FUNCFLAG_CDECL
		else:
			func_type_key = _FUNCFLAG_STDCALL

		try:

			# There already is a matching function pointer type available
			return self.cache_dict['func_type'][func_type_key][(restype, argtypes, flags)]

		except KeyError:

			# Create new function pointer type class
			class FunctionType(ctypes._CFuncPtr):

				_argtypes_ = argtypes
				_restype_ = restype
				memsync = self.unpack_definition_memsync(_memsync_)
				_flags_ = flags

			# Store the new type and return
			self.cache_dict['func_type'][func_type_key][(restype, argtypes, flags)] = FunctionType
			return FunctionType 
開發者ID:pleiszenburg,項目名稱:zugbruecke,代碼行數:29,代碼來源:arg_definition.py


注:本文中的ctypes._CFuncPtr方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。