/ lib / ctypes / __init__.pyc
__init__.pyc
  1  o

  2  4�HcwH�@s(dZddlZddlZddlZdZddlm	Z	m
  3  Z
  4  mZddlmZddlm
ZddlmZddlmZmZdd	lmZdd
  5  lmZeekrJedee��ejdkrUdd
lmZeZejdkrqejdkrqee��j�d�d�dkrqeZddlmZ m!Z"m#Z$m%Z&d}dd�Z'd}dd�Z(iZ)dd�Z*ejdkr�ddlm+Z,ddlm-Z.iZ/dd�Z0e0jr�e*j�1dd�e0_nejdkr�ddlm2Z,ddlm3Z3m4Z4m5Z5m6Z6m7Z7ddlm8Z8m9Z9dd lm:Z:d}d!d"�Z;Gd#d$�d$e:�Z<e;e<d%�Gd&d'�d'e:�Z=e;e=�Gd(d)�d)e:�Z>e;e>�Gd*d+�d+e:�Z?e;e?�Gd,d-�d-e:�Z@e;e@�ed.�ed/�k�r'e?ZAe@ZBnGd0d1�d1e:�ZAe;eA�Gd2d3�d3e:�ZBe;eB�Gd4d5�d5e:�ZCe;eC�Gd6d7�d7e:�ZDe;eD�Gd8d9�d9e:�ZEe3eE�e3eD�k�rjeDZEed/�ed:�k�rxe?ZFe@ZGnGd;d<�d<e:�ZFe;eF�Gd=d>�d>e:�ZGe;eG�Gd?d@�d@e:�ZHeHeH_IeH_Je;eH�GdAdB�dBe:�ZKeKeK_IeK_Je;eK�GdCdD�dDe:�ZLeLeL_IeL_Je;eL�GdEdF�dFe:�ZMe;eMd%�GdGdH�dHe:�ZNeNZOe;eN�GdIdJ�dJe:�ZPddKlmQZQmRZRmSZSGdLdM�dMe:�ZTGdNdO�dOe:�ZUdPdQ�ZVd}dRdS�ZWdTdU�ZXdVdW�ZYGdXdY�dYeZ�Z[GdZd[�d[e[�Z\ejdk�rJGd\d]�d]e[�Z]dd^lm^Z^m:Z:Gd_d`�d`e:�Z_Gdadb�dbe[�Z`Gdcdd�ddeZ�Zaeae[�Zbeae\�Zcejdk�rhe\dedejd�Zenejdfk�rze\dgejfddh��Zene\d�Zeejdk�r�eae]�Zgeae`�ZhegjijjZjddilmkZkmlZld~djdk�Zme3eB�e3eN�k�r�eBZneAZone3e@�e3eN�k�r�e@Zne?Zon
e3eG�e3eN�k�r�eGZneFZoddllmpZpmqZqmrZrmsZse*eNeNeNen�ep�Zte*eNeNeAen�eq�Zudmdn�Zveve<eNe<e<�es�Zwdodp�Zxeve<eNeA�er�Zyddrds�Zzzddtlm{Z{Wn
  6  e|�yYnweve<eNeA�e{�Z}ddudv�Z~ejdk�r0dwdx�Zdydz�Z�dd{l�m�Z�m�Z�eKZ�eHZ�e=eAe?eFfD]"Z�e3e��dhk�rOe�Z��qBe3e��d|k�rZe�Z��qBe3e��dk�rce�Z��qBe>eBe@eGfD]"Z�e3e��dhk�rxe�Z��qke3e��d|k�r�e�Z��qke3e��dk�r�e�Z��qk[�eV�dS)�z,create and manipulate C data types in Python�Nz1.1.0)�Union�	Structure�Array)�_Pointer)�CFuncPtr)�__version__)�
  7  RTLD_LOCAL�RTLD_GLOBAL)�
