a
    *=ic$                    @   s%  d Z ddlmZmZmZ ddlT ddlZddlZddl	Z	e	j
d dkr`G dd deZdd	 Zn,e	j
d d
kreZdd Zeee_dd	 Ze	j
dd
 dkrddlmZ nddlZz
ejZW n ey   dd ZY n0 eeZi ZG dd deZG dd deZG dd deZG dd deZ G dd deZ!G dd deZ"G dd deZ#G d d! d!eZ$G d"d# d#eZ%G d$d% d%eZ&G d&d' d'eZ'G d(d) d)e'Z(e(d*e(_)e(d
e(_*e(de(_+e(d+e(_,e(d,e(_-e(d-e(_.e(d.e(_/e(d/e(_0e(d0e(_1e(d1e(_2e(d2e(_3e(d3e(_4e(d4e(_5e(d5e(_6e(d6e(_7e(d7e(_8e(d8e(_9e(d9e(_:e(d:e(_;e(d;e(_<e(d<e(_=e(d=e(_>e(d>e(_?e(d?e(_@e(d@e(_Ae(dAe(_Be(dBe(_Ce(dCe(_De(dDe(_Ee(dEe(_Fe(dFe(_Ge(dGe(_He(dHe(_Ie(dIe(_Je(dJe(_Ke(dKe(_Le(dLe(_Me(dMe(_Ne(dNe(_Oe(dOe(_Pe(dPe(_Qe(dQe(_Re(dRe(_Se(dSe(_Te(dTe(_Ue(dUe(_Ve(dVe(_We(dWe(_Xe(dXe(_Ye(dYe(_Ze(dZe(_[e(d[e(_\e(d\e(_]e(d]e(_^e(d^e(__e(d_e(_`e(d`e(_ae(dae(_be(dbe(_ce(dce(_de(dde(_ee(dee(_fe(dfe(_ge(dge(_he(dhe(_ie(die(_je(dje(_ke(dke(_le(dle(_me(dme(_ne(dne(_oe(doe(_pe(dpe(_qe(dqe(_re(dre(_se(dse(_te(dte(_ue(due(_ve(dve(_we(dwe(_xe(dxe(_ye(dye(_ze(dze(_{e(d{e(_|e(d|e(_}e(d}e(_~e(d~e(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(dÃe(_e(dăe(_e(dŃe(_e(dƃe(_e(dǃe(_e(dȃe(_e(dɃe(_e(dʃe(_e(d˃e(_e(d̃e(_e(d̓e(_e(d΃e(_e(dσe(_e(dЃe(_e(dуe(_e(d҃e(_e(dӃe(_e(dԃe(_e(dՃe(_e(dփe(_e(d׃e(_e(d؃e(_e(dكe(_e(dڃe(_e(dۃe(_e(d܃e(_e(d݃e(_e(dރe(_e(d߃e(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_ e(d e(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_	e(d	e(_
e(d
e(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_e(de(_G dd de'Zede_ed*e_ed
e_ede_ed+e_G dd de'Zede_ ed*e_!ed
e_"ede_#ed+e_$ed,e_%ed-e_&ed.e_'ed/e_(G dd deZ)G dd deZ*e*de*_+e*d*e*_ e*d
e*_,e*de*_-e*d+e*_.e*d,e*_/e*d-e*_0e*d.e*_1G d d! d!e'Z2e2de2_3e2d*e2_4e2d
e2_5e2de2_6G d"d# d#e'Z7e7de7_+e7d*e7_8e7d
e7_9e7de7_:e7d+e7_ G d$d% d%e'Z;e;de;_+e;d*e;_<e;d
e;_=e;de;_>e;d+e;_?e;d,e;_@e;d-e;_Ae;d.e;_Be;d/e;_Ce;d0e;_De;d1e;_Ee;d2e;_Fe;d3e;_Ge;d4e;_He;d5e;_Ie;d6e;_Je;d7e;_Ke;d8e;_Le;d9e;_Me;d:e;_Ne;d;e;_Oe;d<e;_Pe;d=e;_Qe;d>e;_Re;d?e;_e;d@e;_Se;dAe;_Te;dBe;_Ue;dCe;_Ve;dDe;_We;dEe;_Xe;dFe;_Ye;dOe;_Ze;d^e;_[e;d_e;_e;d`e;_\e;dae;_]e;dbe;_^e;dce;__e;dde;_`e;dee;_ae;dfe;_be;dge;_ce;dhe;_de;die;_ee;dje;_fe;dke;_ge;dle;_he;dme;_ie;dne;_je;doe;_ke;dpe;_0e;dqe;_le;dre;_me;dse;_ne;dte;_oe;due;_pe;dve;_qe;dwe;_re;dxe;_se;dye;_te;dze;_ue;d{e;_ve;d|e;_we;d}e;_xe;d~e;_ye;de;_ze;de;_{e;de;_|e;de;_}e;de;_~e;de;_e;de;_e;de;_e;de;_e;de;_e;de;_e;de;_e;de;_e;de;_e;de;_e;de;_e;de;_e;de;_e;de;_e;de;_e;d&e;_e;d'e;_e;d(e;_e;d)e;_e;d*e;_e;d+e;_e;d,e;_e;d-e;_e;d.e;_e;d/e;_G d0d1 d1e'Zede_ ed*e_ed
e_G d2d3 d3e'Zede_+ed*e_ed
e_ede_ed+e_G d4d5 d5e'Zede_ ed*e_"ed
e_-G d6d7 d7eZG d8d9 d9eZG d:d; d;eZd<d=d>d?d@dAdBdCdDdEdFdGdHdIZG dJdK dKeZedLedMedNedOedPedQedRedSedTedUedVedWedXedYedZed[ed\ed]ed^ed_ed`daZG dbdc dceZeddedeedfedgdhZG didj djeZG dkdl dleZG dmdn dneZG dodp dpeZG dqdr dreZG dsdt dteZG dudv dveZG dwdx dxeZG dydz dzeZG d{d| d|eZG d}d~ d~eZG dd deZedeee!eeed< eee)e)eed< eee)eed< deeeeee)gfdegfdeeegeejfdegeejfdeegeejfdegfdeegefdegefdeege e jfdege e jfdege e jfdegefdeeeeeeegeefdeege#fdegefdeegefdeegefde)gefde)gefde)gefde)gefde)gefde)gefde)gefde)gefde)gefde)gefde)gefde)gefdg efdegefdegfde#gfdegfde gfdeeeegfdegfde)e)gefde!e!gefde"e"gefdeegefde#ege e jfdeegeejfdegeejfdegefde)gefde)ge)e)jfdegeejfde#gefdegefdege e jfdeegefdeegefdeege e jfdegefde geejfdee!ge)fde)gefde)ge)e)jfde)ge e jfde)ge"fde)ge)e)jfde)ge!fdÐe)ge)e)jfdĐe)eege"fdŐe)geejfdƐe)ge)e)jfdǐe)ge e jfdȐe)geejfdɐe)ge e jfdʐe)ge e jfdːe)gefd̐e)ge e jfdeegefde#gefde#ge e jfde#eee"ge e jfdeegefde#ge!fde#gefde#gefde#ee ge e jfde#ege"fde#gefde#ge e jfdِegeejfdڐe)gefdېe)gefdܐe)geejfdݐeegefdސege e jfdߐegefde)geejfde)geejfdeed egfde!eeeeeeeegfdeeeege!fdeeege!fdde)fdegefdegefdegefdegefdegefde)gefde)ege)e)jfdegeejfde!e!ge"fde"ge!fde"ge!fdegeejfde)ge)e)jfde)gefdeege"fdegefdeege!fdeege e jfdege)e)jfdege e jfdegeejfdege)e)jfde)geejfdege e jfdege e jfd ege e jfde)gefde(gefdegefde)gefde(gefde(gefdeegefdegefd	e(gefd
egefde(gefde(gefdegefde(gefde(gefde(gefde)gefdegefdeeeeeeegefdeeeegefdeeegefdee"eeeeegfde)ed egefde)gefde)ege)e)jfde)gefde)egejfde)egeejfde)egefde)egefde)gefd e)gefd!e)ge e jfd"e)ge e jfd#e)gefd$egefd%egeejfd&egefd'eegeejfd(eegefd)egefd*egefd+egeejfd,eed egefgZG d-d. d.eZd/d0 Zd1d2 ZG d3d4 d4eZĐd5d6 ZŐeă ZƐeŃ  g d7ZdS (8  a  
Clang Indexing Library Bindings
===============================

This module provides an interface to the Clang indexing library. It is a
low-level interface to the indexing library which attempts to match the Clang
API directly while also being "pythonic". Notable differences from the C API
are:

 * string results are returned as Python strings, not CXString objects.

 * null cursors are translated to None.

 * access to child cursors is done via iteration, not visitation.

The major indexing objects are:

  Index

    The top-level object which manages some global library state.

  TranslationUnit

    High-level object encapsulating the AST for a single translation unit. These
    can be loaded from .ast files or parsed on the fly.

  Cursor

    Generic object for representing a node in the AST.

  SourceRange, SourceLocation, and File

    Objects representing information about the input source.

Most object information is exposed using properties, when the underlying API
call is efficient.
    )absolute_importdivisionprint_function)*N   c                       sN   e Zd Zd fdd	Zdd Ze fddZedd	 Ze	d
d Z
  ZS )c_interop_stringNc                    s4   |d u rd}t |tr |d}tt| | d S )N utf8)
isinstancestrencodesuperc_char_p__init__)selfp	__class__ ]/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/clang/cindex.pyr   K   s
    

zc_interop_string.__init__c                 C   s   | j S Nvaluer   r   r   r   __str__R   s    zc_interop_string.__str__c                    s&   t t| jd u rd S t t| jdS Nr	   )r   r   r   decoder   r   r   r   r   U   s    zc_interop_string.valuec                 C   sL   t |tr| |S t |tr$| |S |d u r0d S tdt|j| jd S )NzCannot convert '{}' to '{}')r
   r   bytes	TypeErrorformattype__name__)clsparamr   r   r   
from_param[   s    

zc_interop_string.from_paramc                 G   s   | j S r   r   xargsr   r   r   to_python_stringf   s    z!c_interop_string.to_python_string)N)r!   
__module____qualname__r   r   propertyr   classmethodr$   staticmethodr(   __classcell__r   r   r   r   r   I   s   

r   c                 C   s   t | tr| S | dS r   )r
   r   r   r&   r   r   r   bj   s    
r0      c                 G   s   | S r   r   r%   r   r   r   _to_python_stringt   s    r2   c                 C   s   | S r   r   r/   r   r   r   r0   y   s    )r      )abcc                 C   s   | S r   r   r/   r   r   r   fspath   s    r5   c                   @   s   e Zd ZdZdS )TranslationUnitLoadErrora  Represents an error that occurred when loading a TranslationUnit.

    This is raised in the case where a TranslationUnit could not be
    instantiated due to failure in the libclang library.

    FIXME: Make libclang expose additional error information in this scenario.
    N)r!   r)   r*   __doc__r   r   r   r   r6      s   r6   c                   @   s$   e Zd ZdZdZdZdZdd ZdS )TranslationUnitSaveErrorzRepresents an error that occurred when saving a TranslationUnit.

    Each error has associated with it an enumerated value, accessible under
    e.save_error. Consumers can compare the value with one of the ERROR_
    constants in this class.
       r1   r   c                 C   sH   t |tsJ |dk s|dkr*td| || _t| d||f  d S )Nr9   r   znEncountered undefined TranslationUnit save error constant: %d. Please file a bug to have this value supported.Error %d: %s)r
   int	ExceptionZ
save_errorr   r   enumerationmessager   r   r   r      s    z!TranslationUnitSaveError.__init__N)r!   r)   r*   r7   ERROR_UNKNOWNZERROR_TRANSLATION_ERRORSZERROR_INVALID_TUr   r   r   r   r   r8      s
   	r8   c                   @   s"   e Zd ZdZdd ZdddZdS )CachedPropertya  Decorator that lazy-loads the value of a property.

    The first time the property is accessed, the original property function is
    executed. The value it returns is set as the new value of that instance's
    property, replacing the original method.
    c                 C   s$   || _ z|j| _W n   Y n0 d S r   )wrappedr7   )r   rB   r   r   r   r      s
    zCachedProperty.__init__Nc                 C   s*   |d u r| S |  |}t|| j j| |S r   )rB   setattrr!   )r   instanceZinstance_typer   r   r   r   __get__   s
    
zCachedProperty.__get__)N)r!   r)   r*   r7   r   rE   r   r   r   r   rA      s   rA   c                   @   s6   e Zd ZdZdefdefgZdd Zed	ddZ	dS )
	_CXStringz)Helper for transforming CXString results.spellingfreec                 C   s   t j|  d S r   )conflibclang_disposeStringr   r   r   r   __del__   s    z_CXString.__del__Nc                 C   s   t | tsJ tj| S r   )r
   rF   rI   rJ   clang_getCStringresfnr'   r   r   r   from_result   s    z_CXString.from_result)NN)
r!   r)   r*   r7   r   c_int_fields_rL   r-   rQ   r   r   r   r   rF      s
   rF   c                   @   s   e Zd ZdZded fdefgZdZdd Ze	dd	 Z
e	d
d Zedd Zedd Zedd Zedd Zdd Zdd Zdd ZdS )SourceLocationzQ
    A SourceLocation represents a particular location within a source file.
    ptr_datar1   int_dataNc                 C   s   | j d u r|t t t t f\}}}}tj| t|t|t|t| |rXt|}nd }|t|j	t|j	t|j	f| _ | j S r   )
