
    Aec                        d dl mZ ddlmZmZmZ d dlZ	 d dlZ e e	e
ej                  j                  d      d d             dk  Z e e	e
ej                  j                  d      d d             d	k  ZerdZndZd Zej$                  d        Zd&dZej*                  d        Zd Zd Zej*                  d        Zd Zd Zd Zd Zd Zed Znd Zd Z d Z!ej$                  d'd       Z"ej*                  d        Z#d Z$ej$                  d         Z%d! Z&ej$                  d"        Z'd# Z(d$ Z)d% Z*y# e$ r	 dZd
Zd
ZY w xY w)(    )absolute_import   )CTypeCTypedefTypeCStructOrUnionTypeN.   )r   	      )r   r
      T__builtin__builtinsc                 N    | yt        | dd       }|xr |j                  dd      S )NF
directives
np_pythran)getattrget)envr   s     7lib/python3.12/site-packages/Cython/Compiler/Pythran.pyhas_np_pythranr      s.    
{lD1J>:>>,>?    c                 d    t        | t              rt        | j                        S | j                  S N)
isinstancer   is_pythran_supported_typetypedef_base_type
is_numerictype_s    r   is_pythran_supported_dtyper        s)    %&()@)@AAr   c           	         | j                   r| j                  | j                  }}t        |t              r|j
                  }nLt        |t              r|j                         }n+t        |t              r|j                  }nt        d|z        t        rd|||fz  S d|d|ddj                  d|z        dS | j                  r| j                  S | j                  r| j                         S t        d	| d
t!        |       d      )Nzunsupported type %s!zpythonic::types::%s<%s,%d>pythonic::types::<z,pythonic::types::pshape<,)longz>>zunsupported pythran type z ())	is_bufferndimdtyper   r   cnamer   sign_and_namer   typedef_cname
ValueErrorpythran_is_pre_0_9joinis_pythran_exprpythran_typer   type)Typtyper(   r)   ctypes        r   r1   r1   '   s    	||WWbhhUe/0KKEu%'')E|,''E3e;<</52EEE  MRRWY\YaYabklpbpYqrr	 
}}!!
2tBxH
IIr   c                     d| z  S )Nz(typename std::remove_reference<%s>::type )tys    r   type_remove_refr9   ?   s    5::r   c                 ~    | dk(  rdt        |      dt        |      dS dt        |      d| dt        |      dS )	Nz**z8decltype(pythonic::numpy::functor::power{}(std::declval<z>(), std::declval<z>()))decltype(std::declval<z>() z std::declval<>())r1   )optAtBs      r   pythran_binop_typerA   D   sD    	Tzl2.0 	0 
 b,r"24 	4r   c                 &    d| dt        |      dS )N	decltype(zstd::declval<r<   r=   )r>   r   s     r   pythran_unaryop_typerD   M   s    
L! !r   c                     dj                  |D cg c]
  } | |       c}      }t        |      dk(  rd|z  S d|z  S c c}w )Nr$   r   z[%s]z(%s))r/   len)
