Python ctypes._CFuncPtr() Examples
The following are 8
code examples of ctypes._CFuncPtr().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
ctypes
, or try the search function
.
Example #1
Source File: __init__.py From OpenXMolar with BSD 3-Clause "New" or "Revised" License | 6 votes |
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
Example #2
Source File: enumerate_windef.py From windbgtool with MIT License | 6 votes |
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
Example #3
Source File: test_funcptr.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_abstract(self): from ctypes import _CFuncPtr self.assertRaises(TypeError, _CFuncPtr, 13, "name", 42, "iid")
Example #4
Source File: common.py From mayhem with BSD 3-Clause "New" or "Revised" License | 5 votes |
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)
Example #5
Source File: test_funcptr.py From Imogen with MIT License | 5 votes |
def test_abstract(self): from ctypes import _CFuncPtr self.assertRaises(TypeError, _CFuncPtr, 13, "name", 42, "iid")
Example #6
Source File: test_funcptr.py From odoo13-x64 with GNU General Public License v3.0 | 5 votes |
def test_abstract(self): from ctypes import _CFuncPtr self.assertRaises(TypeError, _CFuncPtr, 13, "name", 42, "iid")
Example #7
Source File: test_funcptr.py From android_universal with MIT License | 5 votes |
def test_abstract(self): from ctypes import _CFuncPtr self.assertRaises(TypeError, _CFuncPtr, 13, "name", 42, "iid")
Example #8
Source File: arg_definition.py From zugbruecke with GNU Lesser General Public License v2.1 | 5 votes |
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