_data
c_object_pc_uintrI   rJ   clang_getInstantiationLocationbyrefFiler;   r   )r   flcor   r   r   _get_instantiation   s    

 z!SourceLocation._get_instantiationc                 C   s   t j| |||S )z
        Retrieve the source location associated with a given file/line/column in
        a particular translation unit.
        )rI   rJ   clang_getLocation)tufilelinecolumnr   r   r   from_position   s    zSourceLocation.from_positionc                 C   s   t j| ||S )zRetrieve a SourceLocation from a given character offset.

        tu -- TranslationUnit file belongs to
        file -- File instance to obtain offset from
        offset -- Integer character offset within file
        )rI   rJ   clang_getLocationForOffset)rc   rd   offsetr   r   r   from_offset  s    zSourceLocation.from_offsetc                 C   s   |   d S )z1Get the file represented by this source location.r   ra   r   r   r   r   rd     s    zSourceLocation.filec                 C   s   |   d S )z1Get the line represented by this source location.r9   rk   r   r   r   r   re     s    zSourceLocation.linec                 C   s   |   d S )z3Get the column represented by this source location.r1   rk   r   r   r   r   rf     s    zSourceLocation.columnc                 C   s   |   d S )z8Get the file offset represented by this source location.r   rk   r   r   r   r   ri     s    zSourceLocation.offsetc                 C   s   t j| |S r   )rI   rJ   clang_equalLocationsr   otherr   r   r   __eq__!  s    zSourceLocation.__eq__c                 C   s   |  | S r   ro   rm   r   r   r   __ne__$  s    zSourceLocation.__ne__c                 C   s&   | j r| j j}nd }d|| j| jf S )Nz,<SourceLocation file %r, line %r, column %r>)rd   namere   rf   r   filenamer   r   r   __repr__'  s    

zSourceLocation.__repr__)r!   r)   r*   r7   c_void_prY   rS   rW   ra   r-   rg   rj   r+   rd   re   rf   ri   ro   rq   ru   r   r   r   r   rT      s&   

	



rT   c                   @   sn   e Zd ZdZded fdefdefgZedd Ze	dd	 Z
e	d
d Zdd Zdd Zdd Zdd ZdS )SourceRangezY
    A SourceRange describes a range of source locations within the source
    code.
    rU   r1   Zbegin_int_dataZend_int_datac                 C   s   t j| |S r   )rI   rJ   clang_getRangestartendr   r   r   from_locations;  s    zSourceRange.from_locationsc                 C   s   t j| S )zi
        Return a SourceLocation representing the first character within a
        source range.
        )rI   rJ   clang_getRangeStartr   r   r   r   rz   ?  s    zSourceRange.startc                 C   s   t j| S )zh
        Return a SourceLocation representing the last character within a
        source range.
        )rI   rJ   clang_getRangeEndr   r   r   r   r{   G  s    zSourceRange.endc                 C   s   t j| |S r   )rI   rJ   clang_equalRangesrm   r   r   r   ro   O  s    zSourceRange.__eq__c                 C   s   |  | S r   rp   rm   r   r   r   rq   R  s    zSourceRange.__ne__c                 C   s   t |tsdS |jdu r&| jjdu r&n(| jjj|jjksJ|jj| jjjkrNdS | jj|j  k rl| jjk rtn ndS | jj|jkr| jj|jkrdS n |j| jjkr|j| jjkrdS dS )z$Useful to detect the Token/Lexer bugFNT)r
   rT   rd   rz   rr   r{   re   rf   rm   r   r   r   __contains__U  s"    
"zSourceRange.__contains__c                 C   s   d| j | jf S )Nz<SourceRange start %r, end %r>ry   r   r   r   r   ru   l  s    zSourceRange.__repr__N)r!   r)   r*   r7   rv   rY   rS   r-   r|   r+   rz   r{   ro   rq   r   ru   r   r   r   r   rw   /  s   



rw   c                   @   s   e 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d Zdd Zedd Zedd Zedd Zedd Zedd Zedd Zedd Zedd Zedd  Zed!d" Zd,d$d%Zd&d' Zd(d) Zd*d+ Z d#S )-
Diagnosticz
    A Diagnostic is a single instance of a Clang diagnostic. It includes the
    diagnostic severity, the message, the location the diagnostic occurred, as
    well as additional source ranges and associated fix-it hints.
    r   r9   r1   r                ?   c                 C   s
   || _ d S r   ptrr   r   r   r   r   r     s    zDiagnostic.__init__c                 C   s   t j|  d S r   )rI   rJ   clang_disposeDiagnosticr   r   r   r   rL     s    zDiagnostic.__del__c                 C   s   t j| S r   )rI   rJ   clang_getDiagnosticSeverityr   r   r   r   severity  s    zDiagnostic.severityc                 C   s   t j| S r   )rI   rJ   clang_getDiagnosticLocationr   r   r   r   location  s    zDiagnostic.locationc                 C   s   t j| S r   )rI   rJ   clang_getDiagnosticSpellingr   r   r   r   rG     s    zDiagnostic.spellingc                 C   s   G dd dt }|| S )Nc                   @   s$   e Zd Zdd Zdd Zdd ZdS )z(Diagnostic.ranges.<locals>.RangeIteratorc                 S   s
   || _ d S r   diagr   r   r   r   r   r     s    z1Diagnostic.ranges.<locals>.RangeIterator.__init__c                 S   s   t tj| jS r   )r;   rI   rJ   clang_getDiagnosticNumRangesr   r   r   r   r   __len__  s    z0Diagnostic.ranges.<locals>.RangeIterator.__len__c                 S   s    |t | krttj| j|S r   )len
IndexErrorrI   rJ   clang_getDiagnosticRanger   r   keyr   r   r   __getitem__  s    z4Diagnostic.ranges.<locals>.RangeIterator.__getitem__Nr!   r)   r*   r   r   r   r   r   r   r   RangeIterator  s   r   object)r   r   r   r   r   ranges  s    zDiagnostic.rangesc                 C   s   G dd dt }|| S )Nc                   @   s$   e Zd Zdd Zdd Zdd ZdS )z(Diagnostic.fixits.<locals>.FixItIteratorc                 S   s
   || _ d S r   r   r   r   r   r   r     s    z1Diagnostic.fixits.<locals>.FixItIterator.__init__c                 S   s   t tj| jS r   )r;   rI   rJ   clang_getDiagnosticNumFixItsr   r   r   r   r   r     s    z0Diagnostic.fixits.<locals>.FixItIterator.__len__c                 S   s6   t  }tj| j|t|}t|dkr,tt||S Nr   )	rw   rI   rJ   clang_getDiagnosticFixItr   r[   r   r   FixIt)r   r   ranger   r   r   r   r     s    z4Diagnostic.fixits.<locals>.FixItIterator.__getitem__Nr   r   r   r   r   FixItIterator  s   r   r   )r   r   r   r   r   fixits  s    zDiagnostic.fixitsc                 C   s   G dd dt }|| S )Nc                   @   s$   e Zd Zdd Zdd Zdd ZdS )z5Diagnostic.children.<locals>.ChildDiagnosticsIteratorc                 S   s   t j|| _d S r   )rI   rJ   clang_getChildDiagnosticsdiag_setr   r   r   r   r     s    z>Diagnostic.children.<locals>.ChildDiagnosticsIterator.__init__c                 S   s   t tj| jS r   )r;   rI   rJ   clang_getNumDiagnosticsInSetr   r   r   r   r   r     s    z=Diagnostic.children.<locals>.ChildDiagnosticsIterator.__len__c                 S   s    t j| j|}|stt|S r   )rI   rJ   clang_getDiagnosticInSetr   r   r   r   r   r   r   r   r   r     s    zADiagnostic.children.<locals>.ChildDiagnosticsIterator.__getitem__Nr   r   r   r   r   ChildDiagnosticsIterator  s   r   r   )r   r   r   r   r   children  s    zDiagnostic.childrenc                 C   s   t j| S )z<The category number for this diagnostic or 0 if unavailable.)rI   rJ   clang_getDiagnosticCategoryr   r   r   r   category_number  s    zDiagnostic.category_numberc                 C   s   t j| S )z4The string name of the category for this diagnostic.)rI   rJ   clang_getDiagnosticCategoryTextr   r   r   r   category_name  s    zDiagnostic.category_namec                 C   s   t j| dS )z5The command-line option that enables this diagnostic.N)rI   rJ   clang_getDiagnosticOptionr   r   r   r   option  s    zDiagnostic.optionc                 C   s"   t  }tj| t| t |S )z6The command-line option that disables this diagnostic.)rF   rI   rJ   r   r[   rQ   )r   disabler   r   r   disable_option  s    zDiagnostic.disable_optionNc                 C   s4   |du rt j }|tj @ r&tdt j| |S )z
        Format this diagnostic for display. The options argument takes
        Diagnostic.Display* flags, which can be combined using bitwise OR. If
        the options argument is not provided, the default display options will
        be used.
        NzInvalid format options)rI   rJ   %clang_defaultDiagnosticDisplayOptionsr   _FormatOptionsMask
ValueErrorclang_formatDiagnostic)r   optionsr   r   r   r     s
    
zDiagnostic.formatc                 C   s   d| j | j| jf S )Nz2<Diagnostic severity %r, location %r, spelling %r>)r   r   rG   r   r   r   r   ru     s    zDiagnostic.__repr__c                 C   s   |   S r   )r   r   r   r   r   r     s    zDiagnostic.__str__c                 C   s   | j S r   r   r   r   r   r   r$     s    zDiagnostic.from_param)N)!r!   r)   r*   r7   ZIgnoredZNoteWarningErrorZFatalZDisplaySourceLocationZDisplayColumnZDisplaySourceRangesZDisplayOptionZDisplayCategoryIdZDisplayCategoryNamer   r   rL   r+   r   r   rG   r   r   r   r   r   r   r   r   ru   r   r$   r   r   r   r   r   o  sN   










r   c                   @   s    e Zd ZdZdd Zdd ZdS )r   z
    A FixIt represents a transformation to be applied to the source to
    "fix-it". The fix-it shouldbe applied by replacing the given source range
    with the given value.
    c                 C   s   || _ || _d S r   r   r   )r   r   r   r   r   r   r     s    zFixIt.__init__c                 C   s   d| j | jf S )Nz<FixIt range %r, value %r>r   r   r   r   r   ru     s    zFixIt.__repr__N)r!   r)   r*   r7   r   ru   r   r   r   r   r     s   r   c                   @   s,   e Zd ZdZdd Zdd Zedd ZdS )	
TokenGroupaf  Helper class to facilitate token management.

    Tokens are allocated from libclang in chunks. They must be disposed of as a
    collective group.

    One purpose of this class is for instances to represent groups of allocated
    tokens. Each token in a group contains a reference back to an instance of
    this class. When all tokens from a group are garbage collected, it allows
    this class to be garbage collected. When this class is garbage collected,
    it calls the libclang destructor which invalidates all tokens in the group.

    You should not instantiate this class outside of this module.
    c                 C   s   || _ || _|| _d S r   )_tu_memory_count)r   rc   Zmemorycountr   r   r   r     s    zTokenGroup.__init__c                 C   s   t j| j| j| j d S r   )rI   rJ   clang_disposeTokensr   r   r   r   r   r   r   rL     s    zTokenGroup.__del__c           	      c   s   t t }t }tj| |t|t| t|j}|dk r@dS t	|t t| j
}t| ||}td|D ]4}t }|| j|_|| j|_| |_||_|V  qjdS )zHelper method to return all tokens in an extent.

        This functionality is needed multiple places in this module. We define
        it here because it seems like a logical place.
        r9   Nr   )POINTERTokenrY   rI   rJ   clang_tokenizer[   r;   r   castcontentsr   r   rV   rU   r   _group)	rc   extentZtokens_memoryZtokens_countr   Ztokens_arrayZtoken_groupitokenr   r   r   
get_tokens  s"    

zTokenGroup.get_tokensN)r!   r)   r*   r7   r   rL   r-   r   r   r   r   r   r     s
   r   c                   @   s<   e Zd ZdZi Zdd Zdd Zedd Zedd	 Z	d
S )	TokenKindz%Describes a specific type of a Token.c                 C   s   || _ || _dS )z@Create a new TokenKind instance from a numeric value and a name.N)r   rr   )r   r   rr   r   r   r   r   B  s    zTokenKind.__init__c                 C   s   d| j f S )NzTokenKind.%srr   r   r   r   r   ru   G  s    zTokenKind.__repr__c                 C   s&   t j| d}|du r"td|  |S )z6Obtain a registered TokenKind instance from its value.NzUnknown TokenKind: %d)r   
_value_mapgetr   )r   resultr   r   r   
from_valueJ  s    zTokenKind.from_valuec                 C   s:   | t jv rtd|  t | |}|t j| < tt || dS )zRegister a new TokenKind enumeration.

        This should only be called at module load time by code within this
        package.
        z TokenKind already registered: %dN)r   r   r   rC   )r   rr   kindr   r   r   registerT  s
    


zTokenKind.registerN)
r!   r)   r*   r7   r   r   ru   r-   r   r   r   r   r   r   r   =  s   
	r   c                   @   s@   e Zd ZdZdd Zdd Zedd Zedd	 Z	d
d Z
dS )BaseEnumerationa!  
    Common base class for named enumerations held in sync with Index.h values.

    Subclasses must define their own _kinds and _name_map members, as:
    _kinds = []
    _name_map = None
    These values hold the per-subclass instances and value-to-name mappings,
    respectively.

    c                 C   sz   |t | jjkr6| j jd g|t | jj d  7  _| jj| d ur\tdt| j||| _| | jj|< d | j_d S )Nr9   z{0} value {1} already loaded)r   r   _kindsr   r   r   r   	_name_mapr   r   r   r   r   r   o  s    &
