
    daf&                       U d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlmZ d dlmZmZ d dlmZmZmZmZm Z m!Z! da"dZ#dZ$h dZ% G d	 d
ejL                        Z'e'jP                  Z(ee)d<   e'jT                  Z*ee)d<    G d d      Z+ e+       Z,dZ-ee.gdf   Z/eg e.f   Z0e1e.e.f   Z2 G d de      Z3de3fdZ4 G d de      Z5de5fdZ6e!dddde7de d   de.dz  de8dz  def
d       Z9e!ddddde7de d   de.dz  de8dz  ddf
d        Z9ddddde7de:de.dz  de8dz  ddf
d!Z9dddde7de.dz  de8dz  ddfd"Z;dddde7de.dz  de8dz  defd#Z<d$e.de.fd%Z=d$e.de.fd&Z> ej~                  d'      j                  ZAd$e.de:fd(ZB eCd)j                         j                               ZFd$e.de.fd*ZGd$e.de.fd+ZHd$e.de.fd,ZId$e.d-e.de.fd.ZJd$e.d/e.de.fd0ZKd$e.d1e.de.fd2ZLd$e.deMe8d3f   fd4ZNd5e.d6e.de d7   fd8ZO G d9 d:      ZP G d; d<ej                        ZR G d= d>e j                  ?      ZT G d@ dAeT      ZUdB ZVdC ZWdD ZXdE ZY e	j                         d dFdG       Z[ddHdIZ\ddJZ] G dK dLeT      Z^ej                  dM        Z`ddNZa G dO dP      Zb G dQ dR      Zc G dS dT      Zd G dU dV      Ze G dW dX      Zfe1e.ee.geTf   f   Zge^eUdYZhdZj                         D  ci c]  } | e^ c} Ziege)d[<   eUeid\<   de.d]e.ddfd^Zje1e.d_f   Zke1e.eff   Zle1e.d`f   Zme1e.daf   Zndao G db dc      Zpddddde.dee:dfe.dz  ddfdgZq	 ddhe.dz  die8dz  de.fdjZr G dk dl      Zs G dm d`      Zt G dn d_      Zu eCdoj                         j                               ZveCe.   e)dp<   dqj                  drds      j                         j                         \  ZxZyZzZ{Z|Z}e1e.dtf   Z~edu   Z G dv dw      Z G dx dt      Z G dy dz      Zdd{Zd| Zd} Z G d~ de      Z G d de?      Zdddddddddd	Zed3ef   Ze1e.ef   Zi Zee)d<   i Zee)d<   e1e.ef   Zi Zee)d<   eCej                  e      Z G d de      Z G d de      Z G d de      Z edd       G d de             Z G d de      Z G d de      Z G d de      Z ede.h       G d de             Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d d      Z G d d      Z G d d«      ZdÄ Zi Ze1e.e.f   e)d<    G dń de      Ze1e.ee:z  f   Zdddǜde.dede:de:ddf
d̄Z edde.hΫ        eddde.hЫ        eddeee.hΫ        edddeee.hЫ        ed$e.h        eddee.hԫ        edeh        eddehԫ        ede.eh        eddee.ehԫ       [ G dل de      Z G dۄ de      Z G d݄ de      Z ed߫       edd       ede.eh       ede.ehd       G d de                                  Z ede.eh       ede.eeh       edeh       G d de                           ZdeMe.e.f   fdZd Z G d de      Z	 ddede.dz  defdZ G d de      Z G d de?      Z eed        G d de      Z G d de      Z G d de      Z G d de      Z G d  de      Z G d de      Z G d de      Z G d de      Z G d d	e      Z G d
 deë      ZĐdddZ G d d      Zee.dz  gdf   Ze1e.ef   Z G d da      ZeesdZdaod Ze̐dk(  r) ej                   eej                  dd              yyc c} w (      N)Callable)FunctionTypeNoneType)AnyFinal
NamedTupleNoReturnLiteraloverload1PY_SSIZE_T_MAX	__clinic_>
   argsnargskwargs_parserargsbufkwnamesfastargsnoptargs	_keywordsreturn_valuec                        e Zd ZdZdZdefdZy)	Sentinelsunspecifiedunknownreturnc                 >    d| j                   j                          dS )N<>)value
capitalizeselfs    */root/Python-3.12.4/Tools/clinic/clinic.py__repr__zSentinels.__repr__C   s    4::((*+1--    N)__name__
__module____qualname__r   r   strr&    r'   r%   r   r   ?   s    KG.# .r'   r   r   r   c                       e Zd ZdefdZy)Nullr   c                      y)Nz<Null>r,   r#   s    r%   r&   zNull.__repr__M   s    r'   N)r(   r)   r*   r+   r&   r,   r'   r%   r.   r.   L   s    # r'   r.   z--c                   2    e Zd ZU ee   ed<   eed<   eed<   y)_TextAccumulatortextappendoutputN)r(   r)   r*   listr+   __annotations__Appender	Outputterr,   r'   r%   r1   r1   Y   s    
s)Or'   r1   r   c                  @    g fd} t        j                  |       S )Nc                  J    dj                        } j                          | S N )joinclear)sr2   s    r%   r4   z!_text_accumulator.<locals>.output`   s    GGDM

r'   )r1   r3   )r4   r2   s    @r%   _text_accumulatorr@   ^   s"    D D$++v66r'   c                   "    e Zd ZU eed<   eed<   y)TextAccumulatorr3   r4   N)r(   r)   r*   r7   r6   r8   r,   r'   r%   rB   rB   g   s    r'   rB   c                  6    t               \  } }}t        ||      S )a'  
    Creates a simple text accumulator / joiner.

    Returns a pair of callables:
        append, output
    "append" appends a string to the accumulator.
    "output" returns the contents of the accumulator
       joined together (''.join(accumulator)) and
       empties the accumulator.
    )r@   rB   )r2   r3   r4   s      r%   text_accumulatorrD   k   s      -.D&&66**r'   )filenameline_numberr   failTrE   rF   c                      y Nr,   rG   rE   rF   r   s       r%   warn_or_failrK   y   s     r'   F)rG   rE   rF   c                      y rI   r,   rJ   s       r%   rK   rK      s     r'   c                    dj                  |D cg c]  }t        |       c}      }t               \  }}| r	 |d       n |d       t        r?|t        j                  }t        t        dd       r|t        j                  j                  }| |d|z   dz          | |dt        |      z           |d        ||       t         |              | rt        j                  d	       y y c c}w )
N ErrorWarningblock_parserz
 in file ""z	 on line :
)r=   r+   rD   clinicrE   getattrrQ   rF   printsysexit)rG   rE   rF   r   ajoinedaddr4   s           r%   rK   rK      s     XXt,!s1v,-F"$KCGIH6>40k6I --99KL8#c)*K#k**+JK	&(O % -s   C-c                     t        || |ddS )NFrE   rF   rG   rK   rE   rF   r   s      r%   warnra      s    
 kPUVVr'   c                     t        || |dd y )NTr^   r_   r`   s      r%   rG   rG      s    
 ${Nr'   r?   c                 >    dD ]  \  }}| j                  ||      }  | S )N))\z\\)rR   z\")'z\'replace)r?   oldnews      r%   quoted_for_c_stringrj      s0    
  S
 IIc3  Hr'   c                     d| z   dz   S )NrR   r,   r?   s    r%   c_reprrm      s    7S=r'   z^[A-Za-z_][A-Za-z0-9_]*$c                 D    t        d | j                  d      D              S )Nc              3   2   K   | ]  }t        |        y wrI   )is_legal_c_identifier).0fields     r%   	<genexpr>z)is_legal_py_identifier.<locals>.<genexpr>   s     F$U+Fs   .)allsplitrl   s    r%   is_legal_py_identifierrw      s    FFFFr'   z
asm auto break case char const continue default do double
else enum extern float for goto if inline int long
register return short signed sizeof static struct switch
typedef typeof union unsigned void volatile while
c                 N    t        |       st        d|        | t        v r| dz   S | S )NzIllegal C identifier:_value)rp   rG   
c_keywordsrl   s    r%   ensure_legal_c_identifierr{      s+     #$a(J8|Hr'   c                     t               \  }}}| j                  d      D ]   } ||j                                 |d       " |j                           |       S )N
)r@   rv   rstrippop)r?   r2   r\   r4   lines        r%   rstrip_linesr      sO    )+D#v DKKMD	 	HHJ8Or'   c                 N    | j                  dd      } | j                  dd      } | S )N{{{}}}rf   rl   s    r%   format_escaper      s)     	
		#tA			#tAHr'   r   c                    t               \  }}| j                  d      D ]  }|j                  d      \  }}}|s ||        |d       +|j                  d      \  }}}|r||vr ||        |d       W|rt        d|z   dz          |j	                         rt        d|z   dz          ||   }	|	st        j                  t        |	      |      }	 ||	        |d         |       dd S )	a4  
    Perform str.format-like substitution, except:
      * The strings substituted must be on lines by
        themselves.  (This line is the "source line".)
      * If the substitution text is empty, the source line
        is removed in the output.
      * If the field is not recognized, the original line
        is passed unmodified through to the output.
      * If the substitution text is not empty:
          * Each line of the substituted text is indented
            by the indent of the source line.
          * A newline will be added to the end.
    r}   r   r   zText found after {z0} block marker!  It must be on a line by itself.z(Non-whitespace characters found before {NrT   )rD   rv   	partitionrG   striptextwrapindentr   )
r?   r   r\   r4   r   r   curlytrailingnamer!   s
             r%   linear_formatr      s     #$KC "&.."5xII ( 2 23 7eXF*II%,/aab<<>;dBEwwxtU 3V<E
D	14 8CR=r'   prefixc                 &   | j                  d      }|j                         }g }|D ]5  }|j                  |       |j                  |       |j                  d       7 |r"|j                  |       |j                  |       dj                  |      S )z
    Returns 's', with 'prefix' prepended to all lines.

    If the last line is empty, prefix is not prepended
    to it.  (If s is blank, returns s unchanged.)

    (textwrap.indent only adds to non-blank lines.)
    r}   r<   rv   r   r3   r=   )r?   r   rv   lastfinalr   s         r%   indent_all_linesr     s     GGDME99;DE VTT VT775>r'   suffixc                 &   | j                  d      }|j                         }g }|D ]5  }|j                  |       |j                  |       |j                  d       7 |r"|j                  |       |j                  |       dj                  |      S )z
    Returns 's', with 'suffix' appended to all lines.

    If the last line is empty, suffix is not appended
    to it.  (If s is blank, returns s unchanged.)
    r}   r<   r   )r?   r   rv   r   r   r   s         r%   suffix_all_linesr   )  s     GGDME99;DE TVT TV775>r'   .c                 X    g g d fd} D ]  }|j                         rj                  |       %|dk(  r |        2|dv r+ |        j                  dj                  |      dz
         at        dt	        |      z   dz   t	               z           |        t              S )a  Splits a version string into a tuple of integers.

    The following ASCII characters are allowed, and employ
    the following conversions:
        a -> -3
        b -> -2
        c -> -1
    (This permits Python-style version strings such as "1.4b3".)
    c                       st        dt              z         j                  t        dj	                                       j                          y )NzUnsupported version string: r<   )
ValueErrorreprr3   intr=   r>   )accumulatorr?   versions   r%   flushzversion_splitter.<locals>.flushI  sA    ;d1gEFFs277;/01r'   rt   abc   zIllegal character z in version string r   N)isdigitr3   indexr   r   tuple)r?   r   cr   r   s   `  @@r%   version_splitterr   =  s     GK  	_99;q!#XG%ZGNN5;;q>A-.1DG;>SSVZ[\V]]^^	_ 
G>r'   version1version2)rT   r      c                     t        j                  t        |       t        |      d      }t        |      D ]  \  }\  }}||k  r y||kD  s y y)Nr   )	fillvaluerT   r   )	itertoolszip_longestr   	enumerate)r   r   iteratorirZ   bs         r%   version_comparitorr   \  sY    $$%5h%?AQRZA[ghiHx( 	6Aqq5q5	
 r'   c                       e Zd Zd Zy)CRenderDatac                     g | _         g | _        g | _        g | _        g | _        g | _        g | _        g | _        d| _        g | _	        d| _
        g | _        g | _        y )Nr   _return_value)declarationsinitializersmodificationskeywordsformat_unitsparse_argumentsimpl_parametersimpl_argumentsr   return_conversionconverter_retvalpost_parsingcleanupr#   s    r%   __init__zCRenderData.__init__g  s            "  " ! + "$ /  r'   Nr(   r)   r*   r   r,   r'   r%   r   r   f  s    1r'   r   c                       e Zd ZdZd Zd Zy)FormatCounterFormatterz
    This counts how many instances of each formatter
    "replacement string" appear in the format string.

    e.g. after evaluating "string {a}, {b}, {c}, {a}"
         the counts dict would now look like
         {'a': 2, 'b': 1, 'c': 1}
    c                 6    t        j                         | _        y rI   )collectionsCountercountsr#   s    r%   r   zFormatCounterFormatter.__init__  s    !))+r'   c                 2    | j                   |xx   dz  cc<   y)Nr   r<   )r   )r$   keyr   r   s       r%   	get_valuez FormatCounterFormatter.get_value  s    CAr'   N)r(   r)   r*   __doc__r   r   r,   r'   r%   r   r     s    ,r'   r   c                   R    e Zd ZdZdZdZdZd Zej                  d        Z
d Zd Zy)Languager<   c                      y rI   r,   )r$   rE   s     r%   r   zLanguage.__init__      r'   c                      y rI   r,   )r$   rU   
signaturess      r%   renderzLanguage.render  s    r'   c                      y rI   r,   r$   r   s     r%   
parse_linezLanguage.parse_line  r   r'   c                 f      fd} |d        |d       d j                   v rdnd} |d|       y )Nc                 d    dg}|j                  |       t               }t               }|j                  |        fd}|j                  j                         D ]   \  }|v r|dkD  s |d        |d       " |D ])  |j                  j                        dk7  s" |d       + y)ah  
            Ensures that the string found at getattr(self, attr)
            contains exactly one formatter replacement string for
            each valid field.  The list of valid fields is
            ['dsl_name'] extended by additional_fields.

            e.g.
                self.fmt = "{dsl_name} {a} {b}"

                # this passes
                self.assert_only_one('fmt', 'a', 'b')

                # this fails, the format string has a {b} in it
                self.assert_only_one('fmt', 'a')

                # this fails, the format string doesn't have a {c} in it
                self.assert_only_one('fmt', 'a', 'b', 'c')

                # this fails, the format string has two {a}s in it,
                # it must contain exactly one
                self.fmt2 = '{dsl_name} {a} {a}'
                self.assert_only_one('fmt2', 'a')

            dsl_namec                     | r1t        dj                  j                  j                               y t        dj                  j                  j                               y )Nz'{} {} must contain {{{}}} exactly once!z{} {} must not contain {{{}}}!)rG   format	__class__r(   )should_be_there_but_isntattrr   r$   s    r%   
local_failz>Language.validate.<locals>.assert_only_one.<locals>.local_fail  sV    +BII//t= > 9@@//t= >r'   r   TFN)extendrV   r   r   r   itemsget)	r   additional_fieldsfieldsr   fcfr   countr   r$   s	   `      @r%   assert_only_onez*Language.validate.<locals>.assert_only_one  s    2 !\FMM+,4&D(*CJJt>  #zz//1 &e6>qy"4(u%&  %::>>$'1,t$%r'   
start_line	stop_line{arguments}	argumentschecksumchecksum_line)r   )r$   r   rr   s   `  r%   validatezLanguage.validate  s9    .	%` 	%$,0B0BB
/r'   N)r(   r)   r*   r   body_prefixr   r   r   r   abstractmethodr   r   r   r,   r'   r%   r   r     s?    JKIM 	 50r'   r   )	metaclassc                        e Zd ZdZdZdZdZdZy)PythonLanguagePythonz#/*[{dsl_name} input]#z$#[{dsl_name} start generated code]*/z1#/*[{dsl_name} end generated code: {arguments}]*/N)r(   r)   r*   languager   r   r   r   r,   r'   r%   r   r     s    H+JK:IGMr'   r   c              #   ~   K   t                g }t        |       D ]  }t        |      |z   }t        |        yw)zf
    Given [(1,), (2,), (3,)], should yield:
       ()
       (3,)
       (2, 3)
       (1, 2, 3)
    N)r   reversedr5   lr   groups      r%   permute_left_option_groupsr    s@      'MK! !5kK/K  !s   ;=c              #   r   K   t                g }| D ]   }|j                  |       t        |       " yw)zb
    Given [(1,), (2,), (3,)], should yield:
      ()
      (1,)
      (1, 2)
      (1, 2, 3)
    N)r   r   r   s      r%   permute_right_option_groupsr    s<      'MK !5!K  !s   57c                 R   t        |      }|s| rt        d      g }t               }t        |      D ]S  }t	        |       D ]C  }||z   |z   }t        |      |v r|j                  t        |             |j                  |       E U |j                  t
               t        |      S )a  
    Generator function that computes the set of acceptable
    argument lists for the provided iterables of
    argument groups.  (Actually it generates a tuple of tuples.)

    Algorithm: prefer left options over right options.

    If required is empty, left must also be empty.
    z!required is empty but left is notr   )	r   r   setr  r  lenr\   r3   sort)leftrequiredrightr   r   rr   ts           r%   permute_optional_groupsr    s     XH@AAKUF(/ "+D1 	"AHq A1vJJs1vq!	"" r'   c                     | j                         j                  d      }|r|d   }|j                         rn|d= |rdj                  |      S )Nr}   r   )r~   rv   r   r=   )r?   linesr   s      r%   &strip_leading_and_trailing_blank_linesr  9  sM    HHJT"E
Qx::<!H	 
 99Ur'   r   c                |    t        |       } t        j                  |       } |rt        j                  | d|z        } | S )z
    Reformats s:
        * removes leading and trailing blank lines
        * ensures that it does not end with a newline
        * dedents so the first nonwhite character on any line is at column "indent"
    rN   )r  r   dedentr   )r?   r   s     r%   normalize_snippetr  B  s8     	/q1AAOOAsV|,Hr'   	hasformatc                   |rd}d}nd}d}t        | j                  j                         D cg c]$  }|j                         s|j	                         s|& c}      }|dk(  rd}nd|z  }|d|xs |z  z  }t        |      S c c}w )z
    Generates the code template for a static local PyArg_Parser variable,
    with an initializer.  For core code (incl. builtin modules) the
    kwtuple field is also statically initialized.  Otherwise
    it is initialized at runtime.
    r<   z".format = "{format_units}:{name}",z.fname = "{name}",r   z
            #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
            #  define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
            #else
            #  define KWTUPLE NULL
            #endif
        a  
            #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)

            #define NUM_KEYWORDS %d
            static struct {{
                PyGC_Head _this_is_not_used;
                PyObject_VAR_HEAD
                PyObject *ob_item[NUM_KEYWORDS];
            }} _kwtuple = {{
                .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
                .ob_item = {{ {keywords_py} }},
            }};
            #undef NUM_KEYWORDS
            #define KWTUPLE (&_kwtuple.ob_base.ob_base)

            #else  // !Py_BUILD_CORE
            #  define KWTUPLE NULL
            #endif  // !Py_BUILD_CORE
        a  
            static const char * const _keywords[] = {{{keywords_c} NULL}};
            static _PyArg_Parser _parser = {{
                .keywords = _keywords,
                %s
                .kwtuple = KWTUPLE,
            }};
            #undef KWTUPLE
    )r  
parametersvaluesis_positional_only	is_varargr  )fr  fnameformat_pnum_keywordsr   s          r%   declare_parserr"  Q  s     6$<<&&(##%akkm 	
 L q$ %(   e L \**Us   )Bc                    g }| j                  d      D ]=  }|j                  d      \  }}}|s|j                  |       -|j                  d      \  }}}|s|j                  |       Vd|vr|j                  |       l|j                  d      D 	cg c]  }	|	j                         dz    }}	|dz  }t	        |      |k  rdt	        |      z  }
nd}
|s|}d}|r9|st	        |      t	        |d	         z   |kD  rn||j                  d	      z  }d
}|r9|s|j                  d      dz   |z   }|j                  |j                                |
}|r|@ dj                  |      S c c}	w )a"  
    A simple-minded text wrapper for C function declarations.

    It views a declaration line as looking like this:
        xxxxxxxx(xxxxxxxxx,xxxxxxxxx)
    If called with length=30, it would wrap that line into
        xxxxxxxx(xxxxxxxxx,
                 xxxxxxxxx)
    (If the declaration has zero or one parameters, this
    function won't wrap it.)

    If this doesn't work properly, it's probably better to
    start from scratch with a more sophisticated algorithm,
    rather than try and improve/debug this dumb little function.
    r}   (),, rN       Tr   F)rv   r   r3   r   r  r   r~   r=   )r2   lengthr  r   r   _after_l_parenr  after_r_parenxspacesfirsts               r%   wrap_declarationsr0    sw     E

4  #'>>##6 =LL'4'>'>s'C$
A}LLj LL0:0@0@0EF1aggi$&F
F#v;3v;&FFDEYZ]!33f<
q))  {{4(3.>LL'F '@ 99U) Gs   E&c                   j     e Zd ZdZdZdZdZdZdZ fdZd Z	d	 Z
d
 Zd Zed        Zd Zd Z xZS )	CLanguager   Cz/*[{dsl_name} input]r<   z#[{dsl_name} start generated code]*/z0/*[{dsl_name} end generated code: {arguments}]*/c                     t         |   |       t        j                  |      | _        t        | j                  _        y rI   )superr   cppMonitorrG   )r$   rE   r   s     r%   r   zCLanguage.__init__  s+    ";;x(r'   c                 :    | j                   j                  |       y rI   )r6  	writeliner   s     r%   r   zCLanguage.parse_line  s    4 r'   c                     d }|D ]=  }t        |t              s|r&t        dt        |      z   dz   t        |      z          |}? | j	                  ||      S )NzXYou may specify at most one function per block.
Found a block containing at least two:
	z and )
