o
    1&in                     @   s  d Z ddlmZ ddlmZ ddlZddlZddl	m
Z
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rBe
jZne
jZdZdZdZdZG dd deZdd Zedd Z eedd Z!edd Z"edd Z#edd Z$edd Z%edd  Z&ed!d" Z'ed#d$ Z(ed%d& Z)ed'd( Z*ed)d* Z+ed+d, Z,ed-d. Z-ed/d0 Z.ed1d2 Z/ed3d4 Z0ed5d6 Z1ed7d8 Z2ed9d: Z3ed;d< Z4ed=d> Z5ed?d@ Z6edAdB Z7edCdD Z8edEdF Z9G dGdH dHeZ:ej;g ddddddddde:j<e:j<e:j<e:j<e:j<dddddddddddddddddde:j<ddddddddddddddde:j=e:j>B e:j=e:j>B e:j=e:j>B e:j=e:j>B e:j=e:j>B e:j=e:j>B e:j=e:j>B e:j=e:j>B e:j=e:j>B e:j=e:j>B ddddddde:j?e:j>B e:j?e:j>B e:j?e:j>B e:j?e:j>B e:j?e:j>B e:j?e:j>B e:j?e:j?e:j?e:j?e:j?e:j?e:j?e:j?e:j?e:j?e:j?e:j?e:j?e:j?e:j?e:j?e:j?e:j?e:j?e:j?dddddde:j@e:j>B e:j@e:j>B e:j@e:j>B e:j@e:j>B e:j@e:j>B e:j@e:j>B e:j@e:j@e:j@e:j@e:j@e:j@e:j@e:j@e:j@e:j@e:j@e:j@e:j@e:j@e:j@e:j@e:j@e:j@e:j@e:j@dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddejAdIZBej;g dJejCdIZDej;g dKejCdIZEG dLdM dMeZFej;g ddddddddddeFjGeFjHB eFjGeFjGeFjGeFjIB ddddddddddddddeFjGeFjGeFjGddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddeFjGddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddejAdIZJedNdO ZKedPdQ ZLedRdS ZMedTdU ZNedVdW ZOedXdY ZPedZd[ ZQed\d] ZRed^d_ ZSed`da ZTedbdc ZUeddde ZVedfdg ZWdS )hz
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.
    )
namedtuple)IntEnumN)typescgutilsconfig)impl_ret_untracked)overload	intrinsicregister_jitable)TypingError
typerecordz%upper lower title decimal digit flags	   
          c                   @   sH   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dZdS )_PyUnicode_TyperecordMasks               r   @         i   i   i   i   i    i @  N)__name__
__module____qualname__
ALPHA_MASKDECIMAL_MASK
DIGIT_MASK
LOWER_MASKLINEBREAK_MASK
SPACE_MASK
TITLE_MASK
UPPER_MASKXID_START_MASKXID_CONTINUE_MASKPRINTABLE_MASKNUMERIC_MASKCASE_IGNORABLE_MASK
CASED_MASKEXTENDED_CASE_MASK r,   r,   HC:\wamp64\www\opt\env\Lib\site-packages\numba/cpython/unicode_support.pyr   >   s     r   c                 C   s   t d)Nz(Calling the Python definition is invalid)RuntimeErrorar,   r,   r-   _PyUnicode_gettyperecordP   s   r1   c                 C   sP   t |tjs
tddd }ttjtjtjtjtjtjgt}|t	}||fS )z~
    Provides the binding to numba_gettyperecord, returns a `typerecord`
    namedtuple of properties from the codepoint.
    zcodepoint must be an integerc              
   S   sH  |  tj}|  t}|  tj}| }|  tj}| }	|  tj}
|
 }tj	
||||||	|	|g}t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}|||d	 g|  g }|D ]
}||| q| ||jt|}t| ||j|S )
NZnumba_gettyperecordnameupperlowertitledecimaldigitflagsr   )get_value_typer   Zvoid_Py_UCS4intcZ
as_pointerucharushortllvmliteirFunctionTyper   get_or_insert_functionmoduleZalloca_oncecallappendloadZ
make_tuplereturn_typetupler   )contextbuilder	signatureargsZll_void
ll_Py_UCS4ll_intcZll_intc_ptrZll_ucharZll_uchar_ptrZ	ll_ushortZll_ushort_ptrfntyfnr4   r5   r6   r7   r8   r9   byrefbufxresr,   r,   r-   details]   sD   
	z$_gettyperecord_impl.<locals>.details)

isinstancer   Integerr   
NamedTupler<   r=   r>   r   r;   )	typingctx	codepointrU   Ztuptysigr,   r,   r-   _gettyperecord_implT   s   %r\   c                    s@   t | tjrddlm   fdd}|S t | tjrdd S dS )z
    Provides a _PyUnicode_gettyperecord binding, for convenience it will accept
    single character strings and code points.
    r   _get_code_pointc                    s2   t | dkrd}t| | d}tt|}|S )Nr   z.gettyperecord takes a single unicode characterr   )len
ValueErrorr\   r;   )r0   msg
code_pointdatar]   r,   r-   impl   s   
z gettyperecord_impl.<locals>.implc                 S   s   t t| S N)r\   r;   r/   r,   r,   r-   <lambda>   s    z$gettyperecord_impl.<locals>.<lambda>N)rV   r   ZUnicodeTypeZnumba.cpython.unicoder^   rW   )r0   rd   r,   r]   r-   gettyperecord_impl   s   rg   c                 C   s.   t |tjs
tddd }ttj}||fS )z
    Accessor function for the _PyUnicode_ExtendedCase array, binds to
    numba_get_PyUnicode_ExtendedCase which wraps the array and does the lookup
    zExpected an indexc                 S   sJ   |  t}|  tj}tj||g}tj|j	|dd}|
||d gS )NZ numba_get_PyUnicode_ExtendedCaser2   r   )r:   r;   r   r<   r?   r@   rA   r   rB   rC   rD   )rI   rJ   rK   rL   rM   rN   rO   rP   r,   r,   r-   rU      s   
z(_PyUnicode_ExtendedCase.<locals>.details)rV   r   rW   r   r;   r<   )rY   indexrU   r[   r,   r,   r-   _PyUnicode_ExtendedCase   s
   
	ri   c                 C   s,   t | }|jtj@ rt|jd@ S | |j S )N  )r1   r9   r   r+   ri   r6   chctyper,   r,   r-   _PyUnicode_ToTitlecase   s   
rn   c                 C      t | }|jtj@ dkS Nr   )r1   r9   r   r#   rk   r,   r,   r-   _PyUnicode_IsTitlecase      rq   c                 C   ro   rp   )r1   r9   r   r%   rk   r,   r,   r-   _PyUnicode_IsXidStart   rr   rs   c                 C   ro   rp   )r1   r9   r   r&   rk   r,   r,   r-   _PyUnicode_IsXidContinue   rr   rt   c                 C      t | }|jtj@ r|jS dS N)r1   r9   r   r   r7   rk   r,   r,   r-   _PyUnicode_ToDecimalDigit      rx   c                 C   ru   rv   )r1   r9   r   r   r8   rk   r,   r,   r-   _PyUnicode_ToDigit   ry   rz   c                 C   ro   rp   )r1   r9   r   r(   rk   r,   r,   r-   _PyUnicode_IsNumeric   rr   r{   c                 C   ro   rp   )r1   r9   r   r'   rk   r,   r,   r-   _PyUnicode_IsPrintable   rr   r|   c                 C   ro   rp   )r1   r9   r   r    rk   r,   r,   r-   _PyUnicode_IsLowercase   rr   r}   c                 C   ro   rp   )r1   r9   r   r$   rk   r,   r,   r-   _PyUnicode_IsUppercase   rr   r~   c                 C   ro   rp   )r1   r9   r   r!   rk   r,   r,   r-   _PyUnicode_IsLineBreak  rr   r   c                 C      t re   NotImplementedErrorrl   r,   r,   r-   _PyUnicode_ToUppercase	     r   c                 C   r   re   r   r   r,   r,   r-   _PyUnicode_ToLowercase  r   r   c                 C   \   t | }|jtj@ r%|jd@ }|jd? }t|D ]
}t|| ||< q|S | |j |d< dS Nrj      r   r   )r1   r9   r   r+   r5   rangeri   rl   rT   rm   rh   nir,   r,   r-   _PyUnicode_ToLowerFull     

r   c                 C   r   r   )r1   r9   r   r+   r6   r   ri   r   r,   r,   r-   _PyUnicode_ToTitleFull"  r   r   c                 C   r   r   )r1   r9   r   r+   r4   r   ri   r   r,   r,   r-   _PyUnicode_ToUpperFull0  s   

r   c                 C   st   t | }tj}|j|@ r5|jd? d@ r5|jd@ |jd?  }|jd? d@ }t|D ]
}t|| ||< q(|S t| |S )N      rj   r   )r1   r   r+   r9   r5   r   ri   r   )rl   rT   rm   Zextended_case_maskrh   r   r   r,   r,   r-   _PyUnicode_ToFoldedFull?  s   
r   c                 C   ro   rp   )r1   r9   r   r*   rk   r,   r,   r-   _PyUnicode_IsCasedM  rr   r   c                 C   ro   rp   )r1   r9   r   r)   rk   r,   r,   r-   _PyUnicode_IsCaseIgnorableT  rr   r   c                 C      t | dk rdS dS Nr   r   )rz   r   r,   r,   r-   _PyUnicode_IsDigit[     r   c                 C   r   r   )rx   r   r,   r,   r-   _PyUnicode_IsDecimalDigitc  r   r   c                 C   ro   rp   )r1   r9   r   r"   rk   r,   r,   r-   _PyUnicode_IsSpacek  rr   r   c                 C   ro   rp   )r1   r9   r   r   rk   r,   r,   r-   _PyUnicode_IsAlphaq  rr   r   c                   @   s(   e Zd ZdZdZdZdZdZdZdZ	dS )	_PY_CTFr   r      r   r   r   r   N)
r   r   r   LOWERUPPERALPHADIGITALNUMSPACEXDIGITr,   r,   r,   r-   r     s    r   )Zdtype(   r   r   r   r   r         r   r   r   r         r         r            r            r                        r   !   "   #   $   %   &   '   (   )   *   +   ,   -   .   /   0   1   2   3   4   5   6   7   8   9   :   ;   <   =   >   ?   r   a   b   c   d   e   f   g   h   i   j   k   l   m   n   o   p   q   r   s   t   u   v   w   x   y   z   [   \   ]   ^   _   `   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   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   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   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   P   Q   R   S   T   U   V   W   X   Y   Z   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  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	  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"  r#  r$  r%  r&  r'  r(  r)  r*  r+  r,  r-  r.  r/  r0  r1  r2  r3  r4  r5  r6  r7  r8  r9  r:  r;  r<  r=  r>  r?  r@  rA  rB  rC  rD  rE  rF  rG  rH  rI  rJ  rK  rL  rM  rN  rO  rP  rQ  rR  rS  rT  rU  rV  rW  rX  rY  rZ  r[  r\  r]  r^  r_  r`  ra  rb  rc  rd  re  rf  rg  rh  ri  rj  rk  rl  rm  rn  ro  rp  rq  rr  rs  rt  ru  rv  rw  rx  ry  rz  r{  r|  c                   @   s   e Zd ZdZdZdZdS )
_PY_CTF_LBr   r   r   N)r   r   r   
LINE_BREAK	LINE_FEEDCARRIAGE_RETURNr,   r,   r,   r-   r  d  s    r  c                 C   s   t | t d@ S )zk
    Equivalent to the CPython macro `Py_CHARMASK()`, masks off all but the
    lowest 256 bits of ch.
    r|  )r   uint8r   r,   r,   r-   _Py_CHARMASK  s   r  c                 C      t t|  S )zw
    Equivalent to the CPython macro `Py_TOUPPER()` converts an ASCII range
    code point to the upper equivalent
    )_Py_ctype_toupperr  r   r,   r,   r-   _Py_TOUPPER     r  c                 C   r  )zw
    Equivalent to the CPython macro `Py_TOLOWER()` converts an ASCII range
    code point to the lower equivalent
    )_Py_ctype_tolowerr  r   r,   r,   r-   _Py_TOLOWER  r  r  c                 C      t t|  tj@ S )z8
    Equivalent to the CPython macro `Py_ISLOWER()`
    )_Py_ctype_tabler  r   r   r   r,   r,   r-   _Py_ISLOWER     r  c                 C   r  )z8
    Equivalent to the CPython macro `Py_ISUPPER()`
    )r  r  r   r   r   r,   r,   r-   _Py_ISUPPER  r  r  c                 C   r  )z8
    Equivalent to the CPython macro `Py_ISALPHA()`
    )r  r  r   r   r   r,   r,   r-   _Py_ISALPHA  r  r  c                 C   r  )z8
    Equivalent to the CPython macro `Py_ISDIGIT()`
    )r  r  r   r   r   r,   r,   r-   _Py_ISDIGIT  r  r  c                 C   r  )z9
    Equivalent to the CPython macro `Py_ISXDIGIT()`
    )r  r  r   r   r   r,   r,   r-   _Py_ISXDIGIT  r  r  c                 C   r  )z8
    Equivalent to the CPython macro `Py_ISALNUM()`
    )r  r  r   r   r   r,   r,   r-   _Py_ISALNUM  r  r  c                 C   r  )z8
    Equivalent to the CPython macro `Py_ISSPACE()`
    )r  r  r   r   r   r,   r,   r-   _Py_ISSPACE  r  r  c                 C   r  )z&Check if character is ASCII line break)_Py_ctype_islinebreakr  r  r  r   r,   r,   r-   _Py_ISLINEBREAK     r  c                 C   r  )z#Check if character is line feed `
`)r  r  r  r  r   r,   r,   r-   _Py_ISLINEFEED  r  r  c                 C   r  )z)Check if character is carriage return ``)r  r  r  r  r   r,   r,   r-   _Py_ISCARRIAGERETURN  r  r  )X__doc__collectionsr   enumr   Zllvmlite.irr?   numpynpZ
numba.corer   r   r   Znumba.core.imputilsr   Znumba.core.extendingr   r	   r
   Znumba.core.errorsr   r   ZUSE_LEGACY_TYPE_SYSTEMZuint32r;   c_uint32Z_Py_TABZ_Py_LINEFEEDZ_Py_CARRIAGE_RETURNZ	_Py_SPACEr   r1   r\   rg   ri   rn   rq   rs   rt   rx   rz   r{   r|   r}   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   arrayr   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  r  r  r,   r,   r,   r-   <module>   s
   
3
























	
 !"#$%&'()*+,-./0
1
2
3
4
5
6
7
8
9
:;<=>?@A
B
C
D
E
F
GHIJKLMNOPQRSTUVWXYZ[\]^_`a
b
c
d
e
f
ghijklmnopqrstuvwxyz{|}~                                                                                                                                                                                                                                   	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  
  
!
&!$

	























	
	
	
	
	
	


