
    i6                       S SK r \ R                  " S0 S\_S\_S\_S\_S\_S\_S\_S	\_S
\_S\_S\_S\_S\_S\_S\_S\_S\_S\_S\_S\_6  S SKrS SKrS SKrS SKrS SKrS SKrS SK	J
r
  S SKJr  S SKJrJr  S SKJrJr  S SKJr  SSKJr  SSKJr  SSKJr  SSKJr  S S!KJr  SS"KJr  S S#KJr  S S$KJr    S S$K!Jr"  \" \"S%S&9r" S S'K$Jr%J&r'J(r)  \" \%\'RT                  \)RV                  \'RX                  \'RX                  R[                  5       S   0S(9r%C'C)SS)\" \ S%S*94S S+\"4S,S-\%4/r.S.S.S/S0S1.r/S2S2S3S4S5.r0S6S70r1S8r2\3" / S9Q5      r4/ S:Qr5\ R                  " \3\3" S;5      5      r6S<S=0Rn                  r8\ R                  " \SS S S>.Rn                  5      r9 " S? S@5      r:SA r;Sr< SB r=\=r< " SC SD5      r> " SE SF\>5      r?\
 " SG SH5      5       r@ " SI SJ\?5      rASSKS/SL.SM jrB\B" SNSOSP9SQ 5       rC\B" 5       SR\A4SS j5       rD\B" STSUSVSW9SX 5       rE\B" SYSZSUS[SW9S\ 5       rF\B" S]S^SP9S_ 5       rG\B" S`SKSaSW9Sb 5       rH\B" 5       Sc 5       rISS0 4Sd jrJ " Se Sf\A5      rK " Sg Sh\?5      rL " Si Sj5      rM " Sk Sl5      rN " Sm Sn5      rO\ R                  " \\\\So9  \R                  " Sp\R                  5      R                  rS\R                  " Sq5      R                  rT\R                  " Sr5      R                  rV\R                  " Ss5      R                  rX " St Su5      rY " Sv Sw5      rZ " Sx Sy5      r[Sz r\ " S{ S|5      r] " S} S~5      r^ " S S5      r_ " S S5      r`\ R                  \ R                  S\cS\ R                  S\c4S j5       5       re\ R                  " S5      \ R                  S\cS\ R                  4S j5       5       rh " S S5      rig! \# a    Sr" GNf = f! \# a    Sr% GNf = f)    NosreoperatortextwrapTemplateNamingOptionsStringEncodingUtilsSourceDescriptorStringIOTree
DebugFlagsdefaultdictclosingpartialwrapszlib_compressbz2_compresslzma_compresszstd_compress)	dataclassr   )r   r   )r   contextmanager)r      )r   )r	   )r   )r
      )r   )r   )r   )compress	   )compresslevel)r   CompressionParameterStrategy)optionszliblevelbz2   zstdstrrangeinput)unicode
basestringxrange	raw_inputz&PyLong_Typez&PyFloat_Typez&PyWrapperDescr_Type)py_intpy_longpy_floatwrapper_descriptorPyTypeObjectPyHeapTypeObject)r&      r   betar   )ArithmeticErrorAssertionErrorAttributeErrorBaseExceptionBaseExceptionGroupBlockingIOErrorBrokenPipeErrorBufferErrorBytesWarningChildProcessErrorConnectionAbortedErrorConnectionErrorConnectionRefusedErrorConnectionResetErrorDeprecationWarningEOFErrorEllipsisEncodingWarningEnvironmentError	ExceptionExceptionGroupFalseFileExistsErrorFileNotFoundErrorFloatingPointErrorFutureWarningGeneratorExitIOErrorImportErrorImportWarningIndentationError
IndexErrorInterruptedErrorIsADirectoryErrorKeyErrorKeyboardInterruptLookupErrorMemoryErrorModuleNotFoundError	NameErrorNoneNotADirectoryErrorNotImplementedNotImplementedErrorOSErrorOverflowErrorPendingDeprecationWarningPermissionErrorProcessLookupErrorPythonFinalizationErrorRecursionErrorReferenceErrorResourceWarningRuntimeErrorRuntimeWarningStopAsyncIterationStopIterationSyntaxErrorSyntaxWarningSystemError
SystemExitTabErrorTimeoutErrorTrue	TypeErrorUnboundLocalErrorUnicodeDecodeErrorUnicodeEncodeErrorUnicodeErrorUnicodeTranslateErrorUnicodeWarningUserWarning
ValueErrorWarningWindowsErrorZeroDivisionError_IncompleteInputError__build_class__	__debug__
__import__absaiterallanextanyasciibinbool
breakpoint	bytearraybytescallablechrclassmethodcompilecomplex	copyrightcreditsdelattrdictdirdivmod	enumerateevalexecexitfilterfloatformat	frozensetgetattrglobalshasattrhashhelphexidr*   int
isinstance
issubclassiterlenlicenselistlocalsmapmax
memoryviewminnextobjectoctopenordpowprintpropertyquitr)   reprreversedroundsetsetattrslicesortedstaticmethodr(   sumsupertupletypevarszip)
r   rh   r;   rK   r   r   rH   r   r   _)		__cinit____dealloc____richcmp____next__	__await__	__aiter__	__anext____getbuffer____releasebuffer__inlineCYTHON_INLINE)ustringr   r   c                   J    \ rS rSrSrSrSrSrSrSS jr	S r
S	 rS
 rS rSrg)IncludeCodei'  zQ
An include file and/or verbatim C code to be included in the
generated sources.
r   r   r   Nc                    U R                   U l        [        U 5      =R                   S-  sl         0 U l        U(       aQ  US   S:X  a*  US   S:X  a!  SR	                  U5      U R                  S'   SnOSR	                  U5      U R                  S'   U(       a  X R                  U R                  '   U(       a  U R
                  U l        g U(       a  U R                  U l        g U R                  U l        g )	Nr   r   <>z#include {}Fz#include "{}")	counterorderr   piecesr   INITIALlocationLATEEARLY)selfincludeverbatimlateinitials        T/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/Cython/Compiler/Code.py__init__IncludeCode.__init__A  s    \\
T
aqzS WR[C%7!.!5!5g!>A!0!7!7!@A&.KK

# LLDM IIDM JJDM    c                     X!;   aO  X   n[        U R                  UR                  5      Ul        UR                  R                  U R                  5        gXU'   g)z
Insert `self` in dict `d` with key `key`. If that key already
exists, update the attributes of the existing value with `self`.
N)r   r   r   update)r   dkeyothers       r   dict_updateIncludeCode.dict_updateW  sC    
 8FE ?ENLL,cFr   c                     U R                   $ N)r   r   s    r   sortkeyIncludeCode.sortkeyc  s    zzr   c                 8    U R                   R                  S5      $ )zp
