本文整理汇总了Python中ctypes._win_functype_cache方法的典型用法代码示例。如果您正苦于以下问题:Python ctypes._win_functype_cache方法的具体用法?Python ctypes._win_functype_cache怎么用?Python ctypes._win_functype_cache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ctypes
的用法示例。
在下文中一共展示了ctypes._win_functype_cache方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: WINFUNCTYPE
# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import _win_functype_cache [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
示例2: test_with_refcounts
# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import _win_functype_cache [as 别名]
def test_with_refcounts(runner, verbosity, testcase):
"""Run testcase several times, tracking reference counts."""
import gc
import ctypes
ptc = ctypes._pointer_type_cache.copy()
cfc = ctypes._c_functype_cache.copy()
wfc = ctypes._win_functype_cache.copy()
# when searching for refcount leaks, we have to manually reset any
# caches that ctypes has.
def cleanup():
ctypes._pointer_type_cache = ptc.copy()
ctypes._c_functype_cache = cfc.copy()
ctypes._win_functype_cache = wfc.copy()
gc.collect()
test = unittest.makeSuite(testcase)
for i in range(5):
rc = sys.gettotalrefcount()
runner.run(test)
cleanup()
COUNT = 5
refcounts = [None] * COUNT
for i in range(COUNT):
rc = sys.gettotalrefcount()
runner.run(test)
cleanup()
refcounts[i] = sys.gettotalrefcount() - rc
if filter(None, refcounts):
print "%s leaks:\n\t" % testcase, refcounts
elif verbosity:
print "%s: ok." % testcase
示例3: _reset_cache
# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import _win_functype_cache [as 别名]
def _reset_cache():
ctypes._win_functype_cache.clear()
_original_reset_cache()