ó
ù“Fac           @   sŒ   d  Z  d d l m Z m Z d d l m Z d d l m Z d d l Td d l	 Td d l
 Z
 d e f d „  ƒ  YZ d	 e f d
 „  ƒ  YZ d S(   sJ   
This module contains the namespace class and the singleton module class.
iÿÿÿÿ(   t   dirnamet   basename(   t   parse(   t   matcher(   t   *Nt	   Namespacec           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s[  
    Contains the naming information for an extension.

    Public fields:

    header is the header attribute ("header file" name).
    is_ext is true for extensions, false for xproto.
    major_version and minor_version are extension version info.
    ext_xname is the X extension name string.
    ext_name is the XCB extension name prefix.
    c         C   s  | |  _  t | ƒ |  _ t | ƒ |  _ t | ƒ j ƒ  |  _ |  j j d ƒ |  _	 |  j	 d |  _
 i  |  _ |  j j d t ƒ rñ t |  _ |  j j d ƒ |  _ |  j j d ƒ |  _ |  j j d ƒ |  _ |  j j d ƒ |  _ d |  j f |  _ n t |  _ d |  _ d	 |  _ d  S(
   Nt   headert   :s   extension-xnames   major-versions   minor-versions   extension-namet   xcbt    (   R   (   t   pathR    t   dirR   t   fileR   t   getroott   roott   getR   t   nst   eventst   Falset   Truet   is_extt   major_versiont   minor_versiont	   ext_xnamet   ext_namet   prefix(   t   selft   filename(    (    s0   /usr/lib/python2.7/site-packages/xcbgen/state.pyt   __init__   s"    					c         C   s   | | f |  j  | <d  S(   N(   R   (   R   t   idt   namet   item(    (    s0   /usr/lib/python2.7/site-packages/xcbgen/state.pyt	   add_event4   s    c         C   sa   xZ |  j  j ƒ  D]I \ } \ } } | j | k r | j | ƒ } | d  k	 rY | | f Sq q Wd  S(   N(   R   t   itemst   is_ge_eventt   get_name_for_opcodet   None(   R   t   opcodeR"   R   R   t   eventt   opcode_specific_name(    (    s0   /usr/lib/python2.7/site-packages/xcbgen/state.pyt   get_event_by_opcode7   s    "(   t   __name__t
   __module__t   __doc__R   R    R(   (    (    (    s0   /usr/lib/python2.7/site-packages/xcbgen/state.pyR      s   		t   Modulec           B   sÁ   e  Z d  Z e j d Z e j d Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s8  
    This is the grand, encompassing class that represents an entire XCB specification.
    Only gets instantiated once, in the main() routine.

    Don't need to worry about this much except to declare it and to get the namespace.

    Public fields:
    namespace contains the namespace info for the spec.
    t   opent   closec         C   s®  t  | ƒ |  _ | |  _ g  |  _ g  |  _ d |  _ i  |  _ i  |  _ i  |  _ g  |  _	 i  |  _
 |  j |  j
 |  j j <|  j d d d t ƒ |  j d d d t ƒ |  j d d d t ƒ |  j d	 d d t ƒ |  j d d d t ƒ |  j d d d t ƒ |  j d d d t ƒ |  j d d d  t ƒ |  j d d d! t ƒ |  j d d d" t ƒ |  j d d d# t ƒ |  j d d d$ t ƒ |  j d d d% t ƒ |  j d d d& t ƒ d  S('   Ni    t   CARD8R	   t   uint8_tt   CARD16t   uint16_tt   CARD32t   uint32_tt   CARD64t   uint64_tt   INT8t   int8_tt   INT16t   int16_tt   INT32t   int32_tt   INT64t   int64_tt   BYTEt   BOOLt   chart   floatt   doublet   void(   R0   (   R2   (   R4   (   R6   (   R8   (   R:   (   R<   (   R>   (   R0   (   R0   (   RA   (   RB   (   RC   (   RD   (   R   t	   namespacet   outputt   importst   direct_importst   import_levelt   typesR   t   errorst   allt
   namespacesR   t   add_typet   tcard8t   tcard16t   tcard32t   tcard64t   tint8t   tint16t   tint32t   tint64t   tbytet   tboolt   tchart   tfloatt   tdoublet   tvoid(   R   R   RF   (    (    s0   /usr/lib/python2.7/site-packages/xcbgen/state.pyR   M   s2    									c         C   s   t  j |  |  j ƒ d  S(   N(   R   t   executeRE   (   R   (    (    s0   /usr/lib/python2.7/site-packages/xcbgen/state.pyt   registero   s    c         C   s>   |  j  ƒ  x- |  j D]" \ } } d |  _ | j |  ƒ q Wd  S(   Ni    (   t   add_events_to_namespacesRL   t   padst   resolve(   R   R   R   (    (    s0   /usr/lib/python2.7/site-packages/xcbgen/state.pyRa   s   s    
	c         C   s?   |  j  ƒ  x$ |  j D] \ } } | j | ƒ q W|  j ƒ  d  S(   N(   R-   RL   t   outR.   (   R   R   R   (    (    s0   /usr/lib/python2.7/site-packages/xcbgen/state.pyt   generatez   s    
c         C   sX   |  j  d k r+ |  j j | | j f ƒ n  |  j j | | j f ƒ | |  j | j <d  S(   Ni    (   RI   RH   t   appendR   RG   RM   R   (   R   R   RE   (    (    s0   /usr/lib/python2.7/site-packages/xcbgen/state.pyt
   add_importƒ   s    c         C   s.   x' |  j  D] \ } } | | k r
 t Sq
 Wt S(   N(   RG   R   R   (   R   R   t   name_R   (    (    s0   /usr/lib/python2.7/site-packages/xcbgen/state.pyt
   has_import‰   s    c         C   sc   | | } | |  j  k r d  S| | f |  j  | <| d  |  j j k r_ |  j j | | f ƒ n  d  S(   Niÿÿÿÿ(   RJ   RE   R   RL   Rd   (   R   R   R   R   R   t   key(    (    s0   /usr/lib/python2.7/site-packages/xcbgen/state.pyRN      s    
c         C   s¨   | } | |  j  k r$ |  j  | | S|  j j | } | |  j  k rR |  j  | | Sx? |  j  j ƒ  D]. } | j d ƒ d | k rb |  j  | | Sqb Wt d | ƒ ‚ d  S(   NR   i   s   Type %s not found(   RJ   RE   R   t   keyst
   rpartitiont   ResolveException(   R   R   t   idxRh   (    (    s0   /usr/lib/python2.7/site-packages/xcbgen/state.pyt   get_type_impl˜   s    c         C   s   |  j  | d ƒ S(   Ni   (   Rm   (   R   R   (    (    s0   /usr/lib/python2.7/site-packages/xcbgen/state.pyt   get_type§   s    c         C   s   |  j  | d ƒ S(   Ni    (   Rm   (   R   R   (    (    s0   /usr/lib/python2.7/site-packages/xcbgen/state.pyt   get_type_nameª   s    c         C   s   |  j  | S(   N(   RM   (   R   R   (    (    s0   /usr/lib/python2.7/site-packages/xcbgen/state.pyt   get_namespace­   s    c         C   s3   | d  |  j  j k r/ |  j j | | f ƒ n  d  S(   Niÿÿÿÿ(   RE   R   RL   Rd   (   R   R   R   R   (    (    s0   /usr/lib/python2.7/site-packages/xcbgen/state.pyt   add_request±   s    c         C   sF   | | f |  j  | <| d  |  j j k rB |  j j | | f ƒ n  d  S(   Niÿÿÿÿ(   R   RE   R   RL   Rd   (   R   R   R   R   (    (    s0   /usr/lib/python2.7/site-packages/xcbgen/state.pyR    ¶   s    c         C   s|   xu |  j  j ƒ  D]d \ } \ } } | d  d k r; d } n
 | d } |  j | } | d  k	 r | j | | | ƒ q q Wd  S(   NiÿÿÿÿR   R	   iþÿÿÿ(   R   (   R   R!   RM   R$   R    (   R   R   R   R   t   namespace_nameRE   (    (    s0   /usr/lib/python2.7/site-packages/xcbgen/state.pyR_   ¼   s    "	
c         C   s   |  j  | d S(   Ni   (   R   (   R   R   (    (    s0   /usr/lib/python2.7/site-packages/xcbgen/state.pyt	   get_eventÌ   s    c         C   sF   | | f |  j  | <| d  |  j j k rB |  j j | | f ƒ n  d  S(   Niÿÿÿÿ(   RK   RE   R   RL   Rd   (   R   R   R   R   (    (    s0   /usr/lib/python2.7/site-packages/xcbgen/state.pyt	   add_errorÐ   s    c         C   s   |  j  | d S(   Ni   (   RK   (   R   R   (    (    s0   /usr/lib/python2.7/site-packages/xcbgen/state.pyt	   get_errorÕ   s    (   R)   R*   R+   t   __main__RF   R-   R.   R   R^   Ra   Rc   Re   Rg   RN   Rm   Rn   Ro   Rp   Rq   R    R_   Rs   Rt   Ru   (    (    (    s0   /usr/lib/python2.7/site-packages/xcbgen/state.pyR,   @   s(   		"																(   R+   t   os.pathR    R   t   xml.etree.cElementTreeR   t   xcbgenR   t   xcbgen.errort   xcbgen.xtypesRv   t   objectR   R,   (    (    (    s0   /usr/lib/python2.7/site-packages/xcbgen/state.pyt   <module>   s   

3