AlkantarClanX12

Your IP : 52.15.223.239


Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/cffi/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/cffi/__pycache__/api.cpython-311.pyc

�

�܋fP�����ddlZddlZddlmZddlmZddlmZ	en#e	$rddl
mZd�ZYnwxYw	en
#e	$re
ZYnwxYwe��ZGd�d	e��Zd
�Zd�Zd�ZdS)
�N�)�
allocate_lock)�	CDefError)�model)�Callablec�,�t|t��S�N)�
isinstancer)�xs �[/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib64/python3.11/site-packages/cffi/api.py�<lambda>r
s���A�x�0�0��c�x�eZdZdZd;d�Zd<d�Zd=d�Zd>d�Zd?d	�Zd
�Z	d�Z
d>d�Zd
�Zd�Z
d�Zd�Zd;d�Z		d@d�Zd�ZdAd�Zd�Zedfd�Zd�ZdBd�ZdCd�Zd?d�Zd�ZdDd�Zd �Zd!�Zeeedd"��Z dAd#�Z!d$�Z"d%�Z#d&�Z$d'�Z%d(�Z&d)�Z'd*�Z(d+�Z)d,�Z*d-�Z+dEd/�Z,	dEd0�Z-dFd2�Z.d3�Z/d4�Z0dGd6�Z1d7�Z2d8�Z3d9�Z4d:�Z5dS)H�FFIa�
    The main top-level class that you instantiate once, or once per module.

    Example usage:

        ffi = FFI()
        ffi.cdef("""
            int printf(const char *, ...);
        """)

        C = ffi.dlopen(None)   # standard library
        -or-
        C = ffi.verify()  # use a C compiler: verify the decl above is right

        C.printf("hello, %s!\n", ffi.new("char[]", "world"))
    Nc���|�sddl}ddlm}|j|kr^t|d��r+t	d|�dt
�d|j�d|j�d	�	���t	d|�dt
�d
|j�d	����ddlm}||_t��|_	|�
��|_i|_tjd��j|_tjd
��j|_g|_g|_g|_g|_d|_i|_d|_d|_t5j|��|_t|d��r|�|��t=|j��D]6}|�d��rtA||tC||�����7|j	5|�"t4j#��|_$|�"t4j%��|_&ddd��n#1swxYwYtO|tj��rfttPd��sP|�)|j$d��tP_*|�+��\tP_,tP_-nA|�)|j$d��|_*|�+��\|_,|_-|j.|_.dS)z{Create an FFI instance.  The 'backend' argument is used to
        select a non-default backend, mostly for tests.
        Nrr)�__version__�__file__z5Version mismatch: this is the 'cffi' package version z
, located in zQ.  When we import the top-level '_cffi_backend' extension module, we get version z=.  The two versions should be equal; check your installation.zS.  This interpreter comes with a built-in '_cffi_backend' module, which is version )�cparser�parsed_types�	new_types�set_ffi�RTLD_�NULL)/�
_cffi_backend�r�hasattr�	Exceptionrr�_backendr�_lock�Parser�_parser�_cached_btypes�types�
ModuleType�__dict__�
_parsed_types�
_new_types�_function_caches�
_libraries�_cdefsources�_included_ffis�_windows_unicode�_init_once_cache�
_cdef_version�
_embeddingr�
get_typecache�
_typecacher�list�
startswith�setattr�getattr�_get_cached_btype�
voidp_type�BVoidP�char_array_type�BCharAr
r�castr�
_get_types�CData�CType�buffer)�self�backendrr�names     r�__init__zFFI.__init__)s#���?�
,�+�+�+�%�%�%�%�%�%��"�k�1�1��7�J�/�/�E�#�)�#���X�X�X��+�+�+�W�-=�-=�-=�%?�@�@�@�
$�)�#���X�X�X�w�/B�/B�/B�%D�E�E�E�	��������
�"�_�_��
��~�~�'�'��� ���"�-�n�=�=�F����*�;�7�7�@��� "��������� ��� $��� "���!�������-�g�6�6����7�I�&�&�	"��O�O�D�!�!�!���)�*�*�	<�	<�D����w�'�'�
<���d�G�G�T�$:�$:�;�;�;��
�Z�	H�	H��0�0��1A�B�B�D�K��0�0��1F�G�G�D�K�	H�	H�	H�	H�	H�	H�	H�	H�	H�	H�	H����	H�	H�	H�	H��g�u�/�0�0�	:��3��'�'�
<��9�9�T�[�!�4�4���'.�'9�'9�';�';�$��	�3�9���	�	�$�+�q�1�1�D�I�%,�%7�%7�%9�%9�"�D�J��
��n����s�:A	H�H�HFc�8�|�||||���dS)a[Parse the given C source.  This registers all declared functions,
        types, and global variables.  The functions and global variables can
        then be accessed via either 'ffi.dlopen()' or 'ffi.verify()'.
        The types can be used in 'ffi.new()' and other functions.
        If 'packed' is specified as True, all structs declared inside this
        cdef are packed, i.e. laid out without any field alignment at all.
        Alternatively, 'pack' can be a small integer, and requests for
        alignment greater than that are ignored (pack=1 is equivalent to
        packed=True).
        )�override�packed�packN)�_cdef)r@�csourcerErFrGs     r�cdefzFFI.cdefes$��	