ArgumentError��calcsizezVersion number mismatch�nt)�FormatError�posix�darwin�.�)�FUNCFLAG_CDECL�FUNCFLAG_PYTHONAPI�FUNCFLAG_USE_ERRNO�FUNCFLAG_USE_LASTERRORcCsvt|t�r"|durt|�d}t�d||�t|}|�}||_|St|t�r7t�dd|�t|}|�}|St|��)z�create_string_buffer(aBytes) -> character array
  8      create_string_buffer(anInteger) -> character array
  9      create_string_buffer(aBytes, anInteger) -> character array
 10      N�zctypes.create_string_buffer)	�
 11  isinstance�bytes�len�_sys�audit�c_char�value�int�	TypeError��init�size�buftype�buf�r&�wC:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\ctypes\__init__.py�create_string_buffer0s
 12  
 13  r(cC�
 14  t||�S�N)r()r"r#r&r&r'�c_bufferDs
 15  r+c�t�|�dd�r�tO�|�dd�r�tO�|r td|����zt���fWStyFG���fdd�dt�}|t���f<|YSw)a�CFUNCTYPE(restype, *argtypes,
 16                   use_errno=False, use_last_error=False) -> function prototype.
 17  
 18      restype: the result type
 19      argtypes: a sequence specifying the argument types
 20  
 21      The function prototype can be called in different ways to create a
 22      callable object:
 23  
 24      prototype(integer address) -> foreign function
 25      prototype(callable) -> create and return a C callable function from callable
 26      prototype(integer index, method name[, paramflags]) -> foreign function calling a COM method
 27      prototype((ordinal number, dll object)[, paramflags]) -> foreign function exported by ordinal
 28      prototype((function name, dll object)[, paramflags]) -> foreign function exported by name
 29      �	use_errnoF�use_last_error�!unexpected keyword argument(s) %sc�eZdZ�Z�Z�ZdS)z CFUNCTYPE.<locals>.CFunctionTypeN��__name__�
 30  __module__�__qualname__�
 31  _argtypes_�	_restype_�_flags_r&��argtypes�flags�restyper&r'�
CFunctionTypef�r<)	�_FUNCFLAG_CDECL�pop�_FUNCFLAG_USE_ERRNO�_FUNCFLAG_USE_LASTERROR�
 32  ValueError�keys�_c_functype_cache�KeyError�	_CFuncPtr)r;r9�kwr<r&r8r'�	CFUNCTYPELs�rH)�LoadLibrary)�FUNCFLAG_STDCALLcr,)Nr-Fr.r/cr0)z$WINFUNCTYPE.<locals>.WinFunctionTypeNr1r&r8r&r'�WinFunctionType~r=rK)	�_FUNCFLAG_STDCALLr?r@rArBrC�_win_functype_cacherErF)r;r9rGrKr&r8r'�WINFUNCTYPErs�rN)�dlopen)�sizeof�byref�	addressof�	alignment�resize)�	get_errno�	set_errno)�_SimpleCDatacCsJddlm}|dur
|j}t|�||�}}||kr#td|||f��dS)Nrrz"sizeof(%s) wrong: %d instead of %d)�structr�_type_rP�SystemError)�typ�typecoder�actual�requiredr&r&r'�_check_size�s��r_cs eZdZdZ�fdd�Z�ZS)�	py_object�Ocs.zt���WStydt|�jYSw)Nz
 33  %s(<NULL>))�super�__repr__rB�typer2��self��	__class__r&r'rc�s
 34  �zpy_object.__repr__)r2r3r4rYrc�
__classcell__r&r&rgr'r`�sr`�Pc@�eZdZdZdS)�c_short�hN�r2r3r4rYr&r&r&r'rl��rlc@rk)�c_ushort�HNrnr&r&r&r'rp�rorpc@rk)�c_long�lNrnr&r&r&r'rr�rorrc@rk)�c_ulong�LNrnr&r&r&r'rt�rort�irsc@rk)�c_intrvNrnr&r&r&r'rw�rorwc@rk)�c_uint�INrnr&r&r&r'rx�rorxc@rk)�c_float�fNrnr&r&r&r'rz�rorzc@rk)�c_double�dNrnr&r&r&r'r|�ror|c@rk)�c_longdouble�gNrnr&r&r&r'r~�ror~�qc@rk)�
 35  c_longlongr�Nrnr&r&r&r'r��ror�c@rk)�c_ulonglong�QNrnr&r&r&r'r��ror�c@rk)�c_ubyte�BNrnr&r&r&r'r��ror�c@rk)�c_byte�bNrnr&r&r&r'r��ror�c@rk)r�cNrnr&r&r&r'r�rorc@�eZdZdZdd�ZdS)�c_char_p�zcC�d|jjt�|�jfS�Nz%s(%s)�rhr2�c_void_p�from_bufferrrer&r&r'rc��zc_char_p.__repr__N�r2r3r4rYrcr&r&r&r'r���r�c@rk)r�rjNrnr&r&r&r'r��ror�c@rk)�c_bool�?Nrnr&r&r&r'r��ror�)�POINTER�pointer�_pointer_type_cachec@r�)�	c_wchar_p�ZcCr�r�r�rer&r&r'rcr�zc_wchar_p.__repr__Nr�r&r&r&r'r��r�r�c@rk)�c_wchar�uNrnr&r&r&r'r�ror�cCsFt��t��tjdkrt��tjtt	�_t
 36  jtt�_ttd<dS)Nr
)
r��clearrD�_os�namerMr��
 37  from_paramr�r�r�rr�r&r&r&r'�_reset_caches
 38  r�cCs�t|t�r4|dur!tt�dkrtdd�|D��d}nt|�d}t�d||�t|}|�}||_|St|t	�rIt�dd|�t|}|�}|St
 39  |��)z�create_unicode_buffer(aString) -> character array
 40      create_unicode_buffer(anInteger) -> character array
 41      create_unicode_buffer(aString, anInteger) -> character array
 42      N�css$�|]
}t|�dkrdndVqdS)i��r�rN)�ord)�.0r�r&r&r'�	<genexpr>s�"z(create_unicode_buffer.<locals>.<genexpr>rzctypes.create_unicode_buffer)r�strrPr��sumrrrrrr r!r&r&r'�create_unicode_buffers 
 43  
 44  r�cCsLt�|d�durtd��t|�tvrtd��|�|�|t|<tt|�=dS)Nz%This type already exists in the cachezWhat's this???)r��get�RuntimeError�id�set_type)r��clsr&r&r'�SetPointerType/s
 45  r�cCs||Sr*r&)r[rr&r&r'�ARRAY9sr�c@sPeZdZdZeZeZdZdZ	dZ
 46  eddddfdd�Zdd	�Z
d
 47  d�Zdd
�ZdS)�CDLLa�An instance of this class represents a loaded dll/shared
 48      library, exporting functions using the standard C calling
 49      convention (named 'cdecl' on Windows).
 50  
 51      The exported functions can be accessed as attributes, or by
 52      indexing with the function name.  Examples:
 53  
 54      <obj>.qsort -> callable object
 55      <obj>['qsort'] -> callable object
 56  
 57      Calling the functions releases the Python GIL during the call and
 58      reacquires it afterwards.
 59      z<uninitialized>rNFc	s�|�_�j�|r�tO�|r�tO�tj�d�r,	|r,|�d�r,d|vr,|tj	tj
 60  BO}tjdkrS|dur8|}nddl}|j
}d|vsGd|vrS|��j��_||jO}G��fdd	�d	t�}|�_|durnt�j|��_dS|�_dS)
 61  N�aix�)z.a(r
r�/�\cseZdZ�Z�jZdS)zCDLL.__init__.<locals>._FuncPtrN)r2r3r4r7�_func_restype_r6r&�r:rfr&r'�_FuncPtrps
 62  r�)�_name�_func_flags_r@rAr�platform�
 63  startswith�endswithr��RTLD_MEMBER�RTLD_NOWr�r
�!_LOAD_LIBRARY_SEARCH_DEFAULT_DIRS�_getfullpathname�!_LOAD_LIBRARY_SEARCH_DLL_LOAD_DIRrFr��_dlopen�_handle)	rfr��mode�handler-r.Zwinmoder
r�r&r�r'�__init__Ts.
 64  
 65  
 66  z
CDLL.__init__cCs8d|jj|j|jtjdd@t|�tjdd@fS)Nz<%s '%s', handle %x at %#x>r�r)rhr2r�r�r�maxsizer�rer&r&r'rczs
 67  ��z
