ó 6šâWc@s³ddlmZddlZddlZddlZddlZddlZddlZddlZddlZddl m Z m Z de fd„ƒYZ ddd„ƒYZdS( iÿÿÿÿ(tParseDeclarationsN(tdumptloadtCppParserErrorcBseZRS((t__name__t __module__(((s3/usr/lib/python2.7/dist-packages/Pyste/CppParser.pyRst CppParsercBs•eZdZdddddd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z dd „Z d „Z d „Zd „Zd„ZRS(s7Parses a header file and returns a list of declarationstgccxmlcCs¤|dkrg}n|dkr*g}n||_||_||_||_t|_||_g|_i|_ |r yt j |ƒWq t k rœq XndS(s3includes and defines ar the directives given to gccN( tNonetincludest gccxml_pathtdefinestversiontFalset delete_cachet cache_dirt cache_filest mem_cachetostmakedirstOSError(tselfR R RR R ((s3/usr/lib/python2.7/dist-packages/Pyste/CppParser.pyt__init__s"             cCs|jƒdS(N(tClose(R((s3/usr/lib/python2.7/dist-packages/Pyste/CppParser.pyt__del__6scCsn|j}tjj|ƒ}|s+d}n|jd|ƒg|D]}d|j|ƒ^qB}dj|ƒS(Nt.is-I "%s"t (R RtpathtdirnametinserttUnixfytjoin(RtfilenameR tfiledirtx((s3/usr/lib/python2.7/dist-packages/Pyste/CppParser.pyt_IncludeParams:s  &cCs-g|jD]}d|^q }dj|ƒS(Ns-D "%s"R(R R(RR"R ((s3/usr/lib/python2.7/dist-packages/Pyste/CppParser.pyt _DefineParamsDs cCsxtjj|ƒr|Sx[|jD]1}tjj||ƒ}tjj|ƒr |Sq Wtjj|ƒ}td|‚dS(NsHeader file "%s" not found!(RRtisfileR Rtbasenamet RuntimeError(RtheaderRR tname((s3/usr/lib/python2.7/dist-packages/Pyste/CppParser.pyt FindHeaderIscCs¦ttdƒrCtjdƒ\}}t|dƒ}tj|ƒntjdƒ}t|dƒ}|jdtjj |ƒƒ|j|ƒ|jdƒ|jƒ|S(smCreates a temporary file, appends the text tail to it, and returns the filename of the file. tmkstemps.htas#include "%s" s ( thasattrttempfileR+tfileRtclosetmktemptwriteRtabspath(RR ttailtf_nottemptf((s3/usr/lib/python2.7/dist-packages/Pyste/CppParser.pyt AppendTailUs   cCs|jddƒS(Ns\t/(treplace(RR((s3/usr/lib/python2.7/dist-packages/Pyste/CppParser.pyRgsc Cs |j|ƒ}|r*|j||ƒ}n|}tjdƒ}z%|j|ƒ}|jƒ}d}|j|ƒ}|j|ƒ}tj||j ||||fƒ}|dksÅtj j |ƒ rÑt d‚nt |ƒ} |r_xy| D]n} tj jtj j| jdƒƒ} tj jtj j|ƒƒ}| |krê|| jdf| _qêqêWn| SWdtjrÊtj j |ƒrÊtj j|ƒ} tj j| ƒdd} dG| GHtj|| ƒny'tj|ƒ|rðtj|ƒnWntk rnXXdS(s?Parses the given header using gccxml and GCCXMLParser. s.xmls%s %s %s "%s" -fxml=%sisError executing gccxmliNsDEBUG:(R*R8R.R1R#R$RRtsystemR RR%RRtnormpathtnormcasetlocationtsettingstDEBUGR&tsplitexttshutiltcopytremoveR( RR(R4R txmlfileR R tcmdtstatust declarationstdeclt decl_filenamet debugname((s3/usr/lib/python2.7/dist-packages/Pyste/CppParser.pytParseWithGCCXMLksB %   %     cCs’|dkrd}n|jƒ}|j|||ƒ}|dkrm|j||ƒ}|j||||ƒntjj|j|ƒƒ}||fS(s»Parses the given filename related to the given interface and returns the (declarations, headerfile). The header returned is normally the same as the given to this method (except that it is the full path), except if tail is not None: in this case, the header is copied to a temp filename and the tail code is appended to it before being passed on to gccxml. This temp filename is then returned. tN( RtstriptGetCacheRLt CreateCacheRRR3R*(RR(t interfaceR4RHtheader_fullpath((s3/usr/lib/python2.7/dist-packages/Pyste/CppParser.pytParse˜s    cCsHtjj|ƒ}tjj|ƒdd}tjj|j|ƒ}|S(Nis.pystec(RRR&RARR(RRQtinterface_namet cache_file((s3/usr/lib/python2.7/dist-packages/Pyste/CppParser.pyt CacheFileName«sc Csî|||f}||jkr)|j|S|jdkr<dS|j|ƒ}|j|ƒ}tjj|ƒræt|dƒ}zZt |ƒ}||j krdSt |ƒ}|j |ƒrÐ|j j |ƒ||SdSWd|jƒXndSdS(Ntrb(RRRR*RVRRR%R/RR thas_keyRtappendR0( RR(RQR4tkeyRUR7R tcache((s3/usr/lib/python2.7/dist-packages/Pyste/CppParser.pyRO²s(   c Cs|||f}|jjƒ||j|<|jdkr<dS|j|ƒ}|j|ƒ}tjj|ƒr¨t |dƒ}zt |ƒ}t |ƒ} Wd|j ƒXni} || |<|j j |ƒt |dƒ}z't|j|dƒt| |dƒWd|j ƒX|S(NRWtwbi(RtclearRRR*RVRRR%R/RR0RRYRR ( RR(RQR4RHRZRUR7R R[((s3/usr/lib/python2.7/dist-packages/Pyste/CppParser.pyRPÏs,     cCsk|jrg|jrgx6|jD]+}ytj|ƒWqtk rFqXqWg|_tj|jƒndS(N(RRRRDRRBtrmtreeR(RR ((s3/usr/lib/python2.7/dist-packages/Pyste/CppParser.pyRïs  N(RRt__doc__RRRR#R$R*R8RRLRSRVRORPR(((s3/usr/lib/python2.7/dist-packages/Pyste/CppParser.pyRs     -    ((t GCCXMLParserRR.RBRtsystos.pathR?tshelvetcPickleRRt ExceptionRR(((s3/usr/lib/python2.7/dist-packages/Pyste/CppParser.pyts