isinstanceFunctionrG   r   render_function)r$   rU   r   functionos        r%   r   zCLanguage.render  s     	A!X&vy}  G  zH  H  KR  R  UY  Z[  U\  \  ]		
 ##FH55r'   c                 r   t        j                  d|j                        rt        d       t	               \  }}}|j                  j                  d      D ]#  } |d        |t        |              |d       % |d   t        k(  r	 |d       n|j                           |d       dj                  |      S )	Nz[^\x00-\x7F]z(Non-ascii character appear in docstring.r}   rR   z\n"
z"\n"r<   )
research	docstringra   r@   rv   rj   sig_end_markerr   r=   )r$   r  r2   r\   r4   r   s         r%   docstring_for_c_stringz CLanguage.docstring_for_c_string  s    99_akk2;<-/c6KK%%d+ 	DH#D)*M	
 8~% LHHJHwwt}r'   c                   > t        |j                  j                               }|sJ t        |d   j                  t
              sJ |d= d}|r"t        |d   j                  t              rd}|d= |D cg c]  }|j                   }}|xr  |d   j                  xs |d   j                  }|j                   xs |j                  j                  dk(  }|j                  t        t        fv }t        }	dx}
x}x}x}}t        |d      D ]  \  }}|j                         r)|j!                         rJ |j#                         r9||z
  }?|j%                         r|	t        k7  rt'        d       |dz  }|dz
  }	n|	t        k(  r|}|j!                         r|}
|j#                         r|} t)        |      dk(  xr3 |d   j!                         xr |d   j#                          xr | xr | }d}t+        d	      }|r|j,                  sd
x}}nt+        d      }t+        d      }t+        d      }d x}x}}t+        d      }t+        d      }t+        d      }t+        d      }t+        d      }d>d
d>fd
}|sY|sd}t+        d      }g } n|rJ d}|}|rdnd}!t+        d|!z  d      g} |rdj/                  |dg| d d!      }n ||g|  }n|rd"}t        |d   t0              r5|d   j2                  d#k(  r#t+        d$      }"|r
d
x}x}}|"}n|"} ||      }nd%}#|d   j4                  |#k(  r|#d&z  }#t+        d'|#z        }|d   j7                  d      }$|d   j9                  |#|$      }%|%d(|#z  }% ||t+        |%d            }nH|rd)}|} ||d*      }n7|s|
t)        |      |z
  k(  r|s	d+}|}d,}&d-}'nd)}|}d.}&d/}'|& d0| }(|	t        k7  rt        n|})t+        d1|&||)fz  d      g} d}*t        |      D ]?  \  }}|j7                  |dz         }$|'|z  }#|j%                         r|sb| j;                  t+        d2|j                  j<                  |(|j                  j<                  |(|j                  j<                  |fz  d             n5| j;                  t+        d3|j                  j<                  |fz  d             |j                  j9                  |#|$      }%|%d }  nW|*s|j#                         r&d}*| j;                  t+        d4d      |&|dz   fz         | j;                  t+        |%d             B | |*r1| j;                  d5       n|st+        d6d      g} nt+        d7d      g}  ||g|  }nSt?        |
|      |z   t)        |      tA        |	t        k7        z
  k  }+|	t        k(  rd8|d9|d9|f},d,}&nd:|d9|d9|d9|	f},|rd;| d<nd=}&|sCd>}|}d-}'tC        |      }-|-d?t)        |      z  z  }-|+r|-d@|&||z   fz  z  }-t+        dA|,z  d      g} nLdB}|}dC}'tC        |      }-|-d?t)        |      z  z  }-|-dDz  }-|-dEz  }-|+r|-dF|&||z   fz  z  }-t+        dG|,z  d      g} |rdH|z   }|}d }.t        |      D ]  \  }}t        |j                  t              rtE        dI      |j7                  |dz         }$|j                  j9                  |'|z  |$      }%|%d }  n|.r ||
k(  s||k(  r| j;                  dJ|.z         d }.|j#                         s| j;                  t+        |%d             ||
k  rbdK}.| j;                  t+        dL|dz   |.fz  d             |+r| j;                  t+        dMd             | j;                  t+        |%d             ||k  rdN}/t?        ||
      }0ndO}/||z   }0|	t        k7  r|0dz  }0||0k(  r!|/}.| j;                  t+        dP|.z  d             |dz   t)        |      k(  r| j;                  t+        |%d             |/}.| j;                  t+        dQ|'|z  z  d             | j;                  t+        |%dR             | j;                  t+        dS|.z  d              | |.rA| j;                  dJ|.z         n,tC        |dT      }-|st+        dUd      g} nt+        dVd      g}  ||g| dW|-i}|rd
}|j                  t        k(  r|}ndX}t+        dY      }t        >      }1d|v}2dZ|v }3|3r|2sJ |rtE        d[      |3s>d\}-|1jG                  dt+        d]d             |2s|1jG                  dt+        d^d              ||g|1dW-i}|d_v rd`}4d
}5nda}4d<}5|jH                  r|db|jH                  z   z  }|jK                  dc|      }|jK                  dd|4      }|jK                  de|5      }d
}6| jL                  jO                         }7|7sd
x}8}9n_df|7z   }8dg|7z   dhz   }9|rP|jP                  tR        jT                  vr4tR        jT                  jW                  |jP                         t+        di      }6|J |r|jY                  dj      rJ |djz  }||}|r|djz  }|jK                  dk|      }||||||||8|9|6dl
}:i };|:j[                         D ])  \  }<}=|=J dmt]        |<      z          |=rd|=z   dz   }=|=|;|<<   + |;S c c}w )nNr   FTrT   
PyObject *r   zToo many var argszPyObject *return_value = NULL;z
            #define {methoddef_name}    \
                {{"{name}", {methoddef_cast}{c_basename}{methoddef_cast_end}, {methoddef_flags}, {c_basename}__doc__}},
            r<   zA
                PyDoc_VAR({c_basename}__doc__);
                za
                PyDoc_STRVAR({c_basename}__doc__,
                {docstring});
                zd
            static {impl_return_type}
            {c_basename}_impl({impl_parameters})
            z~
            static PyObject *
            {c_basename}({self_type}{self_name}, PyObject *args, PyObject *kwargs)
            zl
            static PyObject *
            {c_basename}({self_type}{self_name}, PyObject *args)
            z
            static PyObject *
            {c_basename}({self_type}{self_name}, PyObject *const *args, Py_ssize_t nargs)
            z
            static PyObject *
            {c_basename}({self_type}{self_name}, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
            z
            static PyObject *
            {c_basename}({self_type}{self_name}, PyTypeObject *{defining_class_name}, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
        r,   )r   c                
   t               \  }} ||        |t        |      }|j                  dt        d      dz          |j	                  t        d             |D ]  } |d        ||        t         |       |      S )Nr   z
                {{
                    {return_value_declaration}
                    {parser_declarations}
                    {declarations}
                    {initializers}
                r}   aB  
                    {modifications}
                    {return_value} = {c_basename}_impl({impl_arguments});
                    {return_conversion}
                    {post_parsing}

                {exit_label}
                    {cleanup}
                    return return_value;
                }}
                )parser_declarations)rD   r5   insertr  r3   r   )	prototyper   r   r\   r4   rr   parser_body_fieldss         r%   parser_bodyz/CLanguage.output_templates.<locals>.parser_bodyX  s    *,KC	N!'&\FMM!. 0    MM+ 
- 
 
   D	E
 !|LLr'   METH_NOARGSz
                    static PyObject *
                    {c_basename}({self_type}{self_name}, PyObject *Py_UNUSED(ignored))
                    z'METH_METHOD|METH_FASTCALL|METH_KEYWORDSzreturn NULL;
goto exit;z
                    if (nargs || (kwnames && PyTuple_GET_SIZE(kwnames))) {{
                        PyErr_SetString(PyExc_TypeError, "{name}() takes no arguments");
                        %s
                    }}
                       r  r}   r   z/    return {c_basename}_impl({impl_arguments});r   METH_OOzo
                    static PyObject *
                    {c_basename}({impl_parameters})
                    argr*  z
                    static PyObject *
                    {c_basename}({self_type}{self_name}, PyObject *%s)
                    z
                        if (!PyArg_Parse(%s, "{format_units}:{name}", {parse_arguments})) {{
                            goto exit;
                        }}
                        METH_VARARGSz    {option_group_parsing}METH_FASTCALLr   zargs[%d]zPyTuple_GET_SIZE(args)zPyTuple_GET_ITEM(args, %d)z - z
                if (!_PyArg_CheckPositional("{name}", %s, %d, %s)) {{
                    goto exit;
                }}
                au  
                            %s = PyTuple_New(%s);
                            if (!%s) {{
                                goto exit;
                            }}
                            for (Py_ssize_t i = 0; i < %s; ++i) {{
                                PyTuple_SET_ITEM(%s, i, Py_NewRef(args[%d + i]));
                            }}
                            zX
                            %s = PyTuple_GetSlice(%d, -1);
                            z
                        if (%s < %d) {{
                            goto skip_optional;
                        }}
                        zskip_optional:z
                        if (!_PyArg_ParseStack(args, nargs, "{format_units}:{name}",
                            {parse_arguments})) {{
                            goto exit;
                        }}
                        z
                        if (!PyArg_ParseTuple(args, "{format_units}:{name}",
                            {parse_arguments})) {{
                            goto exit;
                        }}
                        _PyArg_UnpackKeywordsr'  _PyArg_UnpackKeywordsWithVarargzPy_MIN(nargs, r%  0zMETH_FASTCALL|METH_KEYWORDSz
PyObject *argsbuf[%s];zK
Py_ssize_t noptargs = %s + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - %d;z
                    args = %s(args, nargs, NULL, kwnames, &_parser, %s, argsbuf);
                    if (!args) {{
                        goto exit;
                    }}
                    zMETH_VARARGS|METH_KEYWORDSzfastargs[%d]z
PyObject * const *fastargs;z+
Py_ssize_t nargs = PyTuple_GET_SIZE(args);zH
Py_ssize_t noptargs = %s + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - %d;z
                    fastargs = %s(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, %s, argsbuf);
                    if (!fastargs) {{
                        goto exit;
                    }}
                    zMETH_METHOD|z9defining_class should be the first parameter (after self)z%s:skip_optional_posonlyz
                        if (nargs < %d) {{
                            goto %s;
                        }}
                        zE
                            noptargs--;
                            skip_optional_posskip_optional_kwonlyz
                            if (!noptargs) {{
                                goto %s;
                            }}
                            zD
                            if (%s) {{
                               z
                                if (!--noptargs) {{
                                    goto %s;
                                }}
                            }}
                            r  z
                        if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser{parse_arguments_comma}
                            {parse_arguments})) {{
                            goto exit;
                        }}
                        z
                        if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
                            {parse_arguments})) {{
                            goto exit;
                        }}
                        r   zint return_value = -1;z
                    static int
                    {c_basename}({self_type}{self_name}, PyObject *args, PyObject *kwargs)
                    METH_KEYWORDSz0Slot methods cannot access their defining class.z{base_type_ptr}z
                    if ({self_type_check}!_PyArg_NoKeywords("{name}", kwargs)) {{
                        goto exit;
                    }}
                    z
                        if ({self_type_check}!_PyArg_NoPositional("{name}", args)) {{
                            goto exit;
                        }}
                        )rO  rR  rU  z(PyCFunction)z_PyCFunction_CAST(|z{methoddef_flags}z{methoddef_cast}z{methoddef_cast_end}z#if z
#endif /* z */z
                    #ifndef {methoddef_name}
                        #define {methoddef_name}
                    #endif /* !defined({methoddef_name}) */
                    ;z{return_value_declaration})
docstring_prototypedocstring_definitionimpl_prototypemethoddef_defineparser_prototypeparser_definitionimpl_definitioncpp_if	cpp_endifmethoddef_ifndefzgot a None value for template )/r5   r  r  r;  	converterself_converterdefining_class_converterr   return_convertertypekind
METHOD_NEWMETHOD_INIT	NO_VARARGr   is_keyword_onlyr  is_optionalr  rG   r  r  rD  r=   object_converterformat_unitr   get_displayname	parse_argr3   parser_namemaxr   r"  r   rK  methoddef_flagsrg   r6  	condition	full_namerU   ifndef_symbolsr\   endswithr   r   )?r$   r  r  requires_defining_classr   
convertershas_option_groupsdefault_return_converternew_or_initvarargpos_onlymin_posmax_posmin_kw_onlypseudo_argsr   meth_oreturn_value_declarationrd  ra  rb  rg  rc  re  rf  parser_prototype_keywordparser_prototype_varargsparser_prototype_fastcall"parser_prototype_fastcall_keywordsparser_prototype_def_classrN  flagsparser_codereturn_errormeth_o_prototypeargnamedisplaynameparseargr   argname_fmt	left_argsmax_argshas_optionalhas_optional_kwargs_declarationr   	add_labellabel	first_optr   parses_positionalparses_keywordsmethoddef_castmethoddef_cast_endrj  conditionalrh  ri  dd2r   r!   rM  s?                                                                 @r%   output_templateszCLanguage.output_templates  sg   !,,--/0
z*Q-11>BBBqM"'*Z]%<%<>VW&*#1+56aakk6
6&XJqM,?,?,W:b>CWCW()(:(:$: %4##|3 	! ff[ 99CDDD7DWD{[j!, 	 DAq  "//111}}"#g+KY&,-q QY&G'') H}}G!	 $ j/Q& m..0Q-++-- *) o	 	& $D , .  q{{9;;"6"3 5 # $5 6 $  , -  AEDD),=#4 6 $ 
 $5 6 $ 
 %6 7 %!
 .? @ .*
 &7 8 &"  9; 	M> *%#4 6 $  ! '&A#= 2J%1 0 2
 '2'
 01 2 3 ($(II$/ !/ F	/
 / %! %00@$O;$O!E:a=*:;1))S0#4 6 $ 
 , MONNN%58I&6O (8$(34D(E%  a=%%0sNG#4 6 "6" $# 
 )m;;A>%a=227KH#  &	 &H
 %00@0A(ST0U%W! 
 #E7 +,<>Z [(XZ;9V-V (#< (
 '#; 0: !'WI.I%+y%8ywH, . gx0	.1 :;	< =K !L!*- +J1//!4%/;;=&#**+< >  !" 7 7 ) ! 7 7 ) ! 7 7 '#> '(,) *" $**+< >  !" 7 7 '#>
 '(,) * ;;00+F#"&K1==?#'L&&'8 : %&	(' +0Q	(8 9
 ""#4Xa#HIW+JZ &&&'78"#4 6
 %&$' #(K $5 6
 %&$' #(K !,,< K{ K  #8W5Cc*oX[\bfo\oXpFppO"#:= $ 
  #D	G $  8?.	3C5#E (-a0 :S_ LL" $rv{  ~E  HS  ~S  vT  %T  TL0 2
 +2+
 45 6 7 5#; ,-a0 :S_ LL ?? NN" $osx  {B  EP  {P  sQ  %Q  QL0 2
 +2+
 45 6 7 '&.#= I!*- 881akk+CD$ &> ? ?//!4;;00q+N#"&K!x-1<&&uy'89 $I}}&&'8!'LM\ 7I&&'8 :  !1ui0	:1 :;	(< =
 '#**+< > (),+ ,  &&'8!'LM7{ 3$'$:	 6$+k$9	!Y.%NII~$)	#**+< >  #,	>, 56	,7 8
 1uJ/#**+<Xa+PQ$)	#**+< > #.?>4<=,? @ $**+<Xa+PQ#**+< > 
 #,>,
 56,7 8g88t &&&uy'89-a4@"#4 6
 %&$' #(K $5 6
 %&$' #(K !,,< !G{ !G9E!G !vv##; +C(#4 6 $ 
 ,-F -U :-6O(((& !STT"0a!2 4 !"	"# $
 )MM!%6 8 %&	&' ( !,,< !Gv !G9E!G ==,N!#1N!$S1,,,,E+334GO+334FW+334JL^_hh((*!##FYk)F${2U:IAKKv7L7L$L%%))!++6#4 6 $   +++'00555#!,Nc!N-556RTlm %8%9-!1!1"3 /#!1
 779 	KD%$S&Fd&SS$ut+BtH		
 	K 7s   5kc                 H    | dk  rdnd}d|z   t        t        |             z   S )Nr   left_right_group_)r+   abs)r   	adjectives     r%   group_to_variable_namez CLanguage.group_to_variable_name  s'    $qyGh	)#c#e*o55r'   c                    t               \  }}t        |j                  j                               }t	        |d   j
                  t              r|d= d }g }g }g }	t        }
|D ]X  }|j                  }||
k7  r4|}
g }|dk  r|j                  |       n|dk(  r|	}n|j                  |       |j                  |       Z t        j                  }d} |d       t        ||	|      D ]!  }t        |      }t        ||      }t        ||      }|dk(  r	 |d       5|D ch c]  }|j                   }}i }||d<   |j                   |d<   dj#                  d |D              |d	<   g }|D ]  }|j
                  j%                  |        d
j#                  |      |d<   |j'                  d       |D cg c]  }| j)                  |      dz    }}dj#                  |      }d}t+        ||      }|j-                  |      } ||       $  |d       d} ||j/                  |j0                  ||              |d        |d       t3         |             |d<   y c c}w c c}w )Nr   rT   z"switch (PyTuple_GET_SIZE(args)) {
z    case 0:
        break;
r   r   r<   c              3   H   K   | ]  }|j                   j                    y wrI   )rk  rw  )rq   r   s     r%   rs   z8CLanguage.render_option_group_parsing.<locals>.<genexpr>a  s     'PA(?(?'Ps    "r   r'  r   z = 1;r}   z    case {count}:
        if (!PyArg_ParseTuple(args, "{format_units}:{name}", {parse_arguments})) {{
            goto exit;
        }}
        {group_booleans}
        break;
)group_booleansz    default:
zL        PyErr_SetString(PyExc_TypeError, "{} requires {} to {} arguments");
z        goto exit;
r   option_group_parsing)rD   r5   r  r  r;  rk  rl  r   r   r3   rX   maxsizer  r  minr{  r   r=   parse_argumentdiscardr  r   
format_mapr   r~  r   )r$   r  template_dictr\   r4   r  r   r	  r  r
  r   r   group_id	count_min	count_maxsubsetr   	group_idsr  r   gr  r?   s                          r%   render_option_group_parsingz%CLanguage.render_option_group_parsing#  sl   & '(V!,,--/0
jm--~>1 	AwwH4a<KK&]$ELL'LLO	 KK		12-dHeD $	FKEIu-IIu-Iz   *01Q1I1AAgJAfI "'P'P PAn O <**?;<#'99_#=A a GPQ!T003g=QEQIIe$EA a6AQAFI$	L 	[AHHQ[[)Y78"#C0=fh0G,-A 2 Rs   I/Ic                    |syt               \  }}t               }|j                  sJ d       |j                  }|D cg c]  }|j                   }}| j                  |      }	|d   }
|dd  }t        |
j                  t              s J dt        |j                        z   dz          d}t        |      }|xr |d   j                         }|j                  t        t        fv }d}t        |d      D ]  \  }}|j                  }|dk7  r|j                   t"        urt%        ||      }|j'                         r)|j(                  j+                  d	|j,                   d
       |j.                  }||k7  rq|}|rm| j1                  |      }|j2                  j+                  |       |j4                  j+                  d|z   dz          |j6                  j+                  d|z          d}|j9                  ||        |r|st;        d       d|	d   v r"d|	d   v r|j4                  j=                  d       i }|j                  }||d<   |r|j>                  j@                  }n|j@                  }||d<   |jB                  r|jB                  }n:|jE                  d      }|d   dk(  r|j=                          djG                  |      }||d<   |jI                         dz   |d<   | jK                  |      |d<   dx|d<   x|d<   |d<   |D ]  }|jM                  |        |jN                  j9                  ||       |jN                  jP                  |d<   tS        d jG                  |j4                              |d!<   d"jG                  |jT                        |d#<   d"jG                  |jV                        |d$<   d%jG                  d& |jX                  D              |d'<   |jX                  D cg c]  }|s|	 }}d%jG                  d( |D              |d)<   djG                  |jZ                        |d*<   d+jG                  |j\                        |d,<   |j\                  rd-|d.<   nd|d.<   d+jG                  |j6                        |d/<   d+jG                  |j2                        |d0<   tS        djG                  |j^                        ja                               |d1<   tS        djG                  |jb                        ja                               |d2<   tS        djG                  |j(                              |d3<   |jd                  |d4<   |}t        |      }tg        |      |d5<   tg        |      |d6<   |r| ji                  ||       |jj                  jm                         D ]  \  }}|	|   } |rto        | |d7   8      } to        | |d!   |d1   |d#   |d$   |d2   |d3   9      } d:| v }!to        | |!rd;nd<      } | jq                  |      }"|d=v rts        |"      }"|jt                  rtw        |"|jt                        }"|jx                  rt{        |"|jx                        }"|j+                  |"        |j}                  d>      j                         S c c}w c c}w )?Nr<   z-We should always have a 'self' at this point!r   r   zNo self parameter in !rT   FzPy_XDECREF(z);zint z = 0;Tz]You cannot use optional groups ('[' and ']')
unless all parameters are positional-only ('/').rR  rd  z{impl_parameters}re  r~  r   rt   __new__r*  
c_basename
_METHODDEFmethoddef_namerD  	self_name	self_typeself_type_checkimpl_return_typer}   r   z

r   r   rN   c              3   ,   K   | ]  }d |z   dz     yw)rR   z",Nr,   rq   ks     r%   rs   z,CLanguage.render_function.<locals>.<genexpr>  s"      /G34 03Qw~ /G   
keywords_cc              3   ,   K   | ]  }d |z   dz     yw)z&_Py_ID(z),Nr,   r  s     r%   rs   z,CLanguage.render_function.<locals>.<genexpr>  s#      0C45 1;Q0E 0Cr  keywords_pyr   r'  r   r&  parse_arguments_commar   r   r   r   r   r   
unpack_min
unpack_maxr  )r  )r   r   r   r   r   r   rP  zexit:)
exit_label>   rc  rg  block)@rD   r   r  render_parametersrk  r  r;  rl  r   r~  r  r  rp  rq  rr  r   defaultr   r  r  r   r3   rz  r   r  r   r   r   r   rG   r   clsr   r  rv   r=   upperrF  set_template_dictrn  ro  r   r   r   r   r   r   r   r~   r   r   r+   r  destination_buffersr   r   r  r0  line_prefixr   line_suffixr   get_destinationdump)#r$   rU   r  r\   r4   datar  r   r  	templatesf_selfselfless
last_groupfirst_optional
positionalr  r  r   r   r   
group_namer  r~  r   r  r   rk  r  r   r  r  destinationtemplateneed_exit_labelr?   s#                                      r%   r=  zCLanguage.render_function  sf   &(V}||LLL|((
+56aakk6
6))!,	Aab>&**N;n=TW[\]\g\gWh=hkn=nn;
XC(2,"A"A"C
ff[ 99! j"- 	DAqARaii{:!$^Q!7{{}##k!--$CD GGEU""
!%!<!<U!CJ''..z:%%,,Vj-@7-JK((//0CD(,%HHQ)	, jqr 	"4559-?#@@!!!$KK	%.k"55::D66D $f<<J__S)FbzY&

&)J&0l#*4*:*:*<|*K&'%)%@%@%Ck"eggk"g];%?-PaBb# 	7I''6	7 	
!!!T*,-,>,>,C,C()(5dii@Q@Q6R(Sn%(.D4E4E(Fn%)/T5G5G)Ho&&)hh /G8</G 'Gl##}}2!A22'*xx 0C9A0C (Cm$(*0A0A(Bn%+/99T5I5I+J'(58M1257M12+/99T5I5I+J'(*.))D4G4G*H&'-:2774CYCY;Z;a;a;c-d)*(5bggd>O>O6P6W6W6Y(Zn%#01F#Gi (,(9(9n% $
]
&)*ol#&)*ol#,,Q> "(!;!;!A!A!C !	"D+ H (-:;Q-RT$X*>:"/0C"D*>:+O<*>:%i0H +h6O$X&572H ##M2A <<%a(!!$Q(:(:;!!$Q(:(:;q!C!	"F %%g.3355o 7t 3s   Y<!Z)Z)r(   r)   r*   r   r   r   r   r   r   r   r   rF  r  staticmethodr  r  r=  __classcell__r   s   @r%   r2  r2    s^    KH*JK9IFM
!6(n` 6 6ZHx`6r'   r2  c              #      K   t         j                  }| t         _        	 d  t         j                  | u sJ |t         _        y # t         j                  | u sJ |t         _        w xY wwrI   )rX   stdout)r  saved_stdouts     r%   OverrideStdioWithr  $  sS     ::LCJ"zzV###!
 zzV###!
s   A'A  A'!A$$A'c                     |rdnd}d}|rd|z   dz   }|j                  t        j                  |       |t        j                  |            }t        j                  |      S )z.Create an re object for matching marker lines.z\w+z.+z{}({}){}^$)r   rB  escapecompile)beforeafterword
whole_linegroup_repatterns         r%   create_regexr   /  sT    v4HG-#%nnRYYv."))E:JKG::gr'   c                       e Zd ZdZddZd Zy)Blocka  
    Represents a single block of text embedded in
    another file.  If dsl_name is None, the block represents
    verbatim text, raw original text from the file, in
    which case "input" will be the only non-false member.
    If dsl_name is not None, the block represents a Clinic
    block.

    input is always str, with embedded \n characters.
    input represents the original text from the file;
    if it's a Clinic block, it is the original text with
    the body_prefix and redundant leading whitespace removed.

    dsl_name is either str or None.  If str, it's the text
    found on the start line of the block between the square
    brackets.

    signatures is either list or None.  If it's a list,
    it may only contain clinic.Module, clinic.Class, and
    clinic.Function objects.  At the moment it should
    contain at most one of each.

    output is either str or None.  If str, it's the output
    from this block, with embedded '\n' characters.

    indent is either str or None.  It's the leading whitespace
    that was found on every line of input.  (If body_prefix is
    not empty, this is the indent *after* removing the
    body_prefix.)

    preindent is either str or None.  It's the whitespace that
    was found in front of every line of input *before* the
    "body_prefix" (see the Language object).  If body_prefix
    is empty, preindent must always be empty too.

    To illustrate indent and preindent: Assume that '_'
    represents whitespace.  If the block processed was in a
    Python file, and looked like this:
      ____#/*[python]
      ____#__for a in range(20):
      ____#____print(a)
      ____#[python]*/
    "preindent" would be "____" and "indent" would be "__".

    Nc                     t        |t              sJ || _        || _        |xs g | _        || _        || _        || _        y rI   )r;  r+   inputr   r   r4   r   	preindent)r$   r  r   r   r4   r   r  s          r%   r   zBlock.__init__g  sA    %%%%
 $*"r'   c           
          | j                   xs d}d }dj                  d|d || j                        d || j                        df      S )Nr2   c                 T    t        |       } t        |       dkD  r| d d dz   | d   z   S | S )N      z...r   )r   r  rl   s    r%   	summarizez!Block.__repr__.<locals>.summarizer  s4    QA1v{"v~!,,Hr'   r<   z<Block z input=z output=r    )r   r=   r  r4   )r$   r   r
  s      r%   r&   zBlock.__repr__p  sU    ==*F	
 wwxIdjj,A:yY]YdYdOegjl m 	mr'   )NNNr<   r<   )r(   r)   r*   r   r   r&   r,   r'   r%   r  r  9  s    ,Z#mr'   r  c                   B    e Zd ZdZdddZd Zd Zd ZddZd	 Z	d
 Z
y)BlockParserzX
    Block-oriented parser for Argument Clinic.
    Iterator, yields Block objects.
    Tverifyc                   |j                          t        j                  t        |j	                  d                  | _        dx| _        | _        || _        |j                  j                  d      \  }}}|dk(  sJ t        ||d      | _        t        ||      | _        || _        d| _        d| _        d| _        d| _        y)z
        "input" should be a str object
        with embedded 
 characters.

        "language" should be a Language object.
        Tkeependsr   z
{dsl_name}F)r  N)r   r   dequer   
splitlinesr  block_start_line_numberrF   r   r   r   r   find_start_restart_rer  last_checksum_relast_dsl_namer   first_block)r$   r  r   r  r  r*  r  s          r%   r   zBlockParser.__init__  s     	 &&x0@0@$0@0O'PQ
:;;$t'7 #..88F5L   )&%EJ$VU3 $!r'   c                     | S rI   r,   r#   s    r%   __iter__zBlockParser.__iter__  s    r'   c                     	 | j                   st        | j                  r+| j                  | j                        }d | _        d| _        |S | j                         }| j                  r|j                   ssd| _        |S NF)r  StopIterationr   parse_clinic_blockr  parse_verbatim_block)r$   r   r  s      r%   __next__zBlockParser.__next__  so    ::##}}#66t}}E $#( ##--/E$DLr'   c                 ~    | j                   j                  |j                               }|r|j                  d      S d S Nr   )r  matchlstripr   )r$   r   r$  s      r%   is_start_linezBlockParser.is_start_line  s1    ##DKKM2!&u{{1~0D0r'   c                     | xj                   dz  c_         | j                  j                         }|s| j                  j	                  |       |S r#  )rF   r  r   r   r   )r$   	lookaheadr   s      r%   _linezBlockParser._line  s=    Azz~~MM$$T*r'   c                     t               \  }}| j                  | _        | j                  r@| j	                         }| j                  |      }|r|| _        n ||       | j                  r@t         |             S rI   )rD   rF   r  r  r)  r&  r   r  )r$   r\   r4   r   r   s        r%   r   z BlockParser.parse_verbatim_block  si    &(V'+'7'7$jj::<D))$/H (I jj VXr'   c                 J   t               \  }}| j                  dz   | _        | j                  j                  j                  |      | j                  j                  j                  |      }fd}| j                  ru| j                         } ||      s| j                  |      rnK|r4|j                         }|j                  |      sJ |j                  |      } ||       | j                  ru| j                  |k(  r| j                  }n]| j                  j                  j                  |d      j!                  d      \  }}	}
|	dk(  sJ t#        ||
d      }|| _        || _        t               \  }}d }| j                  rp| j                  d	      }|j%                  |j                               }|r|j'                  d      nd }|rn' ||       | j                  |      rn| j                  rp |       }|ri }t)        j*                  |      D ]O  }|j!                  d
      \  }}}|st-        dt/                     |j1                         ||j1                         <   Q | j2                  rd|v r|d   }n|d   }t5        |t7        |            }||k7  rrt-        dj                  ||             nV|j9                  d      }| xj                  t7        |      z  c_        | j                  j;                  t=        |             d }t?         |       ||      S )Nr   r   c                     | j                        r2| j                        }|r|j                         st        d|       y| j	                         j                        rt        d|        y)NzGarbage after stop line: Tz0Whitespace is not allowed before the stop line: F)
startswithremoveprefixisspacerG   r%  )r   	remainderr   s     r%   is_stop_linez4BlockParser.parse_clinic_block.<locals>.is_stop_line  sk     y) --i8	Y%6%6%84YMBC ;;=++I6KD8TUr'   r   r   r   F)r  T)r(  =z$Mangled Argument Clinic marker line:r  r4   r   zChecksum mismatch!
Expected: {}
Computed: {}
Suggested fix: remove all generated code including the end marker,
or use the '-f' option.r  )r4   ) rD   rF   r  r   r   r   r   r  r)  r&  r%  r.  r/  r  r  r   r   r   r$  r   shlexrv   rG   r   r   r  compute_checksumr  r  r   r   r  )r$   r   	input_addinput_outputr   r2  r   checksum_rer  r*  r  
output_addoutput_outputr   r$  r4   r  rr   r   equalsr!   r   computedoutput_linesr   s                           @r%   r  zBlockParser.parse_clinic_block  s   "2"4	<'+'7'7!';$MM++22H2E	mm//666I	 jj::<DD!T%7%7%={{}{333((5dO jj )//K#}}::AA8_lAmww  yF   GFAu%%%&vu5AK!)D$/D! %5$6!
M	jj:::-D%%dkkm4E*/ATIt!!$' jj AY/ 0&+ooc&:#fe?dL"'++-$**,	0 {{a< {H }H+FCMBx' 3  (3	5 ",,d,;LL 11JJh|45F\^Xf==r'   NF)r(   r)   r*   r   r   r  r!  r&  r)  r   r  r,   r'   r%   r  r  {  s0    
 37  ."1S>r'   r  c                   &    e Zd ZddZdddZd Zy)BlockPrinterNc                 L    || _         |xs t        j                         | _        y rI   )r   ioStringIOr  )r$   r   r  s      r%   r   zBlockPrinter.__init__  s     #bkkmr'   Fcore_includesc                   |j                   }|j                  }|j                  }| j                  j                  }|d u |d u z  rJ dt        |      z          |s	 ||       y  || j                  j                  j                  |              |d       | j                  j                  j                  |      }|s	 ||       n.|j                  d      D ]  } ||        ||        |d         || j                  j                  j                  |              |d       d}|r|t        j                  d      z  }dj                  |j                         }|dj                  |j                        z  }|r|j                  d      s|dz  } ||       dj                  t!        |d      t!        |d            }	 || j                  j"                  j                  ||		              |d       y )
Nz8you must specify dsl_name and output together, dsl_name r,  r}   r<   z
                #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
                #  include "pycore_gc.h"            // PyGC_Head
                #  include "pycore_runtime.h"       // _Py_ID()
                #endif

            zoutput={output} input={input}   )r4   r  r3  )r  r4   r   r  writer   r   r   r   r   rv   r   r   r  r=   r  r6  r   )
r$   r  rF  r  r4   r   rI  r   r   r   s
             r%   print_blockzBlockPrinter.print_block!  s   >>%&D.9  	H<vy}  G  zH  =H  	H:%Ldmm&&--x-@Admm//666I%LD) k"dd
 	dmm%%,,h,?@dhoo '  F $"''%,,''??4($&M3::#FB/"5"- ; 
	 	dmm))00(i0XYdr'   c                 :    | j                   j                  |       y rI   )r  rI  )r$   r2   s     r%   rI  zBlockPrinter.writeT  s    Tr'   rI   )r(   r)   r*   r   rJ  rI  r,   r'   r%   rA  rA    s    $ 38 1fr'   rA  c                   (    e Zd ZdZd Zd Zd Zd Zy)BufferSeriesa  
    Behaves like a "defaultlist".
    When you ask for an index that doesn't exist yet,
    the object grows the list until that item exists.
    So o[n] will always work.

    Supports negative indices for actual items.
    e.g. o[-1] is an element immediately preceding o[0].
    c                 6    d| _         g | _        t        | _        y Nr   )_start_arrayr@   _constructorr#   s    r%   r   zBufferSeries.__init__c  s    -r'   c                    || j                   z  }|dk  rR| xj                   |z  c_         t        |       D cg c]  }| j                          }}|| j                  z   | _        d}|t	        | j                        k\  rB| j                  j                  | j                                |t	        | j                        k\  rB| j                  |   S c c}w rO  )rP  rangerR  rQ  r  r3   )r$   r   r-  r   s       r%   __getitem__zBufferSeries.__getitem__h  s    	T[[q5KK1K38!9=ad'')=F= 4;;.DKA3t{{##KKt0023 3t{{##{{1~ >s   Cc                 Z    | j                   D ]  }|j                  j                           y rI   )rQ  r2   r>   )r$   tas     r%   r>   zBufferSeries.clears  s"    ++ 	BGGMMO	r'   c                 |    | j                   D cg c]  }|j                          }}dj                  |      S c c}w r;   )rQ  r4   r=   )r$   rW  textss      r%   r  zBufferSeries.dumpw  s2    '+{{333wwu~ 4s   9N)r(   r)   r*   r   r   rU  r>   r  r,   r'   r%   rM  rM  X  s    .
	r'   rM  c                   $    e Zd Zd Zd Zd Zd Zy)Destinationc                 h   || _         || _        || _        d}||vr2t        dt	        |      z   dz   |z   dz   dj                  |      z          |dk(  rdnd}t        |      |k  rt        d	|z   d
z   |z          t        |      |kD  rt        d|z   d
z   |z          |dk(  ri }|j                  }||d<   t        j                  j                  |      \  }	}
|	sd}	|	|d<   |
|d<   t        j                  j                  |      \  |d<   |d<   |d   j                  |      | _        t               | _        y )N)bufferfilesuppresszInvalid destination type z for z , must be r'  r^  r   r   z%Not enough arguments for destination z new z#Too many arguments for destination pathrt   dirnamebasenamebasename_rootbasename_extension)r   ro  rU   rG   r   r=   r  rE   osr`  rv   splitextr  rM  buffers)r$   r   ro  rU   r   valid_typesextra_argumentsr  rE   ra  rb  s              r%   r   zDestination.__init__}  s>   		4{",tDz9GCdJ]Z]a]f]fgr]sst#v~!1t9&84?'IDPQt9&6=G$NO&=AH AfI "h 7GX"AiL$AjM:<'':J:J8:T7Ao"6 7 G..q1DM#~r'   c                     | j                   dk(  rdt        | j                        z   }nd}dj                  d| j                  d| j                   |df      S )Nr^  rN   r<   z<Destination r    )ro  r   rE   r=   r   )r$   	file_reprs     r%   r&   zDestination.__repr__  sJ    99d4==11IIwwCIsSTTr'   c                     | j                   dk7  rt        d| j                  z   dz          | j                  j	                          y )Nr]  zCan't clear destinationz , it's not of type buffer)ro  rG   r   rg  r>   r#   s    r%   r>   zDestination.clear  s6    99 *TYY69UUVr'   c                 6    | j                   j                         S rI   )rg  r  r#   s    r%   r  zDestination.dump  s    ||  ""r'   N)r(   r)   r*   r   r&   r>   r  r,   r'   r%   r[  r[  |  s    &4U
#r'   r[  )r3  r   zc cc cpp cxx h hh hpp hxx
extensionspynew_contentsc                 l   	 t        | d      5 }|j                         }d d d        |k(  ry 	 |  d}t        |dd      5 }|j                  |       d d d        	 t	        j
                  ||        y # 1 sw Y   UxY w# t        $ r Y \w xY w# 1 sw Y   <xY w#  t	        j                  |        xY w)Nutf-8encodingz.neww)openreadFileNotFoundErrorrI  re  rg   unlink)rE   rp  fpold_contentsfilename_news        r%   
