
    Aekq                     6   d dl mZ ddlmZ ddlmZ ddlmZ ddlmZ ddl	mZm
Z
 ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ d?dZ G d de      ZdZdddddZdZdZdZdZdZdZdZdZdZd@dZ G d d e      Z d! Z!d" Z"d# Z#d$ Z$d% Z%d& Z&d' Z'd( Z(d) Z)d* Z*d+ Z+d, Z,d- Z-d. Z.d/ Z/ G d0 d1e      Z0d2 Z1dAd3Z2dAd4Z3 e4ejj                  5      Z6 e3d6e67      Z7 e3d8      Z8 e3d9      Z9 e3d:      Z: e3d;      Z; e3d<e67      Z< e3d=e67      Z= e3d>      Z>y)B    )absolute_import   )CythonTransform)
ModuleNode)CompileError)CythonUtilityCode)UtilityCodeTempitaUtilityCode)Options)Interpreter)
PyrexTypes)Naming)Symtabc                     ddl m}  ||       } |dkD  r6d|z  }dj                  | j                  d      D cg c]  }||z   	 c}      } | S c c}w )Nr   )dedent 
)textwrapr   joinsplit)textreindentr   indentxs        6lib/python3.12/site-packages/Cython/Compiler/Buffer.pyr   r      sO    $<D!|xyydjj.>?&1*?@K @s   Ac                   8     e Zd ZdZdZ fdZd Zd Zd Z xZ	S )IntroduceBufferAuxiliaryVarsFc                     t        |t              sJ d| _        t        t        |   |      }| j                  r*t        |j                         t        |j                         |S )Nr   )

isinstancer   max_ndimsuperr   __call__buffers_existsuse_bufstruct_declare_codescopeuse_py2_buffer_functions)selfnoderesult	__class__s      r   r"   z%IntroduceBufferAuxiliaryVars.__call__    sO    $
++3TCDI&tzz2$TZZ0    c           	         j                   j                         }|D cg c]  \  }}|j                  j                  s|  }}}t	        |      dkD  r|j                  d        d| _        |D cg c]  \  }}|j                  j                  s|  }}}t	        |      dkD  rd| _        |D ].  \  dk(  st        j                  t              s'd| _         n ~t        t              r$t	        |      dkD  rt        j                  d      |D ]A  j                  j                  j                   rt        j                  d      j"                  j                  }|j$                  t&        j(                  kD  r't        j                  dt&        j(                  z        |j$                  | j*                  kD  r|j$                  | _        fd	}	t,        j.                  t0        j2                  ft,        j4                  t0        j6                  ff}
|
D cg c]  \  }} |	||       c}}\  }}t9        j:                  ||      _        D |_        | _         y c c}}w c c}}w c c}}w )
Nr   c                     | j                   S N)name)entrys    r   <lambda>z;IntroduceBufferAuxiliaryVars.handle_scope.<locals>.<lambda>5   s
    5:: r+   )keyT
