
\K]c          @   s  d  Z  d d l m Z d d l m Z d d l Z d d l j j	 Z
 d d l m Z m Z d d l m Z d d l m Z m Z m Z d d	 l m Z e d
 d  Z e j Z d e f d     YZ d   Z e d    Z e e  d    Z e d    Z e d    Z e d    Z e d    Z  e d    Z! e d    Z" e d    Z# e d    Z$ e d    Z% e d    Z& e d    Z' e d    Z( e d    Z) e d    Z* e d    Z+ e d     Z, e d!    Z- e d"    Z. e d#    Z/ e d$    Z0 e d%    Z1 e d&    Z2 d' e f d(     YZ3 e j4 d) d) d) d) d) d) d) d) d) e3 j5 e3 j5 e3 j5 e3 j5 e3 j5 d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) e3 j5 d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) e3 j6 e3 j7 Be3 j6 e3 j7 Be3 j6 e3 j7 Be3 j6 e3 j7 Be3 j6 e3 j7 Be3 j6 e3 j7 Be3 j6 e3 j7 Be3 j6 e3 j7 Be3 j6 e3 j7 Be3 j6 e3 j7 Bd) d) d) d) d) d) d) e3 j8 e3 j7 Be3 j8 e3 j7 Be3 j8 e3 j7 Be3 j8 e3 j7 Be3 j8 e3 j7 Be3 j8 e3 j7 Be3 j8 e3 j8 e3 j8 e3 j8 e3 j8 e3 j8 e3 j8 e3 j8 e3 j8 e3 j8 e3 j8 e3 j8 e3 j8 e3 j8 e3 j8 e3 j8 e3 j8 e3 j8 e3 j8 e3 j8 d) d) d) d) d) d) e3 j9 e3 j7 Be3 j9 e3 j7 Be3 j9 e3 j7 Be3 j9 e3 j7 Be3 j9 e3 j7 Be3 j9 e3 j7 Be3 j9 e3 j9 e3 j9 e3 j9 e3 j9 e3 j9 e3 j9 e3 j9 e3 j9 e3 j9 e3 j9 e3 j9 e3 j9 e3 j9 e3 j9 e3 j9 e3 j9 e3 j9 e3 j9 e3 j9 d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) d) g d* e j: Z; e j4 d) d d+ d, d- d. d/ d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d: d; d< d= d> d? d@ dA dB dC dD dE dF dG dH dI dJ dK dL dM dN dO dP dQ dR dS dT dU dV dW dX dY dZ d[ d\ d] d^ d_ d` da db dc dd de df dg dh di dj dk dl dm dn do dp dq dr ds dt du dv dw dx dy dz d{ d| d} d~ d d d d d d d d d d d dj dk dl dm dn do dp dq dr ds dt du dv dw dx dy dz d{ d| d} d~ d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d ddddddddd	d
