6Wc@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddlZddl Tddl m Z m Z ddlZddlZdZdZdZdZd Zd Zd Zd Zd ZdZiZdZdZdZdZdZdZ dZ!dZ"dZ#e$dkre#ndS(s Pyste version %s Usage: pyste [options] interface-files where options are: --module= The name of the module that will be generated; defaults to the first interface filename, without the extension. -I Add an include path -D Define symbol --multiple Create various cpps, instead of only one (useful during development) --out= Specify output filename (default: .cpp) in --multiple mode, this will be a directory --no-using Do not declare "using namespace boost"; use explicit declarations instead --pyste-ns= Set the namespace where new types will be declared; default is the empty namespace --debug Writes the xml for each file parsed in the current directory --cache-dir= Directory for cache files (speeds up future runs) --only-create-cache Recreates all caches (doesn't generate code). --generate-main Generates the _main.cpp file (in multiple mode) --file-list A file with one pyste file per line. Use as a substitute for passing the files in the command line. --gccxml-path= Path to gccxml executable (default: gccxml) --no-default-include Do not use INCLUDE environment variable for include files to pass along gccxml. -h, --help Print this help and exit -v, --version Print version information iN(t*(t CppParsertCppParserErrors0.9.30cs2|gfd}tjj||dS(sAReturn a list containg the include dir and all its subdirectoriescs0tjj|ddkr,j|ndS(NitCVS(tostpathtsplittappend(targtdirtnames(tdirs(s//usr/lib/python2.7/dist-packages/Pyste/pyste.pytvisit>sN(RRtwalktNone(tincludeR ((R s//usr/lib/python2.7/dist-packages/Pyste/pyste.pytRecursiveIncludes;s cCs4dtjkr,tjd}|jtjSgSdS(NtINCLUDE(RtenvironRtpathsep(R((s//usr/lib/python2.7/dist-packages/Pyste/pyste.pytGetDefaultIncludesFs cCsMtjdkrId}x1|D]&}|jdd||<|d7}qWndS(Ntwin32is\t/i(tsystplatformtreplace(tincludestindexR((s//usr/lib/python2.7/dist-packages/Pyste/pyste.pytProcessIncludesNs  cCs[t|}g}z7x0|D](}|j}|r|j|qqWWd|jX|S(N(tfiletstripRtclose(tfilenametftfilestline((s//usr/lib/python2.7/dist-packages/Pyste/pyste.pyt ReadFileListVs    cCsd}yPtjtjdddddddd d d d d ddddg\}}Wn'tjk r}HdG|GH|nXt}g}g}d}d}t} d} t} t} d} x|D]\}}|dkr|j|q|dkr |j|q|dkr/|jt |q|dkrD|}q|dkrY|}q|dkr}dt j _ tt _ q|dkr|dt j _q|dkrtt _q|dkrt} q|dkr|} q|d krt} q|d!kr|t|7}q|d1kr(|q|d2krMd&tGHtjd'q|d(krbt} q|d)krw|} q|d*krg}qd+G|GH|qW||d,d,+|s|n|stjjtjj|d,d,}n|s|}| s|d-7}qnxN|D]F}tjjtjj|}|tjkrtjj|qqW| r| rd.GH|tjd/n| r| rd0GH|tjd/nt||||||| | | | | f S(3NcSsttGHtjddS(Ni(t__doc__t __version__Rtexit(((s//usr/lib/python2.7/dist-packages/Pyste/pyste.pytUsagees isR:I:D:vhsmodule=tmultiplesout=sno-usings pyste-ns=tdebugs cache-dir=sonly-create-cachetversions generate-mains file-list=thelps gccxml-path=sno-default-includesERROR:tgccxmls-Is-Ds-Rs--modules--outs --no-usingsboost::python::s --pyste-nss::s--debugs --multiples --cache-dirs--only-create-caches --file-lists-hs--helps-vs --versionsPyste version %sis--generate-mains --gccxml-paths--no-default-includesUnknown option:is.cppsCError: Use --cache-dir to indicate where to create the cache files!is3Error: --generate-main only valid in multiple mode.(s-hs--help(s-vs --version(tgetoptRtargvt GetoptErrorRRtFalseRtextendRtsettingst namespacestpythontUSING_BOOST_NStpystetTruetDEBUGR$R&R'RRtsplitexttbasenametdirnametabspathR(R(toptionsR"tetdefault_includesRtdefinestmoduletoutR)t cache_dirt create_cachet generate_maint gccxml_pathtopttvalueRtd((s//usr/lib/python2.7/dist-packages/Pyste/pyste.pytParseArgumentscs                                       )    cGs:djg|D]}d|^q }tj|ddS(Ns s #include <%s>t pchinclude(tjointinfostCodeInfo(theaderstxtcode((s//usr/lib/python2.7/dist-packages/Pyste/pyste.pyt PCHIncludes&cCsi}t|d R(RNRO(theader((s//usr/lib/python2.7/dist-packages/Pyste/pyste.pytstIncludeRStTemplatetEnumt AllFromHeadertVartrenamet set_policytexcludet set_wrappertuse_shared_ptrt use_auto_ptrtholdert add_methodtfinalt export_valuestreturn_internal_referencetwith_custodian_and_wardtreturn_value_policytreference_existing_objecttcopy_const_referencetcopy_non_const_referencetreturn_opaque_pointertmanage_new_objecttreturn_by_valuet return_selftWrappercSstj|dS(Nsdeclaration-outside(RNRO(RR((s//usr/lib/python2.7/dist-packages/Pyste/pyste.pyRXstdeclaration_codecSstj|dS(NRB(RNRO(RR((s//usr/lib/python2.7/dist-packages/Pyste/pyste.pyRXst module_codet class_code( RTRNt FunctionInfot ClassInfoRStClassTemplateInfotEnumInfot HeaderInfotVarInfoR^R_R`RaRbRcRdReRfRgRhRiRjRkRlRmRnRoRpRqt exporterutilstFunctionWrapperRu(tcontext((s//usr/lib/python2.7/dist-packages/Pyste/pyste.pyt CreateContextsF                                 c Cst\ }}}}}}}}}} x|D]} t| q.Wt|||tj| } zI|s|st| ||||St||t|Sn t| SWd| j XdS(N( RKtExecuteInterfaceRt declarationsR+t GenerateCodet GenerateMaintOrderInterfacest CreateCachestClose( RRARBRCt interfacesR)RDRERFRGt interfacetparser((s//usr/lib/python2.7/dist-packages/Pyste/pyste.pytBegins' cCsmttj}xW|D]O\}}|||f}|j||}|j||||}dG|GHqWdS(NtCachedi(t JoinTailst exporterstParseWithGCCXMLt CreateCache(RttailsRRWttailRt cachefile((s//usr/lib/python2.7/dist-packages/Pyste/pyste.pyR s cCstj}tjj|s`|r`tjj|r`tjj|}tjj||}q`ntjj|std|ntj |ddt|<|t_t }tjj ||dS(N(Rtsorttreverse(RRQtinterfaces_ordert_((s//usr/lib/python2.7/dist-packages/Pyste/pyste.pyRHs#  cCs#tj||}|j|dS(Ni(tMultipleCodeUnitR(RBRCRtcodeunit((s//usr/lib/python2.7/dist-packages/Pyste/pyste.pyRPs cCs |rtj||}ntj||}tj}dt_tg|D]}|jdf^qI}i} xD|D]<} | j| kr| | jj| qw| g| | j'sJ                 c  +        8