lfVddlZddlZddlZddlmZmZddlmZddlTdZ dZ dZ ej d kpej d kp ej d kZGd d ZGddZGddZGddZGddZGddZej dkrejZnGddejZdZd(dZd(dZdZd Zd!Zd"Zd#Z d)d'Z dS)*N) ffiplatformmodel)VerificationError)*i&i'i(win32)r)r c"eZdZddZdZdZdS) GlobalExprrcL||_||_||_||_||_dSN)nameaddresstype_opsize check_value)selfrrrrrs q/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib64/python3.11/site-packages/cffi/recompiler.py__init__zGlobalExpr.__init__s,    &c ld|jd|jd|jd|jd S)N { "z ", (void *), z , (void *) },)rrr as_c_exprrrs rrzGlobalExpr.as_c_exprs? IIIt|||T\%;%;%=%=%=%=tyyyJ JrcTd|j|j|jfzS)Nz b'%s%s',%d)ras_python_bytesrrrs ras_python_exprzGlobalExpr.as_python_exprs.t|;;==ty#/11 1rN)rr__name__ __module__ __qualname__rrr rrr r sI''''JJJ11111rr c&eZdZdZdZdZdZdS) FieldExprcL||_||_||_||_||_dSr)r field_offset field_sizefbitsize field_type_op)rrr)r*r+r,s rrzFieldExpr.__init__s- ($  *rcdt|jz}d|jd|jdd|d|jdzd|d|jdzS)N r", z, z z r)lenrr)r*r,r)rspacess rrzFieldExpr.as_c_expr&sys49~~%%)YYY0A0A0ABB%+VVT___=>>%+VVT-?-I-I-K-K-K-KLM Nrctr)NotImplementedErrorrs rr zFieldExpr.as_python_expr,s!!rc|jjtkrd}n1|jjtkrt |j}nt d|j||jdS)Nb'') r,opOP_NOOP OP_BITFIELDformat_four_bytesr+r3rr)r size_exprs ras_field_python_exprzFieldExpr.as_field_python_expr/sp   G + +II   "k 1 1)$-88II% %"0@@BBB'i"iii) )rN)r"r#r$rrr r=r%rrr'r'sS+++NNN """ ) ) ) ) )rr'c eZdZdZdZdZdS)StructUnionExprc v||_||_||_||_||_||_||_||_dSr)r type_indexflagsr alignmentcommentfirst_field_indexc_fields) rrrArBrrCrDrErFs rrzStructUnionExpr.__init__;s? $  " !2  rcd|j|j|jfzd|jd|jdzd|jt |jfzz|jr d|jzndzdzS)Nz { "%s", %d, %s,z rz%d, %d z /* %s */ r5z},) rrArBrrCrEr0rFrDrs rrzStructUnionExpr.as_c_exprFs#ty$/4:&NNN&*iii@At5s4=7I7IJJK26E;--2G  rct|jt}d|jD}dt |jt ||jdd|dS)Nc6g|]}|Sr%)r=).0c_fields r z2StructUnionExpr.as_python_expr..Os4555"3355555rz(b'',,))evalrBG_FLAGSrFr;rArjoin)rrB fields_exprs rr zStructUnionExpr.as_python_exprMs}TZ))55&*m555  do . . . e $ $ $ III HH[ ! ! ! ! # #rNr!r%rrr?r?:sA ! ! !#####rr?c eZdZdZdZdZdS)EnumExprcL||_||_||_||_||_dSrrrArsignedallenums)rrrArrXrYs rrzEnumExpr.__init__Xs) $    rcHd|j|j|j|j|jfzS)Nz1 { "%s", %d, _cffi_prim_int(%s, %s), "%s" },rWrs rrzEnumExpr.as_c_expr_s/!%DO!%DK!HH Irc tttttt t td|j|j f}dt|j t||j d|j dS)N))rr)rr)r)r\r)r)r]r)r)r^rr6z\x00r7) PRIM_UINT8 PRIM_INT8 PRIM_UINT16 PRIM_INT16 PRIM_UINT32 PRIM_INT32 PRIM_UINT64 PRIM_INT64rrXr;rArrY)r prim_indexs rr zEnumExpr.as_python_exprdsr)***  i$ & &7t%G%G%G%6z%B%B%B%)YYY ? ?rNr!r%rrrUrUWsD!!!III ? ? ? ? ?rrUc eZdZdZdZdZdS) TypenameExprc"||_||_dSrrrA)rrrAs rrzTypenameExpr.__init__ps $rc$d|j|jfzS)Nz { "%s", %d },rkrs rrzTypenameExpr.as_c_exprts DIt#???rc@dt|j|jdS)Nr6r7)r;rArrs rr zTypenameExpr.as_python_exprws"-do>>> JJrNr!r%rrririosI%%%@@@KKKKKrriceZdZdZdNdZdZdZdZdZdZ gd Z d Z dOd Z d Z dZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZd Z d!Z!dPd#Z"d$Z#d%Z$d&Z%e%Z&d'Z'd(Z(e(Z)d)Z*e*Z+d*Z,d+Z-d,Z. dQd.Z/d/Z0d0Z1d1Z2d2Z3dPd3Z4d4Z5d5Z6d6Z7d7Z8d8Z9d9Z:d:Z;d;Ze>xZ?Z@d>ZAd?ZBd@ZCdAZDdBZEeExZFZGdCZHdDZIdEZJdFZKdGZLdHZMdIZNeNZOeNZPdJZQdKZRdLZSeSZTdMZUd"S)R RecompilerrFcH||_||_||_t|_dSr)ffi module_nametarget_is_python VERSION_BASE_version)rrqrrrss rrzRecompiler.__init__s$& 0$ rc:t|j||_dSr)maxru)rvers r needs_versionzRecompiler.needs_versionsDM3// rc i|_|dt|jt}g|_|D]}|jr|j|Jt |j|j|<|j||jD]}t|tj tj tj tjtjfsJ|j|t |j|j|<|j||jd|D]t}|jsk|j|^t |j|j|<|j||jr!|j|jdud|jvsJi|_i|_|D]K}t|tjr d|j|<'t|tjr d|j|<Lt/t|jdD]\}}||j|<t/t|jdD]\}}||j|<|D]6}t1|d|jjz}|||j|7|jD]}t|t6sJt9|j|_dS)N collecttypekeyENDLENc|jSrrtps rz/Recompiler.collect_type_table..RWrc|jSrrrs rrz/Recompiler.collect_type_table..rr_emit_bytecode_) _typesdict _generatesortedstr cffi_typesis_raw_functionr0appendargs isinstancerVoidTypeBasePrimitiveType PointerTypeStructOrUnionOrEnumFunctionPtrType is_array_typelengthvalues_struct_unions_enums StructOrUnionEnumType enumerategetattr __class__r"CffiOptuple)r all_declsrtp1imethodr8s rcollect_type_tablezRecompiler.collect_type_tablesS }%%%4?444  . .B! .r*222&)$/&:&:#&&r***700C%cEN,1,C,1,=,1,E,1,A ,CDDDDD s+3/24?/C/C,O**3////&&u--- 2 2B% 2$/"*=*E&)$/&:&:#&&r***#2 (=O**51114?11333333!  ' 'B"e122 '*.#B''B// '"& Bvd&9*<*< > > >?? ( (EAr&'D  # #vdk*<*< > > >??  EArDKOO , ,BT#4r|7L#LMMF F2tr* + + + +/ * *Bb&)) ) )) )00rc<|j }||Sr)rs enumfields)rrexpand_anonymous_struct_unions r _enum_fieldszRecompiler._enum_fieldss#-1,A(A%}}:;;;rct|tjs1t|tr|D]}||dS||jvrd|j|<t|tjr)||dSt|tjrg|j Z||j j j vrI| |D]5\}}}}|||||2dSdSdS|D]\}}||dSdSr)rrBaseTypeByIdentityr_do_collect_typerras_raw_functionrfldtypesrq_parser_included_declarationsr _field_type _get_items)rrxname1r_s rrzRecompiler._do_collect_types"e677 "e$$ ---A))!,,,, F T_ $ $"&DOB "e344 -%%b&8&8&:&:;;;;;B 344 -;*$("2"III,0,=,=b,A,APP(sAq--d.>.>r5#.N.NOOOO+*IIPPMMOO--DAq))!,,,, % $--rc|jjj}t |D]\}\}}|dd\}} t |d|d|}n #t$rtd|zwxYw ||_ |||n#t$r} tj | |d} ~ wwxYwdS)Nr.r_generate_cpy_rz"not implemented in recompile(): %r) rqr _declarationsitemsrsplitrAttributeErrorr_current_quals Exceptionrattach_exception_info) r step_namelstrrqualskindrealnameres rrzRecompiler._generatesh,2244!'   D+2u!ZZQ//ND( A @I (KLL! A A A'84?AAA A &+#r8$$$$   +At444   s$A,,B  B!! C+CC)globalfield struct_unionenumtypenamecJi|_|jD] }g|j|< t|_|d||jD]C}|j|}|dkr|dt||j|<D|jd}|j D]2\}}|t|ksJ||j |j ksJ3t|t|jksJ|jd}|j D]2\}}|t|ksJ||j |j ksJ3t|t|j ksJdS)Nctxrc|jSrr)entrys rrz0Recompiler.collect_step_tables..s5:rr|rr) _lsts ALL_STEPSset_seen_struct_unionsr_add_missing_struct_unionssortrrrr0rr)rrrrrs rcollect_step_tableszRecompiler.collect_step_tabless  ' 'I$&DJy ! !#&55  u ''))) / /I*Y'CG##55666$)#JJDJy ! !j((..00 * *EBs3xx<<<<q6;"')))))3xx3t2333333j [&&(( * *EBs3xx<<<<q6;"')))))3xx3t{++++++++rr5c@|j|dzdS)N )_fwrite)rwhats r_prntzRecompiler._prnts   dTk"""""rc~|jr|J||dS|J|||dSr)rswrite_py_source_to_fwrite_c_source_to_f)rfpreambles rwrite_source_to_fzRecompiler.write_source_to_fs[   2###  % %a ( ( ( ( ('''  $ $Q 1 1 1 1 1rcttjtjt |d}|}||S)Nr)openospathrRdirname__file__ readlinesclose)rfilenamegliness r_rel_readlineszRecompiler._rel_readlines!sN bgooh77BBC H H    rc x||_|j}|jj |dts |d|d}|d}|d|||dz<|d||j dd }|jj|d |jd |d | |jj|d |d|d||d|d||d|d||d|d}|d}|d|||dz<|d|| t|d|||||d||dtd|jD}t!|jD]K\}}d} ||vrd||z} |d||| fzL|js |d|d|t)|_|di} |jD]v} |j| } t3| | | <| | d krI|d!| d"| d#| D]} ||  |d|w|jjr|d$|jjD]_} |jdd%\}}n)#t8$rt;d&|jd'|d(wxYw|t;d)|d*|d+`|d,|d||d-|d.|jD]+} | | d kr|d/| z|d0| z,|jD]} | d1kr|d2| | | fz|jjr |d3n |d4|d5t3|jfzd }|jd ks |jj|dz}|d6|z|d||d7|d8|d||d|d9|d:|d;|d<|dzr!|d=|d>|d?|d@|jz|dA|dB|dC|d|dD|dE|dF|dG|dH|dI|dJ|dK|dL|dM|dM|d|d9|dN|dO|d<|dP|j|jfz|dD|d|d9|dQ|dO|d<|dR|j|jfz|dD|d||d7|dS|dd|_dS)TNz#define _CFFI_USE_EMBEDDINGz#define _CFFI_NO_LIMITED_APIz_cffi_include.hz#include "parse_c_type.h" zparse_c_type.hrr5.z#define _CFFI_MODULE_NAME ""z1static const char _CFFI_PYTHON_STARTUP_CODE[] = {z0 };z#ifdef PYPY_VERSIONz3# define _CFFI_PYTHON_STARTUP_FUNC _cffi_pypyinit_z#elif PY_MAJOR_VERSION >= 3z+# define _CFFI_PYTHON_STARTUP_FUNC PyInit_#elsez(# define _CFFI_PYTHON_STARTUP_FUNC init#endifz _embedding.hz#include "_cffi_errors.h" z_cffi_errors.hz>/************************************************************/zstatic void *_cffi_types[] = {cg|] \}}||f Sr%r%rJrrs rrLz2Recompiler.write_c_source_to_f..W NNN7B2wNNNrz // z/* %2d */ %s,%sz 0z};declrzstatic const struct _cffi_z _s _cffi_zs[] = {z.static const char * const _cffi_includes[] = {r\ ffi object includes 8, but the latter has not been prepared with set_source()zMnot implemented yet: ffi.include() of a Python-based ffi inside a C-based ffiz "z",z NULLz?static const struct _cffi_type_context_s _cffi_type_context = {z _cffi_types,z _cffi_%ss,z NULL, /* no %ss */rz %d, /* num_%ss */z _cffi_includes,z NULL, /* no includes */z %d, /* num_types */z %d, /* flags */z#ifdef __GNUC__z?# pragma GCC visibility push(default) /* for -fvisibility= */PyMODINIT_FUNC_cffi_pypyinit_z(const void *p[]){z% if (((intptr_t)p[0]) >= 0x0A03) {zQ _cffi_call_python_org = (void(*)(struct _cffi_externpy_s *, char *))p[1];z }z p[0] = (const void *)0x%x;z p[1] = &_cffi_type_context;z#if PY_MAJOR_VERSION >= 3 return NULL;}z# ifdef _MSC_VERz PyMODINIT_FUNCz# if PY_MAJOR_VERSION >= 3z PyInit_z(void) { return NULL; }z# elsez initz (void) { }z# endifPyInit_(void)z5 return _cffi_init("%s", 0x%x, &_cffi_type_context);initz. _cffi_init("%s", 0x%x, &_cffi_type_context);z# pragma GCC visibility pop) rrrq _embeddingUSE_LIMITED_APIrindexrRrrr_print_string_literal_in_arrayryVERSION_EMBEDDEDdictrrrr _get_c_namerr_seen_constantsrrrr0_included_ffis_assigned_sourcerr _num_externpyru)rrrprntrrbase_module_nametypeindex2typer8rDnumsrrrffi_to_includeincluded_module_nameincluded_sourcerBs rrzRecompiler.write_c_source_to_f's z 8  * D. / / / 1 D/ 0 0 0##$566 KK5 6 6**+;<<a!e  RWWU^^ +11#66r: 8  * DDd6F6F6FH I I I DD E E E  / /0C D D D DLLL D& ' ' ' DD  # $ $ $ D. / / / DD  # $ $ $ DMMM DD  # $ $ $ DNNN''77E 9::A../?@@E!AaC%L D   / 0 0 0  MNNN  X   MNNN   -...NNdo6K6K6M6MNNNOOt// C CEArGN"" >!#4#@#@#B#BB D"a%AA B B B B  DKKK T   #uu v  I*Y'C!#hhDOI""IIyyy*+++ ,,ED**++++T  8 "  DA B B B"&("9 : :8&7;:(//%888++!HHHnnn78888 #*+3444"6"6"689999 DNNN DJJJ DFFF  NOOO   : :II""^i/0000,y89999 L LIG##+tI .JJKKK 8 " / D$ % % % % D- . . .  %T_)=)=(? ?@@@   ! !TX%8%D QJE  !E )*** T      NOOO X   "###   5E5E5E GHHH S 19  D8 9 9 9 DE F F F DMMM  - =>>>  .///  ()))      X S   !!!  "###  *+++ 8H8H8H JKKK Y (8(8(8 :;;; Z Z  *+++   "2"2"2 4555 S   D  dmH-- . . . S  W    /// 1222 S   =  dmA-- . . . S  X     +,,, X s 7O  &O0c8t|trd|dSt|ttfrOfd|D}t |dkr|ddd|dS|S) Nr6r7c:g|]}|Sr%)_to_py)rJitemrs rrLz%Recompiler._to_py..s%3334;;t$$333rrr5(rNrO)rrlistrr0rrRr )rrreps` rrzRecompiler._to_pys a   " "aa> ! a$ ' ' -3333333C3xx1}} 2 XXc]]]], ,!!!rc V||_|j}|d|dt|jjpd}t |D]r}|jj|} |jdd\}}n)#t$rtd|jd|dwxYw|td|d ||fzs||d |j d |d |j fzd|_ t|j |_ d |j D}|d| d|dtd|jD} |jD]M} |j| } t| dkr+| dkr%|d| d| | dN|dkr9|dddt |Dd|ddS)Nz# auto-generated filezimport _cffi_backendr%r\rrrzMnot implemented yet: ffi.include() of a C-based ffi inside a Python-based ffizfrom %s import ffi as _ffi%dzffi = _cffi_backend.FFI('rMz _version = 0x%x,c6g|]}|Sr%)r)rJr8s rrLz3Recompiler.write_py_source_to_f..s$DDDbR''))DDDrz _types = r5rNcg|] \}}||f Sr%r%rs rrLz3Recompiler.write_py_source_to_f..rrrrz _zs = z _includes = (rcg|]}d|zS)z_ffi%dr%rJrs rrLz3Recompiler.write_py_source_to_f.. sEEEA8a<EEErz,),rO)rrr0rqr ranger rrrrrurrrrRr rrrr) rrr num_includesrrrr types_lstrrrs rrzRecompiler.write_py_source_to_fsz  $%%%  #$$$4828b99 |$$ M MA!X4Q7N 4"3BQB76$oo! 4 4 4''...3444 4 *'4555 D/3G2KK L L L L  0@0@0@ BCCC  #t}&6 6777  00DDDODDD  4;;rwwy/A/A#B#B#B#B DEEENNdo6K6K6M6MNNNOO G GI*Y'C3xx!|| W 4 4DKK4D4D4D4DEFFF !   DD EE|1D1DEEEFFFFI J J J S s $A77&Bc|j|Sr)r)rtypes r _gettypenumzRecompiler._gettypenumst$$rc d}t|tjr|s|r|jdkr d}d|jz}nt|tjrd|dd}nT|d}d|d|jdd }|d vr| td }n t|tj r| ||||dSt|tj st|tjrH|d ||||fz|d |zdSt|tjr3d|dz}d||z}d}nt#||d|d|d||d|d|d|dd|d|d |zdS)Nr5_Bool_cffi_to_c_intz, %srz)_cffi_to_c_doublez )_cffi_to_c_r.rchar16_tchar32_tz-1z6 if (_cffi_to_c((char *)&%s, _cffi_type(%d), %s) < 0)z %s;z(%s)_cffi_to_c_pointerz, _cffi_type(%d)NULL z = );z if (z == (rOz && PyErr_Occurred()))rrris_complex_typeis_integer_typerUnknownFloatType get_c_namereplaceryVERSION_CHAR16CHAR32r"_convert_funcarg_to_c_ptr_or_arrayrrr'rr3) rrfromvartovarerrcodeextraarg convertercnameerrvalues r_convert_funcarg_to_cz Recompiler._convert_funcarg_to_cs b%1 2 2$ *2;M;M;O;O$ *!!## =7(:(:, !BG+B 677 = =8:}}R7H7H7H7HJ  b))3855357??33L3L3LN 444&&';<<<HH E- . . *  3 3B497 D D D FU677 *U455 * JJO 0 0 4 4g>? @ @ @ JJy7* + + + F E1 2 2 *02==3D3DDI)D,<,|dn|d?|d@||dA|dS)BNrnoargrarg0rargument of %sz x%dx%drvoidr.r5_cffi_d_rrOstatic rzreturn r/r0rz#ifndef PYPY_VERSIONzstatic PyObject *_cffi_f_z(PyObject *self, PyObject *z %s;;z result = result of %sz resultz PyObject *pyresult;z PyObject *arg%d;z1 if (!PyArg_UnpackTuple(args, "%s", %d, %d, %s))cg|]}d|zS)z&arg%dr%r!s rrLz:Recompiler._generate_cpy_function_decl..s555A8a<555rrzarg%dz return NULLz Py_BEGIN_ALLOW_THREADSz _cffi_restore_errno();cg|]}d|zS)rjr%r!s rrLz:Recompiler._generate_cpy_function_decl..sAAA%!)AAAr { z); }z _cffi_save_errno();z Py_END_ALLOW_THREADSz (void)self; /* unused */z (void)noarg; /* unused */z pyresult = %s;resultz result typez return pyresult;z Py_INCREF(Py_None);z return Py_None;rct|tjp-t|tjo|Sr)rrr PrimitiveTyper1)r&s rneed_indirectionz@Recompiler._generate_cpy_function_decl..need_indirections@tU%899-e&9::,))++ .rFrTz %sx%dz%sx%dz *resultz *result = z return result;z# define _cffi_f_z _cffi_d_r)rsrrrrd_generate_cpy_constant_declrr0rrrr4rRabirtrrrDrr"r?rNinsert void_type)rrrrnumargsargname argumentscall_argumentsrMrr&repr_argumentsryname_and_arguments result_codeargrBrCr result_declrngfreelinerw difference indirection tp_results r_generate_cpy_function_declz&Recompiler._generate_cpy_function_declsw(((("e344444 ;   , ,R 6 6 6 Fzbg,, a<<GG \\GGG "T) )) - -GAt   T__VaZAA B B B  ! !%!) , , , ,9--'16 6 &3,CCC3633nnnM BI001CDDD FGGG S >22 bi 0 0 K kk444 @AAA S   #$$$  !!! 444 IJJJ S "T) ))  GAt//&1*g66C D3    EE EE G D DD  ' 'i C C C C9%% $ $D DDDDD" # # # #")U^44 %K$t+G!BI$8$8G$L$LLK D    D( ) ) ) )KK rw<22 ++ttt^^^ DEEE  $%%%  %&&&   )*** a<< D. / / /  & D#**29h NNO P P P% & &TH_%%%% D% & & & &% & &TH_%%%% D( ) ) ) D$ % % % S  W  . . .  "T) )) > >GAtK%% "! ! //(k1-="=wGGC   S ! ! !  ! !'[!,<"< = = = =I  I & & $t+G&&z7;;C   Q $ $ $IK&KJ  C!YYy11N+5vN7:ssDDD7E~~"G  DD 4 45G H H HJ K K K DIII "[!!!!YY~66N DDkk444H I I I )'((( DIIII DDdddDDA B B B X rc |jr|js|||dS|j|}t |j}|jrt}n#|dkrt}n|dkrt}nt}|j d t|d|zt||d|zdS)Nrrrz _cffi_f_%sz _cffi_d_%s)r)rdrs_generate_cpy_constant_ctxrrr0rOP_DLOPEN_FUNCOP_CPYTHON_BLTN_NOP_CPYTHON_BLTN_OOP_CPYTHON_BLTN_Vrrr r)rrrrAr| meth_kinds r_generate_cpy_function_ctxz%Recompiler._generate_cpy_function_ctx;s ; t4   + +B 5 5 5 F_R%7%7%9%9: bg,,   *&II \\)II \\)II)I 8## t\D0i44(4/ 1 1 1 2 2 2 2 2rct|tjr_|j}|dkr|d}d|d|d}||d|z|j}tj||}|S)N...rz_cffi_array_len((()0)->rO%s[0])rrrIrr4rr)r tp_struct field_nametp_field actual_lengthptr_struct_nametp_items rrzRecompiler._field_typeQs h 0 0 ?$OM%%"+"6"6s";";#OOZZZ!1 &&y'J2F'/}66Gw >>Hrc|||jr,|D]}||dSdSr)rrsanonymous_struct_fields_struct_collecttype)rrfldtypes rrzRecompiler._struct_collecttype]sg b!!!   25577 2 2((1111 2 2 2 2rc $|jdS|j}d|}|d|d|d|d|d|d|d||D]\}}}} |s|d kr|d kr|d |d |d |d>t |t jrJ|j |jdkr8|j}|dz}t |t jr|j-|jdk8|d| dd|z| d|d#t$r%} |dt| zYd} ~ d} ~ wwxYw|d|d|d|d|dS)N_cffi_checkfld__CFFI_UNUSED_FNz static void rz *p)rz8 /* only to generate compile-time warnings or errors */z (void)p;rr5z (void)((p->z) | 0); /* check that 'rz' is an integer */rz[0]rsz*tmpzfield %rrz = &p->z; (void)tmp; }z /* %s */rzstruct _cffi_align_z { char x; z y; };) rrrr2rrrIrrr4rr) rrr=r]r checkfuncnamefnameftyper+fqualrs r _struct_declzRecompiler._struct_declds; ;  Fz/9z;     uuu =>>> S   GHHH \-1->->r-B-B , , )E5(E ,((**h!mm{{05uuueeeEFFF"%99*!L0ELE4I4I!JE!EME"%99*!L0ELE4I4I$$VZ-=U$KKKKEE% , , ,\CFF*++++++++ , S  :::uuu MNNN s15D7'BD77 E&E!!E&Nc|j|}d}g}t|tjr|d|j|dd}||jjjvr|||jjjvr|jn>|j s!t| rn|d|j r:|j dkrt|d|j d|dn|d d }d |pd }g}|t||} | D]\} } } } ||| | } || d |jd| dt(}| dkr t*}d| z}nK|!t| tjr | jd}n%d||dn|jd| d}|| dkrd}n-|d|jd| d}nd|dd| d}|t3| ||| t5||j| t7|jd}|jd||d}d}d}n'|d |jd!}d"}n d#|d}d$|d%}d}nd}d&}d&}|}|jd't=|j||||||||j |dS)(N _CFFI_F_UNION_CFFI_F_OPAQUEopaque_CFFI_F_CHECK_FIELDSrz is declared with 'pack=zi'; only 0 or 1 are supported in API mode (try to use "...;", which does not require a 'pack' declaration)_CFFI_F_PACKED_CFFI_F_EXTERNALexternal|0zfield 'rr7rz %d /* bits */z (size_t)-1z sizeof(((rrrOz ((char *)&((z ) - (char *)0z offsetof(r5rrz (size_t)-2unnamedz sizeof(*(z)0)z-1 /* unknown alignment */zsizeof(zoffsetof(struct _cffi_align_z, y)rr)!rrr UnionTyperrrqrrpartialanyrpackedr3rRrrr_check_not_opaquerr9r:rIrr4r'rr0rextendr?rrA)rrr=r]r^rAreason_for_not_expandingrBrFrfldnamerr+rr8roffsetrEalignrDs rr_zRecompiler._struct_ctxs_R( #'  b%/ * * * LL ) ) ) ;  LL) * * *'/ $ dh&= = ="$("2"III{" 5s2#=#=#?#?@@ 5 3444y /9q==-RYYY()))  -... LL+ , , ,'1 $&3 # +d//3344J5? E E1(E**2w@@&&ww:<'''777'KMMMq==$B*X5DD]"7EO<<#.'DD/8.? c***09??!D=HMM)FF**!1FF+46==3D3D3D3DgggNFgvtX$R)ABBDDEEEE!$DJw$7 8 8  Jw  & &x 0 0 0}##((/8~~~?D8EE),1552DDDNJJPEDE " .G >")) BGZeW-x 9 9 : : :  $$R(((((rct|tjr!|j}t|tj!t|tjr|jt d|zdSdS)Nz0%s is of an opaque type (not declared in cdef()))rrrIrrrrK)rrlocations rrzRecompiler._check_not_opaquesU_-- BU_--  b%- . . O2;3FBXMOO O O O3F3Frct|j}|d|D]\}}||jvr|jrt d|d|jdr1|jdd r|jdd}nA|jdkr$|j dkrd}| |dnt d|| |d|dS) Nc|dS)Nrr%)tp_orders rrz7Recompiler._add_missing_struct_unions..s hqkrr|zinternal inconsistency: z* is partial but was not seen at this point$r_IO_FILEFILE) rrrrrrr3r startswithisdigit forcenamerYr_)rrrorderr]s rrz%Recompiler._add_missing_struct_unionssJ 4&,,..// 11222 7 7IB111:D-->@bb/CDDD7%%c**5rwqrr{/B/B/D/D5!#JJW **r|v/E/E!'J%%b&1111--/1r/4555  T:666 7 7rc0||dSr)rrQs r _generate_cpy_struct_collecttypez+Recompiler._generate_cpy_struct_collecttypes   $$$$$rcr|d}d|vr||ddfS|d|zfS)Nr5r.r)r4r5)rrr=s r _struct_nameszRecompiler._struct_namessD b!! %<<%--S111 1#+% %rcH|j|g||RdSr)rrrQs r_generate_cpy_struct_declz$Recompiler._generate_cpy_struct_decls1"6t11"55666666rcH|j|g||RdSr)r_rrQs r_generate_cpy_struct_ctxz#Recompiler._generate_cpy_struct_ctx s15d0044555555rct|tjr|||dS||dSr)rrr_generate_cpy_enum_collecttyperrQs r#_generate_cpy_anonymous_collecttypez.Recompiler._generate_cpy_anonymous_collecttypesL b%. ) ) )  / /D 9 9 9 9 9  $ $R ( ( ( ( (rct|tjr||dS|||d|zdSNtypedef_)rrr_generate_cpy_enum_declrrQs r_generate_cpy_anonymous_declz'Recompiler._generate_cpy_anonymous_declsS b%. ) ) ;  ( ( , , , , ,   b$ T(9 : : : : :rct|tjr|||dS|||d|zdSr)rrr _enum_ctxr_rQs r_generate_cpy_anonymous_ctxz&Recompiler._generate_cpy_anonymous_ctxsS b%. ) ) : NN2t $ $ $ $ $   RzD'8 9 9 9 9 9rconstcB||f|jvrtd|d|d|j||f|j}d|d|}|ry|d|z|d|d|d |d |d |d |&|d krd|fz}|d|d|d|d|dnM|J|d|z|d|d|dd|d|d|dS)Nzduplicate declaration of z 'r7_cffi_rz$static int %s(unsigned long long *o)rz int n = (z) <= 0;z *o = (unsigned long long)((z) | 0); /* check that z is an integer */rz%dUz if (!_cffi_check_int(*o, n, z))z n |= 2;z return n;rzstatic void %s(char *o)z *(rz)o = ro)r rrArr4)ris_intrrcategoryrrfuncnames r_generate_cpy_constzRecompiler._generate_cpy_const&s d t3 3 3##6>hhEGG G   (D!1222z$,HHdd3   D7(B C C C DIII DD4441 2 2 2 DD:>$$F G G G&??"';."8K[[[JKKK]### D    DIIII&&& D*X5 6 6 6 DIII DDR]]3%7%7%7%7> ? ? ? DIII rcn|}|r|jr||dSdSr)r2rsrrrrrs r"_generate_cpy_constant_collecttypez-Recompiler._generate_cpy_constant_collecttypeDsI##%% &. &  ! !" % % % % % & &rc\|}||||dSr)r2rrs rrxz&Recompiler._generate_cpy_constant_declIs1##%%   r22222rc2|js*|rttd}n3|jrt}nt }|j|}t||}|jdt|d|z|dS)Nrr_cffi_const_%s) rsr2rOP_CONSTANT_INTOP_DLOPEN_CONST OP_CONSTANTrrrr )rrrr const_kindrAs rrz%Recompiler._generate_cpy_constant_ctxMs$ 5););)=)= 5_b11GG$ ), ( ,JZ44G 8## t-4g > > @ @ @ @ @rc0||dSr)rrQs rrz)Recompiler._generate_cpy_enum_collecttype]s b!!!!!rcF|jD]}|d|dS)NT) enumeratorsr)rrr enumerators rrz"Recompiler._generate_cpy_enum_decl`s6. 7 7J  $ $T: 6 6 6 6 7 7rc |j|}ttd}|jr|t |j|jD]9\}}|jd t|d|z||:|d|vr|js d|z}d|z}nn| |j g} |j | }tt|j | ddk}d |j} |jd  t#|j|||| dS) Nrrrrrz sizeof(%s)z ((%s)-1) <= 0rrNr)rrOP_ENUMrscheck_not_partialzipr enumvaluesrrr build_baseinttyperqsizeofintcastrRrUr) rrr=rArr enumvaluerrXbasetprYs rrzRecompiler._enum_ctxds{_R( "%%   #  " " "%(%G%G 3 3 !J Jx ' ':'7*'Dg'0222 3 3 3 3  E!1!1$:O!1%'D$u,FF))$(B77F8??6**DTX]]626677!;<>++,,,,,rcdSrr%rQs r_generate_cpy_macro_collecttypez*Recompiler._generate_cpy_macro_collecttyperWrcL|dkrd}n|}|d||dS)NrTr)r)rrrrs r_generate_cpy_macro_declz#Recompiler._generate_cpy_macro_decls8 ;;KKK   t EEEEErc|dkr|jrtd|dd}n|}ttd}|jdt |d|z||dS)Nrz(cannot use the syntax '...' in '#define z ...' when using the ABI moderrrr)rsrrrrrr )rrrrrs r_generate_cpy_macro_ctxz"Recompiler._generate_cpy_macro_ctxs ;;$ 4'',0DD3444KKK"-- 8## t-4g#. 0 0 0 1 1 1 1 1rct|tjrF|j}|dkrd|d}||jd|z}tj||}|S)Nrz_cffi_array_len(rOr)rrrIrrPr)rr global_namerrs rrPzRecompiler._global_typesi b%/ * * 9IM%%%9D F '';1FGGG-88B rcX||||dSr)rrPrQs r"_generate_cpy_variable_collecttypez-Recompiler._generate_cpy_variable_collecttypes, d//D99:::::rcZ|j}|||}t|tjr|j |j}d}nd}d|d}|d|||jz|d|d|d |d |d |dS) Nr5&z *_cffi_var_rrmrrz return rr0r) rrPrrrIrrr4r)rrrr ampersandrs r_generate_cpy_variable_declz&Recompiler._generate_cpy_variable_declsz   r4 ( ( b%/ * * ry/@BIII)-. Yt43FGG GHHH S  999ddd 3444 S  rc |||}|j|}|jrt}nt}|jdt|d|zt||dS)Nrz _cffi_var_%s) rPrrs OP_GLOBAL_VAROP_GLOBAL_VAR_Frrr r)rrrrAr8s r_generate_cpy_variable_ctxz%Recompiler._generate_cpy_variable_ctxs   r4 ( (_R(   !BB B 8## t^d2F2z4J4J K K M M M M Mrcht|tjsJ||dSr)rrrrrQs r'_generate_cpy_extern_python_collecttypez2Recompiler._generate_cpy_extern_python_collecttypes5"e344444 b!!!!!rc |j}t|jtjrd}n$d|z}d|jd|d}|d|z|d|jd|d |d |g}d |z}t|jD]3\}} | d |z|} | | 4d |} | pd} |d| d} |j dkrd| z} d} tt|jdzd}| |jrt|d}t|jtjr9d|jd||jd|fz}|||j| |d|d|z|dt|jD]o\}} d|z} t| tjs | | rd| z} tj| } |d| d|dz| fzp|d|zt|jtjs'|d|jdd|d ||xjd!z c_dS)"Nrrpz (int)sizeof(r5rOz3static struct _cffi_externpy_s _cffi_externpy__%s =rrr/z , 0, 0 };riz a%drrkr __stdcallz_cffi_stdcall cLt|tjo |jdkS)NrG)rrrvrrs rmay_need_128_bitsz9Recompiler._extern_python_decl..may_need_128_bitss&r5#677-G}, .rr^z!sizeof(%s) > %d ? sizeof(%s) : %drz char a[%s];z char *p = a;za%dr z *(%s)(p + %d) = %s;rz, _cffi_call_python(&_cffi_externpy__%s, p);z return *(z)p;rr)rrrtrrr4rrrrrrRryrwr0rrr)rrr tag_and_spacersize_of_resultrMr~rr&rrrr size_of_as r_extern_python_declzRecompiler._extern_python_declslz bi 0 0 4 NN$t+GG $$R11114N  BT IJJJ     dddNNN4 5 5 5  "T) )) " "GAt//&1*g66C   S ! ! ! !9--'16)-~~~> 6[ !14F!F  . . .BG Q**  RY ' ' +Ir**I bi!4 5 5 5; $$R(() $$R(()?55I }}bi&:&:;M&N&N&N OPPP S  _y ()))   )) M MGAt!)C4!455 /%%d++ /Ci(.. D(DOOC,@,@!A#s+KK L L L L  ;d BCCC")U^44 D DDry';';C'@'@'@'@B C C C S   arc4|||ddS)NrmrrQs r _generate_cpy_extern_python_declz+Recompiler._generate_cpy_extern_python_decls    T955555rc4|||ddS)NzCFFI_DLLEXPORT r rQs r#_generate_cpy_dllexport_python_declz.Recompiler._generate_cpy_dllexport_python_decl s!   T+<=====rc4|||ddS)Nr5r rQs r'_generate_cpy_extern_python_plus_c_declz2Recompiler._generate_cpy_extern_python_plus_c_decl s    T2.....rc|jrtd|jrtd|j|}t t |}|jdt|d|z||dS)Nz,cannot use 'extern "Python"' in the ABI modez$a vararg function is extern "Python"rz&_cffi_externpy__%s) rsrrdr3rrOP_EXTERN_PYTHONrrr )rrrrArs r_generate_cpy_extern_python_ctxz*Recompiler._generate_cpy_extern_python_ctxs   B#@BB B ; P%&NOO O_R( ):66 8## t2T97D I I K K K K Krcr|j}|dt|ts|d}n|d |dn#t $rd|z}YnwxYw|dD]}|}tdturtt|}nt|dd}|d |z d }|D]+}t|d kr ||d }|d |fzz },||dS) Nz=// # NB. this is not a string because of a size limit in MSVCzutf-8asciis# -*- encoding: utf8 -*- Tz//rrz// r5Lz%d,) rrbytesencodedecodeUnicodeDecodeError splitlinesr&mapordr*rstripr0)rsrlinerD printed_linecs rrz)Recompiler._print_string_literal_in_arraysuz  LMMM!U## !!AA HHW    2 HHW    ! 2 2 2-1AAA 2LL&&  DGDzzU""3~~ ..2. D%'/))++ , , ,L - -|$$**D&&&#%L , D      sA**A<;A<cJttt|j|<dSr)r OP_PRIMITIVE PRIM_VOIDrrrrs r_emit_bytecode_VoidTypez"Recompiler._emit_bytecode_VoidType=s!' i!@!@rcdt|j}tt||j|<dSr)PRIMITIVE_TO_INDEXrrr9r)rrrrgs r_emit_bytecode_PrimitiveTypez'Recompiler._emit_bytecode_PrimitiveType@s*'0 !' j!A!Arcvd|jd|jd|jd}tt||j|<dS)Nz_cffi_prim_int(sizeof(z), ( ((z)-1) | 0 /* check that z' is an integer type */ ) <= 0)rrr9rrrrr4s r!_emit_bytecode_UnknownIntegerTypez,Recompiler._emit_bytecode_UnknownIntegerTypeDsD$&777BGGGRWWW>"( a!8!8rcfd|jd|jd}tt||j|<dS)Nz_cffi_prim_float(sizeof(z) * (((z6)1) / 2) * 2 /* integer => 0, float => 1 */ )rArBs r_emit_bytecode_UnknownFloatTypez*Recompiler._emit_bytecode_UnknownFloatTypeJs< WWWbggg/"( a!8!8rc tt|j|j|j|<|dz }|jD]h}|j|}||krNt |tjr| ||ntt||j|<|dz }it|j }|j (|j dkr|dz}ntd|j tt||j|<dS)Nrrr\zabi=)r OP_FUNCTIONrrtrrrrrvr?r9rrdryr3OP_FUNCTION_END)rrrr realindexrBs r_emit_bytecode_RawFunctionTypez)Recompiler._emit_bytecode_RawFunctionTypePs!' T_RY5O!P!P  7  C,I !!c5#677H55c5AAAA-3GY-G-GDOE* QJEEBK   6 v$$ ))bff*>???!'!?!?rc`tt|j|j|j|<dSr)r OP_POINTERrrarr;s r_emit_bytecode_PointerTypez%Recompiler._emit_bytecode_PointerTypecs'!' DOBI4N!O!Orc~|}tt|j||j|<dSr)rrrLrr)rrrraws r_emit_bytecode_FunctionPtrTypez)Recompiler._emit_bytecode_FunctionPtrTypeis6  ""!' DOC4H!I!Irc|j|j}|jtt||j|<dS|jdkr4t dt|ddd|j|dzdksJtt||j|<tdt|j|j|dz<dS)Nrztype z/*...*/zb badly placed: the '...' array length can only be used on global arrays or on fields of structuresrr) rrrr OP_OPEN_ARRAYrrrr5OP_ARRAY)rrr item_indexs r_emit_bytecode_ArrayTypez#Recompiler._emit_bytecode_ArrayTypems_RW- 9 %+M:%F%FDOE " " " Y%  ##GGOOIu5555899 9 ?519-6666%+Hj%A%ADOE ")/c")nn)E)EDOEAI & & &rcZ|j|}tt||j|<dSr)rrOP_STRUCT_UNIONr)rrr struct_indexs r_emit_bytecode_StructTypez$Recompiler._emit_bytecode_StructType{s+*2. !'!F!FrcZ|j|}tt||j|<dSr)rrrr)rrr enum_indexs r_emit_bytecode_EnumTypez"Recompiler._emit_bytecode_EnumTypes)[_ !'!####222 kkkZ"""000h%%%+(+(+(ZKKK   ***F===<<<   FFF+++&&& ```D222,   222   DT)T)T)T)lOOO777.%%%&F#&&&77786666 ))) ;;; :::CJ(,<&&& 333 @ @ @ """7777CCC*---    FFF 1 1 1";;;.MMM""" ...44 4 4 l666>>>/// K K K&&&,<AAABBB999 999 @@@&PPP'A#&@#JJJ F F FGGG 9=====rro)r ceZdZfdZxZS)NativeIOct|tr|d}tt||dS)Nr*)runicoder-superrir)rr4rs rrzNativeIO.writesJ!W%% &HHW%% (D ! ! ' ' * * * * *r)r"r#r$r __classcell__)rs@rriris8 + + + + + + + + +rricX|rtd|t|||du}||t }||||} t|d5}|t|dz|krt dddn #1swxYwY|rtddS#t$rd|tj fz} t| d5}| |dddn #1swxYwY tj| |n9#t$r,tj|tj| |YnwxYwYd SwxYw) Nz generating )rsrrz(already up-to-date)Fz%s.~%dwT)printrorrrirgetvaluerreadr0IOErrorrgetpidrrenameOSErrorunlink) rqrrr target_fileverbose recompilerroutputf1tmp_files r_make_c_or_py_sourcer~sL0 .///C.6$.>AAAJ!!###""$$$ A  H--- ZZ\\F +s # # rwws6{{Q''611 2                 * ( ) ) )u    {BIKK88 (C  B HHV                   - Ih , , , , - - - Ik " " " Ih , , , , , -tt s~ C61C C6CC6C C662F)(E > F) E F)E F)E,+F),3F"F)!F""F)(F)Fc0|Jt|||||Srr~)rqrrr target_c_filerys r make_c_sourcers+     [(M ' ) ))rc(t||d||Srr)rqrrtarget_py_filerys rmake_py_sourcers [$ ' ) ))rc|d} tjtjj|g|ddRn#t $rYnwxYw|dxx|z cc<tjj|g|R|fS)Nrr)rrmakedirsrrRrv) outputdirmodname extensionpartss r_modname_to_filers MM#  E  BGL8U3B3Z8889999       "IIIIII 7< *E * * *E 11s1A AAcxt||}||||ft||||Sr)rrsetattr) patchlistclsrnew_metholds r _patch_methrsC #t  C c4%&&& Cx   JrcTt|D]\}}}t|||dSr)reversedr)rrrold_meths r_unpatch_methsrs?' 22%%T8T8$$$$%%rctjdkrddlm}t ||ddtjdkrddlm}fd}t ||d |dSdS) Nrr) MSVCCompiler_remove_visual_c_refc|Srr%)r manifest_files rrz&_patch_for_embedding..s rdarwin) CCompilercd|jvr=t|j|_|jd}d|j|<|g|Ri|S)Nz-bundlez -dynamiclib) linker_sorr)rrkwdsrold_link_shared_objects rmy_link_shared_objectz3_patch_for_embedding..my_link_shared_objectscDN**!%dn!5!5N((33$1q!))$>>>>>> >rlink_shared_object)sysplatformdistutils.msvc9compilerrrdistutils.ccompilerr)rrrrrs @r_patch_for_embeddingrs |w888888I|-C== ? ? ? |x111111 ? ? ? ? ? "-Y -A-B"D"D rcddlm}dr;ddtjdkrdz ntjdkrdz nd z t ||d fd dS) Nr) build_extz.*rrz.dllrz.dylibz.soget_ext_filenamecSrr%)rext_nametargets rrz#_patch_for_target..svr)distutils.command.build_extrendswithrrr)rrrs ` r_patch_for_targetrs555555t <7 " " f FF \X % % h FF eOF 9&8----/////rrT.cc  t|ts|d}|jr|| ||jdu} | r|| |0t|||\}} |r|g| z} tj j | }n|}| | rd|z} nd} tj ||fi| }t|||||}|rg}tj} | rt|| dkrt!|| |r<|dkrd}nd}t#|dtj |tj|tjd||| }tj|t+|n(#tj|t+|wxYw|S||fS|t||d \}}t-||||}|r|Sd|fS) Nr*z%s.*r)ryrzthe current directory isz setting the current directory tor.z.py)rrr-_windows_unicode_apply_windows_unicoder_apply_embedding_fixrrrrRr get_extensionrgetcwdrrrpabspathchdircompilerr)rqrrrtmpdircall_c_compilerc_filesource_extensionextradircompiler_verboserdebugr embeddingr ext_c_fileextupdatedrcwdmsgoutputfilenamers r recompilersv k3 ' '2!((11  ) ""4(((^4/  +  $ $T * * * >,V[-=??MFE +! U*u-JJJ > +-' KHH4HH[(F(8:::  I)++C *4(333S==%i888#D}}8@SSS"'//&*A*A*ABCCC   !,!4S#5Eu"N"N y)))) y))))! !<  >(eDDIFA k6)9;;;  !M= s )BF%Gr])rTNrNrNN)!rrior5rrerrorr cffi_opcodertrr6r version_inforr r'r?rUriroStringIOriBytesIOr~rrrrrrrrr%rrrs $$$$$$ <7*.c.>.G.#v-11111111 ))))))))8########:????????0 K K K K K K K KD=D=D=D=D=D=D=D=N(t{HH+++++2:+++ 8)))) ))))222 %%%DDD(///"GK;?59<!<!<!<!<!<!r