Ñò
XÁÅGc           @   s³   d  d k  l Z d  d k Z d  d k Z d  d k Z d  d k Z d  d k Z d  d k Z d  d k Z d  d k Z d  d k	 l
 Z
 l Z d e f d „  ƒ  YZ d d d „  ƒ  YZ d S(	   iÿÿÿÿ(   t   ParseDeclarationsN(   t   dumpt   loadt   CppParserErrorc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s/   /usr/lib/pymodules/python2.6/Pyste/CppParser.pyR      s    t	   CppParserc           B   s•   e  Z d  Z d d d d d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d d
 „ Z d „  Z d „  Z d „  Z d „  Z RS(   s7   Parses a header file and returns a list of declarationst   gccxmlc         C   s¬   | d j o
 g  } n | d j o
 g  } n | |  _ | |  _ | |  _ | |  _ t |  _ | |  _ g  |  _ h  |  _	 | o+ y t
 i | ƒ Wq¨ t j
 o q¨ Xn d S(   s3   includes and defines ar the directives given to gccN(   t   Nonet   includest   gccxml_patht   definest   versiont   Falset   delete_cachet	   cache_dirt   cache_filest	   mem_cachet   ost   makedirst   OSError(   t   selfR	   R   R   R   R
   (    (    s/   /usr/lib/pymodules/python2.6/Pyste/CppParser.pyt   __init__   s"    

								 c         C   s   |  i  ƒ  d  S(   N(   t   Close(   R   (    (    s/   /usr/lib/pymodules/python2.6/Pyste/CppParser.pyt   __del__6   s    c         C   sx   |  i  } t i i | ƒ } | p
 d } n | i d | ƒ g  } | D] } | d |  i | ƒ qH ~ } d i | ƒ S(   Nt   .i    s   -I "%s"t    (   R	   R   t   patht   dirnamet   insertt   Unixfyt   join(   R   t   filenameR	   t   filedirt   _[1]t   x(    (    s/   /usr/lib/pymodules/python2.6/Pyste/CppParser.pyt   _IncludeParams:   s    

.c         C   s5   g  } |  i  D] } | d | q ~ } d i | ƒ S(   Ns   -D "%s"R   (   R   R   (   R   R"   R#   R   (    (    s/   /usr/lib/pymodules/python2.6/Pyste/CppParser.pyt   _DefineParamsD   s    (c         C   s|   t  i i | ƒ o | Sx] |  i D]3 } t  i i | | ƒ } t  i i | ƒ o | Sq" Wt  i i | ƒ } t d | ‚ d  S(   Ns   Header file "%s" not found!(   R   R   t   isfileR	   R   t   basenamet   RuntimeError(   R   t   headerR   R    t   name(    (    s/   /usr/lib/pymodules/python2.6/Pyste/CppParser.pyt
   FindHeaderI   s    
 	c         C   s¨   t  t d ƒ o5 t i d ƒ \ } } t | d ƒ } t i | ƒ n t i d ƒ } t | d ƒ } | i d t i i	 | ƒ ƒ | i | ƒ | i d ƒ | i ƒ  | S(   sm   Creates a temporary file, appends the text tail to it, and returns
        the filename of the file.
        t   mkstemps   .ht   as   #include "%s"

s   
(
   t   hasattrt   tempfileR,   t   fileR   t   closet   mktempt   writeR   t   abspath(   R   R    t   tailt   f_not   tempt   f(    (    s/   /usr/lib/pymodules/python2.6/Pyste/CppParser.pyt
   AppendTailU   s    
c         C   s   | i  d d ƒ S(   Ns   \t   /(   t   replace(   R   R   (    (    s/   /usr/lib/pymodules/python2.6/Pyste/CppParser.pyR   g   s    c         C   s  |  i  | ƒ } | o |  i | | ƒ } n | } t i d ƒ } z,|  i | ƒ } |  i ƒ  } d } |  i | ƒ } |  i | ƒ } t i | |  i	 | | | | f ƒ } | d j p t i
 i | ƒ o t d ‚ n t | ƒ }	 | o x| |	 D]p }
 t i
 i t i
 i |
 i d ƒ ƒ } t i
 i t i
 i | ƒ ƒ } | | j o | |
 i d f |
 _ qð qð Wn |	 SWd t i o\ t i
 i | ƒ oI t i
 i | ƒ } t i
 i | ƒ d d } d G| GHt i | | ƒ n y) t i | ƒ | o t i | ƒ n Wn t j
 o n XXd S(   s?   Parses the given header using gccxml and GCCXMLParser.
        s   .xmls   %s %s %s "%s" -fxml=%si    s   Error executing gccxmli   Ns   DEBUG:(   R+   R9   R/   R2   R$   R%   R   R   t   systemR
   R   R&   R   R    t   normpatht   normcaset   locationt   settingst   DEBUGR'   t   splitextt   shutilt   copyt   removeR   (   R   R)   R5   R    t   xmlfileR	   R   t   cmdt   statust   declarationst   declt   decl_filenamet	   debugname(    (    s/   /usr/lib/pymodules/python2.6/Pyste/CppParser.pyt   ParseWithGCCXMLk   sD    %! %"	 c         C   s–   | d j o
 d } n | i ƒ  } |  i | | | ƒ } | d j o, |  i | | ƒ } |  i | | | | ƒ n t i i |  i | ƒ ƒ } | | f S(   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.
        t    N(	   R   t   stript   GetCacheRM   t   CreateCacheR   R   R4   R+   (   R   R)   t	   interfaceR5   RI   t   header_fullpath(    (    s/   /usr/lib/pymodules/python2.6/Pyste/CppParser.pyt   Parse˜   s    
c         C   sH   t  i i | ƒ } t  i i | ƒ d d } t  i i |  i | ƒ } | S(   Ni    s   .pystec(   R   R   R'   RB   R   R   (   R   RR   t   interface_namet
   cache_file(    (    s/   /usr/lib/pymodules/python2.6/Pyste/CppParser.pyt   CacheFileName«   s    c   	      C   sø   | | | f } | |  i  j o |  i  | S|  i d  j o d  S|  i | ƒ } |  i | ƒ } t i i | ƒ o t | d ƒ } z^ t	 | ƒ } | |  i
 j o d  St	 | ƒ } | i | ƒ o |  i i | ƒ | | Sd  SWd  | i ƒ  Xn d  Sd  S(   Nt   rb(   R   R   R   R+   RW   R   R   R&   R0   R   R   t   has_keyR   t   appendR1   (	   R   R)   RR   R5   t   keyRV   R8   R   t   cache(    (    s/   /usr/lib/pymodules/python2.6/Pyste/CppParser.pyRP   ²   s(    	c   
   
   C   s  | | | f } |  i  i ƒ  | |  i  | <|  i d  j o d  S|  i | ƒ } |  i | ƒ } t i i | ƒ o= t	 | d ƒ } z t
 | ƒ } t
 | ƒ }	 Wd  | i ƒ  Xn h  }	 | |	 | <|  i i | ƒ t	 | d ƒ } z' t |  i | d ƒ t |	 | d ƒ Wd  | i ƒ  X| S(   NRX   t   wbi   (   R   t   clearR   R   R+   RW   R   R   R&   R0   R   R1   R   RZ   R   R   (
   R   R)   RR   R5   RI   R[   RV   R8   R   R\   (    (    s/   /usr/lib/pymodules/python2.6/Pyste/CppParser.pyRQ   Ï   s,    
c         C   sp   |  i  ob |  i oX x8 |  i D]- } y t i | ƒ Wq t j
 o q Xq Wg  |  _ t i |  i ƒ n d  S(   N(   R   R   R   RE   R   RC   t   rmtreeR   (   R   R    (    (    s/   /usr/lib/pymodules/python2.6/Pyste/CppParser.pyR   ï   s    
 		N(   R   R   t   __doc__R   R   R   R$   R%   R+   R9   R   RM   RT   RW   RP   RQ   R   (    (    (    s/   /usr/lib/pymodules/python2.6/Pyste/CppParser.pyR      s   		
					-			 (    (   t   GCCXMLParserR    R/   RC   R   t   syst   os.pathR@   t   shelvet   cPickleR   R   t	   ExceptionR   R   (    (    (    s/   /usr/lib/pymodules/python2.6/Pyste/CppParser.pyt   <module>   s   