pWc@sZddlZddlZddlZddlmZmZdefdYZdZdS(iNi(tmodelt ffiplatformtVGenericEnginecBseZdZeZdZdZdZdZddZ 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((s6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pyt__init__s   cCs|jd|jdS(NR(t setdefaultR(Rtkwds((s6/usr/lib64/python2.7/site-packages/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((s6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pyt find_modules     cCsdS(N((R((s6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pyt collect_types$stcCs|jj|ddS(Ns (t_ftwrite(Rtwhat((s6/usr/lib64/python2.7/site-packages/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((s6/usr/lib64/python2.7/site-packages/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/(s6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pyt__dir__Ss(t__name__t __module__t_cffi_generic_moduleRt _cffi_ffiR0R1((R/tmoduleR(s6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pyR/Os Rtloadedtlibrary( Rt_backendRRRtcurdirRtmodulefilenamet load_libraryt_loadttypest ModuleType(RtflagstbackendRR8((R/R6Rs6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pyR<@s % cCsHg|jjjjD]\}\}}||f^q}|j|S(N(Rt_parsert _declarationstitemstsort(Rtkeyttptqualtlst((s6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pyt_get_declarations\s7 cCsx|jD]\}}|jdd\}}yt|d||f}Wn$tk rttjd|nXy|||Wq tk r}tj||q Xq WdS(Nt is_generate_gen_%s_%ssnot implemented in verify(): %r( RJtsplittgetattrtAttributeErrorRtVerificationErrort ExceptionRtattach_exception_info(Rt step_nametnameRGtkindtrealnametmethodte((s6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pyR&bs  c Ksx|jD]}\}}|jdd\}}t|d||f}y|||||Wq tk r} tj| |q Xq WdS(NRKis _%s_gen_%s(RJRLRMRPRRQ( RR6RRR RSRGRTRURVRW((s6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pyR=qscCsdS(N((RRGRS((s6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pyt_generate_nothing{scKsdS(N((RRGRSR6R ((s6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pyt _loaded_noop~scCs8t|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(RRGRSR*tnumargstargnamestittypet indirectiontcontexttargtarglistttpresultt wrappernameRntfuncdeclt result_code((s6/usr/lib64/python2.7/site-packages/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^RRg(t.0ttyp((s6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pys ss*'%s' is used as result type, but is opaqueiRks _cffi_f_%s(R^RR_R`Rat_load_constantRctanyReRkRgRft PointerTypeRhtfldtypesR t TypeErrort _get_c_nameRlRmttupleRt_get_cached_btypet load_functiont_make_struct_wrappertsetattrRsR0(RRGRSR6R8t newfunctiont indirectionstbase_tpt indirect_argsRrR~tindirect_resulttBFuncRy((s6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pyt_loaded_gen_functions@     csp|jj|jj|dkrK|jfd}nfd}||_|S(NRkcs$j}|||dS(Ni(tnew(Retres(tBTypeRtoldfunc(s6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pytnewfuncs cs7| j|f|d}|S(Ni(tnewp(Re(RRARrR(s6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pyRs-(RR9Rt_cffi_base_type(RRRrRGRR((RRARRrRs6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pyRs    cCs,||jkst|j|d|dS(Ntstruct(RSR`t_generate_struct_or_union_decl(RRGRS((s6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pyt_generate_gen_struct_declscCs|j|d||dS(NR(t_loading_struct_or_union(RRGRSR6((s6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pyt_loading_gen_structscKs|j|dS(N(t_loaded_struct_or_union(RRGRSR6R ((s6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pyt_loaded_gen_structscCs,||jkst|j|d|dS(Ntunion(RSR`R(RRGRS((s6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pyt_generate_gen_union_declscCs|j|d||dS(NR(R(RRGRSR6((s6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pyt_loading_gen_unionscKs|j|dS(N(R(RRGRSR6R ((s6/usr/lib64/python2.7/site-packages/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 j k r8} |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_typeRjRROtstrRRht ArrayTypetlengthR( RRGR+RSt checkfuncnametlayoutfuncnametcnameR*tfnametftypetfbitsizetfqualRW((s6/usr/lib64/python2.7/site-packages/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)RZ( R R`t_load_known_int_constantRRRRtintRR^RRgRj(RRRGRSR6RRtvalueRRRtptnegativet BLongLongt fntypeextra((s6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pyRs2     $ "  cCs`t|tjo|j}|j||||}t|||t|jj|dS(N( R^RRRRRRsR0Rh(RRGRSR6R8RR((s6/usr/lib64/python2.7/site-packages/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(RRSRR*((s6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pyRs       cCs|jjdd}|jjdd}|j||}|jj|d}||dkr|jj|}tjdkrt|d}ntj |ndS(Nschar[]is int(*)(char*)iisutf-8(i( RRRRtstringRR(RRRO(RR6RRRRRterror((s6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pyRscCs |jdd}d||fS(Nt$t___D_s _cffi_e_%s_%s(treplace(RR+RS((s6/usr/lib64/python2.7/site-packages/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 enumeratorsRbRRRRhRRit enumvaluesR(RRGRSR+t enumeratorRR*t enumvalue((s6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pyRs   "  cCsx|jrRg|jD]}|jt|||^q}t||_t|_n"|j||}|j||dS(N( RRRRRRtpartial_resolvedRR(RRGRSR6R+RRR((s6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pyR s + cCsPxIt|j|jD]2\}}t|||t|jj|qWdS(N(RiRRRRsR0Rh(RRGRSR6R8RR((s6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pyRs"cCs5|dkrd}n|}|jt|d|dS(Ns...R(R RbR(RRGRSR((s6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pyt_generate_gen_macro_decls  cCsc|dkrd}n|}|jt|||d|}t|||t|jj|dS(Ns...R(R RRRRsR0Rh(RRGRSR6R8RR((s6/usr/lib64/python2.7/site-packages/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^RRRRRRhRtitemRbRc(RRGRSR*Rttp_ptr((s6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pyt_generate_gen_variable_decl5s    cst|tjr_|jdkrd|f}|jjdd}|j||}|}|jj|j} t ||jj | \} } | dkrt j d||jfn|j | }ntj|j} |jt| ||} |jdk r5|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(s6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pytgetterfscs|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 */ #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 */ typedef unsigned char _Bool; # endif #else # include # if (defined (__SVR4) && defined (__sun)) || defined(_AIX) # include # endif #endif ( RRR>RRRtobjectRR$(((s6/usr/lib64/python2.7/site-packages/cffi/vengine_gen.pyts