zBaseEnumeration.__init__c                 C   s   | j S r   r   r   r   r   r   r$   z  s    zBaseEnumeration.from_paramc                 C   sF   | j du r<i | _ | jj D ]\}}t|| jr|| j |< q| j |  S )z-Get the enumeration name of this cursor kind.N)r   r   __dict__itemsr
   r   r   r   r   r   r   rr   }  s    
zBaseEnumeration.namec                 C   s2   |t | jks| j| d u r(td| | j| S )Nz!Unknown template argument kind %d)r   r   r   )r"   idr   r   r   from_id  s    zBaseEnumeration.from_idc                 C   s   d| j | jf S )Nz%s.%s)r   rr   r   r   r   r   ru     s    zBaseEnumeration.__repr__N)r!   r)   r*   r7   r   r$   r+   rr   r,   r   ru   r   r   r   r   r   c  s   
	
r   c                   @   st   e Zd ZdZg ZdZe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S )
CursorKindzL
    A CursorKind describes the kind of entity that a cursor points to.
    Nc                   C   s   dd t jD S )z,Return all CursorKind enumeration instances.c                 S   s   g | ]}|d ur|qS r   r   .0r&   r   r   r   
<listcomp>      z,CursorKind.get_all_kinds.<locals>.<listcomp>)r   r   r   r   r   r   get_all_kinds  s    zCursorKind.get_all_kindsc                 C   s   t j| S )z#Test if this is a declaration kind.)rI   rJ   clang_isDeclarationr   r   r   r   is_declaration  s    zCursorKind.is_declarationc                 C   s   t j| S )z!Test if this is a reference kind.)rI   rJ   clang_isReferencer   r   r   r   is_reference  s    zCursorKind.is_referencec                 C   s   t j| S )z#Test if this is an expression kind.)rI   rJ   clang_isExpressionr   r   r   r   is_expression  s    zCursorKind.is_expressionc                 C   s   t j| S )z!Test if this is a statement kind.)rI   rJ   clang_isStatementr   r   r   r   is_statement  s    zCursorKind.is_statementc                 C   s   t j| S )z"Test if this is an attribute kind.)rI   rJ   clang_isAttributer   r   r   r   is_attribute  s    zCursorKind.is_attributec                 C   s   t j| S )z Test if this is an invalid kind.)rI   rJ   clang_isInvalidr   r   r   r   
is_invalid  s    zCursorKind.is_invalidc                 C   s   t j| S )z(Test if this is a translation unit kind.)rI   rJ   clang_isTranslationUnitr   r   r   r   is_translation_unit  s    zCursorKind.is_translation_unitc                 C   s   t j| S )z%Test if this is a preprocessing kind.)rI   rJ   clang_isPreprocessingr   r   r   r   is_preprocessing  s    zCursorKind.is_preprocessingc                 C   s   t j| S )z"Test if this is an unexposed kind.)rI   rJ   clang_isUnexposedr   r   r   r   is_unexposed  s    zCursorKind.is_unexposedc                 C   s   d| j f S )NzCursorKind.%sr   r   r   r   r   ru     s    zCursorKind.__repr__)r!   r)   r*   r7   r   r   r-   r   r   r   r   r   r   r   r   r   r   ru   r   r   r   r   r     s   
r   r9   r         r3   r   	   
                  r                                                r   !   "   #   $   %   &   '   (   )   *   +   ,   -   .   /   0   1   2   F   G   H   I   d   e   f   g   h   i   j   k   l   m   n   o   p   q   r   s   t   u   v   w   x   y   z   {   |   }   ~                                                                                                                                                                                                                                                            i  i  i  i  i  i  i  i  i	  i
  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i   i!  i"  i#  i$  i%  i&  i'  i(  i)  i*  i,  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  iX  iY  iZ  i[  i  c                   @   s   e Zd ZdZg ZdZdS )TemplateArgumentKindzf
    A TemplateArgumentKind describes the kind of entity that a template argument
    represents.
    N)r!   r)   r*   r7   r   r   r   r   r   r   r    s   r  c                   @   s    e Zd ZdZg ZdZdd ZdS )ExceptionSpecificationKindzn
    An ExceptionSpecificationKind describes the kind of exception specification
    that a function has.
    Nc                 C   s   d | jS )NzExceptionSpecificationKind.{})r   rr   r   r   r   r   ru     s    z#ExceptionSpecificationKind.__repr__r!   r)   r*   r7   r   r   ru   r   r   r   r   r    s   r  c                   @   s~  e Zd ZdZdefdefded fgZe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d d! Zd"d# Zd$d% Zd&d' Zd(d) Zd*d+ Zed,d- Zed.d/ Zed0d1 Zed2d3 Zed4d5 Z ed6d7 Z!ed8d9 Z"ed:d; Z#ed<d= Z$ed>d? Z%ed@dA Z&edBdC Z'edDdE Z(edFdG Z)edHdI Z*edJdK Z+edLdM Z,edNdO Z-edPdQ Z.edRdS Z/edTdU Z0edVdW Z1edXdY Z2edZd[ Z3ed\d] Z4ed^d_ Z5d`da Z6dbdc Z7ddde Z8dfdg Z9dhdi Z:djdk Z;dldm Z<dndo Z=dpdq Z>drds Z?dtdu Z@dvdw ZAdxdy ZBedzd{ ZCed|d} ZDd~S )Cursorzr
    The Cursor class represents a reference to an element within the AST. It
    acts as a kind of iterator.
    _kind_idZxdatadatar   c                 C   s   t j| |}| |_|S r   )rI   rJ   clang_getCursorr   )rc   r   cursorr   r   r   from_location  s    zCursor.from_locationc                 C   s   t j| |S r   )rI   rJ   clang_equalCursorsrm   r   r   r   ro     s    zCursor.__eq__c                 C   s   |  | S r   rp   rm   r   r   r   rq     s    zCursor.__ne__c                 C   s   t j| S )zw
        Returns true if the declaration pointed at by the cursor is also a
        definition of that entity.
        )rI   rJ   clang_isCursorDefinitionr   r   r   r   is_definition  s    zCursor.is_definitionc                 C   s   t j| S )zReturns True if the cursor refers to a C++ member function or member
        function template that is declared 'const'.
        )rI   rJ   clang_CXXMethod_isConstr   r   r   r   is_const_method  s    zCursor.is_const_methodc                 C   s   t j| S )zKReturns True if the cursor refers to a C++ converting constructor.
        )rI   rJ   ,clang_CXXConstructor_isConvertingConstructorr   r   r   r   is_converting_constructor  s    z Cursor.is_converting_constructorc                 C   s   t j| S )zEReturns True if the cursor refers to a C++ copy constructor.
        )rI   rJ   &clang_CXXConstructor_isCopyConstructorr   r   r   r   is_copy_constructor  s    zCursor.is_copy_constructorc                 C   s   t j| S )zHReturns True if the cursor refers to a C++ default constructor.
        )rI   rJ   )clang_CXXConstructor_isDefaultConstructorr   r   r   r   is_default_constructor  s    zCursor.is_default_constructorc                 C   s   t j| S )zEReturns True if the cursor refers to a C++ move constructor.
        )rI   rJ   &clang_CXXConstructor_isMoveConstructorr   r   r   r   is_move_constructor  s    zCursor.is_move_constructorc                 C   s   t j| S )zReturns True if the cursor refers to a C++ member function or member
        function template that is declared '= default'.
        )rI   rJ   clang_CXXMethod_isDefaultedr   r   r   r   is_default_method  s    zCursor.is_default_methodc                 C   s   t j| S )z]Returns True if the cursor refers to a C++ field that is declared
        'mutable'.
        )rI   rJ   clang_CXXField_isMutabler   r   r   r   is_mutable_field!  s    zCursor.is_mutable_fieldc                 C   s   t j| S )zReturns True if the cursor refers to a C++ member function or member
        function template that is declared pure virtual.
        )rI   rJ   clang_CXXMethod_isPureVirtualr   r   r   r   is_pure_virtual_method'  s    zCursor.is_pure_virtual_methodc                 C   s   t j| S )zReturns True if the cursor refers to a C++ member function or member
        function template that is declared 'static'.
        )rI   rJ   clang_CXXMethod_isStaticr   r   r   r   is_static_method-  s    zCursor.is_static_methodc                 C   s   t j| S )zReturns True if the cursor refers to a C++ member function or member
        function template that is declared 'virtual'.
        )rI   rJ   clang_CXXMethod_isVirtualr   r   r   r   is_virtual_method3  s    zCursor.is_virtual_methodc                 C   s   t j| S )zvReturns True if the cursor refers to a C++ record declaration
        that has pure virtual member functions.
        )rI   rJ   clang_CXXRecord_isAbstractr   r   r   r   is_abstract_record9  s    zCursor.is_abstract_recordc                 C   s   t j| S )zHReturns True if the cursor refers to a scoped enum declaration.
        )rI   rJ   clang_EnumDecl_isScopedr   r   r   r   is_scoped_enum?  s    zCursor.is_scoped_enumc                 C   s   t j| S )z
        If the cursor is a reference to a declaration or a declaration of
        some entity, return a cursor that points to the definition of that
        entity.
        )rI   rJ   clang_getCursorDefinitionr   r   r   r   get_definitionD  s    zCursor.get_definitionc                 C   s   t j| S )a  Return the Unified Symbol Resolution (USR) for the entity referenced
        by the given cursor (or None).

        A Unified Symbol Resolution (USR) is a string that identifies a
        particular entity (function, class, variable, etc.) within a
        program. USRs can be compared across translation units to determine,
        e.g., when references in one translation refer to an entity defined in
        another translation unit.)rI   rJ   clang_getCursorUSRr   r   r   r   get_usrN  s    	zCursor.get_usrc                 C   s   | j tjksJ tj| S )zBReturns the File that is included by the current inclusion cursor.)r   r   INCLUSION_DIRECTIVErI   rJ   clang_getIncludedFiler   r   r   r   get_included_fileY  s    zCursor.get_included_filec                 C   s   t | jS )zReturn the kind of this cursor.)r   r   r  r   r   r   r   r   _  s    zCursor.kindc                 C   s   t | dstj| | _| jS )z;Return the spelling of the entity pointed at by the cursor.	_spelling)hasattrrI   rJ   clang_getCursorSpellingr  r   r   r   r   rG   d  s    
zCursor.spellingc                 C   s   t | dstj| | _| jS )a  
        Return the display name for the entity referenced by this cursor.

        The display name contains extra information that helps identify the
        cursor, such as the parameters of a function or template or the
        arguments of a class template specialization.
        _displayname)r  rI   rJ   clang_getCursorDisplayNamer  r   r   r   r   displaynamel  s    	
zCursor.displaynamec                 C   s   t | dstj| | _| jS )zAReturn the mangled name for the entity referenced by this cursor._mangled_name)r  rI   rJ   clang_Cursor_getManglingr  r   r   r   r   mangled_namez  s    
zCursor.mangled_namec                 C   s   t | dstj| | _| jS )zu
        Return the source location (the starting character) of the entity
        pointed at by the cursor.
        _loc)r  rI   rJ   clang_getCursorLocationr  r   r   r   r   r     s    
zCursor.locationc                 C   s$   t | dstj| | _t| jS )z"Return the linkage of this cursor._linkage)r  rI   rJ   Zclang_getCursorLinkager  LinkageKindr   r   r   r   r   linkage  s    
zCursor.linkagec                 C   s$   t | dstj| | _t| jS )z:Return the thread-local storage (TLS) kind of this cursor.	_tls_kind)r  rI   rJ   Zclang_getCursorTLSKindr  TLSKindr   r   r   r   r   tls_kind  s    
zCursor.tls_kindc                 C   s   t | dstj| | _| jS )zv
        Return the source range (the range of text) occupied by the entity
        pointed at by the cursor.
        _extent)r  rI   rJ   clang_getCursorExtentr  r   r   r   r   r     s    
zCursor.extentc                 C   s$   t | dstj| | _t| jS )zf
        Retrieves the storage class (if any) of the entity pointed at by the
        cursor.
        _storage_class)r  rI   rJ   Zclang_Cursor_getStorageClassr  StorageClassr   r   r   r   r   storage_class  s    
zCursor.storage_classc                 C   s$   t | dstj| | _t| jS )zT
        Retrieves the availability of the entity pointed at by the cursor.
        _availability)r  rI   rJ   clang_getCursorAvailabilityr  AvailabilityKindr   r   r   r   r   availability  s    
zCursor.availabilityc                 C   s$   t | dstj| | _t| jS )zi
        Retrieves the access specifier (if any) of the entity pointed at by the
        cursor.
        _access_specifier)r  rI   rJ   clang_getCXXAccessSpecifierr  AccessSpecifierr   r   r   r   r   access_specifier  s    
zCursor.access_specifierc                 C   s   t | dstj| | _| jS )zT
        Retrieve the Type (if any) of the entity pointed at by the cursor.
        _type)r  rI   rJ   clang_getCursorTyper  r   r   r   r   r      s    
zCursor.typec                 C   s   t | dstj| | _| jS )aI  Return the canonical Cursor corresponding to this Cursor.

        The canonical cursor is the cursor which is representative for the
        underlying entity. For example, if you have multiple forward
        declarations for the same class, the canonical cursor for the forward
        declarations will be identical.
        
_canonical)r  rI   rJ   clang_getCanonicalCursorr  r   r   r   r   	canonical  s    	
zCursor.canonicalc                 C   s   t | dstj| | _| jS )z0Retrieve the Type of the result for this Cursor._result_type)r  rI   rJ   clang_getCursorResultTyper  r   r   r   r   result_type  s    
zCursor.result_typec                 C   s(   t | ds"tj| }t|| _| jS )z
        Retrieve the exception specification kind, which is one of the values
        from the ExceptionSpecificationKind enumeration.
        _exception_specification_kind)r  rI   rJ   Z)clang_getCursorExceptionSpecificationTyper  r   r  )r   Zexc_kindr   r   r   exception_specification_kind  s    
