_e[c@sdddlZddlZddlZddlmZddlmZdefdYZdZ dS(iNi(tmodel(tVerificationErrortVGenericEnginecBseZdZeZdZdZdZdZddZ dZ dd Z d Z d Z d Zd ZdZeZeZeZdZeZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#d.dd.dZ%d Z&eZ'd.d!Z(d"Z)d#Z*d$Z+d%Z,d&d'Z-d&d(Z.d)Z/d*Z0eZ1d+Z2d,Z3eZ4d-Z5RS(/tgcCs+||_|j|_g|_i|_dS(N(tverifiertffitexport_symbolst_struct_pending_verification(tselfR((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyt__init__s   cCs|jd|jdS(NR(t setdefaultR(Rtkwds((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pytpatch_extension_kwdsscCssxl|D]d}||}|dkr/tj}nx9|D]1}tjj||}tjj|r6|Sq6WqWdS(N(tNonetsystpathtostjointisfile(Rt module_nameRt so_suffixest so_suffixtbasenametdirnametfilename((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyt find_modules     cCsdS(N((R((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyt collect_types%stcCs|jj|ddS(Ns (t_ftwrite(Rtwhat((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyt_prnt(scCs|j}|t||jj|jdtjdkrtjdkrWd}nd}|jj}|d||fndS(Ntdecltwin32itPyInit_tinitsvoid %s%s(void) { } (i( Rtcffimod_headerRtpreamblet _generateRtplatformt version_infotget_module_name(Rtprnttprefixtmodname((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pytwrite_source_to_f+s    icsjj}tjjtjjj}|j||j ddt j ffdYd}j dd||S(Ntloadingt FFILibrarycs,eZZjZgZfdZRS(csjS(N(t _cffi_dir(R(R/(s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyt__dir__Ts(t__name__t __module__t_cffi_generic_moduleRt _cffi_ffiR0R1((R/tmoduleR(s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyR/Ps Rtloadedtlibrary( Rt_backendRRRtcurdirRtmodulefilenamet load_libraryt_loadttypest ModuleType(RtflagstbackendRR8((R/R6Rs0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyR<As % cCsHg|jjjjD]\}\}}||f^q}|j|S(N(Rt_parsert _declarationstitemstsort(Rtkeyttptqualtlst((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyt_get_declarations]s7 cCsx|jD]\}}|jdd\}}yt|d||f}Wn!tk rqtd|nXy|||Wq tk r}tj||q Xq WdS(Nt is_generate_gen_%s_%ssnot implemented in verify(): %r(RJtsplittgetattrtAttributeErrorRt ExceptionRtattach_exception_info(Rt step_nametnameRGtkindtrealnametmethodte((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyR&cs  c Ksx|jD]}\}}|jdd\}}t|d||f}y|||||Wq tk r} tj| |q Xq WdS(NRKis _%s_gen_%s(RJRLRMRORRP( RR6RQR RRRGRSRTRURV((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyR=rscCsdS(N((RRGRR((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyt_generate_nothing|scKsdS(N((RRGRRR6R ((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyt _loaded_noopscCs8t|tjst|jr8|jt||dS|j}t|j }g}xUt |j D]D\}}d}t|tj rd}n|j d||fqfWd|} gt |j |D]"\}} |jd| | ^q} |j} t| tj r6| jd| jd| tj} ndj| pHd } d |} |jj | |jr~|jd }nd}d || | f}d |} || j|| |dt|jtj rd}n$t|jtjsd}nd}|d||dj|f|d|dS(NRt*s%sx%dsargument of %ss %sis *rs, tvoids _cffi_f_%sRKs %s%s(%s)s result of %st{s*r = sreturn s %s%s(%s);t}(t isinstanceRtFunctionPtrTypetAssertionErrortellipsist_generate_gen_consttFalseRtlentargst enumeratet StructOrUniontappendtzipt get_c_nametresulttinsertt void_typeRRtabitVoidType(RRGRRR*tnumargstargnamestittypet indirectiontcontexttargtarglistttpresultt wrappernameRmtfuncdeclt result_code((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyt_generate_gen_function_declsJ    8          cCst|tjst|jr<|jt|||}ng}|}td|jDsvt|j tj rg}xat |jD]P\} } t| tj rtj | } |j | | fn|j | qW|j } t| tj rg| jdkr&td| jfntj | } |jd| |jdd| ftj} ntjt|| |j}n|jj|} d|} |j| | }x,|D]$\} } |j|| | |}qWt|||t|jj |dS(Ncss!|]}t|tjVqdS(N(R]RRf(t.0ttyp((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pys ss*'%s' is used as result type, but is opaqueiRjs _cffi_f_%s(R]RR^R_R`t_load_constantRbtanyRdRjRfRet PointerTypeRgtfldtypesR t TypeErrort _get_c_nameRkRlttupleRt_get_cached_btypet load_functiont_make_struct_wrappertsetattrRrR0(RRGRRR6R8t newfunctiont indirectionstbase_tpt indirect_argsRqR}tindirect_resulttBFuncRx((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyt_loaded_gen_functions@     csp|jj|jj|dkrK|jfd}nfd}||_|S(NRjcs$j}|||dS(Ni(tnew(Rdtres(tBTypeRtoldfunc(s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pytnewfuncs cs7| j|f|d}|S(Ni(tnewp(Rd(RRARqR(s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyRs-(RR9Rt_cffi_base_type(RRRqRGRR((RRARRqRs0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyRs    cCs,||jkst|j|d|dS(Ntstruct(RRR_t_generate_struct_or_union_decl(RRGRR((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyt_generate_gen_struct_declscCs|j|d||dS(NR(t_loading_struct_or_union(RRGRRR6((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyt_loading_gen_structscKs|j|dS(N(t_loaded_struct_or_union(RRGRRR6R ((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyt_loaded_gen_structscCs,||jkst|j|d|dS(Ntunion(RRR_R(RRGRR((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyt_generate_gen_union_declscCs|j|d||dS(NR(R(RRGRRR6((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyt_loading_gen_unionscKs|j|dS(N(R(RRGRRR6R ((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyt_loaded_gen_unionsc Cs|jdkrdSd||f}d||f}d||fj}|j}|d||f|d|d|dx|jD]\}} } } t| tjr| js| dkr|d |qy.|d | j d d |d | |fWqt k r5} |dt | qXqW|d|j j ||d|f|d|d||d|d||dx|jD]\}} } } | dkrqn|d||ft| tjr| jdkr|d| jq|d||fqW|d|d|d|d|d|f|d|dS(Ns_cffi_check_%s_%ss_cffi_layout_%s_%ss%s %ssstatic void %s(%s *p)R[s8 /* only to generate compile-time warnings or errors */s (void)p;is (void)((p->%s) << 1);s { %s = &p->%s; (void)tmp; }s*tmpsfield %rtqualss /* %s */R\sintptr_t %s(intptr_t i)s, struct _cffi_aligncheck { char x; %s y; };s static intptr_t nums[] = {s sizeof(%s),s) offsetof(struct _cffi_aligncheck, y),s offsetof(%s, %s),s 0, /* %s */s sizeof(((%s *)0)->%s),s -1s };s return nums[i];s3 /* the next line is not executed, but compiled */s %s(0);(tfldnamesR tstripRt enumfieldsR]Rt PrimitiveTypetis_integer_typeRiRtstrRRgt ArrayTypetlengthR( RRGR+RRt checkfuncnametlayoutfuncnametcnameR*tfnametftypetfbitsizetfqualRV((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyRsT         !     cCsr|jdkrdSd||f}|jjdd}|j||}g}d} x=tr|| } | dkr|Pn|j| | d7} qZWt|tj rE|j rE|d} |d} |ddd} |ddd}|j t | t |ko"t |jkns-t | || | f|_n)d||fj}||f|j|7}qn|dks td}t |t j r1d |}n|jj|j ||d} |j| |} | }t |t j r|d}n|S( Ns_cffi_const_%ss long long*isint(*)(long long*)s long longiis (*)(void)RY( R R_t_load_known_int_constantRRRRtintRR]RRfRi(RRRGRRR6RRtvalueRRRtptnegativet BLongLongt fntypeextra((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyR~s2     $ "  cCs`t|tjo|j}|j||||}t|||t|jj|dS(N( R]RRRR~RRrR0Rg(RRGRRR6R8RR((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyt_loaded_gen_constantscCs|j}|dkr/|d|||fn|d|||f|d|d||d||d|d||d |d |d |f|d |d dS(Nis& if ((%s) > 0 || (long)(%s) != %dL) {s1 if ((%s) <= 0 || (unsigned long)(%s) != %dUL) {s char buf[64];s if ((%s) <= 0)s) sprintf(buf, "%%ld", (long)(%s));s elses2 sprintf(buf, "%%lu", (unsigned long)(%s));s: sprintf(out_error, "%s has the real value %s, not %s",s "%s", buf, "%d");ids return -1;s }(R(RRRRR*((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyRs       cCs|jjdd}|jjdd}|j||}|jj|d}||dkr|jj|}tjdkrt|d}nt|ndS(Nschar[]is int(*)(char*)iisutf-8(i( RRRRtstringRR(RR(RR6RRRRRterror((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyRscCs |jdd}d||fS(Nt$t___D_s _cffi_e_%s_%s(treplace(RR+RR((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyt_enum_funcnamestenumcCs|jr1x!|jD]}|jt|qWdS|j||}|jj||j}|d||dx3t|j|j D]\}}|j ||qW|d|d|dS(Nsint %s(char *out_error)R[s return 0;R\( Rt enumeratorsRaRRRRgRRht enumvaluesR(RRGRRR+t enumeratorRR*t enumvalue((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyRs   "  cCsx|jrRg|jD]}|jt|||^q}t||_t|_n"|j||}|j||dS(N( RRR~RRRtpartial_resolvedRR(RRGRRR6R+RRR((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyRs + cCsPxIt|j|jD]2\}}t|||t|jj|qWdS(N(RhRRRRrR0Rg(RRGRRR6R8RR((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyRs"cCs5|dkrd}n|}|jt|d|dS(Ns...R(R RaR(RRGRRR((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyt_generate_gen_macro_decl s  cCsc|dkrd}n|}|jt|||d|}t|||t|jj|dS(Ns...R(R R~RRRrR0Rg(RRGRRR6R8RR((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyt_loaded_gen_macro)s   cCst|tjr|jdkr}|j}d|f}|jj||d||d|d|f|dntj|j}|j t ||n(tj|}|j t ||dddS( Ns...s_cffi_sizeof_%sssize_t %s(void)R[s return sizeof(%s);R\RR( R]RRRRRRgRtitemRaRb(RRGRRR*Rttp_ptr((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyt_generate_gen_variable_decl6s    cst|tjr\|jdkrd|f}|jjdd}|j||}|}|jj|j} t ||jj | \} } | dkrt d||jfn|j | }ntj |j} |jt| ||} |jdk r2|jj|}|jj|| } nt||| t|jj|dSd|}|jj|jd|d}|j||}|fd}fd }tt||t||t|jj|dS( Ns...s_cffi_sizeof_%sssize_t(*)(void)is/bad size: %r does not seem to be an array of %ss _cffi_var_%ss *(*)(void)csdS(Ni((R8(tptr(s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pytgettergscs|d #include #include #include #include /* XXX for ssize_t on some platforms */ /* this block of #ifs should be kept exactly identical between c/_cffi_backend.c, cffi/vengine_cpy.py, cffi/vengine_gen.py and cffi/_cffi_include.h */ #if defined(_MSC_VER) # include /* for alloca() */ # if _MSC_VER < 1600 /* MSVC < 2010 */ typedef __int8 int8_t; typedef __int16 int16_t; typedef __int32 int32_t; typedef __int64 int64_t; typedef unsigned __int8 uint8_t; typedef unsigned __int16 uint16_t; typedef unsigned __int32 uint32_t; typedef unsigned __int64 uint64_t; typedef __int8 int_least8_t; typedef __int16 int_least16_t; typedef __int32 int_least32_t; typedef __int64 int_least64_t; typedef unsigned __int8 uint_least8_t; typedef unsigned __int16 uint_least16_t; typedef unsigned __int32 uint_least32_t; typedef unsigned __int64 uint_least64_t; typedef __int8 int_fast8_t; typedef __int16 int_fast16_t; typedef __int32 int_fast32_t; typedef __int64 int_fast64_t; typedef unsigned __int8 uint_fast8_t; typedef unsigned __int16 uint_fast16_t; typedef unsigned __int32 uint_fast32_t; typedef unsigned __int64 uint_fast64_t; typedef __int64 intmax_t; typedef unsigned __int64 uintmax_t; # else # include # endif # if _MSC_VER < 1800 /* MSVC < 2013 */ # ifndef __cplusplus typedef unsigned char _Bool; # endif # endif #else # include # if (defined (__SVR4) && defined (__sun)) || defined(_AIX) || defined(__hpux) # include # endif #endif ( RRR>RRRRtobjectRR$(((s0/tmp/pip-install-KP2Jbq/cffi/cffi/vengine_gen.pyts