当前位置: 首页>>代码示例>>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;未经允许,请勿转载。