ddddg d* e j< Z= e j4 d) d d+ d, d- d. d/ d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d: d; d< d= d> d? d@ dA dB dC dD dE dF dG dH dI dJ dK dL dM dN dO dP dQ dR dS dT dU dV dW dX dY dZ d[ d\ d] d^ d_ d` da db dc dd de df dg dh di dddddddddddddddddd d!d"d#d$d%d&d'd(d d d d d d dddddddddddddddddd d!d"d#d$d%d&d'd(d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d ddddddddd	d
ddddg d* e j< Z> e d)   Z? e d*   Z@ e d+   ZA e d,   ZB e d-   ZC e d.   ZD e d/   ZE e d0   ZF e d1   ZG e d2   ZH d S(3  s   
This module contains support functions for more advanced unicode operations.
This is not a public API and is for Numba internal use only. Most of the
functions are relatively straightforward translations of the functions with the
same name in CPython.
i(   t
   namedtuple(   t   IntEnumN(   t   typest   cgutils(   t   impl_ret_untracked(   t   overloadt	   intrinsict   register_jitablei   (   t   TypingErrort
   typerecords%   upper lower title decimal digit flagst   _PyUnicode_TyperecordMasksc           B   sb   e  Z 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 Z d Z d Z RS(   i   i   i   i   i   i    i@   i   i   i   i   i   i   i    i @  (   t   __name__t
   __module__t
   ALPHA_MASKt   DECIMAL_MASKt
   DIGIT_MASKt
   LOWER_MASKt   LINEBREAK_MASKt
   SPACE_MASKt
   TITLE_MASKt
   UPPER_MASKt   XID_START_MASKt   XID_CONTINUE_MASKt   PRINTABLE_MASKt   NUMERIC_MASKt   CASE_IGNORABLE_MASKt
   CASED_MASKt   EXTENDED_CASE_MASK(    (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyR
   4   s   c         C   s   t  d   d  S(   Ns(   Calling the Python definition is invalid(   t   RuntimeError(   t   a(    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _PyUnicode_gettyperecordF   s    c         C   sv   t  | t j  s! t d   n  d   } t j t j t j t j t j t j t j g t  } | t	  } | | f S(   s~   
    Provides the binding to numba_gettyperecord, returns a `typerecord`
    namedtuple of properties from the codepoint.
    s   codepoint must be an integerc      	   S   s  |  j  t j  } |  j  t  } |  j  t j  } | j   } |  j  t j  } | j   }	 |  j  t j  }
 |
 j   } t j	 j
 | | | | | |	 |	 | g  } | j j | d d } t j | | d d } t j | | d d } t j | | d d } t j | | d d } t j | | d d } t j | |
 d d } | | | | | | g } | j | | d	 g |  g  } x$ | D] } | j | j |   qW|  j | | j t |   } t |  | | j |  S(
   Nt   namet   numba_gettyperecordt   uppert   lowert   titlet   decimalt   digitt   flagsi    (   t   get_value_typeR   t   voidt   _Py_UCS4t   intct
   as_pointert   uchart   ushortt   lct   Typet   functiont   modulet   get_or_insert_functionR   t   alloca_oncet   callt   appendt   loadt
   make_tuplet   return_typet   tupleR   (   t   contextt   buildert	   signaturet   argst   ll_voidt
   ll_Py_UCS4t   ll_intct   ll_intc_ptrt   ll_uchart   ll_uchar_ptrt	   ll_ushortt   ll_ushort_ptrt   fntyt   fnR!   R"   R#   R$   R%   R&   t   byreft   buft   xt   res(    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   detailsS   s>    	(
   t
   isinstanceR   t   IntegerR   t
   NamedTupleR*   R,   R-   R	   R)   (   t	   typingctxt	   codepointRL   t   tuptyt   sig(    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _gettyperecord_implJ   s    	$c            sR   t  |  t j  r5 d d l m     f d   } | St  |  t j  rN d   Sd S(   s   
    Provides a _PyUnicode_gettyperecord binding, for convenience it will accept
    single character strings and code points.
    i(   t   _get_code_pointc            sL   t  |   d k r' d } t |   n    |  d  } t t |   } | S(   Ni   s.   gettyperecord takes a single unicode characteri    (   t   lent
   ValueErrorRT   R)   (   R   t   msgt
   code_pointt   data(   RU   (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   impl   s    c         S   s   t  t |    S(   N(   RT   R)   (   R   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   <lambda>   t    N(   RM   R   t   UnicodeTypet   numba.unicodeRU   RN   (   R   R[   (    (   RU   s4   lib/python2.7/site-packages/numba/unicode_support.pyt   gettyperecord_impl}   s    c         C   sC   t  | t j  s! t d   n  d   } t t j  } | | f S(   s   
    Accessor function for the _PyUnicode_ExtendedCase array, binds to
    numba_get_PyUnicode_ExtendedCase which wraps the array and does the lookup
    s   Expected an indexc         S   sh   |  j  t  } |  j  t j  } t j j | | g  } | j j | d d } | j	 | | d g  S(   NR   t    numba_get_PyUnicode_ExtendedCasei    (
   R'   R)   R   R*   R.   R/   R0   R1   R2   R4   (   R:   R;   R<   R=   R?   R@   RF   RG   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyRL      s    	(   RM   R   RN   R   R)   R*   (   RP   t   indexRL   RS   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _PyUnicode_ExtendedCase   s
    	c         C   s8   t  |   } | j t j @r- t | j d @ S|  | j S(   Ni  (   R   R&   R
   R   Rc   R#   (   t   cht   ctype(    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _PyUnicode_ToTitlecase   s    c         C   s    t  |   } | j t j @d k S(   Ni    (   R   R&   R
   R   (   Rd   Re   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _PyUnicode_IsTitlecase   s    c         C   s
   t   d  S(   N(   t   NotImplementedError(   Rd   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _PyUnicode_IsXidStart   s    c         C   s
   t   d  S(   N(   Rh   (   Rd   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _PyUnicode_IsXidContinue   s    c         C   s
   t   d  S(   N(   Rh   (   Rd   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _PyUnicode_ToDecimalDigit   s    c         C   s
   t   d  S(   N(   Rh   (   Rd   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _PyUnicode_IsDecimalDigit   s    c         C   s
   t   d  S(   N(   Rh   (   Rd   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _PyUnicode_ToDigit   s    c         C   s
   t   d  S(   N(   Rh   (   Rd   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _PyUnicode_IsDigit   s    c         C   s
   t   d  S(   N(   Rh   (   Rd   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _PyUnicode_IsNumeric   s    c         C   s
   t   d  S(   N(   Rh   (   Rd   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _PyUnicode_IsPrintable   s    c         C   s    t  |   } | j t j @d k S(   Ni    (   R   R&   R
   R   (   Rd   Re   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _PyUnicode_IsLowercase   s    c         C   s    t  |   } | j t j @d k S(   Ni    (   R   R&   R
   R   (   Rd   Re   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _PyUnicode_IsUppercase   s    c         C   s
   t   d  S(   N(   Rh   (   Rd   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _PyUnicode_ToUppercase   s    c         C   s
   t   d  S(   N(   Rh   (   Rd   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _PyUnicode_ToLowercase   s    c         C   s
   t   d  S(   N(   Rh   (   Rd   RK   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _PyUnicode_ToLowerFull   s    c         C   s
   t   d  S(   N(   Rh   (   Rd   RK   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _PyUnicode_ToTitleFull  s    c         C   sz   t  |   } | j t j @re | j d @} | j d ?} x( t |  D] } t | |  | | <qC W| S|  | j | d <d S(   Ni  i   i    i   (   R   R&   R
   R   R!   t   rangeRc   (   Rd   RK   Re   Rb   t   nt   i(    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _PyUnicode_ToUpperFull  s    c         C   s
   t   d  S(   N(   Rh   (   Rd   RK   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _PyUnicode_ToFoldedFull  s    c         C   s
   t   d  S(   N(   Rh   (   Rd   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _PyUnicode_IsCased  s    c         C   s
   t   d  S(   N(   Rh   (   Rd   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _PyUnicode_IsCaseIgnorable  s    c         C   s
   t   d  S(   N(   Rh   (   Rd   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _PyUnicode_IsAlpha#  s    t   _PY_CTFc           B   s2   e  Z d  Z d Z d Z d Z d Z d Z d Z RS(   i   i   i   i   i   i   i   i   (	   R   R   t   LOWERt   UPPERt   ALPHAt   DIGITt   ALNUMt   SPACEt   XDIGIT(    (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyR   0  s   i    t   dtypei   i   i   i   i   i   i   i	   i
   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i    i!   i"   i#   i$   i%   i&   i'   i(   i)   i*   i+   i,   i-   i.   i/   i0   i1   i2   i3   i4   i5   i6   i7   i8   i9   i:   i;   i<   i=   i>   i?   i@   ia   ib   ic   id   ie   if   ig   ih   ii   ij   ik   il   im   in   io   ip   iq   ir   is   it   iu   iv   iw   ix   iy   iz   i[   i\   i]   i^   i_   i`   i{   i|   i}   i~   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   iA   iB   iC   iD   iE   iF   iG   iH   iI   iJ   iK   iL   iM   iN   iO   iP   iQ   iR   iS   iT   iU   iV   iW   iX   iY   iZ   c         C   s   t  j |   t  j d  @S(   sk   
    Equivalent to the CPython macro `Py_CHARMASK()`, masks off all but the
    lowest 256 bits of ch.
    i   (   R   t   uint8(   Rd   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _Py_CHARMASK  s    c         C   s   t  t |   S(   sw   
    Equivalent to the CPython macro `Py_TOUPPER()` converts an ASCII range
    code point to the upper equivalent
    (   t   _Py_ctype_toupperR   (   Rd   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _Py_TOUPPER!  s    c         C   s   t  t |   S(   sw   
    Equivalent to the CPython macro `Py_TOLOWER()` converts an ASCII range
    code point to the lower equivalent
    (   t   _Py_ctype_tolowerR   (   Rd   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _Py_TOLOWER,  s    c         C   s   t  t |   t j @S(   s8   
    Equivalent to the CPython macro `Py_ISLOWER()`
    (   t   _Py_ctype_tableR   R   R   (   Rd   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _Py_ISLOWER7  s    c         C   s   t  t |   t j @S(   s8   
    Equivalent to the CPython macro `Py_ISUPPER()`
    (   R   R   R   R   (   Rd   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _Py_ISUPPERA  s    c         C   s   t  t |   t j @S(   s8   
    Equivalent to the CPython macro `Py_ISALPHA()`
    (   R   R   R   R   (   Rd   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _Py_ISALPHAK  s    c         C   s   t  t |   t j @S(   s8   
    Equivalent to the CPython macro `Py_ISDIGIT()`
    (   R   R   R   R   (   Rd   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _Py_ISDIGITU  s    c         C   s   t  t |   t j @S(   s9   
    Equivalent to the CPython macro `Py_ISXDIGIT()`
    (   R   R   R   R   (   Rd   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _Py_ISXDIGIT_  s    c         C   s   t  t |   t j @S(   s8   
    Equivalent to the CPython macro `Py_ISALNUM()`
    (   R   R   R   R   (   Rd   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _Py_ISALNUMi  s    c         C   s   t  t |   t j @S(   s8   
    Equivalent to the CPython macro `Py_ISSPACE()`
    (   R   R   R   R   (   Rd   (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   _Py_ISSPACEs  s    (I   t   __doc__t   collectionsR    t   enumR   t   numpyt   npt   llvmlite.llvmpy.coret   llvmpyt   coreR.   t   numbaR   R   t   numba.targets.imputilsR   t   numba.extendingR   R   R   t   errorsR   R	   t   uint32R)   R
   R   RT   R`   Rc   Rf   Rg   Ri   Rj   Rk   Rl   Rm   Rn   Ro   Rp   Rq   Rr   Rs   Rt   Ru   Rv   Rz   R{   R|   R}   R~   R   t   arrayR   R   R   R   R   R*   R   R   R   R   R   R   R   R   R   R   R   R   R   R   (    (    (    s4   lib/python2.7/site-packages/numba/unicode_support.pyt   <module>   s  			3	00000006