�
�
�7�X�f�4�
�H�H�H�H�Hrc�X�|�|||d���|j�	d|_dSdS)NT)rFrG�	dllexportr)rHr/)r@rIrFrGs    r�
embedding_apizFFI.embedding_apirs7���
�
�7�6���
�E�E�E��?�"� �D�O�O�O�#�"rc��t|t��s9t|t��std���|�d��}|j5t
��|_|jj	|fd|i|��|j
�|��|r|jD]}|�
���|jj}|r'g|j_|D]}|�||���ddd��dS#1swxYwYdS)Nz cdef() argument must be a string�asciirE)r
�str�
basestring�	TypeError�encoder�objectr.r!�parser*�appendr(�clear�_recomplete�finish_backend_type)r@rIrE�options�cache�
finishlist�tps       rrHz	FFI._cdefwse���'�3�'�'�	.��g�z�2�2�
D�� B�C�C�C��n�n�W�-�-�G�
�Z�	=�	=�!'���D���D�L��w�E�E��E�W�E�E�E���$�$�W�-�-�-��
"�!�2�"�"�E��K�K�M�M�M�M���1�J��
=�+-���(�$�=�=�B��*�*�4��<�<�<�<�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=����	=�	=�	=�	=�	=�	=s�BC;�;C?�C?rc�J�t|t��s&|�$t||j��std���|j5t|||��\}}|j�|��|j�|��ddd��n#1swxYwY|S)aHLoad and return a dynamic library identified by 'name'.
        The standard C library can be loaded by passing None.
        Note that functions and types declared by 'ffi.cdef()' are not
        linked to a particular library, just like C headers; in the
        library we only look for the actual (untyped) symbols.
        NzRdlopen(name): name must be a file name, None, or an already-opened 'void *' handle)	r
rQr=rRr�_make_ffi_libraryr(rVr))r@rB�flags�lib�function_caches     r�dlopenz
FFI.dlopen�s����4��,�,�	D����4���,�,���C�D�D�
D�
�Z�	(�	(�"3�D�$��"F�"F��C���!�(�(��8�8�8��O�"�"�3�'�'�'�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(��
s�A	B�B�Bc�J�t|���|��dS)z�Close a library obtained with ffi.dlopen().  After this call,
        access to functions or variables from the library will fail
        (possibly with a segmentation fault).
        N)�type�__cffi_close__)r@ras  r�dlclosezFFI.dlclose�s$��
	
�S�	�	� � ��%�%�%�%�%rc�>�|}||jvr
|j|St|t��s|�d��}|j�|��}|j}|r|���}|�|��}||f}||j|<|S)NrO)	r&r
rPrSr!�
parse_type�is_raw_function�as_function_pointerr6)r@�cdecl�keyre�really_a_function_type�btype�results       r�_typeof_lockedzFFI._typeof_locked�s������$�$�$�$��%�c�*�*��%��%�%�	*��L�L��)�)�E��|�&�&�u�-�-��!%�!5��!�	.��+�+�-�-�D��&�&�t�,�,���.�.��"(���3���
rc���	|j|}nD#t$r7|j5|�|��}ddd��n#1swxYwYYnwxYw|\}}|r|st	d|�d����|S)Nz	the type z3 is a function type, not a pointer-to-function type)r&�KeyErrorrrqr)r@rl�consider_function_as_funcptrrprorns      r�_typeofzFFI._typeof�s���	4��'��.�F�F���	4�	4�	4���
4�
4��,�,�U�3�3��
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4����
4�
4�
4�
4���	4����)/�%��%�!�	C�*F�	C��)�:?�%�%�B�C�C�
C��s1�
�A�A�A�A	�A�
A	�A�Ac��t|t��r|�|��St||j��r|j�|��St|tj��rt|��}|�|St|tj	��rIt|d��r9|j5|�|j
��cddd��S#1swxYwYtt|�����)z�Parse the C type given as a string and return the
        corresponding <ctype> object.
        It can also be used on 'cdata' instance to get its C type.
        N�_cffi_base_type)r
rQrur=r�typeofr#�BuiltinFunctionType�_builtin_function_type�FunctionTyperrr6rwrRre)r@rl�ress   rrxz
FFI.typeof�sD��
�e�Z�(�(�	'��<�<��&�&�&��e�T�Z�(�(�	/��=�'�'��.�.�.��e�U�6�7�7�	�(��/�/�C����
��u�e�0�1�1�	E��E�#4�5�5�	E���
E�
E��-�-�e�.C�D�D�
E�
E�
E�
E�
E�
E�
E�
E�
E�
E�
E�
E����
E�
E�
E�
E���U���$�$�$s�8C�C#�&C#c��t|t��r/|�|��}|j�|��S|j�|��S)zvReturn the size in bytes of the argument.  It can be a
        string naming a C type, or a 'cdata' instance.
        )r
rQrur�sizeof)r@rl�BTypes   rr~z
FFI.sizeof�sS���e�Z�(�(�	/��L�L��'�'�E��=�'�'��.�.�.��=�'�'��.�.�.rc��t|t��r|�|��}|j�|��S)z\Return the natural alignment size in bytes of the C type
        given as a string.
        )r
rQrur�alignof)r@rls  rr�zFFI.alignof�s=���e�Z�(�(�	(��L�L��'�'�E��}�$�$�U�+�+�+rc�~�t|t��r|�|��}|j|g|�R�dS)a3Return the offset of the named field inside the given
        structure or array, which must be given as a C type name.
        You can give several field names in case of nested structures.
        You can also give numeric values which correspond to array
        items, in case of an array type.
        r)r
rQru�
_typeoffsetof)r@rl�fields_or_indexess   r�offsetofzFFI.offsetof�sH���e�Z�(�(�	(��L�L��'�'�E�!�t�!�%�<�*;�<�<�<�Q�?�?rc��t|t��r|�|��}|j�||��S)a�Allocate an instance according to the specified C type and
        return a pointer to it.  The specified C type must be either a
        pointer or an array: ``new('X *')`` allocates an X and returns
        a pointer to it, whereas ``new('X[n]')`` allocates an array of
        n X'es and returns an array referencing it (which works
        mostly like a pointer, like in C).  You can also use
        ``new('X[]', n)`` to allocate an array of a non-constant
        length n.

        The memory is initialized following the rules of declaring a
        global variable in C: by default it is zero-initialized, but
        an explicit initializer can be given which can be used to
        fill all or part of the memory.

        When the returned <cdata> object goes out of scope, the memory
        is freed.  In other words the returned <cdata> object has
        ownership of the value of type 'cdecl' that it points to.  This
        means that the raw data can be used as long as this object is
        kept alive, but must not be used for a longer time.  Be careful
        about that when copying the pointer to the memory somewhere
        else, e.g. into another structure.
        )r
