Your IP : 18.220.2.183


Current Path : /lib64/python3.6/ctypes/__pycache__/
Upload File :
Current File : //lib64/python3.6/ctypes/__pycache__/__init__.cpython-36.pyc

3

�me1@�@s>dZddlZddlZdZddlmZmZm	Z	ddlm
Z
ddlmZddlmZ
ddlmZmZdd	lmZdd
lmZee
kr�edee
��ejdkr�dd
lmZeZejdkr�ejdkr�eej�jjd�d�dkr�eZddlmZmZ m!Z"m#Z$d}dd�Z%d~dd�Z&iZ'dd�Z(ejdk�r\ddlm)Z*ddlm+Z,iZ-dd�Z.e.j�rte(jj/dd�e._nejdk�rtddlm0Z*ddlm1Z1m2Z2m3Z3m4Z4m5Z5ddlm6Z6m7Z7dd lm8Z8dd!d"�Z9Gd#d$�d$e8�Z:e9e:d%�Gd&d'�d'e8�Z;e9e;�Gd(d)�d)e8�Z<e9e<�Gd*d+�d+e8�Z=e9e=�Gd,d-�d-e8�Z>e9e>�ed.�ed/�k�rLe=Z?e>Z@n0Gd0d1�d1e8�Z?e9e?�Gd2d3�d3e8�Z@e9e@�Gd4d5�d5e8�ZAe9eA�Gd6d7�d7e8�ZBe9eB�Gd8d9�d9e8�ZCe1eC�e1eB�k�r�eBZCed/�ed:�k�r�e=ZDe>ZEn0Gd;d<�d<e8�ZDe9eD�Gd=d>�d>e8�ZEe9eE�Gd?d@�d@e8�ZFeFeF_GeF_He9eF�GdAdB�dBe8�ZIeIeI_GeI_He9eI�GdCdD�dDe8�ZJeJeJ_GeJ_He9eJ�GdEdF�dFe8�ZKe9eKd%�GdGdH�dHe8�ZLeLZMe9eL�GdIdJ�dJe8�ZNddKlmOZOmPZPmQZQGdLdM�dMe8�ZRGdNdO�dOe8�ZSdPdQ�ZTd�dRdS�ZUdTdU�ZVdVdW�ZWGdXdY�dYeX�ZYGdZd[�d[eY�ZZejdk�r�Gd\d]�d]eY�Z[dd^lm\Z\m8Z8Gd_d`�d`e8�Z]Gdadb�dbeY�Z^Gdcdd�ddeX�Z_e_eY�Z`e_eZ�Zaejdk�r�eZdedejb�Zcn,ejdfk�r�eZdgejdddh��ZcneZd�Zcejdk�rNe_e[�Zee_e^�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�WxPe<e@e>eEgD]@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/__init__.py�create_string_buffer/s

