ó
¦V]c           @@  sÏ  d  d l  m Z d d l m Z m Z m Z d  d l Z y> d  d l Z e e	 e
 e j j d ƒ d  d !ƒ ƒ d" k  Z Wn e k
 r• d Z e Z n Xd „  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 k r8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* d S(#   i    (   t   absolute_importi   (   t   CTypet   CTypedefTypet   CStructOrUnionTypeNt   .i   i	   c         C@  s8   |  d  k r t St |  d d  ƒ } | o7 | j d t ƒ S(   Nt
   directivest
   np_pythran(   t   Nonet   Falset   getattrt   get(   t   envR   (    (    s6   lib/python2.7/site-packages/Cython/Compiler/Pythran.pyt   has_np_pythran   s    c         C@  s#   t  |  t ƒ r t |  j ƒ S|  j S(   N(   t
   isinstanceR   t   is_pythran_supported_typet   typedef_base_typet
   is_numeric(   t   type_(    (    s6   lib/python2.7/site-packages/Cython/Compiler/Pythran.pyt   is_pythran_supported_dtype   s    t   ndarrayc         C@  sû   |  j  r¸ |  j |  j } } t | t ƒ r7 | j } nI t | t ƒ rU | j ƒ  } n+ t | t ƒ rp | j	 } n t
 d | ƒ ‚ t r— d | | | f Sd | | d j d | ƒ f Sn  |  j rÈ |  j S|  j rÛ |  j ƒ  St
 d |  t |  ƒ f ƒ ‚ d  S(   Ns   unsupported type %s!s   pythonic::types::%s<%s,%d>s3   pythonic::types::%s<%s,pythonic::types::pshape<%s>>t   ,t   longs    unsupported pythran type %s (%s)(   R   (   t	   is_buffert   ndimt   dtypeR   R   t   cnameR   t   sign_and_nameR   t   typedef_cnamet
   ValueErrort   pythran_is_pre_0_9t   joint   is_pythran_exprt   pythran_typeR   t   type(   t   Tyt   ptypeR   R   t   ctype(    (    s6   lib/python2.7/site-packages/Cython/Compiler/Pythran.pyR        s"    	!		
c         C@  s   d |  S(   Ns(   typename std::remove_reference<%s>::type(    (   t   ty(    (    s6   lib/python2.7/site-packages/Cython/Compiler/Pythran.pyt   type_remove_ref8   s    c         C@  sG   |  d k r& d t  | ƒ t  | ƒ f Sd t  | ƒ |  t  | ƒ f Sd  S(   Ns   **sS   decltype(pythonic::numpy::functor::power{}(std::declval<%s>(), std::declval<%s>()))s2   decltype(std::declval<%s>() %s std::declval<%s>())(   R    (   t   opt   tAt   tB(    (    s6   lib/python2.7/site-packages/Cython/Compiler/Pythran.pyt   pythran_binop_type=   s
    c         C@  s   d |  t  | ƒ f S(   Ns   decltype(%sstd::declval<%s>())(   R    (   R'   R   (    (    s6   lib/python2.7/site-packages/Cython/Compiler/Pythran.pyt   pythran_unaryop_typeF   s    c         C@  sH   d j  g  | D] } |  | ƒ ^ q ƒ } t | ƒ d k r@ d n d | S(   NR   i   s   [%s]s   (%s)(   R   t   len(   t
   index_codet   indicest   idxt   indexing(    (    s6   lib/python2.7/site-packages/Cython/Compiler/Pythran.pyt   _index_accessK   s    (c         C@  sƒ   |  \ } } | j  rD d t | j j ƒ } d d j d g | ƒ S| j r[ d | j ƒ  S| j ro d | j St	 d | ƒ ‚ d  S(   Ni   s+   pythonic::__builtin__::functor::slice{}(%s)R   t   0s   std::declval<%s>()s   unsupported indexing type %s!(
   t   is_slicet   intt   stept   is_noneR   t   is_intR   R   R    R   (   t   index_with_typeR/   t
   index_typet   n(    (    s6   lib/python2.7/site-packages/Cython/Compiler/Pythran.pyt   _index_type_codeQ   s    			c         C@  sª   |  j  rg |  j |  j |  j f } |  j j r@ d } | d  } n d } d | d j d „  | Dƒ ƒ f S|  j j r} t |  ƒ S|  j j	 r“ |  j
 ƒ  St d |  j ƒ ‚ d  S(   Nt   contiguous_slicei   t   slices   pythonic::types::%s(%s)R   c         s@  s   |  ] } | j  ƒ  Vq d  S(   N(   t   pythran_result(   t   .0t   v(    (    s6   lib/python2.7/site-packages/Cython/Compiler/Pythran.pys	   <genexpr>f   s    s   unsupported indexing type %s(   R3   t   startt   stopR5   R6   R   R!   R7   t
   to_pythranR   R>   R   (   R/   t   valuest   func(    (    s6   lib/python2.7/site-packages/Cython/Compiler/Pythran.pyt   _index_code]   s    	

c         C@  s#   t  d t |  ƒ t t | ƒ f ƒ S(   Ns   decltype(std::declval<%s>()%s)(   R&   R    R1   R;   (   R   R.   (    (    s6   lib/python2.7/site-packages/Cython/Compiler/Pythran.pyt   pythran_indexing_typen   s    	c         C@  s   t  t |  ƒ S(   N(   R1   RF   (   R.   (    (    s6   lib/python2.7/site-packages/Cython/Compiler/Pythran.pyt   pythran_indexing_codeu   s    c         C@  s$   |  j  s g  St |  j ƒ |  j g S(   N(   t   is_numpy_attributet   np_func_to_listt   objt	   attribute(   RE   (    (    s6   lib/python2.7/site-packages/Cython/Compiler/Pythran.pyRJ   x   s    	c         C@  s   t  S(   N(   R   (   t   name(    (    s6   lib/python2.7/site-packages/Cython/Compiler/Pythran.pyt   pythran_is_numpy_func_supported~   s    c         C@  sS   t  j j d } t |  ƒ } x0 | D]( } | j | d  ƒ } | d  k r# t Sq# Wt S(   Nt   numpy(   t   pythrant   tablest   MODULESRJ   R
   R   R   t   True(   RE   t   CurFt   FLt   F(    (    s6   lib/python2.7/site-packages/Cython/Compiler/Pythran.pyRN      s    c         C@  s8   t  |  ƒ }  d j |  d  d g ƒ } d | |  d f S(   Ns   ::iÿÿÿÿt   functors   pythonic::numpy::%s::%s(   RJ   R   (   RE   t
   submodules(    (    s6   lib/python2.7/site-packages/Cython/Compiler/Pythran.pyt   pythran_functorŠ   s    c         C@  s-   d j  d „  | Dƒ ƒ } d t |  ƒ | f S(   NR   c         s@  s"   |  ] } d  t  | j ƒ Vq d S(   s   std::declval<%s>()N(   R    R!   (   R?   t   a(    (    s6   lib/python2.7/site-packages/Cython/Compiler/Pythran.pys	   <genexpr>   s    s   decltype(%s{}(%s))(   R   RY   (   RE   t   args(    (    s6   lib/python2.7/site-packages/Cython/Compiler/Pythran.pyt   pythran_func_type   s    c         C@  s˜   |  j  } | j r% | j |  j ƒ  ƒ St | d d d d g ƒ rJ |  j ƒ  S|  j rW d S| d  k rr t | ƒ } n  |  j  j s„ t	 ‚ d | |  j
 ƒ  f S(   NR   R   t   is_floatt
   is_complexs   pythonic::__builtin__::Nones   from_python<%s>(%s)(   R!   R7   t	   cast_codet   resultt   is_typeR6   R   R    t   is_pyobjectt   AssertionErrort	   py_result(   R'   R#   t   op_type(    (    s6   lib/python2.7/site-packages/Cython/Compiler/Pythran.pyRC   ”   s    		
	c         C@  s+   x$ | D] } t  |  | t ƒ r t Sq Wt S(   N(   R	   R   RS   (   R   t   typest   attr(    (    s6   lib/python2.7/site-packages/Cython/Compiler/Pythran.pyRa   ¥   s    c         C@  s   |  j  p t |  j ƒ S(   N(   R6   R   R!   (   t   node(    (    s6   lib/python2.7/site-packages/Cython/Compiler/Pythran.pyt!   is_pythran_supported_node_or_none­   s    c         C@  s   d } t  |  | ƒ p t |  ƒ S(   NR   R7   R   R]   R6   R^   (   R   R7   R   R]   R6   R^   (   Ra   R   (   R   t   pythran_supported(    (    s6   lib/python2.7/site-packages/Cython/Compiler/Pythran.pyR   ±   s    c         C@  s   d } t  |  | ƒ p t |  ƒ S(   NR   R7   R   R]   R^   (   R   R7   R   R]   R^   (   Ra   R   (   R   Rj   (    (    s6   lib/python2.7/site-packages/Cython/Compiler/Pythran.pyt#   is_pythran_supported_operation_type¸   s    c         C@  s   |  j  S(   N(   R   (   R   (    (    s6   lib/python2.7/site-packages/Cython/Compiler/Pythran.pyR   ¾   s    c         C@  s/   |  j  o. t |  j ƒ o. |  j d k o. |  j S(   Nt   ct   strided(   Rl   Rm   (   t   is_numpy_bufferR   R   t   modet   cast(   R   (    (    s6   lib/python2.7/site-packages/Cython/Compiler/Pythran.pyt   is_pythran_bufferÃ   s    c         C@  s   t  |  ƒ }  d d j |  ƒ S(   Ns   pythonic/numpy/%s.hppt   /(   RJ   R   (   RE   (    (    s6   lib/python2.7/site-packages/Cython/Compiler/Pythran.pyt   pythran_get_func_include_fileÇ   s    c      
   C@  s´   |  j  d ƒ |  j  d ƒ |  j  d ƒ |  j  d ƒ |  j  d ƒ |  j  d ƒ |  j  d ƒ x0 d D]( } |  j  d | ƒ |  j  d | ƒ qb Wx d D] } |  j  d | ƒ q• Wd  S(   Ns   pythonic/core.hpps   pythonic/python/core.hpps   pythonic/types/bool.hpps   pythonic/types/ndarray.hpps   pythonic/numpy/power.hpps   pythonic/__builtin__/slice.hpps   <new>i   i   i    i@   s   pythonic/types/uint%d.hpps   pythonic/types/int%d.hppt   floatt   float32t   float64t   setR=   t   tupleR4   t   complext	   complex64t
   complex128s   pythonic/types/%s.hpp(   i   i   i    i@   (
   Rt   Ru   Rv   Rw   R=   Rx   R4   Ry   Rz   R{   (   t   add_include_file(   R   t   it   t(    (    s6   lib/python2.7/site-packages/Cython/Compiler/Pythran.pyt   include_pythran_genericË   s    
(   i    i	   (+   t
   __future__R    t
   PyrexTypesR   R   R   t   cythonRP   Rx   t   mapR4   t   __version__t   splitR   t   ImportErrorR   RS   R   t   ccallR   R    t   cfuncR&   R*   R+   R1   R;   RF   RG   RH   RJ   RN   RY   R\   RC   Ra   Ri   R   Rk   R   Rq   Rs   R   (    (    (    s6   lib/python2.7/site-packages/Cython/Compiler/Pythran.pyt   <module>   sF   2
																	