o
    _f                     @   s   d Z ddlmZ ddlmZ edd dkrddlmZ nddlmZ ddlT d	d
 Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Ze	e
eeeeeeeeeeed#Zd$d% ZdS )&a  
XML parser.  One function for each top-level element in the schema.

Most functions just declare a new object and add it to the module.
For typedefs, eventcopies, xidtypes, and other aliases though,
we do not create a new type object, we just record the existing one under a new name.
    )join)version_infoN   )   r   )parse)*c                 C   sx   ddl m} |jd |_t|jd| j }t| }||}t	|| |jd |_|
| js:|| j| dS dS )z
    For imports, we load the file, create a new namespace object,
    execute recursively, then record the import (for header files, etc.)
    r   )state   z%s.xmlN)Zxcbgenr   Zimport_levelr   dirtextr   ZgetrootZ	NamespaceexecuteZ
has_importZ
add_import)nodemodule	namespacer   Znew_fileZnew_rootZnew_namespace r   e/home/ych/rk3568/buildroot/output/rockchip_rk3568/host/lib/python3.10/site-packages/xcbgen/matcher.pyimport_   s   

r   c                 C   s<   |  d}|j|f }||  d}|||j|| d S )NZnewnameZoldnamegetprefixZget_typeadd_typensr   r   r   idnametyper   r   r   typedef#   s   
r   c                 C   6   |  d}|j|f }|d}|||j|| d S Nr   ZCARD32r   r   r   r   r   xidtype)      

r   c                 C   r   r   r   r   r   r   r   xidunion/   r    r!   c                 C   6   |  d}|j|f }t|| }|||j|| d S Nr   )r   r   Enumr   r   r   r   r   r   enum5   r    r%   c                 C   r"   r#   )r   r   ZStructr   r   r   r   r   r   struct;   r    r&   c                 C   r"   r#   )r   r   ZEventStructr   r   r   r   r   r   eventstructA   r    r'   c                 C   r"   r#   )r   r   ZUnionr   r   r   r   r   r   unionG   r    r(   c                 C   s2   |  d}|j|f }t|| }|||| d S r#   )r   r   ZRequestZadd_requestr   r   r   r   requestM   s   

r)   c                 C   F   |  d}|j|f }t|| }||  d|d |||| d S Nr   numberT)r   r   ZEvent
add_opcode	add_eventr   r   r   r   r   eventr   r   r   r0   S   
   

r0   c                 C   L   |  d}|j|f }||  d}||  d|d |||| d S Nr   refr,   F)r   r   Z	get_eventr-   r.   r/   r   r   r   	eventcopyZ   
   
r5   c                 C   r*   r+   )r   r   Errorr-   	add_errorr   r   r   r   r   errorr   r   r   r:   a   r1   r:   c                 C   r2   r3   )r   r   Z	get_errorr-   r8   r9   r   r   r   	errorcopyh   r6   r;   )importr   r   r!   r%   r&   r'   r(   r)   r0   r5   r:   r;   c                 C   s&   t |jD ]}t|j || | qd S )N)listrootfuncstag)r   r   eltr   r   r   r   }   s   r   )__doc__Zos.pathr   sysr   Zxml.etree.ElementTreer   Zxml.etree.cElementTreeZxcbgen.xtypesr   r   r   r!   r%   r&   r'   r(   r)   r0   r5   r:   r;   r?   r   r   r   r   r   <module>   sF    