write_filer}    s    (W- 	%779L	% <' ( Zt$L	lC'	2 b



<*	% 	%   
		,s?   B  A4B  BB 4A=9B   	BBBB3ClassModule	DSLParserc                       e Zd ZdZ	 dddddededz  dededz  d	df
d
Zdeded	dfdZ	ded	e
fdZ	 ddedefdZd Zd Zy)Clinica  
preset block
everything block
methoddef_ifndef buffer 1
docstring_prototype suppress
parser_prototype suppress
cpp_if suppress
cpp_endif suppress

preset original
everything block
methoddef_ifndef buffer 1
docstring_prototype suppress
parser_prototype suppress
cpp_if suppress
cpp_endif suppress

preset file
everything file
methoddef_ifndef file 1
docstring_prototype suppress
parser_prototype suppress
impl_definition block

preset buffer
everything buffer
methoddef_ifndef buffer 1
impl_definition block
docstring_prototype suppress
impl_prototype suppress
parser_prototype suppress

preset partial-buffer
everything buffer
methoddef_ifndef buffer 1
docstring_prototype block
impl_prototype suppress
methoddef_define block
parser_prototype block
impl_definition block

NTr  rE   r   printerr  rE   r   c                >   i | _         || _        |rt        d       |xs t        |      | _        || _        || _        i | _        i | _        g | _	        dx| _
        | _        i | _        | j                  dd       | j                  dd       | j                  dd       |r| j                  ddd       | j                  } |d       |d       |d       |d       |d       |d       |d       |d       |dd       |d      d	
| _        t         t"        t$        d
t&        f   f   }t(        |   }g | _        t-               | _        i | _        d }| j2                  j5                         j7                  d      D ]  }	|	j5                         }	|	s|	j7                         ^}
}}|
dk(  ri x| j0                  |<   }@t9        |      rt;        |d         }nd}| j                  ||      }|
dk(  r| j                  D ]  }
|||
<   	 |
| j                  v sJ |||
<    | ay )Nz$Custom printers are broken right nowr<   r  r]  r_  r^  z{dirname}/clinic/{basename}.hr   )
rh  ra  rb  rd  rc  re  rf  ri  rj  rg  .r}   presetr   
everything)parsersr   rG   rA  r  r  rE   modulesclasses	functionsr  r  destinationsadd_destinationget_destination_bufferr  dictr+   r   r   r5   destination_buffers_stackr  r  presetspresets_textr   rv   r  r   rU   )r$   r   r  r  rE   r  DestBufferTypeDestBufferListr  r   r   r!   optionsr   r]  s                  r%   r   zClinic.__init__  s1    $&#+788,x"8 #%"$)+.004+-/Wh/Z4Xx0  1PQ''i#$Z=$%fI !&	i !*!"66 !&! z$
  c8CH#556n-9;&(+24%%++-33D9 	"D::<D$(JJL!D%'x/11U#f7|GAJ00>F|# 44 *D#)F4L*433333!F4L+	"0 r'   r   ro  c                     || j                   v rt        dt        |      z          t        ||| g| | j                   |<   y )NzDestination already exists: )r  rG   r   r[  )r$   r   ro  r   s       r%   r  zClinic.add_destinationG  sB     4$$$/$t*<="-dD$"F"F$r'   c                 n    | j                   j                  |      }|st        dt        |      z          |S )NzDestination does not exist: )r  r   rG   r   )r$   r   r  s      r%   r  zClinic.get_destinationQ  s2    !!$'/$t*<=r'   itemc                 B    | j                  |      }|j                  |   S rI   )r  rg  )r$   r   r  r  s       r%   r  zClinic.get_destination_bufferW  s"    
   &yyr'   c                    | j                   }t        || j                  | j                        | _        | j                  D ]~  }|j
                  }|r]|| j                  vr.|t        v sJ d|d       t        |   |       | j                  |<   | j                  |   }	 |j                  |       |j                  |        | j                  j                         D ]  \  }}|j                   dk(  r|j#                         }|s*t%        dd|      }|j                   d	k(  rJd
|z   dz   |_        t)        dt+        |      z   dz          |j-                  d       |j                  |       |j                   dk(  s	 t.        j0                  j3                  |j4                        }		 t/        j6                  |	       | j                  rt?        |j4                        5 }
t        |
jA                         | j                        }tC        |      }tE        |      dk7  s|d   j&                  dk7  r$t        dt+        |j4                        z   dz          d d d        d|_        tI        | j                        }|j                  |d       tK        |j4                  |jL                  jO                                 |jL                  jO                         S # t        $ r2 t        dt        j                         j                         z          Y `w xY w# t8        $ rH t.        j0                  j;                  |	      s%t        dj=                  |j4                  |	             Y w xY w# 1 sw Y   xY w# tF        $ r Y %w xY w)Nr  zNo parser to handle z block.z!Exception raised during parsing:
r_  r<   rU   )r   r4   r]  zdump r}   zDestination buffer z$ not empty at end of file, emptying.r^  z7Can't write to destination {}, can't make directory {}!)r   r   r   z	preserve
zModified destination file z, not overwriting!TrE  )(r  r  r   r  rQ   r   r  parse	ExceptionrG   	traceback
format_excr~   rJ  r  r   ro  r  r  r  ra   r   rI  re  r`  ra  rE   makedirsFileExistsErrorisdirr   rv  rw  r5   r  rx  rA  r}  r  getvalue)r$   r  r  r  r   parserr   r  r4   ra  r  parser_2blocks	printer_2s                 r%   r  zClinic.parse_  s   ,,'t}}T[[Q&& 	'E~~H4<</#w.Z2FxlRY0ZZ.-4X->t-DDLL*h/:LL' &	' "&!2!2!8!8!: &	D+:- %%'Fb8FC##x/")D.4"7EK.d;>ddeMM$'''.##v-"$''//+2F2F"GHKK0  ;;!%k&:&:!; {q+6qvvx$--+X)-h$'K1$4&)//\:Y$()E[MaMaHb)bey)y$z	{ #/EK ,T]] ;I))%t)D{33Y[[5I5I5KLM&	P yy!!##] ! :="--/6689 ::4  / H#%77==#9 $ &@@F(3(<(<gAG!HH{ {
 - sb   K=)M3'L<!M3A5M&M37LLAM#M3"M##M3&M0	+M33	N ?N c                 @   d}| x}}d}g }|D ]  }|j                  |       |s$|j                  j                  |      }|r|x}}8d}t        |d      s||fc S |j                  j                  |      }|s t        ddj                  |      z   dz          |x}} ||fS )a  
        fields should be an iterable of field names.
        returns a tuple of (module, class).
        the module object could actually be self (a clinic object).
        this function is only ever used to find the parent of where
        a new class/module should go.
        FNTr  zParent class or module rt   z does not exist.)r3   r  r   hasattrr  rG   r=   )	r$   r   
in_classesparentmoduler  so_farrr   childs	            r%   _module_and_classzClinic._module_and_class  s     
 	!EMM% **51&++FV!
69-s{"NN&&u-E.&1AADVVW  C&	! s{r'   rI   )r   )r(   r)   r*   r  r2  rA  boolr+   r   r  r[  r  r   r  r  r  r,   r'   r%   r  r    s    )L\ ,0L
  #'LL "D(L
 L DjL 
L\GG G
 
GC K   :$zr'   r  )r  r4   r  r4   c                    |s| }t         j                  j                  |       d   dd  }|st        dt	        |       z          	 t        |   |       }t        | d      5 }|j                         }d d d        t        d      j                  }|j                        sy t        |t              sJ t        |||       }|j                  |      }	t!        ||	       y # t        $ r t        dt	        |       z          Y w xY w# 1 sw Y   xY w)Nr   z!Can't extract file type for file z"Can't identify file type for file rr  rs  r<   r  )re  r`  rf  rG   r   rn  KeyErrorrv  rw  r  r  rC  r;  r2  r  r  r}  )
rE   r  r4   	extensionr   r  rawr  rU   cookeds
             r%   