rQrur�newp)r@rl�inits   r�newzFFI.new�s?��.�e�Z�(�(�	(��L�L��'�'�E��}�!�!�%��.�.�.rTc�x����j���}|�|||���d��fd�	}|S)a�Return a new allocator, i.e. a function that behaves like ffi.new()
        but uses the provided low-level 'alloc' and 'free' functions.

        'alloc' is called with the size as argument.  If it returns NULL, a
        MemoryError is raised.  'free' is called with the result of 'alloc'
        as argument.  Both can be either Python function or directly C
        functions.  If 'free' is None, then no free function is called.
        If both 'alloc' and 'free' are None, the default is used.

        If 'should_clear_after_alloc' is set to False, then the memory
        returned by 'alloc' is assumed to be already cleared (or you are
        fine with garbage); otherwise CFFI will clear it.
        Nc�p��t|t��r��|��}�||��Sr	�r
rQru)rlr��	allocatorr@s  ��r�allocatez#FFI.new_allocator.<locals>.allocates8����%��,�,�
,����U�+�+���9�U�D�)�)�)rr	)rr�
new_allocator)r@�alloc�free�should_clear_after_alloc�compiled_ffir�r�s`     @rr�zFFI.new_allocator
sa�����}�(�(�*�*�� �.�.�u�d�/G�I�I�	�	*�	*�	*�	*�	*�	*�	*��rc��t|t��r|�|��}|j�||��S)z�Similar to a C cast: returns an instance of the named C
        type initialized with the given 'source'.  The source is
        casted between integers or pointers of any type.
        )r
rQrurr;)r@rl�sources   rr;zFFI.cast%s?��
�e�Z�(�(�	(��L�L��'�'�E��}�!�!�%��0�0�0r���c�8�|j�||��S)a�Return a Python string (or unicode string) from the 'cdata'.
        If 'cdata' is a pointer or array of characters or bytes, returns
        the null-terminated string.  The returned string extends until
        the first null character, or at most 'maxlen' characters.  If
        'cdata' is an array then 'maxlen' defaults to its length.

        If 'cdata' is a pointer or array of wchar_t, returns a unicode
        string following the same rules.

        If 'cdata' is a single character or byte or a wchar_t, returns
        it as a string or unicode string.

        If 'cdata' is an enum, returns the value of the enumerator as a
        string, or 'NUMBER' if the value is out of range.
        )r�string)r@�cdata�maxlens   rr�z
FFI.string.s�� �}�#�#�E�6�2�2�2rc�8�|j�||��S)aLUnpack an array of C data of the given length,
        returning a Python string/unicode/list.

        If 'cdata' is a pointer to 'char', returns a byte string.
        It does not stop at the first null.  This is equivalent to:
        ffi.buffer(cdata, length)[:]

        If 'cdata' is a pointer to 'wchar_t', returns a unicode string.
        'length' is measured in wchar_t's; it is not the size in bytes.

        If 'cdata' is a pointer to anything else, returns a list of
        'length' items.  This is a faster equivalent to:
        [cdata[i] for i in range(length)]
        )r�unpack)r@r��lengths   rr�z
FFI.unpack@s���}�#�#�E�6�2�2�2rc��|tur
|j|}}n*t|t��r|�|��}|j�|||��S)a�Return a cdata of the given type pointing to the data of the
        given Python object, which must support the buffer interface.
        Note that this is not meant to be used on the built-in types
        str or unicode (you can build 'char[]' arrays explicitly)
        but only on objects containing large quantities of raw data
        in some other format, like 'array.array' or numpy arrays.

        The first argument is optional and default to 'char[]'.
        )�_unspecifiedr:r
rQrur�from_buffer)r@rl�
python_buffer�require_writables    rr�zFFI.from_buffer^s`���L�(�(�#'�;��=�E�E�
��z�
*�
*�	(��L�L��'�'�E��}�(�(��
�)9�;�;�	;rc�:�|j�|||��S)a_ffi.memmove(dest, src, n) copies n bytes of memory from src to dest.

        Like the C function memmove(), the memory areas may overlap;
        apart from that it behaves like the C function memcpy().

        'src' can be any cdata ptr or array, or any Python buffer object.
        'dest' can be any cdata ptr or array, or a writable Python buffer
        object.  The size to copy, 'n', is always measured in bytes.

        Unlike other methods, this one supports all Python buffer including
        byte strings and bytearrays---but it still does not support
        non-contiguous buffers.
        )r�memmove)r@�dest�src�ns    rr�zFFI.memmoveps���}�$�$�T�3��2�2�2rc����������fd�}t�t��r���d����|�|S||��S)a�Return a callback object or a decorator making such a
        callback object.  'cdecl' must name a C function pointer type.
        The callback invokes the specified 'python_callable' (which may
        be provided either directly or via a decorator).  Important: the
        callback object must be manually kept alive for as long as the
        callback may be invoked from the C level.
        c�z��t|��std����j��|����S)Nz.the 'python_callable' argument is not callable)�callablerRr�callback)�python_callablerl�error�onerrorr@s ����r�callback_decorator_wrapz-FFI.callback.<locals>.callback_decorator_wrap�sM����O�,�,�
3��!2�3�3�3��=�)�)�%��*/��:�:�
:rT)rtr�)r@rlr�r�r�r�s`` `` rr�zFFI.callback�su������	:�	:�	:�	:�	:�	:�	:�	:��e�Z�(�(�	K��L�L��T�L�J�J�E��"�*�*�*�*�?�;�;�;rrc�F�t|t��r|�|��}|���}|�d��r#d|j�|d��vrd|z}n|r|ddvrd|z}|j�||��S)a.Return a string giving the C type 'cdecl', which may be itself
        a string or a <ctype> object.  If 'replace_with' is given, it gives
        extra text to append (or insert for more complicated C types), like
        a variable name, or '*' to get actually the C type 'pointer-to-cdecl'.
        �*z&[�&z(%s)rz[(� )r
rQru�stripr3r�getcname)r@rl�replace_withs   r�getctypezFFI.getctype�s����e�Z�(�(�	(��L�L��'�'�E�#�)�)�+�+���#�#�C�(�(�	.��D�M�2�2�5�#�>�>�>�>�!�L�0�L�L�
�	.�,�q�/�T�"9�"9���-�L��}�%�%�e�\�:�:�:rc�:�|j�|||��S)a�Return a new cdata object that points to the same
        data.  Later, when this new cdata object is garbage-collected,
        'destructor(old_cdata_object)' will be called.

        The optional 'size' gives an estimate of the size, used to
        trigger the garbage collection more eagerly.  So far only used
        on PyPy.  It tells the GC that the returned object keeps alive
        roughly 'size' bytes of external memory.
        )r�gcp)r@r��
destructor�sizes    r�gczFFI.gc�s���}� � ��
�D�9�9�9rc���|j�d��dusJ�	|j|}nC#t$r6g}|�||��}|D]}|�||���YnwxYw|S)NF)r�acquirer"rs�get_cached_btyperY)r@rerr\s    rr6zFFI._get_cached_btype�s����z�!�!�%�(�(�E�1�1�1�1�	;��'��-�E�E���	;�	;�	;��J��)�)�$�
�;�;�E�"�
;�
;���(�(��z�:�:�:�:�
;�
;�	;����
�s�
.�=A.�-A.c���ddlm}m}|jr|�|��|p	|��}||||fi|��|_|j���}|j�|��|S)a�Verify that the current ffi signatures compile on this
        machine, and return a dynamic library object.  The dynamic
        library can be used to call functions and access global
        variables declared in this 'ffi'.  The library is compiled
        by the C compiler: it gives you C-level API compatibility
        (including calling macros).  This is unlike 'ffi.dlopen()',
        which requires binary compatibility in the signatures.
        r)�Verifier�_caller_dir_pycache)�verifierr�r�r,�_apply_windows_unicode�load_libraryr)rV)r@r��tmpdir�kwargsr�r�ras       r�verifyz
FFI.verify�s���	<�;�;�;�;�;�;�;�� �	0��'�'��/�/�/�
�0�.�.�0�0��!���v�v�@�@��@�@��
��m�(�(�*�*��	
����s�#�#�#��
rc�4�|j���Sr	)r�	get_errno)r@s r�
_get_errnozFFI._get_errno�s���}�&�&�(�(�(rc�:�|j�|��dSr	)r�	set_errno)r@�errnos  r�
_set_errnozFFI._set_errno�s���
����&�&�&�&�&rz(the value of 'errno' from/to the C callsc�6�|j�|��Sr	)r�getwinerror)r@�codes  rr�zFFI.getwinerror�s���}�(�(��.�.�.rc�n�|j5tj||��cddd��S#1swxYwYdSr	)rr�
pointer_cache)r@�ctypes  r�_pointer_tozFFI._pointer_to�s~��
�Z�	4�	4��&�t�U�3�3�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4����	4�	4�	4�	4�	4�	4s�*�.�.c��	|j�|��}nB#t$r5dt|��jvrt|��j|g|�R�cYS�wxYw|r|j|g|�R�\}}n|jdkrtd���d}|�|��}|j�	|||��S)z�Return the address of a <cdata 'struct-or-union'>.
        If 'fields_or_indexes' are given, returns the address of that
        field or array item in the structure or array, recursively in
        case of nested structures.
        �
__addressof__�pointerzaddressof(pointer)r)
rrxrRrer%r�r��kindr��rawaddressof)r@r�r�r��offset�ctypeptrs      r�	addressofz
FFI.addressof�s���	��M�(�(��/�/�E�E���	�	�	��$�u�+�+�"6�6�6�0�t�E�{�{�0��K�9J�K�K�K�K�K�K��	�����	�.�D�.�u�I�7H�I�I�I�M�E�6�6��z�Y�&�&�� 4�5�5�5��F��#�#�E�*�*���}�)�)�(�E�6�B�B�Bs��;A�Ac��|j�||��\}}|D]&}|j�||d��\}}||z
}�'||fS)Nr)r�typeoffsetof)r@r��field_or_indexr�r��field1�offset1s       rr�zFFI._typeoffsetof�s_���
�2�2�5�.�I�I�
��v�'�	�	�F�!�]�7�7��v�q�I�I�N�E�7��g��F�F��f�}�rc�4�t|t��s$tdt|��j�����||urtd���|j5|j5|j�|j��|j	�
d��|j	�|j	��|j	�
d��|j�
|��ddd��n#1swxYwYddd��dS#1swxYwYdS)a�Includes the typedefs, structs, unions and enums defined
        in another FFI instance.  Usage is similar to a #include in C,
        where a part of the program might include types defined in
        another part for its own usage.  Note that the include()
        method has no effect on functions, constants and global
        variables, which must anyway be accessed directly from the
        lib object returned by the original FFI instance.
        zEffi.include() expects an argument that is also of type cffi.FFI, not zself.include(self)�[�]N)