z#Cursor.exception_specification_kindc                 C   s,   t | ds&| j sJ tj| | _| jS )zReturn the underlying type of a typedef declaration.

        Returns a Type for the typedef this cursor is a declaration for. If
        the current cursor is not a typedef, this raises.
        _underlying_type)r  r   r   rI   rJ   "clang_getTypedefDeclUnderlyingTyper  r   r   r   r   underlying_typedef_type  s
    

zCursor.underlying_typedef_typec                 C   s.   t | ds(| jtjksJ tj| | _| jS )zReturn the integer type of an enum declaration.

        Returns a Type corresponding to an integer. If the cursor is not for an
        enum, this raises.
        
_enum_type)r  r   r   	ENUM_DECLrI   rJ   clang_getEnumDeclIntegerTyper  r   r   r   r   	enum_type  s    
zCursor.enum_typec              
   C   s   t | ds| jtjksJ | j}|jtjkr6| j}|jtj	tj
tjtjtjtjtjtjtjf	v rttj| | _ntj| | _| jS )z%Return the value of an enum constant._enum_value)r  r   r   ENUM_CONSTANT_DECLr    TypeKindENUMget_declarationr  CHAR_UUCHARCHAR16CHAR32USHORTUINTULONG	ULONGLONGUINT128rI   rJ   &clang_getEnumConstantDeclUnsignedValuer  clang_getEnumConstantDeclValue)r   Zunderlying_typer   r   r   
enum_value  s&    



zCursor.enum_valuec                 C   s   t | dstj| | _| jS )z.Return the Objective-C type encoding as a str._objc_type_encoding)r  rI   rJ   clang_getDeclObjCTypeEncodingr  r   r   r   r   objc_type_encoding(  s    

zCursor.objc_type_encodingc                 C   s   t | dstj| | _| jS )z'Returns a hash of the cursor as an int._hash)r  rI   rJ   clang_hashCursorr  r   r   r   r   hash1  s    
zCursor.hashc                 C   s   t | dstj| | _| jS )z+Return the semantic parent for this cursor._semantic_parent)r  rI   rJ   clang_getCursorSemanticParentr  r   r   r   r   semantic_parent9  s    
zCursor.semantic_parentc                 C   s   t | dstj| | _| jS )z*Return the lexical parent for this cursor._lexical_parent)r  rI   rJ   clang_getCursorLexicalParentr  r   r   r   r   lexical_parentA  s    
zCursor.lexical_parentc                 C   s   | j S )z9Returns the TranslationUnit to which this Cursor belongs.r   r   r   r   r   translation_unitI  s    zCursor.translation_unitc                 C   s   t | dstj| | _| jS )zx
        For a cursor that is a reference, returns a cursor
        representing the entity that it references.
        _referenced)r  rI   rJ   clang_getCursorReferencedr  r   r   r   r   
referencedP  s    
zCursor.referencedc                 C   s   t j| S )z:Returns the brief comment text associated with that Cursor)rI   rJ    clang_Cursor_getBriefCommentTextr   r   r   r   brief_comment[  s    zCursor.brief_commentc                 C   s   t j| S )z8Returns the raw comment text associated with that Cursor)rI   rJ   clang_Cursor_getRawCommentTextr   r   r   r   raw_comment`  s    zCursor.raw_commentc                 c   s0   t j| }td|D ]}t j| |V  qdS )z>Return an iterator for accessing the arguments of this cursor.r   N)rI   rJ   clang_Cursor_getNumArgumentsr   clang_Cursor_getArgument)r   num_argsr   r   r   r   get_argumentse  s    zCursor.get_argumentsc                 C   s   t j| S )z@Returns the number of template args associated with this cursor.)rI   rJ   $clang_Cursor_getNumTemplateArgumentsr   r   r   r   get_num_template_argumentsk  s    z!Cursor.get_num_template_argumentsc                 C   s   t j| |S )zMReturns the TemplateArgumentKind for the indicated template
        argument.)rI   rJ   $clang_Cursor_getTemplateArgumentKindr   numr   r   r   get_template_argument_kindo  s    z!Cursor.get_template_argument_kindc                 C   s   t j| |S )z7Returns the CXType for the indicated template argument.)rI   rJ   $clang_Cursor_getTemplateArgumentTyper  r   r   r   get_template_argument_typet  s    z!Cursor.get_template_argument_typec                 C   s   t j| |S )z?Returns the value of the indicated arg as a signed 64b integer.)rI   rJ   %clang_Cursor_getTemplateArgumentValuer  r   r   r   get_template_argument_valuex  s    z"Cursor.get_template_argument_valuec                 C   s   t j| |S )zBReturns the value of the indicated arg as an unsigned 64b integer.)rI   rJ   -clang_Cursor_getTemplateArgumentUnsignedValuer  r   r   r   $get_template_argument_unsigned_value|  s    z+Cursor.get_template_argument_unsigned_valuec                    s0    fdd}g }t j td || t|S )z=Return an iterator for accessing the children of this cursor.c                    s(   | t j ksJ  j| _||  dS Nr9   rI   rJ   clang_getNullCursorr   append)childparentr   r   r   r   visitor  s    
z$Cursor.get_children.<locals>.visitorcursor_visit)rI   rJ   clang_visitChildren	callbacksiter)r   r)  r   r   r   r   get_children  s    	zCursor.get_childrenc                 c   s,   | V  |   D ]}| D ]
}|V  qqdS )z`Depth-first preorder walk over the cursor and its descendants.

        Yields cursors.
        N)r.  walk_preorder)r   r'  Z
descendantr   r   r   r/    s    zCursor.walk_preorderc                 C   s   t | j| jS )zObtain Token instances formulating that compose this Cursor.

        This is a generator for Token instances. It returns all tokens which
        occupy the extent this cursor occupies.
        )r   r   r   r   r   r   r   r   r     s    zCursor.get_tokensc                 C   s   t j| S )z;Returns the offsetof the FIELD_DECL pointed by this Cursor.)rI   rJ   clang_Cursor_getOffsetOfFieldr   r   r   r   get_field_offsetof  s    zCursor.get_field_offsetofc                 C   s&   | j tjkr| j  S tj| S )z3
        Check if the record is anonymous.
        )	r   r   
FIELD_DECLr    r  is_anonymousrI   rJ   clang_Cursor_isAnonymousr   r   r   r   r3    s    zCursor.is_anonymousc                 C   s   t j| S )z3
        Check if the field is a bitfield.
        )rI   rJ   clang_Cursor_isBitFieldr   r   r   r   is_bitfield  s    zCursor.is_bitfieldc                 C   s   t j| S )z3
        Retrieve the width of a bitfield.
        )rI   rJ   clang_getFieldDeclBitWidthr   r   r   r   get_bitfield_width  s    zCursor.get_bitfield_widthc                 C   sj   t | tsJ | tj kr d S d }|D ]*}t |tr>|} qTt|dr(|j} qTq(|d us`J || _| S Nr  )	r
   r  rI   rJ   r%  TranslationUnitr  r  r   rO   rP   r'   rc   argr   r   r   rQ     s    

zCursor.from_resultc                 C   s0   t | tsJ | tj kr d S |d j| _| S r   )r
   r  rI   rJ   r%  r   rN   r   r   r   from_cursor_result  s
    zCursor.from_cursor_resultN)Er!   r)   r*   r7   rR   rv   rS   r-   r  ro   rq   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r+   r   rG   r  r  r   r  r  r   r  r  r  r    r  r  r  r  r  r  r   r  r  r	  r  r  r  r  r  r  r  r  r   r"  r.  r/  r   r1  r3  r6  r8  rQ   r=  r   r   r   r   r    s   














	


	
















r  c                   @   sH   e Zd ZdZg ZdZdd Zdd Zedd Z	e
d	d
 Zdd ZdS )r  z6
    Describes the storage class of a declaration
    Nc                 C   s`   |t tjkr0t jd g|t tj d  7  _tj| d urFtd|| _| tj|< d t_d S )Nr9   zStorageClass already loaded)r   r  r   r   r   r   r   r   r   r   r     s    "
zStorageClass.__init__c                 C   s   | j S r   r   r   r   r   r   r$     s    zStorageClass.from_paramc                 C   sB   | j du r8i | _ tj D ]\}}t|tr|| j |< q| j |  S )z/Get the enumeration name of this storage class.N)r   r  r   r   r
   r   r   r   r   rr     s    

zStorageClass.namec                 C   s.   | t tjkstj|  s$td|  tj|  S )NzUnknown storage class %d)r   r  r   r   )r   r   r   r   r     s    zStorageClass.from_idc                 C   s   d| j f S )NzStorageClass.%sr   r   r   r   r   ru     s    zStorageClass.__repr__)r!   r)   r*   r7   r   r   r   r$   r+   rr   r-   r   ru   r   r   r   r   r    s   	
	
r  c                   @   s    e Zd ZdZg ZdZdd ZdS )r  z2
    Describes the availability of an entity.
    Nc                 C   s   d| j f S )NzAvailabilityKind.%sr   r   r   r   r   ru     s    zAvailabilityKind.__repr__r  r   r   r   r   r    s   r  c                   @   s(   e Zd ZdZg ZdZdd Zdd ZdS )r  z4
    Describes the access of a C++ class member
    Nc                 C   s   | j S r   r   r   r   r   r   r$   ,  s    zAccessSpecifier.from_paramc                 C   s   d| j f S )NzAccessSpecifier.%sr   r   r   r   r   ru   /  s    zAccessSpecifier.__repr__r!   r)   r*   r7   r   r   r$   ru   r   r   r   r   r  #  s
   r  c                   @   s,   e Zd ZdZg ZdZedd Zdd ZdS )r  z%
    Describes the kind of type.
    Nc                 C   s   t j| jS )z'Retrieve the spelling of this TypeKind.)rI   rJ   clang_getTypeKindSpellingr   r   r   r   r   rG   C  s    zTypeKind.spellingc                 C   s   d| j f S )NzTypeKind.%sr   r   r   r   r   ru   H  s    zTypeKind.__repr__)	r!   r)   r*   r7   r   r   r+   rG   ru   r   r   r   r   r  :  s   
r                                c                   @   s(   e Zd ZdZg ZdZdd Zdd ZdS )RefQualifierKindz-Describes a specific ref-qualifier of a type.Nc                 C   s   | j S r   r   r   r   r   r   r$     s    zRefQualifierKind.from_paramc                 C   s   d| j f S )NzRefQualifierKind.%sr   r   r   r   r   ru     s    zRefQualifierKind.__repr__r>  r   r   r   r   rJ    s
   rJ  c                   @   s(   e Zd ZdZg ZdZdd Zdd ZdS )r  z*Describes the kind of linkage of a cursor.Nc                 C   s   | j S r   r   r   r   r   r   r$     s    zLinkageKind.from_paramc                 C   s   d| j f S )NzLinkageKind.%sr   r   r   r   r   ru     s    zLinkageKind.__repr__r>  r   r   r   r   r    s
   r  c                   @   s(   e Zd ZdZg ZdZdd Zdd ZdS )r  z=Describes the kind of thread-local storage (TLS) of a cursor.Nc                 C   s   | j S r   r   r   r   r   r   r$     s    zTLSKind.from_paramc                 C   s   d| j f S )Nz
TLSKind.%sr   r   r   r   r   ru     s    zTLSKind.__repr__r>  r   r   r   r   r    s
   r  c                   @   s<  e Zd ZdZdefded fgZedd Zdd Z	ed	d
 Z
edd Zedd Ze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d)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zd3d4 Z d5d6 Z!d7d8 Z"d9d: Z#d;d< Z$d=d> Z%ed?d@ Z&dAdB Z'dCdD Z(dES )FTypez=
    The type of an element in the abstract syntax tree.
    r  r  r1   c                 C   s   t | jS )zReturn the kind of this type.)r  r   r  r   r   r   r   r     s    z	Type.kindc                 C   s*   G dd dt j}| jtjks"J || S )zRetrieve a container for the non-variadic arguments for this type.

        The returned object is iterable and indexable. Each item in the
        container is a Type instance.
        c                   @   s$   e Zd Zdd Zdd Zdd ZdS )z.Type.argument_types.<locals>.ArgumentsIteratorc                 S   s   || _ d | _d S r   )r(  length)r   r(  r   r   r   r     s    z7Type.argument_types.<locals>.ArgumentsIterator.__init__c                 S   s    | j d u rtj| j| _ | j S r   )rL  rI   rJ   clang_getNumArgTypesr(  r   r   r   r   r     s    
z6Type.argument_types.<locals>.ArgumentsIterator.__len__c                 S   sj   t |tstd|dk r"td|t| krBtd|t| f tj| j|}|j	t
jkrftd|S )NzMust supply a non-negative int.r   z'Only non-negative indexes are accepted.z,Index greater than container length: %d > %dz Argument could not be retrieved.)r
   r;   r   r   r   rI   rJ   clang_getArgTyper(  r   r  INVALID)r   r   r   r   r   r   r     s    

z:Type.argument_types.<locals>.ArgumentsIterator.__getitem__Nr   r   r   r   r   ArgumentsIterator  s   rP  )collections_abcSequencer   r  FUNCTIONPROTO)r   rP  r   r   r   argument_types  s    zType.argument_typesc                 C   s$   t j| }|jtjkr td|S )zRetrieve the Type of elements within this Type.

        If accessed on a type that is not an array, complex, or vector type, an
        exception will be raised.
        z(Element type not available on this type.)rI   rJ   clang_getElementTyper   r  rO  r<   r   r   r   r   r   element_type	  s    zType.element_typec                 C   s    t j| }|dk rtd|S )zRetrieve the number of elements in this type.

        Returns an int.

        If the Type is not an array or vector, this raises.
        r   zType does not have elements.)rI   rJ   clang_getNumElementsr<   rV  r   r   r   element_count 	  s    zType.element_countc                 C   s   | j S )z5The TranslationUnit to which this Type is associated.r
  r   r   r   r   r  .	  s    zType.translation_unitc                 C   sF   t | tsJ d }|D ]}t|dr|j} q0q|d us<J || _| S r9  )r
   rK  r  r  r   r;  r   r   r   rQ   5	  s    