parse_filer    s      *1-ab1I04>ABDi(2 
h	) Qffh  H-;;M$h	***HVh?F\\#Fvv  D1DNBCD s   C D D DDr  r)  c                     | xs d} t        j                  | j                  d            j                         }|r|d | }|S )Nr<   rr  )hashlibsha1encode	hexdigest)r  r)  r?   s      r%   r6  r6    s@     KREU\\'*+557AgvJHr'   c                   ,    e Zd ZdeddfdZdeddfdZy)PythonParserrU   r   Nc                      y rI   r,   )r$   rU   s     r%   r   zPythonParser.__init__  r   r'   r  c                     t        j                         }t        |      5  t        |j                         d d d        |j                         |_        y # 1 sw Y   xY wrI   )rC  rD  r  execr  r  r4   )r$   r  r?   s      r%   r  zPythonParser.parse  sC    KKMq! 		zz|	 	s   AA)r(   r)   r*   r  r   r  r  r,   r'   r%   r  r    s(    v $ $5 $T $r'   r  c                   ,    e Zd Z	 ddeddfdZdefdZy)r  Nr   r   c                 X    || _         |x| _        | _        i | _        i | _        g | _        y rI   )r   r  r  r  r  r  )r$   r   r  s      r%   r   zModule.__init__  s.    
 	$**dk#%"$)+r'   c                 h    dt        | j                        z   dz   t        t        |             z   dz   S )Nz<clinic.Module  at r    r   r   r+   idr#   s    r%   r&   zModule.__repr__	  s,     4		?2V;c"T(mKcQQr'   rI   )r(   r)   r*   r+   r   r&   r,   r'   r%   r  r    s,     
,
, 
	
,R# Rr'   c                   P    e Zd Z	 	 	 	 d	dededz  dedz  dedz  ddf
dZdefdZy)
r~  Nr   r  typedeftype_objectr   c                 |    || _         || _        || _        || _        || _        |xs || _        i | _        g | _        y rI   )r   r  r  r  r  r  r  r  )r$   r   r  r  r  r  s         r%   r   zClass.__init__	  sA     	&mV"$)+r'   c                 h    dt        | j                        z   dz   t        t        |             z   dz   S )Nz<clinic.Class r  r    r  r#   s    r%   r&   zClass.__repr__	  s,    $tyy/1F:SD]JSPPr'   )NNNN)r(   r)   r*   r+   r  r   r&   r,   r'   r%   r~  r~  	  s_     %)"&&*,, TM,
 4Z, t, 
,$Q# Qr'   a  

__abs__
__add__
__and__
__call__
__delitem__
__divmod__
__eq__
__float__
__floordiv__
__ge__
__getattr__
__getattribute__
__getitem__
__gt__
__hash__
__iadd__
__iand__
__ifloordiv__
__ilshift__
__imatmul__
__imod__
__imul__
__index__
__int__
__invert__
__ior__
__ipow__
__irshift__
__isub__
__iter__
__itruediv__
__ixor__
__le__
__len__
__lshift__
__lt__
__matmul__
__mod__
__mul__
__neg__
__next__
__or__
__pos__
__pow__
__radd__
__rand__
__rdivmod__
__repr__
__rfloordiv__
__rlshift__
__rmatmul__
__rmod__
__rmul__
__ror__
__rpow__
__rrshift__
__rshift__
__rsub__
__rtruediv__
__rxor__
__setattr__
__setitem__
__str__
__sub__
__truediv__
__xor__

unsupported_special_methodszI
INVALID, CALLABLE, STATIC_METHOD, CLASS_METHOD, METHOD_INIT, METHOD_NEW
r&  r<   	Parameter).CReturnConverterc                       e Zd ZdZ	 ddddej
                  j                  deddddedz  de	de
dedz  d	e	dz  d
e	dz  dede	dz  de	dededdfdZdZed        Zede	dz  fd       Zde	fdZddZy)r<  aH  
    Mutable duck type for inspect.Function.

    docstring - a str containing
        * embedded line breaks
        * text outdented to the left margin
        * no trailing whitespace.
        It will always be true that
            (not docstring) or ((not docstring[0].isspace()) and (docstring.rstrip() == docstring))
    NF)r  r  r~  return_annotationrD  rp  coexistdocstring_onlyr  r   r  r  r  r~  rn  rD  rp  r  r  r   c                    |xs i | _         || _        || _        || _        || _        || _        |xs || _        || _        || _        |	xs d| _	        |
| _
        || _        d | _        || _        d | _        y r;   )r  r  r   r~  r  r  r  r  rn  rD  rp  r  rl  r  rendered_parameters)r$   r  r   r  r  r  r~  rn  r  rD  rp  r  r  s                r%   r   zFunction.__init__w	  s      %*!2	"mV$ 0"b	"
 -#' r'   c                     | j                   scg x| _         }| j                  j                         D ]=  }|j                         }|j                  j                          |j                  |       ? | j                   S rI   )__render_parameters__r  r  copyrk  
pre_renderr3   )r$   r   r   s      r%   r  zFunction.render_parameters	  sh    ))-//D&__++- FFH&&( )))r'   c                    | j                   t        t        fv ry g }| j                   t        k(  r|j	                  d       nU| j                   t
        k(  r|j	                  d       n0| j                   t        k(  sJ dt        | j                         z          | j                  r|j	                  d       dj                  |      S )N
METH_CLASSMETH_STATICzunknown kind: METH_COEXISTr_  )
rp  rr  rq  CLASS_METHODr3   STATIC_METHODCALLABLEr   r  r=   )r$   r  s     r%   r|  zFunction.methoddef_flags	  s    99j1199$LL&YY-'LL'99(L*:T$))_*LL(<<LL(xxr'   c                 &    d| j                   z   dz   S )Nz<clinic.Function r    r   r#   s    r%   r&   zFunction.__repr__	  s    "TYY.44r'   c                    | j                   | j                  | j                  | j                  | j                  | j
                  | j                  | j                  | j                  | j                  | j                  | j                  d}|j                  |       t        di |}|j                  j                         D ci c]  \  }}||j                  |       c}}|_        |S c c}}w )N)r   r  r  r  r  r~  rn  r  rD  rp  r  r  )r>  r,   )r   r  r  r  r  r~  rn  r  rD  rp  r  r  updater<  r   r  )r$   	overridesr   r  r   r!   s         r%   r  zFunction.copy	  s    IIDOO884?? $ 5 5DLbLbt||"11 	i v  !||113
e %**a*((
 	
s   C)rI   )r   r<  )r(   r)   r*   r   inspect	Signatureemptyr  	ParamDictr+   r  r~  ReturnConverterTyper  r   r  propertyr  r|  r&   r  r,   r'   r%   r<  r<  k	  s   	 ,0#( !%%)$( ' 1 1 7 7$( !#(#(!D(#( 	#(
 #( #( d
#( Tz#( 2#( Tz#( #( #( !#( 
#(J !* * t  5# 5r'   r<  c                       e Zd ZdZej
                  j                  ej
                  j                  ddddedededd	d
edz  de	ddfdZ
defdZdefdZdefdZdefdZdefdZddZde	defdZy)r  z1
    Mutable duck type of inspect.Parameter.
    Nr   )r  
annotationrD  r   r   rp  r>  rk  
CConverterrD  r   r   c                |    || _         || _        || _        || _        || _        || _        |xs d| _        || _        y r;   r   rp  r  r>  rk  r  rD  r   )	r$   r   rp  r  r>  rk  r  rD  r   s	            r%   r   zParameter.__init__	  s@     		 "$"b
r'   c                 &    d| j                   z   dz   S )Nz<clinic.Parameter r    r  r#   s    r%   r&   zParameter.__repr__	  s    #dii/#55r'   c                 P    | j                   t        j                  j                  k(  S rI   )rp  r  r  KEYWORD_ONLYr#   s    r%   rt  zParameter.is_keyword_only	  s    yyG--::::r'   c                 P    | j                   t        j                  j                  k(  S rI   )rp  r  r  POSITIONAL_ONLYr#   s    r%   r  zParameter.is_positional_only	  s    yyG--====r'   c                 P    | j                   t        j                  j                  k(  S rI   )rp  r  r  VAR_POSITIONALr#   s    r%   r  zParameter.is_vararg	  s    yyG--<<<<r'   c                 L    | j                          xr | j                  t        uS rI   )r  r  r   r#   s    r%   ru  zParameter.is_optional	  s     >>##I[)HIr'   c           	      T   | j                   | j                  | j                  | j                  | j                  | j
                  | j                  | j                  d}|j                  |       d|vr.t        j                  | j                        }|d   |_        ||d<   t        di |S )Nr  rk  r>  r,   )r   rp  r  r>  rk  r  rD  r   r  r  r  )r$   r  r   rk  s       r%   r  zParameter.copy	  s    IItyyDLL!]]W[WfWf"nntzz
 	i i'		$..1I!'
!3I"+F;"6""r'   r   c                 Z    |dk(  ry| j                         sd| j                  dS d| dS )Nr   z
"argument"z
"argument rR   )r  r   )r$   r   s     r%   rx  zParameter.get_displayname
  s:    6&&(		}A..s!$$r'   )r   r  )r(   r)   r*   r   r  r  r  r+   r<  r   r   r&   r  rt  r  r  ru  r  rx  r,   r'   r%   r  r  	  s     ''-- !**00$(   $ Tz  
*6# 6; ;>D >=4 =JT J#% % %r'   c                   @     e Zd ZdeddfdZdefdZdef fdZ xZS )LandMinemessager   Nc                     || _         y rI   )__message__)r$   r  s     r%   r   zLandMine.__init__
  s
    "r'   c                 8    dt        | j                        z   dz   S )Nz
<LandMine r    )r   r  r#   s    r%   r&   zLandMine.__repr__
  s    d4#3#344s::r'   r   c                 z    |dv rt         |   |      S t        dt        |      z   dz   | j                  z          y )N)r&   r  z3Stepped on a land mine, trying to access attribute rS   )r5  __getattribute__rG   r   r  )r$   r   r   s     r%   r   zLandMine.__getattribute__
  s@    ..7+D11BT$ZORWWZ^ZjZjjkr'   )r(   r)   r*   r+   r   r&   r   r  r  s   @r%   r  r  

  s6    # # #;# ;lS l lr'   r  c                 |    |s0| j                   }|j                  d      s| S |j                  d      }| t        |<   | S )N
_converter)r(   r  removesuffixr  r  r   s     r%   add_c_converterr  
  s>    zz}}\*H  .JtHr'   c                 l    | j                   dvr%| j                   t        vr| t        | j                   <   | S )N)O&r<   )rw  legacy_converters)r  s    r%   add_default_legacy_c_converterr	  "
  s1     

	*	 1	1-0#//*Jr'   c                       fd}|S )z"
    Adds a legacy converter.
    c                 T    s| }nt        j                  | fi }r	|t        <   | S rI   )	functoolspartialr  )r  added_frw  r   s     r%   closurez'add_legacy_c_converter.<locals>.closure/
  s3    G''4V4G-4k*r'   r,   )rw  r   r  s   `` r%   add_legacy_c_converterr  +
  s     Nr'   c                       e Zd Zd Zy)CConverterAutoRegisterc                 0    t        |        t        |        y rI   )r  r	  r  r   bases	classdicts       r%   r   zCConverterAutoRegister.__init__:
  s    &s+r'   Nr   r,   r'   r%   r  r  9
  s    ,r'   r  c                   T   e Zd ZU dZdZedz  ed<   dZedz  ed<   dZedz  ed<   e	Z
eed<   dZej                  e   eej                  e   df   z  dz  ed<   dZedz  ed	<   dZedz  ed
<   dZeed<   dZdZedz  ed<   dZdZdZdZedz  ed<   dZdZdZdZe	fdde	dddededed	edz  d
edz  deeej                     z  defdZ d Z!defdZ"dede#ddfdZ$d Z%dede#ddfdZ&d Z'd Z(d,dd d!Z)dd d"Z*defd#Z+defd$Z,defd%Z-defd&Z.d' Z/d( Z0d)e1ddfd*Z2e3d+        Z4y)-r  z
    For the init function, self, name, function, and default
    must be keyword-or-positional parameters.  All other
    parameters must be keyword-only.
    Nr   py_namero  r  .default_type	c_default
py_defaultNULLc_ignored_defaultFrk  Tr  rt  )r  r  r  unusedr  r  c                   t        |      | _        || _        || _        |t        ur| j
                  r|t        urt        || j
                        st        | j
                  t              r| j
                  j                  }
n4| j
                  D cg c]  }|j                   }}dj                  |      }
