
V]c           @@  s  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 d e f d     YZ d@ Z i d d 6d d 6e d 6e d 6Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d? e d  Z! d e" f d      YZ# 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-   Z0 d.   Z1 d/   Z2 d0 e" f d1     YZ3 d2   Z4 d? d3  Z5 d? d4  Z6 e7 d5 e j8  Z9 e6 d6 d7 e9 Z: e6 d8  Z; e6 d9  Z< e6 d:  Z= e6 d;  Z> e6 d< d7 e9 Z? e6 d= d7 e9 Z@ e6 d>  ZA d? S(A   i    (   t   absolute_importi   (   t   CythonTransform(   t
   ModuleNode(   t   CompileError(   t   CythonUtilityCode(   t   UtilityCodet   TempitaUtilityCode(   t   Options(   t   Interpreter(   t
   PyrexTypes(   t   Naming(   t   Symtabc         C@  sh   d d l  m } | |   }  | d k rd d | } d j g  |  j d  D] } | | ^ qH  }  n  |  S(   Ni    (   t   dedentt    s   
(   t   textwrapR   t   joint   split(   t   textt   reindentR   t   indentt   x(    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyR      s    
2t   IntroduceBufferAuxiliaryVarsc           B@  s8   e  Z e Z e Z d    Z d   Z d   Z d   Z RS(   c         C@  s`   t  | t  s t  d |  _ t t |   j |  } |  j r\ t | j	  t
 | j	  n  | S(   Ni    (   t
   isinstanceR   t   AssertionErrort   max_ndimt   superR   t   __call__t   buffers_existst   use_bufstruct_declare_codet   scopet   use_py2_buffer_functions(   t   selft   nodet   result(    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyR       s    		c         @  sZ   j  j   } g  | D] \      j j r   ^ q } t |  d k rk | j d d    t |  _ n  g  | D] \      j j rr   ^ qr } t |  d k r t |  _ n  x? | D]7 \     d k r t	   j
 t  r t |  _ Pq q W~ t	  t  r/t |  d k r/t  j d   n  x| D]
    j j j r`t  j d   n    j    j } | j t j k rt  j d t j   n  | j |  j k r| j |  _ n       f d   } t j t j f t j t j f f } g  | D] \ }	 }
 | |	 |
  ^ q\ } } t j | |    _ q6W|  _   |  _! d  S(	   Ni    t   keyc         S@  s   |  j  S(   N(   t   name(   t   entry(    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyt   <lambda>5   t    t
   memoryviews'   Buffer vars not allowed in module scopes-   Buffers with pointer types not yet supported.s1   Buffer ndims exceeds Options.buffer_max_dims = %dc      	   @  sR    j  |   }  j d d  d | d |  d  j  }   j rN t | _ n  | S(   NR#   t   cnamet   typet   pos(   t   manglet   declare_vart   NoneR*   t   is_argt   Truet   used(   R)   t   prefixR(   t   aux_var(   R$   R#   R    R   (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyt   decvarS   s    	("   t   entriest   itemsR)   t	   is_buffert   lent   sortR/   R   t   is_memoryviewsliceR   t   utility_code_definitionR   t   using_memoryviewR   R   R*   t   dtypet   is_ptrR#   t   ndimR   t   buffer_max_dimsR   R	   t   c_pyx_buffer_nd_typeR
   t   pybuffernd_prefixt   c_pyx_buffer_typet   pybufferstruct_prefixR   t	   BufferAuxt
   buffer_auxt   buffer_entriesR   (   R   R    R   t   scope_itemst   bufvarst   memviewslicevarst   buftypeR3   t   auxvarsR)   R1   t
   pybufferndt   rcbuffer(    (   R$   R#   R    R   s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyt   handle_scope.   s@    ++	!				.	c         C@  s$   |  j  | | j  |  j |  | S(   N(   RN   R   t   visitchildren(   R   R    (    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyt   visit_ModuleNodee   s    c         C@  s$   |  j  | | j  |  j |  | S(   N(   RN   t   local_scopeRO   (   R   R    (    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyt   visit_FuncDefNodej   s    (	   t   __name__t
   __module__t   FalseR   R;   R   RN   RP   RR   (    (    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyR      s   		7	R<   R>   t   modet   negative_indicest   castt   fulls   "%s" is not a buffer options   Too many buffer optionss#   "%s" buffer option already supplieds   "%s" missings[   Only allowed buffer modes are: "c", "fortran", "full", "strided" (as a compile-time string)s#   ndim must be a non-negative integers0   dtype must be "object", numeric type or a structs   "%s" must be a booleanc         @  s`  | d k r t } n  t j | | d | d d \ } } t |  t k re t | d d t   n  i   xL | j   D]> \ } \ } } | t	 k r t | t
 |   n  |  | <qx Wxq t t	 |  D]` \ } \ } } | t	 k r t | t
 |   n  |  k r t | t |   n  |  | <q Wx_ t	 D]W } |  k r5y | |  | <Wqt k
 r| rt   t |   qqXq5q5W j d  }	 |	 r|	 j rt   t   n   j d  }
 |
 rt |
 t  s|
 d k  rt   t   n   j d  } | r6| d k r6t   t   n     f d   } | d  | d   S(   sO  
    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).
    t   type_envt	   type_argsi    R<   ii   R>   RV   RY   t   stridedt   ct   fortranc         @  s8    j  |   } t | t  s4 t   t |    n  d  S(   N(   t   getR   t   boolR   t   ERR_BUF_BOOL(   R#   R   (   t	   globalpost   options(    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyt   assert_bool   s    RW   RX   N(   i    R<   (   RY   R\   R]   R^   (   R-   t   buffer_defaultsR   t   interpret_compiletime_optionsR7   t   buffer_positional_options_countR   t   ERR_BUF_TOO_MANYR5   t   buffer_optionst   ERR_BUF_OPTION_UNKNOWNt   zipt   ERR_BUF_DUPt   KeyErrort   ERR_BUF_MISSINGR_   t   is_extension_typet   ERR_BUF_DTYPER   t   intt   ERR_BUF_NDIMt   ERR_BUF_MODE(   Rb   t   envt   posargst   dictargst   defaultst   need_completeR#   t   valueR*   R<   R>   RV   Rd   (    (   Rb   Rc   s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyt   analyse_buffer_options   sJ    	"!"

t   BufferEntryc           B@  sG   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   c         C@  sT   | |  _  | j |  _ | j j j |  _ d |  j |  _ | j j |  _ |  j   d  S(   Ns   %s.rcbuffer->pybuffer.buf(	   R$   R)   RE   t   buflocal_nd_varR(   t   buf_ptrt   buffer_ptr_typet   buf_ptr_typet   init_attributes(   R   R$   (    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyt   __init__   s    	c         C@  s1   |  j    |  _ |  j   |  _ |  j   |  _ d  S(   N(   t   get_buf_shapevarst   shapet   get_buf_stridevarst   stridest   get_buf_suboffsetvarst
   suboffsets(   R   (    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyR      s    c         C@  s   |  j  d  S(   Ns   %s.diminfo[%d].suboffsets(   t   _for_all_ndim(   R   (    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyR      s    c         C@  s   |  j  d  S(   Ns   %s.diminfo[%d].strides(   R   (   R   (    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyR      s    c         C@  s   |  j  d  S(   Ns   %s.diminfo[%d].shape(   R   (   R   (    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyR      s    c         C@  s0   g  t  |  j j  D] } | |  j | f ^ q S(   N(   t   rangeR)   R>   R(   (   R   t   st   i(    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyR      s    c         C@  s  g  } |  j  j } |  j  j } | d k r xV t | |  j   |  j    D]6 \ } } } | j |  | j |  | j |  qI Wd | }	 t }
 n | d k r d | }	 t }
 nJ | d k r d | }	 t	 }
 n+ | d k r d | }	 t
 }
 n t s t  x= t | |  j    D]& \ } } | j |  | j |  qW|	 | j j k r| j j j |	  | j d	 } | j d
 } |
 | | d |	 d | n  |  j j   } d |	 | |  j d j |  f } | S(   NRY   s   __Pyx_BufPtrFull%ddR\   s   __Pyx_BufPtrStrided%ddR]   s   __Pyx_BufPtrCContig%ddR^   s   __Pyx_BufPtrFortranContig%ddt   utility_code_protot   utility_code_defR#   t   nds   %s(%s, %s, %s)s   , (   R)   R>   RV   Rk   R   R   t   appendt   buf_lookup_full_codet   buf_lookup_strided_codet   buf_lookup_c_codet   buf_lookup_fortran_codeRU   R   t   globalstatet   utility_codest   addR   t   empty_declaration_codeR}   R   (   R   t   codet   index_cnamest   paramsR   RV   R   R   t   ot   funcnamet   funcgent	   protocodet   defcodet   buf_ptr_type_codet   ptrcode(    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyt   generate_buffer_lookup_code   sD    		
	
	
	
	"(	   RS   RT   R   R   R   R   R   R   R   (    (    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyR{      s   						c         C@  s   d } | j  } | d k r( | d 7} nW | d k rA | d 7} n> | d k rZ | d 7} n% | d k rs | d	 7} n t s t  |  j r | d
 7} n  | S(   Nt   PyBUF_FORMATRY   s   | PyBUF_INDIRECTR\   s   | PyBUF_STRIDESR]   s   | PyBUF_C_CONTIGUOUSR^   s   | PyBUF_F_CONTIGUOUSs   | PyBUF_WRITABLE(   RV   RU   R   t   writable_needed(   RE   t   buffer_typet   flagsRV   (    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyt	   get_flags  s    		 c         C@  s%   |  j  } t | j _ t | j _ d  S(   N(   RE   R/   R|   R0   t	   rcbuf_var(   R$   RE   (    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyt   used_buffer_aux_vars  s    	c   	   
   C@  s   |  j  |  j j } } | j j } d d g } | d k rJ | j d  n  g  } xN t |  j j  D]: } x1 | D]) } | j d | | | | | | f  qp Wqc W| j d j	 |   d  S(   NR   R   RY   R   s1   %s.diminfo[%d].%s = %s.rcbuffer->pybuffer.%s[%d];R   (
   RE   R)   RV   R|   R(   R   R   R>   t   putlnR   (	   t	   buf_entryR   RE   RV   t   pybuffernd_structt   fldnamest   lnR   t   fldname(    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyt    put_unpack_buffer_aux_into_scope   s    		c         C@  so   |  j  } | j j } | j j } | j d |  | j d |  | j d |  | j d | | f  d  S(   Ns   %s.pybuffer.buf = NULL;s   %s.refcount = 0;s   %s.data = NULL;s   %s.rcbuffer = &%s;(   RE   R|   R(   R   R   (   R$   R   t   bufauxR   t   pybuffer_struct(    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyt   put_init_vars2  s    	c         C@  s   |  j  } t | |  j | |  j  } | j d  | j d |  j j j    | j | j d | |   | j d  t |  |  d  S(   Nt   {s'   __Pyx_BufFmt_StackElem __pyx_stack[%d];s   %s == -1t   }(	   RE   t   get_getbuffer_callR(   R)   R   R<   t   struct_nesting_deptht   error_goto_ifR   (   R$   R   R*   RE   t	   getbuffer(    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyt   put_acquire_arg_buffer@  s    	c         C@  s.   |  j  j t  |  j d | j j j  d  S(   Ns0   __Pyx_SafeReleaseBuffer(&%s.rcbuffer->pybuffer);(   R   t   use_utility_codet   acquire_utility_codeR   RE   R|   R(   (   R   R$   (    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyt   put_release_buffer_codeN  s    c   	      C@  s`   | j  } t | j  } t | |  } | j j } t |  | j  } |  j j	 t
  d t   S(   Ns   __Pyx_GetBufferAndValidate(&%(pybuffernd_struct)s.rcbuffer->pybuffer, (PyObject*)%(obj_cname)s, &%(dtype_typeinfo)s, %(flags)s, %(ndim)d, %(cast)d, __pyx_stack)(   R>   Rq   RX   R   R|   R(   t   get_type_information_cnameR<   R   R   R   t   locals(	   R   t	   obj_cnameRE   R   R>   RX   R   R   t   dtype_typeinfo(    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyR   S  s    	c         @  s  | j  | j } } | j j } t | |  }	   j d    j d | j j    t   d | |  }
 | r  j d |    j	 j
 t j d t }   j d | |
 | f    j d   j d |   t   f d	   t d
  D  }   j d |    j d   j d |
 |      j d |    j j t    j d    j d    j d |    j d    j d |  x | D] }   j	 j |  qW  j d  t |      j   j | |     j	 j |  n   j d   j d |
 |     j d |  t j | t j d  | f    j   j |     j d  t |      j d    j d  d S(   sJ  
    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   s'   __Pyx_BufFmt_StackElem __pyx_stack[%d];s   %ss0   __Pyx_SafeReleaseBuffer(&%s.rcbuffer->pybuffer);t
   manage_refs   %s = %s;s	   if (%s) {s   %s < 0c         3@  s*   |  ]  }   j  j t j d  t Vq d S(   R   N(   t	   funcstatet   allocate_tempR	   t   py_object_typeRU   (   t   .0t   _(   R   (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pys	   <genexpr>  s   i   s   PyErr_Fetch(&%s, &%s, &%s);s   %s == -1s/   Py_XDECREF(%s); Py_XDECREF(%s); Py_XDECREF(%s);s!   __Pyx_RaiseBufferFallbackError();s   } else {s   PyErr_Restore(%s, %s, %s);R   s   %s = %s = %s = 0;sA   %s = %s; __Pyx_INCREF(Py_None); %s.rcbuffer->pybuffer.buf = NULL;t   Py_NoneN(   RE   R)   R|   R(   R   R   R<   R   R   R   R   R	   t
   c_int_typeRU   t   unlikelyt   tupleR   R   R   t   raise_buffer_fallback_codet   release_tempR   t   error_goto_if_negt   typecastR   t
   error_gotot   put(   t	   lhs_cnamet	   rhs_cnameR   t   is_initializedR*   R   RE   R   R   R   R   t   retcode_cnamet	   exc_tempst   t(    (   R   s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyt   put_assign_to_buffera  sL    ""	c         C@  sb  | d o | } | d r| j  j t j d t } | j d |  xt t | | |  j     D] \ }	 \ }
 } } |
 d k r| j d |  | r | j d | | f  | j d | j	 d	 |  | |	 f  n | j d
 | |	 f  | j
 d  n  |
 d k rd } n d } | j d | j	 d | | | f  | |	 f  qe W| rs| j j t  d } n | j j t  d } | j d | j	 d |   | j d | | f  | j | j |   | j d  | j  j |  n^ | rRxU t | | |  j    D]8 \ }
 } } |
 d k r| j d | | | f  qqWn  |  j | |  S(   se  
    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
    t
   wraparoundt   boundscheckR   s   %s = -1;i    s   if (%s < 0) {s	   %s += %s;s   if (%s) %s = %d;s   %s < 0s   %s = %d;s   } else R&   s   (size_t)s
   %s >= %s%st    __Pyx_RaiseBufferIndexErrorNogilt   __Pyx_RaiseBufferIndexErrors	   if (%s) {s   %s != -1s   %s(%s);R   s   if (%s < 0) %s += %s;(   R   R   R	   R   RU   R   t	   enumerateRk   R   R   R   R   R   t   raise_indexerror_nogilt   raise_indexerror_codeR   R   R   (   R$   t   index_signedsR   t
   directivesR*   R   RW   t   in_nogil_contextt   failed_dim_tempt   dimt   signedR(   R   RX   t   func(    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyt   put_buffer_lookup_code  sF    
4				($c         C@  s   |  j  t  d  S(   N(   R   t   buffer_struct_declare_code(   Rt   (    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyR     s    c      
   C@  s   d j  g  t |  D] } d | | | f ^ q  } |  j d | | | | f  d j  g  t |  D] } d | | | f ^ qe  } |  j d | | f  | j t d  | | f d j  g  t |  D]" } t d  | | | | f ^ q  d	  d
 S(   s   
    Generates a buffer lookup function for the right number
    of dimensions. The function gives back a void* at the right location.
    s   , s   i%d, s%d, o%ds1   #define %s(type, buf, %s) (type)(%s_imp(buf, %s))s.   Py_ssize_t i%d, Py_ssize_t s%d, Py_ssize_t o%ds1   static CYTHON_INLINE void* %s_imp(void* buf, %s);sf   
        static CYTHON_INLINE void* %s_imp(void* buf, %s) {
          char* ptr = (char*)buf;
        R&   sX             ptr += s%d * i%d;
          if (o%d >= 0) ptr = *((char**)ptr) + o%d;
        s   
return ptr;
}N(   R   R   R   R   (   t   protot   definR#   R   R   t	   macroargst   funcargs(    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyR     s    55c         C@  s   d j  g  t |  D] } d | | f ^ q  } d j  g  t |  D] } d | | f ^ qE  } |  j d | | | f  d S(   s   
    Generates a buffer lookup function for the right number
    of dimensions. The function gives back a void* at the right location.
    s   , s   i%d, s%ds    + s	   i%d * s%ds1   #define %s(type, buf, %s) (type)((char*)buf + %s)N(   R   R   R   (   R   R   R#   R   R   t   argst   offset(    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyR     s    22c         C@  s   | d k r  |  j  d |  n d j g  t |  D] } d | | f ^ q3  } d j g  t | d  D] } d | | f ^ qi  } |  j  d | | | | d f  d S(	   s   
    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.
    i   s.   #define %s(type, buf, i0, s0) ((type)buf + i0)s   , s   i%d, s%ds    + s	   i%d * s%ds9   #define %s(type, buf, %s) ((type)((char*)buf + %s) + i%d)N(   R   R   R   (   R   R   R#   R   R   R   R   (    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyR     s
    26c         C@  s   | d k r  |  j  d |  n d j g  t |  D] } d | | f ^ q3  } d j g  t d |  D] } d | | f ^ qh  } |  j  d | | | d f  d	 S(
   sB   
    Like C lookup, but the first index is optimized instead.
    i   s.   #define %s(type, buf, i0, s0) ((type)buf + i0)s   , s   i%d, s%ds    + s	   i%d * s%ds9   #define %s(type, buf, %s) ((type)((char*)buf + %s) + i%d)i    N(   R   R   R   (   R   R   R#   R   R   R   R   (    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyR     s
    25c         C@  s   |  j  t    d  S(   N(   R   t   GetAndReleaseBufferUtilityCode(   Rt   (    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyR   )  s    R   c           B@  sA   e  Z d Z e Z d    Z d   Z d   Z d   Z	 d   Z
 RS(   c         C@  s   d  S(   N(    (   R   (    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyR   5  s    c         C@  s   t  | t  S(   N(   R   R   (   R   t   other(    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyt   __eq__8  s    c         C@  s   d S(   NiFos(    (   R   (    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyt   __hash__;  s    c         K@  s   d  S(   N(    (   R   t   kwargs(    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyt   get_tree>  R&   c         @  s   | d } | d } | j  j } | j j   g   t         f d     |  t j d d d d t d   } | j | j	  } | j | j
 | j |  d	  } | j |  | j |  d  S(
   NR   R   c         @  s  |   k r d  S j  |   x |  j D] }  |  q' Wx |  j D] } t | j t  rc qE n  | j } | j rE |    k r | j r qE n  d  } } xJ | j
 j D]< } | j d k r | j } q | j d k r | j } q q W| r j | j | | f  qqE qE Wd  S(   Nu   __getbuffer__u   __releasebuffer__(   R   t   cimported_modulest   type_entriesR   R:   R   R)   Ro   R0   R-   R   t   pyfunc_entriesR#   t
   func_cnameR   t   typeptr_cname(   R   t   mt   eR   t   releaseR_   R   (   t   cython_scopet   find_buffer_typest   typest   visited_scopes(    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyR   I  s(    		
  t   GetAndReleaseBuffert	   from_files   Buffer.ct   contextR   i   (   t   module_nodeR   R  R   t   setR   t   loadt   dictt   format_codeR   t   inject_string_constantst   implR   (   R   t   outputR   t
   proto_codeRt   t	   util_codeR   R
  (    (   R   R   R   R   s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyt   put_code@  s     

	
N(   RS   RT   R-   t   requiresRU   t   is_cython_utilityR   R   R   R   R  (    (    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyR   -  s   				c         C@  sM   |  j  r d S|  j r d S|  j s, |  j r5 d } n d } | |  j   Sd  S(   Nt   objectt   ptrt   nn_R&   (   t   is_pyobjectR=   t
   is_typedeft   is_struct_or_uniont   specialization_name(   R<   R1   (    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyt   mangle_dtype_namek  s    			c      	   C@  s9  t  |  } d | } d | } | j r- d S| d k rH | j   } n  | d k rc t sc t  n  | |  j j k r5|  j j j |  |  j d } g  } | j	 r x) | j	 r | j
 | j  | j } q Wn  | j o | j   } | j   }	 | j   rd } n | j r| j j }
 t |
  d k s3t  g  |
 D] } t |  | j | d  ^ q:} | j d | d	 t xL t |
 |  D]; \ } } | j d
 | | j | j   | j f d	 t qW| j d d	 t | j d d	 t n t st  t |  } d } d } | t j k r4d |	 } d } n | j rTd |	 } d | } nr | sc| j  rld } nZ | j! r~d } nH | j rd } | j" rd } qn$ | j# rd } n t st |   d } | | | |	 d j$ g  | D] } t |  ^ q pd t |  | | | f	 } | j | | d	 t n  | S(   sr  
    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.
    s   __Pyx_TypeInfo_%ss   __Pyx_StructFields_%ss   <error>i    t   typeinfot   NULLi   s!   static __Pyx_StructField %s[] = {t   safes      {&%s, "%s", offsetof(%s, %s)},s     {NULL, NULL, 0}s   };t   0s   IS_UNSIGNED(%s)s   'H's   %s ? 'U' : 'I's   'C's   'R's   'S't   __PYX_BUF_FLAGS_PACKED_STRUCTs   'O'sL   static __Pyx_TypeInfo %s = { "%s", %s, sizeof(%s), { %s }, %s, %s, %s, %s };s   , N(%   R  t   is_errorR-   R   RU   R   R   R   R   t   is_arrayR   t   sizet	   base_typeR  t   can_be_complexR   t   is_simple_buffer_dtypet	   is_structR   t   var_entriesR7   R   R)   R   R/   Rk   R#   R(   t   strR	   t   c_char_typet   is_intt
   is_complext   is_floatt   packedR  R   (   R   R<   t   maxdeptht
   namesuffixR#   t   structinfo_namet   typecodet
   arraysizest   complex_possiblet   declcodet   fieldst   fR   R  t   repR   t   is_unsignedt	   typegroupR   t   tup(    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyR   y  sv    


	  			)	*
		
							4c         K@  s<   | d  k r t j |  d |  St j |  d d | | Sd  S(   Ns   Buffer.cR  (   R-   R   R  R   (   t   util_code_nameR  R   (    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyt   load_buffer_utility  s    t   max_dimst   BufferStructDeclareR  t   BufferFormatStructst   BufferIndexErrort   BufferIndexErrorNogilt   BufferFallbackErrort   BufferGetAndValidatet   BufferFormatCheckt   TypeInfoToFormatN(   R<   R>   RV   RW   RX   (B   t
   __future__R    t   VisitorR   R   t   ErrorsR   R   R   t   CodeR   R&   R   R   R	   R
   R   R   R   Ri   R/   RU   Re   Rg   Rj   Rh   Rl   Rn   Rs   Rr   Rp   Ra   R-   Rz   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   t   buffer_formats_declare_codeR   R   R   R   t   buffer_format_check_codet   _typeinfo_to_format_code(    (    (    s5   lib/python2.7/site-packages/Cython/Compiler/Buffer.pyt   <module>   sj   ["EG								H	B						>	U