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


Python ctypes._win_functype_cache方法代碼示例

本文整理匯總了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 
開發者ID:debasishm89,項目名稱:OpenXMolar,代碼行數:19,代碼來源:__init__.py

示例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 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:34,代碼來源:__init__.py

示例3: _reset_cache

# 需要導入模塊: import ctypes [as 別名]
# 或者: from ctypes import _win_functype_cache [as 別名]
def _reset_cache():
        ctypes._win_functype_cache.clear()
        _original_reset_cache() 
開發者ID:debasishm89,項目名稱:OpenXMolar,代碼行數:5,代碼來源:__init__.py


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