t        dj                  | j                  j                  |||
             || _        |r|| _        |r|| _        |t        urt        d       t#        d      | _         | j&                  di |	 || _        y c c}w )Nr'  z5{}: default value {!r} for field {} is not of type {}z6The 'annotation' parameter is not currently permitted.z<Don't access members of self.function inside converter_init!r,   )r{   r   r  r  r   r  r   r;  ro  r(   r=   rG   r   r   r  r  r  r  r>  converter_init)r$   r   r  r>  r  r  r  r  r  r   	types_strr  namess                r%   r   zCConverter.__init__
  s    .d3	+%!!7*"7D,=,=>d//6 $ 1 1 : :I595F5FGcS\\GEG $		% 0ILSSNN++WdIG H"DL&DN(DO[(IJ !!_`%f% ) Hs   D=c                      y rI   r,   r#   s    r%   r   zCConverter.converter_init
  r   r'   r   c                 &    | j                   t        uS rI   )r  r   r#   s    r%   ru  zCConverter.is_optional
  s    K/0r'   	parameterr  c                    || _         | j                  }| j                  rdnd|z   }|j                  j	                  |       | j
                  r)|j                  j	                  | j                                |j                  j	                  | j                  | j                               | j
                  r-|j                  j	                  d| j                         z          y y )N&r<   )by_referencezPy_ssize_t )	r%  rz  impl_by_referencer   r3   r)  length_namer   simple_declaration)r$   r%  r  r   r?   s        r%   _render_selfzCConverter._render_self
  s    " **Sd:""1%;;&&t'7'7'9: 	##D$;$;I_I_$;$`a;;  ''8H8H8J(JK r'   c                    || _         | j                  }| j                  d      }|j                  j	                  |       | j                         }|r2|j                  j	                  d|z   dz   |j                         z          | j                         }|r2|j                  j	                  d|z   dz   |j                         z          |j                         rnQ|j                         r|j                  j	                  d       n%|j                  j	                  |j                         | j                         r)d|j                  vr|j                  j	                  d       |j                         r)d|j                  vr|j                  j	                  d       |j                  j	                  | j                          | j#                  |j$                         | j'                         x}r5|j&                  j	                  d	|z   dz   |j                         z   d
z          | j)                         }|r6|j(                  j	                  d|z   dz   |j                         z   d
z          y y )NT	in_parserz/* initializers for z */
z/* modifications for r<   r_  r  z/* Post parse cleanup for r}   z/* Cleanup for )r%  r   declarationr   r3   
initializer   r~   modifyr   r  r  r   ru  r   rt  rw  r  r   r   r   )	r$   r%  r  r   r  r   r   r   r   s	            r%   _render_non_selfzCConverter._render_non_self
  s   "yy t,  # ($$%;d%BW%L|ObObOd%de %%&=&Dw&NQ^QeQeQg&gh  ))+MM  $MM  0 #T->->">$$S)$$&3d6G6G+G$$S)  !1!12 	D001  ,,..<.$$%AD%H7%RUaUhUhUj%jmq%qr ,,.LL 1D 87 BW^^EU UX\ \] r'   c                 L    | j                  ||       | j                  ||       y)c
        parameter is a clinic.Parameter instance.
        data is a CRenderData instance.
        N)r,  r3  r$   r%  r  s      r%   r   zCConverter.render  s$    
 	)T*i.r'   c                 :    | j                   sy| j                  dz   S )z6Computes the name of the associated "length" variable.N_length)r)  rz  r#   s    r%   r*  zCConverter.length_name  s    {{)++r'   c                    | j                   r| j                  rJ | j                  dk(  r)| j                   sJ |j                  | j                          | j                  r%|j                  t	        | j                               n'| j
                  r|j                  | j
                         | j                  rdnd| j                  z   }|j                  |       | j                  r#|j                  d| j                         z          y y )Nr  r'  r<   )
rk  rt  rw  r3   rm   subclass_ofparse_by_referencer   r)  r*  )r$   r5   r?   s      r%   r  zCConverter.parse_argument(  s    NNt}}55t#>>!>KK'==KKt}}-.KK(()++Styy@A;;KKd..001 r'   r.  c                <   | j                   g}|s| j                   j                  d      s|j                  d       |r|j                  d       |r| j                  }n| j                  }| j
                  rd| d}|j                  |       dj                  |      S )z
        Computes the basic declaration of the variable.
        Used in computing the prototype declaration and the
        variable declaration.
        *rN   z
Py_UNUSED(r%  r<   )ro  r  r3   rz  r   r  r=   )r$   r(  r/  rL  r   s        r%   r+  zCConverter.simple_declaration=  s     YYK	tyy11#6S!S!##D99D{{#D6+wwy!!r'   c                   | j                  d      g}| j                  }|s"| j                  j                  r| j                  }|r"|j                  d       |j                  |       |j                  d       | j                  rA|j                  d       |j                  | j                                |j                  d       dj                  |      S )z;
        The C statement to declare this variable.
        Tr.  z = r`  z
Py_ssize_t r<   )	r+  r  r%  r   r  r3   r)  r*  r=   )r$   r/  r0  r  s       r%   r0  zCConverter.declarationQ  s     ...>?..4>>//,,Gu%w'3;;/t//12s#ww{##r'   c                      y)z
        The C statements required to set up this variable before parsing.
        Returns a string containing this code indented at column 0.
        If no initialization is necessary, returns an empty string.
        r<   r,   r#   s    r%   r1  zCConverter.initializec       r'   c                      y)z
        The C statements required to modify this variable after parsing.
        Returns a string containing this code indented at column 0.
        If no modification is necessary, returns an empty string.
        r<   r,   r#   s    r%   r2  zCConverter.modifyk  r@  r'   c                      y)z
        The C statements required to do some operations after the end of parsing but before cleaning up.
        Return a string containing this code indented at column 0.
        If no operation is necessary, return an empty string.
        r<   r,   r#   s    r%   r   zCConverter.post_parsings  r@  r'   c                      y)z
        The C statements required to clean up after this variable.
        Returns a string containing this code indented at column 0.
        If no cleanup is necessary, returns an empty string.
        r<   r,   r#   s    r%   r   zCConverter.cleanup{  r@  r'   c                      y)z
        A second initialization function, like converter_init,
        called just before rendering.
        You are permitted to examine self.function here.
        Nr,   r#   s    r%   r  zCConverter.pre_render  s     	r'   c                 P   | j                   dk(  r(dj                  || j                  | j                        S | j                   dk(  r| j                  dk7  rd| j                  z  nd}| j
                  t        v r7t        | j
                     \  }}dj                  || j                  ||||	      S d
j                  || j                  | j
                  ||      S | j                   dk(  r>| j                  dk7  rd| j                  z  nd}dj                  || j                  |      S y )Nr  z
                if (!{converter}({argname}, &{paramname})) {{{{
                    goto exit;
                }}}}
                )r  	paramnamerk  O!rH  z(%s)r<   a  
                    if (!{typecheck}({argname})) {{{{
                        _PyArg_BadArgument("{{name}}", {displayname}, "{typename}", {argname});
                        goto exit;
                    }}}}
                    {paramname} = {cast}{argname};
                    )r  rF  r  	typechecktypenamecasta$  
                if (!PyObject_TypeCheck({argname}, {subclass_of})) {{{{
                    _PyArg_BadArgument("{{name}}", {displayname}, ({subclass_of})->tp_name, {argname});
                    goto exit;
                }}}}
                {paramname} = {cast}{argname};
                )r  rF  r:  rJ  r  rS  z@
                {paramname} = {cast}{argname};
                )r  rF  rJ  )rw  r   rz  rk  ro  r:  type_checks)r$   r  r  rJ  rH  rI  s         r%   ry  zCConverter.parse_arg  s=   t# F7d6F6F%)^^  5	5 t#)-l)B6DII%D;.&1$2B2B&C#	8 w$:J:J+6)(0t  == F7d6F6F'+'7'7d'2  44 s")-l)B6DII%DF7d6F6FTFRS r'   r  c                      y rI   r,   r$   r  s     r%   r  zCConverter.set_template_dict  r   r'   c                 d    | j                   t        v rt        | j                   z   S | j                   S rI   )r   CLINIC_PREFIXED_ARGSCLINIC_PREFIXr#   s    r%   rz  zCConverter.parser_name  s(    99,, 499,,99r'   r?  )5r(   r)   r*   r   r   r+   r6   r  ro  r   r  objectr  bltnsr   r   r  r  r  r  rk  r)  r;  rw  rt  r:  r)  show_in_signaturesignature_namer
   r   r  r   r   ru  r   r,  r3  r   r*  r  r+  r0  r1  r2  r   r   r  ry  TemplateDictr  r  rz  r,   r'   r%   r  r  >
  sI    D#* GS4Z
 D#* "GV! JNL%**S/E%**S/3*>$??$FM !IsTz  "Jd
! $s# F !IsTz    K  HcDj K F
  N  +-! &*&*@K!-!-! -!
 -! d
-! t-! wy'<'<==-! -!^1T 1Lc L L L+^Z/ /; /4 /,2*"% "( (- $$C  c  #J|    r'   r  )PyLong_Checkr   )PyTuple_Checkr   )PyList_Checkr5   )PySet_Checkr  )PyFrozenSet_Check	frozenset)PyDict_Checkr  )PyUnicode_Checkr+   )PyBytes_Checkbytes)PyByteArray_Check	bytearray)	z&PyLong_Typez&PyTuple_Typez&PyList_Typez&PySet_Typez&PyFrozenSet_Typez&PyDict_Typez&PyUnicode_Typez&PyBytes_Typez&PyByteArray_Typer  r  return_convertersc                   T     e Zd ZdZeZdZdZehdde	ddfdZ
d	ed
edef fdZ xZS )bool_converterr   r   rY  acceptrf  r   Nc                
   |t         hk(  rd| _        n!|t        hk7  rt        dt	        |      z          | j
                  t        ur>t        | j
                        | _        t        t        | j
                              | _	        y y )Nr   z*bool_converter: illegal 'accept' argument )
r   rw  rQ  rG   r   r  r   r  r+   r  r$   rf  s     r%   r   zbool_converter.converter_init  se    cU?"Dx=VLM<<{*-DL T\\!23DN +r'   r  r  c                     | j                   dk(  rdj                  || j                        S | j                   dk(  rdj                  || j                        S t        |   ||      S )Nr   
                {paramname} = _PyLong_AsInt({argname});
                if ({paramname} == -1 && PyErr_Occurred()) {{{{
                    goto exit;
                }}}}
                r  rF  r   z
                {paramname} = PyObject_IsTrue({argname});
                if ({paramname} < 0) {{{{
                    goto exit;
                }}}}
                rw  r   rz  r5  ry  r$   r  r  r   s      r%   ry  zbool_converter.parse_arg  sw    s"
 F7d6F6FFGH $
 F7d6F6FFGH w +66r'   )r(   r)   r*   ro  r  r  rw  r  rQ  TypeSetr   r+   ry  r  r  s   @r%   rd  rd    sO    DLK39( 4 4t 47 73 73 7 7r'   rd  c                   8    e Zd ZdZdZdZdZddd
dZd
dZd	 Z	y)rm  zb
    A special-case converter:
    this is the default converter used for the defining class.
    PyTypeObject *r<   FNro  c                    || _         y rI   specified_typer$   ro  s     r%   r   z'defining_class_converter.converter_init  
    "r'   c                 (    | j                  ||       y rI   )r,  r6  s      r%   r   zdefining_class_converter.render  s    )T*r'   c                 "    | j                   |d<   y )Ndefining_class_namer  rM  s     r%   r  z*defining_class_converter.set_template_dict  s    /3yy+,r'   r   )
r(   r)   r*   r   ro  rw  rS  r   r   r  r,   r'   r%   rm  rm    s+     DK%) #+9r'   rm  c                   H     e Zd ZdZeefZdZdZd	dZ	de
de
de
f fdZ xZS )
char_convertercharr   ' 'r   c                 2   t        | j                  | j                        rwt        | j                        dk7  r!t	        dt        | j                        z          t        t        | j                              dd  | _        | j                  dk(  rd| _        y y y )Nr   z&char_converter: illegal default value z"'"z'\'')r;  r  r  r  rG   r   r_  r  r#   s    r%   r   zchar_converter.converter_init  sw    dllD$5$564<< A%=T\\@RRS!%"56qr:DN~~'!( ( 7r'   r  r  c                 ~    | j                   dk(  rdj                  || j                  |      S t        |   ||      S )Nr   a9  
                if (PyBytes_Check({argname}) && PyBytes_GET_SIZE({argname}) == 1) {{{{
                    {paramname} = PyBytes_AS_STRING({argname})[0];
                }}}}
                else if (PyByteArray_Check({argname}) && PyByteArray_GET_SIZE({argname}) == 1) {{{{
                    {paramname} = PyByteArray_AS_STRING({argname})[0];
                }}}}
                else {{{{
                    _PyArg_BadArgument("{{name}}", {displayname}, "a byte string of length 1", {argname});
                    goto exit;
                }}}}
                r  rF  r  rl  rm  s      r%   ry  zchar_converter.parse_arg%  sM    s" F7d6F6F'2  44 w +66r'   r   )r(   r)   r*   ro  r_  ra  r  rw  r  r   r+   ry  r  r  s   @r%   r{  r{    sA    D9%LK)7 73 73 7 7r'   r{  Bbitwisec                   R     e Zd ZdZeZdZdZdddeddfd	Z	d
e
de
de
f fdZ xZS )unsigned_char_converterzunsigned charr   r}  Fr  r  r   Nc                    |rd| _         y y )Nr  )rw  r$   r  s     r%   r   z&unsigned_char_converter.converter_init>  s    "D r'   r  r  c                     | j                   dk(  rdj                  || j                        S | j                   dk(  rdj                  || j                        S t        |   ||      S )Nr   ad  
                {{{{
                    long ival = PyLong_AsLong({argname});
                    if (ival == -1 && PyErr_Occurred()) {{{{
                        goto exit;
                    }}}}
                    else if (ival < 0) {{{{
                        PyErr_SetString(PyExc_OverflowError,
                                        "unsigned byte integer is less than minimum");
                        goto exit;
                    }}}}
                    else if (ival > UCHAR_MAX) {{{{
                        PyErr_SetString(PyExc_OverflowError,
                                        "unsigned byte integer is greater than maximum");
                        goto exit;
                    }}}}
                    else {{{{
                        {paramname} = (unsigned char) ival;
                    }}}}
                }}}}
                rk  r  a  
                {{{{
                    unsigned long ival = PyLong_AsUnsignedLongMask({argname});
                    if (ival == (unsigned long)-1 && PyErr_Occurred()) {{{{
                        goto exit;
                    }}}}
                    else {{{{
                        {paramname} = (unsigned char) ival;
                    }}}}
                }}}}
                rl  rm  s      r%   ry  z!unsigned_char_converter.parse_argB  sw    s"( F7d6F6FFG)H* $
 F7d6F6FFG
H w +66r'   )r(   r)   r*   ro  r   r  rw  r  r  r   r+   ry  r  r  s   @r%   r  r  7  sM    DLK05 # #$ ##7 #73 #73 #7 #7r'   r  c                       e Zd Zy)byte_converterNr(   r)   r*   r,   r'   r%   r  r  g      r'   r  c                   <     e Zd ZdZeZdZdZdededef fdZ	 xZ
S )short_convertershorthrY  r  r  r   c                 |    | j                   dk(  rdj                  || j                        S t        |   ||      S )Nr  a`  
                {{{{
                    long ival = PyLong_AsLong({argname});
                    if (ival == -1 && PyErr_Occurred()) {{{{
                        goto exit;
                    }}}}
                    else if (ival < SHRT_MIN) {{{{
                        PyErr_SetString(PyExc_OverflowError,
                                        "signed short integer is less than minimum");
                        goto exit;
                    }}}}
                    else if (ival > SHRT_MAX) {{{{
                        PyErr_SetString(PyExc_OverflowError,
                                        "signed short integer is greater than maximum");
                        goto exit;
                    }}}}
                    else {{{{
                        {paramname} = (short) ival;
                    }}}}
                }}}}
                rk  rl  rm  s      r%   ry  zshort_converter.parse_argo  sF    s"( F7d6F6FFG)H* w +66r'   r(   r)   r*   ro  r   r  rw  r  r+   ry  r  r  s   @r%   r  r  i  s7    DLK7 73 73 7 7r'   r  c                   N     e Zd ZdZeZdZdddeddfdZd	e	d
e	de	f fdZ
 xZS )unsigned_short_converterzunsigned shortrY  Fr  r  r   Nc                &    |rd| _         y d| _        y )NH_PyLong_UnsignedShort_Converterrw  rk  r  s     r%   r   z'unsigned_short_converter.converter_init  s    "D>DNr'   r  r  c                 |    | j                   dk(  rdj                  || j                        S t        |   ||      S )Nr  z
                {paramname} = (unsigned short)PyLong_AsUnsignedLongMask({argname});
                if ({paramname} == (unsigned short)-1 && PyErr_Occurred()) {{{{
                    goto exit;
                }}}}
                rk  rl  rm  s      r%   ry  z"unsigned_short_converter.parse_arg  F    s"
 F7d6F6FFGH w +66r'   r(   r)   r*   ro  r   r  r  r  r   r+   ry  r  r  s   @r%   r  r    sH    DL05 ? ?$ ?7 73 73 7 7r'   r  r3  re  c                   V     e Zd ZdZeZdZdZehdddeddfdZ	d	e
d
e
de
f fdZ xZS )int_converterr   r   rY  N)rf  ro  rf  r   c                ~    |t         hk(  rd| _        n!|t        hk7  rt        dt	        |      z          ||| _        y y )Nr3  z)int_converter: illegal 'accept' argument )r+   rw  r   rG   r   ro  )r$   rf  ro  s      r%   r   zint_converter.converter_init  s@    cU?"Du_<tF|KLDI r'   r  r  c                     | j                   dk(  rdj                  || j                        S | j                   dk(  rdj                  || j                  |      S t        |   ||      S )Nr   rj  rk  r3  ab  
                if (!PyUnicode_Check({argname})) {{{{
                    _PyArg_BadArgument("{{name}}", {displayname}, "a unicode character", {argname});
                    goto exit;
                }}}}
                if (PyUnicode_READY({argname})) {{{{
                    goto exit;
                }}}}
                if (PyUnicode_GET_LENGTH({argname}) != 1) {{{{
                    _PyArg_BadArgument("{{name}}", {displayname}, "a unicode character", {argname});
                    goto exit;
                }}}}
                {paramname} = PyUnicode_READ_CHAR({argname}, 0);
                r  rl  rm  s      r%   ry  zint_converter.parse_arg  s~    s"
 F7d6F6FFGH $ F7d6F6F'2  44 w +66r'   )r(   r)   r*   ro  r   r  rw  r  rn  r   r+   ry  r  r  s   @r%   r  r    sQ    DLK36%d  t 7 73 73 7 7r'   r  c                   N     e Zd ZdZeZdZdddeddfdZd	e	d
e	de	f fdZ
 xZS )unsigned_int_converterunsigned intrY  Fr  r  r   Nc                &    |rd| _         y d| _        y )NI_PyLong_UnsignedInt_Converterr  r  s     r%   r   z%unsigned_int_converter.converter_init  s    "D<DNr'   r  r  c                 |    | j                   dk(  rdj                  || j                        S t        |   ||      S )Nr  z
                {paramname} = (unsigned int)PyLong_AsUnsignedLongMask({argname});
                if ({paramname} == (unsigned int)-1 && PyErr_Occurred()) {{{{
                    goto exit;
                }}}}
                rk  rl  rm  s      r%   ry  z unsigned_int_converter.parse_arg  r  r'   r  r  s   @r%   r  r    sH    DL05 = =$ =7 73 73 7 7r'   r  c                   <     e Zd ZdZeZdZdZdededef fdZ	 xZ
S )long_converterlongr   rY  r  r  r   c                 |    | j                   dk(  rdj                  || j                        S t        |   ||      S )Nr   z
                {paramname} = PyLong_AsLong({argname});
                if ({paramname} == -1 && PyErr_Occurred()) {{{{
                    goto exit;
                }}}}
                rk  rl  rm  s      r%   ry  zlong_converter.parse_arg  r  r'   r  r  s   @r%   r  r    s7    DLK7 73 73 7 7r'   r  c                   N     e Zd ZdZeZdZdddeddfdZd	e	d
e	de	f fdZ
 xZS )unsigned_long_converterunsigned longrY  Fr  r  r   Nc                &    |rd| _         y d| _        y )Nr  _PyLong_UnsignedLong_Converterr  r  s     r%   r   z&unsigned_long_converter.converter_init  s    "D=DNr'   r  r  c                 ~    | j                   dk(  rdj                  || j                  |      S t        |   ||      S )Nr  a  
                if (!PyLong_Check({argname})) {{{{
                    _PyArg_BadArgument("{{name}}", {displayname}, "int", {argname});
                    goto exit;
                }}}}
                {paramname} = PyLong_AsUnsignedLongMask({argname});
                r  rl  rm  s      r%   ry  z!unsigned_long_converter.parse_arg  M    s" F7d6F6F'2  44 w +66r'   r  r  s   @r%   r  r    sH    DL05 > >$ >
7 
73 
73 
7 
7r'   r  c                   <     e Zd ZdZeZdZdZdededef fdZ	 xZ
S )long_long_converterz	long longLrY  r  r  r   c                 |    | j                   dk(  rdj                  || j                        S t        |   ||      S )Nr  z
                {paramname} = PyLong_AsLongLong({argname});
                if ({paramname} == -1 && PyErr_Occurred()) {{{{
                    goto exit;
                }}}}
                rk  rl  rm  s      r%   ry  zlong_long_converter.parse_arg  r  r'   r  r  s   @r%   r  r    s7    DLK7 73 73 7 7r'   r  c                   N     e Zd ZdZeZdZdddeddfdZd	e	d
e	de	f fdZ
 xZS )unsigned_long_long_converterzunsigned long longrY  Fr  r  r   Nc                &    |rd| _         y d| _        y )NK"_PyLong_UnsignedLongLong_Converterr  r  s     r%   r   z+unsigned_long_long_converter.converter_init  s    "DADNr'   r  r  c                 ~    | j                   dk(  rdj                  || j                  |      S t        |   ||      S )Nr  a  
                if (!PyLong_Check({argname})) {{{{
                    _PyArg_BadArgument("{{name}}", {displayname}, "int", {argname});
                    goto exit;
                }}}}
                {paramname} = PyLong_AsUnsignedLongLongMask({argname});
                r  rl  rm  s      r%   ry  z&unsigned_long_long_converter.parse_arg  r  r'   r  r  s   @r%   r  r    sK    DL05 B B$ B
7 
73 
73 
7 
7r'   r  c                   L     e Zd ZdZdZehddeddfdZded	edef fd
Z	 xZ
S )Py_ssize_t_converter
Py_ssize_trY  re  rf  r   Nc                    |t         hk(  rd| _        t         | _        y |t         t        hk(  rd| _        y t        dt        |      z          y )Nn_Py_convert_optional_to_ssize_tz0Py_ssize_t_converter: illegal 'accept' argument )r   rw  r  r   rk  rG   r   rh  s     r%   r   z#Py_ssize_t_converter.converter_init-  s@    cU?"D #DX&>DNCd6lRSr'   r  r  c                 |    | j                   dk(  rdj                  || j                        S t        |   ||      S )Nr  a  
                {{{{
                    Py_ssize_t ival = -1;
                    PyObject *iobj = _PyNumber_Index({argname});
                    if (iobj != NULL) {{{{
                        ival = PyLong_AsSsize_t(iobj);
                        Py_DECREF(iobj);
                    }}}}
                    if (ival == -1 && PyErr_Occurred()) {{{{
                        goto exit;
                    }}}}
                    {paramname} = ival;
                }}}}
                rk  rl  rm  s      r%   ry  zPy_ssize_t_converter.parse_arg6  sF    s" F7d6F6FFGH w +66r'   )r(   r)   r*   ro  r  r   rn  r   r+   ry  r  r  s   @r%   r  r  )  sH    D36% T TD T7 73 73 7 7r'   r  c                   *    e Zd ZdZeehddeddfdZy)slice_index_converterr  re  rf  r   Nc                    |t         hk(  rd| _        y |t         t        hk(  rd| _        y t        dt	        |      z          y )N_PyEval_SliceIndexNotNone_PyEval_SliceIndexz1slice_index_converter: illegal 'accept' argument )r   rk  r   rG   r   rh  s     r%   r   z$slice_index_converter.converter_initL  s7    cU?8DNX&1DNDtF|STr'   )r(   r)   r*   ro  r   r   rn  r   r,   r'   r%   r  r  I  s$    D36/ U Ud Ur'   r  c                   8     e Zd ZdZdZdZdededef fdZ xZS )size_t_convertersize_t_PyLong_Size_t_ConverterrY  r  r  r   c                 |    | j                   dk(  rdj                  || j                        S t        |   ||      S )Nr  z
                {paramname} = PyNumber_AsSsize_t({argname}, PyExc_OverflowError);
                if ({paramname} == -1 && PyErr_Occurred()) {{{{
                    goto exit;
                }}}}
                rk  rl  rm  s      r%   ry  zsize_t_converter.parse_argY  r  r'   )	r(   r)   r*   ro  rk  r  r+   ry  r  r  s   @r%   r  r  T  s2    D*I7 73 73 7 7r'   r  c                   (    e Zd ZdZdZdededefdZy)fildes_converterr    _PyLong_FileDescriptor_Converterr  r  r   c                 <    dj                  || j                        S )Nz
            {paramname} = PyObject_AsFileDescriptor({argname});
            if ({paramname} == -1) {{{{
                goto exit;
            }}}}
            rk  )r   r   )r$   r  r  s      r%   
_parse_argzfildes_converter._parse_argh  s     
 w$))<	=r'   N)r(   r)   r*   ro  rk  r+   r  r,   r'   r%   r  r  d  s&    D2I=# =C =C =r'   r  c                   <     e Zd ZdZeZdZdZdededef fdZ	 xZ
S )float_converterfloatr  0.0r  r  r   c                 |    | j                   dk(  rdj                  || j                        S t        |   ||      S )Nr  a  
                if (PyFloat_CheckExact({argname})) {{{{
                    {paramname} = (float) (PyFloat_AS_DOUBLE({argname}));
                }}}}
                else
                {{{{
                    {paramname} = (float) PyFloat_AsDouble({argname});
                    if ({paramname} == -1.0 && PyErr_Occurred()) {{{{
                        goto exit;
                    }}}}
                }}}}
                rk  rl  rm  s      r%   ry  zfloat_converter.parse_argw  F    s" F7d6F6FFGH w +66r'   r(   r)   r*   ro  r  r  rw  r  r+   ry  r  r  s   @r%   r  r  q  s7    DLK7 73 73 7 7r'   r  c                   <     e Zd ZdZeZdZdZdededef fdZ	 xZ
S )double_converterdoubler  r  r  r  r   c                 |    | j                   dk(  rdj                  || j                        S t        |   ||      S )Nr  a  
                if (PyFloat_CheckExact({argname})) {{{{
                    {paramname} = PyFloat_AS_DOUBLE({argname});
                }}}}
                else
                {{{{
                    {paramname} = PyFloat_AsDouble({argname});
                    if ({paramname} == -1.0 && PyErr_Occurred()) {{{{
                        goto exit;
                    }}}}
                }}}}
                rk  rl  rm  s      r%   ry  zdouble_converter.parse_arg  r  r'   r  r  s   @r%   r  r    s7    DLK7 73 73 7 7r'   r  c                   <     e Zd ZdZeZdZdZdededef fdZ	 xZ
S )Py_complex_converter
Py_complexDz
{0.0, 0.0}r  r  r   c                 |    | j                   dk(  rdj                  || j                        S t        |   ||      S )Nr  z
                {paramname} = PyComplex_AsCComplex({argname});
                if (PyErr_Occurred()) {{{{
                    goto exit;
                }}}}
                rk  rl  rm  s      r%   ry  zPy_complex_converter.parse_arg  r  r'   )r(   r)   r*   ro  complexr  rw  r  r+   ry  r  r  s   @r%   r  r    s7    DLK$7 73 73 7 7r'   r  c                   (    e Zd ZdZdZdddd	 ddZy)rv  rH  rS  N)rk  ro  r:  c                t    |r|rt        d       d| _        || _        n|rd| _        || _        ||| _        y y )Nz9object: Cannot pass in both 'converter' and 'subclass_of'r  rG  )rG   rw  rk  r:  ro  )r$   rk  ro  r:  s       r%   r   zobject_converter.converter_init  sG     PQ#D&DN#D*DDI r'   r   )r(   r)   r*   ro  rw  r   r,   r'   r%   rv  rv    s&    DK 	
 
r'   rv  c                       e Zd Zy)r]  Nr  r,   r'   r%   r]  r]    r  r'   r]  c                       e Zd Zy)rwbufferNr  r,   r'   r%   r  r    r  r'   r  c                       e Zd Zy)robufferNr  r,   r'   r%   r  r    r  r'   r  c                 B    t        |       t        |      t        |      fS rI   )r[  r  )typesrt  zeroess      r%   str_converter_keyr    s    ed8nd6l;;r'   str_converter_argument_mapc            	       n     e Zd ZdZeeefZdZehdddde	dedz  de
d	dfd
Zd Zdeded	ef fdZ xZS )str_converterzconst char *r?   NF)rf  rt  r  rf  rt  r  r   c                H   t        |||      }t        j                  |      }|st        d|       || _        t        |      | _        |r9| j                  t        d t        fvrt        d       || _
        d| _        d| _        t        |v r| j                  dk(  rd| _        y y y )Nz/str_converter: illegal combination of argumentszQstr_converter: Argument Clinic doesn't support default values for encoded stringszchar *r  Py_None)r  r  r   rG   rw  r  r)  r  r.   r   rt  ro  r  r   )r$   rf  rt  r  r   rw  s         r%   r   zstr_converter.converter_init  s      &9044S9BCH&6l||D$#<<hi$DM DI $DNv$..I"=#DN #>r'   c                 @    | j                   r| j                  }d| dS y )NzPyMem_FREE();
)rt  r   r$   r   s     r%   r   zstr_converter.post_parsing  s&    ==99D d++ r'   r  r  c                     | j                   dk(  rdj                  || j                  |      S | j                   dk(  rdj                  || j                  |      S t        |   ||      S )Nr?   a  
                if (!PyUnicode_Check({argname})) {{{{
                    _PyArg_BadArgument("{{name}}", {displayname}, "str", {argname});
                    goto exit;
                }}}}
                Py_ssize_t {paramname}_length;
                {paramname} = PyUnicode_AsUTF8AndSize({argname}, &{paramname}_length);
                if ({paramname} == NULL) {{{{
                    goto exit;
                }}}}
                if (strlen({paramname}) != (size_t){paramname}_length) {{{{
                    PyErr_SetString(PyExc_ValueError, "embedded null character");
                    goto exit;
                }}}}
                r  zaU  
                if ({argname} == Py_None) {{{{
                    {paramname} = NULL;
                }}}}
                else if (PyUnicode_Check({argname})) {{{{
                    Py_ssize_t {paramname}_length;
                    {paramname} = PyUnicode_AsUTF8AndSize({argname}, &{paramname}_length);
                    if ({paramname} == NULL) {{{{
                        goto exit;
                    }}}}
                    if (strlen({paramname}) != (size_t){paramname}_length) {{{{
                        PyErr_SetString(PyExc_ValueError, "embedded null character");
                        goto exit;
                    }}}}
                }}}}
                else {{{{
                    _PyArg_BadArgument("{{name}}", {displayname}, "str or None", {argname});
                    goto exit;
                }}}}
                rl  rm  s      r%   ry  zstr_converter.parse_arg  s    s" F7d6F6F'2  44  s"& F7d6F6F'2  4'4* w +66r'   )r(   r)   r*   ro  r+   r.   r   r  rw  rn  r  r   r   ry  r  r  s   @r%   r  r    s{    Dx(LK
  #e#' $ $ Dj	$
 $ 
$4,
(7 (73 (73 (7 (7r'   r  )rt  r  rw  rf  rt  r  c                    |s@| dk7  r;i }|t         hk7  r||d<   |rd|d<   t        j                  t        fi |}|t        | <   t
        }t        |||      }||v rt        j                  d       | ||<   y )Nr?   rf  Tr  z8Duplicate keys specified for str_converter_argument_map!)	r+   r  r  r  r  r  r  rX   rY   )rw  rf  rt  r  r   r  r  r   s           r%   r  r  2  s     s* (*cU?%F8#F8##M<V<)0+&"A
FHf
5C
axKLAcFr'   es)rt  rf  zes#)rt  r  rf  etzet#zs#)r  rf  yzy#r  zz#c                   4     e Zd ZdZdZdededef fdZ xZS )PyBytesObject_converterzPyBytesObject *Sr  r  r   c                     | j                   dk(  r)dj                  || j                  | j                  |      S t        |   ||      S )Nr  a  
                if (!PyBytes_Check({argname})) {{{{
                    _PyArg_BadArgument("{{name}}", {displayname}, "bytes", {argname});
                    goto exit;
                }}}}
                {paramname} = ({type}){argname};
                r  rF  ro  r  rw  r   rz  ro  r5  ry  rm  s      r%   ry  z!PyBytesObject_converter.parse_arga  U    s" F7d6F6F $		{  DD w +66r'   r(   r)   r*   ro  rw  r+   ry  r  r  s   @r%   r  r  \  s,    DK
7 
73 
73 
7 
7r'   r  c                   4     e Zd ZdZdZdededef fdZ xZS )PyByteArrayObject_converterzPyByteArrayObject *Yr  r  r   c                     | j                   dk(  r)dj                  || j                  | j                  |      S t        |   ||      S )Nr  a	  
                if (!PyByteArray_Check({argname})) {{{{
                    _PyArg_BadArgument("{{name}}", {displayname}, "bytearray", {argname});
                    goto exit;
                }}}}
                {paramname} = ({type}){argname};
                r   r  rm  s      r%   ry  z%PyByteArrayObject_converter.parse_argr  r  r'   r  r  s   @r%   r  r  m  s,     DK
7 
73 
73 
7 
7r'   r  c                   >     e Zd ZdZeeefZdZdededef fdZ	 xZ
S )unicode_converterrH  Ur  r  r   c                 ~    | j                   dk(  rdj                  || j                  |      S t        |   ||      S )Nr
  ah  
                if (!PyUnicode_Check({argname})) {{{{
                    _PyArg_BadArgument("{{name}}", {displayname}, "str", {argname});
                    goto exit;
                }}}}
                if (PyUnicode_READY({argname}) == -1) {{{{
                    goto exit;
                }}}}
                {paramname} = {argname};
                r  rl  rm  s      r%   ry  zunicode_converter.parse_arg  sM    s"	 F7d6F6F'2  4
4 w +66r'   )r(   r)   r*   ro  r+   r.   r   r  rw  ry  r  r  s   @r%   r	  r	  ~  s8    Dx(LK7 73 73 7 7r'   r	  uzu#)r  ZzZ#rf  r  c                   ^     e Zd ZdZeeefZehdddede	ddfdZ
d	 Zd
ededef fdZ xZS )Py_UNICODE_converterzconst Py_UNICODE *Fr  rf  r  r   Nc                   |t         t        hk(  rdnd}|r|dz  }d| _        || _        d| _        y || _        |t         hk(  rd| _        d| _        y |t         t        hk(  rd| _        d| _        y t        dt        |      z          d| _        y )	Nr  r  r   T#_PyUnicode_WideCharString_Converter'_PyUnicode_WideCharString_Opt_Converterz0Py_UNICODE_converter: illegal 'accept' argument r  )	r+   r   r)  rw  rf  rk  rG   r   r  )r$   rf  r  rw  s       r%   r   z#Py_UNICODE_converter.converter_init  s    
 $c8_4c#3KDK*D   !DK#!F
  	 C?*!J   G$v,VWr'   c                 T    | j                   sdj                  | j                        S y )NzPyMem_Free((void *){name});
r  )r)  r   r   r#   s    r%   r   zPy_UNICODE_converter.cleanup  s(    {{
F		F r'   r  argnumc                    | j                   si| j                  t        hk(  rdj                  || j                  |      S | j                  t        t
        hk(  rdj                  || j                  |      S t        |   ||      S )Na  
                    if (!PyUnicode_Check({argname})) {{{{
                        _PyArg_BadArgument("{{name}}", {argnum}, "str", {argname});
                        goto exit;
                    }}}}
                    {paramname} = PyUnicode_AsWideCharString({argname}, NULL);
                    if ({paramname} == NULL) {{{{
                        goto exit;
                    }}}}
                    )r  rF  r  ag  
                    if ({argname} == Py_None) {{{{
                        {paramname} = NULL;
                    }}}}
                    else if (PyUnicode_Check({argname})) {{{{
                        {paramname} = PyUnicode_AsWideCharString({argname}, NULL);
                        if ({paramname} == NULL) {{{{
                            goto exit;
                        }}}}
                    }}}}
                    else {{{{
                        _PyArg_BadArgument("{{name}}", {argnum}, "str or None", {argname});
                        goto exit;
                    }}}}
                    )r)  rf  r+   r   r   r   r5  ry  )r$   r  r  r   s      r%   ry  zPy_UNICODE_converter.parse_arg  s    {{{{se#	 w$))FS	T h/ w$))FST w &11r'   )r(   r)   r*   ro  r+   r.   r   r  rn  r  r   r   ry  r  r  s   @r%   r  r    se    
  Dx(L  #e      
	 (2 2c 2c 2 2r'   r  s*z*w*c                   Z     e Zd ZdZdZdZdZehddeddfd	Z	d
 Z
dededef fdZ xZS )Py_buffer_converter	Py_buffery*Tz{NULL, NULL}re  rf  r   Nc                F   | j                   t        d fvrt        d       | j                  | _        |t
        t        t        hk(  r
d}|| _	        y |t
        t        hk(  r
d}|| _	        y |t        hk(  r
d}|| _	        y |t        hk(  r
d}|| _	        y t        d       | _	        y )Nz3The only legal default value for Py_buffer is None.r  r  r  r  z5Py_buffer_converter: illegal combination of arguments)
r  r   rG   r  r  r+   r]  r   r  rw  )r$   rf  rw  s      r%   r   z"Py_buffer_converter.converter_init  s    <<T22FG//c68,,K ' V}$K ' xK ' z!K ' HI&r'   c                 F    | j                   }dj                  d|d|dg      S )Nr<   if (z.obj) {
   PyBuffer_Release(&z);
}
)r   r=   r  s     r%   r   zPy_buffer_converter.cleanup  s&    yyww&FiXYYr'   r  r  c                 2   | j                   dk(  rdj                  || j                  |      S | j                   dk(  rdj                  || j                  |      S | j                   dk(  rdj                  || j                  |      S t        |   ||      S )Nr  ay  
                if (PyObject_GetBuffer({argname}, &{paramname}, PyBUF_SIMPLE) != 0) {{{{
                    goto exit;
                }}}}
                if (!PyBuffer_IsContiguous(&{paramname}, 'C')) {{{{
                    _PyArg_BadArgument("{{name}}", {displayname}, "contiguous buffer", {argname});
                    goto exit;
                }}}}
                r  r  a\  
                if (PyUnicode_Check({argname})) {{{{
                    Py_ssize_t len;
                    const char *ptr = PyUnicode_AsUTF8AndSize({argname}, &len);
                    if (ptr == NULL) {{{{
                        goto exit;
                    }}}}
                    PyBuffer_FillInfo(&{paramname}, {argname}, (void *)ptr, len, 1, 0);
                }}}}
                else {{{{ /* any bytes-like object */
                    if (PyObject_GetBuffer({argname}, &{paramname}, PyBUF_SIMPLE) != 0) {{{{
                        goto exit;
                    }}}}
                    if (!PyBuffer_IsContiguous(&{paramname}, 'C')) {{{{
                        _PyArg_BadArgument("{{name}}", {displayname}, "contiguous buffer", {argname});
                        goto exit;
                    }}}}
                }}}}
                r  a  
                if (PyObject_GetBuffer({argname}, &{paramname}, PyBUF_WRITABLE) < 0) {{{{
                    PyErr_Clear();
                    _PyArg_BadArgument("{{name}}", {displayname}, "read-write bytes-like object", {argname});
                    goto exit;
                }}}}
                if (!PyBuffer_IsContiguous(&{paramname}, 'C')) {{{{
                    _PyArg_BadArgument("{{name}}", {displayname}, "contiguous buffer", {argname});
                    goto exit;
                }}}}
                rl  rm  s      r%   ry  zPy_buffer_converter.parse_arg  s    t# F7d6F6F'2  4	4 %$ F7d6F6F'2  4%4( %
 F7d6F6F'2  44 w +66r'   )r(   r)   r*   ro  rw  r)  r  r]  rn  r   r   r+   ry  r  r  s   @r%   r  r    sX     DK&39( ' 't '&Z.7 .73 .73 .7 .7r'   r  c                     | j                   t        t        fv r| j                  ryy| j                   t        k(  ry| j                   t
        t        fv ryt        dt        | j                         z         )N)rH  r$   )rH  r  )zvoid *null)rp  ro  zUnhandled type of function f: )	rp  r  rr  r  r  r  rq  RuntimeErrorr   )r  s    r%   correct_name_for_selfr%  $  s\    vv(K((55'%vvvv,
++'
7$qvv,F
GGr'   c                 h    t        |       \  }}| j                  t        t        t        t
        fv r|S y rI   )r%  rp  rr  rq  r  r  )r  ro  r*  s      r%   !required_type_for_self_for_parserr'  /  s-    #A&GD!vv+z=,GGr'   c                   H    e Zd ZdZdZdZddd
dZd Zed        Z	d Z
d	 Zy)rl  zV
    A special-case converter:
    this is the default converter used for "self".
    Nr<   rq  c                    || _         y rI   rs  ru  s     r%   r   zself_converter.converter_init>  rv  r'   c                     | j                   }t        |      \  }}|| _        | j                  xs | j                  xs || _        | j                   j
                  }|t        t        fv }|t        k(  s|rd| _	        y y r  )