zType.from_resultc                 C   s   t j| S r   )rI   rJ   "clang_Type_getNumTemplateArgumentsr   r   r   r   r  D	  s    zType.get_num_template_argumentsc                 C   s   t j| |S r   )rI   rJ   $clang_Type_getTemplateArgumentAsTyper  r   r   r   r  G	  s    zType.get_template_argument_typec                 C   s   t j| S )ae  
        Return the canonical type for a Type.

        Clang's type system explicitly models typedefs and all the
        ways a specific type can be represented.  The canonical type
        is the underlying type with all the "sugar" removed.  For
        example, if 'T' is a typedef for 'int', the canonical type for
        'T' would be 'int'.
        )rI   rJ   clang_getCanonicalTyper   r   r   r   get_canonicalJ	  s    
zType.get_canonicalc                 C   s   t j| S )zDetermine whether a Type has the "const" qualifier set.

        This does not look through typedefs that may have added "const"
        at a different level.
        )rI   rJ   clang_isConstQualifiedTyper   r   r   r   is_const_qualifiedV	  s    zType.is_const_qualifiedc                 C   s   t j| S )zDetermine whether a Type has the "volatile" qualifier set.

        This does not look through typedefs that may have added "volatile"
        at a different level.
        )rI   rJ   clang_isVolatileQualifiedTyper   r   r   r   is_volatile_qualified^	  s    zType.is_volatile_qualifiedc                 C   s   t j| S )zDetermine whether a Type has the "restrict" qualifier set.

        This does not look through typedefs that may have added "restrict" at
        a different level.
        )rI   rJ   clang_isRestrictQualifiedTyper   r   r   r   is_restrict_qualifiedf	  s    zType.is_restrict_qualifiedc                 C   s   | j tjksJ tj| S )zADetermine whether this function Type is a variadic function type.)r   r  rS  rI   rJ   clang_isFunctionTypeVariadicr   r   r   r   is_function_variadicn	  s    zType.is_function_variadicc                 C   s   t j| S r   )rI   rJ   Zclang_getAddressSpacer   r   r   r   get_address_spacet	  s    zType.get_address_spacec                 C   s   t j| S r   )rI   rJ   clang_getTypedefNamer   r   r   r   get_typedef_namew	  s    zType.get_typedef_namec                 C   s   t j| S )z<Determine whether this Type represents plain old data (POD).)rI   rJ   clang_isPODTyper   r   r   r   is_podz	  s    zType.is_podc                 C   s   t j| S )zE
        For pointer types, returns the type of the pointee.
        )rI   rJ   clang_getPointeeTyper   r   r   r   get_pointee~	  s    zType.get_pointeec                 C   s   t j| S )zJ
        Return the cursor for the declaration of the given type.
        )rI   rJ   clang_getTypeDeclarationr   r   r   r   r  	  s    zType.get_declarationc                 C   s   t j| S )zK
        Retrieve the result type associated with a function type.
        )rI   rJ   clang_getResultTyper   r   r   r   
get_result	  s    zType.get_resultc                 C   s   t j| S )zF
        Retrieve the type of the elements of the array type.
        )rI   rJ   clang_getArrayElementTyper   r   r   r   get_array_element_type	  s    zType.get_array_element_typec                 C   s   t j| S )z:
        Retrieve the size of the constant array.
        )rI   rJ   clang_getArraySizer   r   r   r   get_array_size	  s    zType.get_array_sizec                 C   s   t j| S )zE
        Retrieve the class type of the member pointer type.
        )rI   rJ   clang_Type_getClassTyper   r   r   r   get_class_type	  s    zType.get_class_typec                 C   s   t j| S )z>
        Retrieve the type named by the qualified-id.
        )rI   rJ   clang_Type_getNamedTyper   r   r   r   get_named_type	  s    zType.get_named_typec                 C   s   t j| S )z7
        Retrieve the alignment of the record.
        )rI   rJ   clang_Type_getAlignOfr   r   r   r   	get_align	  s    zType.get_alignc                 C   s   t j| S )z2
        Retrieve the size of the record.
        )rI   rJ   clang_Type_getSizeOfr   r   r   r   get_size	  s    zType.get_sizec                 C   s   t j| |S )z?
        Retrieve the offset of a field in the record.
        )rI   rJ   clang_Type_getOffsetOf)r   	fieldnamer   r   r   
get_offset	  s    zType.get_offsetc                 C   s   t tj| S )z9
        Retrieve the ref-qualifier of the type.
        )rJ  r   rI   rJ   clang_Type_getCXXRefQualifierr   r   r   r   get_ref_qualifier	  s    
zType.get_ref_qualifierc                    s2    fdd}g  t jtd |  t S )z9Return an iterator for accessing the fields of this type.c                    s(   | t j ksJ j| _ |  dS r#  r$  )fieldr   fieldsr   r   r   r)  	  s    
z Type.get_fields.<locals>.visitorfields_visit)rI   rJ   clang_Type_visitFieldsr,  r-  )r   r)  r   r  r   
get_fields	  s    zType.get_fieldsc                 C   s   t tjj| S )z
        Return the kind of the exception specification; a value from
        the ExceptionSpecificationKind enumeration.
        )r  r   rI   rJ   clangZgetExceptionSpecificationTyper   r   r   r    get_exception_specification_kind	  s    z%Type.get_exception_specification_kindc                 C   s   t j| S )z#Retrieve the spelling of this Type.)rI   rJ   clang_getTypeSpellingr   r   r   r   rG   	  s    zType.spellingc                 C   s"   t |t | krdS tj| |S )NF)r    rI   rJ   clang_equalTypesrm   r   r   r   ro   	  s    zType.__eq__c                 C   s   |  | S r   rp   rm   r   r   r   rq   	  s    zType.__ne__N))r!   r)   r*   r7   rR   rv   rS   r+   r   rT  rW  rY  r  r-   rQ   r  r  r]  r_  ra  rc  re  rf  rh  rj  rl  r  ro  rq  rs  ru  rw  ry  r{  r~  r  r  r  rG   ro   rq   r   r   r   r   rK    sP   
&




rK  c                   @   s    e Zd ZdZdd Zdd ZdS )ClangObjectz
    A helper for Clang objects. This class helps act as an intermediary for
    the ctypes library and the Clang CIndex library.
    c                 C   s"   t |tr|sJ | | _| _d S r   )r
   rX   obj_as_parameter_)r   r  r   r   r   r   	  s    zClangObject.__init__c                 C   s   | j S r   r  r   r   r   r   r$   	  s    zClangObject.from_paramN)r!   r)   r*   r7   r   r$   r   r   r   r   r  	  s   r  c                   @   s&   e Zd ZdZdefdefdefgZdS )_CXUnsavedFilez*Helper for passing unsaved file arguments.rr   r   rL  N)r!   r)   r*   r7   r   c_ulongrS   r   r   r   r   r  	  s   r  ()[]{}<>z, :;= )r   r3   r   r   r   r   r   r   r   r   r   r  r  c                   @   s   e Zd ZG dd deZdd Zdd Zedd Ze	d	d
 Z
edd Zedd Zdd Zdd Zdd Zdd Zdd ZdS )CompletionChunkc                   @   s$   e Zd Zdd Zdd Zdd ZdS )zCompletionChunk.Kindc                 C   s
   || _ d S r   r   r   rr   r   r   r   r   
  s    zCompletionChunk.Kind.__init__c                 C   s   | j S r   r   r   r   r   r   r   
  s    zCompletionChunk.Kind.__str__c                 C   s   d|  S )Nz<ChunkKind: %s>r   r   r   r   r   ru    
  s    zCompletionChunk.Kind.__repr__Nr!   r)   r*   r   r   ru   r   r   r   r   Kind
  s   r  c                 C   s   || _ || _d| _d S N)csr   !_CompletionChunk__kindNumberCache)r   completionStringr   r   r   r   r   #
  s    zCompletionChunk.__init__c                 C   s   d| j  d t| j d S )Nz{'z', r  )rG   r   r   r   r   r   r   ru   (
  s    zCompletionChunk.__repr__c                 C   s&   | j tv rt| j  S tj| j| jS r   )_CompletionChunk__kindNumberSpellingCacherI   rJ   clang_getCompletionChunkTextr  r   r   r   r   r   rG   +
  s    

zCompletionChunk.spellingc                 C   s$   | j dkrtj| j| j| _ | j S r  )r  rI   rJ   clang_getCompletionChunkKindr  r   r   r   r   r   Z__kindNumber4
  s    
zCompletionChunk.__kindNumberc                 C   s
   t | j S r   )completionChunkKindMapr  r   r   r   r   r   ;
  s    zCompletionChunk.kindc                 C   s"   t j| j| j}|rt|S d S r   )rI   rJ   (clang_getCompletionChunkCompletionStringr  r   CompletionStringr   rO   r   r   r   string?
  s    
zCompletionChunk.stringc                 C   s
   | j dkS r   r  r   r   r   r   isKindOptionalI
  s    zCompletionChunk.isKindOptionalc                 C   s
   | j dkS r#  r  r   r   r   r   isKindTypedTextL
  s    zCompletionChunk.isKindTypedTextc                 C   s
   | j dkS )Nr   r  r   r   r   r   isKindPlaceHolderO
  s    z!CompletionChunk.isKindPlaceHolderc                 C   s
   | j dkS )Nr   r  r   r   r   r   isKindInformativeR
  s    z!CompletionChunk.isKindInformativec                 C   s
   | j dkS )Nr   r  r   r   r   r   isKindResultTypeU
  s    z CompletionChunk.isKindResultTypeN)r!   r)   r*   r   r  r   ru   rA   rG   r+   r  r   r  r  r  r  r  r  r   r   r   r   r  
  s    




	r  OptionalZ	TypedTextTextZPlaceholderZInformativeZCurrentParameterZ	LeftParenZ
RightParenZLeftBracketZRightBracketZ	LeftBraceZ
RightBraceZ	LeftAngleZ
RightAngleZCommaZ
ResultTypeZColonZ	SemiColonZEqualZHorizontalSpaceZVerticalSpace)r   r9   r1   r   r   r   r   r3   r   r   r   r   r   r   r   r   r   r   r  r  r  c                   @   sd   e Zd ZG dd deZdd Zedd Zdd Ze	d	d
 Z
e	dd Ze	dd Zdd ZdS )r  c                   @   s$   e Zd Zdd Zdd Zdd ZdS )zCompletionString.Availabilityc                 C   s
   || _ d S r   r   r  r   r   r   r   q
  s    z&CompletionString.Availability.__init__c                 C   s   | j S r   r   r   r   r   r   r   t
  s    z%CompletionString.Availability.__str__c                 C   s   d|  S )Nz<Availability: %s>r   r   r   r   r   ru   w
  s    z&CompletionString.Availability.__repr__Nr  r   r   r   r   Availabilityp
  s   r  c                 C   s   | j S r   )
num_chunksr   r   r   r   r   z
  s    zCompletionString.__len__c                 C   s   t j| jS r   )rI   rJ   clang_getNumCompletionChunksr  r   r   r   r   r  }
  s    zCompletionString.num_chunksc                 C   s   | j |krtt| j|S r   )r  r   r  r  r   r   r   r   r   
  s    
zCompletionString.__getitem__c                 C   s   t j| jS r   )rI   rJ   clang_getCompletionPriorityr  r   r   r   r   priority
  s    zCompletionString.priorityc                 C   s   t j| j}t| S r   )rI   rJ   clang_getCompletionAvailabilityr  availabilityKindsr  r   r   r   r  
  s    zCompletionString.availabilityc                 C   s   t drt j| jS t S )Nclang_getCompletionBriefComment)rI   function_existsrJ   r  r  rF   r   r   r   r   briefComment
  s    
zCompletionString.briefCommentc                 C   s>   d dd | D d t| j d t| j d t| j S )Nz | c                 S   s   g | ]}t |qS r   )r   )r   ar   r   r   r   
  r   z-CompletionString.__repr__.<locals>.<listcomp>z || Priority: z || Availability: z || Brief comment: )joinr   r  r  r  r   r   r   r   ru   
  s    zCompletionString.__repr__N)r!   r)   r*   r   r  r   rA   r  r   r+   r  r  r  ru   r   r   r   r   r  o
  s   




r  Z	AvailableZ
DeprecatedZNotAvailableZNotAccessible)r   r9   r1   r   c                   @   s<   e Zd ZdefdefgZdd Zedd Zedd Z	d	S )
CodeCompletionResult
cursorKindr  c                 C   s   t t| jS r   )r   r  r  r   r   r   r   ru   
  s    zCodeCompletionResult.__repr__c                 C   s   t | jS r   )r   r   r  r   r   r   r   r   
  s    zCodeCompletionResult.kindc                 C   s
   t | jS r   )r  r  r   r   r   r   r  
  s    zCodeCompletionResult.stringN)
r!   r)   r*   rR   rX   rS   ru   r+   r   r  r   r   r   r   r  
  s   
r  c                   @   s0   e Zd ZdeefdefgZdd Zdd ZdS )CCRStructureresults
numResultsc                 C   s   | j S r   )r  r   r   r   r   r   
  s    zCCRStructure.__len__c                 C   s   t | |krt| j| S r   )r   r   r  r   r   r   r   r   
  s    zCCRStructure.__getitem__N)	r!   r)   r*   r   r  rR   rS   r   r   r   r   r   r   r  
  s
   
