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Zfejd k�r,eejgjhZhneejijhZhddilmjZjmkZkd�djdk„Zle1e@ƒe1eLƒk�rje@Zme?Znn6e1e>ƒe1eLƒk�r†e>Zme=Znne1eEƒe1eLƒk�r eEZmeDZnddllmoZompZpmqZqmrZre(eLeLeLemƒeoƒZse(eLeLe?emƒepƒZtdmdn„Zueue:eLe:e:ƒerƒZvdodp„Zweue:eLe?ƒeqƒZxdƒdrds„ZyyddtlmzZzWne{k �r>YnXeue:eLe?ƒezƒZ|d…dudv„Z}ejd k�rvdwdx„Z~dydz„Zdd{l€m�Z�m‚Z‚eIZƒeFZ„xPe;e?e=eDgD]@Z…e1e…ƒdhk�r´e…Z†n&e1e…ƒd|k�rÈe…Z‡ne1e…ƒdk�rœe…Zˆ�qœWxPeeEgD]@Z…e1e…ƒdhk�re…Z‰n&e1e…ƒd|k�re…ZŠne1e…ƒdk�rîe…Z‹�qîW[…eTƒdS)†z,create and manipulate C data types in PythonéNz1.1.0)ÚUnionÚ StructureÚArray)Ú_Pointer)ÚCFuncPtr)Ú __version__)Ú RTLD_LOCALÚ RTLD_GLOBAL)Ú ArgumentError)ÚcalcsizezVersion number mismatchÚnt)Ú FormatErrorÚposixÚdarwinÚ.é)ÚFUNCFLAG_CDECLÚFUNCFLAG_PYTHONAPIÚFUNCFLAG_USE_ERRNOÚFUNCFLAG_USE_LASTERRORcCs^t|tƒr6|dkrt|ƒd}t|}|ƒ}||_|St|tƒrRt|}|ƒ}|St|ƒ‚dS)zªcreate_string_buffer(aBytes) -> character array create_string_buffer(anInteger) -> character array create_string_buffer(aBytes, anInteger) -> character array Né)Ú isinstanceÚbytesÚlenÚc_charÚvalueÚintÚ TypeError)ÚinitÚsizeÚbuftypeÚbuf©r"ú'/usr/lib64/python3.6/ctypes/__init__.pyÚcreate_string_buffer/s   r$cCs t||ƒS)N)r$)rrr"r"r#Úc_bufferAsr%c sŽt‰|jddƒrˆtO‰|jddƒr,ˆtO‰|r@td|jƒƒ‚ytˆˆˆfStk rˆG‡‡‡fdd„dtƒ}|tˆˆˆf<|SXdS)aÉCFUNCTYPE(restype, *argtypes, use_errno=False, use_last_error=False) -> function prototype. restype: the result type argtypes: a sequence specifying the argument types The function prototype can be called in different ways to create a callable object: prototype(integer address) -> foreign function prototype(callable) -> create and return a C callable function from callable prototype(integer index, method name[, paramflags]) -> foreign function calling a COM method prototype((ordinal number, dll object)[, paramflags]) -> foreign function exported by ordinal prototype((function name, dll object)[, paramflags]) -> foreign function exported by name Ú use_errnoFÚuse_last_errorz!unexpected keyword argument(s) %scseZdZ”Z”Z”ZdS)z CFUNCTYPE..CFunctionTypeN)Ú__name__Ú __module__Ú __qualname__Ú _argtypes_Ú _restype_Ú_flags_r")ÚargtypesÚflagsÚrestyper"r#Ú CFunctionTypecsr1N) Ú_FUNCFLAG_CDECLÚpopÚ_FUNCFLAG_USE_ERRNOÚ_FUNCFLAG_USE_LASTERRORÚ ValueErrorÚkeysÚ_c_functype_cacheÚKeyErrorÚ _CFuncPtr)r0r.Úkwr1r")r.r/r0r#Ú CFUNCTYPEIs  r<)Ú LoadLibrary)ÚFUNCFLAG_STDCALLc sŽt‰|jddƒrˆtO‰|jddƒr,ˆtO‰|r@td|jƒƒ‚ytˆˆˆfStk rˆG‡‡‡fdd„dtƒ}|tˆˆˆf<|SXdS)Nr&Fr'z!unexpected keyword argument(s) %scseZdZ”Z”Z”ZdS)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)ÚsizeofÚbyrefÚ addressofÚ alignmentÚresize)Ú get_errnoÚ set_errno)Ú _SimpleCDatacCsJddlm}|dkr|j}t|ƒ||ƒ}}||krFtd|||fƒ‚dS)Nr)r z"sizeof(%s) wrong: %d instead of %d)Ústructr Ú_type_rDÚ SystemError)ÚtypÚtypecoder ZactualZrequiredr"r"r#Ú _check_size‹s rQcs eZdZdZ‡fdd„Z‡ZS)Ú py_objectÚOc s.y tƒjƒStk r(dt|ƒjSXdS)Nz %s())ÚsuperÚ__repr__r6Útyper()Úself)Ú __class__r"r#rU™s zpy_object.__repr__)r(r)r*rMrUÚ __classcell__r"r")rXr#rR—srRÚPc@seZdZdZdS)Úc_shortÚhN)r(r)r*rMr"r"r"r#r[ sr[c@seZdZdZdS)Úc_ushortÚHN)r(r)r*rMr"r"r"r#r]¤sr]c@seZdZdZdS)Úc_longÚlN)r(r)r*rMr"r"r"r#r_¨sr_c@seZdZdZdS)Úc_ulongÚLN)r(r)r*rMr"r"r"r#ra¬sraÚir`c@seZdZdZdS)Úc_intrcN)r(r)r*rMr"r"r"r#rdµsrdc@seZdZdZdS)Úc_uintÚIN)r(r)r*rMr"r"r"r#re¹srec@seZdZdZdS)Úc_floatÚfN)r(r)r*rMr"r"r"r#rg½srgc@seZdZdZdS)Úc_doubleÚdN)r(r)r*rMr"r"r"r#riÁsric@seZdZdZdS)Ú c_longdoubleÚgN)r(r)r*rMr"r"r"r#rkÅsrkÚqc@seZdZdZdS)Ú c_longlongrmN)r(r)r*rMr"r"r"r#rnÏsrnc@seZdZdZdS)Ú c_ulonglongÚQN)r(r)r*rMr"r"r"r#roÓsroc@seZdZdZdS)Úc_ubyteÚBN)r(r)r*rMr"r"r"r#rqÚsrqc@seZdZdZdS)Úc_byteÚbN)r(r)r*rMr"r"r"r#rsásrsc@seZdZdZdS)rÚcN)r(r)r*rMr"r"r"r#ræsrc@seZdZdZdd„ZdS)Úc_char_pÚzcCsd|jjtj|ƒjfS)Nz%s(%s))rXr(Úc_void_pÚ from_bufferr)rWr"r"r#rUíszc_char_p.__repr__N)r(r)r*rMrUr"r"r"r#rvësrvc@seZdZdZdS)rxrZN)r(r)r*rMr"r"r"r#rxñsrxc@seZdZdZdS)Úc_boolú?N)r(r)r*rMr"r"r"r#rzösrz)ÚPOINTERÚpointerÚ_pointer_type_cachec@seZdZdZdd„ZdS)Ú c_wchar_pÚZcCsd|jjtj|ƒjfS)Nz%s(%s))rXr(rxryr)rWr"r"r#rUýszc_wchar_p.__repr__N)r(r)r*rMrUr"r"r"r#rûsrc@seZdZdZdS)Úc_wcharÚuN)r(r)r*rMr"r"r"r#r�sr�cCsFtjƒtjƒtjdkr"tjƒtjtt ƒ_t jtt ƒ_t td<dS)Nr ) r~Úclearr8Ú_osÚnamerArZ from_paramr|r�rvrrxr"r"r"r#Ú _reset_caches   r†cCs^t|tƒr6|dkrt|ƒd}t|}|ƒ}||_|St|tƒrRt|}|ƒ}|St|ƒ‚dS)z¯create_unicode_buffer(aString) -> character array create_unicode_buffer(anInteger) -> character array create_unicode_buffer(aString, anInteger) -> character array Nr)rÚstrrr�rrr)rrr r!r"r"r#Úcreate_unicode_buffers   rˆcCsLtj|dƒdk rtdƒ‚t|ƒtkr,tdƒ‚|j|ƒ|t|<tt|ƒ=dS)Nz%This type already exists in the cachezWhat's this???)r~ÚgetÚ RuntimeErrorÚidZset_type)r}Úclsr"r"r#ÚSetPointerType"s  r�cCs||S)Nr")rOrr"r"r#ÚARRAY,srŽc@sNeZdZdZeZeZdZdZ dZ e dddfdd„Z dd „Z d d „Zd d „ZdS)ÚCDLLaÆAn instance of this class represents a loaded dll/shared library, exporting functions using the standard C calling convention (named 'cdecl' on Windows). The exported functions can be accessed as attributes, or by indexing with the function name. Examples: .qsort -> callable object ['qsort'] -> callable object Calling the functions releases the Python GIL during the call and reacquires it afterwards. zrNFcsb|ˆ_ˆj‰|rˆtO‰|r$ˆtO‰G‡‡fdd„dtƒ}|ˆ_|dkrXtˆj|ƒˆ_n|ˆ_dS)NcseZdZ”Z”jZdS)zCDLL.__init__.._FuncPtrN)r(r)r*r-Ú_func_restype_r,r")r/rWr"r#Ú_FuncPtrQsr‘)Ú_nameÚ _func_flags_r4r5r:r‘Ú_dlopenÚ_handle)rWr…ÚmodeZhandler&r'r‘r")r/rWr#Ú__init__Gsz CDLL.__init__cCs8d|jj|j|jtjdd@t|ƒtjdd@fS)Nz<%s '%s', handle %x at %#x>ér)rXr(r’r•Ú_sysÚmaxsizer‹)rWr"r"r#rU[s z CDLL.__repr__cCs6|jdƒr|jdƒrt|ƒ‚|j|ƒ}t|||ƒ|S)NÚ__)Ú startswithÚendswithÚAttributeErrorÚ __getitem__Úsetattr)rWr…Úfuncr"r"r#Ú __getattr__as   zCDLL.__getattr__cCs"|j||fƒ}t|tƒs||_|S)N)r‘rrr()rWZname_or_ordinalr¡r"r"r#rŸhs zCDLL.__getitem__)r(r)r*Ú__doc__r2r“rdr�r’r•r‘Ú DEFAULT_MODEr—rUr¢rŸr"r"r"r#r�2s  r�c@seZdZdZeeBZdS)ÚPyDLLz¯This class represents the Python library itself. It allows accessing Python API functions. The GIL is not released, and Python exceptions are handled correctly. N)r(r)r*r£r2Ú_FUNCFLAG_PYTHONAPIr“r"r"r"r#r¥nsr¥c@seZdZdZeZdS)ÚWinDLLznThis class represents a dll exporting functions using the Windows stdcall calling convention. N)r(r)r*r£r@r“r"r"r"r#r§wsr§)Ú_check_HRESULTrKc@seZdZdZeZdS)ÚHRESULTr`N)r(r)r*rMr¨Z_check_retval_r"r"r"r#r©€s r©c@seZdZdZeZeZdS)ÚOleDLLzÚThis class represents a dll exporting functions using the Windows stdcall calling convention, and returning HRESULT. HRESULT error values are automatically raised as OSError exceptions. N)r(r)r*r£r@r“r©r�r"r"r"r#rª�srªc@s,eZdZdd„Zdd„Zdd„Zdd„Zd S) Ú LibraryLoadercCs ||_dS)N)Ú_dlltype)rWZdlltyper"r"r#r——szLibraryLoader.__init__cCs.|ddkrt|ƒ‚|j|ƒ}t|||ƒ|S)NrÚ_)ržr¬r )rWr…Zdllr"r"r#r¢šs    zLibraryLoader.__getattr__cCs t||ƒS)N)Úgetattr)rWr…r"r"r#rŸ¡szLibraryLoader.__getitem__cCs |j|ƒS)N)r¬)rWr…r"r"r#r=¤szLibraryLoader.LoadLibraryN)r(r)r*r—r¢rŸr=r"r"r"r#r«–sr«z python dllÚcygwinzlibpython%d.%d.dllr˜)Úget_last_errorÚset_last_errorcCs0|dkrtƒ}|dkr"t|ƒjƒ}td|d|ƒS)N)Ú GetLastErrorr ÚstripÚOSError)ÚcodeZdescrr"r"r#ÚWinError¼s  r¶)Ú _memmove_addrÚ _memset_addrÚ_string_at_addrÚ _cast_addrcsG‡‡fdd„dtƒ}|S)NcseZdZ”Z”ZeeBZdS)z!PYFUNCTYPE..CFunctionTypeN)r(r)r*r+r,r2r¦r-r")r.r0r"r#r1Øsr1)r:)r0r.r1r")r.r0r#Ú PYFUNCTYPE×sr»cCs t|||ƒS)N)Ú_cast)ÚobjrOr"r"r#Úcastßsr¾rcCs t||ƒS)zAstring_at(addr[, size]) -> string Return the string at addr.)Ú _string_at)Úptrrr"r"r#Ú string_atãsrÁ)Ú_wstring_at_addrcCs t||ƒS)zFwstring_at(addr[, size]) -> string Return the string at addr.)Ú _wstring_at)rÀrr"r"r#Ú wstring_atïsrÄc Cs@ytdtƒtƒdgƒ}Wntk r,dSX|j|||ƒSdS)Nzcomtypes.server.inprocserverÚ*iïþûi€)Ú __import__ÚglobalsÚlocalsÚ ImportErrorÚDllGetClassObject)ZrclsidZriidZppvÚccomr"r"r#rÊ÷s rÊc Cs6ytdtƒtƒdgƒ}Wntk r,dSX|jƒS)Nzcomtypes.server.inprocserverrÅr)rÆrÇrÈrÉÚDllCanUnloadNow)rËr"r"r#rÌÿs rÌ)ÚBigEndianStructureÚLittleEndianStructureé)N)N)N)N)NNéÿÿÿÿ)rÐrÐ)rÐ)Œr£Úosr„Úsysr™rZ_ctypesrrrrrr:Z_ctypes_versionrr r rLr Z _calcsizeÚ Exceptionr…r r¤ÚplatformrÚunameÚreleaseÚsplitrr2rr¦rr4rr5r$r%r8r<r=r”r>r@rArBÚreplacerCrDrErFrGrHrIrJrKrQrRr[r]r_rardrergrirkrnrorqZ __ctype_le__Z __ctype_be__rsrrvrxZc_voidprzr|r}r~rr�r†rˆr�rŽÚobjectr�r¥r§r¨r©rªr«ZcdllZpydllZ dllhandleZ pythonapiÚ version_infoZwindllZoledllZkernel32r²Zcoredllr°r±r¶Zc_size_tZ c_ssize_tr·r¸r¹rºZmemmoveZmemsetr»r¼r¾r¿rÁrÂrÉrÃrÄrÊrÌZctypes._endianrÍrÎZc_int8Zc_uint8ZkindZc_int16Zc_int32Zc_int64Zc_uint16Zc_uint32Zc_uint64r"r"r"r#Ús8          !              <