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]@Ze1edgkreZn&e1ed{kreZne1edkreZqWxPeeEgD]@Ze1edgkreZn&e1ed{kreZne1edkreZqW[eTdS)Nz1.1.0)Union StructureArray)_Pointer)CFuncPtr) __version__) RTLD_LOCAL RTLD_GLOBAL) ArgumentError)calcsizezVersion number mismatchnt) FormatErrorposixdarwin.)FUNCFLAG_CDECLFUNCFLAG_PYTHONAPIFUNCFLAG_USE_ERRNOFUNCFLAG_USE_LASTERRORcCs^t|tr6|dkrt|d}t|}|}||_|St|trRt|}|}|St|dS)N) isinstancebyteslenc_charvalueint TypeError)initsizebuftypebufr"'/usr/lib64/python3.6/ctypes/__init__.pycreate_string_buffer/s   r$cCs t||S)N)r$)rrr"r"r#c_bufferAsr%c st|jddrtO|jddr,tO|r@td|jytfStk rGfdddt}|tf<|SXdS)N use_errnoFuse_last_errorz!unexpected keyword argument(s) %scseZdZZZZdS)z CFUNCTYPE..CFunctionTypeN)__name__ __module__ __qualname__ _argtypes_ _restype__flags_r")argtypesflagsrestyper"r# CFunctionTypecsr1) _FUNCFLAG_CDECLpop_FUNCFLAG_USE_ERRNO_FUNCFLAG_USE_LASTERROR ValueErrorkeys_c_functype_cacheKeyError _CFuncPtr)r0r.kwr1r")r.r/r0r# CFUNCTYPEIs  r<) LoadLibrary)FUNCFLAG_STDCALLc st|jddrtO|jddr,tO|r@td|jytfStk rGfdddt}|tf<|SXdS)Nr&Fr'z!unexpected keyword argument(s) %scseZdZZZZdS)z$WINFUNCTYPE..WinFunctionTypeN)r(r)r*r+r,r-r")r.r/r0r"r#WinFunctionType{sr?) _FUNCFLAG_STDCALLr3r4r5r6r7_win_functype_cacher9r:)r0r.r;r?r")r.r/r0r# WINFUNCTYPEos  rB)dlopen)sizeofbyref addressof alignmentresize) get_errno set_errno) _SimpleCDatacCsJddlm}|dkr|j}t|||}}||krFtd|||fdS)Nr)r z"sizeof(%s) wrong: %d instead of %d)structr _type_rD SystemError)typtypecoder ZactualZrequiredr"r"r# _check_sizes rQcs eZdZdZfddZZS) py_objectOc s.y tjStk r(dt|jSXdS)Nz %s())super__repr__r6typer()self) __class__r"r#rUs zpy_object.__repr__)r(r)r*rMrU __classcell__r"r")rXr#rRsrRPc@seZdZdZdS)c_shorthN)r(r)r*rMr"r"r"r#r[sr[c@seZdZdZdS)c_ushortHN)r(r)r*rMr"r"r"r#r]sr]c@seZdZdZdS)c_longlN)r(r)r*rMr"r"r"r#r_sr_c@seZdZdZdS)c_ulongLN)r(r)r*rMr"r"r"r#rasrair`c@seZdZdZdS)c_intrcN)r(r)r*rMr"r"r"r#rdsrdc@seZdZdZdS)c_uintIN)r(r)r*rMr"r"r"r#resrec@seZdZdZdS)c_floatfN)r(r)r*rMr"r"r"r#rgsrgc@seZdZdZdS)c_doubledN)r(r)r*rMr"r"r"r#risric@seZdZdZdS) c_longdoublegN)r(r)r*rMr"r"r"r#rksrkqc@seZdZdZdS) c_longlongrmN)r(r)r*rMr"r"r"r#rnsrnc@seZdZdZdS) c_ulonglongQN)r(r)r*rMr"r"r"r#rosroc@seZdZdZdS)c_ubyteBN)r(r)r*rMr"r"r"r#rqsrqc@seZdZdZdS)c_bytebN)r(r)r*rMr"r"r"r#rssrsc@seZdZdZdS)rcN)r(r)r*rMr"r"r"r#rsrc@seZdZdZddZdS)c_char_pzcCsd|jjtj|jfS)Nz%s(%s))rXr(c_void_p from_bufferr)rWr"r"r#rUszc_char_p.__repr__N)r(r)r*rMrUr"r"r"r#rvsrvc@seZdZdZdS)rxrZN)r(r)r*rMr"r"r"r#rxsrxc@seZdZdZdS)c_bool?N)r(r)r*rMr"r"r"r#rzsrz)POINTERpointer_pointer_type_cachec@seZdZdZddZdS) c_wchar_pZcCsd|jjtj|jfS)Nz%s(%s))rXr(rxryr)rWr"r"r#rUszc_wchar_p.__repr__N)r(r)r*rMrUr"r"r"r#rsrc@seZdZdZdS)c_wcharuN)r(r)r*rMr"r"r"r#rsrcCsFtjtjtjdkr"tjtjtt _t jtt _t td<dS)Nr ) r~clearr8_osnamerArZ from_paramr|rrvrrxr"r"r"r# _reset_caches   rcCs^t|tr6|dkrt|d}t|}|}||_|St|trRt|}|}|St|dS)Nr)rstrrrrrr)rrr r!r"r"r#create_unicode_buffers   rcCsLtj|ddk rtdt|tkr,td|j||t|<tt|=dS)Nz%This type already exists in the cachezWhat's this???)r~get RuntimeErroridZset_type)r}clsr"r"r#SetPointerType"s  rcCs||S)Nr")rOrr"r"r#ARRAY,src@sJeZdZeZeZdZdZdZ e dddfddZ ddZ d d Z d d ZdS) CDLLzrNFcsb|_j|rtO|r$tOGfdddt}|_|dkrXtj|_n|_dS)NcseZdZZjZdS)zCDLL.__init__.._FuncPtrN)r(r)r*r-_func_restype_r,r")r/rWr"r#_FuncPtrQsr)_name _func_flags_r4r5r:r_dlopen_handle)rWrmodeZhandler&r'rr")r/rWr#__init__Gsz CDLL.__init__cCs8d|jj|j|jtjdd@t|tjdd@fS)Nz<%s '%s', handle %x at %#x>r)rXr(rr_sysmaxsizer)rWr"r"r#rU[s z CDLL.__repr__cCs6|jdr|jdrt||j|}t||||S)N__) startswithendswithAttributeError __getitem__setattr)rWrfuncr"r"r# __getattr__as   zCDLL.__getattr__cCs"|j||f}t|ts||_|S)N)rrrr()rWZname_or_ordinalrr"r"r#rhs zCDLL.__getitem__)r(r)r*r2rrdrrrr DEFAULT_MODErrUrrr"r"r"r#r2s rc@seZdZeeBZdS)PyDLLN)r(r)r*r2_FUNCFLAG_PYTHONAPIrr"r"r"r#rnsrc@seZdZeZdS)WinDLLN)r(r)r*r@rr"r"r"r#rwsr)_check_HRESULTrKc@seZdZdZeZdS)HRESULTr`N)r(r)r*rMrZ_check_retval_r"r"r"r#rs rc@seZdZeZeZdS)OleDLLN)r(r)r*r@rrrr"r"r"r#rsrc@s,eZdZddZddZddZddZd S) LibraryLoadercCs ||_dS)N)_dlltype)rWZdlltyper"r"r#rszLibraryLoader.__init__cCs.|ddkrt||j|}t||||S)Nr_)rrr)rWrZdllr"r"r#rs    zLibraryLoader.__getattr__cCs t||S)N)getattr)rWrr"r"r#rszLibraryLoader.__getitem__cCs |j|S)N)r)rWrr"r"r#r=szLibraryLoader.LoadLibraryN)r(r)r*rrrr=r"r"r"r#rsrz python dllcygwinzlibpython%d.%d.dllr)get_last_errorset_last_errorcCs0|dkrt}|dkr"t|j}td|d|S)N) GetLastErrorr stripOSError)codeZdescrr"r"r#WinErrors  r) _memmove_addr _memset_addr_string_at_addr _cast_addrcsGfdddt}|S)NcseZdZZZeeBZdS)z!PYFUNCTYPE..CFunctionTypeN)r(r)r*r+r,r2rr-r")r.r0r"r#r1sr1)r:)r0r.r1r")r.r0r# PYFUNCTYPEsrcCs t|||S)N)_cast)objrOr"r"r#castsrrcCs t||S)N) _string_at)ptrrr"r"r# string_atsr)_wstring_at_addrcCs t||S)N) _wstring_at)rrr"r"r# wstring_atsrc Cs@ytdttdg}Wntk r,dSX|j|||SdS)Nzcomtypes.server.inprocserver*ii) __import__globalslocals ImportErrorDllGetClassObject)ZrclsidZriidZppvccomr"r"r#rs rc Cs6ytdttdg}Wntk r,dSX|jS)Nzcomtypes.server.inprocserverrr)rrrrDllCanUnloadNow)rr"r"r#rs r)BigEndianStructureLittleEndianStructure)N)N)N)N)NN)rr)r)osrsysrrZ_ctypesrrrrrr:Z_ctypes_versionrr r rLr Z _calcsize Exceptionrr rplatformrunamereleasesplitrr2rrrr4rr5r$r%r8r<r=rr>r@rArB__doc__replacerCrDrErFrGrHrIrJrKrQrRr[r]r_rardrergrirkrnrorqZ __ctype_le__Z __ctype_be__rsrrvrxZc_voidprzr|r}r~rrrrrrobjectrrrrrrrZcdllZpydllZ dllhandleZ pythonapi version_infoZwindllZoledllZkernel32rZcoredllrrrZc_size_tZ c_ssize_trrrrZmemmoveZmemsetrrrrrrrrrrrZctypes._endianrrZc_int8Zc_uint8ZkindZc_int16Zc_int32Zc_int64Zc_uint16Zc_uint32Zc_uint64r"r"r"r#s6          !              <