r$cCs
t||�S)N)r$)rrr"r"r#�c_bufferAsr%cs�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.<locals>.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_STDCALLcs�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.<locals>.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)rz"sizeof(%s) wrong: %d instead of %d)�structr�_type_rD�SystemError)�typ�typecoder�actualZrequiredr"r"r#�_check_size�srRcs eZdZdZ�fdd�Z�ZS)�	py_object�Ocs.y
t�j�Stk
r(dt|�jSXdS)Nz
%s(<NULL>))�super�__repr__r6�typer()�self)�	__class__r"r#rV�s
zpy_object.__repr__)r(r)r*rMrV�
__classcell__r"r")rYr#rS�srS�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#rb�srb�irac@seZdZdZdS)�c_intrdN)r(r)r*rMr"r"r"r#re�srec@seZdZdZdS)�c_uint�IN)r(r)r*rMr"r"r"r#rf�srfc@seZdZdZdS)�c_float�fN)r(r)r*rMr"r"r"r#rh�srhc@seZdZdZdS)�c_double�dN)r(r)r*rMr"r"r"r#rj�srjc@seZdZdZdS)�c_longdouble�gN)r(r)r*rMr"r"r"r#rl�srl�qc@seZdZdZdS)�
c_longlongrnN)r(r)r*rMr"r"r"r#ro�sroc@seZdZdZdS)�c_ulonglong�QN)r(r)r*rMr"r"r"r#rp�srpc@seZdZdZdS)�c_ubyte�BN)r(r)r*rMr"r"r"r#rr�srrc@seZdZdZdS)�c_byte�bN)r(r)r*rMr"r"r"r#rt�srtc@seZdZdZdS)r�cN)r(r)r*rMr"r"r"r#r�src@seZdZdZdd�ZdS)�c_char_p�zcCsd|jjtj|�jfS)Nz%s(%s))rYr(�c_void_p�from_bufferr)rXr"r"r#rV�szc_char_p.__repr__N)r(r)r*rMrVr"r"r"r#rw�srwc@seZdZdZdS)ryr[N)r(r)r*rMr"r"r"r#ry�sryc@seZdZdZdS)�c_bool�?N)r(r)r*rMr"r"r"r#r{�sr{)�POINTER�pointer�_pointer_type_cachec@seZdZdZdd�ZdS)�	c_wchar_p�ZcCsd|jjtj|�jfS)Nz%s(%s))rYr(ryrzr)rXr"r"r#rV�szc_wchar_p.__repr__N)r(r)r*rMrVr"r"r"r#r��sr�c@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�namerAr�Z
from_paramr}r�rwrryr"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
edddfdd�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:

    <obj>.qsort -> callable object
    <obj>['qsort'] -> callable object

    Calling the functions releases the Python GIL during the call and
    reacquires it afterwards.
    z<uninitialized>rNFcsb|�_�j�|r�tO�|r$�tO�G��fdd�dt�}|�_|dkrXt�j|��_n|�_dS)NcseZdZ�Z�jZdS)zCDLL.__init__.<locals>._FuncPtrN)r(r)r*r-�_func_restype_r,r")r/rXr"r#�_FuncPtrQsr�)�_name�_func_flags_r4r5r:r��_dlopen�_handle)rXr��modeZhandler&r'r�r")r/rXr#�__init__Gsz
CDLL.__init__cCs8d|jj|j|jtjdd@t|�tjdd@fS)Nz<%s '%s', handle %x at %#x>�r)rYr(r�r��_sys�maxsizer�)rXr"r"r#rV[s
z
CDLL.__repr__cCs6|jd�r|jd�rt|��|j|�}t|||�|S)N�__)�
startswith�endswith�AttributeError�__getitem__�setattr)rXr��funcr"r"r#�__getattr__as

zCDLL.__getattr__cCs"|j||f�}t|t�s||_|S)N)r�rrr()rXZname_or_ordinalr�r"r"r#r�hs
zCDLL.__getitem__)r(r)r*�__doc__r2r�rer�r�r�r��DEFAULT_MODEr�rVr�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)�HRESULTraN)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)rXZdlltyper"r"r#r��szLibraryLoader.__init__cCs.|ddkrt|��|j|�}t|||�|S)Nr�_)r�r�r�)rXr�Zdllr"r"r#r��s

zLibraryLoader.__getattr__cCs
t||�S)N)�getattr)rXr�r"r"r#r��szLibraryLoader.__getitem__cCs
|j|�S)N)r�)rXr�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.<locals>.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�cCs6ytdt�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
rLrZ	_calcsize�	Exceptionr�r
r��platformr�uname�release�splitrr2rr�rr4rr5r$r%r8r<r=r�r>r@rArB�replacerCrDrErFrGrHrIrJrKrRrSr\r^r`rbrerfrhrjrlrorprrZ__ctype_le__Z__ctype_be__rtrrwryZc_voidpr{r}r~rr�r�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#�<module>s8


!




<