memoryviewz'Buffer vars not allowed in module scopez-Buffers with pointer types not yet supported.z1Buffer ndims exceeds Options.buffer_max_dims = %dc                     j                  |      }j                  d || j                        }j                  rd|_        |S )N)r/   cnametypeposT)mangledeclare_varr7   is_argused)r6   prefixr5   aux_varr0   r/   r(   r%   s       r   decvarz9IntroduceBufferAuxiliaryVars.handle_scope.<locals>.decvarS   sI    VT2++U15488 , E<<#'GLr+   )!entriesitemsr6   	is_bufferlensortr#   is_memoryviewslicer   utility_code_definitionr   using_memoryviewr   r   r7   dtypeis_ptrr/   ndimr   buffer_max_dimsr    r   c_pyx_buffer_nd_typer   pybuffernd_prefixc_pyx_buffer_typepybufferstruct_prefixr   	BufferAux
buffer_auxbuffer_entriesr%   )r'   r(   r%   scope_itemsr/   r0   bufvarsmemviewslicevarsbuftyper>   auxvarsr6   r<   
pybufferndrcbuffers    `` ``         r   handle_scopez)IntroduceBufferAuxiliaryVars.handle_scope.   s$    mm))+,7P[T55::;O;O5PPw<!LL5L6"&D5@bkdEEJJDaDaEbb 1$"&D ) 	MT5|#
53P3PRc(d(,%	 dJ'CL1,<txx)RSS 	FEzz&&"488-\]]::DjjG||g555"488KgNeNeeg g||dmm+ ' #779Q9QR"44f6R6RSUGOV#W^dFF4$8#W J%//
HEE5	F8  '
a Q
 cL $Xs   I0I07I6I6)I<c                 `    | j                  ||j                         | j                  |       |S r.   )rY   r%   visitchildrenr'   r(   s     r   visit_ModuleNodez-IntroduceBufferAuxiliaryVars.visit_ModuleNodee   s)    $

+4 r+   c                 `    | j                  ||j                         | j                  |       |S r.   )rY   local_scoper[   r\   s     r   visit_FuncDefNodez.IntroduceBufferAuxiliaryVars.visit_FuncDefNodej   s+    $ 0 014 r+   )
__name__
__module____qualname__r#   rF   r"   rY   r]   r`   __classcell__)r*   s   @r   r   r      s%     N5n
r+   r   )rG   rI   modenegative_indicescastfullTF)rI   re   rf   rg   z"%s" is not a buffer optionzToo many buffer optionsz#"%s" buffer option already suppliedz"%s" missingz[Only allowed buffer modes are: "c", "fortran", "full", "strided" (as a compile-time string)z#ndim must be a non-negative integerz0dtype must be "object", numeric type or a structz"%s" must be a booleanNc                     |t         }t        j                  |||d      \  }}t        |      t        kD  rt        |d   d   t              i |j                         D ](  \  }\  }}|t        vrt        |t        |z        ||<   * t        t        |      D ]?  \  }\  }}|t        vrt        |t        |z        |v rt        |t        |z        ||<   A t        D ]  }|vs	 ||   |<    j                  d      }	|	r|	j                  rt         t               j                  d      }
|
r%t#        |
t$              r|
dk  rt         t&              j                  d      }|r|d	vrt         t(               fd
} |d        |d       S # t        $ r |rt         t        |z        Y w xY w)aO  
    Must be called during type analysis, as analyse is called
    on the dtype argument.

    posargs and dictargs should consist of a list and a dict
    of tuples (value, pos). Defaults should be a dict of values.

    Returns a dict containing all the options a buffer can have and
    its value (with the positions stripped).
    )r   rG   )type_env	type_argsr   rG   rI   r   re   )rh   stridedcfortranc                 n    j                  |       }t        |t              st        t        | z        y r.   )getr   boolr   ERR_BUF_BOOL)r/   r   	globalposoptionss     r   assert_boolz+analyse_buffer_options.<locals>.assert_bool   s2    KK!T"y,*=>> #r+   rf   rg   )buffer_defaultsr   interpret_compiletime_optionsrB   buffer_positional_options_countr   ERR_BUF_TOO_MANYr@   buffer_optionsERR_BUF_OPTION_UNKNOWNzipERR_BUF_DUPKeyErrorERR_BUF_MISSINGrq   is_extension_typeERR_BUF_DTYPEr   intERR_BUF_NDIMERR_BUF_MODE)rt   envposargsdictargsdefaultsneed_completer/   valuer7   rG   rI   re   rv   ru   s   `            @r   analyse_buffer_optionsr      s    "#AAC<AGX 7|5572;q>+;<<G&nn. luc~%s$:T$ABB
 ".': luc~%s$:T$ABB7?sK$$677  JwJ (J KK E((9m44;;vDZc*dQh9l33;;vDT@@9l33?
 "#N1  J &y/D2HII !Js   -FF>=F>c                   6    e Zd Zd Zd Zd Zd Zd Zd Zd Z	y)	BufferEntryc                     || _         |j                  | _        |j                  j                  j                  | _        d| j                  z  | _        |j                  j                  | _        | j                          y )Nz%s.rcbuffer->pybuffer.buf)	r0   r6   rP   buflocal_nd_varr5   buf_ptrbuffer_ptr_typebuf_ptr_typeinit_attributes)r'   r0   s     r   __init__zBufferEntry.__init__   s[    
