
NWc           @@  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 dD 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 dC 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. e. e j/  Z0 d,   Z1 d-   Z2 d.   Z3 d/   Z4 d0   Z5 d1 e" f d2     YZ6 d3   Z7 dC d4  Z8 dC d5  Z9 e: d6 e; e j/   Z< e9 d7 d8 e< Z= e9 d9  Z> e9 d:  Z? e9 d;  Z@ e9 d< d= d> ZA e9 d? d8 e< d@ eA g ZB e9 dA d8 i  d@ eA g ZC e9 dB d8 i  d@ eA g ZD dC S(E   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(    (    s9   /bar/jli/Chip-seq/script/cython/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@  sp   t  | t  s t  d |  _ t t |   j |  } |  j rl t | j	  t
 | j	  | j	 j t  n  | S(   Ni    (   t
   isinstanceR   t   AssertionErrort   max_ndimt   superR   t   __call__t   buffers_existst   use_bufstruct_declare_codet   scopet   use_py2_buffer_functionst   use_utility_codet   empty_bufstruct_utility(   t   selft   nodet   result(    (    s9   /bar/jli/Chip-seq/script/cython/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(    (    s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyt   <lambda>7   s    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   (    s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyt   decvarU   s    	("   t   entriest   itemsR*   t	   is_buffert   lent   sortR0   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   buftypeR4   t   auxvarsR*   R2   t
   pybufferndt   rcbuffer(    (   R&   R%   R"   R   s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyt   handle_scope0   s@    ++	!				.	c         C@  s$   |  j  | | j  |  j |  | S(   N(   RO   R   t   visitchildren(   R!   R"   (    (    s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyt   visit_ModuleNodeg   s    c         C@  s$   |  j  | | j  |  j |  | S(   N(   RO   t   local_scopeRP   (   R!   R"   (    (    s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyt   visit_FuncDefNodel   s    (	   t   __name__t
   __module__t   FalseR   R<   R   RO   RQ   RS   (    (    (    s9   /bar/jli/Chip-seq/script/cython/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?   RW   RZ   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(    s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyt   assert_bool   s    RX   RY   N(   i    s   dtype(   s   fulls   stridedR^   s   fortran(   R.   t   buffer_defaultsR   t   interpret_compiletime_optionsR8   t   buffer_positional_options_countR   t   ERR_BUF_TOO_MANYR6   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(   Rc   t   envt   posargst   dictargst   defaultst   need_completeR%   t   valueR+   R=   R?   RW   Re   (    (   Rc   Rd   s9   /bar/jli/Chip-seq/script/cython/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*   RF   t   buflocal_nd_varR)   t   buf_ptrt   buffer_ptr_typet   buf_ptr_typet   init_attributes(   R!   R&   (    (    s9   /bar/jli/Chip-seq/script/cython/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!   (    (    s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyR      s    c         C@  s   |  j  d  S(   Ns   %s.diminfo[%d].suboffsets(   t   _for_all_ndim(   R!   (    (    s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyR      s    c         C@  s   |  j  d  S(   Ns   %s.diminfo[%d].strides(   R   (   R!   (    (    s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyR      s    c         C@  s   |  j  d  S(   Ns   %s.diminfo[%d].shape(   R   (   R!   (    (    s9   /bar/jli/Chip-seq/script/cython/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(    (    s9   /bar/jli/Chip-seq/script/cython/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(   NRZ   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?   RW   Rl   R   R   t   appendt   buf_lookup_full_codet   buf_lookup_strided_codet   buf_lookup_c_codet   buf_lookup_fortran_codeRV   R   t   globalstatet   utility_codest   addR   t   empty_declaration_codeR~   R   (   R!   t   codet   index_cnamest   paramsR   RW   R   R   t   ot   funcnamet   funcgent	   protocodet   defcodet   buf_ptr_type_codet   ptrcode(    (    s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyt   generate_buffer_lookup_code   sD    		
	
	
	
	"(	   RT   RU   R   R   R   R   R   R   R   (    (    (    s9   /bar/jli/Chip-seq/script/cython/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_FORMATRZ   s   | PyBUF_INDIRECTR]   s   | PyBUF_STRIDESR^   s   | PyBUF_C_CONTIGUOUSR_   s   | PyBUF_F_CONTIGUOUSs   | PyBUF_WRITABLE(   RW   RV   R   t   writable_needed(   RF   t   buffer_typet   flagsRW   (    (    s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyt	   get_flags  s    		 c         C@  s%   |  j  } t | j _ t | j _ d  S(   N(   RF   R0   R}   R1   t	   rcbuf_var(   R&   RF   (    (    s9   /bar/jli/Chip-seq/script/cython/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   RZ   R   s1   %s.diminfo[%d].%s = %s.rcbuffer->pybuffer.%s[%d];R   (
   RF   R*   RW   R}   R)   R   R   R?   t   putlnR   (	   t	   buf_entryR   RF   RW   t   pybuffernd_structt   fldnamest   lnR   t   fldname(    (    s9   /bar/jli/Chip-seq/script/cython/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;(   RF   R}   R)   R   R   (   R&   R   t   bufauxR   t   pybuffer_struct(    (    s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyt   put_init_vars4  s    	c         C@  s   | j  j t  |  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   }(   R   R   t   acquire_utility_codeRF   t   get_getbuffer_callR)   R*   R   R=   t   struct_nesting_deptht   error_goto_ifR   (   R&   R   R+   RF   t	   getbuffer(    (    s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyt   put_acquire_arg_bufferA  s    	c         C@  s.   |  j  j t  |  j d | j j j  d  S(   Ns0   __Pyx_SafeReleaseBuffer(&%s.rcbuffer->pybuffer);(   R   R   R   R   RF   R}   R)   (   R   R&   (    (    s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyt   put_release_buffer_codeO  s    c   	      C@  sP   | j  } t | j  } t | |  } | j j } t |  | j  } 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?   Rr   RY   R   R}   R)   t   get_type_information_cnameR=   t   locals(	   R   t	   obj_cnameRF   R   R?   RY   R   R   t   dtype_typeinfo(    (    s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyR   S  s    	c         C@  s  | j  | j } } | j j t  | j j } t | |  }	 | j d  | j d | j	 j
    t | d | |  }
 | r9| j d |  | j j t j d t } | j d | |
 | f  | j d | j d |   g  t d	  D]! } | j j t j d t ^ q \ } } } | j d
 | | | f  | j d | j d |
 |    | j d | | | f  | j j t  | j d  | j d  | j d | | | f  x' | | | f D] } | j j |  qW| j d  | 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 < 0i   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   sA   %s = %s; __Pyx_INCREF(Py_None); %s.rcbuffer->pybuffer.buf = NULL;t   Py_NoneN(   RF   R*   R   R   R   R}   R)   R   R   R=   R   R   t	   funcstatet   allocate_tempR	   t
   c_int_typeRV   t   unlikelyR   t   py_object_typet   raise_buffer_fallback_codet   release_tempR   t   error_goto_if_negt   typecastt
   error_gotot   put(   t	   lhs_cnamet	   rhs_cnameR   t   is_initializedR+   R   RF   R   R   R   R   t   retcode_cnameR   R*   Rz   t   tbt   t(    (    s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyt   put_assign_to_buffer_  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 t    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   RV   R   t	   enumerateRl   R   R   R   R   R   t   raise_indexerror_nogilt   raise_indexerror_codeR   R   R   (   R&   t   index_signedsR   t
   directivesR+   R   RX   t   in_nogil_contextt   failed_dim_tempt   dimt   signedR)   R   RY   t   func(    (    s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyt   put_buffer_lookup_code  sF    
4				($c         C@  s   |  j  t  d  S(   N(   R   t   buffer_struct_declare_code(   Ru   (    (    s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyR     s    c         C@  sC   t  d  d j d g |   d j d g |   f } t d |  S(   Nsi   
        static Py_ssize_t __Pyx_zeros[] = {%s};
        static Py_ssize_t __Pyx_minusones[] = {%s};
    s   , t   0s   -1t   proto(   R   R   R   (   R   R   (    (    s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyt   get_empty_bufstruct_code  s    3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   (   R   t   definR%   R   R   t	   macroargst   funcargs(    (    s9   /bar/jli/Chip-seq/script/cython/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(    (    s9   /bar/jli/Chip-seq/script/cython/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   (    (    s9   /bar/jli/Chip-seq/script/cython/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   (    (    s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyR   !  s
    25c         C@  s   |  j  t    d  S(   N(   R   t   GetAndReleaseBufferUtilityCode(   Ru   (    (    s9   /bar/jli/Chip-seq/script/cython/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!   (    (    s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyR   8  s    c         C@  s   t  | t  S(   N(   R   R   (   R!   t   other(    (    s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyt   __eq__;  s    c         C@  s   d S(   NiFos(    (   R!   (    (    s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyt   __hash__>  s    c         K@  s   d  S(   N(    (   R!   t   kwargs(    (    s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyt   get_treeA  s    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*   Rp   R1   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(    s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyR   L  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_codeRu   t	   util_codeR   R
  (    (   R   R   R   R   s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyt   put_codeC  s     

	
N(   RT   RU   R.   t   requiresRV   t   is_cython_utilityR   R   R   R   R  (    (    (    s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyR   0  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=   R2   (    (    s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyt   mangle_dtype_namen  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 seperate 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   };R   s   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   RV   R   R   R   R   t   is_arrayR   t   sizet	   base_typeR  t   can_be_complexR   t   is_simple_buffer_dtypet	   is_structR   t   var_entriesR8   R   R*   R   R0   Rl   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(    (    s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyR   |  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   (    (    s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyt   load_buffer_utility  s    t   max_dimst   BufferStructDeclareR  t   BufferIndexErrort   BufferIndexErrorNogilt   BufferFallbackErrort   BufferFormatStructst   proto_blockt   utility_code_proto_before_typest   BufferFormatCheckR  t   TypeInfoToFormatt   TypeInfoCompareN(   s   dtypes   ndims   modes   negative_indicess   cast(E   t
   __future__R    t   VisitorR   R   t   ErrorsR   R   R   t   CodeR   R   R   R   R	   R
   R   R   R   Rj   R0   RV   Rf   Rh   Rk   Ri   Rm   Ro   Rt   Rs   Rq   Rb   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   R9  R  R%  R  R   R   R   R   t   buffer_structs_codeR   t   _typeinfo_to_format_codet   typeinfo_compare_code(    (    (    s9   /bar/jli/Chip-seq/script/cython/Cython/Compiler/Buffer.pyt   <module>   sz   \"EG								H	B				
			>	U			