_e[c@sddlZddlZddlmZddlmZmZmZdZdZ dZ dZ de fd YZ d e fd YZd efd YZeZdefdYZdefdYZdefdYZdefdYZdefdYZdefdYZdefdYZdefdYZeeZdZeeZdefd YZd!efd"YZeed#dZd$e fd%YZ d&e fd'YZ!d(e!fd)YZ"d*e!fd+YZ#d,e fd-YZ$dd.Z%dd/Z&eZ'ej(Z)d0Z*d1Z+d2Z,d3Z-dS(4iNi(t allocate_lock(t CDefErrortVerificationErrortVerificationMissingiicCs[|t@rd|j}n|t@r:d|j}n|t@rWd|j}n|S(Ns const s volatile s __restrict (tQ_CONSTtlstript Q_VOLATILEt Q_RESTRICT(tqualst replace_with((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pytqualify s   tBaseTypeByIdentitycBs_eZeZeZddddZdZdZdZedZ dZ d Z RS( tsa C fileicCs|j}|jddks$t|j}|r~|jdr^d|kr^d|}q~|ddkr~d|}q~nt||}|jd|}d |krtd |j|fn|S( Nt&it*s&[s(%s)is[(t t$s-cannot generate '%s' in %s: unknown type name( tc_name_with_markertcounttAssertionErrortstript startswithR treplaceRt _get_c_name(tselfR tcontextRtresult((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyt get_c_names    cCs|jjddS(NR R (RR(R((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyR/scCsd|jkS(NR(R(R((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyt has_c_name2scCstS(N(tFalse(R((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pytis_integer_type5scCsby|j|}WnJtk r]|j||}|jj||}||ks^tnX|S(N(t_cached_btypestKeyErrortbuild_backend_typet setdefaultR(Rtffit finishlistt can_delaytBTypetBType2((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pytget_cached_btype8s cCsd|jfS(Ns<%s>(R(R((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyt__repr__AscCs)g|jD]}|t||f^q S(N(t_attrs_tgetattr(Rtname((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyt _get_itemsDs( t__name__t __module__Rt is_array_typetis_raw_functionRRRRR(R)R-(((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyR s    tBaseTypecBs#eZdZdZdZRS(cCs(|j|jko'|j|jkS(N(t __class__R-(Rtother((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyt__eq__JscCs ||k S(N((RR4((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyt__ne__NscCst|jt|jfS(N(thashR3ttupleR-(R((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyt__hash__Qs(R.R/R5R6R9(((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyR2Hs  tVoidTypecBs eZdZdZdZRS(cCs d|_dS(Nsvoid&(R(R((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyt__init__XscCst||dS(Nt new_void_type(t global_cache(RR#R$((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyR![s((R.R/R*R;R!(((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyR:Us tBasePrimitiveTypecBseZdZRS(cCstS(N(R(R((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pytis_complex_typebs(R.R/R?(((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyR>ast PrimitiveTypecBseZd>Zi3dd6dd6dd6dd6dd6dd6dd 6dd 6dd 6dd 6dd 6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd 6dd!6dd"6dd#6dd$6dd%6dd&6dd'6dd(6dd)6dd*6dd+6dd,6dd-6dd.6dd/6dd06dd16dd26dd36dd46dd56dd66dd76Zd8Zd9Zd:Zd;Zd<Zd=Z RS(?R,tctchartitshorttinttlongs long longs signed chars unsigned charsunsigned shorts unsigned ints unsigned longsunsigned long longtftfloattdoubles long doubletjsfloat _Complexsdouble _Complext_Booltwchar_ttchar16_ttchar32_ttint8_ttuint8_ttint16_ttuint16_ttint32_ttuint32_ttint64_ttuint64_tt int_least8_tt uint_least8_tt int_least16_ttuint_least16_tt int_least32_ttuint_least32_tt int_least64_ttuint_least64_tt int_fast8_tt uint_fast8_tt int_fast16_tt uint_fast16_tt int_fast32_tt uint_fast32_tt int_fast64_tt uint_fast64_ttintptr_tt uintptr_ttintmax_tt uintmax_tt ptrdiff_ttsize_ttssize_tcCs/||jkst||_|d|_dS(NR (tALL_PRIMITIVE_TYPESRR,R(RR,((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyR;s cCs|j|jdkS(NRA(RnR,(R((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyt is_char_typescCs|j|jdkS(NRC(RnR,(R((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyRscCs|j|jdkS(NRG(RnR,(R((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyt is_float_typescCs|j|jdkS(NRJ(RnR,(R((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyR?scCst||d|jS(Ntnew_primitive_type(R=R,(RR#R$((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyR!s(sname( R.R/R*RnR;RoRRpR?R!(((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyR@fsv      tUnknownIntegerTypecBs)eZdZdZdZdZRS(R,cCs||_|d|_dS(NR (R,R(RR,((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyR;s cCstS(N(tTrue(R((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyRscCstd|jdS(Ns4integer type '%s' can only be used after compilation(tNotImplementedErrorR,(RR#R$((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyR!s(sname(R.R/R*R;RR!(((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyRrs  tUnknownFloatTypecBs eZdZdZdZRS(R,cCs||_|d|_dS(NR (R,R(RR,((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyR;s cCstd|jdS(Ns2float type '%s' can only be used after compilation(RtR,(RR#R$((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyR!s(sname(R.R/R*R;R!(((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyRus tBaseFunctionTypecBseZdZddZRS(targsRtellipsistabicCs||_||_||_||_g|jD]}|j^q.}|jr_|jdn|pkdg}|jdj|f}|dk r|d |d|d}n|jj j d||_ dS(Ns...tvoids, iRR ( RwRRxRyRtappendt _base_patterntjointNoneRR(RRwRRxRytargtreprargsR ((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyR;s    "  (sargssresultsellipsissabiN(R.R/R*R~R;(((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyRvstRawFunctionTypecBs&eZdZeZdZdZRS(s(&)(%s)cCstd|fdS(NsPcannot render the type %r: it is a function type, not a pointer-to-function type(R(RR#R$((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyR!scCst|j|j|j|jS(N(tFunctionPtrTypeRwRRxRy(R((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pytas_function_pointers(R.R/R|RsR1R!R(((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyRs RcBs eZdZdZdZRS(s(*&)(%s)cCs|jj||}g}x*|jD]}|j|j||q%Wd}|jdkr|jsy|jjf}Wqtk rqXqnt ||dt |||j|S(Nt __stdcalltnew_function_type(( RR(RwR{RyRxt_backendt FFI_STDCALLtAttributeErrorR=R8(RR#R$RRwttptabi_args((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyR!s    cCst|j|j|j|jS(N(RRwRRxRy(R((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pytas_raw_functions(R.R/R|R!R(((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyRs t PointerTypecBs#eZdZddZdZRS(ttotypeRicCs\||_||_t|d}|jr@d|jf}n|jjd||_dS(Ns *&s(%s)R (RRR R0RRR(RRRtextra((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyR;s    cCs.|jj||dt}t||d|S(NR%tnew_pointer_type(RR(RsR=(RR#R$tBItem((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyR!s(stotypesquals(R.R/R*R;R!(((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyRs cCs t|tS(N(RR(R((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pytConstPointerTypestNamedPointerTypecBseZdZddZRS(RR,icCs-tj|||||_|d|_dS(NR (RR;R,R(RRR,R((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyR;s (stotypesname(R.R/R*R;(((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyRst ArrayTypecBs/eZdZeZdZdZdZRS(titemtlengthcCse||_||_|dkr'd}n|dkr<d}n d|}|jjjd||_dS(Ns&[]s...s &[/*...*/]s&[%s]R (RRR~RR(RRRtbrackets((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyR;)s       cCst|j|S(N(RR(Rt newlength((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pytresolve_length6scCsl|jdkr%td|fn|jj||t|jj||}t||d||jS(Ns...s)cannot render the type %r: unknown lengthtnew_array_type(RRRR(RR=(RR#R$tBPtrItem((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyR!9s (sitemslength(R.R/R*RsR0R;RR!(((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyR%s  RBtStructOrUnionOrEnumcBs/eZdZdZdZdZdZRS(R,cCs0|jpd|j|jf}|d|_dS(Ns%s %sR (t forcenametkindR,R(RR,((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pytbuild_c_name_with_markerHscCs||_|jdS(N(RR(RR((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pytforce_the_nameLs cCs#|jjdst|jd S(NR i(RtendswithR(R((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pytget_official_namePs(snameN(R.R/R*R~RRRR(((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyRDs   t StructOrUnioncBszeZd ZdZeZeZd dZdZ e dZ dZ edZ dZdZdZd ZRS( icCs;||_||_||_||_||_|jdS(N(R,tfldnamestfldtypest fldbitsizetfldqualsR(RR,RRRR((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyR;[s      ccs_|jdk r[xIt|j|jD]/\}}|dkr%t|tr%|Vq%q%WndS(NR (RR~tzipRt isinstanceR(RR,ttype((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pytanonymous_struct_fieldscs"ccs|j}|dkr+dt|j}nxt|j|j|j|D]c\}}}}|dkrt|tr|rx-|j D] }|VqWqJ||||fVqJWdS(NiR (i( RR~tlenRRRRRRt enumfields(Rtexpand_anonymous_struct_unionRR,RtbitsizeRR((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyRis   c Csg}g}g}g}xT|jD]F\}}}}|j||j||j||j|q%Wt||_t||_t||_t||_dS(N(RR{R8RRRR( RtnamesttypestbitsizesRR,RRR((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyt force_flattenws   cCs5tj||||}|s1|j||n|S(N(RR(tfinish_backend_type(RR#R$R%R&((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyR(s  cCs|jr5|jdkr1td|jfndS|j|}d|_|jdkr]nz|jdkrg|jD]}|j||^qv}tt |j ||j }d}|j rd}n|j j|||dd|ng}|j\}} } } xtt|j D]y} | | } |j| }t|tr|jdkr|jj||}t| |j|\}}|dkr|jd|j|j | pd fn|j|}|j| |f|j| d|_n|j||}t|tr>|jdkr>| dkstnK|j|}|| kr|jd |j|j | pxd || fn|j|qWtt |j ||j |}|j j|||| | d|_dS( Nis(recursive structure declaration for '%s'iiiis...sfield '%s.%s' has a bogus size?s{}s=field '%s.%s' is declared as %d bytes, but is really %d bytes(t completedRtR,RRR~t fixedlayoutR(tlistRRRtpackedRtcomplete_struct_or_uniontrangeRRRRRtdivmodtsizeoft_verification_errorRRR{(RR#R$R&RRtlsttsflagstfieldofst fieldsizet totalsizettotalalignmentRCtfsizetftypet BItemTypetnlentnrestt BFieldTypet bitemsize((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyRs`   %     ! ! cCst|dS(N(R(Rtmsg((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyRscCs1|jr-|jdkr-t|jndS(N(tpartialRR~RR(R((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pytcheck_not_partialscCs=|j|j|t||d|j|jd|S(Ns new_%s_typetkey(RR{R=RR(RR#R$((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyR!s  N(R.R/R~RRRRRR;RRsRRR(RRRR!(((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyRUs      <  t StructTypecBseZdZRS(tstruct(R.R/R(((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyRst UnionTypecBseZdZRS(tunion(R.R/R(((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyRstEnumTypecBsJeZdZeZeZddZdZdZ dZ dZ RS(tenumcCs2||_||_||_||_|jdS(N(R,t enumeratorst enumvaluest baseinttypeR(RR,RRR((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyR;s     cCsKtj|||jdkrG|j}d|jdd|_ndS(NRRt_(RRRR~RR(RRR,((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyRs cCs,|jr(|j r(t|jndS(N(Rtpartial_resolvedRR(R((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyRsc CsJ|j|j||}t||d|j|j|j|d|S(Nt new_enum_typeR(Rtbuild_baseinttypeR=RRR(RR#R$t base_btype((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyR!s     c Cs|jdk r"|jj||S|jrLt|j}t|j}nOddl}ytjWnt k rynX|j d|j d}}|dkrd}t d}t d}nd}t d}t d}|j||} |j||} |j | } |j | } |dd | d>kr\|dd | |>kr\| S|dd | d>kr|dd | |>kr| Std |j dS( NisU%r has no values explicitly defined; guessing that it is equivalent to 'unsigned int'iiRERFs unsigned ints unsigned longis=%s values don't all fit into either 'long' or 'unsigned long'(RR~R(Rtmintmaxtwarningst__warningregistry__tcleart NameErrortwarnRR@RR( RR#R$tsmallest_valuet largest_valueRtsignt candidate1t candidate2tbtype1tbtype2tsize1tsize2((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyRs@         N( R.R/RRRRR~R;RRR!R(((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyRs    cCsH|dkrd|}nt|ddd}|j|d|_|S(Ns$%st unknown_type(R~RRtorigin(R,t structnameR((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyR*s     cCs;|dkrd|}nt|ddd}t||S(Ns$$%s(R~RR(R,RR((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pytunknown_ptr_type2s  cCsat|tjrtSt?tt|dsJtjt|_ nt|j SWdQXdS(Nt __typecache( RRt ModuleTypet_typecache_cffi_backendt global_lockthasattrRtweakreftWeakValueDictionaryR(tbackend((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyt get_typecache<s c Os|jd||f}| s%ty|j|SWntk rGnXyt|j||}Wn,tk r}td|||fnX|j}t2|j|} | dkr|||<|S| SWdQXdS(NRs %s: %r: %s( tpopRt _typecacheR R+RRtRtgetR~( tsrctypeR#tfuncnameRwtkwdsRtrestetcachetres1((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyR=Gs"     cCstd|d|S(Nt?R(R=(R#R&((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pyt pointer_cache^scCsQ|jrMt|jdtkrMd||jdff|jd|_ndS(Nis%s: %si(RwRtstr(RR,((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pytattach_exception_infoas"(.RRtlockRterrorRRRRRRR tobjectR R2R:t void_typeR>R@RrRuRvRRRt voidp_typeRtconst_voidp_typeRRR~tchar_array_typeRRRRRRRRRRRR=RR(((s*/tmp/pip-install-KP2Jbq/cffi/cffi/model.pytsL   /  L     G