JJ	%%55;;
2TZZ?!JJ66r+   c                     | j                         | _        | j                         | _        | j	                         | _        y r.   )get_buf_shapevarsshapeget_buf_stridevarsstridesget_buf_suboffsetvars
suboffsetsr'   s    r   r   zBufferEntry.init_attributes   s2    ++-
..0446r+   c                 $    | j                  d      S )Nz%s.diminfo[%d].suboffsets_for_all_ndimr   s    r   r   z!BufferEntry.get_buf_suboffsetvars   s    !!"=>>r+   c                 $    | j                  d      S )Nz%s.diminfo[%d].stridesr   r   s    r   r   zBufferEntry.get_buf_stridevars   s    !!":;;r+   c                 $    | j                  d      S )Nz%s.diminfo[%d].shaper   r   s    r   r   zBufferEntry.get_buf_shapevars   s    !!"899r+   c                     t        | j                  j                        D cg c]  }|| j                  |fz   c}S c c}w r.   )ranger6   rI   r5   )r'   sis      r   r   zBufferEntry._for_all_ndim   s0    -2499>>-BCTZZO#CCCs   =c           	         g }| j                   j                  }| j                   j                  }|dk(  rqt        || j	                         | j                               D ]9  \  }}}|j                  |       |j                  |       |j                  |       ; d|z  }	t        }
ny|dk(  rd|z  }	t        }
n$|dk(  rd|z  }	t        }
n|dk(  rd|z  }	t        }
nJ t        || j	                               D ]'  \  }}|j                  |       |j                  |       ) |	|j                  j                  vrO|j                  j                  j                  |	       |j                  d	   }|j                  d
   } |
|||	|       | j                  j                         }|	d|d| j                   ddj#                  |      d}|S )Nrh   z__Pyx_BufPtrFull%ddrm   z__Pyx_BufPtrStrided%ddrn   z__Pyx_BufPtrCContig%ddro   z__Pyx_BufPtrFortranContig%ddutility_code_protoutility_code_def)r/   nd(, ))r6   rI   re   r}   r   r   appendbuf_lookup_full_codebuf_lookup_strided_codebuf_lookup_c_codebuf_lookup_fortran_codeglobalstateutility_codesaddr   empty_declaration_coder   r   )r'   codeindex_cnamesparamsr   re   r   r   ofuncnamefuncgen	protocodedefcodebuf_ptr_type_codeptrcodes                  r   generate_buffer_lookup_codez'BufferEntry.generate_buffer_lookup_code   s    YY^^yy~~6>|#668#99;= !1a a a a ! -r1H*Gy 3b813b8+"9B>1L$*A*A*CD !1a a !
 4++999**..x8(()=>I&&'9:GIwX"= --DDF&.0A4<<&*ii&79r+   N)
ra   rb   rc   r   r   r   r   r   r   r    r+   r   r   r      s&    7
?<:D*r+   r   c                     d}|j                   }|dk(  r|dz  }n#|dk(  r|dz  }n|dk(  r|dz  }n|dk(  r|d	z  }nJ | j                  r|d
z  }|S )NPyBUF_FORMATrh   z| PyBUF_INDIRECTrm   z| PyBUF_STRIDESrn   z| PyBUF_C_CONTIGUOUSro   z| PyBUF_F_CONTIGUOUSz| PyBUF_WRITABLE)re   writable_needed)rP   buffer_typeflagsre   s       r   	get_flagsr     sw    EDv~##		""	''		''!!5,>#>5Lr+   c                 `    | j                   }d|j                  _        d|j                  _        y NT)rP   r   r;   	rcbuf_var)r0   rP   s     r   used_buffer_aux_varsr     s)    !!J&*J# $Jr+   c                 v   | j                   | j                  j                  }}|j                  j                  }ddg}|dk(  r|j                  d       g }t        | j                  j                        D ]#  }|D ]  }|j                  d||||||fz          % |j                  dj                  |             y )Nr   r   rh   r   z1%s.diminfo[%d].%s = %s.rcbuffer->pybuffer.%s[%d];r   )
rP   r6   re   r   r5   r   r   rI   putlnr   )		buf_entryr   rP   re   pybuffernd_structfldnameslnr   fldnames	            r    put_unpack_buffer_aux_into_scoper      s     !++Y^^-@-@J"22887#Hv~%	B9>>&&' 5 	5GIII&7&44 5	55
 	JJsxx|r+   c                    | j                   }|j                  j                  }|j                  j                  }|j	                  d|z         |j	                  d|z         |j	                  d|z         |j	                  |d|d       y )Nz%s.pybuffer.buf = NULL;z%s.refcount = 0;z%s.data = NULL;z.rcbuffer = &;)rP   r   r5   r   r   )r0   r   bufauxr   pybuffer_structs        r   put_init_varsr   2  s{    F..44&&,,OJJ(?:;JJ!O34 	JJ #445JJ'8/JKr+   c                 p   | j                   }t        || j                  || j                        }|j	                  d       |j	                  d| j                  j
                  j                         z         |j	                  |j                  d|z  |             |j	                  d       t        | |       y )N{'__Pyx_BufFmt_StackElem __pyx_stack[%d];%s == -1})	rP   get_getbuffer_callr5   r6   r   rG   struct_nesting_deptherror_goto_ifr   )r0   r   r7   rP   	getbuffers        r   put_acquire_arg_bufferr   @  s    !!J"4j%**MI 	JJsOJJ85::;K;K;`;`;bbcJJt!!*y"8#>?JJsO %UD1r+   c                     | j                   j                  t               | j                  d|j                  j
                  j                  z         y )N0__Pyx_SafeReleaseBuffer(&%s.rcbuffer->pybuffer);)r   use_utility_codeacquire_utility_coder   rP   r   r5   )r   r0   s     r   put_release_buffer_coder   N  s;    %%&:;JJAEDTDTDdDdDjDjjkr+   c                    |j                   }t        |j                        }t        ||      }|j                  j
                  }t        | |j                        }| j                  j                  t               dt               z  S )Nz__Pyx_GetBufferAndValidate(&%(pybuffernd_struct)s.rcbuffer->pybuffer, (PyObject*)%(obj_cname)s, &%(dtype_typeinfo)s, %(flags)s, %(ndim)d, %(cast)d, __pyx_stack))rI   r   rg   r   r   r5   get_type_information_cnamerG   r   r   r   locals)	r   	obj_cnamerP   r   rI   rg   r   r   dtype_typeinfos	            r   r   r   S  sv    D{ Dj+.E"2288/k6G6GHN%%&:;%'-x0 1r+   c           	      f   |j                   |j                  }}|j                  j                  }t	        ||      }	j                  d       j                  d|j                  j                         z         t        d||      }
|rj                  d|z         j                  j                  t        j                  d      }j                  |d|
|z  d       j                  d	j                  d
|z        z         t        fdt        d      D              }j                  d|z         j                  d	j                  d|
| z  z        z         j                  d|z         j                   j#                  t$               j                  d       j                  d       j                  d|z         j                  d       j                  d|z         |D ]  }j                  j'                  |        j                  d       t)        |       j                  j+                  ||             j                  j'                  |       nj                  d	j                  d|
|z  z        z         j                  | dt        j,                  |t        j.                  d      d|d       j                  j1                  |             j3                  d       t)        |       j                  d       j                  d       y)aJ  
    Generate code for reassigning a buffer variables. This only deals with getting
    the buffer auxiliary structure and variables set up correctly, the assignment
    itself and refcounting is the responsibility of the caller.

    However, the assignment operation may throw an exception so that the reassignment
    never happens.

    Depending on the circumstances there are two possible outcomes:
    - Old buffer released, new acquired, rhs assigned to lhs
    - Old buffer released, new acquired which fails, reaqcuire old lhs buffer
      (which may or may not succeed).
    r   r   z%sr   F