r
rrRre�__name__�
ValueErrorrr!�includer*rV�extendr+)r@�ffi_to_includes  rr�zFFI.includes����.�#�.�.�	A��)� $�^� 4� 4� =� =�@�A�A�
A��T�!�!��1�2�2�2�
�
!�	;�	;���
;�
;���$�$�^�%;�<�<�<��!�(�(��-�-�-��!�(�(��)D�E�E�E��!�(�(��-�-�-��#�*�*�>�:�:�:�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;����
;�
;�
;�
;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;����	;�	;�	;�	;�	;�	;s7�D
�B
C5�)D
�5C9	�9D
�<C9	�=D
�
D�Dc�B�|j�|j|��Sr	)r�newp_handler8�r@rs  r�
new_handlezFFI.new_handles���}�(�(���a�8�8�8rc�6�|j�|��Sr	)r�from_handler�s  rr�zFFI.from_handles���}�(�(��+�+�+rc�:�|j�|��dSr	)r�releaser�s  rr�zFFI.release"s���
���a� � � � � rc��|j�td���t|��}|r|�d��n|�d��||_dS)acWindows: if 'enabled_flag' is True, enable the UNICODE and
        _UNICODE defines in C, and declare the types like TCHAR and LPTCSTR
        to be (pointers to) wchar_t.  If 'enabled_flag' is False,
        declare these types to be (pointers to) plain 8-bit characters.
        This is mostly for backward compatibility; you usually want True.
        Nz%set_unicode() can only be called oncez�typedef wchar_t TBYTE;typedef wchar_t TCHAR;typedef const wchar_t *LPCTSTR;typedef const wchar_t *PCTSTR;typedef wchar_t *LPTSTR;typedef wchar_t *PTSTR;typedef TBYTE *PTBYTE;typedef TCHAR *PTCHAR;z�typedef char TBYTE;typedef char TCHAR;typedef const char *LPCTSTR;typedef const char *PCTSTR;typedef char *LPTSTR;typedef char *PTSTR;typedef TBYTE *PTBYTE;typedef TCHAR *PTCHAR;)r,r��boolrJ)r@�enabled_flags  r�set_unicodezFFI.set_unicode%s~��� �,��D�E�E�E��L�)�)���	0��I�I�/�
0�
0�
0�
0�
�I�I�/�
0�
0�
0�!-����rc��|�dd��}t|ttf��st	d���t|��ddgz}||d<dS)N�
define_macros�z''define_macros' must be a list or tuple)�UNICODE�1)�_UNICODEr�)�getr
r2�tuplerR)r@�kwds�	defmacross   rr�zFFI._apply_windows_unicodeCsf���H�H�_�b�1�1�	��)�d�E�]�3�3�	G��E�F�F�F���O�O�'7�'8�':�:�	� )��_���rc�2���fd�}dtjv�rddl}tjdkrdd�tj��}t
td��r/|d|j�tj	d����nYtjd	krd
}nd}t
td��r/|d|j�tj	d����t
td��r0|d|j�tj	d
d����n�tjdkrd}t
td��r|dz
}nK	ddl
}n#t$r	ddlm
}YnwxYwd}|�
d��r||�
d��z
}|tjdz	tjdz	dzfz}t
td��r|tjz
}|d|��tjdkr|dd��dSdS)Nc�j����|g��}||vr|�|��dSdSr	)�
setdefaultrV)rm�value�lstrs   �r�ensurez(FFI._apply_embedding_fix.<locals>.ensureMsA����/�/�#�r�*�*�C��C����
�
�5�!�!�!�!�!� �r�__pypy__r�win32zpython{0[0]}{0[1]}�prefix�library_dirs�libs��zpypy-czpypy3-c�bin�pypy�goalz
python%d%d�gettotalrefcount�_d)�	sysconfigzpython%d.%d�	DEBUG_EXT����abiflags�	libraries�extra_link_argsz	/MANIFEST)�sys�builtin_module_names�os�platform�format�version_infor�path�joinr
r�ImportError�	distutils�get_config_var�
hexversionr)r@rrr�	pythonlib�templaters `     r�_apply_embedding_fixzFFI._apply_embedding_fixKsP���	"�	"�	"�	"�	"�
��1�1�1��I�I�I��|�w�&�&�1�7�7��8H�I�I�	��3��)�)�M��F�>�2�7�<�<��
�F�+K�+K�L�L�L��
�#�d�*�*� (�I�I� )�I��3��)�)�L��F�>�2�7�<�<��
�E�+J�+J�K�K�K��s�H�%�%�
Q���~�r�w�|�|�C�J���'O�'O�P�P�P���|�w�&�&�'���3� 2�3�3�%���$�H��4�$�$�$�$�$��"�4�4�4�3�3�3�3�3�3�3�3�4����(���+�+�K�8�8�F��	� 8� 8�� E� E�E�H�!��^�r�)�C�N�b�,@�D�+H�I�J�I��s�J�'�'�
*��S�\�)�	���{�I�&�&�&��<�7�"�"��F�$�k�2�2�2�2�2�#�"s�E � E3�2E3�.cc��ddl}t|d��rtd���t|t��std���|j|vs|jr|j|vrtd���t|��|||f|_	dS)Nr�_assigned_sourcez:set_source() cannot be called several times per ffi objectz'module_name' must be a stringzY'module_name' must not contain '/': use a dotted name to make a 'package.module' location)
rrr�r
rQrR�sep�altseprPr-)r@�module_namer��source_extensionrrs      r�
set_sourcezFFI.set_source}s����	�	�	��4�+�,�,�	/��.�/�/�
/��+�z�2�2�	>��<�=�=�=�
�6�[� � �R�Y� �2�9��3K�3K��H�I�I�
I�!$�[�!1�!1�6�!1�4�!9����rc���ddlm}t|t��st	d���|�|��}|�||��|j|||fi|��dS)Nr)�	pkgconfigz;the pkgconfig_libs argument must be a list of package names)rr4r
r2rR�flags_from_pkgconfig�merge_flagsr2)r@r0�pkgconfig_libsr�r1rr4�kwds2s        r�set_source_pkgconfigzFFI.set_source_pkgconfig�s����������.�$�/�/�	0��/�0�0�
0��.�.�~�>�>�����d�E�*�*�*�����V�-=�F�F��F�F�F�F�Fr�buildc���ddlm}ddlm}t	|d��s8t	|d��r|j���Std���|j\}}}}|�td���||��||||f|||d	d
�|��\}	}
|r_|
r/tj�d|	j
d�d���n.tj�d
|	j
d�d���|	S)Nr)�mkpathr��	recompiler-r�z8set_source() must be called before distutils_extension()zadistutils_extension() is only for C extension modules, not for dlopen()-style pure Python modulesF)r��extradirr1�call_c_compilerz
regenerated: �
znot modified: )�distutils.dir_utilr<�
recompilerr>rr��
get_extensionr�r-rRr�stderr�write�sources)r@r��verboser<r>r0r�r1r�ext�updateds           r�distutils_extensionzFFI.distutils_extension�s[��-�-�-�-�-�-�)�)�)�)�)�)��t�/�0�0�	7��t�Z�(�(�
5��}�2�2�4�4�4��6�7�7�
7�6:�6K�3��V�-�t��>��&�'�'�
'�	��v���� �y��{�!'�@�06��2B�16�@�@�;?�@�@���W��	K��
K��
� � � ���A����!H�I�I�I�I��
� � � ���Q����!I�J�J�J��
rc��ddlm}t|d��std���|j\}}}}|�td���||||f|dd�|��dS)Nrr=r-�0set_source() must be called before emit_c_code()zYemit_c_code() is only for C extension modules, not for dlopen()-style pure Python modulesF��c_filer@�rCr>rr�r-rR�r@�filenamer>r0r�r1rs       r�emit_c_codezFFI.emit_c_code�s���)�)�)�)�)�)��t�/�0�0�	Q��O�P�P�P�6:�6K�3��V�-�t��>��I�J�J�
J��	�$��V�	B�!�5�	B�	B�<@�	B�	B�	B�	B�	Brc��ddlm}t|d��std���|j\}}}}|�td���||||f|dd�|��dS)Nrr=r-rMz^emit_python_code() is only for dlopen()-style pure Python modules, not for C extension modulesFrNrPrQs       r�emit_python_codezFFI.emit_python_code�s���)�)�)�)�)�)��t�/�0�0�	Q��O�P�P�P�6:�6K�3��V�-�t����O�P�P�
P��	�$��V�	B�!�5�	B�	B�<@�	B�	B�	B�	B�	Br�.c	��ddlm}t|d��std���|j\}}}}	||||f|||||d�|	��S)a�The 'target' argument gives the final file name of the
        compiled DLL.  Use '*' to force distutils' choice, suitable for
        regular CPython C API modules.  Use a file name ending in '.*'
        to ask for the system's default extension for dynamic libraries
        (.so/.dll/.dylib).

        The default is '*' when building a non-embedded C API extension,
        and (module_name + '.*') when building an embedded library.
        rr=r-z,set_source() must be called before compile())r��targetr1�compiler_verbose�debug)rCr>rr�r-)
r@r�rHrXrZr>r0r�r1rs
          r�compilezFFI.compile�s���	*�)�)�)�)�)��t�/�0�0�	M��K�L�L�L�6:�6K�3��V�-�t��y��{�F�H�6� &�9I�*1��H�H�BF�H�H�	Hrc�t�	|j|}n9#t$r,|j�|dt��f��}YnwxYw|dr|dS|d5|j|}|dr|dcddd��S|��}d|f|j|<ddd��n#1swxYwY|S)NFrrT)r-rsrr)r@�func�tagrrps     r�	init_oncez
FFI.init_once�s>��	P��%�c�*�A�A���	P�	P�	P��%�0�0��u�m�o�o�6N�O�O�A�A�A�	P����
�Q�4�	��Q�4�K�
�q�T�	8�	8��%�c�*�A���t�
���t�		8�	8�	8�	8�	8�	8�	8�	8��T�V�V�F�*.���D�!�#�&�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8����	8�	8�	8�	8��
s'�
�3A�A�!B-�B-�-B1�4B1c���|jrtd���ddl}|�d|��}|r||���d�}|���pdg}|�d|d�����}tdt|����D]R�|�}|�	��r4|�
|��s|dd�}|�
|����St|����fd�|D��}d�|��}t|d	d
��||_dS)Nz-embedding_init_code() can only be called oncerz\s*\nrz\s*rr�c�*��g|]}|�d�dz��S)NrAr�)�.0�line�is  �r�
<listcomp>z+FFI.embedding_init_code.<locals>.<listcomp>s%���1�1�1�4��a�b�b��$��1�1�1r�	cffi_init�exec)
r/r��re�match�end�
splitlines�group�range�len�rstripr3r#r[)r@�pysourcerhri�linesr
rcrds       @r�embedding_init_codezFFI.embedding_init_code�sT����?�	N��L�M�M�M�
	�	�	�	�����8�,�,���	.���	�	�����-�H��#�#�%�%�-�"������&�%��(�+�+�1�1�3�3���q�#�e�*�*�%�%�	)�	)�A���8�D��{�{�}�}�
)��/�/�&�1�1�)�#�C�R�C�[�F��/�/�&�1�1�)����K�K��1�1�1�1�5�1�1�1���7�7�5�>�>����+�v�.�.�.�"����rc� �td���)Nz:ffi.def_extern() is only available on API-mode FFI objects)r�)r@�argsrs   r�
def_externzFFI.def_externs���#�$�$�	$rc���g}g}g}|jjD]�}|�d��r|�|dd����5|�d��r|�|dd����h|�d��r|�|dd�����|���|���|���|||fS)z�Returns the user type names known to this FFI instance.
        This returns a tuple containing three lists of names:
        (typedef_names, names_of_structs, names_of_unions)
        ztypedef �Nzstruct �zunion �)r!�
_declarationsr3rV�sort)r@�typedefs�structs�unionsrms     r�
list_typeszFFI.list_typess���
�������<�-�	'�	'�C��~�~�j�)�)�
'�����A�B�B��(�(�(�(����	�*�*�
'����s�1�2�2�w�'�'�'�'�����)�)�
'��
�
�c�!�"�"�g�&�&�&���
�
�������������
�
�
��'�6�*�*rr	)FFN)FN)F)r)NNT)r�)NNN)r)rN)r+)r:T)rVrNN)6r��
__module__�__qualname__�__doc__rCrJrMrHrcrgrqrurxr~r�r�r�r�r;r�r�r�r�r�r�r�r�r6r�r�r��propertyr�r�r�r�r�r�r�r�r�r�r�r*r2r9rKrSrUr[r_rrrurr�rrrrs���������":%�:%�:%�:%�xI�I�I�I�!�!�!�!�
=�=�=�=�$����$&�&�&����$����%�%�%�&/�/�/�,�,�,�	@�	@�	@�/�/�/�/�6.2�/3�����01�1�1�3�3�3�3�$3�3�3�<0<�%*�;�;�;�;�$3�3�3� <�<�<�<�*;�;�;�;� 
:�
:�
:�
:�
�
�
�����<)�)�)�'�'�'��H�Z��T�?�
A�
A�E�/�/�/�/�4�4�4�C�C�C�*���;�;�;�.9�9�9�,�,�,�!�!�!�-�-�-�<*�*�*�03�03�03�d9�9�9�9�/3�G�G�G�G�����4
B�
B�
B�
B�
B�
B�H�H�H�H�&���0#�#�#�4$�$�$�+�+�+�+�+rrc��ddl}t|t��s*tjdks|�|�||��Sd}d}d|vs
d|vs	|j|vr0	|�||��S#t$r}|}Yd}~nd}~wwxYwddl}|j	�
|��}|�R|dkr/tjdkrtjdkrtd���d|��}|�|�d	|��}t|���|�||��S)
Nrr	�crV�/r
zXdlopen(None) cannot work on Windows for Python 3 (see http://bugs.python.org/issue23606)zEctypes.util.find_library() did not manage to locate a library called z.  Additionally, )rr
rQrrr�r.�OSError�ctypes.util�util�find_libraryr!)	rArBr`r�first_error�e�ctypesr"�msgs	         r�_load_backend_libr�$s]��
�I�I�I��d�J�'�'���<�7�"�"�d�&6��'�'��e�4�4�4����K�
�d�{�{�c�T�k�k�R�V�t�^�^�	��'�'��e�4�4�4���	�	�	��K�K�K�K�K�K�����	���������;�#�#�D�)�)�D��|��3�;�;�3�<�7�2�2�s�7G�4�7O�7O��D�E�E�
E��37�$�9���"�-8�[�[�#�#�>�C��c�l�l������e�,�,�,s�A.�.
B�8A?�?Bc
���������	�
���
�����j}t|||���
�
��fd����
�fd����
�fd��d����fd��i�	dg�
i������	�
��fd����	���fd��G��	��
����fd	�d
t���t|t��rF	t|t
��s|�d��}d|z�_n#t$rYnwxYw������j	fS)
Nc���d|z}�jj|\}}��|��}��||��}|�j|<dS)Nz	function )r!rzr6�
load_functionr%)	rBrmr]�_rr�
backendlib�ffi�librarys	      ���r�accessor_functionz,_make_ffi_library.<locals>.accessor_functionBs[����D� ����)�#�.���A��%�%�b�)�)���(�(���5�5��!&������rc
��������d�z}�	jj|\}}�	�|����j��j�t��t
���fd����fd�����dS)N�	variable c��������Sr	r�)r@rrB�
read_variables ���rr
z>_make_ffi_library.<locals>.accessor_variable.<locals>.<lambda>Ps�����u�d�3�3�rc������|��Sr	r�)r@rrrB�write_variables  ���rr
z>_make_ffi_library.<locals>.accessor_variable.<locals>.<lambda>Qs�����u�d�E� B� B�r)r!rzr6r�r�r4r�)
rBrmr]r�rr�r��
FFILibraryr�r�s
`   @@@���r�accessor_variablez,_make_ffi_library.<locals>.accessor_variableIs���������D� ����)�#�.���A��%�%�b�)�)��"�0�
�#�2���
�D�(�3�3�3�3�3�3�B�B�B�B�B�B�#D�#D�	E�	E�	E�	E�	Erc�`��	�|S#t$r��j5|�vrjd|z}�jj|\}}��|��}|jdkrt
j�|��}��||��}|�|<ddd��n#1swxYwY�|cYSwxYw)Nr��array)	rsrr!rzr6r�rr�r�)	rBrmr]r�r�p�addr_variablesr�r�s	      ���r�
addressof_varz(_make_ffi_library.<locals>.addressof_varSs���	(�!�$�'�'���
	(�
	(�
	(���
-�
-��~�-�-�%��,�C��K�5�c�:�E�B���1�1�"�5�5�E��z�W�,�,� %� 3�C�� ?� ?��"�0�0���=�=�A�+,�N�4�(�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-����
-�
-�
-�
-�"�$�'�'�'�'�
	(���s3��B-�A/B�B-�B	�B-�B	�B-�,B-c�(�td|�d����)Nznon-integer constant 'z,' cannot be accessed from a dlopen() library)�NotImplementedError)rBs r�accessor_constantz,_make_ffi_library.<locals>.accessor_constantbs'��!�!�HL���#O�P�P�	Prc�<���jj|�j|<dSr	)r!�_int_constantsr%)rBr�r�s ��r�accessor_int_constantz0_make_ffi_library.<locals>.accessor_int_constantfs ���!$��!;�D�!A������rFc�����
d�jurdS�jj���D]�\}\}}t	|t
j��s=|�dd��\}}|dkr�	�|<�G|dkr��|<�S|dkr��|<�_t|j	��D]\}}||f�fd�	}|�|<����jj
D]}��|�
����j�
d<dS)Nrr�r�function�variable�constantc�Z��|���|j|�j|<dSr	)�check_not_partial�
enumvaluesr%)rBr]rdr�s   �r�
accessor_enumzB_make_ffi_library.<locals>.update_accessors.<locals>.accessor_enum|s/����,�,�.�.�.�13��q�1A��(��.�.�.r)r.r!rz�itemsr
r�EnumType�split�	enumerate�enumeratorsr�r)rmr]r�r^rBrd�enumnamer�r�r�r�r��	accessors�accessors_versionr�r�s        ��������r�update_accessorsz+_make_ffi_library.<locals>.update_accessorsmsM����Q��3�#4�4�4��F��K�5�;�;�=�=�	8�	8�L�C��"�a��b�%�.�1�1�

8��I�I�c�1�-�-�	��T��*�$�$�&7�I�d�O�O��J�&�&�&7�I�d�O�O��J�&�&�&7�I�d�O��#,�R�^�#<�#<�8�8�K�A�x�/1�Q�B�B�B�B�B�B�+8�I�h�'�'�	8�
�K�.�	>�	>�D�� � ��'<�=�=�=�=�"�0��!���rc�����j5|�jvs	|�jvr	ddd��dS|�vr���|�vrt|����||��ddd��dS#1swxYwYdSr	)rr%�AttributeError)rBr�r�r�r�r�s �����r�
make_accessorz(_make_ffi_library.<locals>.make_accessor�s����
�Y�	"�	"��w�'�'�'�4�:�3F�+F�+F��	"�	"�	"�	"�	"�	"�	"�	"��9�$�$� � �"�"�"��y�(�(�(��.�.�.��I�d�O�D�!�!�!�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"�	"�	"s�A)�2A)�)A-�0A-c�L��eZdZ�fd�Z�fd�Z���fd�Z����fd�Z�fd�ZdS)�%_make_ffi_library.<locals>.FFILibraryc�:���|��t||��Sr	)r5)r@rBr�s  �r�__getattr__z1_make_ffi_library.<locals>.FFILibrary.__getattr__�s#����M�$�����4��&�&�&rc���	t|j|��}|�||��dS#t$r �|��t	|||��YdSwxYwr	)r5�	__class__�__set__r�r4)r@rBrr�r�s    �r�__setattr__z1_make_ffi_library.<locals>.FFILibrary.__setattr__�s���
.�"�4�>�4�8�8��
� � ��u�-�-�-�-�-��	"�
+�
+�
+��
�d�#�#�#���d�E�*�*�*�*�*�*�
+���s�0�&A�Ac����j5�������cddd��S#1swxYwYdSr	)r�keys)r@r�r�r�s ���r�__dir__z-_make_ffi_library.<locals>.FFILibrary.__dir__�s������
(�
(� � �"�"�"� �~�~�'�'�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(����
(�
(�
(�
(�
(�
(s�4�8�8c����|�jvr
�j|S|�jvr�|��S�|��|�jvr
�j|S|�jvr�|��Std|�d����)Nz7cffi library has no function or global variable named '�')r%r�)r@rBr�r�r�r�s  ����rr�z3_make_ffi_library.<locals>.FFILibrary.__addressof__�s�����w�'�'�'��'��-�-��z�*�*�*�$�}�T�*�*�*��M�$�����w�'�'�'��'��-�-��z�*�*�*�$�}�T�*�*�*� �.�AE���"H�I�I�
Irc�b������|j���dSr	)�	close_libr%rW)r@r�s �rrfz4_make_ffi_library.<locals>.FFILibrary.__cffi_close__�s/���� � �"�"�"��M���!�!�!�!�!rN)r�r�r�r�r�r�r�rf)r�r�r�r�r�r�r�r�s��������rr�r��s��������	'�	'�	'�	'�	'�	.�	.�	.�	.�	.�	(�	(�	(�	(�	(�	(�	(�	I�	I�	I�	I�	I�	I�	I�	I�	"�	"�	"�	"�	"�	"�	"rr�zutf-8z
FFILibrary_%s)
rr�rTr
rQrPrSr��UnicodeErrorr%)r��libnamer`rAr�r�r�r�r�r�r�r�r�r�r�r�r�s`   @@@@@@@@@@@@@rr_r_>s(�����������������l�G�"�7�G�U�;�;�J�'�'�'�'�'�'�'�E�E�E�E�E�E�E�
(�
(�
(�
(�
(�
(�
(�P�P�P�B�B�B�B�B�B��I�����N�1�1�1�1�1�1�1�1�1�1�1�1�."�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�V�"�"�"�@�'�:�&�&��	��g�s�+�+�
2�!�.�.��1�1��"1�G�";�J�����	�	�	��D�	�����j�l�l�G��G�$�$�$s�4C�
C�Cc��ddl}	|j|j}|j}|j}||}|j5|�|��cddd��S#1swxYwYdS#tttf$rYdSwxYw)Nr)
r�modulesr��_cffi_original_ffi�_cffi_types_of_builtin_funcsrr6rsr�rR)r]r�moduler��types_of_builtin_funcsr]s      rrzrz�s����J�J�J�	-���T�_�-���'��!'�!D��
#�D�
)���Y�	-�	-��(�(��,�,�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-�	-�	-��
�n�i�0�����t�t����s"�(A$�A�A�A�$A?�>A?)rr#�lockrr�rrrr��	NameError�collectionsrrQrPrTr�rr�r_rzr�rr�<module>r�sC����������������������������1��H�H���1�1�1�$�$�$�$�$�$�0�0�H�H�H�1����
��J�J�������J�J�J������v�x�x��J+�J+�J+�J+�J+�&�J+�J+�J+�Z-�-�-�4x%�x%�x%�t
-�
-�
-�
-�
-s��0�0�7�A�A