Return the main piece of C code, corresponding to the include
file. If there was no include file, return None.
r   )r   getr   s    r   	mainpieceIncludeCode.mainpiecef  s    
 {{q!!r   c                 x    [        U R                  5       H!  nUR                  U R                  U   5        M#     g r   )r   r   putln)r   codeks      r   writeIncludeCode.writem  s)    $AJJt{{1~& %r   )r   r   r   )NNTF)__name__
__module____qualname____firstlineno____doc__r   r   r   r   r   r   r   r   r  __static_attributes__ r   r   r   r   '  s6    & GEDG',
"'r   r   c                      [         R                  R                  [         R                  R                  [         R                  R                  [        5      5      5      n [         R                  R                  U S5      $ )NUtility)r   pathdirnameabspath__file__join)
Cython_dirs    r   get_utility_dirr  s  sE     1J!KLJ77<<
I..r   c                     [         R                  R                  [        5       U 5      n[	        [
        R                  " USS95       nUR                  5       sSSS5        $ ! , (       d  f       g= f)z\
Read all lines of the file at the provided path from a path relative
to get_utility_dir().
UTF-8)encodingN)r   r  r  r  r   r   open_source_file	readlines)r  filenamefs      r   read_utilities_from_utility_dirr    sH    
 ww||O-t4H	''7C	D{{} 
E	D	Ds   A!!
A/c                   2    \ rS rSrSrSSS jjrS rS rSrg)	AbstractUtilityCodei  Nc                     g r   r  )r   globalstateused_bys      r   put_codeAbstractUtilityCode.put_code  s    r   c                     g r   r  r   kwargss     r   get_treeAbstractUtilityCode.get_tree      r   c                     g r   r  r(  s     r   get_shared_library_scope,AbstractUtilityCode.get_shared_library_scope  r,  r   r  r   r#  GlobalStatereturnN)	r  r	  r
  r  requiresr%  r*  r.  r  r  r   r   r!  r!    s    Hr   r!  c                   "   \ rS rSrSrSr0 r\R                  " S5      R                  r
\S 5       r\SS j5       r\S 5       r\S	 5       r\0 4S
 j5       r\SS j5       r\R                  " S5      R&                  4S jrS rS rS rSS jrSrg)UtilityCodeBasei  a  
Support for loading utility code from a file.

Code sections in the file can be specified as follows:

    ##### MyUtility.proto #####

    [proto declarations]

    ##### MyUtility.init #####

    [code run at module initialization]

    ##### MyUtility #####
    #@requires: MyOtherUtility
    #@substitute: naming

    [definitions]

    ##### MyUtility #####
    #@substitute: tempita

    [requires tempita substitution
     - context can't be specified here though so only
       tempita utility that requires no external context
       will benefit from this tag
     - only necessary when @required from non-tempita code]

for prototypes and implementation respectively.  For non-python or
-cython files backslashes should be used instead.  5 to 30 comment
characters may be used on either side.

If the @cname decorator is not used and this is a CythonUtilityCode,
one should pass in the 'name' keyword argument to be used for name
mangling of such entries.
Fzo(.+)[.](proto(?:[.]\S+)?|impl|init|cleanup|module_state_decls|module_state_traverse|module_state_clear|export)$c                     [         R                  " SS[         R                  " U 5      0-  [         R                  5      R                  $ )NzS^%(C)s{5,30}  \s*  (?P<name> (?:\w|\.)+ )  \s*  %(C)s{5,30} |^%(C)s+  @(?P<tag> .+)C)r   r   escapeVERBOSEmatch)line_comment_chars    r   get_special_comment_matcher+UtilityCodeBase.get_special_comment_matcher  sC    zz& "))-./0
 24=
 >CU	Cr   Nc                 0   Uc  g SR                  U5      nU(       aT  SU;   aN  SUS   ;   aE   [        U5      R                  [        [        5      5      nX:X  a  [        S	U SU S
US S35      eUnSU-  U-   nUS:X  a  XqS'   OUS:X  a  XqS'   O	US   n
XzU'   U(       aH  US   n
UR                  5        H.  u  pU
R                  U[        5       5      R                  U5        M0     g g ! [
        [        4 a  n	[        SU SU SUS SU	 35      eS n	A	ff = f)N

substitutenamingz&Error parsing templated utility code '.z
' at line r   z: zFFound useless 'substitute: naming' declaration without replacements. (:)protor   implr   r   )r  r   r@  r   r   rY   r   rl   items
setdefaultr   r   )clsutilitynamer   linesbegin_linenotagsr  new_codeeall_tagstag_name
tag_valuess                r   _add_utilityUtilityCodeBase._add_utility  sV   ?yyLD(Xl9K-Kk#D>44T&\B "\]a\bbcdhciijkwxyjzz{|~ ~D l"T)7?AJV^AJqzH!TNqzH(,

$##Hce4;;JG )5 ' j) k"<TF!D6T`abSccefgehik kks   'C( (D8DDc           	         U R                   R                  U5      nU(       a  U$ [        R                  R	                  U5      u  p4US;   a=  Sn[        [        R                  " S5      R                  S5      n[        R                  nOVSn[        [        R                  " S5      R                  S5      n[        [        R                  " S5      R                  S5      nU R                  U5      nU R                  n	[        U5      n
[        S	 5      n/ n[        [        5      nS =n=pS
n[!        U
5       GH  u  nnU" U5      nUc  UR#                  U" U" U5      5      5        M1  UR%                  S5      (       ai  U R'                  XXUU5        US-   nUS S 2	 UR)                  5         UR%                  S5      nU	" U5      nU(       a  UR+                  5       u  pOSnX.   nM  UR%                  S5      nSU;  a  [-        SU SU SU 35      eUR/                  S5      u  nnnUR                  5       nUR1                  5       nUS;  a  [-        SU SU SU 35      e[        R2                  " SU5      (       d  [-        SU SU SU 35      eUU   R5                  U5        UR#                  S5        GM     Uc  [7        S5      eU R'                  XXUU5        [9        U5      nX R                   U'   U$ )N)z.pyxz.pyz.pxdz.pxi#z^\s*#(?!\s*cython\s*:).* /z^\s*//.*|/\*[^*]*\*/z	\s+(\\?)$z\1c                      S S 0 /$ r   r  r  r   r   <lambda>:UtilityCodeBase.load_utilities_from_file.<locals>.<lambda>  s    tR(8r   r   rK  r   rF  tagrC  zFound invalid tag 'z' in utility section rB  )r3  r@  proto_blockzFound unknown tag name 'z\S+$zFound invalid tag value 'zEmpty utility code file)_utility_cacher   r   r  splitextr   r   r   subr(   rstripr<  match_section_titleread_utilities_hookr   r   r   appendgrouprT  cleargroupsrl   	partitionstripr:  addr   r   )rI  r  	utilitiesr   extcommentstrip_commentsrb  match_special
match_type	all_linesrL  rN  rJ  rK  r   rM  linenolinemmtype	tag_valuerR  s                          r   load_utilities_from_file(UtilityCodeBase.load_utilities_from_file  s   &&**40	!!$'11G$RZZ0K%L%P%PRTUNZZFG$RZZ0G%H%L%LbQNRZZ5995AF77@,,
'-	 89	3 $$$$%i0LFDd#AyVN4$89:  \4P%z!H

wwv"4(!&JD$!D#/GGEN	i'&)<YKG\]a\bbcdhci'jkk)2)<)<S)A&!Y#??,%OO-	#LL&)A(K`ae`ffghlgm'nooxx33&)B9+Mbcgbhhijnio'pqqX""9-R C 1F ?677 	\4HO	#,4 r   c           	      "   SU;   a  UR                  SS5      u  p!U(       d   eU R                  U5      nXA   u  pVnU(       Ga  SU;   a5  SUS   ;   a,  [        U [        5      (       d  [        R                  " X40 UD6$ UR                  5       nUR                  5        H  u  pX;   a  M  U	S:X  a_  U(       a-  [        U
5       Vs/ s H  nU R                  " X40 UD6PM     n
nOi[        U
5       Vs/ s H  nU R                  X5      PM     n
nO>U	S:X  a  U
SS1-
  n
U
(       d  M  O'U
(       d  Sn
O[        U
5      S:X  a  [        U
5      S   n
XU	'   M     Ub  XSS	'   Ub  XcS
'   SU;  a  XS'   SU;  a  U(       a  X#S'   U " S0 UD6$ s  snf s  snf )zl
Load utility code from a file specified by from_file (relative to
Cython/Utility) and name util_code_name.
z::r   r@  tempitar3  rA  Nr   rE  rF  rK  filer  )rsplitrx  r   TempitaUtilityCodeloadcopyrG  r   load_cachedr   r   )rI  util_code_name	from_filer)  rl  rE  rF  rN  orig_kwargsrK  valuesdeps               r   r  UtilityCodeBase.load>  s    >!(6(=(=dA(F%Iy00;	%5Tt#	T,5G(G!#'9::-22>WPVWW ++-K $

>:%"-3F^"=-;c #&((3"I["I-;  "=
 .4F^"=-;c #&//#"A-;  "=\) $x&;;F!  "!F[A%!&\!_F%t- !-0 #7O!6N+6NI&6N}V}9"="=s   F2Fc                 b    XU 4n X4   $ ! [          a     Of = fU R                  X5      =oSU'   U$ )zP
Calls .load(), but using a per-type cache based on utility name and file name.
)rY   r  )rI  utility_code_namer  _UtilityCodeBase__cacher   r  s         r   r  UtilityCodeBase.load_cachedt  sH    
 !S1	< 		!hh'8DDs|s   
 
c                   ^^^ U R                   " X40 UD6nU(       d6  UR                  UR                  5      UR                  UR                  5      4$ / / smmUUU4S jmT" U5        SR	                  T5      SR	                  T5      4$ )an  
Load a utility code as a string. Returns (proto, implementation).

If 'include_requires=True', concatenates all requirements before the actually
requested utility code, separately for proto and impl part.

In a lot of cases it may be better to use regular "load" and "CCodeWriter.put_code_here"
since that is able to apply the code transformations to the code too.
c                 L  > U R                   (       a  U R                    H  nT" U5        M     U R                  (       a*  TR                  U R                  U R                  5      5        U R                  (       a+  TR                  U R                  U R                  5      5        g g r   )r3  rE  re  format_coderF  )	util_coder  implsprependprotoss     r   r  /UtilityCodeBase.load_as_string.<locals>.prepend  sl    !!$--CCL .i33IOODE~~Y229>>BC r   rX  )r  r  rE  rF  r  )	rI  r  r  include_requiresr)  utilr  r  r  s	         @@@r   load_as_stringUtilityCodeBase.load_as_string  s     xx<V<$$TZZ0$$TYY/1 1 B	D 	wwv..r   z\n\n+c                 H    U(       a  U" SUR                  5       5      S-   nU$ )z#
Format a code section for output.
r?  z

)rj  )r   code_stringreplace_empty_liness      r   r  UtilityCodeBase.format_code  s'     -dK4E4E4GH6QKr   c                 R    S[        U 5      R                  < SU R                  < S3$ )Nr   (z)>)r   r  rK  r   s    r   __repr__UtilityCodeBase.__repr__  s    !$Z00$))<<r   c                     g r   r  r(  s     r   r*  UtilityCodeBase.get_tree  r,  r   c                     g r   r  r(  s     r   r.  (UtilityCodeBase.get_shared_library_scope  r,  r   c                     U $ r   r  )r   memodicts     r   __deepcopy__UtilityCodeBase.__deepcopy__  s    r   r  r   F)r  r	  r
  r  r  is_cython_utilityr_  r   r   r:  rc  r   r<  r   rT  rx  r  r  r  ra  r  r  r*  r.  r  r  r  r   r   r5  r5    s    #J N**ze  C C H H@ E EN 3 3j ?A 
 
 / /: <>::h;O;S;S =r   r5  c                   8    \ rS rSr% Sr\\S'   \\S'   \\S'   Srg)SharedFunctionDecli  z6Contains parsed declaration of shared utility functionrK  retparamsr  N)r  r	  r
  r  r  r(   __annotations__r  r  r   r   r  r    s    @
I	HKr   r  c                       \ rS rSrSr/ SQr    SS jrS\S\4S jr	S	 r
S
 rS rSS jrS r\R                   SSSSSS\4S jj5       rS rSS jrSSS jjrSrg)UtilityCodei  a  
Stores utility code to add during code generation.

See GlobalState.put_utility_code.

hashes/equals by instance

proto           C prototypes
export          C prototypes exported from the shared utility code module
impl            implementation code
init            code to call on module initialization
requires        utility code dependencies
proto_block     the place in the resulting file where the prototype should
                end up
name            name of the utility code (or None)
file            filename of the utility code file this utility was loaded
                from (or None)
shared_utility_functions        List of parsed declaration line of the shared utility function
)rE  exportrF  initcleanupmodule_state_declsmodule_state_traversemodule_state_clearNc                 ~  ^  UT l         UT l        UT l        UT l        UT l        UT l        UT l        UT l        0 T l        / T l	        U	T l
        U
T l        UT l        UT l        U(       a  T R                  U5      O/ T l        U(       a  T R!                  5         [#        U 4S jT R$                   5       5      T l        g )Nc              3   >   >#    U  H  n[        TUS 5      v   M     g 7fr   r   ).0partr   s     r   	<genexpr>'UtilityCode.__init__.<locals>.<genexpr>  s     !X'$d";";s   )rE  rF  r  r  r  r  r  r3  _cachespecialize_listr^  rK  r|  r  parse_export_functionsshared_utility_functions_validate_suitable_for_sharingr   
code_parts_parts_tuple)r   rE  rF  r  r  r  r  r  r3  r^  rK  r|  r  s   `            r   r   UtilityCode.__init__  s    
 
		"4%:""4 !&		OU(C(CF(K[]%//1 "!X!XXr   export_protor2  c           	      l   SU;  a  SU;  a  SU;  d%   SUR                  5        SU R                   35       e/ nSnUR                  S5       H  nUR                  5       R                  SS	5      n[        R
                  " S
SU5      n[        U5      S:X  a  ML  [        R                  " X4[        R                  5      nUc   SU< SU R                   35       eUR                  5       u  pgnUR                  [        UR                  5       UR                  5       UR                  5       S95        M     U$ )Nz///**/z(Export block must not contain comments:
z

 in file a_  
            ^static\s                                         # `static` keyword
            (?P<ret_type>[^;()]+[\s*])                        # return type + modifier with optional * - e.g.: int *, float, const str *, ...
            (?P<func_name>\w+)\((?P<func_params>[^)]*)\)$     # function with params - e.g. foo(int, float, *PyObject)
        z;
r?  rX  z\s+ r   z5Wrong format of function definition in export block 
z
 in )rK  r  r  )rj  r|  splitreplacer   ra  r   r:  r9  rh  re  r  )	r   r  parsed_protosproto_regexrE  matchedret_type	func_namefunc_paramss	            r   r  "UtilityCode.parse_export_functions  s6   <'D,DUaIa 	e78J8J8L7M[Y]YbYbXcd	ea  "''.EKKM))$3EFF63.E5zQhh{2::>G& dH	QWX\XaXaWbcd& 07~~/?,H  "	(9x~~?OXcXiXiXkl / r   c                 ,    [        U R                  5      $ r   )r   r  r   s    r   __hash__UtilityCode.__hash__	  s    D%%&&r   c                     XL a  g[        U 5      [        U5      p2X#La!  [        X5      (       d  [        X5      (       d  gU R                  UR                  :H  $ )NTF)r   r   r  )r   r   	self_type
other_types       r   __eq__UtilityCode.__eq__  sO    = $T
DK:&
50L0LPZ[_PlPl  E$6$666r   c                     Uc  gX-  $ zI
Format a string in this utility code with context. If None, do nothing.
Nr  r   scontexts      r   none_or_subUtilityCode.none_or_sub  s     9{r   c                    U R                   nUb3  UR                  5       US'   UR                  5       US'   U< SUS   < S3n[        [	        UR                  5       5      5      n U R                  U   $ ! [         GaB    U R                  c  S nO0U R                   Vs/ s H  ofR                  U5      PM     Os  snf nn[        U R                  U R                  U5      U R                  U R                  U5      U R                  U R                  U5      U R                  U R                  U5      U R                  U R                   U5      U R                  U R"                  U5      U R                  U R$                  U5      UU R&                  U5
      =opR                  U'   U R(                  R+                  U5        Us $ f = f)Nr   	type_name[])rK  empty_declaration_codespecialization_namer   r   rG  r  rY   r3  
specializer  r  rE  rF  r  r  r  r  r  r^  r  re  )r   
pyrex_typedatarK  r   r3  rr  s           r   r  UtilityCode.specialize  s   yy!%<<>DL * > > @D#T+%67DF4::<()	;;s## 	}}$8<F1LL.FF#.  T2  D1  D1  t4  !8!8$?  !;!;TB  !8!8$?  $ AC    ''*H)	s   &A5 5)GB98DGGc                 L    [        U S5      nU(       d  g SU;  d
   SU  35       eg )NrF  zNAMED_CGLOBAL(moddict_cname)z$moddict_cname should not be shared: r  )r   r  s     r   r  *UtilityCode._validate_suitable_for_sharing=  s2    dF+F-[@ 	:24&9	:@r   writerCCodeWriteroutputr1  	code_typec                 b   [        X5      nU(       d  g US;   n[        XU5      u  pWU(       a  SU S3OSnUS:w  a  U R                   SU 3OU R                  nUR                  SU U S35        U(       a(  U(       d!  UR	                  XPR                   S	U 35        g UR                  U5        g )
N)rE  rF  z
 (used by rD  rX  rF  rB  /*  */r   )r   process_utility_ccoderK  r  put_or_includeput_multilines)	r   r  r  r  r$  r  can_be_reusedresult_is_module_specificrK  s	            r   _put_code_sectionUtilityCode._put_code_sectionC  s    d.!%661FtU`1a.-4Jwiq)"-6&-@$))Ai[)diis4&	-.!:!!+))Ai[/IJ!!+.r   c                     U R                   (       d  g US   nU R                  X!S5        UR                  SUR                  UR                  5      -   5        UR                  5         g )Ninit_globalsr    )r  r  r  error_goto_if_PyErr
module_pos)r   r  r  s      r   _put_init_code_section"UtilityCode._put_init_code_sectionX  sS    yy'vv6 	TF66v7H7HIIJr   c           
          UR                  SU R                   S35        U R                   H<  nUR                  SUR                   SUR                   SUR                   S35        M>     UR                  5         g )Nr  r  static z(*z)(z); /*proto*/)r  rK  r  r  r  )r   r  shareds      r   !_put_shared_function_declarations-UtilityCode._put_shared_function_declarationsb  sc    

S3'(33FJJBv{{m2fmm_LYZ 4 	

r   c                 V   [        U R                  =(       a*    UR                  R                  R                  R
                  5      nU R                  (       a3  U(       d,  U R                   H  nUR                  X@R                  S9  M     U(       a  U R                  XR                     5        UR                  R                  U R                  5        U R                  (       a  U R                  XR                     USUS9  U(       d  U R                  XR                     US5        U R                  (       a  U(       d  U R                  US   USUS9  U R                  (       a+  [         R"                  (       a  U R                  US   US5        U R$                  (       a  U R                  US   US	5        U R&                  (       a  U R                  US
   US5        U R(                  (       a  U R                  US   US5        U R*                  (       a  U R-                  U5        g g )Nr$  rE  r  utility_code_defrF  cleanup_globalsr  module_state_contentsr  module_state_traverse_contentsr  module_state_clear_contentsr  )r   r  module_nodescoper  shared_utility_qualified_namer3  use_utility_coderK  r  r^  extendrE  r  rF  r  r	   generate_cleanup_coder  r  r  r  r  )r   r#  r$  has_shared_utility_code
dependencys        r   r%  UtilityCode.put_codei  s   "&))qk.E.E.K.K.S.S.q.q#
 ==!8"mm
,,Z,K , #22;?O?O3PQ,,33D4Q4QR::"";/?/?#@+w`g"h&"";/?/?#@+xX994"";/A#BKQWah"i<<G99"";/@#A;PYZ"""";/F#GVjk%%"";/O#PR]_vw"""";/L#M{\pq99''4 r   )r  r  r  r  r|  rF  r  r  r  r  rK  rE  r^  r3  r  r  )NNNNNNNNutility_code_protoNNNr   )r  r  r2  Nr0  )r  r	  r
  r  r  r  r   r(   r   r  r  r  r  r  r  cythonfinalr  r  r  r%  r  r  r   r   r  r    s    & EJAE@D37PTY43 4 <'7@: \\/ /} /Y\ / /(5 5r   r  F)regexis_module_specific_last_macro_processorc                 .   ^ ^^^^ TS   mUUUUU 4S jnU$ )z8Decorator to chain the code macro processors below.
    r   c                 `   >^  [        T 5      S[        S[        4U UUUU4S jj5       nUTS'   U$ )Nutility_coder  c                   > SnTb  T" XU5      u  p#T(       a  T H
  nXB;   d  M
    O   X#4$ T	c
  T" XU5      nO"[         R                  " T	[        TU5      U5      nT H$  nXB;   d  M
  [        SU SU R                   S35      e   UT-  nX#4$ )NFzLeft-over utility code macro 'z()' found in '')r   ra  r   rl   rK  )
r"  r  r  r  macrofuncr  last_processormacro_namesr  s
        r   process=add_macro_processor.<locals>.build_processor.<locals>.process  s     ).%)9G^i9j6 (E+ ) 'AA }"<E ffUGD&,A;O %'&)Gwn]i]n]n\oop'qrr % &);;%99r   r   )r   r  r(   )r&  r)  r  r  r'  r(  r  s   ` r   build_processor,add_macro_processor.<locals>.build_processor  s>    	t	:+ 	:C 	: 	: 
	:8 $+a r   r  )r  r  r  r(  r+  r'  s   ```` @r   add_macro_processorr-    s"     +1-N B r   CSTRINGz)CSTRING\(\s*"""([^"]*(?:"[^"]+)*)"""\s*\))r  c                     UR                  S5      R                  SS5      nSR                  S UR                  5        5       5      $ )zUReplace CSTRING('''xyz''') by a C compatible string, taking care of line breaks.
    r   "z\042rX  c              3      #    U  H@  nUR                  S 5      (       a  UR                  S5      (       a  SU S3OSUSS  S3v   MB     g7f)\z\\r0  z\n"
Nr   "
)endswith)r  rt  s     r   r  !_wrap_c_string.<locals>.<genexpr>  sW      *(D !%d 3 3t}}V7L7L!D6TUVZ[^\^V_U``cRdd(s   AA
)rf  r  r  
splitlines)r   matchobjcontents      r   _wrap_c_stringr9    sF     nnQ''W5G77 *&&(* * *r   r"  c                 $    U R                  U5      $ r   )r  )r"  r   rF  s      r   _format_impl_coder;    s    ##D))r   CALL_UNBOUND_METHODTzLCALL_UNBOUND_METHOD\(([a-zA-Z_]+),\s*"([^"]+)",\s*([^),\s]+)((?:,[^),]+)*)\))r  r  c                 B   UR                  5       u  p#pESU-  nU(       a2  USS R                  S5       Vs/ s H  ofR                  5       PM     snO/ n[        U5      S:  d   S[        U5      S S35       eU R	                  [
        R                   S	3XBX55      $ s  snf )
zRReplace 'UNBOUND_METHOD(type, "name")' by a constant Python identifier cname.
    z&%sr   N,r&   z'CALL_UNBOUND_METHOD() does not support r   z call arguments->)rh  r  rj  r   cached_unbound_method_call_coder   modulestateglobal_cname)r  r7  
type_cnamemethod_name	obj_cnameargsargs          r   _inject_unbound_methodrG    s     08/@,JY#J;?48>>##67#6CIIK#67RDt9q=`CCIa=P_``=11))
*"-{2 2 8s   BPYIDENT	PYUNICODEzPY(IDENT|UNICODE)\("([^"]+)"\)c                     UR                  5       u  p#[        R                  < SU R                  [        R
                  " U5      US:H  S9R                  < 3$ )zDReplace 'PYIDENT("xyz")' by a constant Python identifier cname.
    r?  IDENT
identifier)rh  r   rA  get_py_string_constr
   EncodedStringcname)r  r7  str_typerK  s       r   _inject_string_constantrR    s\     __&NH&&""((.8w;N 	# 	PPUPU	VW Wr   EMPTYzEMPTY\((bytes|unicode|tuple)\)c                 t    UR                  S5      n[        R                  < S[        [        SU 35      < 3$ )zLReplace 'EMPTY(bytes|tuple|...)' by a constant Python identifier cname.
    r   r?  empty_)rf  r   rA  r   )r  r7  r  s      r   !_inject_empty_collection_constantrV    s6     q!I&&&,-/ /r   CGLOBALz(NAMED_)?CGLOBAL\(([^)]+)\)c                 ~    UR                  5       u  p#U(       a  [        [        U5      n[        R                   SU 3$ Nr?  )rh  r   r   rA  )r  r7  is_namedrK  s       r   _inject_cglobalr[    s9     __&NHvt$,,-Rv66r   c                     U$ )z;Entry point for code processors, must be defined last.
    r  )r"  r   r  s      r   r  r    s
     r   c                     U (       d  gU(       a  U SU 3nU(       a  X1S'    X@   nUR                  U5      $ ! [          a    SSKJn  U" XS9=oTU '    N-f = f)z+Run tempita on string s with given context.NrC  __namer   r   )rK  )rY   Tempitar   r@  )r  r  r|  rK  __cachetemplater   s          r   sub_tempitarb    sj    q 7:
 w''	  7& ( 661:7s   8 AAc                   L   ^  \ rS rSrSU 4S jjr\SS0 4S j5       rS rSrU =r	$ )r~  i   Nc                    > Uc  0 nOUR                  5       n[        X&XQ5      n[        X6XQ5      n[        XFXQ5      n[        TU ]  " X#4XAUS.UD6  g )N)r  rK  r|  )r  rb  r   r   )	r   rK  rE  rF  r  r|  r  r)  	__class__s	           r   r   TempitaUtilityCode.__init__!  sc    ?G llnGED74$54$5	D"D	D<B	Dr   c                     U(       a"  [        [        UR                  5       5      5      OS n[        U5      c   eXX4n XF   $ ! [         a     Of = fU R                  XUS9=otU'   U$ )N)r  )r   r   rG  r   rY   r  )rI  r  r  r  _TempitaUtilityCode__cachecontext_keyr   r  s           r   r  TempitaUtilityCode.load_cached-  su    8?eF7==?34TK ,,,0>	< 		!hh'8WhUUs|s   A 
AAc                 L    Uc  g[        XU R                  U R                  5      $ r  )rb  r|  rK  r  s      r   r  TempitaUtilityCode.none_or_sub9  s#     91tyy$))<<r   r  )NNNNNN)
r  r	  r
  r  r   r   r  r  r  __classcell__)re  s   @r   r~  r~     s/    
D 6:DRT 	 	= =r   r~  c                   4    \ rS rSrSrSr SrS rSS	S jjrSrg)
LazyUtilityCodeiB  z~
Utility code that calls a callback with the root code writer when
available. Useful when you only have 'env' but not 'code'.
z<lazy>Nc                     Xl         g r   callback)r   rr  s     r   r   LazyUtilityCode.__init__J  s     r   c                 X    U R                  UR                  5      nUR                  X2S9  g )Nr  )rr  
rootwriterr  )r   r#  r$  rJ  s       r   r%  LazyUtilityCode.put_codeM  s'    -- 6 67$$W$>r   rq  r   r0  )	r  r	  r
  r  r  r3  r   r%  r  r  r   r   ro  ro  B  s"     HH!? ?r   ro  c                       \ rS rSr\" 5       S4S jrS rSS jrSS jrSS jr	S r
S	 rSS
 jrS rS rS rS rS rSS jrS rS rS rS rS rS rS rS rSrg)FunctionStateiR  Nc                    X l         Xl        X0l        S U l        SU l        [        5       U l        U R                  5       U l        U R                  5         S U l
        S U l        / U l        S U l        S U l        SU l        SU l        / U l        0 U l        0 U l        [        5       U l        SU l        S U l        / U l        SU l        SU l        SU l        SU l        g )Nr   FT)names_takenownerr  error_labellabel_counterr   labels_used	new_labelreturn_labelnew_error_labelcontinue_labelbreak_labelyield_labelsexc_varscurrent_except	can_trace	gil_ownedtemps_allocated
temps_freetemps_used_typezombie_tempstemp_counterclosure_tempscollect_temps_stackshould_declare_error_indicatoruses_error_indicatorerror_without_exceptionneeds_refnanny)r   r{  rz  r  s       r   r   FunctionState.__init___  s    &

5 NN,""!!E! $&  /4+$)!',$#r   c                 &   U R                   (       ay  U R                  5       nU(       aa  SU R                  R                  < SSR	                  [        U5       VVVs/ s H  u  p#nU< SU< S3PM     snnn5      < 3n[        U5      eg g s  snnnf )Nz&TEMPGUARD: Temps left over at end of 'z': , z [r  )r  temps_in_user  rK  r  r   rl   )r   	leftoversrK  ctype	is_pytempmsgs         r   validate_exitFunctionState.validate_exit  s    ))+IIMZ^ZcZc282CeE2C.Y "&u-2CeE [F 
 #3''   eEs   Bc                 r    U R                   nUS-   U l         S[        R                  U4-  nUb  USU-   -  nU$ )Nr   %s%dr   )r}  r   label_prefix)r   rK  nlabels       r   r  FunctionState.new_label  sG    --U&--q11S4ZEr   c                     U R                  SU-  5      n[        U R                  5      S-   U4nU R                  R                  U5        U$ )Nzresume_from_%sr   )r  r   r  re  )r   	expr_typer  num_and_labels       r   new_yield_labelFunctionState.new_yield_label  sJ    /);<T../!3U;  /r   c                 P    U R                   nU R                  US-   5      U l         U$ )Nerror)r|  r  )r   prefixold_err_lbls      r   r  FunctionState.new_error_label  s)    &&>>&7*:;r   c                 2    U R                   U R                  4$ r   r  r  r   s    r   get_loop_labelsFunctionState.get_loop_labels  s     	r   c                 "    Uu  U l         U l        g r   r  r   labelss     r   set_loop_labelsFunctionState.set_loop_labels  s    #				r   c                     U R                  5       nU R                  U R                  US-   5      U R                  US-   5      45        U$ )Ncontinuebreak)r  r  r  )r   r  
old_labelss      r   new_loop_labelsFunctionState.new_loop_labels  sM    ))+
^^FZ/0^^FW,-/	0 r   c                 ^    U R                   U R                  U R                  U R                  4$ r   r  r  r  r|  r   s    r   get_all_labelsFunctionState.get_all_labels  s0    	 	r   c                 :    Uu  U l         U l        U l        U l        g r   r  r  s     r   set_all_labelsFunctionState.set_all_labels  s#     $								r   c                     U R                  5       n/ n[        U/ SQ5       H?  u  p4U(       a"  UR                  U R                  U5      5        M.  UR                  U5        MA     U R	                  U5        U$ )N)r  r  r2  r  )r  r   re  r  r  )r   r  
new_labels	old_labelrK  s        r   all_new_labelsFunctionState.all_new_labels  sh    ((*

":/WXOI!!$.."67!!),	  Y
 	J'r   c                 :    U R                   R                  U5        g r   )r~  rk  r   lbls     r   	use_labelFunctionState.use_label  s    S!r   c                     XR                   ;   $ r   )r~  r  s     r   
label_usedFunctionState.label_used  s    &&&&r   c           	         UR                   (       a  UR                  (       d  UR                  nOUR                  (       a  UR                  (       d  UR                  nOUR
                  (       a  SSKJn  UR                  U5      nOoUR                  (       a^  UR                  (       dM  U R                  R                  S   (       a/  U R                  R                  [        R                  SS5      5        UR                  (       d  SnU R                   R#                  X45      nU(       a5  Ub2  US   (       a(  US   R%                  5       nUS   R'                  U5        O U =R(                  S-  sl        S[*        R,                  U R(                  4-  nXpR.                  ;  a  OMF  U R0                  R3                  XqX#45        U(       d  U R4                  R7                  U5        X4U R8                  U'   [:        R<                  (       a1  U R>                  RA                  S	U< S
U< SU(       a  SOS< S35        U RB                  (       a  U RB                  S   R7                  Xq45        U$ )a  
Allocates a temporary (which may create a new one or get a previously
allocated and released one of the same type). Type is simply registered
and handed back, but will usually be a PyrexType.

If type.needs_refcounting, manage_ref comes into play. If manage_ref is set to
True, the temp will be decref-ed on return statements and in exception
handling clauses. Otherwise the caller has to deal with any reference
counting of the variable.

If not type.needs_refcounting, then manage_ref will be ignored, but it
still has to be passed. It is recommended to pass False by convention
if it is known that type will never be a reference counted type.

static=True marks the temporary declaration with "static".
This is only used when allocating backing store for a module-level
C array literals.

if reusable=False, the temp will not be reused after release.

A C string referring to the variable is returned.
r   
PyrexTypes
cpp_localsOptionalLocalsCppSupport.cppFr   r  r  z allocated (rD  rX  	 - zombier  r   )"is_cv_qualifiedis_referencecv_base_typeis_fake_referenceref_base_typeis_cfunctionrX  r  
c_ptr_typeis_cpp_classr  
directivesr  r  r  needs_refcountingr  r   popremover  r   codewriter_temp_prefixrz  r  re  r  rk  r  r   debug_temp_code_commentsr{  r  r  )r   r   
manage_refstaticreusabler  freelistresults           r   allocate_tempFunctionState.allocate_temp  s   . (9(9$$Dt'='=%%D$((.Dt'='=$**BWBWXdBeJJ''(?(?@PRb(cd%% J??&&'9:,!a[__&FQKv&!!Q&!6#@#@$BSBS"TT!1!115    ''z(JK!!%%f-(,'9V$..JJFDPX"^iJijk##$$R(,,f^<r   c                    U R                   U   u  p#U R                  R                  X#45      nUc  / [        5       4nX@R                  X#4'   XS   ;   a  [	        SU-  5      eXR
                  ;  a  US   R                  U5        US   R                  U5        [        R                  (       a6  U R                  R                  SU< SXR
                  ;   a  SOS< S	35        gg)
z^
Releases a temporary so that it can be reused by other code needing
a temp of the same type.
Nr   zTemp %s freed twice!r   r  z
 released r  rX  r  )r  r  r   r   rl   r  re  rk  r   r  r{  r  )r   rK  r   r  r  s        r   release_tempFunctionState.release_temp  s    
  //5??&&'9:CE{H2:OOT./A;5<==(((QKt$..JJT->->%>kBFH I /r   c                     / nU R                    HU  u  p#pEU R                  R                  X445      nUb
  X&S   ;  d  M/  UR                  X#U=(       a    UR                  45        MW     U$ )zhReturn a list of (cname,type,manage_ref) tuples of temp names and their type
that are currently in use.
r   )r  r  r   re  r  )r   usedrK  r   r  r  r  s          r   r  FunctionState.temps_in_use(  sh     .2.B.B*D
**D+=>H4{#:T)N8N8NOP /C r   c                     U R                  5        VVVs/ s H%  u  pnU(       d  M  UR                  (       d  M"  X4PM'     snnn$ s  snnnf )zReturn a list of (cname,type) tuples of temp names and their type
that are currently in use. This includes only temps
with a reference counted type which owns its reference.
)r  r  )r   rK  r   r  s       r   temps_holding_reference%FunctionState.temps_holding_reference3  sL     /3.?.?.A:.A*D
 "&"8"8 .A: 	: :s   AAAc           
      r    U R                    VVVVs/ s H  u  pp4U(       d  M  X4PM     snnnn$ s  snnnnf )zRReturn a list of (cname, type) tuples of refcount-managed Python objects.
        )r  )r   rP  r   r  r  s        r   all_managed_tempsFunctionState.all_managed_temps<  s;     8<7K7K7K3E 7K 	 s   1
1
c                     [        U R                  R                  5        VVVVs/ s H   u  u  po2(       d  M  US     H  nXA4PM     M"     snnnn5      $ s  snnnnf )zReturn a list of (cname, type) tuples of refcount-managed Python
objects that are not currently in use.  This is used by
try-except and try-finally blocks to clean up temps in the
error case.
r   )r   r  rG  )r   r   r  r  rP  s        r   all_free_managed_temps$FunctionState.all_free_managed_tempsC  s`     040E0E0G
0G,"H: !! M$ 0G
  	 
s
   AAc                 J    U R                   R                  [        5       5        g)z:
Useful to find out which temps were used in a code block
N)r  re  r   r   s    r   start_collecting_temps$FunctionState.start_collecting_tempsO  s     	  ''.r   c                 6    U R                   R                  5       $ r   )r  r  r   s    r   stop_collecting_temps#FunctionState.stop_collecting_tempsU  s    ''++--r   c                 $    [        U5      U l        g r   )ClosureTempAllocatorr  r   r  s     r   init_closure_temps FunctionState.init_closure_tempsX  s    1%8r   )r  r  r  r  r  r  r|  r  r  r  r}  r~  rz  r  r{  r  r  r  r  r  r  r  r  r  r  r   )yield)rX  )FT)r  r	  r
  r  r   r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r   r   rx  rx  R  s|     +.%t '$V
(

$$	"'
8tI&	:
/.9r   rx  c                   "    \ rS rSrSrSS jrSrg)NumConsti\  zGlobal info about a Python number constant held by GlobalState.

cname       string
value       string
py_type     string     int, long, float
value_code  string     evaluation code if different from value
Nc                 H    Xl         X l        X0l        U=(       d    UU l        g r   )rP  valuepy_type
value_code)r   rP  r  r  r  s        r   r   NumConst.__init__e  s    

$-r   )rP  r  r  r  r   r  r	  r
  r  r  r   r  r  r   r   r	  r	  \  s    .r   r	  c                       \ rS rSrSrS rSrg)PyObjectConstil  z>Global info about a generic constant held by GlobalState.
    c                     Xl         X l        g r   rP  r   r   rP  r   s      r   r   PyObjectConst.__init__r  s    
	r   r  Nr  r  r   r   r  r  l  s    
r   r  )possible_unicode_identifierpossible_bytes_identifierreplace_identifierfind_alphanumsz(?![0-9])\w+$s   (?![0-9])\w+$z[^a-zA-Z0-9_]+z([a-zA-Z0-9]+)c                   (    \ rS rSrSrS rSS jrSrg)StringConsti~  z?Global info about a C string constant held by GlobalState.
    c                 n    Xl         X l        [        R                  " U5      U l        S U l        SU l        g NF)rP  textr
   escape_byte_stringescaped_value
py_stringsc_used)r   rP  r  byte_strings       r   r   StringConst.__init__  s-    
	+>>{Kr   Nc                    U R                   nU(       d  Uc  S =pSnO7SnUR                  5       nUS;   a  S nS nOSR                  [        U5      5      nU(       a  SnODUc?  [	        U[
        5      (       a  [        [        U5      5      nO[        [        U5      5      nOSnXeU4nU R                  c  0 U l	        O U R                  U   $ U(       a  [        R                  S   O[        R                   U(       a  SOS U(       a  SU-   OS SU R                  [        [        R                   5      S   3n[#        XXe5      n	XR                  U'   U	$ ! [         a     Nf = f)	NTF)utf8utf-8r   usasciizus-asciirX  r(   ubr   )r  lowerr  r  r   r   r   r  r  r!  rY   r   interned_prefixespy_const_prefixrP  r   const_prefixPyStringConst)
r   r  rM  r  encoding_key
is_unicodeinternr   pystring_cname	py_strings
             r   rN  StringConst.get_py_string_const  s]   yy )&**HJ J~~'HLL#!ww~h'?@F$&&7=>9$?@F<0??" DOs++
 39v''.f>T>TU sc*%1s\!r:

3v2234568 	 ".FO	(  s   <E 
E E )r"  rP  r   r!  r  r   )r  r	  r
  r  r  r   rN  r  r  r   r   r  r  ~  s    /r   r  c                   (    \ rS rSrSrSS jrS rSrg)r/  i  zDGlobal info about a Python string constant held by GlobalState.
    c                 4    Xl         X l        X@l        X0l        g r   )rP  r  r1  r2  )r   rP  r  r2  r1  s        r   r   PyStringConst.__init__  s    
 $r   c                 4    U R                   UR                   :  $ r   rP  r   r   s     r   __lt__PyStringConst.__lt__  s    zzEKK''r   )rP  r  r2  r1  NFF)r  r	  r
  r  r  r   r<  r  r  r   r   r/  r/    s    (r   r/  c                   j   \ rS rSr0 r/ SQr/ SQrS3S jrS rS r	S r
S	 rS
 rS rS3S jrS4S jrS rS3S jrS rS5S jrS rS3S jrS rS rS rS3S jrS rS rS rS6S jrS\4S jrS r S r!S  r"S! r#S" r$S5S# jr%S$ r&S% r'S& r(S'\)S(\)4S) jr*S* r+S+ r,\-S, 5       r.S- r/S. r0S/ r1S3S0 jr2S1 r3S2r4g)7r1  i  ))h_codefilename_tableutility_code_proto_before_typesnumeric_typedefscomplex_type_declarationstype_declarationsr  module_declarationstypeinfobefore_global_var
global_varstring_declsdeclslate_includesmodule_stater  module_state_endconstant_name_definesr  r  module_state_clear_endr  r  module_state_traverse_endmodule_codemodule_exttypesinitfunc_declarationsinit_modulepystring_tablecached_builtinscached_constantsinit_constantsinit_codeobjectsr  r  cleanup_modulemain_methodutility_code_pragmasr  utility_code_pragmas_endend)r@  rB  rE  r  r_  Nc                 r   0 U l         / U l        0 U l        [        5       U l        0 U l        SU l        X0l        X@l        0 U l	        X l
        0 U l        0 U l        0 U l        0 U l        / U l        0 U l        / U l        0 U l        0 U l        [        5       U l        / U l        UR-                  U 5        Xl        g r  )rA  filename_listinput_file_contentsr   utility_codesdeclared_cnamesin_utility_code_generationcode_configcommon_utility_include_dirpartsr  const_cnames_usedstring_const_indexdedup_const_indexpyunicode_ptr_const_indexcodeobject_constantsnum_const_indexarg_default_constantsconst_array_counterscached_cmethodsinitialised_constantsr  set_global_stateru  )r   r  r  rf  rg  s        r   r   GlobalState.__init__&  s     #%  U!*/'&*D'
& "$"$!#)+&$&!!%'"$&!!%(U"(*%% r   c                    U R                   n[        U R                  5       H?  u  p#UR                  5       =o@R                  U'   US:  d  M+  UR                  SU-  5        MA     U R                  S   nUR                  S[        R                   S[        R                   S35        UR                  S[        R                   S35        U R                  S	   nUR                  S
[        R                   S[        R                   S3SS9  UR                  S[        R                   S35        UR                  [        R                  " S5      5        U R                  S   nUR                  S5        U R                  S   nUR                  S[        R                   S[        R                   S35        UR                  S[        R                   S35        [        R                  (       d  U R                  S	 OfU R                  S   nUR                  S[        R                   S[        R                   S35        UR                  S[        R                   S35        U R                  S   nUR                  S5        UR                  S5        U R                  S   nU R                  R                   (       a  UR#                  S5        UR                  S5        UR                  S5        g )Nr   z/* #### Code section: %s ### */rW  zint __Pyx_InitCachedBuiltins( *rD  CYTHON_UNUSED_VAR();rX  zint __Pyx_InitCachedConstants(T)refnanny__Pyx_InitCachedConstantsr  zint __Pyx_InitGlobals(void)rY  zint __Pyx_InitConstants(r  zvoid __Pyx_CleanupGlobals(r  rX  z)/* --- Runtime support code (head) --- */r  z
#line 1 "cython_utility"
z"/* --- Runtime support code --- */)ru  r   code_layoutinsertion_pointrh  r  start_initcfuncr   modulestatetype_cnamemodulestatevalue_cnameput_setup_refcount_contextr
   rO  r	   r  rf  emit_linenumsr  )r   ru  ir  wr  s         r   initialize_main_c_code"GlobalState.initialize_main_c_codeB  s   __
 !1!12GA#-#=#=#??A

4 1u9D@A 3
 JJ()	+++,Bv/L/L.MQP	Q 	
$V%B%B$C2FGJJ)*	,++,Bv/L/L.MQP 	 	 	
$V%B%B$C2FG	$$^%A%AB]%^_JJ~&	78JJ'(	&++,Bv/L/L.MQP	Q 	
$V%B%B$C2FG,,

,-

,-A,//063P3P2QQRTU GG()F)F(GrJKzz./

2

>?zz,-))JJ56

2

78r   c                 |    U R                   nU R                   H   nUR                  5       U R                  U'   M"     g r   )ru  h_code_layoutr|  rh  )r   ru  r  s      r   initialize_main_h_code"GlobalState.initialize_main_h_codes  s2    __
&&D)99;DJJt 'r   c                 d   U R                  5         U R                  S   n[        R                  SS5      nUR	                  UR                  UR                  5      5        UR                  S5        U R                  S   n[        R                  SS5      nUR                  UR                  UR                  5      5        UR                  S5        U R                  S   n[        R                  S	S5      nUR                  UR                  UR                  5      5        UR                  S5        g )
Nr  TypeConversionszTypeConversion.crX  r]  UtilityCodePragmasModuleSetupCode.cr^  UtilityCodePragmasEnd)	close_global_declsrh  r~  r  putr  rF  r  r  )r   r  r  s      r   finalize_main_c_code GlobalState.finalize_main_c_codex  s    !
 zz,-!--.?AST!!$)),-

2
 zz01&&';=PQ

4##DII./

2zz45&&'>@ST

4##DII./

2r   c                      U R                   U   $ r   )rh  )r   r   s     r   __getitem__GlobalState.__getitem__  s    zz#r   c                    U R                  5         U R                  S   nUR                  S5        UR                  UR                  5      (       a,  UR                  UR                  5        UR                  S5        UR                  S5        UR                  5         U R                  S   nS HT  nX R                  ;   d  M  U R                  UR                  [        R                  U-   5      U R                  U   U5        MV     UR                  5         UR                  S5        UR                  UR                  5      (       a<  UR                  UR                  5        UR                  5         UR                  S5        UR                  S5        UR                  5         S H  nU R                  U   nUR                  S5        UR                  UR                  5      (       a,  UR                  UR                  5        UR                  S5        UR                  S5        UR                  5         M     [        R                  (       a0  U R                  S   nUR                  S5        UR                  5         [        R                  (       a1  U R                  S	   nUR                  S5        UR                  5         g g )
NrW  	return 0;
return -1;}rX  )r   r   )r  rY  r  r[  )generate_const_declarationsrh  r  r  r|  	put_labelexit_cfunc_scoperp  immortalize_constantsname_in_module_stater   pyrex_prefixput_finish_refcount_contextr	   r  )r   r  
const_typer  s       r   r  GlobalState.close_global_decls  s	    	((*JJ()	<<&&KK&GGL!		JJ)*,J666****6+>+>+KL--j9 - 	
%%'	<<&&KK&))+GGL!		6D

4 AGGK ||AMM**AMM*%GGCL  7 ((

,-AGGCL ((

+,AGGCL  )r   c                 F    U S   R                  SUR                  -  5        g )NrI  zstatic PyObject *%s;)r  rP  r   entrys     r   put_pyobject_declGlobalState.put_pyobject_decl  s    \  !7%++!EFr   c                 |    Ub+  XR                   ;   a  g U R                   R                  U5        U R                  S   $ )NrX  )rr  rk  rh  r   targets     r   get_cached_constants_writer'GlobalState.get_cached_constants_writer  s;    333&&**62zz,--r   c                     U=(       a    S=(       d    Sn U R                   X4   nU$ ! [         a    U R                  X5      n U$ f = f)Nlongr   rn  rY   new_num_const)r   	str_valuelongnessr  cs        r   get_int_constGlobalState.get_int_const  sV    %v.	7$$i%9:A   	7""96A	7s   ( AAc                 r     U R                   US4   nU$ ! [         a    U R                  USU5      n U$ f = f)Nr   r  )r   r  r  r  s       r   get_float_constGlobalState.get_float_const  sP    	C$$i%9:A   	C""9gzBA	Cs    66c                     Ub   U R                   R                  U5      nUb  U$ U R                  U5      nUb  X0R                   U'   U$ r   )rk  r   new_array_const_cname)r   r  	dedup_keyconsts       r   get_py_constGlobalState.get_py_const  sR     **..y9E **62 05""9-r   c                 t    U R                  S5      n[        X!5      nU R                  R                  U5        U$ NrX  )new_const_cnamer  ro  re  )r   r   rP  r  s       r   get_argument_default_const&GlobalState.get_argument_default_const  s7    $$R(%&""))!, r   c                     UR                   (       a  UR                  5       nOUR                  5       n U R                  U   nU(       a  SUl        U$ ! [         a    U R                  X5      n N-f = fNT)r1  
utf8encode
byteencoderj  rY   new_string_constr"  )r   r  r"  r#  r  s        r   get_string_constGlobalState.get_string_const  sh    ??//+K//+K	9''4A AH	  	9%%d8A	9s   A A10A1c                     UR                   (       d   e U R                  U   nU$ ! [         a"    U R                  5       =o R                  U'    U$ f = fr   )r1  rl  rY   r  )r   r  r  s      r   get_pyunicode_ptr_const#GlobalState.get_pyunicode_ptr_const  s_    	N..t4A   	N7;7K7K7MMA..t4	Ns   & (AAc                 ^    U R                  USS9nUR                  UR                  U5      nU$ )NF)r"  )r  rN  r  )r   r  rM  c_stringr4  s        r   rN  GlobalState.get_py_string_const  s3     $ 5 5d5 5 I00
K	r   c                     [        U R                  5      n[        R                   SU S3nU R                  R	                  U5        U$ )Nr  r  )r   rm  r   codeobjtab_cnamere  )r   nodeidxrK  s       r   get_py_codeobj_const GlobalState.get_py_codeobj_const  sD    $++,))*!C52!!((.r   c                 "    U R                  USS9$ NTrL  rN  r   r  s     r   get_interned_identifier#GlobalState.get_interned_identifier      '''>>r   c                 \    U R                  U5      n[        X1U5      nX@R                  U'   U$ r   )new_string_const_cnamer  rj  )r   r  r#  rP  r  s        r   r  GlobalState.new_string_const  s1    ++K8[1/0,r   c                 ^    U R                  X5      n[        XAX#5      nXPR                  X4'   U$ r   )new_num_const_cnamer	  rn  )r   r  r  r  rP  r  s         r   r  GlobalState.new_num_const   s4    ((8U7712e-.r   c                 D    UR                  SS5      nU R                  US9$ )NASCIIignore)r  )decoder  )r   bytes_valuer  s      r   r  "GlobalState.new_string_const_cname&  s(    ""7H5##%#00r   c                     U R                   nUR                  SSS9=p4X2;   a"  X$   S-   =oRU'   UR                  SUS9nX2;   a  M"  SX#'   U$ )NrX  )sepr   r   r   )ri  r   )r   
format_strr  rP  r  r   s         r   unique_const_cnameGlobalState.unique_const_cname+  sf    %%"))b")==m$(K!O3G5k%%#w%?E m r   c                 "   US:X  a  US-  nSn[         R                  U   nUR                  SS5      R                  SS5      R                  SS5      n[        U5      S	:  a%  U R	                  US
-   US S -   S-   USS  -   5      nU$ U< U< 3nU$ )Nr  Lr   rB  r   +-neg_*   zlarge{counter}_   _xxx_i)r   r,  r  r   r  )r   r  r  r  rP  s        r   r  GlobalState.new_num_const_cname4  s    fSLEG))'2c3'//S9AA#vNu:?++**U3BZ7'AE#$KOQE  %e,Er   c                     [        SU5      S S R                  S5      nU R                  US-   5      nU(       a  [        R                  U   nO[        R
                  nU< U< 3$ )Nr       z{sep}{counter})r  rj  r  r   r,  r.  )r   r  r  name_suffixs       r   r  GlobalState.new_const_cnameC  s_    "3.s399#>--e6F.FG--f5F((F--r   r  c                     U R                   R                  US5      nUS-   U R                   U'   [        R                   U SU S3$ )Nr   r   r  r  )rp  r   r   r  )r   r  counts      r   r  !GlobalState.new_array_const_cnameL  sL    ))--fa8,1!G!!&)%%&vhawa88r   c                     X4n U R                   U   nU$ ! [         a+    U R                  SU< SU< 35      =o@R                   U'    U$ f = f)Numethodr   )rq  rY   r  )r   rB  rC  r   rP  s        r   get_cached_unbound_method%GlobalState.get_cached_unbound_methodQ  sk    '	@((-E   	@040D0Dj+>1@ @E((-	@s    1A
Ac           	          S[        U5      -  nU R                  [        R                  US5      5        U R	                  X45      nU/U-   nSU< SU< U< SSR                  U5      < S3$ )NzCallUnboundCMethod%dObjectHandling.c__Pyx_z(&r  rD  )r   r  r  r  r  r  )	r   modulestate_cnamerD  rB  rC  
arg_cnamesr  cache_cnamerE  s	            r   r@  +GlobalState.cached_unbound_method_call_codeZ  sh    2S_Dk556GI[\]44ZM{Z'IIdO	
 	
r   c                 f   UR                   (       a  UR                  (       a  U R                  UR                  U5      (       al  U R	                  U5        UR
                  nU[        ;   a	  [        U   nU R                  UR                  [        R                  " U5      UR                  5        g g g g r   )
is_builtinis_constshould_declarerP  r  rK  renamed_py2_builtins_mapput_cached_builtin_initposr
   rO  )r   r  rK  s      r   add_cached_builtin_decl#GlobalState.add_cached_builtin_declg  s    ""5;;66&&u-zz333D9D,,II~;;DAKK! 7 !/r   c                    U R                   S   nUR                  U R                  U5      R                  5      nU R	                  [
        R                  SS5      5        UR                  U< SU< SU< SUR                  U5      < 35        g )NrW  GetBuiltinNamer  z = __Pyx_GetBuiltinName(z); if (!) )	rh   name_in_main_c_code_module_stater  rP  r  r  r  r  
error_goto)r   r  rK  rP  r  cname_in_modulestates         r   r  #GlobalState.put_cached_builtin_initr  s}    JJ() AA((.44 6##$46HI	K	 LL	 	 r   c                     U R                  5         U R                  5         U R                  5         U R                  5         U R	                  5         g r   )generate_cached_methods_declsgenerate_object_constant_declsgenerate_codeobject_constantsgenerate_string_constantsgenerate_num_constantsr   s    r   r  'GlobalState.generate_const_declarations~  s@    **,++-**, 	&&(##%r   c                     US:  a  SOSnU(       a  SOSnU R                   S   nUR                  SU SU S	U S
U S3	5        U R                   S   nUR                  SU SU SU S35        g )N   r   
Py_ssize_tPy_VISIT__Pyx_VISIT_CONSTr  for (z i=0; i<z	; ++i) { z(traverse_module_state->z[i]); }r  z&; ++i) { Py_CLEAR(clear_module_state->)rh  r  )r   struct_attr_cnamer  may_have_refcyclescounter_type
visit_callr  s          r   )_generate_module_array_traverse_and_clear5GlobalState._generate_module_array_traverse_and_clear  s     %u<#5Z;N
34u\N(5'J<Oghygz  {C  D  	E01u\N(5'9`ar`ss{|}r   c                    U R                    Vs/ s H%  n[        UR                  5      UR                  U4PM'     nnUR                  5         U H  u  p4nU R                  S   R                  SUR                  R                  U5      -  5        UR                  R                  (       d  M]  U R                  S   R                  SU 3UR                  SSS9  UR                  R                  (       a  US-  nU R                  S	   R                  S
U S35        M     [        U R                  R                  5       5       H  u  pV[        R                   U 3nU R                  S   R                  SU SU S35        U R!                  XvSS9  [#        U5      nUc  M^  U[$        R&                  ::  d  Mt  U R                  S   n	U	R)                  SU S35        U	R                  SU	R+                  U S35      -  5        M     g s  snf )NrM  z%s;r  zclear_module_state->TF)clear_before_decrefnannyz	->memviewr  z Py_VISIT(traverse_module_state->rx  
PyObject *r  ];r(  r  zfor (size_t i=0; i<z; ++i) z{ Py_CLEAR(%s); }z[i])ro  r   rP  sortrh  r  r   declaration_coder  put_xdecref_clearis_memoryviewslicer   rp  rG  r   r  r+  cleanup_level_for_type_prefixr	   r  r  r  )
r   r  constsr   rP  r  r  r'  cleanup_levelpart_writers
             r   r  *GlobalState.generate_object_constant_decls  s   5575a qww<!,5 	 7!KAaJJ~&,,UQVV5L5LU5S-ST66++ JJ+,>>&ug.$(	 ?  vv(($JJ./5525'<>' ", $D$=$=$C$C$EFMF#)#6#6"7x @JJ~&,,z:K9LAeWTV-WX ::;Lhm:n9&AM(]g>[>[-["jj):;"5eWG DE!!'#DDHYGZZ]E^_` G37s   ,Hc                    U R                   (       d  g U R                  S   nU R                  S   nUR                  S5        UR                  S5        / n[        U R                   R	                  5       5       H  u  u  pEnUR                  U5        U R                  [        R                  " U5      5      R                  nUR                  SU-  5        UR                  UR                  U5      < SU< S35        UR                  UR                  U5       SUR                  U5       S35        M     [        R                  (       a=  U R                  S	   nU H'  nUR                  S
UR                  U5       S35        M)     g g )NrM  rW  rX  z/* Cached unbound methods */z__Pyx_CachedCFunction %s;z.type = (PyObject*);z.method_name = &r  z	Py_CLEAR(z	.method);)rq  rh  r  r   rG  re  r  r
   rO  rP  r  r	   r  )	r   declr  cnamesrB  rC  rP  method_name_cnamer  s	            r   r  )GlobalState.generate_cached_methods_decls  sf   ##zz.)zz+,

2

1206t7K7K7Q7Q7S0T,%ZuMM%  $ < <^=Y=YZe=f g m mJJ2  JJ55e<jJ K JJ88?@ A99:KLMQPQ 1U ((jj!23G	$*O*OPU*V)WW`ab   )r   c                    / n/ n/ n[        U R                  R                  5        Vs/ s H%  n[        UR                  5      UR                  U4PM'     sn5       GH?  u    pTUR
                  (       a;  UR                  [        UR                  5      UR                  UR                  45        UR                  (       d  Mf  UR                  R                  5        H  nUR                  nUR                  (       aM  [        U[        5      (       d8  [        R                  " UR                  UR                   =(       d    S5      5      nUR                  (       a  UOUR                  UR"                  =(       a    UR                  UR                  U45        M     GMB     UR%                  5         UR%                  5         UR%                  5         U R&                  S   nU H3  u  pYn
[        R(                  " U
5      nUR+                  SU	 SU S3SS9  M5     [        U R,                  R/                  5       5       H  u  pI[        R0                  " U5      u  pU(       a  UR+                  S5        UR+                  S	U	< S
U< S35        U(       d  MX  UR+                  S5        UR+                  S	U	< S
U< S35        UR+                  S5        M     [        U5      [        U5      -   nU R&                  S   R+                  S[2        R4                   SU S35        U R7                  [2        R4                  USS9  U R9                  X25        g s  snf )Nr  rJ  zstatic const char z[] = "";Tsafez#ifdef Py_UNICODE_WIDEzstatic Py_UNICODE z[] = { z };#else#endifrM  r0  r  r1  Fr2  )r   rj  r  r   rP  r"  re  r   r!  r  r1  r   r(   r
   rO  r  r  r2  r3  rh  split_string_literalr  rl  rG  encode_pyunicode_stringr   stringtab_cnamer+  generate_pystring_constants)r   c_constspy_bytes_constspy_unicode_constsr  r   r4  r  decls_writerrP  r   cliteralutf16_arrayutf32_arraypy_string_counts                  r   r  %GlobalState.generate_string_constants  s    4CZCZCaCaCcdCcaAGGaggq9CcdeGAqxxQWWqww HI|||!"!4!4!6I66D ++JtS4I4I-;;DKK	HZHZHe^e<fg*3*>*>&O[[!((AY-A-A!]  "7	 f 	  zz.1'/#Am%::=IH$UG6(2>   (0 t==CCEFHA'5'M'Ma'P$K""#;<UKXY{""7+""P[#\]""8, G o.5F1GG

>"((:f6L6L5MQN__a)bc66v7M7Msx6y(():L[ es   ,Mtext_stringsbyte_stringsc                    U R                   S   n/ nSnSn[        U5       Hf  u  nu  pn
UR                  U
R                  S5      5        US:X  a	  U(       a  UnUR	                  SU	 S[
        R                   SU S35        US	-  nMh     [        U5      nU Ht  u  pn
UR                  U
R                  (       a  U
R                  5       OU
R                  5       5        UR	                  SU	 S[
        R                   SU S35        US	-  nMv     [        [        [        U5      5      nS
R                  U5      nU R                   S   nUR	                  S5        UR	                  S[        U5      R                  5        SSR                  U Vs/ s H  nSU-  PM
     sn5       S35        U R!                  ["        R%                  SS5      5        Sn['        [(        5       GHw  u  nnnUc  M  U" U5      n[        U5      [        U5      S-
  :  a  M2  US:X  a  US	:X  d   S5       eSnOUS:X  a  SU S3nOSU 3nUR	                  SU(       d  SOS SU SU S [        U5       S!3	5        S"n[*        R,                  " [*        R.                  " U5      5      nUR	                  S#U S$3S"S%9  UR	                  S&[        U5       S'U S(35        UR	                  UR1                  S)U R2                  5      5        UR	                  S*5        UR	                  S+5        UR	                  S,UR5                  U R2                  5       S-35        UR	                  S.5        GMz     U(       a  UR	                  S/[        U5       S!35        [*        R,                  " [*        R.                  " U5      5      nUR	                  S0U S$3S"S%9  UR	                  S15        UR	                  S25        U(       a  UR	                  S.5        UR	                  S3UR7                  [
        R                  5       S435        UR	                  S55        US:  a  UR	                  S6US7:  a  S8OS9 S:U S;35        UR	                  S<5        UR	                  S=5        US:  a  UR	                  S>U S?35        UR	                  S@5        UR	                  SA5        UR	                  UR5                  U R2                  5      5        UR	                  SB5        UR	                  SC5        UR	                  SD5        UR	                  SB5        U[        U5      :  a  UR	                  S6[        U5      S7:  a  S8OS9 SEU SF[        U5       S;35        UR	                  S<5        UR	                  SG5        UR	                  SC5        UR	                  SD5        UR	                  S@5        UR	                  SA5        UR	                  UR5                  U R2                  5      5        UR	                  SB5        UR	                  SB5        UR	                  SA5        UR	                  SH[        U5       S;35        UR	                  SI5        UR	                  UR5                  U R2                  5      5        UR	                  SB5        UR	                  SB5        U[        U5      :  a"  U R9                  SJU 3[        U5      U-
  U5        UR	                  SB5        g s  snf )KNrO  r   r   r'  #define r  r  r  r   r   rY  {z*const struct { const unsigned int length: z; } index[] = {r>  z{%d}};DecompressStringzStringTools.cF
   r"   zBCompression algorithm no. 1 must be 'zlib' to be used as fallback.z(CYTHON_COMPRESS_STRINGS) != 0r'   z(CYTHON_COMPRESS_STRINGS) == z+ && __PYX_LIMITED_VERSION_HEX >= 0x030e0000rW  ifelifz /* compression: z (z
 bytes) */Tzconst char* const cstring = "rC  rD  z1PyObject *data = __Pyx_DecompressString(cstring, r  rx  r  z7const char* const bytes = __Pyx_PyBytes_AsString(data);z#if !CYTHON_ASSUME_SAFE_MACROSz,if (likely(bytes)); else { Py_DECREF(data);  }rG  z#else /* compression: none (zconst char* const bytes = "zPyObject *data = NULL;z*CYTHON_UNUSED_VAR(__Pyx_DecompressString);zPyObject **stringtab = r=  zPy_ssize_t pos = 0;r&  r"  r   r#   i = 0; i < ; i++) {z*Py_ssize_t bytes_length = index[i].length;zIPyObject *string = PyUnicode_DecodeUTF8(bytes + pos, bytes_length, NULL);zif (likely(string) && i >= z#) PyUnicode_InternInPlace(&string);zif (unlikely(!string)) {zPy_XDECREF(data);r  zstringtab[i] = string;zpos += bytes_length;z i = z; i < zHPyObject *string = PyBytes_FromStringAndSize(bytes + pos, bytes_length);zfor (Py_ssize_t i = 0; i < z2if (unlikely(PyObject_Hash(stringtab[i]) == -1)) {zstringtab + )rh  r   re  encoder  r   rJ  r   r  r  r  r   r   r  r   
bit_lengthr  r  r  r   compression_algorithmsr
   rH  r  error_goto_if_nullr  r  r  r  )r   rU  rV  definesbytes_valuesfirst_internedstringtab_posr  is_internedrP  r  stringtab_bytes_startr   indexconcat_bytesr  lengthhas_ifalgo_number	algo_namer   compressed_bytesguardescaped_bytess                           r   rK  'GlobalState.generate_pystring_constants  sh   **45,.+, .7|-D)A)DG 45#!"MMHUG1V-C-C,DAm_TUVWQM .E 47|3D +NAdT]] 1HYZMMHUG1V-C-C,DAm_TUVWQM +
 Sl+,xx-JJ'(	 	
**-e**?*?*A)B C885$I5Vf_5$IJK3P	
 	k556H/Z[089O0P,KH'5#$L(9B(>>F""a'n+mn'8f$7}Dop7}EGGaF7q?PQZP[[]^abr^s]tt~  AF*??112BCEMGG3M?"EDGQGGGL\H]G^^`al`mmopqGGA((ABGGMNGG45GGCALLQUQ`Q`DaCbbefgGGH9 1Q< GG23|3D2EZPQ&;;--l;=	-m_B?dK	()	<=GGH 	
)!*L*LVMcMc*d)eefgh	%& !1$ GGe%:U%BEUUabwax  yB  C  DGG@AGG_`"5n5EEhijGG./GG'(GGALL12GGCLGG,-GG*+GGCL !3u:-GGeSZ%%7E\J%PeOfflmpqvmwlx  yB  C  DGG@AGG^_GG,-GG*+GG./GG'(GGALL12GGCLGGCL	#$ 	
-c%j\CD	DE	T__-.		
 !3u:-&&6K5L'MsSXz\qOqstu	S %Js   [6c                    U R                   S   nS[        R                   S[        R                   S3nU R                  (       dg  UR                  U5        UR                  S[        R                   S35        UR                  S5        UR                  5         UR                  S5        g S	nS
nS
nS
nS
nS
nU R                   H  n	U	R                  n
U
R                  (       dV  [        U[        U
R                  5      U
R                  -
  5      n[        XZR                  5      n[        XjR                  5      n[        U[        U	R                  5      5      n[        XR                   S
   5      nM     UR#                  [$        R&                  " SUR)                  5        SUR)                  5        SUR)                  5        SUR)                  5        SUR)                  5        SUR)                  5        S35      5        U R+                  [,        R/                  SS5      5        UR                  U5        UR                  S5        UR                  S5        U R                   H  n	U	R1                  US5        M     UR                  S5        UR                  S5        UR                  S5        UR                  S5        UR                  S5        UR                  5         UR                  S5        [        U R                  5      nU R                   S   R                  S[        R2                   SU S35        U R5                  [        R2                  USS9  g ) NrZ  zint __Pyx_CreateCodeObjects(rv  rD  rw  rx  r  r  i  r   z=        typedef struct {
            unsigned int argcount : z.;
            unsigned int num_posonly_args : z-;
            unsigned int num_kwonly_args : z%;
            unsigned int nlocals : z#;
            unsigned int flags : z(;
            unsigned int first_line : z;;
        } __Pyx_PyCode_New_function_description;
        
NewCodeObjr  z)PyObject* tuple_dedup_map = PyDict_New();z*if (unlikely(!tuple_dedup_map)) return -1;badzPy_DECREF(tuple_dedup_map);zbad:r  rM  r0  r  r1  Fr2  )rh  r   r~  r  rm  r}  r  r  def_nodeis_generator_expressionr   r   rE  num_kwonly_argsnum_posonly_argsvarnamesr  r  r   dedentrc  r  r  r  generate_codeobjr  r+  )r   r  init_function	max_flagsmax_func_argsmax_kwonly_argsmax_posonly_argsmax_varsmax_liner  ry  code_object_counts               r   r  )GlobalState.generate_codeobject_constants  s   JJ)**6+G+G*H6KhKhJiijk 	 ((m,GG()F)F(GrJKGGK  GGCL 	--D}}H33 #M3x}}3EH`H`3` a"%o7O7O"P#&'79R9R#S 8S%78H8\\!_5H . 	
hoo #%%2%=%=%?$@ A--=-H-H-J,K L,,;,F,F,H+I J$$,$7$7$9#: ;""+"6"6"8!9 :''/':':'<&= >		 	 		 	k55lDWXY	-(	;<	<=--D!!!U+ . 	
-.			-.			 9 9:

>"((:f6M6M5NaPaObbd)ef66v7N7NPav{6|r   c           	      X   U R                   R                  5        Vs/ s Hd  nUR                  [        UR                  R                  S5      5      UR                  R                  S5      UR                  UR                  U4PMf     nnUR                  5         U(       d  g [        U5      nU R                  S   R                  S[        R                   SU S35        U R                  [        R                  USS9  / n/ /n/ nSnS	nU H  u  n	  ppUR                  nU	S
:X  a  UR                  X45        M.  [        R                   " U5      nUR#                  5       nUS::  az  US-   S-  S[        U5      S-
  -  :  a?  UR                  / 5        SS [        U5      S-
   nUS-   S-  S[        U5      S-
  -  :  a  M?  US-  nUS   R                  X U 345        M  UR                  X45        M     U R                  S   nU R                  S   nS[$        S[$        S[&        4S jnS[(        R*                  4S jnS[$        4S jnS:S[&        S[(        R*                  4S jjnSnU(       a  UR                  S5        UR                  SUR-                  [        R                  5       S35        U" US S!U5        U" UUU5        U" U[        U5      5        U" UU R.                  S"5        UR                  S#5        UR                  S#5        U[        U5      -  nUS:  Ga#  UR                  S5        UR                  SUR-                  [        R                  5       S$U S35        / S%QnS&nSn[1        US5       Hh  u  nnU(       d  M  S'SUS-
  -   3nU" UUUU   U5        U" UUUU-   5        U S(U S)3nU[        U5      -  nUU[        U5      :X  a  UOS*U S+U S,3-  nMj     U" UU5        [        U5      S-::  a  S.OS/nU" UU R.                  U S0U S135        UR                  S#5        UR                  S#5        UU-  nU(       Ga   S2 nUR                  S5        UR                  SUR-                  [        R                  5       S$U S35        S3R3                  U Vs/ s H  nU" US   5      PM     sn5      R5                  S45      n UR                  S5[6        R8                  " U 5       S635        U" UUU5        U" U[        U5      5        UR                  S75        U" UU R.                  S85        UR                  S95        UR                  S#5        UR                  S#5        U R;                  UR-                  [        R                  5      UU5        g s  snf s  snf );Nr  rM  r0  r  r1  Fr2  r   rX  r   ?      r   LLr   r   rY  rO  rK  r  	constantsc                     SR                  U Vs/ s H  oDS   PM	     sn5      nU R                  U SU SU S35        g s  snf )Nr>  r   z const z[] = {rZ  )r  r  )r  rK  r  r  r  r  s         r   store_array7GlobalState.generate_num_constants.<locals>.store_array	  sE    XXY7YtY78FGGugWTF'&=> 8s   A r_  c                 H    US:  a  SOSnU R                  SU SU S35        g )Nr"  r   r#  r&  r`  ra  r  )r  r_  r)  s      r   generate_forloop_startBGlobalState.generate_num_constants.<locals>.generate_forloop_start	  s*    $'%K5\LGGeL>cU)DEr   rhs_codec                 p    U R                  SU S35        U R                  U R                  SU5      5        g )Nznumbertab[i] = r=  znumbertab[i])r  re  )r  	error_posr  s      r   assign_constant;GlobalState.generate_num_constants.<locals>.assign_constant	  s0    GGohZq12GGA((CDr   start_offsetc           
          [         R                  n[        U5       H'  u  pEUS   nU R                  SU SU SX$-    S35        M)     g )Nr   rX  r  r  r  )r   numbertab_cnamer   r  )rf  r  r  r  r  r  rP  s          r   define_constants<GlobalState.generate_num_constants.<locals>.define_constants	  sP     $*#9#9O!),qTq0A<CSBTTUVW -r   rY  zPyObject **numbertab = r=  c_constantsdoublez"PyFloat_FromDouble(c_constants[i])r  z + )rX  int8_tint16_tint32_tint64_t%scint_constants_z[i - r  z(i < z ? z : %s)r&   PyLong_FromLongPyLong_FromLongLongr  rD  c                 
   U S:  nU(       a  U * n [        5       nU (       a)  U S-  nSU   nUR                  U5        U S-  n U (       a  M)  U(       d  gU(       a  UR                  [        S5      5        UR                  5         U$ )Nr      s    0123456789abcdefghijklmnopqrstuv      0   -)r   re  r   reverse)numberis_negdigitsdigit
digit_chars        r   	to_base325GlobalState.generate_num_constants.<locals>.to_base32L	  sy    %z$WF")/"E.QRW.XJMM*-qLF	 f
 MM#d), r   s   \000r   zconst char* c_constant = "rC  zchar *end_pos;z+PyLong_FromString(c_constant, &end_pos, 32)zc_constant = end_pos + 1;r   )rn  r  r  r   r  lstripr  r3  rh  r  r   r  r+  rP  re  r   str_to_numberrc  r(   r   r  r#  r  r  r   r  r  r
   rH  r  )!r   r  r8  constant_countfloat_constantsint_constants_by_bytesizelarge_constantsint_constant_count
int_suffixr  r   r  r  rP  number_valuerc  r  rf  r  r  r  r  constant_offset	int_typesarray_accessint_constants_seen	byte_sizer  
array_name	read_item	capi_funcr  r  s!                                    r   r  "GlobalState.generate_num_constants  s   //668:8a 99c!''.."56s8KQWWVWVbVbdef8 	 :V

>"((:f6L6L5MQ~N^^`)ab66v7M7M~rw6x%'D!
39/GQ*GGE'!&&':;$2259)446
#%>a/!<U8VYZ8Z2[[188<
 &**M3/H+IA+M%N
 &>a/!<U8VYZ8Z2[[ '!+&-b188%>R\Q]A^9_`#**E+@A% 4:( JJ'(**45	? 	?S 	?T 	?
	F6+<+< 	F	EC 	E	X 	XVEVEV 	X ./GGCLGG-a.P.PQWQgQg.h-iijkl=(ODWoG"1c/&:;At0TUGGCLGGCLs?33O!GGCLGG-a.P.PQWQgQg.h-iilm|l}}~  AGIL45(12KQ(O$	9 .qY]/C.DE
Az9Y+?K )_GY5YZ)l%0B/C1E	"c)n4"!*c2K.L!LI !3 4C	{&I )P #1&89-01J-Kq-P)VkIAt9+Q|nA0NOGGCLGGCL11O& GGCLGG-a.P.PQWQgQg.h-iilm|l}}~  A}}%O!i!o%OPWWX_`HGG01T1TU]1^0__abcWoG"1c/&:;GG$%At0]^GG/0GGCLGGCL""..v/E/EF	_:F &Ps   A+V")V'c                    UR                  S5        UR                  S5        UR                  SU  S35        UR                  SU S35        UR                  S5        UR                  S5        UR                  S	5        UR                  S
5        UR                  S5        UR                  S5        UR                  S5        UR                  S5        UR                  S5        UR                  S
5        UR                  S5        UR                  S5        UR                  S5        UR                  S5        UR                  S5        g )Nz#if CYTHON_IMMORTAL_CONSTANTSrY  zPyObject **table = r=  zfor (Py_ssize_t i=0; i<z; ++i) {-#if CYTHON_COMPILING_IN_CPYTHON_FREETHREADINGz#if PY_VERSION_HEX < 0x030E0000zEif (_Py_IsOwnedByCurrentThread(table[i]) && Py_REFCNT(table[i]) == 1)rF  z5if (PyUnstable_Object_IsUniquelyReferenced(table[i]))rG  z3Py_SET_REFCNT(table[i], _Py_IMMORTAL_REFCNT_LOCAL);r  z5Py_SET_REFCNT(table[i], _Py_IMMORTAL_INITIAL_REFCNT);r  )array_cnamer  r  s      r   r  !GlobalState.immortalize_constantsr	  s   45S*;-q9:.~.>iHIDE 	67\]WLMXSJKSWLMXSSXr   c                     XR                   ;   aZ  U R                   U   n[        UR                  5      [        UR                  5      :X  d   eUR                  UR                  :X  d   egX R                   U'   g)NFT)rd  r(   r   r  )r   rP  r  r   s       r   r  GlobalState.should_declare	  sf    (((((/Euzz?c%**o555::+++*/  'r   c                     UR                  5       n U R                  U   nU$ ! [         aB    [        U R                  5      nU R                  R                  U5        X0R                  U'    U$ f = fr   )get_filenametable_entryrA  rY   r   ra  re  )r   source_descr  rl  s       r   lookup_filenameGlobalState.lookup_filename	  st    335	/''.E
 	  	/**+E%%k2).&		/s   # AA/.A/c                 8    U R                   U   $ ! [         a     Of = fUR                  SSS9nU Vs/ s H0  nSSU;   a"  UR                  SS5      R                  SS	5      OU-   PM2     Os  snf nnU(       d  UR	                  S
5        X@R                   U'   U$ )Nr  r  )r  error_handlingz * rY  r  z.*[inserted by cython to avoid comment closer]/r  z-/[inserted by cython to avoid comment start]*rX  )rb  rY   	get_linesr  re  )r   r  source_filert  Fs        r   commented_file_contents#GlobalState.commented_file_contents	  s    	++K88 		!++WX+V $
 $ 
 D[	 J'I&*, $
 
 !((2,01  -s    
7A-c                     U(       a;  XR                   ;  a+  U R                   R                  U5        UR                  XS9  ggg)z
Adds code to the C file. utility_code should
a) implement __eq__/__hash__ for the purpose of knowing whether the same
   code has already been included
b) implement put_code, which takes a globalstate instance

See UtilityCode.
r  N)rc  rk  r%  )r   r"  r$  s      r   r  GlobalState.use_utility_code	  s?     L0B0BB""<0!!$!8 C<r   c                    Uc  g UR                   (       a  U R                  UR                   5        UR                  (       a  U R                  UR                  5        SSKJn  UR                  UR                  5       HB  n[        US5      (       d  M  UR                  ULd  M'  U R                  UR                  5        MD     g )Nr   r  r  )
r"  r  utility_code_definitionrX  r  get_all_subtypesr   r   r  use_entry_utility_code)r   r  r  tps       r   r  "GlobalState.use_entry_utility_code	  s    =!!%"4"45((!!%"?"?@ --ejj9Br7##(=++BHH5 :r   )ro  rq  rf  rm  rg  rp  ri  rd  rk  ra  rA  re  rr  rb  r  rn  rh  rl  ru  r  rj  rc  r   r  T)rX  rX  )5r  r	  r
  r  r  r{  r  r   r  r  r  r  r  r  r  r  r  r  r  r  r  rN  r  r  r  r  r  r  r  r  r(   r  r  r@  r  r  r  r+  r  r  r  r   rK  r  r  r   r  r  r  r  r  r  r  r  r   r   r1  r1    s   : J*KZM!8/9b<
..!`G
.?1
.9C 9

	!
 &~(Tc:3MjL LD L\?}BSj  :,9
6r   r1  c                 x   ^^ U R                   m[        R                  " T5      mU4S jnU4S jn[        X5      $ )Nc                 (   > T" U R                   5      $ r   )	funcstate)r   attribute_ofs    r   r   !funccontext_property.<locals>.get	  s    DNN++r   c                 4   > [        U R                  TU5        g r   )r   r  )r   r  rK  s     r   r   !funccontext_property.<locals>.set	  s    e,r   )r  r   
attrgetterr   )r&  r   r   r  rK  s      @@r   funccontext_propertyr  	  s1    ==D&&t,L,-Cr   c                       \ rS rSrSS jrSrg)CCodeConfigi	  c                 (    X l         Xl        X0l        g r   )emit_code_commentsr  c_line_in_traceback)r   r  r  r  s       r   r   CCodeConfig.__init__	  s    "4*#6 r   )r  r  r  N)TTT)r  r	  r
  r  r   r  r  r   r   r  r  	  s    
7r   r  c                   T   \ rS rSrSr\R                  " S S9SS j5       rS rS r	S r
S	 rS
 r\R                  S 5       rS rS rS rS r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       rSS jrSS jrS rS rS r S r!S r"S r#S  r$S! r%S" r&S# r'S$ r(S% r)SS& jr*SS' jr+S( r,S) r-SS* jr.S+ r/S, r0SS- jr1S. r2S/ r3S0 r4S1 r5SS2 jr6S3 r7\8S4 5       r9\8S5 5       r:S6 r;S7 r<SS8 jr=SS9 jr>\R                  S: 5       r?\R                  S; 5       r@\R                  S< 5       rAS= rB\R                  S> 5       rC\R                  S? 5       rDS@ rESA\F4SB jrG\R                  SC 5       rH\R                  SD 5       rI\R                  SE 5       rJ\R                  SF 5       rK\R                  SG 5       rLSH rMSI rNSJ rO  SSK jrPSL\Q4SM jrRSN rSSO rTSP rU\V4SQ jrWSR rXSS rYST rZSU r[SV r\SW r]SSX jr^SSY jr_SSZ jr`SS[ jraSS\ jrbSS] jrcS^ rdS_ reS` rfSa rgSb rhSc riSd rjSe rkSf rlSg rmSh rnSi roSj rpSk rqSl rrSm rsSSn jrtSo ruSp rvSq rwSSr jrxSSs jrySSt jrzSu r{Sv r|SSw jr}SSx jr~Sy rSz rSS{ jrSS| jrS} rS~ rSS jrSS jrSS jrS rS rS rS rS rS rSS jrSS jrSS jrSS jrS rS rSS jrSS jrSS jrSS jrS rS rSS jrS rS rSS jrS rSS jr\FGRA                  SS5      4S jrS rS rS rSrg)r  i	  ar  
Utility class to output C code.

When creating an insertion point one must care about the state that is
kept:
- formatting state (level, bol) is cloned and used in insertion points
  as well
- labels, temps, exc_vars: One must construct a scope in which these can
  exist by calling enter_cfunc_scope/exit_cfunc_scope (these are for
  sanity checking and forward compatibility). Created insertion points
  looses this scope and cannot access it.
- marker: Not copied to insertion point
- filename_table, filename_list, input_file_contents: All codewriters
  coming from the same root share the same instances simultaneously.
create_fromNc                    Uc
  [        5       nX l        S U l        S U l        / U l        S U l        S U l        S U l        SU l        SU l	        SU l
        Ub  U R                  UR                  5        UR
                  U l        U(       a3  UR                  U l        UR                  U l
        UR                  U l	        UR                  U l        UR                  U l        g g )Nr   r   )r   bufferlast_poslast_marked_pospyclass_stackr  r#  rf  r$   
call_levelbolrs  )r   r  r  copy_formattings       r   r   CCodeWriter.__init__
  s    >LN6#
"!!+"9"9:(22DN(..
&??"-"8"8'00DM#.#>#>D  #r   c                     [        XU5      nU$ r   r  )r   r  r  r  r  s        r   
create_newCCodeWriter.create_new'
  s     [/Br   c                 P    U R                   b   eXl         UR                  U l        g r   )r#  rf  )r   global_states     r   rs  CCodeWriter.set_global_state-
  s(    '''''33r   c                 :    U R                   R                  U5        g r   )r  copyto)r   r  s     r   r  CCodeWriter.copyto2
  s    1r   c                 6    U R                   R                  5       $ r   )r  getvaluer   s    r   r
  CCodeWriter.getvalue5
  s    {{##%%r   c                 V    SU;   a  U R                  U5        g U R                  U5        g Nr?  )_write_lines_write_to_bufferr   r  s     r   r  CCodeWriter.write8
  s%    19a !!!$r   c                     U R                   (       a  U R                   S S OSnU R                  R                  R                  U/UR	                  S5      -  5        U R                  U5        g )Nr   Nr   r?  )r  r  markersr  r  r  )r   r  filename_lines      r   r  CCodeWriter._write_lines>
  sU    
 594H4H,,Ra0i""M?QWWT]#BCa r   c                 :    U R                   R                  U5        g r   )r  r  r  s     r   r  CCodeWriter._write_to_bufferH
  s    !r   c                 V    U R                  X R                  R                  5       SS9nU$ )NT)r  r  r  )r  r  r|  r;  s     r   r|  CCodeWriter.insertion_pointK
  s'    D9T9T9Vhlmr   c                     [        U S9$ )zi
Creates a new CCodeWriter connected to the same global state, which
can later be inserted using insert.
r  r   r   s    r   
new_writerCCodeWriter.new_writerO
  s    
 t,,r   c                     UR                   U R                   L d   eU R                  R                  UR                  5        g)z
Inserts the contents of another code writer (created with
the same global state) in the current location.

It is ok to write to the inserted writer also after insertion.
N)r#  r  insert)r   r  s     r   r  CCodeWriter.insertV
  s4     !!T%5%55556==)r   c                     g r   r  r   s    r   r}  CCodeWriter.label_countera
  s    !r   c                     g r   r  r   s    r   r  CCodeWriter.return_labelc
       r   c                     g r   r  r   s    r   r|  CCodeWriter.error_labele
      r   c                     g r   r  r   s    r   r~  CCodeWriter.labels_usedg
  r(  r   c                     g r   r  r   s    r   r  CCodeWriter.continue_labeli
  s    "r   c                     g r   r  r   s    r   r  CCodeWriter.break_labelk
  r(  r   c                     g r   r  r   s    r   return_from_error_cleanup_label+CCodeWriter.return_from_error_cleanup_labelm
  s    /3r   c                     g r   r  r   s    r   r  CCodeWriter.yield_labelso
  r%  r   c              #   
  #    [        X5       Hp  u  pgU R                  U5      (       d  M  U(       a  U R                  U5        SnUb  U R                  XES9  U R	                  U5        Xg4v   U R                  U5        Mr     g7f)a  
Helper for generating multiple label interceptor code blocks.

@param new_labels: the new labels that should be intercepted
@param orig_labels: the original labels that we should dispatch to after the interception
@param skip_to_label: a label to skip to before starting the code blocks
@param pos: the node position to mark for each interceptor block
@param trace: add a trace line for the pos marker or not
N)trace)r   r  put_gotomark_posr  )r   r  orig_labelsskip_to_labelr  r5  r  
orig_labels           r   label_interceptorCCodeWriter.label_interceptorr
  ss      "%Z!=E??5))m, $c/NN5!%%MM*% ">s   BBc                 8    U R                   R                  U5      $ r   )r  r  r   rK  s     r   r  CCodeWriter.new_label
  s    dnn.F.Ft.L'Lr   c                 4    U R                   R                  " U6 $ r   )r  r  r   rE  s     r   r  CCodeWriter.new_error_label
      dnn.L.Ld.S'Sr   c                 4    U R                   R                  " U6 $ r   )r  r  rA  s     r   r  CCodeWriter.new_yield_label
  rC  r   c                 6    U R                   R                  5       $ r   )r  r  r   s    r   r  CCodeWriter.get_loop_labels
  s    dnn.L.L.N'Nr   c                 8    U R                   R                  U5      $ r   )r  r  r  s     r   r  CCodeWriter.set_loop_labels
  s    dnn.L.LV.T'Tr   c                 4    U R                   R                  " U6 $ r   )r  r  rA  s     r   r  CCodeWriter.new_loop_labels
  rC  r   c                 6    U R                   R                  5       $ r   )r  r  r   s    r   r  CCodeWriter.get_all_labels
      dnn.K.K.M'Mr   c                 8    U R                   R                  U5      $ r   )r  r  r  s     r   r  CCodeWriter.set_all_labels
  s    dnn.K.KF.S'Sr   c                 6    U R                   R                  5       $ r   )r  r  r   s    r   r  CCodeWriter.all_new_labels
  rN  r   c                 8    U R                   R                  U5      $ r   )r  r  r  s     r   r  CCodeWriter.use_label
  s    dnn.F.Fs.K'Kr   c                 8    U R                   R                  U5      $ r   )r  r  r  s     r   r  CCodeWriter.label_used
  s    dnn.G.G.L'Lr   c                      [        XS9U l        g )N)r  )rx  r  r  s     r   enter_cfunc_scopeCCodeWriter.enter_cfunc_scope
  s    &t9r   c                 b    U R                   c  g U R                   R                  5         S U l         g r   )r  r  r   s    r   r  CCodeWriter.exit_cfunc_scope
  s&    >>!$$&r   c                     U R                   R                  S   nUR                  SU S35        U R                  U5        U R                  S5        U R                  SU S35        U(       a  U R	                  5         gg)z
Init code helper function to start a cfunc scope and generate
the prototype and function header ("static SIG {") of the function.
rT  zstatic CYTHON_SMALL_CODE ; /*proto*/rX  r   {N)r#  rh  r  rX  put_declare_refcount_context)r   	signaturer  ry  rE  s        r   r}  CCodeWriter.start_initcfunc
  ss    
   &&'>?/	{+FGu%

2

WYKs+,--/ r   c                 @   UR                  U5      nSUR                  U5       SU S3nU(       a1  U R                  S   R                  UR	                  SS5      S-   5        U(       a  U R                  U5        U R                  S5        U R                  US-   5        g )	Nr  r  rD  rK  CYTHON_UNUSED rX  r]  r^  )mangle_internalr4  r#  r  r  rX  )	r   class_scopereturn_typec_slot_nameargs_signatureneeds_funcstateneeds_prototypeslotfunc_cnamedeclarations	            r   start_slotfuncCCodeWriter.start_slotfunc
  s    $44[A < <^ LMQ~N^^_`W%++K,?,?@PRT,UXe,ef"";/

2

;%&r   c                 j    U R                  U R                  R                  X5      R                  5      $ r   )r  r#  r  rP  )r   r  r  s      r   
get_py_intCCodeWriter.get_py_int
  s/    ((**9?EE
 	
r   c                 j    U R                  U R                  R                  X5      R                  5      $ r   )r  r#  r  rP  )r   r  r  s      r   get_py_floatCCodeWriter.get_py_float
  s/    ((,,YCII
 	
r   c                 V    U R                  U R                  R                  X5      5      $ r   )r  r#  r  )r   r  r  s      r   r  CCodeWriter.get_py_const
  s)    (())&<
 	
r   c                 L    U R                   R                  U5      R                  $ r   )r#  r  rP  r  s     r   r  CCodeWriter.get_string_const
  s    006<<<r   c                 8    U R                   R                  U5      $ r   )r#  r  r  s     r   r  #CCodeWriter.get_pyunicode_ptr_const
  s    77==r   c                 n    U R                   R                  X5      R                  nU R                  U5      $ r   )r#  rN  rP  r  )r   r  rM  rP  s       r   rN  CCodeWriter.get_py_string_const
  s4      44#e 	((//r   c                 V    U R                  U R                  R                  U5      5      $ r   )r  r#  r  )r   r  s     r   r   CCodeWriter.get_py_codeobj_const
  s$    (()9)9)N)Nt)TUUr   c                 j    U R                  U R                  R                  U5      R                  5      $ r   )r  r#  r  rP  r   r   s     r   r  &CCodeWriter.get_argument_default_const
  s+    (()9)9)T)TUY)Z)`)`aar   c                 $    U R                  U5      $ r   r  r  s     r   r2  CCodeWriter.intern
  s    ''--r   c                 "    U R                  USS9$ r  r  r  s     r   intern_identifierCCodeWriter.intern_identifier
  r  r   c                 8    U R                   R                  U5      $ r   )r#  r  r  s     r   r  'CCodeWriter.get_cached_constants_writer
  s    ;;FCCr   c                     U R                   R                  c  U R                  U5      $ U R                   R                  R                  U5      $ r   )r  r  r  r  r   rP  s     r   r   CCodeWriter.name_in_module_state
  s@    >>' 88??~~##88??r   c                 ,    [         R                   SU  3$ rY  )r   r  r:  s    r   r  ,CCodeWriter.name_in_main_c_code_module_state
  s    
 //05'::r   c                 ,    [         R                   SU  3$ rY  )r   rA  r:  s    r   name_in_slot_module_state%CCodeWriter.name_in_slot_module_state
  s     001E7;;r   c                 r    UR                   (       a  UR                  $ U R                  UR                  5      $ r   )is_py_class_scopenamespace_cnamer  r  s     r   namespace_cname_in_module_state+CCodeWriter.namespace_cname_in_module_state
  s.    ""(((,,U-B-BCCr   c                 r    UR                   (       a  U R                  UR                  5      $ UR                  $ r   )is_extension_typer  typeptr_cnamer  s     r   typeptr_cname_in_module_state)CCodeWriter.typeptr_cname_in_module_state  s.    !!,,T-?-?@@%%%r   c                    U R                   (       a!  U R                  (       a  U R                  5         U R                  R                  (       aF  U R
                  (       a5  U R
                  u  p4nU R                  SU SUR                  5        S35        U(       a*  U(       a  U R                  U5        OU R                  U5        U R                  S5        SU l        g )Nz
#line z "r3  r?  r   )
r  r  emit_markerrf  r  r  r  get_escaped_descriptionput_safer  )r   r  rE  r  rt  r   s         r   r  CCodeWriter.putln
  s    ==TXX))d.B.B#'#7#7 Kqb1T1T1V0WWZ[\d#$r   c                 l    Uc  g U R                   (       a  U R                   S S US S :X  a  g X4U l        g )Nr   )r  r  r   r  r5  s      r   r7  CCodeWriter.mark_pos  s9    ;D$8$8!$<BQ$Gr   c                 $   U R                   u  pXl        S U l         U R                  S5        U R                  R                  (       a0  U R                  5         U R                  U R                  U5      5        U(       a  U R                  U5        g g r  )r  r  r  rf  r  indent_build_markerwrite_trace_liner  s      r   r  CCodeWriter.emit_marker  so    ]]
"$..KKMd0056!!#& r   c                 t   U R                   (       a  U R                   R                  (       a  U R                  R                  S   (       al  U R	                  5         U R                  SUS   S SU R                  U5      S SU R                   R                  (       + S SU R                  U5       S3	5        g g g g )N	linetracez__Pyx_TraceLine(r   r   r>  z)
)	r  r  r#  r  r  r  pos_to_offsetr  r  r   r  s     r   r  CCodeWriter.write_trace_line+  s    >>dnn664;K;K;V;VWb;cKKM"3q6!*Ad.@.@.Ea-HdnnNfNfJfghIiijkokzkz{~k  kA  AD  EF <d6>r   c                    Uu  p#n[        U[        5      (       d   eU R                  R                  U5      nU[	        SUS-
  5      U nUS==   S-  ss'   XeX3S-    -  nSR                  U5      nSUR                  5        SUS	 SU S
3$ )Nr   r&   r   z             # <<<<<<<<<<<<<<r   r?  z/* "z":r   z
*/
)r   r   r#  r  r   r  r  )r   r  r  rt  colcontentsrL  r  s           r   r  CCodeWriter._build_marker2  s    !$3+'78888##;;KHQQ-b	44	$Av&&yyk99;<BtAhbfUUr   c                 4    U R                  U5        SU l        g r  )r  r  r   r  s     r   r  CCodeWriter.put_safe=  s    

4r   c                 "   U R                   R                  nU(       GaL  [        U5      S:  Ga<  [        R                  " UR                  S5      5      R                  5       nU SU S3n[        R                  R                  X55      n[        R                  R                  U5      (       d  U S[        R                  " 5        3nSn [        R                  " U5       n	U	R                  U5        S S S 5        [        R                   " Xv5        SnU(       d:  [        R                  R                  U5      (       a  [        R&                  " U5        UR)                  SS	5      n
S
U
 S3nU R+                  U5        g ! , (       d  f       N= f! ["        [$        4 a(    [        R                  R                  U5      (       d  e  Nf = f! U(       d<  [        R                  R                  U5      (       a  [        R&                  " U5        f f f = f)Ni   r&  r   z.hz.tmpFTr2  rY  z
#include "r3  )r#  rg  r   hashlibsha256rb  	hexdigestr   r  r  existsgetpidr   open_new_filer  shutilmoverM   rf   unlinkr  r  )r   r  rK  include_dirr   include_filer  tmp_pathdoner  c_paths              r   r  CCodeWriter.put_or_includeB  s   &&AA3t9t+>>$++f"56@@BD"V1TF"-L77<<:D77>>$''"V4		}5,,,X6! 7KK/D  BGGNN8$<$<		(+ \\$,Fxs+DD!! 76 (9  77>>$// 0  BGGNN8$<$<		(+ %=4s=   
F  E=2 F =
FF 5GG	 GG	 	AHc                     U R                   (       a1  SU;   a+  SU R                   -  R                  UR                  SS95      nU R                  U5        g )Nr?  r   Tkeepends)r$   r  r6  r  r  s     r   r  CCodeWriter.put_multilines_  s@     ::$$,4::%++DOOTO,JKDr   c                    SnSU;   a  UR                  S5      OSnSU;   aU  X1R                  S5      -  nUS:  a  U =R                  U-  sl        O&US:X  a   US   S:X  a  SnU =R                  S-  sl        U R                  (       a  U R                  5         U R	                  U5        SU l        US:  a  U =R                  U-  sl        g U(       a  U =R                  S-  sl        g g )NFrY  r   r  Tr   )r  r$   r  r  r  )r   r  
fix_indentdls       r   r  CCodeWriter.putg  s    
36$;

3A$;**S/!BAv

b 
qT!W^!


a
88KKM

46JJ"JJJ!OJ r   rJ  c                 Z   UR                   (       a   UR                  5       eUR                  X R                  S5        UR	                  U R                  5        UR
                  (       aA  [        R                  (       a+  UR                  U R                  S   U R                  S5        g g g )NrF  r  r  )rE  rK  r  r#  r  r  r	   r  )r   rJ  s     r   put_code_hereCCodeWriter.put_code_here{  s     ==.',,. !!$(8(8&A&&t'7'78??w<<%%  !23T5E5EyR  =?r   c                 .    U =R                   S-  sl         g Nr   r#   r   s    r   increase_indentCCodeWriter.increase_indent      

a
r   c                 .    U =R                   S-  sl         g r  r#   r   s    r   decrease_indentCCodeWriter.decrease_indent  r  r   c                 F    U R                  S5        U R                  5         g )NrY  )r  r  r   s    r   begin_blockCCodeWriter.begin_block  s    

3r   c                 F    U R                  5         U R                  S5        g )Nr  )r  r  r   s    r   	end_blockCCodeWriter.end_block  s    

3r   c                 @    U R                  SU R                  -  5        g )Nr   )r  r$   r   s    r   r  CCodeWriter.indent  s    dTZZ/0r   c                 *    S[        U5      S-   S S -  $ )Nz0x%02X%02X%02X%02X)r   r   r   r      )r   )r   	pyversions     r   get_py_version_hexCCodeWriter.get_py_version_hex  s    #uY'7)'CRa&HHHr   c                 `    XR                   R                  ;   a  U R                  SU-  5        g g )Nz%s:;)r  r~  r  r  s     r   r  CCodeWriter.put_label  s'    ..,,,JJv|$ -r   c                 b    U R                   R                  U5        U R                  SU-  5        g )Ngoto %s;)r  r  r  r  s     r   r6  CCodeWriter.put_goto  s%      %

:#$r   c                 >   UR                   S:X  a  U(       d  UR                  (       d  g UR                   S:X  a  UR                  (       d  g UR                  (       d  U R	                  S5        U(       a  U R	                  SU-  5        UR
                  (       a4  U R	                  UR                  R                  UR                  US95        O3U R	                  UR                  R                  UR                  US95        UR                  b8  U R                  SUR                  R                  UR                  5      -  5        O,UR                  R                  (       a  U R	                  S5        U R                  S5        U R                  R!                  U5        g )Nprivaterc  %s )dll_linkagez = %sz = NULLr=  )
visibilitydefined_in_pxdr  cf_usedr  is_cpp_optionalr   cpp_optional_declaration_coderP  r4  r  r  literal_codeis_pyobjectr  r#  r  )r   r  storage_classr  
definitions        r   put_var_declarationCCodeWriter.put_var_declaration  s%    y(*@T@Ty(}}HH%&HHU]*+  HHUZZ== > 6 7 HHUZZ00 1 6 7::!MM'EJJ$;$;EJJ$GGHZZ##HHY

3//6r   func_contextc                 t   UR                    GH   u  p#pEUR                  (       aA  UR                  (       d0  UR                  R                  S   (       a  UR                  U5      nOUR                  U5      nUR                  (       a  U R                  SU-  5        M  UR                  (       a4  U R                  U< SUR                  UR                  5      < S35        M  U R                  U=(       a    S=(       d    S< U< S35        GM     UR                  (       a  U R                  R                  (       a  SnOSnU R                  U< S[        R                   < S	35        U R                  U< S
[        R"                  < S35        U R                  U< S[        R$                  < S	35        g g )Nr  z
%s = NULL; = r=  r  rX  rc  zint z = 0;zconst char *z = NULL;)r  r  r  r  r  r  r4  r  r  r6  r  default_valuer  r  r  r   lineno_cnamefilename_cnameclineno_cname)r   r  rK  r   r  r  r>  unuseds           r   put_temp_declarations!CCodeWriter.put_temp_declarations  s,   .:.J.J*D
  )?)?LDVDVDaDabnDo99$?,,T2

<$./((

t/@/@ASAS/TUV

f&:&@b&@$GH /K 66~~22)JJ&&2E2EFGJJVV=R=RSTJJ&&2F2FGH 7r   c                 d    U R                  [        R                  5        U R                  S5        g r  )r  r   GENERATED_BY_MARKERr   s    r   put_generated_byCCodeWriter.put_generated_by  s    

5,,-

2r   c                 T    U R                  SU-  5        U R                  SU-  5        g )Nz
#ifndef %sz
#define %sr  )r   rs  s     r   put_h_guardCCodeWriter.put_h_guard  s$    

<%'(

<%'(r   c                 :    [         R                  (       a  SU-  $ U$ )Nzunlikely(%s))r	   gcc_branch_hintsr   conds     r   unlikelyCCodeWriter.unlikely  s    ##!D((Kr   c           
      p    U(       d  gSSR                  U Vs/ s H
  o2" X35      PM     sn5      -  $ s  snf )NrX  r  r  )r  )r   	modifiersmapperru  s       r   build_function_modifiers$CCodeWriter.build_function_modifiers  s2    sxxi @ii @AAA @s   3
c                     UR                   nUR                  (       d  UR                   R                  5       (       a  UR                   R                  (       a  SUR                  -   $ UR                  $ )Nz(PyObject *))r   is_self_argis_completer  rP  )r   r  r   s      r   entry_as_pyobjectCCodeWriter.entry_as_pyobject  sL    zz!!%***@*@*B*B:://!EKK//;;r   c                 $    SSK JnJn  U" X2U5      $ )Nr   py_object_typetypecast)r  r  r  )r   rP  r   r  r  s        r   as_pyobjectCCodeWriter.as_pyobject  s    8e44r   c                 &    UR                  X5        g r   )generate_gotrefr  s      r   
put_gotrefCCodeWriter.put_gotref  s    T)r   c                 &    UR                  X5        g r   )generate_giverefr  s      r   put_giverefCCodeWriter.put_giveref      d*r   c                 &    UR                  X5        g r   )generate_xgiverefr  s      r   put_xgiverefCCodeWriter.put_xgiveref  s    t+r   c                 &    UR                  X5        g r   )generate_xgotrefr  s      r   put_xgotrefCCodeWriter.put_xgotref  r'  r   c                 $    UR                  XUS9  g N)r/  )generate_increfr   rP  r   r/  s       r   
put_increfCCodeWriter.put_incref  s     	T6r   c                 $    UR                  XUS9  g r1  )generate_xincrefr3  s       r   put_xincrefCCodeWriter.put_xincref  s    d7r   c                 $    UR                  XX4S9  g N)r/  have_gil)generate_decrefr   rP  r   r/  r<  s        r   
put_decrefCCodeWriter.put_decref  s    TIr   c                 $    UR                  XX4S9  g r;  )generate_xdecrefr>  s        r   put_xdecrefCCodeWriter.put_xdecref  s    dJr   c                 &    UR                  XUXES9  g N)r.  r/  r<  )generate_decref_clearr   rP  r   r.  r/  r<  s         r   put_decref_clearCCodeWriter.put_decref_clear  s    ""4DW$) 	# 	>r   c                 &    UR                  XUXES9  g rF  )generate_xdecref_clearrH  s         r   r5  CCodeWriter.put_xdecref_clear  s    ##DEX$) 	$ 	>r   c                 (    UR                  XU5        g r   )generate_decref_setr   rP  r   	rhs_cnames       r   put_decref_setCCodeWriter.put_decref_set  s      i8r   c                 (    UR                  XU5        g r   )generate_xdecref_setrP  s       r   put_xdecref_setCCodeWriter.put_xdecref_set  s    !!$y9r   c                 $    UR                  XUS9  g N)r<  )generate_incref_memoryviewslice)r   slice_cnamer   r<  s       r   put_incref_memoryviewslice&CCodeWriter.put_incref_memoryviewslice"  s    ,,T,Rr   c                 N    U R                  UR                  UR                  US9  g rY  )r\  rP  r   )r   r  r<  s      r   put_var_incref_memoryviewslice*CCodeWriter.put_var_incref_memoryviewslice&  s    ''UZZ('Sr   c                 P    U R                  UR                  UR                  5        g r   )r!  rP  r   r  s     r   put_var_gotrefCCodeWriter.put_var_gotref)  s    UZZ0r   c                 P    U R                  UR                  UR                  5        g r   )r%  rP  r   r  s     r   put_var_giverefCCodeWriter.put_var_giveref,      ejj1r   c                 P    U R                  UR                  UR                  5        g r   )r.  rP  r   r  s     r   put_var_xgotrefCCodeWriter.put_var_xgotref/  rg  r   c                 P    U R                  UR                  UR                  5        g r   )r*  rP  r   r  s     r   put_var_xgiverefCCodeWriter.put_var_xgiveref2  s    %++uzz2r   c                 T    U R                   " UR                  UR                  40 UD6  g r   )r4  rP  r   r   r  kwdss      r   put_var_increfCCodeWriter.put_var_incref5      UZZ848r   c                 T    U R                   " UR                  UR                  40 UD6  g r   )r8  rP  r   ro  s      r   put_var_xincrefCCodeWriter.put_var_xincref8      ejj9D9r   c                 T    U R                   " UR                  UR                  40 UD6  g r   )r?  rP  r   ro  s      r   put_var_decrefCCodeWriter.put_var_decref;  rs  r   c                 T    U R                   " UR                  UR                  40 UD6  g r   )rC  rP  r   ro  s      r   put_var_xdecrefCCodeWriter.put_var_xdecref>  rw  r   c                 l    U R                   " UR                  UR                  4SUR                  0UD6  g Nr.  )rI  rP  r   
in_closurero  s      r   put_var_decref_clear CCodeWriter.put_var_decref_clearA  s+    ekk5::d5K[K[d_cdr   c                 V    U R                   " UR                  UR                  U40 UD6  g r   )rR  rP  r   r   r  rQ  rp  s       r   put_var_decref_setCCodeWriter.put_var_decref_setD  s!    EKKYG$Gr   c                 V    U R                   " UR                  UR                  U40 UD6  g r   )rV  rP  r   r  s       r   put_var_xdecref_setCCodeWriter.put_var_xdecref_setG  s!    U[[%**iH4Hr   c                 l    U R                   " UR                  UR                  4SUR                  0UD6  g r  )r5  rP  r   r  ro  s      r   put_var_xdecref_clear!CCodeWriter.put_var_xdecref_clearJ  s+    u{{EJJeEL\L\e`der   c                     U HR  nU(       a  UR                   (       d  M  UR                  (       a  U R                  U5        MA  U R                  U5        MT     g r   )r  xdecref_cleanupr|  ry  )r   entries	used_onlyr  s       r   put_var_decrefsCCodeWriter.put_var_decrefsM  s<    E


((((/''. r   c                 8    U H  nU R                  U5        M     g r   )r|  r   r  r  s      r   put_var_xdecrefsCCodeWriter.put_var_xdecrefsU  s    E  ' r   c                 8    U H  nU R                  U5        M     g r   )r  r  s      r   put_var_xdecrefs_clear"CCodeWriter.put_var_xdecrefs_clearY  s    E&&u- r   c                 R   U R                   R                  R                  (       dJ  U R                   R                  R                  (       d%  U R                   R                  R                  (       a8  U R                  S5        U R                  SU S35        U R                  S5        g g )Nz?#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000z)PyUnstable_Object_EnableDeferredRefcount(rx  rG  )r  r  is_module_scopeis_c_class_scoper  r  r  s     r   put_make_object_deferred$CCodeWriter.put_make_object_deferred]  sq     NN  00$$55$$66JJXYJJB5'LMJJx  7r   c                     SSK JnJn  U" X$S5      nU(       a  U R                  U< SU< S35        g U R                  U< SU< S35        g )Nr   r  Py_Noner  z; __Pyx_INCREF(Py_None);z; Py_INCREF(Py_None);)r  r  r  r  )r   rP  r   r/  r  r  py_nones          r   put_init_to_py_noneCCodeWriter.put_init_to_py_noneh  s6    84;JJE7KLJJHIr   c                     X!R                   -  nU R                  XAR                  U5        UR                  (       a  U R	                  S5        g g )Nr  )rP  r  r   r  r%  )r   r  ra  r/  r  s        r   put_init_var_to_py_none#CCodeWriter.put_init_var_to_py_nonep  s@    ++% 	  zz59Y' r   c                 F   SnUR                   (       d  UR                  S:X  at  SSKJn  UR                  [        ;  aZ  UR                  UR                  5      (       a  SnO7UR                  S:X  a  U R                  R                  S   (       d  OU(       a  g UR                  R                  5       nU(       d  g UR                   (       a  UWR                  /-  nU(       a  UR                  U5      OUR                  nUR                  R                  5       n	U	S:w  a
  S	U	< S
U< 3nUR                  R                  5       n
U(       af  WR                  U R                  R                  5      R!                  UR                  5      nUR#                  5       nU(       a  U R%                  U5        U R%                  SU
< SU< SSR'                  U5      < SUR(                  (       a  UR*                  OS< SU< 3
5        U(       a  W(       a  U R%                  S5        g g g )NF__getattribute__r   )	TypeSlotsT__getattr__fast_getattrPyCFunctionz(void(*)(void))(rD  rY  z, (PyCFunction)r  |0r  rG  )
is_specialrK  rX  r  special_py_methodsis_binop_number_slotr#  r  r`  method_flagsmethod_coexistput_pymethoddef_wrapper
func_cnamemethod_function_typeas_c_string_literalget_slot_tableget_slot_by_method_namepreprocessor_guard_coder  r  doc	doc_cname)r   r  term
allow_skipwrapper_code_writeris_number_slotr  r  func_ptrcast
entry_nameslotpreproc_guards                r   put_pymethoddefCCodeWriter.put_pymethoddefx  s   uzz-??#zz!3311%**== &*NZZ=09I9I9T9TUc9d  335Y5566LI\&>>uEbgbrbr335= 26AHZZ335
 ++D,<,<,G,GH``afakaklD 88:M

=)

&#(99#5	 mJJx  ,>r   c                    UR                   nUR                  (       a  UR                  R                  5       =(       d    / nSSKJn  XC;   a  [        R                  U-   nU R                  SU-  5        SUR                   -  nUR                  S:X  a7  U R                  SU-  5        U R                  S5        U R                  S5        OU R                  S	U-  5        U R                  S
5        U$ )Nr   )method_noargszBstatic PyObject *%s(PyObject *self, CYTHON_UNUSED PyObject *arg) {z%s(self)r   zPyObject *res = %s;zFif (!res && !PyErr_Occurred()) { PyErr_SetNone(PyExc_StopIteration); }zreturn res;z
return %s;r  )
r  r  r`  r  r  r  r   method_wrapper_prefixr  rK  )r   r  r  r  r  	func_calls         r   r  #CCodeWriter.put_pymethoddef_wrapper  s    %%
 ??779?RL0,#99JF


_bllm&)9)99	::+JJ4y@AJJghJJ}-JJ|i78

3r   c                     U R                   R                  S   (       a0  U R                   R                  [        R	                  SS5      5        g U R                   R                  [        R	                  SS5      5        g )Nfast_gilFastGilr  	NoFastGil)r#  r  r  r  r  r   s    r   use_fast_gil_utility_code%CCodeWriter.use_fast_gil_utility_code  sZ    &&z2--k.E.EiQd.ef--k.E.EkSf.ghr   c                 Z   U R                   R                  S   S:w  a  SSKJn  U" U R                  SS5        U R                   R                  [        R                  SS5      5        U R                  5         U(       d  S	nU(       a  U R                  S
5        U R                  SU-  5        g)z
Acquire the GIL. The generated code is safe even when no PyThreadState
has been allocated for this thread (for threads not initialized by
using the Python API). Additionally, the code generated by this method
may be called recursively.
subinterpreters_compatiblenor   )warningzTAcquiring the GIL is currently very unlikely to work correctly with subinterpreters.r   ForceInitThreadsr  __pyx_gilstate_savezPyGILState_STATE z%s = __Pyx_PyGILState_Ensure();N)r#  r  Errorsr  r  r  r  r  r  r  r  )r   declare_gilstatevariabler  s       r   put_ensure_gilCCodeWriter.put_ensure_gil  s     &&'CDL'$$f
 	))##$68KL	N&&(,H,-

4x?@r   c                 ^    U R                  5         U(       d  SnU R                  SU-  5        g)z4
Releases the GIL, corresponds to `put_ensure_gil`.
r  z__Pyx_PyGILState_Release(%s);N)r  r  )r   r  s     r   put_release_ensured_gil#CCodeWriter.put_release_ensured_gil  s*     	&&(,H

2X=>r   c                     U R                  S5        U R                  S[        R                   S35        U R                  S5        g )Nr  zPyMutex_Lock(&rx  rG  r  r   parallel_freethreading_mutexr   s    r   put_acquire_freethreading_lock*CCodeWriter.put_acquire_freethreading_lock  s7    

BC

^F$G$G#HKL

8r   c                     U R                  S5        U R                  S[        R                   S35        U R                  S5        g )Nr  zPyMutex_Unlock(&rx  rG  r  r   s    r   put_release_freethreading_lock*CCodeWriter.put_release_freethreading_lock  s8    

BC

%f&I&I%J"MN

8r   c                    U R                  5         U R                  S5        U(       a  U R                  SU-  5        U(       a2  SnU R                  R                  [        R                  SS5      5        OSnU R                  U S35        g)	zg
Acquire the GIL. The thread's thread state must have been initialized
by a previous `put_release_gil`
z__Pyx_FastGIL_Forget();z_save = %s;__Pyx_RestoreUnknownThreadReleaseUnknownGilr  PyEval_RestoreThreadz(_save);N)r  r  r#  r  r  r  )r   r  unknown_gil_stater  s       r   put_acquire_gilCCodeWriter.put_acquire_gil  sz    
 	&&(

,-JJ}x/04I--''(;=PQS /I

i[)*r   c                 L   U R                  5         U(       a4  U R                  R                  [        R	                  SS5      5        SnSnOSnSnU R                  U S35        U R                  SU S	35        U(       a  U R                  S
U-  5        U R                  S5        g)z2Release the GIL, corresponds to `put_acquire_gil`.r  r  __Pyx_SaveUnknownThread__Pyx_UnknownThreadStatePyEval_SaveThreadzPyThreadState *z _save;z_save = z();z%s = _save;z__Pyx_FastGIL_Remember();N)r  r#  r  r  r  r  )r   r  r  r  result_types        r   put_release_gilCCodeWriter.put_release_gil   s    &&(--''(;=PQS1I4K+I+K

k]'*+

Xi[,-JJ}x/0

./r   c                 &    U R                  S5        g )Nz%PyGILState_STATE __pyx_gilstate_save;r  r   s    r   r  CCodeWriter.declare_gilstate  s    

:;r   c                 R    U R                  SU< SU R                  U5      < 35      $ )Nif (z < (0)) )r  r  )r   r  r  s      r   put_error_if_negCCodeWriter.put_error_if_neg  s!     zzts7KLMMr   c                    U(       a  SOSnUR                   (       a  SnOUR                  R                  (       a  UR                  (       a  SnO]UR                  R                  (       a@  UR                  (       a/  UR
                  (       d  UR                  R                  (       a  SnOSnU R                  R                  [        R                  U U 3S5      5        U(       d%  UR                  R                  UR                  5      nU R                  SU< S	S
U U 3< SUR                  R!                  5       < SU R#                  U5      < S3	5        g )NNogilrX  RaiseClosureNameErrorRaiseCppGlobalNameErrorRaiseCppAttributeErrorRaiseUnboundLocalErrorr  zif (unlikely(!z)) { r  r  z); r_  )from_closurer   r  
is_cglobalis_variable	is_memberr  r  r#  r  r  r  check_for_null_coderP  r  rK  r  r  )r   r  r  in_nogil_contextunbound_check_code	nogil_tagr&  s          r   put_error_if_unbound CCodeWriter.put_error_if_unbound  s    /GR	*DZZ$$)9)9,DZZ$$):):5??W\WbWbWsWs ,D+D))''4&(<>PQ	S "!&!?!?!L

 2"(yk : %

 > > @ $ 4	6 	7r   c                     SU R                   l        U(       a  SU R                   l        SU R                  US   5      < SUS   < S3$ )NTz__PYX_MARK_ERR_POS(r   r  r   rD  )r  r  r  r  )r   r  r  s      r   set_error_infoCCodeWriter.set_error_info3  sA    8<526DNN/  Q(F 	r   c                    U R                   R                  nU R                   R                  U5        Uc  SU-  $ SU R                   l        U(       a  SU R                   l        SU R                  US   5      < SUS   < SU< S3$ )Nr  Tz
__PYX_ERR(r   r  r   rD  )r  r|  r  r  r  r  )r   r  r  r  s       r   r  CCodeWriter.error_goto;  su    nn((  %;##8<526DNN/  Q(F 	r   c                 R    SU R                  U5      < SU R                  U5      < 3$ )Nr  r  )r  r  )r   r  r  s      r   error_goto_ifCCodeWriter.error_goto_ifH  s    #}}T2DOOC4HIIr   c                 ,    U R                  SU-  U5      $ )Nz!%sr  r   rP  r  s      r   re  CCodeWriter.error_goto_if_nullK  s    !!%%-55r   c                 ,    U R                  SU-  U5      $ )Nz(%s < 0)r  r  s      r   error_goto_if_negCCodeWriter.error_goto_if_negN  s    !!*u"4c::r   c                 &    U R                  SU5      $ )NzPyErr_Occurred()r  r  s     r   r  CCodeWriter.error_goto_if_PyErrR  s    !!"4c::r   c                 8    U R                   R                  U5      $ r   )r#  r  )r   r  s     r   r  CCodeWriter.lookup_filenameU  s    //99r   c                 &    U R                  S5        g )N__Pyx_RefNannyDeclarationsr  r   s    r   r_  (CCodeWriter.put_declare_refcount_contextX  s    

/0r   c                     UR                  5       nU(       a/  U R                  R                  [        R	                  SS5      5        U R                  SX=(       a    S=(       d    S4-  5        g )Nr  r  z#__Pyx_RefNannySetupContext(%s, %d);r   r   )r  r#  r  r  r  r  )r   rK  acquire_gils      r   r  &CCodeWriter.put_setup_refcount_context[  s[    '')--''(:<OPR

8DBSRSBXWX;YYZr   c                 B    U R                  U(       a  S5        g S5        g )Nz"__Pyx_RefNannyFinishContextNogil()z__Pyx_RefNannyFinishContext();r  r   nogils     r   r  'CCodeWriter.put_finish_refcount_contextb  s    

57gFfgr   c                     UR                  5       nUU(       a  [        R                  OS[        R                  [        R                  4nSU R
                  l        U R                  SU-  5        g)zt
Build a Python traceback for propagating exceptions.

qualified_name should be the qualified name of the function.
r   Tz#__Pyx_AddTraceback(%s, %s, %s, %s);N)r  r   r  r  r  r  r  r  )r   qualified_nameinclude_clineformat_tuples       r   put_add_tracebackCCodeWriter.put_add_tracebacke  s[     (;;=$1F  q!!	
 /3+

8<GHr   c           	      :   SU R                   l        U R                  SU[        R                  [        R
                  [        R                  U R                  R                  S   U4-  5        U R                  R                  [        R                  SS5      5        g)z
Generate code to print a Python warning for an unraisable exception.

qualified_name should be the qualified name of the function.
Tz0__Pyx_WriteUnraisable("%s", %s, %s, %s, %d, %d);unraisable_tracebacksWriteUnraisableExceptionzExceptions.cN)r  r  r  r   r  r  r  r#  r  r  r  r  )r   r+  r(  s      r   put_unraisableCCodeWriter.put_unraisablev  s     /3+

E  !!''(?@I
 
 	 	))##$>O	Qr   c                 t    U R                   R                  S   =(       d    U R                   R                  S   $ )Nprofiler  )r#  r  r   s    r   
is_tracingCCodeWriter.is_tracing  s0    **95a9I9I9T9TU`9aar   c                     U R                   R                  nU(       a3  XR                  ;  a$  UR                  nU(       a  XR                  ;  a  M$  U(       a  UR                  U   $ S$ )z[
Calculate a fake 'instruction offset' from a node position as 31 bit int (32 bit signed).
r   )r  r  node_positions_to_offsetparent_scope)r   r  r  s      r   r  CCodeWriter.pos_to_offset  sT     $$#A#AA&&E #A#AA6;u--c2BBr   c                 B    U R                  U(       a  S5        g S5        g )N__Pyx_TraceDeclarationsGen__Pyx_TraceDeclarationsFuncr  )r   is_generators     r   put_trace_declarations"CCodeWriter.put_trace_declarations  s    

</cEbcr   c                 <    U(       a  U R                  SU-  5        g g )Nz__Pyx_TraceFrameInit(%s)r  )r   codeobjs     r   put_trace_frame_init CCodeWriter.put_trace_frame_init  s    JJ1G;< r   c                 B   U(       a  SOSnU R                  U SUR                  5        S[        R                   SU R	                  US   5       SUS    SU R                  U5      S	 SUS	 SU(       a  [        R                  OS
 SU R                  U5       S35        g )N__Pyx_TraceStartGen__Pyx_TraceStartFuncr  r  r  r   ], r   r   r  rx  )r  r  r   filetable_cnamer  r  skip_dispatch_cnamer  )r   rK  r  r(  r@  is_cpdef_func
trace_funcs          r   put_trace_startCCodeWriter.put_trace_start  s    .:*@V


l!'')*"%%&a(<(<SV(D'ES1vhb!!#&q)Qir-:v))DBs#$
	
r   c                 B    U R                  S[        U5      S S35        g )Nz__Pyx_PyMonitoring_ExitScope(r   rx  )r  r   r'  s     r   put_trace_exitCCodeWriter.put_trace_exit  s    

24;q/DEr   c           	      z    U R                  U5      nU R                  SU SU R                  U5       SU S35        g )Nz__Pyx_TraceYield(r  rx  r  r  r  )r   retvalue_cnamer  r  s       r   put_trace_yieldCCodeWriter.put_trace_yield  sC    __S)


&~&6b9K9KC9P8QQST^S__abcr   c                    U R                   R                  nUR                  (       a  UR                  R                  S   OUS   nUR                  R                  5       nU R                  US   5      nU R                  U5      nU R                  SU S[        R                   SU SU SU R                  U5       SU S35        g )Nr   r   z__Pyx_TraceResumeGen(r  r  rJ  rx  )r  r  scope_classr  rK  r  r  r  r  r   rK  r  )r   r  r  
first_linerK  filename_indexr  s          r   put_trace_resumeCCodeWriter.put_trace_resume  s    $$161B1BU&&**1-A
zz--/--c!f5__S)


#fB%%&a'7sl"!!#&'rl	
r   c           
          U R                  SU R                  U5       S[        U5      S S[        U5      S S35        g )N__Pyx_TraceException(r  r   rx  r  r  r   )r   r  reraisefreshs       r   put_trace_exceptionCCodeWriter.put_trace_exception  sE    

*4+=+=c+B*C2d7mTUEVVXY]^cYdefXggijkr   c                 J    U R                  S[        R                   S35        g )Nr`  z, 0, 0);)r  r   r  r   s    r   put_trace_exception_propagating+CCodeWriter.put_trace_exception_propagating  s    

*6+>+>*?xHIr   c                 L    U R                  SU R                  U5       S35        g )Nz__Pyx_TraceExceptionHandled(rx  )r  r  r  s     r   put_trace_exception_handled'CCodeWriter.put_trace_exception_handled  s$    

1$2D2DS2I1J"MNr   c                 f    U R                  SU R                  U5       S[        U5      S S35        g )Nz__Pyx_TraceExceptionUnwind(r  r   rx  ra  )r   r  r(  s      r   put_trace_unwindCCodeWriter.put_trace_unwind  s3    

01C1CC1H0IDQVKXY?Z\]^r   c           	      z    U R                  U5      nU R                  SU SU R                  U5       SU S35        g )Nz__Pyx_TraceStopIteration(r  rx  rU  )r   r  r  r  s       r   put_trace_stopiteration#CCodeWriter.put_trace_stopiteration  sB    __S)


.ugR8J8J38O7PPRS]R^^`abr   c                    SnSnUc  OpUR                   (       a  UR                  U5      nOMUR                  (       a  SnO9UR                  (       a  SnO%UR                  (       a  SnSUR                   3nOSnU R                  U5      nU R                  U SU U SU R                  U5       S[        U5      S SU S35        g )	NrX  __Pyx_TraceReturnValuer  __Pyx_TraceReturnCValuer  r  r   rx  )	r  r  is_void	is_stringto_py_functionr  r  r  r   )r   rV  r  rf  r(  	extra_argrN  r  s           r   put_trace_returnCCodeWriter.put_trace_return  s    	-
$$(44^DN  &N""&N''2J[7789I 'N-

j\>"29+R@R@RSV@W?XXZ[_`e[fghZiiklzk{{}~r   DefaultPlacementNewr  c                 d    U R                   R                  U5        U R                  SU S35        g )Nz$__Pyx_default_placement_construct(&(z));)r#  r  r  )r   r  _utility_codes      r   put_cpp_placement_new!CCodeWriter.put_cpp_placement_new  s,    ))-8

9&EFr   c                 j    U R                  S5        U R                  U5        U R                  S5        g )Nz#ifdef _OPENMPz#endif /* _OPENMP */r  )r   strings     r   putln_openmpCCodeWriter.putln_openmp  s(    

#$

6

)*r   c                     U R                  SU-  5        U R                  S5        U R                  S5        U R                  S5        U R                  S5        U R                  S5        g)zT
Redefine the macros likely() and unlikely to no-ops, depending on
condition 'cond'
#if %s    #undef likely    #undef unlikelyz    #define likely(x)   (x)z    #define unlikely(x) (x)rG  Nr  r  s     r   undef_builtin_expect CCodeWriter.undef_builtin_expect  sT    
 	

8d?#

&'

()

01

01

8r   c                     U R                  SU-  5        U R                  S5        U R                  S5        U R                  S5        U R                  S5        U R                  S5        g )Nr  r  r  z2    #define likely(x)   __builtin_expect(!!(x), 1)z2    #define unlikely(x) __builtin_expect(!!(x), 0)rG  r  r  s     r   redef_builtin_expect CCodeWriter.redef_builtin_expect  sR    

8d?#

&'

()

GH

GH

8r   )
r  r  r  rf  r  r#  r  r  r$   r  )NNF)NNTr   r  )TF)rX  Fr  )rX  NT)TT)FTTr  )r  T)TNr  )FNr  )FFFr>  )r  r	  r
  r  r  r  r   r   r  rs  r  r
  r  r  r  r  r|  r  r  r  r}  r  r|  r~  r  r  r0  r  r;  r  r  r  r  r  r  r  r  r  r  r  rX  r  r}  rm  rp  rs  r  r  r  rN  r  r  r2  r  r  r  r   r  r  r  r  r  r7  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r6  r  rx  r   r  r  r  modifier_output_mapperr  r  r  r!  r%  r*  r.  r4  r8  r?  rC  rI  r5  rR  rV  r\  r_  rb  re  ri  rl  rq  ru  ry  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  re  r  r  r  r_  r  r  r.  r3  r7  r  rA  rE  rO  rR  rW  r]  rd  rg  rj  rm  rp  ry  r  r~  r  r  r  r  r  r   r   r  r  	  s   < ]]}-? .?44
&% \\! !-* ! !     " " 3 3   &2 MSSNTSMSMKL:0
'





=>0
Vb.?D@ ; ; < <
D&% \\	' 	' \\F F \\V V
 \\" "8 \\ (	R[ 	R \\  \\  \\  \\  \\1 1I%% 8:9=74I- I.) :P B5*+,+78JK>>9:ST12239:9:eHIf/(.	!J(/!b,iA.?

+"0"<
N
70J6;;:1[hI"Q$bCd=
Fd
"lJO_c@2 -8,<,<=RTd,eG
+

r   r  c                   ,    \ rS rSrS rS rS rS rSrg)PyrexCodeWriteri  c                 H    [         R                  " U5      U l        SU l        g r  )r   r  r  r$   )r   outfile_names     r   r   PyrexCodeWriter.__init__  s    $$\2
r   c                 b    U R                   R                  SU R                  -  < U< S35        g )Nr  r?  )r  r  r$   r  s     r   r  PyrexCodeWriter.putln  s     tzz!1489r   c                 .    U =R                   S-  sl         g r  r#   r   s    r   r  PyrexCodeWriter.indent      

a
r   c                 .    U =R                   S-  sl         g r  r#   r   s    r   r~  PyrexCodeWriter.dedent  r  r   )r  r$   N)	r  r	  r
  r  r   r  r  r~  r  r  r   r   r  r    s    :r   r  c                   ~    \ rS rSrSrSS jrSS jrSS jr\S 5       r	S r
S	 rSS
 jrSS jrS rS rS rS rSrg)PyxCodeWriteri  z/
Can be used for writing out some Cython code.
Nc                 r    U=(       d
    [        5       U l        X l        X l        X0l        X@l        0 U l        g r   )r   r  r$   original_levelr  r  _insertion_points)r   r  indent_levelr  r  s        r   r   PyxCodeWriter.__init__  s-    .!
* !#r   c                 .    U =R                   U-  sl         gr  r#   r   levelss     r   r  PyxCodeWriter.indent'  s    

f
r   c                 .    U =R                   U-  sl         g r   r#   r  s     r   r~  PyxCodeWriter.dedent+  s    

f
r   c              #   v   #    U R                  U5        U R                  5         Sv   U R                  5         g7f)zN
with pyx_code.indenter("for i in range(10):"):
    pyx_code.putln("print i")
N)r  r  r~  )r   rt  s     r   indenterPyxCodeWriter.indenter.  s(      	

4s   79c                 6    U R                   R                  5       $ r   )r  emptyr   s    r   r  PyxCodeWriter.empty9  s    {{  ""r   c                     U R                   R                  5       n[        U[        5      (       a  UR	                  U R
                  5      nU$ r   )r  r
  r   r   r  r  )r   r  s     r   r
  PyxCodeWriter.getvalue<  s8    %%'fe$$]]4==1Fr   c                     Uc  U R                   b  U R                   nUb  [        X5      nU R                  R                  U(       a  U R                  S-   U S35        g S5        g )Nz    r?  )r  rb  r  r  r$   )r   rt  r  s      r   r  PyxCodeWriter.putlnB  sX    ?||',,t-DdTZZ&01$r:MMr   c                     Uc  U R                   b  U R                   nUb  [        X5      n[        XR                  S-  5      nU R                  R                  U5        g )Nr  )r  rb  _indent_chunkr$   r  r  )r   chunkr  s      r   	put_chunkPyxCodeWriter.put_chunkK  sN    ?||',,/EeZZ!^4% r   c                     [        U 5      " U R                  R                  5       U R                  U R                  5      $ r   )r   r  r|  r$   r  r   s    r   r|  PyxCodeWriter.insertion_pointU  s*    Dz$++557T\\RRr   c                 Z    U R                   R                  5         U R                  U l        g r   )r  resetr  r$   r   s    r   r  PyxCodeWriter.resetX  s!     	((
r   c                 >    U R                  5       U R                  U'   g r   )r|  r  r>  s     r   named_insertion_point#PyxCodeWriter.named_insertion_point^  s    '+';';'=t$r   c                      U R                   U   $ r   )r  r>  s     r   r  PyxCodeWriter.__getitem__a  s    %%d++r   )r  r  r  r  r$   r  )Nr   Nr   )r   r   )r  r	  r
  r  r  r   r  r~  r   r  r  r
  r  r  r|  r  r  r  r  r  r   r   r  r    sT    $  #N!S)>,r   r  r  indentation_lengthr2  c                 (   SU ;  d   eU R                  SS9nU(       d  U $ US   R                  S5      nU(       a  X2S'   OUS	 U(       d  g[        U 5      S-   n[        U5       H1  u  pV[	        U5      nUS-   [        U5      :X  a  SX%'   M(  Xt:  d  M/  UnM3     U[        U 5      :  a  SnXA:  a$  SX-
  -  nU Vs/ s H  nUS:w  a  X-   OSPM     nnO%XA:  a   XA-
  n	U Vs/ s H  nUS:w  a  XiS	 OSPM     nnS
R                  U5      $ s  snf s  snf )zONormalise leading space to the intended indentation and strip empty lines.
    	Tr  r   r  r?  r   r   NrX  )r6  rb  r   r   _count_indentationr  )
r  r  rL  	last_linemin_indentationr  rt  line_indentation
add_indentstarts
             r   r  r  e  s\   
 ud+Eb	  %Ib	"I #&e*q.O U#-d3a3t9,EH/.O $ U#+.@A
 
 "&J47 	 
 
	-+@ 
 !DLDLd2 	 

 775>

s   ;D
!Dr   r  c                 D    Sn[        U 5       H  u  pUS:w  d  M    U$    U$ )Nr   r  )r   )r  r  chs      r   r  r    s/     A19H  Hr   c                   &    \ rS rSrS rS rS rSrg)r  i  c                 :    Xl         0 U l        0 U l        SU l        g r  )klassr  r  temps_count)r   r  s     r   r   ClosureTempAllocator.__init__  s    
!r   c                 z    U R                   R                  5        H  u  p[        U5      U R                  U'   M     g r   )r  rG  r   r  )r   r   r?  s      r   r  ClosureTempAllocator.reset  s/     00668LD$(LDOOD! 9r   c                    XR                   ;  a  / U R                   U'   / U R                  U'   O2U R                  U   (       a  U R                  U   R                  S5      $ S[        R                  U R
                  4-  nU R                  R                  S X"USS9  U R                   U   R                  U5        U =R
                  S-  sl        U$ )Nr   r  T)r  rK  rP  r   is_cdefr   )	r  r  r  r   r  r  r  declare_varre  )r   r   rP  s      r   r  "ClosureTempAllocator.allocate_temp  s    +++)+D  &$&DOOD!__T"??4(,,Q//&779I9IJJ

4etUYZT"))%0Ar   )r  r  r  r  N)r  r	  r
  r  r   r  r  r  r  r   r   r  r    s    1
r   r  r  )jr  declarer   r  r   r   r   r  r   dataclassesr   r  r   	functoolsr   r   
contextlibr   r   collectionsr   rX  r   r	   r   r
   r   Scanningr   r   r"   r   r   r%   r   rS   compression.zstdr   r   zstd_CompressionParameterr    zstd_Strategystrategybtultra2compression_levelboundsrd  r  ctypedef_builtins_mapbasicsize_builtins_mapKNOWN_PYTHON_BUILTINS_VERSIONr   KNOWN_PYTHON_BUILTINSuncachable_builtinsr  r   r  r7  r   r  rd  r  r!  r5  r  r  r-  r9  r;  rG  rR  rV  r[  r  rb  r~  ro  rx  r	  r  r   Ur:  r  r  ra  r  findallr  r  r/  r1  r  r  r  r  r  r  ccallr(   r   r  	exceptvalcfuncr  r  r  r   r   <module>r     s     f& fV ff fv ff'-f7=fNTff.4fCIf !f /5f 	f (.	f 6<	f
 $f
 39f
 IOf
 _ef   	 	   !  $ . #      & ' +:, <q9L
  M!**M,B,B!335N5`5`5g5g5ijk5l4 M 	" Q/0|	    *)*1  &  !6 ! \# \ | * ^^Iy : 0   o#  !'v8 #	! I' I'X/   6  S) Sj   K5/ K5\ -1Ueidj &R 
6*	* *K * * 			2	2 {
+
W
W  ,	// 
(
7
7   "&D" (&= =D?o ? G9 G9T. .   6V"(A jj)9244@FF JJ'89?? ZZ 1266 ,-55? ?D( ($C6 C6L 7 7X Xv  $H, H,V , ,&** , ,  ,^ "# &**    us  L  Ms$   <O 

O OOO+*O+