manage_refz = r   	if (%s) {%s < 0c              3   t   K   | ]/  }j                   j                  t        j                  d        1 yw)Fr   N)	funcstateallocate_tempr   py_object_type).0_r   s     r   	<genexpr>z'put_assign_to_buffer.<locals>.<genexpr>  s4      - ..66z7P7P]b6c -s   58   zPyErr_Fetch(&%s, &%s, &%s);r   z/Py_XDECREF(%s); Py_XDECREF(%s); Py_XDECREF(%s);z!__Pyx_RaiseBufferFallbackError();z} else {zPyErr_Restore(%s, %s, %s);r   z%s = %s = %s = 0;Py_Nonez; __Pyx_INCREF(Py_None); z.rcbuffer->pybuffer.buf = NULL;N)rP   r6   r   r5   r   r   rG   r   r   r   r   r   
c_int_typeunlikelytupler   r   r   raise_buffer_fallback_coderelease_tempr   error_goto_if_negtypecastr   
error_gotoput)	lhs_cname	rhs_cnamer   is_initializedr7   r   rP   r   r   r   r   retcode_cname	exc_tempsts        `        r   put_assign_to_bufferr  a  s     (22INNJ"2288j+.EJJsOJJ8;;L;L;a;a;ccd"4z;GI

EHYYZ44Z5J5JW\4]

	I0EFG

;$--=0H"IJK
  -#(8- -	

09<=

;zY=R/S!TTU

DyPQ))*DE

67

:

/);<

3

&23 	+ANN''*	+

3(D9

4))-=>##M2
 	

;zY=R/S!TTU

''Z5N5NPYZ%' 	( 	

4??3'((D9

3JJsOr+   c           
         |d   xr |}|d   r|j                   j                  t        j                  d      }|j	                  d|z         t        t        ||| j                                     D ]  \  }	\  }
}}|
dk7  r~|j	                  d|z         |rA|j	                  |d|d	       |j	                  d
|j                  d|z        ||	fz         n|j	                  d||	fz         |j                  d       |
dk7  rd}nd}|j	                  d
|j                  |d||      ||	fz          |r"|j                  j                  t               d}n!|j                  j                  t               d}|j	                  d|j                  d|z        z         |j	                  |d|d       |j	                  |j                  |             |j	                  d       |j                   j                  |       nG|rEt        ||| j                               D ]'  \  }
}}|
dk7  s|j	                  d|d|d|d	       ) | j!                  ||      S )ae  
    Generates code to process indices and calculate an offset into
    a buffer. Returns a C string which gives a pointer which can be
    read from or written to at will (it is an expression so caller should
    store it in a temporary if it is used more than once).

    As the bounds checking can have any number of combinations of unsigned
    arguments, smart optimizations etc. we insert it directly in the function
    body. The lookup however is delegated to a inline function that is instantiated
    once per ndim (lookup with suboffsets tend to get quite complicated).

    entry is a BufferEntry
    
wraparoundboundscheckFr   z%s = -1;r   zif (%s < 0) {z += r   zif (%s) %s = %d;r   z%s = %d;z} else  z(size_t)z >=  __Pyx_RaiseBufferIndexErrorNogil__Pyx_RaiseBufferIndexErrorr   z%s != -1r   );r   zif (z < 0) )r   r   r   r   r   	enumerater}   r   r   r  r   r   raise_indexerror_nogilraise_indexerror_coder  r   r   )r0   index_signedsr   
directivesr7   r   rf   in_nogil_contextfailed_dim_tempdimsignedr5   r   rg   funcs                  r   put_buffer_lookup_coder    s;    ",/D4D- 
 ..66z7L7LY^6_

:/0+4SV[VmVmVo5p+q 	''C'&%{

?U23#JJeU;<JJ1h&67'5.  . / JJz_c,BBC#{!JJ)eT5AB-& & '#	'* --.DE5D--.CD0D

;zO/K!LLM

o67

4??3'(

3##O4	$'|UE\E\E^$_ 	L FE5{

eUEJK	L ,,T<@@r+   c                 .    | j                  t               y r.   )r   buffer_struct_declare_coder   s    r   r$   r$     s    34r+   c                    dj                  t        |      D cg c]
  }d|||fz   c}      }| j                  d|d|d|d|d	       dj                  t        |      D cg c]
  }d|||fz   c}      }| j                  d	|d
|d       |j                  t        d      ||fz  dj                  t        |      D cg c]  }t        d      ||||fz   c}      z   dz          yc c}w c c}w c c}w )
    Generates a buffer lookup function for the right number
    of dimensions. The function gives back a void* at the right location.
    r   zi%d, s%d, o%d#define (type, buf, z	) (type)(z
_imp(buf, z))z.Py_ssize_t i%d, Py_ssize_t s%d, Py_ssize_t o%dzstatic CYTHON_INLINE void* z_imp(void* buf, r  zf
        static CYTHON_INLINE void* %s_imp(void* buf, %s) {
          char* ptr = (char*)buf;
        r  zX          ptr += s%d * i%d;
          if (o%d >= 0) ptr = *((char**)ptr) + o%d;
        z
return ptr;
}N)r   r   r   r   )protodefinr/   r   r   	macroargsfuncargss          r   r   r     s    		b	J1?aAY6JKI	KKtYX\^ghiyy`efh`ij[\JaQRTUYVjkH	KKtXVW	KK   h  #%'' &+2Y+0 !" ,2 3 , 1a|, +0 #

    K k
+0s   C/%C4C9c           	         dj                  t        |      D cg c]	  }d||fz   c}      }dj                  t        |      D cg c]	  }d||fz   c}      }| j                  d|d|d|d       y	c c}w c c}w )
r"  r   i%d, s%d + 	i%d * s%dr#  r$  z) (type)((char*)buf + r   N)r   r   r   r%  r&  r/   r   r   argsoffsets          r   r   r     sl     9959=ajAq6)=>DZZuRyA!1v-ABF	KKtTSYZ[ >As   A7A<c                 <   |dk(  r| j                  d|z         ydj                  t        |      D cg c]	  }d||fz   c}      }dj                  t        |dz
        D cg c]	  }d||fz   c}      }| j                  d||||dz
  fz         yc c}w c c}w )	z
    Similar to strided lookup, but can assume that the last dimension
    doesn't need a multiplication as long as.
    Still we keep the same signature for now.
    r   .#define %s(type, buf, i0, s0) ((type)buf + i0)r   r*  r+  r,  9#define %s(type, buf, %s) ((type)((char*)buf + %s) + i%d)Nr   r   r   r-  s          r   r   r     s     
QwDtKLyyuRyA!*1v-AB5a=Ia[Aq61IJOSWY]_egilmgmRnno BIs   B#Bc                 2   |dk(  r| j                  d|z         y	dj                  t        |      D cg c]	  }d||fz   c}      }dj                  t        d|      D cg c]	  }d||fz   c}      }| j                  d|||dfz         y	c c}w c c}w )
zB
    Like C lookup, but the first index is optimized instead.
    r   r1  r   r*  r+  r,  r2  r   Nr3  r-  s          r   r   r     s     
QwDtKLyyuRyA!*1v-AB5B<Ha[Aq61HIOSWY]_eghRiij BHs   B!Bc                 6    | j                  t                      y r.   )r   GetAndReleaseBufferUtilityCoder   s    r   r&   r&   )  s    79:r+   c                   2    e Zd ZdZdZd Zd Zd Zd Zd Z	y)r6  NFc                      y r.   r   r   s    r   r   z'GetAndReleaseBufferUtilityCode.__init__5  s    r+   c                 "    t        |t              S r.   )r   r6  )r'   others     r   __eq__z%GetAndReleaseBufferUtilityCode.__eq__8  s    %!?@@r+   c                      y)NiFosr   r   s    r   __hash__z'GetAndReleaseBufferUtilityCode.__hash__;  s    r+   c                      y r.   r   )r'   kwargss     r   get_treez'GetAndReleaseBufferUtilityCode.get_tree>  s    r+   c                   	
 |d   }|d   }|j                   j                  }|j                  j                  g 
t	               	
fd	 	|       t        j                  ddt        
            }|j                  |j                        }|j                  |j                  |j                  |      d         }|j                  |       |j                  |       y )	Nr   r   c                     | 
v ry 
j                  |        | j                  D ]
  } |        | j                  D ]  }t        |j                  t
              r|j                  }|j                  s7| u r|j                  sHd x}}|j                  j                  D ]:  }|j                  dk(  r|j                  }|j                  dk(  s/|j                  }< |s	j                  |j                  ||f        y )N__getbuffer____releasebuffer__)r   cimported_modulestype_entriesr   rE   r   r6   r   r;   r%   pyfunc_entriesr/   
func_cnamer   typeptr_cname)r%   mer
  releaserq   r   cython_scopefind_buffer_typestypesvisited_scopess          r   rN  zBGetAndReleaseBufferUtilityCode.put_code.<locals>.find_buffer_typesI  s    &u%,, %!!$%'' Fa779JKFF&&,QVV $((GcWW33 T66%55Q\\sVV';;q||WT aoosG%DEFr+   GetAndReleaseBufferBuffer.c)rO  )	from_filecontextr   )module_noder%   rT  rM  setr
   loaddictformat_coder%  inject_string_constantsimplr   )r'   outputr   
proto_coder   	util_coder%  r[  rM  rN  rO  rP  s           @@@@r   put_codez'GetAndReleaseBufferUtilityCode.put_code@  s    ()01
  &&{{// 	F( 	#&++!Zu%'	 %%ioo6$$--innfEaHJ 	

4r+   )
ra   rb   rc   requiresis_cython_utilityr   r;  r=  r@  r_  r   r+   r   r6  r6  -  s)    
 HA '(r+   r6  c                     | j                   ry| j                  ry| j                  s| j                  rd}nd}|| j	                         z   S )Nobjectptrnn_r  )is_pyobjectrH   
is_typedefis_struct_or_unionspecialization_name)rG   r<   s     r   mangle_dtype_namerj  k  sI     	u77FF11333r+   c                 ,   t        |      }d|z  }d|z  }|j                  ry||j                         }|dk  rJ || j                  j                  vr| j                  j                  j                  |       | j                  d   }g }|j                  r@|j                  r4|j                  |j                         |j                  }|j                  r4|j                  xr |j                         }|j                         }	|j                         rd}n|j                  r|j                  }
|j                   r|
j"                  }
|
j$                  }t'        |      dkD  sJ |D cg c]  }t)        | |j*                  |dz
         }}|j-                  d|z  d	
       t/        ||      D ]G  \  }}|j-                  d|d|j0                  d|j                         d|j2                  d	d	
       I |j-                  dd	
       |j-                  dd	
       nJ t5        |      }d}d}|t6        j8                  u rd|	z  }d}nj|j:                  rd|	z  }d|z  }nS|s|j<                  rd}nB|j>                  rd}n3|j                  rd}|j@                  rd}n|jB                  rd}nJ |       d}||||	djE                  |D cg c]  }t5        |       c}      xs dt'        |      |||f	}|j-                  ||z  d	
       |S c c}w c c}w )ar  
    Output the run-time type information (__Pyx_TypeInfo) for given dtype,
    and return the name of the type info struct.

    Structs with two floats of the same size are encoded as complex numbers.
    One can separate between complex numbers declared as struct or with native
    encoding by inspecting to see if the fields field of the type is
    filled in.
    z__Pyx_TypeInfo_%sz__Pyx_StructFields_%sz<error>r   typeinfoNULLr   z!static __Pyx_StructField %s[] = {T)safez  {&z, "z", offsetof(r   z)},z  {NULL, NULL, 0}z};0zIS_UNSIGNED(%s)z'H'z%s ? 'U' : 'I'z'C'z'R'z'S'__PYX_BUF_FLAGS_PACKED_STRUCTz'O'zLstatic __Pyx_TypeInfo %s = { "%s", %s, sizeof(%s), { %s }, %s, %s, %s, %s };)#rj  is_errorr   r   r   r   is_arrayr   size	base_typerh  can_be_complexr   is_simple_buffer_dtype	is_structr%   is_constconst_base_type_scopevar_entriesrB   r   r6   r   r}   r/   r5   strr   c_char_typeis_int
is_complexis_floatpackedrf  r   )r   rG   maxdepth
namesuffixr/   structinfo_nametypecode
arraysizescomplex_possibledeclcodestruct_scopefieldsfrO  rl  repr   is_unsigned	typegroupr   tups                        r   r   r   y  s    #5)J+D-
:O~~i E$>$>$@1}4##111&&**40##J/
>>..!!%**- .. !33N8L8L8N//1'')$O__ ;;L~~+AA!--Fv;?"$& 0affhlK &E &NN>PW[N\"651 c8$affe.J.J.Lagg W]a  cc NN.TN:NN4dN+%jJ***+h6KI\\+h6K(;6I!1!1I^^I__I||7I%LS/8yy*5Q#a&56=#s:+u. 	x#~D1KS&J 6s   )!L	Lc                 f    |t        j                  | dfi |S t        j                  | dfd|i|S )NrR  rT  )r	   rW  r
   )util_code_namerT  r?  s      r   load_buffer_utilityr    s=    
EfEE!&&~z]7]V\]]r+   )max_dimsBufferStructDeclare)rT  BufferFormatStructsBufferIndexErrorBufferIndexErrorNogilBufferFallbackErrorBufferGetAndValidateBufferFormatCheckTypeInfoToFormat)r   r   r.   )?
__future__r   Visitorr   r   Errorsr   r	   r   Coder
   r  r   r   r   r   r   r   r   r{   rw   ry   r|   rz   r~   r   r   r   r   rs   r   rc  r   r   r   r   r   r   r   r   r  r  r$   r   r   r   r   r&   r6  rj  r   r  rX  rJ   rT  r  buffer_formats_declare_coder  r  r   r   buffer_format_check_code_typeinfo_to_format_coder   r+   r   <module>r     s   & $ "   * 1     V? Vv Gf$PUV"# 6 , 3 l4B'>JD& DN %
$L2l
1EP?AD5 *\p	k;;V ;|4Un^ //
001FPWX 12GH  ,,>? ,-DE 01FG *+A7S ./BGT  //AB r+   