CDLL.__repr__cCs6|�d�r|�d�rt|��|�|�}t|||�|S)N�__)r�r��AttributeError�__getitem__�setattr)rfr��funcr&r&r'�__getattr__�s
 68  
 69  zCDLL.__getattr__cCs"|�||f�}t|t�s||_|Sr*)r�rrr2)rfZname_or_ordinalr�r&r&r'r��s
 70  zCDLL.__getitem__)r2r3r4�__doc__r>r�rwr�r�r�r��DEFAULT_MODEr�rcr�r�r&r&r&r'r�?s

 71  �&r�c@seZdZdZeeBZdS)�PyDLLz�This class represents the Python library itself.  It allows
 72      accessing Python API functions.  The GIL is not released, and
 73      Python exceptions are handled correctly.
 74      N)r2r3r4r�r>�_FUNCFLAG_PYTHONAPIr�r&r&r&r'r��sr�c@�eZdZdZeZdS)�WinDLLznThis class represents a dll exporting functions using the
 75          Windows stdcall calling convention.
 76          N)r2r3r4r�rLr�r&r&r&r'r��sr�)�_check_HRESULTrWc@r�)�HRESULTrsN)r2r3r4rYr��_check_retval_r&r&r&r'r��s
 77  r�c@seZdZdZeZeZdS)�OleDLLz�This class represents a dll exporting functions using the
 78          Windows stdcall calling convention, and returning HRESULT.
 79          HRESULT error values are automatically raised as OSError
 80          exceptions.
 81          N)r2r3r4r�rLr�r�r�r&r&r&r'r��sr�c@s6eZdZdd�Zdd�Zdd�Zdd�Zeej	�Z
 82  d	S)
 83  �
LibraryLoadercCs
 84  ||_dSr*��_dlltype)rfZdlltyper&r&r'r���
 85  zLibraryLoader.__init__cCs.|ddkr
 86  t|��|�|�}t|||�|S)Nr�_)r�r�r�)rfr��dllr&r&r'r��s
 87  
 88  zLibraryLoader.__getattr__cCr)r*)�getattr�rfr�r&r&r'r��r�zLibraryLoader.__getitem__cCs
 89  |�|�Sr*r�r�r&r&r'rI�r�zLibraryLoader.LoadLibraryN)r2r3r4r�r�r�rI�classmethod�_types�GenericAlias�__class_getitem__r&r&r&r'r��sr�z
 90  python dll�cygwinzlibpython%d.%d.dllr�)�get_last_error�set_last_errorcCs0|durt�}|durt|���}td|d|�Sr*)�GetLastErrorr�strip�OSError)�code�descrr&r&r'�WinError�s
 91  r�)�
_memmove_addr�_memset_addr�_string_at_addr�
 92  _cast_addrcsG��fdd�dt�}|S)NcseZdZ�Z�ZeeBZdS)z!PYFUNCTYPE.<locals>.CFunctionTypeN)r2r3r4r5r6r>r�r7r&�r9r;r&r'r<�sr<)rF)r;r9r<r&r�r'�
 93  PYFUNCTYPE�sr�cCst|||�Sr*)�_cast)�objr[r&r&r'�cast�sr������cCr))zAstring_at(addr[, size]) -> string
 94  
 95      Return the string at addr.)�
 96  _string_at��ptrr#r&r&r'�	string_at�
 97  r�)�_wstring_at_addrcCr))zFwstring_at(addr[, size]) -> string
 98  
 99          Return the string at addr.)�_wstring_atr�r&r&r'�
100  wstring_at
r�r�cCs<ztdt�t�dg�}Wn
101  tyYdSw|�|||�S)N�comtypes.server.inprocserver�*i�)�
102  __import__�globals�locals�ImportError�DllGetClassObject)ZrclsidZriid�ppv�ccomr&r&r'rs�rcCs4ztdt�t�dg�}W|��StyYdSw)Nr�rr)rrrr�DllCanUnloadNow)rr&r&r'rs��r)�BigEndianStructure�LittleEndianStructure�r*)NN)r�)�r��osr��sysr�typesr�r�_ctypesrrrrrrF�_ctypes_versionrr	r
103  rXr�	_calcsize�	Exceptionr�rr�r�r�uname�release�splitrr>rr�rr@rrAr(r+rDrHrIr�rJrLrMrN�replacerOrPrQrRrSrTrUrVrWr_r`rlrprrrtrwrxrzr|r~r�r�r��__ctype_le__�__ctype_be__r�rr�r��c_voidpr�r�r�r�r�r�r�r�r�r��objectr�r�r�r�r�r�r��cdll�pydll�	dllhandle�	pythonapi�version_info�windll�oledll�kernel32r�r�r�r��c_size_t�	c_ssize_tr�r�r�r��memmove�memsetr�r�r�r�r�r�rr�r�rr�ctypes._endianr	r
104  �c_int8�c_uint8�kind�c_int16�c_int32�c_int64�c_uint16�c_uint32�c_uint64r&r&r&r'�<module>s4
105  
106  
107  
108  !�
109  
110  
111  
112  
113  
114  N
	
115  
116  �
117  ��
118