o
    ik                     @   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,   Z/home/ubuntu/veenaModal/venv/lib/python3.10/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 )
Nnumba_gettyperecordnameupperlowertitledecimaldigitflagsr   )get_value_typer   void_Py_UCS4intc
as_pointerucharushortllvmliteirFunctionTyper   get_or_insert_functionmodulealloca_oncecallappendload
make_tuplereturn_typetupler   )contextbuilder	signatureargsll_void
ll_Py_UCS4ll_intcll_intc_ptrll_ucharll_uchar_ptr	ll_ushortll_ushort_ptrfntyfnr5   r6   r7   r8   r9   r:   byrefbufxresr,   r,   r-   details]   sD   
	z$_gettyperecord_impl.<locals>.details)

isinstancer   Integerr   
NamedTupler>   r@   rA   r   r=   )	typingctx	codepointr`   tuptysigr,   r,   r-   _gettyperecord_implT   s   %rh   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
ValueErrorrh   r=   )r0   msg
code_pointdatari   r,   r-   impl   s   
z gettyperecord_impl.<locals>.implc                 S   s   t t| S N)rh   r=   r/   r,   r,   r-   <lambda>   s    z$gettyperecord_impl.<locals>.<lambda>N)ra   r   UnicodeTypenumba.cpython.unicoderj   rb   )r0   rp   r,   ri   r-   gettyperecord_impl   s   ru   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 )N numba_get_PyUnicode_ExtendedCaser3   r   )r;   r=   r   r>   rB   rC   rD   r   rE   rF   rH   )rN   rO   rP   rQ   rS   rT   rZ   r[   r,   r,   r-   r`      s   
z(_PyUnicode_ExtendedCase.<locals>.details)ra   r   rb   r   r=   r>   )rd   indexr`   rg   r,   r,   r-   _PyUnicode_ExtendedCase   s
   
	rx   c                 C   s,   t | }|jtj@ rt|jd@ S | |j S )N  )r1   r:   r   r+   rx   r7   chctyper,   r,   r-   _PyUnicode_ToTitlecase   s   
r}   c                 C      t | }|jtj@ dkS Nr   )r1   r:   r   r#   rz   r,   r,   r-   _PyUnicode_IsTitlecase      r   c                 C   r~   r   )r1   r:   r   r%   rz   r,   r,   r-   _PyUnicode_IsXidStart   r   r   c                 C   r~   r   )r1   r:   r   r&   rz   r,   r,   r-   _PyUnicode_IsXidContinue   r   r   c                 C      t | }|jtj@ r|jS dS N)r1   r:   r   r   r8   rz   r,   r,   r-   _PyUnicode_ToDecimalDigit      r   c                 C   r   r   )r1   r:   r   r   r9   rz   r,   r,   r-   _PyUnicode_ToDigit   r   r   c                 C   r~   r   )r1   r:   r   r(   rz   r,   r,   r-   _PyUnicode_IsNumeric   r   r   c                 C   r~   r   )r1   r:   r   r'   rz   r,   r,   r-   _PyUnicode_IsPrintable   r   r   c                 C   r~   r   )r1   r:   r   r    rz   r,   r,   r-   _PyUnicode_IsLowercase   r   r   c                 C   r~   r   )r1   r:   r   r$   rz   r,   r,   r-   _PyUnicode_IsUppercase   r   r   c                 C   r~   r   )r1   r:   r   r!   rz   r,   r,   r-   _PyUnicode_IsLineBreak  r   r   c                 C      t rq   NotImplementedErrorr{   r,   r,   r-   _PyUnicode_ToUppercase	     r   c                 C   r   rq   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 Nry      r   r   )r1   r:   r   r+   r6   rangerx   r{   r_   r|   rw   nir,   r,   r-   _PyUnicode_ToLowerFull     

r   c                 C   r   r   )r1   r:   r   r+   r7   r   rx   r   r,   r,   r-   _PyUnicode_ToTitleFull"  r   r   c                 C   r   r   )r1   r:   r   r+   r5   r   rx   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      ry   r   )r1   r   r+   r:   r6   r   rx   r   )r{   r_   r|   extended_case_maskrw   r   r   r,   r,   r-   _PyUnicode_ToFoldedFull?  s   
r   c                 C   r~   r   )r1   r:   r   r*   rz   r,   r,   r-   _PyUnicode_IsCasedM  r   r   c                 C   r~   r   )r1   r:   r   r)   rz   r,   r,   r-   _PyUnicode_IsCaseIgnorableT  r   r   c                 C      t | dk rdS dS Nr   r   )r   r   r,   r,   r-   _PyUnicode_IsDigit[     r   c                 C   r   r   )r   r   r,   r,   r-   _PyUnicode_IsDecimalDigitc  r   r   c                 C   r~   r   )r1   r:   r   r"   rz   r,   r,   r-   _PyUnicode_IsSpacek  r   r   c                 C   r~   r   )r1   r:   r   r   rz   r,   r,   r-   _PyUnicode_IsAlphaq  r   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   )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/  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|  r}  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  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   llvmlite.irrB   numpynp
numba.corer   r   r   numba.core.imputilsr   numba.core.extendingr   r	   r
   numba.core.errorsr   r   USE_LEGACY_TYPE_SYSTEMuint32r=   c_uint32_Py_TAB_Py_LINEFEED_Py_CARRIAGE_RETURN	_Py_SPACEr   r1   rh   ru   rx   r}   r   r   r   r   r   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{|}~                                                                                                                                                                                                                                   	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  
  
!
&!$

	























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