
    #	h                         S SK r S SKrSSKJr  SSKJr  SSKJr   \   \  \" 5       r " S S	\5      rS
 rS rS rg! \	 a    S SK
Jr  S r N0f = f! \	 a    \r N;f = f)    N   )allocate_lock)	CDefError)model)Callablec                 "    [        U [        5      $ N)
isinstancer   )xs    :/var/www/html/env/lib/python3.13/site-packages/cffi/api.py<lambda>r      s    Ax0    c                      \ rS rSrSrS6S jrS7S jrS8S jrS9S jrS:S	 jr	S
 r
S rS9S jrS rS rS rS rS6S jr  S;S jrS rS<S jrS r\S4S jrS rS=S jrS>S jrS:S jrS rS?S jrS rS r\ " \\SS5      r!S<S  jr"S! r#S" r$S# r%S$ r&S% r'S& r(S' r)S( r*S) r+S* r,S@S+ jr- S@S, jr.SAS- jr/S. r0S/ r1SBS0 jr2S1 r3S2 r4S3 r5S4 r6S5r7g)CFFI   af  
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                 
   Uc  SSK nSSKJn  UR                  U:w  ak  [        US5      (       a4  [	        SU< S[
        < SUR                  < SUR
                  < S	3	5      e[	        SU< S[
        < S
UR                  < S	35      eSSKJn  Xl        [        5       U l	        UR                  5       U l        0 U l        [        R                  " S5      R                  U l        [        R                  " S5      R                  U l        / U l        / U l        / U l        / U l        SU l        0 U l        SU l        SU l        [4        R6                  " U5      U l        [        US5      (       a  UR;                  U 5        [=        UR                  5       H0  nUR?                  S5      (       d  M  [A        X[C        X5      5        M2     U R                     U RE                  [4        RF                  5      U l$        U RE                  [4        RJ                  5      U l&        SSS5        [O        U[        R                  5      (       a`  [        [P        S5      (       dJ  U RS                  U RH                  S5      [P        l*        URW                  5       u  [P        l,        [P        l-        O>U RS                  U RH                  S5      U l*        URW                  5       u  U l,        U l-        UR\                  U l.        g! , (       d  f       N= f)zkCreate an FFI instance.  The 'backend' argument is used to
select a non-default backend, mostly for tests.
Nr   r   )__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	Exceptionr   r   _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backendr   r   names        r   __init__FFI.__init__)   s@    ? ,%""k17J//##X++W-=-=%? @ @
 $#Xw/B/B%D E E 	"_
~~' "--n=FF**;7@@ "  $ "!--g67I&&OOD!))*Dw''GG$:; + ZZ001A1ABDK001F1FGDK  gu//003''99T[[!4'.'9'9';$	39 		$++q1DI%,%7%7%9"DJ
nn Zs   A	K44
LFc                 $    U R                  XX4S9  g)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)rA   csourcerG   rH   rI   s        r   cdefFFI.cdefe   s     	

7f
Hr   c                 P    U R                  XUSS9  U R                  c  SU l        g g )NT)rH   rI   	dllexportr   )rJ   r0   )rA   rK   rH   rI   s       r   embedding_apiFFI.embedding_apir   s*    

7
E??" DO #r   c                 R   [        U[        5      (       d1  [        U[        5      (       d  [        S5      eUR	                  S5      nU R
                     [        5       U l        U R                  R                  " U4SU0UD6  U R                  R                  U5        U(       a#  U R                   H  nUR                  5         M     U R                  R                  nU(       a+  / U R                  l        U H  nUR                  X5        M     S S S 5        g ! , (       d  f       g = f)Nz cdef() argument must be a stringasciirG   )r
   str
basestring	TypeErrorencoder    objectr/   r"   parser+   appendr)   clear_recompletefinish_backend_type)rA   rK   rG   optionscache
finishlisttps          r   rJ   	FFI._cdefw   s    '3''gz22 BCCnnW-GZZ!'DLLwEEWE$$W-!22EKKM 311J+-($B**4< % ZZs   B<D
D&c                 V   [        U[        5      (       d(  Ub%  [        XR                  5      (       d  [        S5      eU R                     [        XU5      u  p4U R                  R                  U5        U R                  R                  U5        SSS5        U$ ! , (       d  f       W$ = f)a   Load 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
   rU   r>   rV   r    _make_ffi_libraryr)   rZ   r*   )rA   rC   flagslibfunction_caches        r   dlopen
FFI.dlopen   s     4,,4,, C D DZZ"3D"FC!!((8OO""3'  
	 Z 
s   
AB
B(c                 8    [        U5      R                  U5        g)zClose 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__)rA   rf   s     r   dlcloseFFI.dlclose   s    
 	S	  %r   c                 R   UnX R                   ;   a  U R                   U   $ [        U[        5      (       d  UR                  S5      nU R                  R                  U5      nUR                  nU(       a  UR                  5       nU R                  U5      nXT4nX`R                   U'   U$ )NrS   )	r'   r
   rT   rW   r"   
parse_typeis_raw_functionas_function_pointerr7   )rA   cdeclkeyrk   really_a_function_typebtyperesults          r   _typeof_lockedFFI._typeof_locked   s    $$$%%c**%%%LL)E||&&u-!%!5!5!++-D&&t,."(3r   c                      U R                   U   nWu  pEU(       a  U(       d  [	        SU< S35      eU$ ! [         a<    U R                     U R                  U5      nS S S 5         MW  ! , (       d  f        Nf= ff = f)Nz	the type z3 is a function type, not a pointer-to-function type)r'   KeyErrorr    rx   r   )rA   rs   consider_function_as_funcptrrw   rv   ru   s         r   _typeofFFI._typeof   sx    	4''.F
 )/%!*F:?B C C  	4,,U3 	4s'   5 A;A(A;(
A7	2A;7A;c                 "   [        U[        5      (       a  U R                  U5      $ [        XR                  5      (       a  U R                  R                  U5      $ [        U[        R                  5      (       a  [        U5      nUb  U$ [        U[        R                  5      (       aB  [        US5      (       a1  U R                     U R                  UR                  5      sSSS5        $ [        [        U5      5      e! , (       d  f       N"= f)zParse 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
   rU   r}   r>   r   typeofr$   BuiltinFunctionType_builtin_function_typeFunctionTyper   r    r7   r   rV   rk   )rA   rs   ress      r   r   
FFI.typeof   s    
 eZ((<<&&eZZ((==''..eU6677(/C
ue0011E#455--e.C.CD U$$ s   D  
Dc                     [        U[        5      (       a,  U R                  U5      nU R                  R	                  U5      $ U R                  R	                  U5      $ )zfReturn the size in bytes of the argument.  It can be a
string naming a C type, or a 'cdata' instance.
)r
   rU   r}   r   sizeof)rA   rs   BTypes      r   r   
FFI.sizeof   sI     eZ((LL'E==''..==''..r   c                     [        U[        5      (       a  U R                  U5      nU R                  R	                  U5      $ )zLReturn the natural alignment size in bytes of the C type
given as a string.
)r
   rU   r}   r   alignof)rA   rs   s     r   r   FFI.alignof   s4     eZ((LL'E}}$$U++r   c                 z    [        U[        5      (       a  U R                  U5      nU R                  " U/UQ76 S   $ )a  Return 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
   rU   r}   _typeoffsetof)rA   rs   fields_or_indexess      r   offsetofFFI.offsetof   s;     eZ((LL'E!!%<*;<Q??r   c                     [        U[        5      (       a  U R                  U5      nU R                  R	                  X5      $ )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
   rU   r}   r   newp)rA   rs   inits      r   newFFI.new   s4    . eZ((LL'E}}!!%..r   c                 t   ^ ^ T R                   R                  5       nUR                  XU5      mSUU 4S jjnU$ )aw  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.
c                 `   > [        U [        5      (       a  TR                  U 5      n T" X5      $ r	   r
   rU   r}   )rs   r   	allocatorrA   s     r   allocate#FFI.new_allocator.<locals>.allocate  s)    %,,U+U))r   r	   )r   r   new_allocator)rA   allocfreeshould_clear_after_alloccompiled_ffir   r   s   `     @r   r   FFI.new_allocator  s>     }}((* ..u/GI		* 	* r   c                     [        U[        5      (       a  U R                  U5      nU R                  R	                  X5      $ )zSimilar 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
   rU   r}   r   r<   )rA   rs   sources      r   r<   FFI.cast%  s4    
 eZ((LL'E}}!!%00r   c                 8    U R                   R                  X5      $ )ak  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)rA   cdatamaxlens      r   r   
FFI.string.  s      }}##E22r   c                 8    U R                   R                  X5      $ )a  Unpack 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)rA   r   lengths      r   r   
FFI.unpack@  s     }}##E22r   c                     U[         L a  U R                  Up!O&[        U[        5      (       a  U R	                  U5      nU R
                  R                  XU5      $ )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
   rU   r}   r   from_buffer)rA   rs   python_bufferrequire_writables       r   r   FFI.from_buffer^  sN     L(#';;=z**LL'E}}(()9; 	;r   c                 :    U R                   R                  XU5      $ )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)rA   destsrcns       r   r   FFI.memmovep  s     }}$$T22r   c                    ^ ^^^ UUUU 4S jn[        T[        5      (       a  T R                  TSS9mUc  U$ U" U5      $ )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                 v   > [        U 5      (       d  [        S5      eTR                  R                  TU TT5      $ )Nz.the 'python_callable' argument is not callable)callablerV   r   callback)python_callablers   erroronerrorrA   s    r   callback_decorator_wrap-FFI.callback.<locals>.callback_decorator_wrap  s@    O,, !2 3 3==))%*/: :r   T)r|   r   )rA   rs   r   r   r   r   s   `` `` r   r   FFI.callback  sE    	: 	: eZ((LLTLJE"***?;;r   c                 F   [        U[        5      (       a  U R                  U5      nUR                  5       nUR	                  S5      (       a&  SU R
                  R                  US5      ;   a  SU-  nOU(       a  US   S;  a  SU-   nU R
                  R                  X5      $ )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)r   z[( )r
   rU   r}   stripr4   r   getcname)rA   rs   replace_withs      r   getctypeFFI.getctype  s     eZ((LL'E#))+##C((DMM225#>>!L0L,q/T"9-L}}%%e::r   c                 :    U R                   R                  XU5      $ )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)rA   r   
destructorsizes       r   gcFFI.gc  s     }}  D99r   c                     U R                   R                  S5      SL d   e U R                  U   nU$ ! [         a1    / nUR	                  X5      nU H  nUR                  X5        M      U$ f = f)NF)r    acquirer#   r{   get_cached_btyper]   )rA   rk   r   r`   s       r   r7   FFI._get_cached_btype  s~    zz!!%(E111	;''-E   	;J))$;E"((: #	;s   3 7A.-A.c                    SSK JnJn  U R                  (       a  U R	                  U5        U=(       d    U" 5       nU" XU40 UD6U l         U R                   R                  5       nU R                  R                  U5        U$ )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*   rZ   )rA   r   tmpdirkwargsr   r   rf   s          r   verify
FFI.verify  sp     	<   ''/
 0.0 !v@@mm((* 	s#
r   c                 6    U R                   R                  5       $ r	   )r   	get_errno)rA   s    r   
_get_errnoFFI._get_errno  s    }}&&((r   c                 :    U R                   R                  U5        g r	   )r   	set_errno)rA   errnos     r   
_set_errnoFFI._set_errno  s    &r   z(the value of 'errno' from/to the C callsc                 8    U R                   R                  U5      $ r	   )r   getwinerror)rA   codes     r   r   FFI.getwinerror  s    }}((..r   c                 |    U R                      [        R                  " X5      sS S S 5        $ ! , (       d  f       g = fr	   )r    r   pointer_cache)rA   ctypes     r   _pointer_toFFI._pointer_to  s!    ZZ&&t3 ZZs   -
;c                     U R                   R                  U5      nU(       a  U R                  " U/UQ76 u  p4OUR                  S:X  a  [        S5      eSnU R                  U5      nU R                   R                  XQU5      $ ! [         a9    S[        U5      R                  ;   a  [        U5      R
                  " U/UQ76 s $ e f = f)zReturn 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__pointerzaddressof(pointer)r   )
r   r   rV   rk   r&   r   r   kindr   rawaddressof)rA   r   r   r   offsetctypeptrs         r   	addressofFFI.addressof  s    	MM((/E
  ..uI7HIME6zzY& 455F##E*}}))(6BB  	$u+"6"66E{00K9JKK	s   B ?CCc                     U R                   R                  X5      u  pU H%  nU R                   R                  XS5      u  pXF-  nM'     X4$ )Nr   )r   typeoffsetof)rA   r   field_or_indexr   r   field1offset1s          r   r   FFI._typeoffsetof  sL    225I'F!]]77qINEF ( }r   c                 ^   [        U[        5      (       d"  [        S[        U5      R                  < 35      eXL a  [        S5      eUR                     U R                     U R                  R                  UR                  5        U R                  R                  S5        U R                  R                  UR                  5        U R                  R                  S5        U R                  R                  U5        SSS5        SSS5        g! , (       d  f       N= f! , (       d  f       g= f)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 zself.include(self)[]N)r
   r   rV   rk   __name__
ValueErrorr    r"   includer+   rZ   extendr,   )rA   ffi_to_includes     r   r	  FFI.include  s     .#.. $^ 4 = =@ A A !122!!$$^%;%;<!!((-!!(()D)DE!!((-##**>:  "! "!s%   D BD<D
D	D
D,c                 N    U R                   R                  U R                  U5      $ r	   )r   newp_handler9   rA   r   s     r   
new_handleFFI.new_handle  s    }}((a88r   c                 8    U R                   R                  U5      $ r	   )r   from_handler  s     r   r  FFI.from_handle  s    }}((++r   c                 :    U R                   R                  U5        g r	   )r   releaser  s     r   r  FFI.release"  s    a r   c                     U R                   b  [        S5      e[        U5      nU(       a  U R                  S5        OU R                  S5        Xl         g)a;  Windows: 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 onceztypedef 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;ztypedef 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  boolrL   )rA   enabled_flags     r   set_unicodeFFI.set_unicode%  sU       ,DEEL)II / 0 II / 0 !-r   c                     UR                  SS5      n[        U[        [        45      (       d  [	        S5      e[        U5      SS/-   nX!S'   g )Ndefine_macros z''define_macros' must be a list or tuple)UNICODE1)_UNICODEr!  )getr
   r3   tuplerV   )rA   kwds	defmacross      r   r   FFI._apply_windows_unicodeC  sP    HH_b1	)dE]33EFFO'7'8': :	 )_r   c                 j  ^ U4S jnS[         R                  ;   Ga%  SS Kn[         R                  S:X  af  SR	                  [         R
                  5      n[        [         S5      (       a1  U" SUR                  R                  [         R                  S5      5        O_[         R
                  S	:  a  S
nOSn[        [         S5      (       a1  U" SUR                  R                  [         R                  S5      5        [        [         S5      (       a2  U" SUR                  R                  [         R                  SS5      5        O[         R                  S:X  a  Sn[        [         S5      (       a  US-  nO0 SS K
nSnUR                  S5      (       a  XVR                  S5      -  nU[         R                  S-	  [         R                  S-	  S-  4-  n[        [         S5      (       a  U[         R                  -  nU" SU5        [         R                  S:X  a
  U" SS5        g g ! [         a	    SSKJ
n   Nf = f)Nc                 X   > TR                  U / 5      nX;  a  UR                  U5        g g r	   )
setdefaultrZ   )rt   valuelstr%  s      r   ensure(FFI._apply_embedding_fix.<locals>.ensureM  s*    //#r*C

5!  r   __pypy__r   win32zpython{0[0]}{0[1]}prefixlibrary_dirslibs   zpypy-czpypy3-cbinpypygoalz
python%d%dgettotalrefcount_d)	sysconfigzpython%d.%d	DEBUG_EXT         abiflags	librariesextra_link_argsz	/MANIFEST)sysbuiltin_module_namesosplatformformatversion_infor   pathjoinr1  r;  ImportErrorcffi._shimmed_dist_utilsget_config_var
hexversionr@  )rA   r%  r-  rE  	pythonlibtemplater;  s    `     r   _apply_embedding_fixFFI._apply_embedding_fixK  s   	"
 111||w& 1778H8HI	3))>277<<

F+KL
 ##d* (I )I3))>277<<

E+JK sH%%~rww||CJJ'OP||w&'3 233$HC$ )++K88 8 8 EEH!^^r)CNNb,@D+HIJIsJ''S\\)	{I&<<7"$k2 # # CBCs   4H H21H2c                 "   SS K n[        U S5      (       a  [        S5      e[        U[        5      (       d  [        S5      eUR                  U;   d!  UR                  (       a  UR                  U;   a  [        S5      e[        U5      UX44U l	        g )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)
rE  r   r  r
   rU   rV   sepaltseprT   rT  )rA   module_namer   source_extensionr%  rE  s         r   
set_sourceFFI.set_source}  s    4+,, . / /+z22<==66[ RYY2993K H I I!$[!16!1!9r   c                     SSK Jn  [        U[        5      (       d  [	        S5      eUR                  U5      nUR                  XW5        U R                  " XU40 UD6  g )Nr   )	pkgconfigz;the pkgconfig_libs argument must be a list of package names)r   r\  r
   r3   rV   flags_from_pkgconfigmerge_flagsrY  )rA   rW  pkgconfig_libsr   rX  r%  r\  kwds2s           r   set_source_pkgconfigFFI.set_source_pkgconfig  sV    .$// / 0 0..~>d*-=FFr   c                    SSK Jn  SSKJn  [	        U S5      (       d6  [	        U S5      (       a  U R
                  R                  5       $ [        S5      eU R                  u  pVpxUc  [        S5      eU" U5        U" XU4XUS	S
.UD6u  pU(       ak  U
(       a3  [        R                  R                  SU	R                  S   < S35        U	$ [        R                  R                  SU	R                  S   < S35        U	$ )Nr   )mkpathr   	recompilerT  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   extradirrX  call_c_compilerzregenerated: 
znot modified: )rL  rd  
recompilerrf  r   r   get_extensionr  rT  rV   rC  stderrwritesources)rA   r   verboserd  rf  rW  r   rX  r%  extupdateds              r   distutils_extensionFFI.distutils_extension  s    3)t/00tZ((}}2244 6 7 76:6K6K3-> & ' ' 	v !'@062B16@ ;?@ 

  A!HI 
 

  Q!IJ
r   c                     SSK Jn  [        U S5      (       d  [        S5      eU R                  u  p4pVUc  [        S5      eU" XU4USSS.UD6  g )Nr   re  rT  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_filerh  uses_ffiplatformrj  rf  r   r  rT  rV   rA   filenamerf  rW  r   rX  r%  s          r   emit_c_codeFFI.emit_c_code  sk    )t/00OPP6:6K6K3-> I J J$V 	2!5#(	2,0	2r   c                     SSK Jn  [        U S5      (       d  [        S5      eU R                  u  p4pVUb  [        S5      eU" XU4USSS.UD6  g )Nr   re  rT  ru  z^emit_python_code() is only for dlopen()-style pure Python modules, not for C extension modulesFrv  ry  rz  s          r   emit_python_codeFFI.emit_python_code  sl    )t/00OPP6:6K6K3- O P P$V 	2!5#(	2,0	2r   c           	          SSK Jn  [        U S5      (       d  [        S5      eU R                  u  pgpU" XU4UX8X$S.U	D6$ )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.
r   re  rT  z,set_source() must be called before compile())r   targetrX  compiler_verbosedebug)rj  rf  r   r  rT  )
rA   r   ro  r  r  rf  rW  r   rX  r%  s
             r   compileFFI.compile  s\     	*t/00KLL6:6K6K3-F H6 &*1HBFH 	Hr   c                 n    U R                   U   nUS   (       a  US   $ US      U R                   U   nUS   (       a  US   sS S S 5        $ U" 5       nSU4U R                   U'   S S S 5        U$ ! [         a)    U R                   R                  US[        5       45      n Nf = f! , (       d  f       W$ = f)NFr   r   T)r.   r{   r*  r   )rA   functagr   rw   s        r   	init_onceFFI.init_once  s    	P%%c*A Q4Q4KqT%%c*Att	 T VF*.D!!#&    	P%%00umo6NOA	P T s"   A/ B%B%/0B"!B"%
B4c                    U R                   (       a  [        S5      eSS KnUR                  SU5      nU(       a  XR	                  5       S  nUR                  5       =(       d    S/nUR                  SUS   5      R                  5       n[        S[        U5      5       HS  nXF   nUR                  5       (       d  M  UR                  U5      (       a  M6  US S nUR                  U5      (       d  M  MU     [        U5      nU Vs/ s H
  owUS  S-   PM     nnSR                  U5      n[        US	S
5        Xl         g s  snf )Nz-embedding_init_code() can only be called oncer   z\s*\nr   z\s*r   ri  	cffi_initexec)r0   r  rematchend
splitlinesgrouprangelenrstripr4   rJ  r  )rA   pysourcer  r  linesr1  ilines           r   embedding_init_codeFFI.embedding_init_code  s   ??LMM
 	8,		-H##%-"&%(+113q#e*%A8D{{}}//&11#CR[F //&11 &
 K+0154ab$51775>+v." 2s   D<c                     [        S5      e)Nz:ffi.def_extern() is only available on API-mode FFI objects)r  )rA   argsr%  s      r   
def_externFFI.def_extern  s     # $ 	$r   c                    / n/ n/ nU R                   R                   H  nUR                  S5      (       a  UR                  USS 5        M/  UR                  S5      (       a  UR                  USS 5        M[  UR                  S5      (       d  Ms  UR                  USS 5        M     UR	                  5         UR	                  5         UR	                  5         XU4$ )zReturns 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)
ztypedef    Nzstruct    zunion    )r"   _declarationsr4   rZ   sort)rA   typedefsstructsunionsrt   s        r   
list_typesFFI.list_types  s    
 <<--C~~j))AB(	**s12w'))c!"g& . 	6**r   )r;   r9   r>   r?   r   rT  r   r#   r/   r+   r0   r)   r,   r.   r*   r    r(   r'   r"   r2   r-   r@   r   r	   )FFN)FN)F)r   )NNT)r  )NNN)r   )r   N)z.c)buildT).r   NN)8r  
__module____qualname____firstlineno____doc__rD   rL   rP   rJ   rh   rm   rx   r}   r   r   r   r   r   r   r<   r   r   r   r   r   r   r   r   r7   r   r   r   propertyr   r   r   r   r   r	  r  r  r  r  r   rQ  rY  ra  rr  r|  r  r  r  r  r  r  __static_attributes__r  r   r   r   r      s"   ":%xI!
=$$&$%&/,	@/6 .2/3013$3< 0<%*;$3 <*; 
:
<)'ZT?AE/4C*;.9,!-<*03d9 /3G422H&0#4$+r   r   c                 ,   SS K n[        U[        5      (       d*  [        R                  S:w  d  Ub  U R                  X5      $ SnS nSU;   d  SU;   d  UR                  U;   a   U R                  X5      $ SS KnUR                  R                  U5      nUcV  US:X  a3  [        R                  S:X  a  [        R                  S:  a  [        S5      eSU< 3nUb	  U< S	U< 3n[        U5      eU R                  Xr5      $ ! [         a  nUn S nANS nAff = f)
Nr   r0  cr  /r4  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, )rE  r
   rU   rC  rF  r   rU  OSErrorctypes.utilutilfind_libraryrH  )	rB   rC   re   rE  first_errorectypesrI  msgs	            r   _load_backend_libr  &  s   dJ''<<7"d&6''44K
d{cTkRVVt^	''44 ;;##D)D|3;3<<72s7G7G47O D E E 379"-8#>Ccl,,  	K	s   #C= =
DDDc           
        ^ ^^^^^^	^
^^^^^^ T R                   n[        X1U5      mUU U4S jmUUU 4S jmUUU 4S jmS mU U4S jm0 m	S/m
0 mUUUUU	U
U U4S jmUU	U UU4S jm " UU	UUU UUU4S	 jS
[        5      m[        U[        5      (       a1   [        U[
        5      (       d  UR                  S5      nSU-  Tl        T" 5       mTTR                  4$ ! [         a     N!f = f)Nc                    > SU -   nTR                   R                  U   u  p#TR                  U5      nTR                  X@5      nUTR                  U '   g )Nz	function )r"   r  r7   load_functionr&   )	rC   rt   ra   _r   r+  
backendlibffilibrarys	         r   accessor_function,_make_ffi_library.<locals>.accessor_functionD  sS    D ))#.%%b)((5!&r   c           
         >^ ^^^ ST -   nT	R                   R                  U   u  p#T	R                  U5      mTR                  mTR                  m[        TT [        UU U4S jUU U4S j5      5        g )N	variable c                    > T" TT5      $ r	   r  )rA   r   rC   read_variables    r   r   >_make_ffi_library.<locals>.accessor_variable.<locals>.<lambda>R  s    ud3r   c                    > T" TTU5      $ r	   r  )rA   r+  r   rC   write_variables     r   r   r  S  s    udE Br   )r"   r  r7   r  r  r5   r  )
rC   rt   ra   r  r   r  r  
FFILibraryr  r  s
   `   @@@r   accessor_variable,_make_ffi_library.<locals>.accessor_variableK  sd    D ))#.%%b)"00#22
D(3B#D 	Er   c                 p  >  TU    $ ! [          a    TR                     U T;  an  SU -   nTR                  R                  U   u  p#TR	                  U5      nUR
                  S:w  a  [        R                  " TU5      nTR                  X@5      nUTU '   S S S 5        O! , (       d  f       O= fTU    s $ f = f)Nr  array)	r{   r    r"   r  r7   r   r   r   r  )	rC   rt   ra   r  r   paddr_variablesr  r  s	         r   addressof_var(_make_ffi_library.<locals>.addressof_varU  s    	(!$'' 
	(~-%,CKK55c:EB11"5EzzW, % 3 3C ?"00=A+,N4(  "$''
	(s'    B5A5B	B5
B*	&B54B5c                 "    [        SU < S35      e)Nznon-integer constant 'z,' cannot be accessed from a dlopen() library)NotImplementedError)rC   s    r   accessor_constant,_make_ffi_library.<locals>.accessor_constantd  s    !HL#O P 	Pr   c                 R   > TR                   R                  U    TR                  U '   g r	   )r"   _int_constantsr&   )rC   r  r  s    r   accessor_int_constant0_make_ffi_library.<locals>.accessor_int_constanth  s"    !$!;!;D!Ar   Fc                    > TS   TR                   L a  g TR                  R                  R                  5        H  u  n u  p[	        U[
        R                  5      (       d=  U R                  SS5      u  p4US:X  a  T	TU'   MH  US:X  a  TTU'   MU  US:X  a  TTU'   Mb  Md  [        UR                  5       H  u  pVX4U4S jjnUTU'   M     M     TR                  R                   H  nTR                  UT
5        M     TR                   TS'   g )Nr   r   r   functionvariableconstantc                 ^   > UR                  5         UR                  U   TR                  U '   g r	   )check_not_partial
enumvaluesr&   )rC   ra   r  r  s      r   accessor_enumB_make_ffi_library.<locals>.update_accessors.<locals>.accessor_enum~  s(    ,,.13q1A((.r   )r/   r"   r  itemsr
   r   EnumTypesplit	enumerateenumeratorsr  r*  )rt   ra   r  r  rC   r  enumnamer  r  r  r  r  	accessorsaccessors_versionr  r  s           r   update_accessors+_make_ffi_library.<locals>.update_accessorso  s    Q3#4#44KK55;;=LC"b%..11IIc1-	*$&7IdOJ&&7IdOJ&&7IdO ' $-R^^#<KA/1 B +8Ih'	 $= > KK..D  '<= /"00!r   c                    > TR                      U TR                  ;   d  U TR                  ;   a
   S S S 5        g U T;  a  T" 5         U T;  a  [        U 5      eTU    " U 5        S S S 5        g ! , (       d  f       g = fr	   )r    r&   AttributeError)rC   r  r  r  r  r  s    r   make_accessor(_make_ffi_library.<locals>.make_accessor  sh    YYw'''4:3F3F+F Y 9$ "y((..dOD! YYs   "A+)A++
A9c                   \   > \ rS rSrU4S jrU4S jrUUU4S jrU UUU4S jrU4S jrSr	g)	%_make_ffi_library.<locals>.FFILibraryi  c                 *   > T" U5        [        X5      $ r	   )r6   )rA   rC   r  s     r   __getattr__1_make_ffi_library.<locals>.FFILibrary.__getattr__  s    $4&&r   c                    >  [        U R                  U5      nUR                  X5        g ! [         a    T" U5        [	        XU5         g f = fr	   )r6   	__class____set__r  r5   )rA   rC   r+  r  r  s       r   __setattr__1_make_ffi_library.<locals>.FFILibrary.__setattr__  sK    ."4>>48
   -	 " +d#E*+s   + AAc                    > TR                      T" 5         TR                  5       sS S S 5        $ ! , (       d  f       g = fr	   )r    keys)rA   r  r  r  s    r   __dir__-_make_ffi_library.<locals>.FFILibrary.__dir__  s$     " ~~' s   /
=c                   > UTR                   ;   a  TR                   U   $ UTR                   ;   a  T" U5      $ T" U5        UTR                   ;   a  TR                   U   $ UTR                   ;   a  T" U5      $ [        SU< S35      e)Nz7cffi library has no function or global variable named '')r&   r  )rA   rC   r  r  r  r  s     r   r   3_make_ffi_library.<locals>.FFILibrary.__addressof__  s    w'''''--z***$T**$w'''''--z***$T** AE"H I Ir   c                 Z   > TR                  5         U R                  R                  5         g r	   )	close_libr&   r[   )rA   r  s    r   rl   4_make_ffi_library.<locals>.FFILibrary.__cffi_close__  s      "MM!r   r  N)
r  r  r  r  r  r  r  r   rl   r  )r  r  r  r  r  r  r  r  s   r   r  r    s(    	'	.	(	I 	I	" 	"r   r  zutf-8zFFILibrary_%s)
r   r  rX   r
   rU   rT   rW   r  UnicodeErrorr&   )r  libnamere   rB   r  r  r  r  r  r  r  r  r  r  r  r  r  s   `   @@@@@@@@@@@@@r   rd   rd   @  s    llG"7U;J'E(PB IN1 1." "" "V "@ ':&&	gs++!..1"1G";J lGG$$$$  		s   0C 
C('C(c                    SS K n UR                  U R                     nUR                  nUR                  nX@   nUR
                     UR                  U5      sS S S 5        $ ! , (       d  f       g = f! [        [        [        4 a     g f = f)Nr   )
rC  modulesr  _cffi_original_ffi_cffi_types_of_builtin_funcsr    r7   r{   r  rV   )r  rC  moduler  types_of_builtin_funcsra   s         r   r   r     sx     	-T__-''!'!D!D#) YY((, YY ni0 s   5A3 A""
A03B
B)rC  r$   lockr   r   r   r   r   r   	NameErrorcollectionsr   rU   rT   rX   r   r   r  rd   r   r  r   r   <module>r     sy       1
 xL+& L+^-4x%t-e  1$0H1  Js    = A AAAA