index_codeindicesidxindexings       r   _index_accessrK   R   sD    xxG<SC<=H'la'Fx??Vx?? =s   >c                 :   | \  }}|j                   rCdt        |j                  j                         z   }dt        ddj                  dg|z        dS |j                  rd|j                         z  S |j                  rd|j                  z  S t        d|z        )	Nr	   z
pythonic::z::functor::slice{}(r$   0r&   std::declval<%s>()zunsupported indexing type %s!)is_sliceintstepis_nonepythran_builtinsr/   is_intr+   r0   r1   r-   )index_with_typerI   
index_typens       r   _index_type_coderX   X   s    %OC
||((())HHcU1W 	 
		#j&>&>&@@@		#	##j&=&===
4zA
BBr   c                    | j                   rb| j                  | j                  | j                  f}| j                  j                  rd}|d d }nd}d|ddj                  d |D              dS | j                  j                  rt        |       S | j                  j                  r| j                         S t        d	| j                  z        )
Ncontiguous_slicer	   slicer"   (r$   c              3   <   K   | ]  }|j                           y wr   )pythran_result).0vs     r   	<genexpr>z_index_code.<locals>.<genexpr>o   s     ?1A,,.?s   r&   zunsupported indexing type %s)rO   startstoprQ   rR   r/   r2   rT   
to_pythranr0   r^   r-   )rI   valuesfuncs      r   _index_coderg   f   s    
||CHHchh.88%DBQZFD#((??@B 	B	#		!	!!!##
3chh>
??r   c           	      T    t        dt        |       dt        t        |      d      S )Nr;   z>()r&   )r9   r1   rK   rX   )r   rH   s     r   pythran_indexing_typeri   w   s'    U&0  r   c                 "    t        t        |       S r   )rK   rg   )rH   s    r   pythran_indexing_coderk   ~   s    g..r   c                 d    | j                   sg S t        | j                        | j                  gz   S r   )is_numpy_attributenp_func_to_listobj	attributerf   s    r   rn   rn      s+    ""	488$'777r   c                      y)NFr7   )names    r   pythran_is_numpy_func_supportedrt      s    r   c                     t         j                  j                  d   }t        |       }|D ]  }|j	                  |d       }| y y)NnumpyFT)pythrantablesMODULESrn   r   )rf   CurFFLFs       r   rt   rt      sL    ~~%%g.T" 	A88At$D|	 r   c                 ^    t        |       } dj                  | d d dgz         }d|d| d   S )Nz::functorzpythonic::numpy::rn   r/   )rf   
submoduless     r   pythran_functorr      s6    4 D49	{23J(2DH==r   c                 V    dj                  d |D              }dt        |       d|dS )Nr$   c              3   L   K   | ]  }d t        |j                        z    yw)rN   N)r1   r2   )r_   as     r   ra   z$pythran_func_type.<locals>.<genexpr>   s     OQ)L,@@Os   "$rC   z{}(z)))r/   r   )rf   argss     r   pythran_func_typer      s&    88O$OPD#24#8$??r   c                 N   | j                   }|j                  r|j                  | j                               S t	        |g d      r| j                         S | j
                  r	dt        z  S |t        |      }| j                   j                  sJ d|d| j                         dS )N)r0   r   is_float
is_complexzpythonic::%s::Nonezfrom_python<z>(r&   )
r2   rT   	cast_coderesultis_typerR   rS   r1   is_pyobject	py_result)r>   r4   op_types      r   rd   rd      s    ggG~~  --wSTyy{	zz#&666}W%77$)2<<>::r   c                 0    |D ]  }t        | |d      s y y)NFT)r   )r   typesattrs      r   r   r      s%     5$& r   c                 H    | j                   xs t        | j                        S r   )rR   r   r2   )nodes    r   !is_pythran_supported_node_or_noner      s    <<?4TYY??r   c                 8    d}t        | |      xs t        |       S )N)r0   rT   r   r   rR   r   r   r0   r   pythran_supporteds     r   r   r      s#    X5+,F0FFr   c                 8    d}t        | |      xs t        |       S )N)r0   rT   r   r   r   r   r   s     r   #is_pythran_supported_operation_typer      s#    M5*+Eu/EEr   c                     | j                   S r   )r0   r   s    r   r0   r0      s       r   c                     | j                   xr4 t        | j                        xr | j                  dv xr | j                   S )N)cstrided)is_numpy_bufferr    r)   modecastr   s    r   is_pythran_bufferr      sA    !! >&@&M >JJ**>38::~?r   c                 @    t        |       } ddj                  |       z  S )Nzpythonic/numpy/%s.hpp/r   rq   s    r   pythran_get_func_include_filer      s    4 D"SXXd^33r   c                    | j                  d       | j                  d       | j                  d       | j                  d       | j                  d       | j                  dt        z         | j                  d       dD ]*  }| j                  d	|z         | j                  d
|z         , dD ]  }| j                  d|z          y )Nzpythonic/core.hppzpythonic/python/core.hppzpythonic/types/bool.hppzpythonic/types/ndarray.hppzpythonic/numpy/power.hppzpythonic/%s/slice.hppz<new>)          @   zpythonic/types/uint%d.hppzpythonic/types/int%d.hpp)
floatfloat32float64setr[   tuplerP   complex	complex64
complex128zpythonic/types/%s.hpp)add_include_filerS   )r   its      r   include_pythran_genericr      s    ,-3423563403CCD! =81<=7!;<=4 :4q89:r   )ndarrayr   )+
__future__r   
PyrexTypesr   r   r   cythonrw   r   maprP   __version__splitr.   pythran_is_pre_0_9_6ImportErrorrS   r   ccallr    r1   cfuncr9   rA   rD   rK   rX   rg   ri   rk   rn   rt   r   r   rd   r   r   r   r   r0   r   r   r   r7   r   r   <module>r      s   ' ? ?  s3(;(;(A(A#(Fq(KLMPVV S'*=*=*C*CC*H1*M!NOR[[ $!
@  J0 ; ;4!
 @ @
C@"/8
 ?>
@
 ; ;   @ G GF ! !?4:O   G s   A D7 7EE