r>  r%  rT  rt  ro  rp  rq  rr  r  rS  )r$   r  r  default_namerp  r  s         r%   r  zself_converter.pre_renderA  sr    MM%:1%="l*''D499D	}}!!z;77M!k%*D" '2r'   c                 H    t        | j                        xs | j                  S rI   )r'  r>  ro  r#   s    r%   parser_typezself_converter.parser_types  s    0?L499Lr'   c                 f   | j                   j                  t        k(  ry| j                  ||       | j                  | j
                  k7  rht        |j                        dk(  sJ |j                  d   | j                  k(  sJ d| j                  z   dz   |j                  d   z   |j                  d<   yy)r5  Nr   r   r$  r%  )	r>  rp  r  r,  ro  r-  r  r   r   r6  s      r%   r   zself_converter.renderw  s    
 ==.)T*99((( t**+q000&&q)TYY666%(499_s%:T=P=PQR=S%SD" )r'   c                    | j                   |d<   | j                  |d<   | j                  j                  }| j                  j                  }|t
        t        fv r|r|j                  rv|t
        k(  rdj                  | j                         }ndj                  | j                         }| d}||d<   | j                  j                  j                  }d| d}||d	<   y y y y )
Nr  r  z4({0} == base_tp || {0}->tp_init == base_tp->tp_init)zN(Py_IS_TYPE({0}, base_tp) ||
         Py_TYPE({0})->tp_new == base_tp->tp_new)z &&
        r  zPyTypeObject *base_tp = r`  base_type_ptr)
r   r-  r>  rp  r  rq  rr  r  r   r  )r$   r  rp  r  
type_checkr   r  type_ptrs           r%   r  z self_converter.set_template_dict  s    %)YYk"%)%5%5k"}}!!mmj+..CCKKz!J6$))$ J%vdii0  !\/D/3M+,--++77K1+a@H-5M/* =HC.r'   r   )r(   r)   r*   r   ro  rw  r   r  r  r-  r   r  r,   r'   r%   rl  rl  6  sB     DK%) #
+d M MT$6r'   rl  r  r   c                 |    |s0| j                   }|j                  d      s| S |j                  d      }| t        |<   | S )N_return_converter)r(   r  r  rb  r  s     r%   add_c_return_converterr5    sC     zz}}01H  !45dHr'   c            
       <    e Zd Zdededeedf   deeef   ddf
dZ	y)	CReturnConverterAutoRegisterr  r   r  .r  r   Nc                     t        |        y rI   )r5  r  s       r%   r   z%CReturnConverterAutoRegister.__init__  s     	s#r'   )
r(   r)   r*   r  r+   r   ro  r  r   r   r,   r'   r%   r7  r7    sF    $$$$ s#$ CH~	$
 
$r'   r7  c                       e Zd ZU dZdZeed<   dddedz  ddfdZddZ	d	e
ddfd
Zded	e
ddfdZded	e
ddfdZded	e
ddfdZy)r  rH  Nr  )r  r  r   c                ,   || _         	  | j                  di | y # t        $ rn}dj                  d |j	                         D              }t        j                  | j                  j                  dz   |z   dz   t        |      z          Y d }~y d }~ww xY w)Nr'  c              3   D   K   | ]  \  }}|d z   t        |      z     yw)r4  N)r   )rq   r   r!   s      r%   rs   z,CReturnConverter.__init__.<locals>.<genexpr>  s!     U{tU$*tE{2Us    r$  z)
r,   )
r  return_converter_init	TypeErrorr=   r   rX   rY   r   r(   r+   )r$   r  r   er?   s        r%   r   zCReturnConverter.__init__  s     %	I&D&&00 	I		UfllnUUAHHT^^,,s2Q6>QGHH	Is    	BA$BBc                      y rI   r,   r#   s    r%   r<  z&CReturnConverter.return_converter_init  s    Sr'   r  c                 *   g }|j                   } || j                         | j                  j                  d      s |d        ||j                  dz          |j                  j                  dj                  |             |j                  |_        y )Nr=  rN   r`  r<   )r3   ro  r  r   r   r=   r   )r$   r  r   r\   s       r%   declarezCReturnConverter.declare  sq    kkDIIyy!!#&HD!!C'(  / 11r'   exprc                 F    d| d}|j                   j                  |       y )Nzif ((z*) && PyErr_Occurred()) {
    goto exit;
}
r   r3   )r$   rB  r  r   s       r%   err_occurred_ifz CReturnConverter.err_occurred_if  s'    
 tfKL%%d+r'   variablec                 F    d| d}|j                   j                  |       y )Nr   z == NULL) {
    goto exit;
}
rD  )r$   rF  r  r   s       r%   err_occurred_if_null_pointerz-CReturnConverter.err_occurred_if_null_pointer  s'    
 hZAB%%d+r'   r>  c                      y rI   r,   r$   r>  r  s      r%   r   zCReturnConverter.render       r'   r   )r(   r)   r*   ro  r  rQ  r6   r+   r   r<  r   rA  rE  rH  r<  r   r,   r'   r%   r  r    s    
 D GV
 &*I d
I
 
I 12K 2D 2,, , 
	,,, , 
	,  
	r'   r  rQ  c                   $    e Zd ZdZdededdfdZy)bool_return_converterr   r>  r  r   Nc                     | j                  |       | j                  |j                   d|       |j                  j	                  d|j                   d       y )Nz == -1z%return_value = PyBool_FromLong((long)r  )rA  rE  r   r   r3   rJ  s      r%   r   zbool_return_converter.render  sU    
 	T 5 56f=tD%%3D4I4I3J$O	
r'   )r(   r)   r*   ro  r<  r   r   r,   r'   r%   rM  rM    s(    D	
	
 	
 
		
r'   rM  c                   0    e Zd ZdZdZdZdZdededdfdZ	y)	long_return_converterr  PyLong_FromLongr<   r>  r  r   Nc                    | j                  |       | j                  |j                   d| j                   d|       |j                  j                  d| j                   d| j                   |j                   d       y )Nz == z-1zreturn_value = r$  r  )rA  rE  r   unsigned_castr   r3   conversion_fnrJ  rJ  s      r%   r   zlong_return_converter.render  sy    
 	T 5 56d4;M;M:NbQSWX%%d001499+d>S>S=TTXY	
r'   )
r(   r)   r*   ro  rT  rJ  rS  r<  r   r   r,   r'   r%   rP  rP    s7    D%MDM	
	
 	
 
		
r'   rP  c                       e Zd ZdZdZy)int_return_converterr   (long)Nr(   r)   r*   ro  rJ  r,   r'   r%   rV  rV    s    DDr'   rV  c                   ,    e Zd ZdZdZdZdededdfdZy)	init_return_converterz:
    Special return converter for __init__ functions.
    r   rW  r>  r  r   Nc                      y rI   r,   rJ  s      r%   r   zinit_return_converter.render#  rK  r'   )	r(   r)   r*   r   ro  rJ  r<  r   r   r,   r'   r%   rZ  rZ    s4     DD  
	r'   rZ  c                       e Zd ZdZdZdZy)unsigned_long_return_converterr  PyLong_FromUnsignedLong(unsigned long)Nr(   r)   r*   ro  rT  rS  r,   r'   r%   r]  r]  *  s    D-M%Mr'   r]  c                       e Zd ZdZdZdZy)unsigned_int_return_converterr  r_  z(unsigned int)N)r(   r)   r*   ro  rJ  rS  r,   r'   r%   rb  rb  0  s    DD$Mr'   rb  c                       e Zd ZdZdZy)Py_ssize_t_return_converterr  PyLong_FromSsize_tN)r(   r)   r*   ro  rT  r,   r'   r%   rd  rd  6  s    D(Mr'   rd  c                       e Zd ZdZdZdZy)size_t_return_converterr  PyLong_FromSize_tz(size_t)Nr`  r,   r'   r%   rg  rg  ;  s    D'MMr'   rg  c                   (    e Zd ZdZdZdededdfdZy)double_return_converterr  r<   r>  r  r   Nc                     | j                  |       | j                  |j                   d|       |j                  j	                  d| j
                   |j                   d       y )Nz == -1.0z"return_value = PyFloat_FromDouble(r  )rA  rE  r   r   r3   rJ  rJ  s      r%   r   zdouble_return_converter.renderE  s^    
 	T 5 56h?F%%0D<Q<Q;RRVW	
r'   )r(   r)   r*   ro  rJ  r<  r   r   r,   r'   r%   rj  rj  A  s-    DD	
	
 	
 
		
r'   rj  c                       e Zd ZdZdZy)float_return_converterr  z(double)NrX  r,   r'   r%   rm  rm  Q  s    DDr'   rm  -)rE   c                    t        | t        j                        r| j                  } t        j                  |       } t        | |d      }t        ||      } |       S )z
    Takes an ast.Expr node.  Compiles and evaluates it.
    Returns the result of the expression.

    globals represents the globals dict the expression
    should see.  (There's no equivalent for "locals" here.)
    eval)r;  astExprr!   