r  c                   @   s<   e Zd Zdd Zdd Zdd Zedd Zed	d
 ZdS )CodeCompletionResultsc                 C   s&   t |ttr|sJ | | _| _d S r   )r
   r   r  r   r  r   r   r   r   r   
  s    zCodeCompletionResults.__init__c                 C   s   | j S r   r  r   r   r   r   r$   
  s    z CodeCompletionResults.from_paramc                 C   s   t j|  d S r   )rI   rJ    clang_disposeCodeCompleteResultsr   r   r   r   rL   
  s    zCodeCompletionResults.__del__c                 C   s   | j jS r   )r   r   r   r   r   r   r  
  s    zCodeCompletionResults.resultsc                 C   s   G dd dt }|| S )Nc                   @   s$   e Zd Zdd Zdd Zdd ZdS )z9CodeCompletionResults.diagnostics.<locals>.DiagnosticsItrc                 S   s
   || _ d S r   )ccr)r   r  r   r   r   r   
  s    zBCodeCompletionResults.diagnostics.<locals>.DiagnosticsItr.__init__c                 S   s   t tj| jS r   )r;   rI   rJ   #clang_codeCompleteGetNumDiagnosticsr  r   r   r   r   r   
  s    zACodeCompletionResults.diagnostics.<locals>.DiagnosticsItr.__len__c                 S   s   t j| j|S r   )rI   rJ   clang_codeCompleteGetDiagnosticr  r   r   r   r   r   
  s    zECodeCompletionResults.diagnostics.<locals>.DiagnosticsItr.__getitem__Nr   r   r   r   r   DiagnosticsItr
  s   r  r   )r   r  r   r   r   diagnostics
  s    z!CodeCompletionResults.diagnosticsN)	r!   r)   r*   r   r$   rL   r+   r  r  r   r   r   r   r  
  s   
r  c                   @   s8   e Zd ZdZedddZdd Zdd ZdddZd	S )Indexz
    The Index type provides the primary interface to the Clang CIndex library,
    primarily by providing an interface for reading and parsing translation
    units.
    Fc                 C   s   t tj| dS )z
        Create a new Index.
        Parameters:
        excludeDecls -- Exclude local declarations from translation units.
        r   )r  rI   rJ   clang_createIndex)ZexcludeDeclsr   r   r   create
  s    zIndex.createc                 C   s   t j|  d S r   )rI   rJ   clang_disposeIndexr   r   r   r   rL   
  s    zIndex.__del__c                 C   s   t || S )z/Load a TranslationUnit from the given AST file.)r:  from_ast_file)r   pathr   r   r   read
  s    z
Index.readNr   c                 C   s   t ||||| S )as  Load the translation unit from the given source code file by running
        clang and generating the AST before loading. Additional command line
        parameters can be passed to clang via the args parameter.

        In-memory contents for files can be provided by passing a list of pairs
        to as unsaved_files, the first item should be the filenames to be mapped
        and the second should be the contents to be substituted for the
        file. The contents may be passed as strings or file objects.

        If an error was encountered during parsing, a TranslationUnitLoadError
        will be raised.
        )r:  from_source)r   r  r'   unsaved_filesr   r   r   r   parse
  s    zIndex.parse)F)NNr   )	r!   r)   r*   r7   r-   r  rL   r  r  r   r   r   r   r  
  s   r  c                   @   s   e Zd ZdZdZdZdZdZdZdZ	dZ
ed)d
dZed*ddZdd Zdd Zedd Zedd Zdd Zdd Zdd Zdd Zedd Zd+d d!Zd"d# Zd,d%d&Zd-d'd(Zd	S ).r:  zRepresents a source code translation unit.

    This is one of the main types in the API. Any time you wish to interact
    with Clang's representation of a source file, you typically start with a
    translation unit.
    r   r9   r1   r   r   @   rA  Nc              	   C   s  |du rg }|du rg }|du r(t  }d}t|dkrRtt| dd |D  }d}t|dkrtt|  }t|D ]P\}\}	}
t|
dr|
 }
t|
}
tt	|	|| _
|
|| _t|
|| _qxtj||durt	|nd|t||t||}|std| ||dS )a  Create a TranslationUnit by parsing source.

        This is capable of processing source code both from files on the
        filesystem as well as in-memory contents.

        Command-line arguments that would be passed to clang are specified as
        a list via args. These can be used to specify include paths, warnings,
        etc. e.g. ["-Wall", "-I/path/to/include"].

        In-memory file content can be provided via unsaved_files. This is an
        iterable of 2-tuples. The first element is the filename (str or
        PathLike). The second element defines the content. Content can be
        provided as str source code or as file objects (anything with a read()
        method). If a file object is being used, content will be read until EOF
        and the read cursor will not be reset to its original position.

        options is a bitwise or of TranslationUnit.PARSE_XXX flags which will
        control parsing behavior.

        index is an Index instance to utilize. If not provided, a new Index
        will be created for this TranslationUnit.

        To parse source from the filesystem, the filename of the file to parse
        is specified by the filename argument. Or, filename could be None and
        the args list would contain the filename(s) to parse.

        To parse source from an in-memory buffer, set filename to the virtual
        filename you wish to associate with this source (e.g. "test.c"). The
        contents of that file are then provided in unsaved_files.

        If an error occurs, a TranslationUnitLoadError is raised.

        Please note that a TranslationUnit with parser errors may be returned.
        It is the caller's responsibility to check tu.diagnostics for errors.

        Also note that Clang infers the source language from the extension of
        the input filename. If you pass in source code containing a C++ class
        declaration with the filename "test.c" parsing will fail.
        Nr   c                 S   s   g | ]}t |qS r   )r0   r   r   r   r   r   ^  r   z/TranslationUnit.from_source.<locals>.<listcomp>r  zError parsing translation unit.)index)r  r  r   r   r  	enumerater  r  r0   r5   rr   r   rL  rI   rJ   clang_parseTranslationUnitr6   )r"   rt   r'   r  r   r  Z
args_arrayZunsaved_arrayr   rr   r   r   r   r   r   r  )  s8    *

zTranslationUnit.from_sourcec                 C   s:   |du rt  }tj|t|}|s.t|| ||dS )a  Create a TranslationUnit instance from a saved AST file.

        A previously-saved AST file (provided with -emit-ast or
        TranslationUnit.save()) is loaded from the filename specified.

        If the file cannot be loaded, a TranslationUnitLoadError will be
        raised.

        index is optional and is the Index instance to use. If not provided,
        a default Index will be created.

        filename can be str or PathLike.
        N)r   r  )r  r  rI   rJ   clang_createTranslationUnitr5   r6   )r"   rt   r  r   r   r   r   r  v  s    zTranslationUnit.from_ast_filec                 C   s$   t |tsJ || _t| | dS )zCreate a TranslationUnit instance.

        TranslationUnits should be created using one of the from_* @classmethod
        functions above. __init__ is only called internally.
        N)r
   r  r  r  r   )r   r   r  r   r   r   r     s    zTranslationUnit.__init__c                 C   s   t j|  d S r   )rI   rJ   clang_disposeTranslationUnitr   r   r   r   rL     s    zTranslationUnit.__del__c                 C   s   t j| S )z?Retrieve the cursor that represents the given translation unit.)rI   rJ   clang_getTranslationUnitCursorr   r   r   r   r    s    zTranslationUnit.cursorc                 C   s   t j| S )z3Get the original translation unit source file name.)rI   rJ    clang_getTranslationUnitSpellingr   r   r   r   rG     s    zTranslationUnit.spellingc                 C   s,   dd }g }t j| td || t|S )aM  
        Return an iterable sequence of FileInclusion objects that describe the
        sequence of inclusions in a translation unit. The first object in
        this sequence is always the input file. Note that this method will not
        recursively iterate over header files included through precompiled
        headers.
        c                 S   s,   |dkr(|j }|t|jt| || d S r   )r   r&  FileInclusionrd   r\   )ZfobjZlptrdepthincludeslocr   r   r   r)    s    z-TranslationUnit.get_includes.<locals>.visitortranslation_unit_includes)rI   rJ   clang_getInclusionsr,  r-  )r   r)  r  r   r   r   get_includes  s    zTranslationUnit.get_includesc                 C   s   t | |S )z)Obtain a File from this translation unit.)r\   	from_namers   r   r   r   get_file  s    zTranslationUnit.get_filec                 C   s:   |  |}t|tr"t| ||S t| ||d |d S )a  Obtain a SourceLocation for a file in this translation unit.

        The position can be specified by passing:

          - Integer file offset. Initial file offset is 0.
          - 2-tuple of (line number, column number). Initial file position is
            (0, 0)
        r   r9   )r  r
   r;   rT   rj   rg   )r   rt   positionr]   r   r   r   get_location  s    	

zTranslationUnit.get_locationc                 C   s   |  |}t|dk rtd|\}}t|drJt| ||d |d }nt|trbt| ||}t|drt| ||d |d }nt|trt| ||}t|tsJ t|tsJ t	
||S )a  Obtain a SourceRange from this translation unit.

        The bounds of the SourceRange must ultimately be defined by a start and
        end SourceLocation. For the locations argument, you can pass:

          - 2 SourceLocation instances in a 2-tuple or list.
          - 2 int file offsets via a 2-tuple or list.
          - 2 2-tuple or lists of (line, column) pairs in a 2-tuple or list.

        e.g.

        get_extent('foo.c', (5, 10))
        get_extent('foo.c', ((1, 1), (1, 15)))
        r1   z)Must pass object with at least 2 elementsr   r   r9   )r  r   r<   r  rT   rg   r
   r;   rj   rw   r|   )r   rt   	locationsr]   Zstart_locationZend_locationr   r   r   
get_extent  s*    




zTranslationUnit.get_extentc                 C   s   G dd dt }|| S )zW
        Return an iterable (and indexable) object containing the diagnostics.
        c                   @   s$   e Zd Zdd Zdd Zdd ZdS )z1TranslationUnit.diagnostics.<locals>.DiagIteratorc                 S   s
   || _ d S r   )rc   )r   rc   r   r   r   r     s    z:TranslationUnit.diagnostics.<locals>.DiagIterator.__init__c                 S   s   t tj| jS r   )r;   rI   rJ   clang_getNumDiagnosticsrc   r   r   r   r   r     s    z9TranslationUnit.diagnostics.<locals>.DiagIterator.__len__c                 S   s    t j| j|}|stt|S r   )rI   rJ   clang_getDiagnosticrc   r   r   r   r   r   r   r     s    z=TranslationUnit.diagnostics.<locals>.DiagIterator.__getitem__Nr   r   r   r   r   DiagIterator  s   r  r   )r   r  r   r   r   r    s    zTranslationUnit.diagnosticsc                 C   s   |du rg }d}t |rtt |  }t|D ]P\}\}}t|drL| }t|}tt||| _||| _t ||| _	q.t
j| t |||}dS )aj  
        Reparse an already parsed translation unit.

        In-memory contents for files can be provided by passing a list of pairs
        as unsaved_files, the first items should be the filenames to be mapped
        and the second should be the contents to be substituted for the
        file. The contents may be passed as strings or file objects.
        Nr   r  )r   r  r  r  r  r0   r5   rr   r   rL  rI   rJ   clang_reparseTranslationUnit)r   r  r   unsaved_files_arrayr   rr   r   r   r   r   r   reparse
  s    	

zTranslationUnit.reparsec                 C   s:   t j| }tt j| t||}|dkr6t|ddS )a  Saves the TranslationUnit to a file.

        This is equivalent to passing -emit-ast to the clang frontend. The
        saved file can be loaded back into a TranslationUnit. Or, if it
        corresponds to a header, it can be used as a pre-compiled header file.

        If an error occurs while saving, a TranslationUnitSaveError is raised.
        If the error was TranslationUnitSaveError.ERROR_INVALID_TU, this means
        the constructed TranslationUnit was not valid at time of save. In this
        case, the reason(s) why should be available via
        TranslationUnit.diagnostics().

        filename -- The path to save the translation unit to (str or PathLike).
        r   zError saving TranslationUnit.N)rI   rJ   clang_defaultSaveOptionsr;   clang_saveTranslationUnitr5   r8   )r   rt   r   r   r   r   r   save#  s    zTranslationUnit.saveFc              	   C   s   d}|r|d7 }|r|d7 }|r(|d7 }|du r4g }d}	t |rtt |  }	t|D ]P\}
\}}t|drt| }t|}tt||	|
 _||	|
 _t ||	|
 _	qVt
j| t||||	t ||}|rt|S dS )af  
        Code complete in this translation unit.

        In-memory contents for files can be provided by passing a list of pairs
        as unsaved_files, the first items should be the filenames to be mapped
        and the second should be the contents to be substituted for the
        file. The contents may be passed as strings or file objects.
        r   r9   r1   r   Nr  )r   r  r  r  r  r0   r5   rr   r   rL  rI   rJ   clang_codeCompleteAtr  )r   r  re   rf   r  Zinclude_macrosZinclude_code_patternsZinclude_brief_commentsr   r  r   rr   r   r   r   r   r   codeComplete9  s2    


zTranslationUnit.codeCompletec                 C   s(   |durt |d |d d}t| |S )a7  Obtain tokens in this translation unit.

        This is a generator for Token instances. The caller specifies a range
        of source code to obtain tokens for. The range can be specified as a
        2-tuple of SourceLocation or as a SourceRange. If both are defined,
        behavior is undefined.
        Nr   r9   ry   )rw   r   r   )r   r  r   r   r   r   r   b  s    zTranslationUnit.get_tokens)NNr   N)N)Nr   )NFFF)NN)r!   r)   r*   r7   Z
