Kc@sddlZddlZddlZddlmZddlmZmZmZej dZ dZ dddYZ de fd YZ d dd YZd dd YZdddYZdddYZdS(iN(t open_new_file(tpy_object_typetc_char_array_typettypecasts[A-Za-z_][A-Za-z0-9_]*$it CCodeWritercBsCeZdZddZdZdZdZdZdZdZ d Z d Z d d"e d Zd d"e d ZdZdZd"dZd"dZdZd"dZdZdZdZdZdZdZd dZdZdZdZddZ d Z!d!Z"RS(#cCs(||_d|_d|_d|_dS(Nii(tftleveltboltNonetmarker(tselfR((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pyt__init__s   tcCsR|jr|jr|jn|r5|j|n|jjdd|_dS(Ns i(R Rt emit_markertputRtwrite(R tcode((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pytputlns  cCs>|jjd|j|jjd|jd|_dS(Ns s /* %s */ (RRtindentR R(R ((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pyR $s cCs|jd|jd}|dkr:|j|7_n|jrP|jn|jj|d|_|dkr|j|7_ndS(Nt{t}i(tcountRRRRR(R Rtdl((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pyR*s     cCs|jd|_dS(Ni(R(R ((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pytincrease_indent5scCs|jd|_dS(Ni(R(R ((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pytdecrease_indent8scCs|jd|jdS(NR(RR(R ((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pyt begin_block;s cCs|j|jddS(NR(RR(R ((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pyt end_block?s cCs|jjd|jdS(Ns (RRR(R ((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pyRCscCs&|\}}}d||f|_dS(Ns"%s":%s(R (R tpostfiletlinetcol((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pytmark_posFsicCs7x0|D](}|js|j||||qqWdS(N(t in_cincludetput_var_declaration(R tentrieststatict dll_linkaget definitiontentry((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pytput_var_declarationsJs  cCs+|j}|dkr | r dS|j r:|dkr:dSd}|dkrXtj}n?|dkry|stj}qn|dkr|rd}qn|r|jd|n|dkrd}n|j|jj|jd||j dk r|jd|jj |j n|j d dS( NtprivateR texterntpublicR#s%s R$s = %st;( t visibilitytusedtNamingtextern_c_macroRRttypetdeclaration_codetcnametinitt literal_codeR(R R&R#R$R%R,t storage_class((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pyR!Ps.         #cCsQ|j}|j r#|jj s;|jjrF|jjrFd|jS|jSdS(Ns (PyObject *)(R0t is_self_argt is_completetis_extension_typet base_typeR2(R R&R0((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pytentry_as_pyobjectms   cCs|rtt||S|SdS(N(RR(R R2R0((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pyt as_pyobjectuscCs!|jd|j||dS(NsPy_INCREF(%s);(RR;(R R2R0((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pyt put_incref{scCs!|jd|j||dS(NsPy_DECREF(%s);(RR;(R R2R0((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pyt put_decref~scCs-|jjr)|jd|j|ndS(NsPy_INCREF(%s);(R0t is_pyobjectRR:(R R&((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pytput_var_increfs cCs'|jd|j|||fdS(NsPy_DECREF(%s); %s = 0;(RR;(R R2R0((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pytput_decref_clears cCs!|jd|j||dS(NsPy_XDECREF(%s);(RR;(R R2R0((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pyt put_xdecrefscCs'|jd|j|||fdS(NsPy_XDECREF(%s); %s = 0;(RR;(R R2R0((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pytput_xdecref_clears cCs-|jjr)|jd|j|ndS(NsPy_DECREF(%s);(R0R>RR:(R R&((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pytput_var_decrefs cCs6|jjr2|jd|j||jfndS(NsPy_DECREF(%s); %s = 0;(R0R>RR:R2(R R&((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pytput_var_decref_clears  cCs-|jjr)|jd|j|ndS(NsPy_XDECREF(%s);(R0R>RR:(R R&((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pytput_var_xdecrefs cCs6|jjr2|jd|j||jfndS(NsPy_XDECREF(%s); %s = 0;(R0R>RR:R2(R R&((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pytput_var_xdecref_clears  cCsNxG|D]?}| s|jr|jr6|j|qF|j|qqWdS(N(R-txdecref_cleanupRERC(R R"t used_onlyR&((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pytput_var_decrefss   cCs"x|D]}|j|qWdS(N(RE(R R"R&((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pytput_var_xdecrefss cCs"x|D]}|j|qWdS(N(RF(R R"R&((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pytput_var_xdecrefs_clears cCs-t|td}|jd||fdS(NtPy_Nones%s = %s; Py_INCREF(Py_None);(RRR(R R2R0tpy_none((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pytput_init_to_py_noness%scCs$||j}|j||jdS(N(R2RNR0(R R&ttemplateR((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pytput_init_var_to_py_nones cCsB|jr|j}nd}|jd|j|j||fdS(Nis9{"%s", (PyCFunction)%s, METH_VARARGS|METH_KEYWORDS, %s}%s(tdoct doc_cnameRtnamet func_cname(R R&ttermtdoc_code((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pytput_pymethoddefs  cCs&|jd||jd|dS(Ns #ifndef %ss #define %s(R(R tguard((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pyt put_h_guardsN(#t__name__t __module__R RR RRRRRRRRtTrueR'R!R:R;R<R=R?R@RARBRCRDRERFRIRJRKRNRPRWRY(((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pyRsB                             tMainCCodeWritercBseZdZddZdZdZdZdZdZ dZ dZ d Z d Z d Zd Zd ZdZdZdZdZdZdZdZdZRS(icCsPtj|||r%|j|_n t|_d|_d|_d|_dS(Ni(RR t global_statetGlobalCodeStatet label_counterRt error_labeltexc_vars(R Rtbase((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pyR s   cCsAd|_i|_|j|_|jd|_d|_dS(Ni(R`t labels_usedt new_labelt return_labeltnew_error_labelRtcontinue_labelt break_label(R ((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pyt init_labelss     cCs'|j}|d|_dtj|fS(Nis%s%d(R`R.t label_prefix(R tn((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pyRes  cCs|j}|j|_|S(N(RaRe(R t old_err_lbl((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pyRgs cCs|j|jfS(N(RhRi(R ((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pytget_loop_labelsscCs|\|_|_dS(N(RhRi(R tlabels((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pytset_loop_labelsscCs/|j}|j|j|jf|S(N(RnRpRe(R t old_labels((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pytnew_loop_labelss   cCs|j|j|j|jfS(N(RhRiRfRa(R ((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pytget_all_labelsscCs"|\|_|_|_|_dS(N(RhRiRfRa(R Ro((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pytset_all_labelsscCs]|j}g}x7|D]/}|r;|j|jq|j|qW|j||S(N(RstappendReRt(R Rqt new_labelst old_label((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pytall_new_labelss   cCsd|j|scsHjdx4|D],}|jj|j}jd|qWdS(NR s static %s;(RR0R1R2(tconstsRtdecl(R(s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pyt put_constss  (RRRutsort(R Rtinternedt uninternedRR((Rs7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pyRs  csg}g}xI|jD]>}|j}|r|jrD|j|qT|j|qqW|jdfd}jdjdtj||d||djdjddS( NcSst|jj|jjS(N(RRR2(RR((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pyRscsAx:|D]2}|j}jd|jj|||fqWdS(Ns{&%s, %d, %s, sizeof(%s)},(R2RR(RRRR2(R(s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pyt put_stringtabs   R s$static __Pyx_StringTabEntry %s[] = {iis {0, 0, 0, 0}s};(RRRRuRRR.tstringtab_cname(R RRRRRR((Rs7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pyRs       N(RZR[R RRRRRRRRRRRRRRR(((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pyR_ps         tPyrexCodeWritercBs,eZdZdZdZdZRS(cCst||_d|_dS(Ni(RRR(R t outfile_name((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pyR scCs%|jjdd|j|fdS(Ns%s%s t (RRR(R R((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pyRscCs|jd7_dS(Ni(R(R ((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pyRscCs|jd8_dS(Ni(R(R ((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pytdedent s(RZR[R RRR(((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pyRs   ((((((RtreR.t Pyrex.UtilsRt PyrexTypesRRRtcompileRRRR]RRR_R(((s7/usr/lib/python2.7/site-packages/Pyrex/Compiler/Code.pyts