o
    ij
                     @   s   d dl Z d dlZd dlmZ d dlmZ d dlmZ edd Zdd Z	ed	d
 Z
dd ZG dd dejZedkrAe  dS dS )    N)types)	intrinsic)jitc                 C   s   t ||}dd }||fS )Nc                 S   s(   |\}}|  |}|||}||S N)get_python_apibytes_from_string_and_sizeZbytes_as_string)contextbuildersigargscsrcsizeapib r   i/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/site-packages/numba/tests/test_pythonapi.pycodegen   s   

z'_pyapi_bytes_as_string.<locals>.codegen)r   Zvoidptr)	typingctxr   r   r
   r   r   r   r   _pyapi_bytes_as_string   s   r   c                 C      t | j| jS r   )r   _data_lengthunir   r   r   PyBytes_AsString   s   r   c                 C   s*   t j||f}|||}dd }||fS )Nc                 S   sp   |\}}|  |}|||}||j}||j}	||||	 ||}
||	}| ||j|
|f}|S r   )	r   r   ZallocaZcstringZ
py_ssize_tZbytes_as_string_and_sizeloadZ
make_tuplereturn_type)r   r	   r
   r   r   r   Zpyapir   Zp_cstrZp_sizecstrtupr   r   r   r   !   s   


z0_pyapi_bytes_as_string_and_size.<locals>.codegen)r   TupleZ
from_types)r   r   r   Zrettyr
   r   r   r   r   _pyapi_bytes_as_string_and_size   s   
r    c                 C   r   r   )r    r   r   r   r   r   r   PyBytes_AsStringAndSize0   s   r!   c                   @   s   e Zd Zdd Zdd ZdS )TestPythonAPIc                 C   sH   t ddt}|d}tjj}tjg|_tj|_||}| 	|d d S )NTZnopythonZhellos   hello)
r   r   ctypes	pythonapiZPyBytes_FromStringc_void_pargtypes	py_objectrestypeassertEqual)selfcfuncr   fnobjr   r   r   test_PyBytes_AsString6   s   
z#TestPythonAPI.test_PyBytes_AsStringc                 C   sV   t ddt}|d}tjj}tjtjg|_tj|_	||d |d }| 
|d d S )NTr#   zhello worldr      s   hello world)r   r!   r$   r%   ZPyBytes_FromStringAndSizer&   Zc_size_tr'   r(   r)   r*   )r+   r,   r   r-   r.   r   r   r   test_PyBytes_AsStringAndSizeC   s   z*TestPythonAPI.test_PyBytes_AsStringAndSizeN)__name__
__module____qualname__r/   r1   r   r   r   r   r"   4   s    r"   __main__)r$   ZunittestZ
numba.corer   Znumba.core.extendingr   Znumbar   r   r   r    r!   ZTestCaser"   r2   mainr   r   r   r   <module>   s    

