o
    j                     @   s  d dl mZmZmZ ddlZz(ddlZeeeej	
ddd dk Zeeeej	
ddd dk ZW n eyE   dZd	Zd	ZY nw erKd
ZndZdd Zejdd Zd>ddZejdd Zdd Zdd Zejdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zedu rd%d& Znd'd& Zd(d) Zd*d+ Zejd?d,d-Z ejd.d/ Z!d0d1 Z"ejd2d3 Z#d4d5 Z$ejd6d7 Z%d8d9 Z&d:d; Z'd<d= Z(dS )@   )CTypeCTypedefTypeCStructOrUnionType    N.   )r   	      )r   r      T__builtin__builtinsc                 C   s(   | d u rdS t | dd }|o|ddS )NF
directivesZ
np_pythran)getattrget)envr    r   X/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/Cython/Compiler/Pythran.pyhas_np_pythran   s   r   c                 C   s   t | tr
t| jS | jS N)
isinstancer   is_pythran_supported_typeZtypedef_base_type
is_numerictype_r   r   r   is_pythran_supported_dtype   s   

r   ndarrayc                 C   s   | j rA| j| j}}t|tr|j}nt|tr| }nt|tr&|j	}nt
d| tr5d|||f S d||dd| f S | jrG| jS | jrN|  S t
d| t| f )Nzunsupported type %s!zpythonic::types::%s<%s,%d>z3pythonic::types::%s<%s,pythonic::types::pshape<%s>>,)longz unsupported pythran type %s (%s))Z	is_bufferndimdtyper   r   cnamer   sign_and_namer   Ztypedef_cname
ValueErrorpythran_is_pre_0_9joinis_pythran_exprpythran_typer   type)ZTyptyper   r   ctyper   r   r   r&   #   s"   



r&   c                 C   s   d|  S )Nz(typename std::remove_reference<%s>::typer   )tyr   r   r   type_remove_ref;   s   r+   c                 C   s2   | dkrdt |t |f S dt || t |f S )Nz**zSdecltype(pythonic::numpy::functor::power{}(std::declval<%s>(), std::declval<%s>()))z2decltype(std::declval<%s>() %s std::declval<%s>())r&   )opZtAZtBr   r   r   pythran_binop_type@   s   r.   c                 C   s   d| t |f S )Nzdecltype(%sstd::declval<%s>())r,   )r-   r   r   r   r   pythran_unaryop_typeI   s   r/   c                    s4   d  fdd|D }t|dkrd| S d| S )Nr   c                    s   g | ]} |qS r   r   ).0idx
index_coder   r   
<listcomp>P   s    z!_index_access.<locals>.<listcomp>r   z[%s]z(%s))r$   len)r3   indicesZindexingr   r2   r   _index_accessN   s   r7   c                 C   sf   | \}}|j rdt|jj  }dtddg| f S |jr%d|  S |jr-d|j	 S t
d| )Nr   z"pythonic::%s::functor::slice{}(%s)r   0std::declval<%s>()zunsupported indexing type %s!)is_sliceintstepis_nonepythran_builtinsr$   is_intr!   r%   r&   r"   )Zindex_with_typer1   Z
index_typenr   r   r   _index_type_codeT   s   
rA   c                 C   s~   | j r(| j| j| jf}| jjrd}|d d }nd}d|ddd |D f S | jjr0t| S | jj	r8| 
 S td| j )	NZcontiguous_slicer   slicezpythonic::types::%s(%s)r   c                 s   s    | ]}|  V  qd S r   )pythran_result)r0   vr   r   r   	<genexpr>k   s    z_index_code.<locals>.<genexpr>zunsupported indexing type %s)r:   startstopr<   r=   r$   r'   r?   
to_pythranr%   rC   r"   )r1   valuesfuncr   r   r   _index_codeb   s   rK   c                 C   s   t dt| tt|f S )Nzdecltype(std::declval<%s>()%s))r+   r&   r7   rA   )r   r6   r   r   r   pythran_indexing_types   s   rL   c                 C   s
   t t| S r   )r7   rK   )r6   r   r   r   pythran_indexing_codez   s   
rM   c                 C   s   | j sg S t| j| jg S r   )Zis_numpy_attributenp_func_to_listobj	attributerJ   r   r   r   rN   }   s   rN   c                 C   s   dS )NFr   )namer   r   r   pythran_is_numpy_func_supported   s   rS   c                 C   s<   t jjd }t| }|D ]}||d }|d u r dS qdS )NnumpyFT)pythranZtablesZMODULESrN   r   )rJ   ZCurFZFLFr   r   r   rS      s   c                 C   s0   t | } d| d d dg }d|| d f S )Nz::Zfunctorzpythonic::numpy::%s::%srN   r$   )rJ   Z
submodulesr   r   r   pythran_functor   s   rY   c                 C   s$   d dd |D }dt| |f S )Nr   c                 s   s    | ]
}d t |j V  qdS )r9   N)r&   r'   )r0   ar   r   r   rE      s    z$pythran_func_type.<locals>.<genexpr>zdecltype(%s{}(%s)))r$   rY   )rJ   argsr   r   r   pythran_func_type   s   r\   c                 C   s   | j }|jr||  S t|r(|  st| dd r(d|   d|   dS t|g dr3|  S | jr:dt	 S |d u rBt
|}| j jsHJ d||  f S )Nentryz	decltype(z){})r%   r   is_float
is_complexzpythonic::%s::Nonezfrom_python<%s>(%s))r'   r?   Z	cast_coderesultr%   Zresult_in_tempr   is_typer=   r>   r&   Zis_pyobjectZ	py_result)r-   r(   Zop_typer   r   r   rH      s   rH   c                 C   s    |D ]}t | |dr dS qdS )NFT)r   )r   typesattrr   r   r   rb      s
   rb   c                 C   s   | j pt| jS r   )r=   r   r'   )noder   r   r   !is_pythran_supported_node_or_none   s   rf   c                 C      d}t | |p
t| S )N)r%   r?   r   r_   r=   r`   rb   r%   r   Zpythran_supportedr   r   r   r      s   r   c                 C   rg   )N)r%   r?   r   r_   r`   rh   ri   r   r   r   #is_pythran_supported_operation_type   s   rj   c                 C   s   | j S r   )r%   r   r   r   r   r%      s   r%   c                 C   s"   | j ot| jo| jdv o| j S )N)cZstrided)Zis_numpy_bufferr   r   modecastr   r   r   r   is_pythran_buffer   s
   rn   c                 C   s   t | } dd|  S )Nzpythonic/numpy/%s.hpp/rX   rQ   r   r   r   pythran_get_func_include_file   s   rp   c                 C   s   |  d |  d |  d |  d |  d |  dt  |  d dD ]}|  d	|  |  d
|  q'dD ]	}|  d|  q:d S )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)
floatZfloat32Zfloat64setrB   tupler;   complexZ	complex64Z
complex128zpythonic/types/%s.hpp)Zadd_include_filer>   )r   itr   r   r   include_pythran_generic   s   





r{   )r   r   ))Z
PyrexTypesr   r   r   cythonrU   rw   mapr;   __version__splitr#   Zpythran_is_pre_0_9_6ImportErrorr>   r   Zccallr   r&   Zcfuncr+   r.   r/   r7   rA   rK   rL   rM   rN   rS   rY   r\   rH   rb   rf   r   rj   r%   rn   rp   r{   r   r   r   r   <module>   s^    "&


	

	