PARSE_NONEZ PARSE_DETAILED_PROCESSING_RECORDZPARSE_INCOMPLETEZPARSE_PRECOMPILED_PREAMBLEZPARSE_CACHE_COMPLETION_RESULTSZPARSE_SKIP_FUNCTION_BODIESZ/PARSE_INCLUDE_BRIEF_COMMENTS_IN_CODE_COMPLETIONr,   r  r  r   rL   r+   r  rG   r  r  r  r  r  r  r  r  r   r   r   r   r   r:    sB     L


(

   
)r:  c                   @   sP   e Zd ZdZedd Zedd Zedd Zdd	 Z	d
d Z
edd ZdS )r\   zd
    The File class represents a particular source file that is part of a
    translation unit.
    c                 C   s   t tj| t|S )z9Retrieve a file handle within the given translation unit.)r\   rI   rJ   clang_getFiler5   )r  	file_namer   r   r   r  u  s    zFile.from_namec                 C   s   t j| S )z3Return the complete file and path name of the file.)rI   rJ   clang_getFileNamer   r   r   r   rr   z  s    z	File.namec                 C   s   t j| S )z.Return the last modification time of the file.)rI   rJ   clang_getFileTimer   r   r   r   time  s    z	File.timec                 C   s   | j S r   r   r   r   r   r   r     s    zFile.__str__c                 C   s
   d| j  S )Nz
<File: %s>r   r   r   r   r   ru     s    zFile.__repr__c                 C   s&   t | tsJ t| } |d j| _| S r   )r
   rX   r\   r   rN   r   r   r   rQ     s    zFile.from_resultN)r!   r)   r*   r7   r-   r  r+   rr   r  r   ru   rQ   r   r   r   r   r\   o  s   


r\   c                   @   s$   e Zd ZdZdd Zedd ZdS )r  a  
    The FileInclusion class represents the inclusion of one source file by
    another via a '#include' directive or as the input file for the translation
    unit. This class provides information about the included file, the including
    file, the location of the '#include' directive and the depth of the included
    file in the stack. Note that the input file has depth 0.
    c                 C   s   || _ || _|| _|| _d S r   )sourceincluder   r  )r   srcZtgtr  r  r   r   r   r     s    zFileInclusion.__init__c                 C   s
   | j dkS )z,True if the included file is the input file.r   )r  r   r   r   r   is_input_file  s    zFileInclusion.is_input_fileN)r!   r)   r*   r7   r   r+   r  r   r   r   r   r    s   r  c                   @   s    e Zd ZdZdZdZdd ZdS )CompilationDatabaseErrorzRepresents an error that occurred when working with a CompilationDatabase

    Each error is associated to an enumerated value, accessible under
    e.cdb_error. Consumers can compare the value with one of the ERROR_
    constants in this class.
    r   r9   c                 C   s@   t |tsJ |dkr"td| || _t| d||f  d S )Nr9   zmEncountered undefined CompilationDatabase error constant: %d. Please file a bug to have this value supported.r:   )r
   r;   r<   Z	cdb_errorr   r=   r   r   r   r     s    z!CompilationDatabaseError.__init__N)r!   r)   r*   r7   r@   ZERROR_CANNOTLOADDATABASEr   r   r   r   r   r    s   r  c                   @   s<   e Zd ZdZdd Zedd Zedd Zedd	 Zd
S )CompileCommandz3Represents the compile command used to build a filec                 C   s   || _ || _d S r   )cmdccmds)r   r  r  r   r   r   r     s    zCompileCommand.__init__c                 C   s   t j| jS )z1Get the working directory for this CompileCommand)rI   rJ   !clang_CompileCommand_getDirectoryr  r   r   r   r   	directory  s    zCompileCommand.directoryc                 C   s   t j| jS )z0Get the working filename for this CompileCommand)rI   rJ    clang_CompileCommand_getFilenamer  r   r   r   r   rt     s    zCompileCommand.filenamec                 c   s2   t j| j}t|D ]}t j| j|V  qdS )z
        Get an iterable object providing each argument in the
        command line for the compiler invocation as a _CXString.

        Invariant : the first argument is the compiler executable
        N)rI   rJ   clang_CompileCommand_getNumArgsr  r   clang_CompileCommand_getArg)r   rL  r   r   r   r   	arguments  s    zCompileCommand.argumentsN)	r!   r)   r*   r7   r   r+   r  rt   r  r   r   r   r   r    s   

r  c                   @   s<   e Zd ZdZdd Zdd Zdd Zdd	 Zed
d Z	dS )CompileCommandsz
    CompileCommands is an iterable object containing all CompileCommand
    that can be used for building a specific file.
    c                 C   s
   || _ d S r   )r  )r   r  r   r   r   r     s    zCompileCommands.__init__c                 C   s   t j| j d S r   )rI   rJ   clang_CompileCommands_disposer  r   r   r   r   rL     s    zCompileCommands.__del__c                 C   s   t tj| jS r   )r;   rI   rJ   clang_CompileCommands_getSizer  r   r   r   r   r     s    zCompileCommands.__len__c                 C   s"   t j| j|}|stt|| S r   )rI   rJ    clang_CompileCommands_getCommandr  r   r  )r   r   ccr   r   r   r     s    zCompileCommands.__getitem__c                 C   s   | sd S t | S r   )r  rN   r   r   r   rQ     s    zCompileCommands.from_resultN)
r!   r)   r*   r7   r   rL   r   r   r-   rQ   r   r   r   r   r    s   r  c                   @   s@   e Zd ZdZdd Zedd Zedd Zdd	 Zd
d Z	dS )CompilationDatabasez
    The CompilationDatabase is a wrapper class around
    clang::tooling::CompilationDatabase

    It enables querying how a specific source file can be built.
    c                 C   s   t j|  d S r   )rI   rJ   !clang_CompilationDatabase_disposer   r   r   r   rL      s    zCompilationDatabase.__del__c                 C   s   | st ddt| S )Nr   "CompilationDatabase loading failed)r  r  rN   r   r   r   rQ     s
    zCompilationDatabase.from_resultc              
   C   sZ   t  }ztjt| t|}W n4 tyT } ztt|jdW Y d}~n
d}~0 0 |S )z@Builds a CompilationDatabase from the database found in buildDirr  N)	rY   rI   rJ   'clang_CompilationDatabase_fromDirectoryr5   r[   r  r;   r   )ZbuildDirZ	errorCodeZcdber   r   r   fromDirectory
  s    
z!CompilationDatabase.fromDirectoryc                 C   s   t j| t|S )z
        Get an iterable object providing all the CompileCommands available to
        build filename. Returns None if filename is not found in the database.
        )rI   rJ   ,clang_CompilationDatabase_getCompileCommandsr5   rs   r   r   r   getCompileCommands  s    z&CompilationDatabase.getCompileCommandsc                 C   s   t j| S )zo
        Get an iterable object providing all the CompileCommands available from
        the database.
        )rI   rJ   /clang_CompilationDatabase_getAllCompileCommandsr   r   r   r   getAllCompileCommands  s    z)CompilationDatabase.getAllCompileCommandsN)
r!   r)   r*   r7   rL   r-   rQ   r  r  r  r   r   r   r   r    s   

r  c                   @   s`   e Zd ZdZded fdefgZedd Zedd Z	ed	d
 Z
edd Zedd ZdS )r   a7  Represents a single token from the preprocessor.

    Tokens are effectively segments of source code. Source code is first parsed
    into tokens before being converted into the AST and Cursors.

    Tokens are obtained from parsed TranslationUnit instances. You currently
    can't create tokens manually.
    rV   r   rU   c                 C   s   t j| j| S )zhThe spelling of this token.

        This is the textual representation of the token in source.
        )rI   rJ   clang_getTokenSpellingr   r   r   r   r   rG   4  s    zToken.spellingc                 C   s   t tj| S )z*Obtain the TokenKind of the current token.)r   r   rI   rJ   clang_getTokenKindr   r   r   r   r   <  s    z
Token.kindc                 C   s   t j| j| S )z(The SourceLocation this Token occurs at.)rI   rJ   clang_getTokenLocationr   r   r   r   r   r   A  s    zToken.locationc                 C   s   t j| j| S )z$The SourceRange this Token occupies.)rI   rJ   clang_getTokenExtentr   r   r   r   r   r   F  s    zToken.extentc                 C   s.   t  }| j|_tj| jt| dt| |S )z%The Cursor this Token corresponds to.r9   )r  r   rI   rJ   clang_annotateTokensr[   )r   r  r   r   r   r  K  s    zToken.cursorN)r!   r)   r*   r7   rY   rv   rS   r+   rG   r   r   r   r  r   r   r   r   r   &  s   	




r   r  r*  r  r  r  r  r  r  r  r  r  r
  r  r  r	  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r   r  rK   r   r  r  rl   r   r  r   rN  rp  rr  r7  r  r\  r   r  r  r  r  r  r  rM   r  r  r  r  r  r  r  r  Z!clang_getCursorReferenceNameRanger  r  r  r  r  r  r  r  r  r   r   r   r   r   r   r   r   r   r   r   rU  r  r  r  r  r  r  Zclang_getIBOutletCollectionTyper  r  rZ   rb   rh   r%  rM  r  r  r   rX  Zclang_getNumOverloadedDeclsZclang_getOverloadedDeclrk  rx   r~   r}   rn  Z"clang_getSpecializedCursorTemplateZclang_getTemplateCursorKindr  r  r  r  r  r  Zclang_getTUResourceUsageNamerm  r  rg  r?  r  r  r   r^  r  r   r   Z"clang_isFileMultipleIncludeGuardedrd  r   ri  r   r   rb  r   r   r   Zclang_isVirtualBaser`  r  r  r  r   r+  r  r  r  r  r  r  r!  r4  r5  r  r  r0  rx  rt  rZ  r[  r|  rz  r  rv  r  c                   @   s   e Zd Zdd Zdd ZdS )LibclangErrorc                 C   s
   || _ d S r   m)r   r?   r   r   r   r   7  s    zLibclangError.__init__c                 C   s   | j S r   r!  r   r   r   r   r   :  s    zLibclangError.__str__N)r!   r)   r*   r   r   r   r   r   r   r   6  s   r   c              
   C   s   zt | |d }W nJ ty\ } z2t|d }|r@W Y d }~d S t|W Y d }~n
d }~0 0 t|dkrt|d |_t|dkr|d |_t|dkr|d |_d S )Nr   zW. Please ensure that your python bindings are compatible with your libclang.so version.r1   r9   r   r   )getattrAttributeErrorr   r   r   argtypesrestypeerrcheck)rJ   itemignore_errorsfuncr  msgr   r   r   register_function=  s    

r,  c                    s$    fdd}t D ]}|| qdS )zRegister function prototypes with a libclang library instance.

    This must be called as part of library instantiation so Python knows how
    to call out to the shared library.
    c                    s   t |  S r   )r,  )r(  r)  rJ   r   r   r   Y  s    z$register_functions.<locals>.registerN)functionList)rJ   r)  r   r]   r   r-  r   register_functionsR  s    r/  c                
   @   s   e Zd Zejdejejej	e
dZdZdZdZedd Zedd	 Zed
d Zedd Zdd Zdd Zdd ZdS )ConfigZLIBCLANG_LIBRARY_PATHnativeNTFc                 C   s   t jrtdt| t _dS )z,Set the path in which to search for libclangzSlibrary path must be set before before using any other functionalities in libclang.N)r0  loadedr<   r5   library_path)r  r   r   r   set_library_pathe  s    zConfig.set_library_pathc                 C   s   t jrtdt| t _dS )z"Set the exact location of libclangzSlibrary file must be set before before using any other functionalities in libclang.N)r0  r2  r<   r5   library_file)rt   r   r   r   set_library_filen  s    zConfig.set_library_filec                 C   s   t jrtd| t _dS )a   Perform compatibility check when loading libclang

        The python bindings are only tested and evaluated with the version of
        libclang they are provided with. To ensure correct behavior a (limited)
        compatibility check is performed when loading the bindings. This check
        will throw an exception, as soon as it fails.

        In case these bindings are used with an older version of libclang, parts
        that have been stable between releases may still work. Users of the
        python bindings can disable the compatibility check. This will cause
        the python bindings to load, even though they are written for a newer
        version of libclang. Failures now arise if unsupported or incompatible
        features are accessed. The user is required to test themselves if the
        features they are using are available and compatible between different
        libclang versions.
        zZcompatibility_check must be set before before using any other functionalities in libclang.N)r0  r2  r<   compatibility_check)Zcheck_statusr   r   r   set_compatibility_checkw  s    zConfig.set_compatibility_checkc                 C   s    |   }t|tj  dt_|S )NT)get_cindex_libraryr/  r0  r7  r2  )r   rJ   r   r   r   rJ     s    z
Config.libc                 C   sj   t jrt jS dd l}| }|dkr*d}n|dkr8d}nd}t jrftjt jd | rft jd | }|S )Nr   Darwinzlibclang.dylibWindowszlibclang.dllzlibclang.so/)r0  r5  platformsystemr3  osr  isfile)r   r=  rr   rd   r   r   r   get_filename  s    zConfig.get_filenamec              
   C   sP   zt |  }W n8 tyJ } z t|d }t|W Y d }~n