Expressionr  r   )nodeglobalsrE   cofns        r%   eval_ast_exprrx  V  sJ     $!zz>>$D	x	(B	b'	"B4Kr'   c                   @    e Zd Zd Zd Zd Zd Zed        Zd Z	d Z
y)	IndentStackc                      g | _         d | _        y rI   )indentsmarginr#   s    r%   r   zIndentStack.__init__i  s    r'   c                 4    | j                   st        d       y y )Nz3IndentStack expected indents, but none are defined.)r|  rG   r#   s    r%   _ensurezIndentStack._ensurem  s    ||FG r'   c                     d|v rt        d       |j                         }t        |      s| j                          | j                  d   S t        |      t        |      z
  S )z:
        Returns the length of the line's margin.
        	z6Tab characters are illegal in the Argument Clinic DSL.rT   )rG   r%  r  r  r|  )r$   r   strippeds      r%   measurezIndentStack.measureq  sS     4<IJ;;=8} LLN<<##4y3x=((r'   c                    | j                  |      }d|z  }| j                  s#| j                  j                  |       || _        y| j                  d   }||k(  ry||kD  r#| j                  j                  |       || _        y|| j                  vrt	        d       d}||k7  r4| j                  j                          | j                  d   }|dz  }||k7  r4|| _        |S )z
        Infer what is now the current margin based on this line.
        Returns:
            1 if we have indented (or this is the first margin)
            0 if the margin has not changed
           -N if we have dedented N times
        rN   r   rT   r   zIllegal outdent.)r  r|  r3   r}  rG   r   )r$   r   r   r}  currentoutdent_counts         r%   inferzIndentStack.infer  s     d#v||LL' DK,,r"WGLL' DK%#$LLll2&GQM  r'   c                 ,    t        | j                        S )zA
        Returns how many margins are currently defined.
        )r  r|  r#   s    r%   depthzIndentStack.depth  s    
 4<<  r'   c                      | j                   |z   S )zA
        Indents a line by the currently defined margin.
        )r}  r   s     r%   r   zIndentStack.indent  s     {{T!!r'   c                 z    | j                   }| j                  d   }|j                  |      st        d       ||d S )zd
        Dedents a line by the currently defined margin.
        (The inverse of 'indent'.)
        rT   z<Cannot dedent, line does not start with the previous margin:N)r}  r|  r.  rG   )r$   r   r}  r   s       r%   r  zIndentStack.dedent  s<    
 b!v&OPFG}r'   N)r(   r)   r*   r   r  r  r  r  r  r   r  r,   r'   r%   rz  rz  h  s6    H)@ ! !"	r'   rz  c                      e Zd ZdeddfdZd2dZdeddfdZdeddfd	Zded
ededdfdZ	dededdfdZ
dededdfdZ	 d3dededdfdZdeddfdZdeddfdZd2dZd2dZd2dZd2dZdeddfdZdeddfdZed        Zed edefd!       Z	 d4d"ed edz  ddfd#Zd$ Zd% Z ed&      \  ZZ Z!Z"Z#Z$Z%d' Z&d( Z'd) Z(ed*e)jT                  dz  de+ee,e-f   fd+       Z.d, Z/d- Z0d. Z1d/ Z2d0 Z3d1 Z4y)5r  rU   r   Nc                 (   || _         i | _        t        |       D ]f  }|j                  d      \  }}}|rt	        | |      | j                  |<   |j                  d      \  }}}|sKt	        | |      | j                  d|z   <   h | j                          y )N
directive_at_@)rU   
directivesdirr   rV   reset)r$   rU   r   r*  r?   r   s         r%   r   zDSLParser.__init__  s    I 		AD|4IAq#'.tT':$ u-IAq#-4T4-@c	*		A 	

r'   c                    d | _         | j                  | _        d | _        d| _        d| _        d| _        | j                  | _        d| _	        t               | _        t        | _        d| _        d | _        d| _        d| _        y )NFr   r<   )r>  state_dsl_startstateparameter_indentkeyword_onlypositional_onlyr   ps_startparameter_stateseen_positional_with_defaultrz  r   r  rp  r  forced_text_signatureparameter_continuationpreserve_outputr#   s    r%   r  zDSLParser.reset  sx    "&"6"6
 $!$
#}},1)!m	15"&(#$r'   r
  c                 \    t        t        |      dk  rt        dt        z   dz   |z          y y )Nr   z(Insufficient Clinic version!
  Version: z
  Required: )r   r   rG   )r$   r
  s     r%   directive_versionzDSLParser.directive_version  s0    gx014<wFIYY\dde 5r'   r   c                 R   |j                  d      d d }| j                  j                  |      \  }}|rt        d       ||j                  v rt        dt        |      z   dz          t        ||      }||j                  |<   | j                  j                  j                  |       y )Nrt   rT   z#Can't nest a module inside a class!zAlready defined module r  )rv   rU   r  rG   r  r   r  r  r  r   r3   )r$   r   r   r  r  ms         r%   directive_modulezDSLParser.directive_module  s    C"%kk33F;676>>!*T$Z7#=>4  t

$$Q'r'   r  r  c                 d   |j                  d      }|j                         }| j                  j                  |      \  }}|xs |}||j                  v rt        dt        |      z   dz          t        |||||      }||j                  |<   | j                  j                  j                  |       y )Nrt   zAlready defined class r  )rv   r   rU   r  r  rG   r   r~  r  r   r3   )	r$   r   r  r  r   r  r  r  r   s	            r%   directive_classzDSLParser.directive_class  s     Czz|kk33F;6>>!)DJ6<=$Wk: t

$$Q'r'   r!   c                     |dvrt        dt        |             |j                  ddd      }|| j                  j                  |<   y )N)r  r  zunknown variablez/*z*/)zblock comment startzblock comment end)rG   r   r  rU   __dict__)r$   r   r!   s      r%   directive_setzDSLParser.directive_set  sK    55#T$Z0  #'!%" 
 &+T"r'   commandc                     |xdk(  r  | j                   j                  |g|  y dk(  r*| j                   j                  |      j                          y 	 t	        dt        |             y )Nri   r>   zunknown destination command)rU   r  r  r>   rG   r   )r$   r   r  r   s       r%   directive_destinationzDSLParser.directive_destination  sS     +++D848++D17792DMBr'   command_or_namer  c                    | j                   j                  }|dk(  rS| j                   j                  j                  |      }|st	        dt        |      z   dz          |j                  |       y |dk(  r4| j                   j                  j                  |j                                y |dk(  rW| j                   j                  st	        d       | j                   j                  j                         }|j                  |       y |dk(  r^| j                  j                  j                  t        j                  |             | j                  j                  j                  d       y | j                   j                  |      }|d	k(  rt!        |      D ]  }|||<   	 y ||vr,t	        d
t        |      z   dz   dj#                  |      z          |||<   y )Nr  zUnknown preset r  pushr   z#Can't 'output pop', stack is empty!rW   r}   r  z#Invalid command / destination name z5, must be one of:
  preset push pop print everything rN   )rU   r  r  r   rG   r   r  r  r3   r  r   r  r4   pprintpformatr  r5   r=   )r$   r  r  fdr  previous_fdr  r   s           r%   directive_outputzDSLParser.directive_output  s   
 [[,,h&[[((,,[9F&k)::S@AIIff$KK1188Ce#;;88:;++??CCEKIIk" g%JJ$$V^^B%78JJ$$T*KK..{;l*R 4"$6o9NN  RJ  J  MP  MU  MU  VX  MY  Y  Z?r'   c                     | j                   j                  j                  | j                  j	                  |      j                                y rI   )r  r4   r3   rU   r  r  r  s     r%   directive_dumpzDSLParser.directive_dumpE  s2    

  !<!<T!B!G!G!IJr'   r   c                     | j                   j                  j                  dj                  |             | j                   j                  j                  d       y )NrN   r}   )r  r4   r3   r=   )r$   r   s     r%   directive_printoutzDSLParser.directive_printoutH  s:    

  $0

  &r'   c                 @    | j                   rt        d       d| _         y )Nz'Can't have preserve twice in one block!T)r  rG   r#   s    r%   directive_preservezDSLParser.directive_preserveL  s    :;#r'   c                 T    | j                   t        urt        d       t        | _         y )Nz9Can't set @classmethod, function is not a normal callable)rp  r  rG   r  r#   s    r%   at_classmethodzDSLParser.at_classmethodQ  s    99H$LM 	r'   c                 T    | j                   t        urt        d       t        | _         y )Nz:Can't set @staticmethod, function is not a normal callable)rp  r  rG   r  r#   s    r%   at_staticmethodzDSLParser.at_staticmethodV  s    99H$MN!	r'   c                 @    | j                   rt        d       d| _         y )NzCalled @coexist twice!T)r  rG   r#   s    r%   
at_coexistzDSLParser.at_coexist[  s    <<)*r'   text_signaturec                 @    | j                   rt        d       || _         y )NzCalled @text_signature twice!)r  rG   )r$   r  s     r%   at_text_signaturezDSLParser.at_text_signature`  s    %%01%3"r'   r  c                    | j                          || _        | j                  j                  | _        g |_        | j                  j
                  j                  }|j                  j                  d      }t        || j                  j
                  j                        D ]3  \  }}d|v rt        dt        |      z   |       | j                  |       5 | j                  | j                         | j                  d        |j                  j!                  | j                  j"                  j%                  t        |j&                               | j(                  r)|j                  rt        d       | j                  |_        y y )Nr}   r  z/Tab characters are illegal in the Clinic DSL.
	)rF   z?'preserve' only works for blocks that don't produce any output!)r  r  r4   saved_outputrU   rQ   rF   r  rv   r   r  rG   r   r  nextstate_terminalr   r   r   r   r  )r$   r  block_startr  rF   r   s         r%   r  zDSLParser.parsee  s"   


 JJ--kk..::!!$'!*5$++2J2J2b2b!c 	Kt|H4PT:UcnoJJt	
 			$%%&

4DKK0077@P@PQR||VW,,EL  r'   c                 f    | j                         j                  d      ry| j                         syy)Nr   TF)r%  r.  r   r   s    r%   ignore_linezDSLParser.ignore_line{  s,     ;;=##C( zz|r'   r   c                 L    t        |       t        | j                               z
  S rI   )r  r   r  s    r%   calculate_indentzDSLParser.calculate_indent  s    4y3tzz|,,,r'   r  c                 :    || _         || j                  |       y y rI   )r  )r$   r  r   s      r%   r  zDSLParser.next  s"     
JJt r'   c                 8   | j                  |      ry t        j                  |      }|d   }| j                  j	                  |d       }|r
	  ||dd    y | j                  | j                  |       y # t
        $ r}t        t        |             Y d }~y d }~ww xY w)Nr   r   )
r  r5  rv   r  r   r=  rG   r+   r  state_modulename_name)r$   r   r   directive_name	directiver>  s         r%   r  zDSLParser.state_dsl_start  s    D! T"OO''=	6!":& 		$,,d3	  SVs   A2 2	B;BBc           
      "   |j                         sy | j                  j                  |       |j                  d      \  }}}|rV|j	                  d      \  }}}|j                         }|j                         }|j                         }t        |      r|rt        |      rt        |      r|j                  d      D cg c]  }|j                          }	}|	j                         }
| j                  j                  |	      \  }}|xs |j                  D ]  }|j                  |
k(  s n d }|s@t        d|d|d|       t        d|j                         t        dt        |      z   d	z          |j                  d      D cg c]  }|j                          }	}|	j                         }
| j                  j                  |	      \  }}|j                   | j                   k(  r|j"                  | j"                  k(  st        d
       |j%                  |
||||d      | _        | j(                  j*                  j-                  | j&                         |xs |j                  j-                  | j&                         | j/                  | j0                         y |j	                  d      \  }}}|j	                  d      \  }}}|j                         }|j                         xs d }t        |      st        d|       |rt        |      st        d|       d }|rd| d}d }	 t3        j4                  |      }|st        d|z   dz   |z          	 | j9                  |j:                  d   j<                        \  }}}|rt        dj?                  |             |t@        vrt        dt        |      z          tA        |   d"i |}|j                  d      D cg c]  }|j                          }	}|	j                         }
| j                  j                  |	      \  }}|j                  d      }	|	d   tD        v rt        |	d    d       |	d   dk(  r,| j                   tF        k7  s|st        d       tH        | _        n?|	d   dk(  r7| j                   tJ        k7  s|st        d       tL        | _        |s
tO               }|s
tQ               }|s(t        dt        |j                               z   dz          tS        |
|||||| j                   | j"                        | _        | j(                  j*                  j-                  | j&                         tU        | j&                        \  }}i }|r|dk(  r|jV                  |d <   tY        ||| j&                  fi |x}| j&                  _,        t[        |j                  t\        jZ                  j^                  | j&                  |!      }|| j&                  j`                  |j                  <   |xs |j                  j-                  | j&                         | j/                  | jb                         y c c}w c c}w # t6        $ r Y )w xY w# tB        $ r t        d|z   dz   |z          Y w xY wc c}w )#Nr4   as rt   classr  existingzcls. functionsz Couldn't find existing function r  zZ'kind' of function and cloned function don't match!  (@classmethod/@staticmethod/@coexist)r<   )r   r~  r  r  r  rD  z->zIllegal function name:zIllegal C basename:zdef x() -> z: passzBadly-formed annotation for z: r   z7Legacy converter {!r} not allowed as a return converterz%No available return converter called rT   zH is a special method and cannot be converted to Argument Clinic!  (Yet.)r  z__new__ must be a class method!r   z?__init__ must be a normal method, not a class or static method!z(Undefined module used in declaration of )r   r~  r  r  r  rn  rp  r  rH  ro  )r>  rk  r,   )2r   r   r  
rpartitionr   rw   rp   rv   r   rU   r  r  r   rW   rG   r   rp  r  r  r>  r  r   r3   r  state_function_docstringrq  r  SyntaxErrorparse_converterbodyreturnsr   rb  r   r  r  rq  r  rr  rZ  r  r<  r%  r  rl  r  r  r  r  state_parameters_start)r$   r   r  r<  r  r~  r*  r  r-  r   function_namer  r  existing_functionr  rn  	ast_inputr   legacyr   ro  scp_selfs                          r%   r  zDSLParser.state_modulename_name  s   " zz|$ $(??3#7 '-'7'7'?$Iq*!)I#))+J~~'H&y1#8#D&x0-5^^C-@A!'')AA &

"kk;;FC*--)B)B -%(-->- )-%('3&*hO*CMM:;d8nLsRS-6__S-AB!'')BB &

"kk;;FC)..$));@Q@Y@Y]a]i]i@iuv 1 6 6MU^gmsv  DN  Z\ 6  !]

%%,,T]];))00?		$778>>$/a#'>>&#9 	1jOO%	%%'/4
%i0)953J?&
3%gYf5IF9- 3i?$FPQ	R'+';';FKKN<R<R'S$ffR &,(00@4:MN#4T#:#DV#D  &/__S%9:!'')::

kk33F;%":44F2J<ghi":"		\)367"DIBZ:%		X%sVW#DI##8#: /1;d9??CT>UUX[[\ myQW]`mw2B\`\h\hj

$$T]]3 +4==9
d4<' [[F6N,:4t}},_X^,__T]])277G$5$5$E$EPTP]P]ikl,2  )	!!((7		$--.C B C<    R3i?$FPQR ;s7   YY&Y A5Y( Z	Y%$Y%(Z	Z	   c                     | j                  |      ry | j                  j                  |      s| j                  | j                  |      S d| _        | j                  | j                  |      S r;   )r  r   r  r  r  r  state_parameterr   s     r%   r  z DSLParser.state_parameters_startq  s]    D! {{  &99T::DAA&(#yy--t44r'   c                     | j                   | j                  k7  rM| j                  | _         | j                  j                  j	                         D ]  }|j
                   |_         yy)z?
        Transition to the "required" parameter state.
        N)r  ps_requiredr>  r  r  r   )r$   r   s     r%   to_requiredzDSLParser.to_required}  sZ     4#3#33#'#3#3D ]]--446 #77(# 4r'   c                    | j                   r'| j                   dz   |j                         z   }d| _         | j                  |      ry | j                  j                  dk(  sJ | j                  j                  |      }|dk(  r| j                  | j                  |      S |dk(  r| j                  | j                  |      S |j                         }|j                  d      r|d d | _         y |j                         }|dv r| j                  |       y | j                  | j                  | j                  fv r| j                          n| j                  | j                   k(  r| j"                  | _        n| j                  | j"                  k(  r| j$                  st| j                          nc| j                  | j&                  | j(                  fv rn>t+        d| j,                  j.                  z   d	z   t1        | j                        z   d
z          d }|j3                  d      \  }}}|rv|j5                         }d|vrb|j5                         j7                  d      }|st+        d       |d   }|j                  d      r
|dz  }|d d }||d<   dj9                  |      }|j;                  d      \  }}	}
|	s|
}d }
d }	 d| d}t=        j>                  |      }|s(t+        d| j,                  j.                  z   dz   |z          |jB                  d   jD                  }tG        |jD                        dkD  r(t+        d| j,                  j.                  z   dz   |z          |jH                  s|jJ                  r(t+        d| j,                  j.                  z   dz   |z          |jL                  r(t+        d| j,                  j.                  z   dz   |z          |jN                  rd}|jN                  }nd}|jD                  d   }|jP                  }| jS                  |jT                        \  }}}|
sf| j                  | j(                  k(  rt+        dtW        |      z   dz          |rtX        }|j[                  dd       nt\        }d|v rt+        d       n|rt+        d       | j                  | j                  k(  r| j(                  | _        |
j5                         }
d}d|
 }	 t=        j>                  |      }d|vr> G d  d!t<        j^                        } |       }|ja                  |       |jb                  }n	 te        |
      }|t\        u rt+        d"       |rt+        d$tW        |
      z          |jB                  d   jl                  }to        |t<        jp                        r|jr                  dk(  rtX        }d%}d}nsto        |t<        jt                        snto        |t<        jv                        rto        |jx                  t<        jz                        r0t}        |jx                  jl                        t~        t        t        hv s]|j                  d      }to        |t0              r|s0t+        d&tW        |
      z   d'z   t=        j                  |      z          |
}t        }nto        |t<        j                        rg }|}to        |t<        j                        rB|j                  |j                         |jl                  }to        |t<        j                        rBto        |t<        jp                        st+        d(tW        |
      z   d)z          |j                  |jr                         d*j9                  t        |            }|j                  d      }to        |t0              r|st+        d+tW        |      z   d'z          	 te        |      }n`t=        j                  |      }tW        |      }to        |t        d j                  f      rd,|z   }nto        |t0              rt        |      }n|}|j[                  d       |j[                  d       |rt        nt        }|rd.nd}||vrt+        | d/| d0        ||   |xs ||| j,                  fi |}|rt        j                  j                  } nA| j                  rt        j                  j                  } nt        j                  j                  } to        |t              rtG        | j,                  j                        dk(  r| j                  | j                  k7  rt+        d1       |t\        urt+        d2       | j$                  rt+        d3       t        j                  j                  } | j                  | _        | j,                  j                  j                          nt+        d4       to        |t              rtG        | j,                  j                        }!|!dk(  r| j                  | j                  k7  rt+        d5       |t\        urt+        d6       | j$                  rt+        d7       | j,                  j                  t+        d8       t        j                  j                  } nt+        d9       t        || | j,                  ||| j$                  :      }"| j,                  j                  j                         D #cg c]  }#|#j.                   }$}#||$dd  v rt+        d;tW        |      z   d<z          n|$r||$d   k(  r|t+        d=| d>       |r| d?| n|}%|"| j,                  j                  |%<   y # t@        $ r2 	 d }
d| d}t=        j>                  |      }n# t@        $ r Y nw xY wY w xY w# tf        $ r Y Rth        $ r&}t+        d#jk                  |
|             Y d }~{d }~ww xY w# tf        $ r
 t        }Y w xY w# t@        $ r,}t+        d-tW        |j                        z          Y d }~d }~wt        t        f$ rI t        }|j                  d      }|
}to        |t0              r|st+        d+tW        |      z   d'z          Y Iw xY wc c}#w )@NrN   r<      rT   r   rd   )r=  /[]	Function ; has an unsupported group configuration. (Unexpected state z.a)r  zInvalid 'as' clause!r   :r4  zdef x(z): passz( has an invalid parameter declaration:
	z1 has an invalid parameter declaration (comma?):
	z9 has an invalid parameter declaration (default value?):
	z4 has an invalid parameter declaration (**kwargs?):
	TFz*Can't have a parameter without a default (z#)