d }~0 0 |S )Nz[. To provide a path to libclang use Config.set_library_path() or Config.set_library_file().)cdllLoadLibraryrA  OSErrorr   r   )r   Zlibraryr  r+  r   r   r   r9    s    zConfig.get_cindex_libraryc                 C   s*   zt | j| W n ty$   Y dS 0 dS )NFT)r#  rJ   r$  r  r   r   r   r    s
    zConfig.function_exists)r!   r)   r*   r?  environr   r  r  dirnamerealpath__file__r3  r5  r7  r2  r-   r4  r6  r8  rA   rJ   rA  r9  r  r   r   r   r   r0  _  s   (



r0  c                  C   s"   t jjD ]\} }t||  qd S r   )r  ZenumerationsZ
TokenKindsr   r   )rr   r   r   r   r   register_enumerations  s    rI  )r  r0  r  r  r  r  r   r  r   r\   r   r  r  rT   rw   r  r   r   r6   r:  r  rK  (  r7   
__future__r   r   r   ctypesZclang.enumerationsr  r?  sysversion_infor   r   r0   r2   r-   r(   collectionsr4   rQ  r5   r$  r   rv   rX   r,  r<   r6   r8   r   rA   	StructurerF   rT   rw   r   r   r   r   r   r   ZUNEXPOSED_DECLZSTRUCT_DECLZ
UNION_DECLZ
CLASS_DECLr  r2  r  ZFUNCTION_DECLZVAR_DECLZ	PARM_DECLZOBJC_INTERFACE_DECLZOBJC_CATEGORY_DECLZOBJC_PROTOCOL_DECLZOBJC_PROPERTY_DECLZOBJC_IVAR_DECLZOBJC_INSTANCE_METHOD_DECLZOBJC_CLASS_METHOD_DECLZOBJC_IMPLEMENTATION_DECLZOBJC_CATEGORY_IMPL_DECLZTYPEDEF_DECLZ
CXX_METHODZ	NAMESPACEZLINKAGE_SPECZCONSTRUCTORZ
DESTRUCTORZCONVERSION_FUNCTIONZTEMPLATE_TYPE_PARAMETERZTEMPLATE_NON_TYPE_PARAMETERZTEMPLATE_TEMPLATE_PARAMETERZFUNCTION_TEMPLATEZCLASS_TEMPLATEZ%CLASS_TEMPLATE_PARTIAL_SPECIALIZATIONZNAMESPACE_ALIASZUSING_DIRECTIVEZUSING_DECLARATIONZTYPE_ALIAS_DECLZOBJC_SYNTHESIZE_DECLZOBJC_DYNAMIC_DECLZCXX_ACCESS_SPEC_DECLZOBJC_SUPER_CLASS_REFZOBJC_PROTOCOL_REFZOBJC_CLASS_REFZTYPE_REFZCXX_BASE_SPECIFIERZTEMPLATE_REFZNAMESPACE_REFZ
MEMBER_REFZ	LABEL_REFZOVERLOADED_DECL_REFZVARIABLE_REFZINVALID_FILEZNO_DECL_FOUNDNOT_IMPLEMENTEDZINVALID_CODEZUNEXPOSED_EXPRZDECL_REF_EXPRZMEMBER_REF_EXPRZ	CALL_EXPRZOBJC_MESSAGE_EXPRZ
BLOCK_EXPRZINTEGER_LITERALZFLOATING_LITERALZIMAGINARY_LITERALZSTRING_LITERALZCHARACTER_LITERALZ
PAREN_EXPRZUNARY_OPERATORZARRAY_SUBSCRIPT_EXPRZBINARY_OPERATORZCOMPOUND_ASSIGNMENT_OPERATORZCONDITIONAL_OPERATORZCSTYLE_CAST_EXPRZCOMPOUND_LITERAL_EXPRZINIT_LIST_EXPRZADDR_LABEL_EXPRZStmtExprZGENERIC_SELECTION_EXPRZGNU_NULL_EXPRZCXX_STATIC_CAST_EXPRZCXX_DYNAMIC_CAST_EXPRZCXX_REINTERPRET_CAST_EXPRZCXX_CONST_CAST_EXPRZCXX_FUNCTIONAL_CAST_EXPRZCXX_TYPEID_EXPRZCXX_BOOL_LITERAL_EXPRZCXX_NULL_PTR_LITERAL_EXPRZCXX_THIS_EXPRZCXX_THROW_EXPRZCXX_NEW_EXPRZCXX_DELETE_EXPRZCXX_UNARY_EXPRZOBJC_STRING_LITERALZOBJC_ENCODE_EXPRZOBJC_SELECTOR_EXPRZOBJC_PROTOCOL_EXPRZOBJC_BRIDGE_CAST_EXPRZPACK_EXPANSION_EXPRZSIZE_OF_PACK_EXPRZLAMBDA_EXPRZOBJ_BOOL_LITERAL_EXPRZOBJ_SELF_EXPRZOMP_ARRAY_SECTION_EXPRZOBJC_AVAILABILITY_CHECK_EXPRZFIXED_POINT_LITERALZOMP_ARRAY_SHAPING_EXPRZOMP_ITERATOR_EXPRZCXX_ADDRSPACE_CAST_EXPRZUNEXPOSED_STMTZ
LABEL_STMTZCOMPOUND_STMTZ	CASE_STMTZDEFAULT_STMTZIF_STMTZSWITCH_STMTZ
WHILE_STMTZDO_STMTZFOR_STMTZ	GOTO_STMTZINDIRECT_GOTO_STMTZCONTINUE_STMTZ
BREAK_STMTZRETURN_STMTZASM_STMTZOBJC_AT_TRY_STMTZOBJC_AT_CATCH_STMTZOBJC_AT_FINALLY_STMTZOBJC_AT_THROW_STMTZOBJC_AT_SYNCHRONIZED_STMTZOBJC_AUTORELEASE_POOL_STMTZOBJC_FOR_COLLECTION_STMTZCXX_CATCH_STMTZCXX_TRY_STMTZCXX_FOR_RANGE_STMTZSEH_TRY_STMTZSEH_EXCEPT_STMTZSEH_FINALLY_STMTZMS_ASM_STMTZ	NULL_STMTZ	DECL_STMTZOMP_PARALLEL_DIRECTIVEZOMP_SIMD_DIRECTIVEZOMP_FOR_DIRECTIVEZOMP_SECTIONS_DIRECTIVEZOMP_SECTION_DIRECTIVEZOMP_SINGLE_DIRECTIVEZOMP_PARALLEL_FOR_DIRECTIVEZOMP_PARALLEL_SECTIONS_DIRECTIVEZOMP_TASK_DIRECTIVEZOMP_MASTER_DIRECTIVEZOMP_CRITICAL_DIRECTIVEZOMP_TASKYIELD_DIRECTIVEZOMP_BARRIER_DIRECTIVEZOMP_TASKWAIT_DIRECTIVEZOMP_FLUSH_DIRECTIVEZSEH_LEAVE_STMTZOMP_ORDERED_DIRECTIVEZOMP_ATOMIC_DIRECTIVEZOMP_FOR_SIMD_DIRECTIVEZOMP_PARALLELFORSIMD_DIRECTIVEZOMP_TARGET_DIRECTIVEZOMP_TEAMS_DIRECTIVEZOMP_TASKGROUP_DIRECTIVEZ OMP_CANCELLATION_POINT_DIRECTIVEZOMP_CANCEL_DIRECTIVEZOMP_TARGET_DATA_DIRECTIVEZOMP_TASK_LOOP_DIRECTIVEZOMP_TASK_LOOP_SIMD_DIRECTIVEZOMP_DISTRIBUTE_DIRECTIVEZOMP_TARGET_ENTER_DATA_DIRECTIVEZOMP_TARGET_EXIT_DATA_DIRECTIVEZOMP_TARGET_PARALLEL_DIRECTIVEZ OMP_TARGET_PARALLELFOR_DIRECTIVEZOMP_TARGET_UPDATE_DIRECTIVEZ$OMP_DISTRIBUTE_PARALLELFOR_DIRECTIVEZ*OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVEZOMP_DISTRIBUTE_SIMD_DIRECTIVEZ&OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVEZOMP_TARGET_SIMD_DIRECTIVEZOMP_TEAMS_DISTRIBUTE_DIRECTIVEZ#OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVEZ0OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVEZ+OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVEZOMP_TARGET_TEAMS_DIRECTIVEZ%OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVEZ2OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVEZ7OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVEZ*OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVEZBUILTIN_BIT_CAST_EXPRZOMP_MASTER_TASK_LOOP_DIRECTIVEZ'OMP_PARALLEL_MASTER_TASK_LOOP_DIRECTIVEZ#OMP_MASTER_TASK_LOOP_SIMD_DIRECTIVEZ,OMP_PARALLEL_MASTER_TASK_LOOP_SIMD_DIRECTIVEZOMP_PARALLEL_MASTER_DIRECTIVEZOMP_DEPOBJ_DIRECTIVEZOMP_SCAN_DIRECTIVEZOMP_TILE_DIRECTIVEZOMP_CANONICAL_LOOPZOMP_INTEROP_DIRECTIVEZOMP_DISPATCH_DIRECTIVEZOMP_MASKED_DIRECTIVEZOMP_UNROLL_DIRECTIVEZOMP_META_DIRECTIVEZOMP_GENERIC_LOOP_DIRECTIVEZ OMP_TEAMS_GENERIC_LOOP_DIRECTIVEZ'OMP_TARGET_TEAMS_GENERIC_LOOP_DIRECTIVEZ#OMP_PARALLEL_GENERIC_LOOP_DIRECTIVEZTRANSLATION_UNITZUNEXPOSED_ATTRZIB_ACTION_ATTRZIB_OUTLET_ATTRZIB_OUTLET_COLLECTION_ATTRZCXX_FINAL_ATTRZCXX_OVERRIDE_ATTRZANNOTATE_ATTRZASM_LABEL_ATTRZPACKED_ATTRZ	PURE_ATTRZ
CONST_ATTRZNODUPLICATE_ATTRZCUDACONSTANT_ATTRZCUDADEVICE_ATTRZCUDAGLOBAL_ATTRZCUDAHOST_ATTRZCUDASHARED_ATTRZVISIBILITY_ATTRZDLLEXPORT_ATTRZDLLIMPORT_ATTRZCONVERGENT_ATTRZWARN_UNUSED_ATTRZWARN_UNUSED_RESULT_ATTRZALIGNED_ATTRZPREPROCESSING_DIRECTIVEZMACRO_DEFINITIONZMACRO_INSTANTIATIONr  ZMODULE_IMPORT_DECLZTYPE_ALIAS_TEMPLATE_DECLZSTATIC_ASSERTZFRIEND_DECLZOVERLOAD_CANDIDATEr  ZNULLZTYPEZDECLARATIONZNULLPTRZINTEGRALr  NONEZDYNAMIC_NONEZDYNAMICZMS_ANYZBASIC_NOEXCEPTZCOMPUTED_NOEXCEPTZUNEVALUATEDZUNINSTANTIATEDZUNPARSEDr  r  rO  ZEXTERNZSTATICZPRIVATEEXTERNZOPENCLWORKGROUPLOCALZAUTOZREGISTERr  Z	AVAILABLEZ
DEPRECATEDZNOT_AVAILABLEZNOT_ACCESSIBLEr  ZPUBLICZ	PROTECTEDZPRIVATEr  Z	UNEXPOSEDZVOIDBOOLr  r  r  r  r  r  r  r  r  ZCHAR_SZSCHARZWCHARZSHORTINTLONGZLONGLONGZINT128FLOATDOUBLEZ
LONGDOUBLEZOVERLOADZ	DEPENDENTZOBJCIDZ	OBJCCLASSZOBJCSELZFLOAT128ZHALFZIBM128ZCOMPLEXZBLOCKPOINTERZLVALUEREFERENCEZRVALUEREFERENCERECORDr  ZTYPEDEFZOBJCINTERFACEZOBJCOBJECTPOINTERZFUNCTIONNOPROTOrS  ZCONSTANTARRAYZVECTORZINCOMPLETEARRAYZVARIABLEARRAYZDEPENDENTSIZEDARRAYZMEMBERPOINTERZ
ELABORATEDPIPEZOCLIMAGE1DROZOCLIMAGE1DARRAYROZOCLIMAGE1DBUFFERROZOCLIMAGE2DROZOCLIMAGE2DARRAYROZOCLIMAGE2DDEPTHROZOCLIMAGE2DARRAYDEPTHROZOCLIMAGE2DMSAAROZOCLIMAGE2DARRAYMSAAROZOCLIMAGE2DMSAADEPTHROZOCLIMAGE2DARRAYMSAADEPTHROZOCLIMAGE3DROZOCLIMAGE1DWOZOCLIMAGE1DARRAYWOZOCLIMAGE1DBUFFERWOZOCLIMAGE2DWOZOCLIMAGE2DARRAYWOZOCLIMAGE2DDEPTHWOZOCLIMAGE2DARRAYDEPTHWOZOCLIMAGE2DMSAAWOZOCLIMAGE2DARRAYMSAAWOZOCLIMAGE2DMSAADEPTHWOZOCLIMAGE2DARRAYMSAADEPTHWOZOCLIMAGE3DWOZOCLIMAGE1DRWZOCLIMAGE1DARRAYRWZOCLIMAGE1DBUFFERRWZOCLIMAGE2DRWZOCLIMAGE2DARRAYRWZOCLIMAGE2DDEPTHRWZOCLIMAGE2DARRAYDEPTHRWZOCLIMAGE2DMSAARWZOCLIMAGE2DARRAYMSAARWZOCLIMAGE2DMSAADEPTHRWZOCLIMAGE2DARRAYMSAADEPTHRWZOCLIMAGE3DRWZ
OCLSAMPLERZOCLEVENTZOCLQUEUEZOCLRESERVEIDZ	EXTVECTORZATOMICrJ  ZLVALUEZRVALUEr  Z
NO_LINKAGEZINTERNALZUNIQUE_EXTERNALZEXTERNALr  rK  r  r  r  r  r  r  r  r  r  r  r  r  r:  r\   r  r  r  r  r  r   	CFUNCTYPErY   	py_objectrR   rQ   bool
c_longlongr=  c_ulonglongr   r.  r   r,  r/  r0  rI  rI   __all__r   r   r   r   <module>	   s	  %!



 G@ 
7&.>













































































	




	



























































































































	









   |(  
A
-
'  o$.2





	











          ]]