after a parameter with a default!r  r  r  z@You can't specify py_default without specifying a default value!z"Vararg can't take a default value!zx = c                   B    e Zd ZdZd ZeZeZexZZexZ	Z
exZZexZZeZy)1DSLParser.state_parameter.<locals>.DetectBadNodesFc                     d| _         y )NT)bad)r$   rt  s     r%   bad_nodez:DSLParser.state_parameter.<locals>.DetectBadNodes.bad_node  s	    '+DHr'   N)r(   r)   r*   r  r  
visit_Callvisit_IfExpvisit_ListCompvisit_SetCompvisit_DictCompvisit_GeneratorExp
visit_Dict	visit_Set
visit_Listvisit_Tuplevisit_Starredr,   r'   r%   DetectBadNodesr    sM    #, &.
&. :BA>FF); 2:9
Y3;;
[ )1r'   r  z+'unspecified' is not a legal default value!z<Malformed expression given as default value
{!r} caused {!r}z)Unsupported expression as default value: z<unrepresentable>z When you specify an expression (z<) as your default value,
you MUST specify a valid c_default.zUnsupported default value z  (looked like a Python constant)rt   z#When you specify a named constant (Py_zSyntax error: zlegacy z is not a valid rk  z-A 'self' parameter cannot be marked optional.z/A 'self' parameter cannot have a default value.z2A 'self' parameter cannot be in an optional group.zVA 'self' parameter, if specified, must be the very first thing in the parameter block.z7A 'defining_class' parameter cannot be marked optional.z9A 'defining_class' parameter cannot have a default value.z<A 'defining_class' parameter cannot be in an optional group.z?A 'defining_class' parameter cannot be defined at module level.z}A 'defining_class' parameter, if specified, must either be the first thing in the parameter block, or come just after 'self'.)r>  rk  r  r   z$You can't have two parameters named r  zParameter 'z' requires a custom C name_as_)_r  r%  r  r   r  r  r  r  state_parameter_docstring_startr~   r  parse_special_symbolr  r  r  r  ps_left_square_beforeps_group_beforer   ps_group_afterps_optionalrG   r>  r   r+   r   r   rv   r=   r  rq  r  r  r  r   r  defaultskw_defaultskwargr  rT  r  r  r   r  
setdefaultr   NodeVisitorvisitr  rp  	NameErrorr  r   r!   r;  Namer  BinOpUnaryOpoperandConstantro  r   r  r  r   r  r   	Attributer3   r   r   literal_evalr  r   rm   r2   r   AttributeErrorr  r  r  r  r  r  r  POSITIONAL_OR_KEYWORDrl  r  r  r>   rm  r  r  )&r$   r   r   c_namer   have_as_tokenr   r   baser<  r  r  r  function_argsr  r%  parameter_namer  r   r!   r  r  denylistr>  rB  r  r  rZ   r  r  
legacy_strrk  rp  _lpr   r  r"  r   s&                                         r%   r  zDSLParser.state_parameter  s   &&..4t{{}DD*,D'D!{{  A%%%""4(R<99T::DAAQ;99TAA4HH{{}==*.s)D'{{}''%%d+DMM43C3C#DD!!T%?%??#'#7#7D !!T%9%99::  "!!d&9&94;K;K%LLt}}1114qqtwx|  yM  yM  uN  N  QV  V  W (,v(>%mX::<D$!)//4/0??3'CKD#CR[F q	xx' $ 4fgDG	 g.IYYy)F t}}1114``cgghA++}!!"Q&t}}1114iilppq!!]%>%>t}}1114qqtxxyt}}1114llosstI%,,II%**1-I"#33I4H4HIff##t'7'77ADDXX  \B  B  C!!+v6#v%WX9:##t'7'77'+'7'7$mmoGCwi(IbU9-f,1 1*  ./HNN6*",,CD $W K/ !NO DtG}TU{{1~++dCHH-$''V2C E!4J &I syy1ckk2$T\\3<<@t||112sE76KK &

; 7I&y#69?$w-O  SR  R  UX  U]  U]  ^b  Uc  c  d!(J#Ecmm4AA$Q6(GG %Q6 &a29DMILnnoHHQTTN!$(1+!6J &

; 7I&y#69BT*EUU  YX  X  Y( $Z 0  ,,T2E!%eJ!%$)?@$)J$6	#E3/$*5M	$.	 k95lJ7$* 
"(Yb
tD6)*Y?@ DJv7X]hagh	$$33D$$11D$$::Di04==++,1((D,<,<<HI+JK::MN((88'+}}$((..0mni!9:dmm../Cax((D,<,<<RS+TU::WX==$$,Z[((88  U  V ndT]]iafnrnxnxy!%!9!9!@!@!BCACCU12Y&7$~:NNQTTU~q1fn;~..HIJ17 VH-^()  %a  		 $TF'2	9- 		r % $ D 006w0BD DDN % ( '(  6%QVV455/ U"JJ{3	$
"9c2y>jAQQ  UT  T  UUr Ds   6m Ao% .n Go% B&o% :o A!o% q3	nm<;n<	nnnnn	oo% o&oo% oo% o"o% !o""o% %	q0.!pAq0/q0r  c                    | xt         j                  d x\  xt        d x	\   } |di fS   xt         j                  dx	\  } |di fS  t         j                  d x\  t         j                  dxm\  }t               }i }| j                  D ]J  }t        |j                  t              st        d       t        |j                  |      ||j                  <   L |d|fS  	 t        d       y )N)r!   r,   TF)funcz6Cannot use a kwarg splat in a function-call annotationz@Annotations must be either a name, a function call, or a string.)rq  r  r+   r  Callru  r   r;  rT  rG   rx  r!   )r  r!   r   symbolsr   rt  s         r%   r  zDSLParser.parse_converter  s     33NCE3dB& 4UB&  .sxx~.!)(*&// JD%dhh4UV'4TZZ'IF488$J UF** / Vr'   c                 l    |dk(  r9 j                   r%t        d j                  j                  z   dz          d _         y |dk(  rщ j                   j
                   j                  fv r j                   _        nt j                   j                   j                  fv r j                   _        n>t        d j                  j                  z   dz   t         j                        z   dz           xj                  dz  c_
        d j                  _        y |d	k(  rL j                  s%t        d j                  j                  z   d
z          t         fd j                  j                  j                         D              s%t        d j                  j                  z   dz           xj                  dz  c_
         j                   j                   j                  fv r j                   _        y  j                   j                   j                   fv r j                    _        y t        d j                  j                  z   dz   t         j                        z   dz          y |dk(  rǉ j"                  r%t        d j                  j                  z   dz          d _         j                   j                   j$                   j                    j                  fvs j                  r>t        d j                  j                  z   dz   t         j                        z   dz           j                   r%t        d j                  j                  z   dz           j                  j                  j                         D ]  }|j'                         r|j(                  t*        j,                  j.                  k7  rYt1        |j2                  t4              s?t1        |j2                  t6              s%t        d j                  j                  z   dz          t*        j,                  j8                  |_         y y )Nr=  r  z uses '*' more than once.Tr  r  z.b)r   r   has a ] without a matching [.c              3   P   K   | ]  }|j                   j                   k(    y wrI   )r   )rq   r   r$   s     r%   rs   z1DSLParser.parse_special_symbol.<locals>.<genexpr>  s     Xqww$**,Xs   #&zD has an empty group.
All groups must contain at least one parameter.z.c)r  z uses '/' more than once.z.d)zI mixes keyword-only and positional-only parameters, which is unsupported.)r  rG   r>  r   r  r  r  r  r	  r+   r   r  anyr  r  r  ps_right_square_afterr  r
  r  rp  r  r  r  r;  rk  rl  rm  r  )r$   symbolr   s   `  r%   r  zDSLParser.parse_special_symbol  s   S=  [4==#5#558SST $Ds]##t7Q7Q'RR'+'A'A$%%$*:*:D<O<O)PP'+':':$[4==#5#558uux{  }A  }Q  }Q  yR  R  UZ  Z  [JJ!OJ+/DMM(s]::[4==#5#558XXYXdmm6N6N6U6U6WXX[4==#5#558  AJJ!OJ##(B(BDDXDX'YY'+';';$%%$*=*=t?Y?Y)ZZ'+'A'A$[4==#5#558uux{  }A  }Q  }Q  yR  R  UZ  Z  [s]##[4==#5#558SST#'D  $$T-=-=t?O?OQUQkQkmq  nB  nB  -C  C  HL  HR  HR[4==#5#558uux{  }A  }Q  }Q  yR  R  UZ  Z  [  [4==#5#55  9D  D  E]]--446 ;;;=FFg//EEE"1;;?"1;;0HIt}}'9'99  =H  H  I **::; r'   c                     t        | j                  j                        | _        | j                  j                  dk(  sJ | j                  | j                  |      S )Nr   )r  r   r}  parameter_docstring_indentr  r  state_parameter_docstringr   s     r%   r  z)DSLParser.state_parameter_docstring_start  sH    *-dkk.@.@*A'{{  A%%%yy77>>r'   c                    |j                         }|j                  d      ry | j                  j                  |      }|| j                  k  r| j                  j                  |       | j                  j                  dk  sJ | j                  j                  dk(  r| j                  | j                  |      S | j                  j                  dk(  sJ | j                  | j                  |      S | j                  j                  sJ t        t        t        | j                  j                  j                                           }|j                  }|r|dz  }|r|| j                  j!                  |      z  }||_        y )Nr   r   r  r   r}   )r   r.  r   r  r.  r  r  r  r  r  r>  r  r   r5   r  rD  r  )r$   r   r  r   last_parameternew_docstrings         r%   r/  z#DSLParser.state_parameter_docstring  s8   ::<s#$$T*D333KKd#;;$$q((({{  A%yy!5!5t<<;;$$)))99T::DAA}}''''htDMM,D,D,K,K,M'NOP&00T!MT[[//55M#0 r'   c                 l   | j                   r%t        d| j                  j                  z   dz          |j	                         }|j                  d      ry | j                  j                  }|r|dz  }|r*| j                  j                  |      j                         }nd}||z  }|| j                  _        y )Nr  r(  r   r}   r<   )
r   rG   r>  r   r   r.  rD  r   r  r~   )r$   r   r  r2  s       r%   r  z"DSLParser.state_function_docstring  s    ::t}}1114TTU::<s#//T!M;;%%d+224DD"/r'   c           	         | j                   }|j                  t        t        fv }|r|j                  s|j                  S t               \  }}|j                  }|r+|j                  sJ  |j                  j                         n |j                         | j                  r | j                         n d       |sJ dt        |      z          t        |d   j                  t              sJ |d   j                         sJ d|d   _        d}|dd  D ]=  }|j                         sd}n|sJ |rt!        |j"                        |_        7d|_        ? dfd}d}	d}
d}|j$                  s:t'        |      D ],  }|j                  j(                  s|j                         rd} n d}d|d   }t+        d	j-                  |            d
z  fd}|D ]  }|j                  j(                  s|j                  sJ t        |j                  t              }|r|j$                  rR|j                         r|j$                   }	n|	r|
s|j                         s
d}
 |d       |j/                         r|s
d} |d       t1               \  }} | ||j                               t        |j                  t              r |d       |j3                         r |d       |j                  j4                  xs |j                  } ||       |j3                         sa|j                  j7                         rG |d       |j                  j8                  }|st        |j                  j:                        } ||       ||k7  s|r |d        | |                 |d             |r |d        d       |j$                  s dt<        z   dz           |       }|j?                  dd      }d}|D ]  }|j                  jA                         s|r	 d       nd} d        |j                          d        tC        jD                  tG        |j                  jI                               d               |       }|r|dz  }|j                  jI                         }|jK                  d      D cg c]  }|jI                          }}t+        |      dk\  r'|d   rAtM        d|jN                  z   dz   dz   dz          nt+        |      dk(  r|jQ                  d	       t+        |jK                  d            dz
  }|dkD  rtM        d       |s|jS                  dd       |jS                  d|       dj-                  |      } |        |       }tU        ||       }|jI                         }|S c c}w )!Nr$  z(We should always have a self parameter. r   Tr   Fc                 `    d}| k  r|dz  }dz  | k  r| kD  r|dz  }dz  | kD  r|S )Nr<   r  r   r  r,   )desiredr?   right_bracket_counts     r%   fix_right_bracket_countz;DSLParser.format_docstring.<locals>.fix_right_bracket_countD  s]    )G3HA'1,' *G3 *G3HA'1,' *G3 r'   rT   r<   rN   c                     r| }dn3d| z   }t        |      z   dk\  r d               t              | }t        |      z   |       y )NFrN   H   r}   )r  )r2   r?   r\   first_parameterr   line_lengths     r%   add_parameterz1DSLParser.format_docstring.<locals>.add_parameterf  s]     #A&+Od
A"SV+r1D	F&)&k s1v%Ar'   z/,z*,r  r=  r4  r&  r  r%  r}   z, ]z,] z  r(  r  zDocstring for z does not have a summary line!
z3Every non-blank function docstring must start with
z0a single line summary followed by an empty line.z{parameters}z?You may not specify {parameters} more than once in a docstring!)r  )+r>  rp  rq  rr  rD  r@   r  r  r   r  r   r;  rk  rl  r  r7  r  r   r  r   rS  r  r=   rt  rD   r  rT  ru  r  r  rE  rg   r   r   r   r   r~   rv   rG   r~  r3   rK  r   )r$   r  r  r2   r4   r  r  r   r8  
need_slashadded_slashneed_a_trailing_slash
added_starlast_pr=  is_selfp_addp_outputr   r!   docstring_first_linespacer_linerD  r   r  parameters_marker_countr\   r;  r   r<  r7  s                             @@@@@r%   format_docstringzDSLParser.format_docstring  sM   MMff[ 99q{{;;-/c6((
  55L5

OK%%**+H SIDQRGSS:jm55~FFFa=3355501JqM-"O^ 	.++-&+O**?",/LA) -.A)	. #$	 JK$)! ##!*- A;;88 ++-04- J"O^Fbggdm,K;&F    :*{{44vvv$Q[[.Aq// '')%&%5%5!5J8L8L8N"&K!$'$$&z!%J!$'"2"4x-a.C.CDEakk>:  #J;;=#J{{11;QVVd{{})@)@)B#JKK22E  $Q[[%8%8 9%LK$9#Jhj)u:*x '*+$c"H ~%,-%x  4;;E5I  
	MA;;$$&D	"IKIQ[[-?-?-A BFKL
	M X
$J KK&&(	+4??4+@A4AA u:?Qx%36XXJKFG H Z1_ LL"%ioon&E"F"J"Q&RS&LLN+ 	Q,-IIe$	IH	!)
C	$$&	Y Bs   W
c                 @   |rJ | j                   sy| j                  r| j                   j                  j                         }|sd}nDt	        t        t        |                  }|j                  t        j                  j                  k7  }|r%t        d| j                   j                  z   dz          | j                   j                  j                         D ]'  \  }}|s	|j                  j                         |_        ) | j!                         | j                   _        y)z;
        Called when processing the block is done.
        NTr  z1 specifies '*' without any parameters afterwards.)r>  r  r  r  r  r   r5   rp  r  r  r  rG   r   r   rD  r~   rI  )r$   r   r  no_parameter_after_starr1  r   r!   s          r%   r  zDSLParser.state_terminal  s     x}}]]--446F*.'!%htF|&<!=*8*=*=ARARA_A_*_'&[4==#5#558kkl  ==3399; 	7KD%#oo446EO	7
 #'"7"7"9r'   r   )r<   rI   )5r(   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  StateKeeperr  r  r  rT  r  r  r  r  r
  r	  r+  r  r  r  rq  rB  r   r  ConverterArgsr  r  r  r/  r  rI  r  r,   r'   r%   r  r    s,   v $ "% f# f$ f
(S (T ((( ( 	(
 
($	+# 	+c 	+d 	+CC C
 
C$  "(  (  (  
	( TK3 K4 K' ' '$
!
"

4 4 4
-5 -T -, 
 
 -s -s - -  $ * 
	4$B/N :?q7H#_k!6	5#R*h 4	sD-'	( *-;^?180$zx:r'   )rU   pythonc           
         dd l }dd l}|j                  d      }|j                  dddd       |j                  d	d
t        d       |j                  dddd       |j                  ddd       |j                  ddd       |j                  dt        t
        j                  d       |j                  ddt        dd       |j                  |       }|j                  r|j                  r7t        d       t                |j                           |j                  d       g }g }t        dj                         j                               }t!               }|D ]L  }	d|fd |ffD ]?  \  }
}|	|v r|	j#                  |
      s|j%                  |	|	j'                  |
      f        L N t                t        d!       t)        t*              }t        d"d#j-                  d$ |D              z          t        d"d#j-                  d% |D              z          t                d&d'|fd(d)|ffD ]B  \  }}}t        |d*z          d}|D ]  \  }	}t/        |t1        |            } t)        |d+ ,      D ]  \  }	}||	   }t3        ||d       }|st5        j6                  |      }g }|j8                  j;                         D ]y  \  }}|j<                  t4        j>                  j@                  k(  s.|jB                  t4        j>                  jD                  k7  r| d-|jB                  }n|}|j%                  |       { t        d.jG                  |d/j-                  |                    t                E t        d0       t        d1        |j                  d       |jH                  rQ|jJ                  s|j                  r7t        d2       t                |j                           |j                  d       |jL                  s7t        d3       t                |j                           |j                  d       t        jN                  |jL                        D ]  \  }}}d4D ]  }||v s|jQ                  |        |D ]t  }|j#                  d5      s|j#                  d6      s&t
        jR                  j-                  ||      }|jT                  rt        |       tW        ||jX                   7       v  y |j                  s"|j                           |j                  d       |jJ                  rOt1        |j                        d8kD  r7t        d9       t                |j                           |j                  d       |j                  D ]<  }|jT                  rt        |       tW        ||jJ                  |jX                   :       > y );Nr   a2  Preprocessor for CPython C files.

The purpose of the Argument Clinic is automating all the boilerplate involved
with writing argument parsing code for builtins and providing introspection
signatures ("docstrings") for CPython builtins.

For more information see https://docs.python.org/3/howto/clinic.html)descriptionz-fz--force
store_truezforce output regeneration)actionhelpz-oz--outputzredirect file output to OUTPUT)ro  rS  z-vz	--verbosezenable verbose modez--convertersz>print a list of all supported converters and return convertersz--makez,walk --srcdir to run over all relevant filesz--srcdirz)the directory tree to walk in --make mode)ro  r  rS  rE   FILEr=  zthe list of files to process)metavarro  r   rS  zHUsage error: can't specify --converters and a filename at the same time.rT   z
            add_c_converter
            add_c_return_converter
            add_default_legacy_c_converter
            add_legacy_c_converter
            r4  r  zLegacy converters:r(  rN   c              3   H   K   | ]  }|d    j                         s|  ywr   N)isupperrq   r   s     r%   rs   zmain.<locals>.<genexpr>w       DaQqT\\^D   ""c              3   H   K   | ]  }|d    j                         s|  ywrW  )islowerrY  s     r%   rs   zmain.<locals>.<genexpr>x  rZ  r[  
Convertersr   zReturn convertersr<  r  c                 (    | d   j                         S r#  )lower)r-  s    r%   <lambda>zmain.<locals>.<lambda>  s    adjjl r'   r  r4  z
    {}({})r'  zNAll converters also accept (c_default=None, py_default=None, annotation=None).z4All return converters also accept (py_default=None).z3Usage error: can't use -o or filenames with --make.z4Usage error: --srcdir must not be empty with --make.)z.svnz.gitz.hgbuild	externalsz.cz.hr  r   z2Usage error: can't use -o with multiple filenames.)r4   r  )-rX   argparseArgumentParseradd_argumentr+   re  curdir
parse_argsr  rE   rW   print_usagerY   r  r   rv   ru  r  r3   r  sortedr  r=   r{  r  rV   r  	signaturer  r   rp  r  r  r  r  r   maker4   srcdirwalkremover`  verboser  force)argvrX   rd  cmdlinensr  rb  ignoredr  r   r   idsr  title	attributelongest
short_namer  callablerk  r  r  r%  r?   rootdirsfilesrcs_dirrE   r`  s                                 r%   mainr  >  sY   %%H & IG y9  ;z>  @{<3  5 7  9 ,L  N#ryyI  KV#S<  >			D	!B	}};;\]G!CHHRL
 
 !  		D$&78z*   7?==(JJd&7&7&?@A		 	"#)*fsxxD6DDDEfsxxD6DDDE +Z8 "9;LM&
 	!E9c %#+G$' 8 jgs:78$*34J$K N jTl"3	48#--h7	
1:1E1E1K1K1M --NI ~~):):)G)GG$,,0A0A0G0GG#1"2!I4E4E3H IA .A"))!,- l))*dii
6KLMN G/	0 	^_DE	ww99GHG!CHHRLyyHIG!CHHRL!#!3 
	6D$H )d?KK() " 6 ))$/83D3DT3Jww||D(3::$K4BHH56	
	6 	;;	yyS%)BCKK D::(O8BII"((lCDr'   __main__r   )N   )TTrI   )r   rq  builtinsrR  r   
contextlibr  r6  enumr  r  r  rC  r   re  r  rB  r5  stringrX   r   r  collections.abcr   r  r   r   typingr   r   r   r	   r
   r   r   rs  rP  rO  Enumr   r   r6   r   r.   r  rE  r+   r7   r8   r  rU  r1   r@   rB   rD   rQ  r   rK   r  ra   rG   rj   rm   r  r$  rp   rw   r  r   rv   rz   r{   r   r   r   r   r   r   r   r   r   	Formatterr   ABCMetar   r   r  r  r  r  	lru_cacher  r"  r0  r2  contextmanagerr  r   r  r  rA  rM  r[  LangDict	languagesrn  r}  	ClassDictDestinationDict
ModuleDict
ParserDictrU   r  r  r6  r  r  r~  r  rg   INVALIDr  r  r  rr  rq  r  r  r<  r  r  r  r	  r  ro  r  r  rK  ConverterTypeConverterDictr  r  ReturnConverterDictrb  rn  rd  rm  r{  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rv  r]  r  r  r  r  r  ConverterKeywordDictr  r_  ra  r  r  r	  r  r  r%  r'  rl  r5  r7  r  rM  rP  rV  rZ  r]  rb  rd  rg  rj  rm  rx  rz  rL  rM  r  r  r  r(   rY   rr  r  s   0r%   <module>r     s    
     
     	  	  	   
   $ ( F F 	 .		 . **U *"" " 
 vSE4K RW	CH~z 
7+ 7j +/ + 
  "	
$- Dj t	
  
 
 !"	
%. Dj t	
 
 
 "	
 Dj t	
 
<  "WWDjW tW 
	W  "OODjO tO 	O3 3 c c  #

#=>DD Gc Gd G  
 
EGEEG
  C C S S *S *C *C *X S S * S S ( c3h >  8I 2 2jV--  F0 F0THX H!!: #$   $) 8+v1h_6 _6H " "?m ?mD]> ]>@: :z! !H(# (#\ XseXo../8	5P5V5V5XZTyZ
H Z!
4  C D * g	sK'(#x- 
#{"#
	l ld !	  d
	
 
F "Tzd
 	$ $R R"Q Q. ), E-J 
EGEEGKE) SX EPKGCUUWUUW H=,Z k!"	67 ] ]@<% <%~l l,T ,
z1 zz ,/,);,1/;
 j)S-'( 
M 
 $& = % 3 334 )+ & +
ejjo
7Z 7@9z 9&7Z 7B T*-7j -7 +-7^ 4, 37j 7>7z 7* SE*&7J &7 +&7P7Z 7*7Z 7 7j 7.7* 7 7: 7.7: 7@	UJ 	U7z 7 
=z 
=7j 7,7z 7.7: 7"z >      < .0 DcN /L7J L7r C4/0 
 	3   	
 
: $$SE 2 %$tSE 2 $$UIs,C D %$tUIs,C D #SE 2 $tXsO < #XJ 7 $tXJ 7 #S(O < $tXsH,E F7j 7"7* 7"7
 7( T*S(O4c8_TB;2: ;2 C 5 + ;2z c6]3c68%<=hZ0K7* K7 1 > 4K7\	Hc3h 	Hh6Z h6Z  

Dj
 
$4 $8!= 8v ' 2
, 

, 
$0 
1 &%: &%$B %)"7 )
3 
. 
 4 
 .1 $M M` d
|T)*S#Xo: o:z#  <
8 
~DB zCHHT#((12,  ep [s   
`<