§
    ƒÛgã  ã                   ó  — d dl Z d dlZd dlmZ d dlmc mc mZ	 d dl
mZmZ d dlmZmZ d dlmZmZmZ d dlmc mZ d dlZ e¦   «         Zde_         e¦   «         Ze G d„ de¦  «        ¦   «         Zed	k    r ej        ¦   «          dS dS )
é    N)Újit)ÚtypesÚerrors)Úcompile_isolatedÚFlags)ÚTestCaseÚskip_unless_cffiÚtagTc                   ó˜   — e Zd ZdZd„ Zd„ Zefd„Zd„ Zd„ Z	d„ Z
ef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 )ÚTestCFFIFc                 óR   — t          j        ¦   «          t          j        ¦   «          d S ©N)ÚmodÚinitÚinit_ool©Úselfs    úK/granary/edev/quantum/lib/python3.11/site-packages/numba/tests/test_cffi.pyÚsetUpzTestCFFI.setUp   s   € ÝŒ‰
Œ
ˆ
ÝŒ‰Œˆˆˆó    c                 ó"  — t          j        t          j                             t          j        ¦  «        ¦  «        }|                      t          |j        ¦  «        d¦  «         |                      |j        d         t          j
        ¦  «         d S )Né   r   )Úcffi_supportÚmap_typer   ÚffiÚtypeofÚcffi_sinÚassertEqualÚlenÚargsr   Údouble)r   Ú	signatures     r   Útest_type_mapzTestCFFI.test_type_map   sg   € Ý Ô)­#¬'¯.ª.½¼Ñ*FÔ*FÑGÔGˆ	Ø×Ò�˜Yœ^Ñ,Ô,¨aÑ0Ô0Ð0Ø×Ò˜œ¨Ô*­E¬LÑ9Ô9Ð9Ð9Ð9r   c                 ó¨   — t          |t          j        g|¬¦  «        }|j        }dD ]*}|                       ||¦  «         ||¦  «        ¦  «         Œ+d S )N©Úflags)g333333ó¿éÿÿÿÿr   gš™™™™™¹?g…ëQ¸	@)r   r   r!   Úentry_pointÚassertPreciseEqual)r   Úpyfuncr&   ÚcresÚcfuncÚxs         r   Ú_test_functionzTestCFFI._test_function$   sd   € Ý ­¬¨¸eÐDÑDÔDˆØÔ ˆà)ð 	9ð 	9ˆAØ×#Ò# F F¨1¡I¤I¨u¨u°Q©x¬xÑ8Ô8Ð8Ð8ð	9ð 	9r   c                 óD   — |                       t          j        ¦  «         d S r   )r.   r   Úuse_cffi_sinr   s    r   Útest_sin_functionzTestCFFI.test_sin_function+   s   € Ø×Ò�CÔ,Ñ-Ô-Ð-Ð-Ð-r   c                 óÒ   — t           j        }t          |dt          ¬¦  «        }|j        }|                       |¦   «         d¦  «         |                       |¦   «         d¦  «         d S )N© r%   T)r   Úuse_cffi_boolean_truer   Úno_pyobj_flagsr(   r   )r   r*   r+   r,   s       r   Útest_bool_function_oolzTestCFFI.test_bool_function_ool.   sd   € ÝÔ*ˆÝ ¨µ.ÐAÑAÔAˆØÔ ˆØ×Ò˜˜™œ 4Ñ(Ô(Ð(Ø×Ò˜˜™œ $Ñ'Ô'Ð'Ð'Ð'r   c                 óR   — |                       t          j        t          ¬¦  «         d S ©Nr%   )r.   r   r0   r5   r   s    r   Útest_sin_function_npmzTestCFFI.test_sin_function_npm5   s$   € Ø×Ò�CÔ,µNÐÑCÔCÐCÐCÐCr   c                 óD   — |                       t          j        ¦  «         d S r   )r.   r   Úuse_cffi_sin_ool)r   r&   s     r   Útest_sin_function_oolzTestCFFI.test_sin_function_ool8   s   € Ø×Ò�CÔ0Ñ1Ô1Ð1Ð1Ð1r   c                 óR   — |                       t          j        t          ¬¦  «         d S r8   )r.   r   r;   r5   r   s    r   Útest_sin_function_npm_oolz"TestCFFI.test_sin_function_npm_ool;   s$   € Ø×Ò�CÔ0½ÐÑGÔGÐGÐGÐGr   c                 óD   — |                       t          j        ¦  «         d S r   )r.   r   Úuse_two_funcsr   s    r   Útest_two_funcszTestCFFI.test_two_funcs>   s   € à×Ò�CÔ-Ñ.Ô.Ð.Ð.Ð.r   c                 óD   — |                       t          j        ¦  «         d S r   )r.   r   Úuse_two_funcs_oolr   s    r   Útest_two_funcs_oolzTestCFFI.test_two_funcs_oolB   s   € Ø×Ò�CÔ1Ñ2Ô2Ð2Ð2Ð2r   c                 ó^  — t           j        } t          d¬¦  «        |¦  «        }t           j        t           j        dft           j        t           j        dft           j        t           j        dft           j        t           j        dft           j        t           j        dft           j        t           j        dft           j        t           j        dft           j        t           j        dft           j        t           j        dft           j        t           j        dft           j        t           j        dft           j        t           j        dffD ]6\  }}} ||||¦  «        } ||||¦  «        }|                      ||¦  «         Œ7|                      t          |j	        ¦  «        d|j	        ¦  «         d S )NT©Únopythong      ð?g      ð¿r   )
r   Úuse_func_pointerr   r   Úcffi_cosÚcffi_sin_oolÚcffi_cos_oolr   r   Ú	overloads)r   r*   r,   ÚfaÚfbr-   ÚexpectedÚgots           r   Útest_function_pointerzTestCFFI.test_function_pointerE   sZ  € ÝÔ%ˆØ"•˜TÐ"Ñ"Ô" 6Ñ*Ô*ˆåŒ\�3œ<¨Ð-ÝŒ\�3œ<¨Ð.ÝŒ\�3œ<¨Ð-ÝŒ\�3œ<¨Ð.ÝÔ�sÔ/°Ð5ÝÔ�sÔ/°Ð6ÝÔ�sÔ/°Ð5ÝÔ�sÔ/°Ð6ÝŒ\�3Ô+¨SÐ1ÝŒ\�3Ô+¨TÐ2ÝŒ\�3Ô+¨SÐ1ÝŒ\�3Ô+¨TÐ2ð4ð 	,ð 	,‰KˆR��Qð �v˜b " aÑ(Ô(ˆHØ�%˜˜B Ñ"Ô"ˆCØ×Ò˜S (Ñ+Ô+Ð+Ð+à×Ò�˜Uœ_Ñ-Ô-¨q°%´/ÑBÔBÐBÐBÐBr   c                 óœ   — t           j        } t          d¬¦  «        |¦  «        }|                       |¦   «          |¦   «         ¦  «         d S )NTrF   )r   Úuse_user_defined_symbolsr   r   )r   r*   r,   s      r   Útest_user_defined_symbolsz"TestCFFI.test_user_defined_symbols[   sL   € ÝÔ-ˆØ"•˜TÐ"Ñ"Ô" 6Ñ*Ô*ˆØ×Ò˜˜™œ 5 5¡7¤7Ñ+Ô+Ð+Ð+Ð+r   c                 ó‚   —  |||¦  «         t           j                             |t          j        |¦  «        ¦  «         d S r   )ÚnpÚtestingÚassert_allcloseÚsin)r   r,   r-   Úys       r   Úcheck_vector_sinzTestCFFI.check_vector_sin`   s7   € Øˆˆa�‰ŒˆÝ
Œ
×"Ò" 1¥b¤f¨Q¡i¤iÑ0Ô0Ð0Ð0Ð0r   c                 óÜ   — t          j        d¦  «                             |¦  «        }t          j        |¦  «        } t	          d¬¦  «        |¦  «        }|                      |||¦  «         d S )Né
   TrF   )rV   ÚarangeÚastypeÚ
zeros_liker   r[   )r   r*   Údtyper-   rZ   r,   s         r   Ú_test_from_buffer_numpy_arrayz&TestCFFI._test_from_buffer_numpy_arrayd   sd   € ÝŒI�b‰MŒM× Ò  Ñ'Ô'ˆÝŒM˜!ÑÔˆØ"•˜TÐ"Ñ"Ô" 6Ñ*Ô*ˆØ×Ò˜e Q¨Ñ*Ô*Ð*Ð*Ð*r   c                 óZ   — |                       t          j        t          j        ¦  «         d S r   )rb   r   Úvector_sin_float32rV   Úfloat32r   s    r   Útest_from_buffer_float32z!TestCFFI.test_from_buffer_float32j   ó#   € Ø×*Ò*­3Ô+AÅ2Ä:ÑNÔNÐNÐNÐNr   c                 óZ   — |                       t          j        t          j        ¦  «         d S r   )rb   r   Úvector_sin_float64rV   Úfloat64r   s    r   Útest_from_buffer_float64z!TestCFFI.test_from_buffer_float64m   rg   r   c                 óè  — d}t          j        |¦  «        t          j        |dz  |dz  ¦  «        dz  z   }t          j        |¦  «        } t          d¬¦  «        t          j        ¦  «        } |||¦  «         t           j                             |j        |¦  «          t          d¬¦  «        t          j	        ¦  «        } |||¦  «         t           j                             |j
        |¦  «         d S )Nr]   é   é   y              ð?TrF   )rV   r^   Úzerosr   r   Úvector_extract_realrW   Úassert_equalÚrealÚvector_extract_imagÚimag)r   Únr-   rZ   Ú
real_cfuncÚ
imag_cfuncs         r   Útest_from_buffer_structz TestCFFI.test_from_buffer_structp   s×   € ØˆÝŒI�a‰LŒL�2œ9 Q¨¡U¨A°©EÑ2Ô2°RÑ7Ñ7ˆÝŒH�Q‰KŒKˆØ'•S $Ð'Ñ'Ô'­Ô(?Ñ@Ô@ˆ
Øˆ
�1�aÑÔÐÝ
Œ
×Ò ¤¨Ñ*Ô*Ð*Ø'•S $Ð'Ñ'Ô'­Ô(?Ñ@Ô@ˆ
Øˆ
�1�aÑÔÐÝ
Œ
×Ò ¤¨Ñ*Ô*Ð*Ð*Ð*r   c                 ó  — t           j        } t          d¬¦  «        |¦  «        }t          j        dt	          d¦  «        ¦  «        }t          j        ddgt          |¦  «        z  ¦  «        }|                      |||¦  «         d S )NTrF   Úfr]   r   )r   rd   r   ÚarrayÚranger   r[   )r   r*   r,   r-   rZ   s        r   Útest_from_buffer_pyarrayz!TestCFFI.test_from_buffer_pyarray{   sv   € ÝÔ'ˆØ"•˜TÐ"Ñ"Ô" 6Ñ*Ô*ˆÝŒK˜�U 2™YœYÑ'Ô'ˆÝŒK˜˜a˜S¥3 q¡6¤6™\Ñ*Ô*ˆØ×Ò˜e Q¨Ñ*Ô*Ð*Ð*Ð*r   c                 óÂ  — t           j        } t          d¬¦  «        |¦  «        }t          j        d¦  «                             t          j        ¦  «        d d d…         }t          j        |¦  «        }|                      t          j
        ¦  «        5 } |||¦  «         d d d ¦  «         n# 1 swxY w Y   |                      dt          |j        ¦  «        ¦  «         d S )NTrF   r]   rm   z3from_buffer() unsupported on non-contiguous buffers)r   rd   r   rV   r^   r_   re   r`   ÚassertRaisesr   ÚTypingErrorÚassertInÚstrÚ	exception)r   r*   r,   r-   rZ   Úraisess         r   Útest_from_buffer_errorzTestCFFI.test_from_buffer_error‚   s  € ÝÔ'ˆØ"•˜TÐ"Ñ"Ô" 6Ñ*Ô*ˆåŒI�b‰MŒM× Ò ¥¤Ñ,Ô,¨S¨S¨q¨SÔ1ˆÝŒM˜!ÑÔˆØ×Ò�vÔ1Ñ2Ô2ð 	°fØˆE�!�Q‰KŒKˆKð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	à�ŠÐKÝ˜&Ô*Ñ+Ô+ñ	-ô 	-ð 	-ð 	-ð 	-s   ÂB,Â,B0Â3B0c                 óB  — t          j        ddgdt           j        ¬¦  «        }t          j        |¦  «        }t          j        ddgddggdt           j        ¬¦  «        }t          j        |¦  «        }t          j        ddgdt           j        ¬¦  «        }t          j        |¦  «        }t          j        ddgddggdt           j        ¬¦  «        }t          j        |¦  «        }|                     d¦  «        }	t
          j        }
 t          d	¬
¦  «        |
¦  «        }|                      |||¦  «          |||¦  «         t          j	        |¦  «        }ddg|d<   t           j
                             ||¦  «         |                      |||¦  «         |                      t          j        ¦  «        5 } |||¦  «         d d d ¦  «         n# 1 swxY w Y   t           j
                             ||	¦  «         |                      dt!          |j        ¦  «        ¦  «         d S )Nr   rm   ÚC)Úorderra   rn   é   ÚFÚKTrF   r   zAfrom_buffer() only supports multidimensional arrays with C layout)rV   r{   re   r`   Úcopyr   rd   r   r[   rY   rW   rX   r   r   r€   r�   r‚   rƒ   )r   Úc1Úc1_zerosÚc2Úc2_zerosÚf1Úf1_zerosÚf2Úf2_zerosÚf2_copyr*   r,   Úsin_c2r„   s                 r   Ú"test_from_buffer_numpy_multi_arrayz+TestCFFI.test_from_buffer_numpy_multi_array�   s)  € ÝŒX�q˜!�f C­r¬zÐ:Ñ:Ô:ˆÝ”= Ñ$Ô$ˆÝŒX˜˜1�v  1˜vÐ&¨c½¼ÐDÑDÔDˆÝ”= Ñ$Ô$ˆÝŒX�q˜!�f C­r¬zÐ:Ñ:Ô:ˆÝ”= Ñ$Ô$ˆÝŒX˜˜1�v  1˜vÐ&¨c½¼ÐDÑDÔDˆÝ”= Ñ$Ô$ˆØ—'’'˜#‘,”,ˆÝÔ'ˆØ"•˜TÐ"Ñ"Ô" 6Ñ*Ô*ˆà×Ò˜e R¨Ñ2Ô2Ð2àˆˆb�(ÑÔÐÝ”˜‘”ˆØ˜�Fˆˆq‰	Ý
Œ
×"Ò" 8¨VÑ4Ô4Ð4à×Ò˜e R¨Ñ2Ô2Ð2à×Ò�vÔ1Ñ2Ô2ð 	 °fØˆE�"�hÑÔÐð	 ð 	 ð 	 ñ 	 ô 	 ð 	 ð 	 ð 	 ð 	 ð 	 ð 	 øøøð 	 ð 	 ð 	 ð 	 å
Œ
×"Ò" 2 wÑ/Ô/Ð/Ø�ŠÐYÝ˜&Ô*Ñ+Ô+ñ	-ô 	-ð 	-ð 	-ð 	-s   Æ3GÇGÇGc                 ó  ‡‡— t           j        Št          d¬¦  «        ˆfd„¦   «         Št          d¬¦  «        ˆˆfd„¦   «         }d}|                       ||¦  «         ‰|¦  «         ‰|dz   ¦  «        z   ¦  «         dS )zj
        Issue #2263

        Linkage error due to multiple definition of global tracking symbol.
        TrF   c                 ó   •—  ‰| ¦  «        S r   r3   )r-   Úmy_sins    €r   Úinnerz2TestCFFI.test_indirect_multiple_use.<locals>.inner³   s   ø€ à�6˜!‘9”9Ðr   c                 ó8   •—  ‰| ¦  «         ‰| dz   ¦  «        z   S )Nr   r3   )r-   r›   rš   s    €€r   Úfooz0TestCFFI.test_indirect_multiple_use.<locals>.foo·   s"   ø€ à�5˜‘8”8˜f˜f Q¨¡U™mœmÑ+Ð+r   g+‡ÙÎ÷ñ?r   N)r   r   r   r   )r   r�   r-   r›   rš   s      @@r   Útest_indirect_multiple_usez#TestCFFI.test_indirect_multiple_use©   s¸   øø€ õ ”ˆõ 
�dÐ	Ñ	Ô	ð	ð 	ð 	ð 	ñ 
Ô	ð	õ 
�dÐ	Ñ	Ô	ð	,ð 	,ð 	,ð 	,ð 	,ñ 
Ô	ð	,ð ˆØ×Ò˜˜˜Q™œ  ¨¡¤¨V¨V°A¸±E©]¬]Ñ!:Ñ;Ô;Ð;Ð;Ð;r   N)Ú__name__Ú
__module__Ú__qualname__Ú_numba_parallel_test_r   r#   Úenable_pyobj_flagsr.   r1   r6   r9   r<   r>   rA   rD   rQ   rT   r[   rb   rf   rk   rx   r}   r…   r—   rž   r3   r   r   r   r      sz  € € € € € ð
 "Ððð ð ð:ð :ð :ð
 ,>ð 9ð 9ð 9ð 9ð.ð .ð .ð(ð (ð (ðDð Dð Dð +=ð 2ð 2ð 2ð 2ðHð Hð Hð/ð /ð /ð3ð 3ð 3ðCð Cð Cð,,ð ,ð ,ð
1ð 1ð 1ð+ð +ð +ðOð Oð OðOð Oð Oð	+ð 	+ð 	+ð+ð +ð +ð	-ð 	-ð 	-ð-ð -ð -ð8<ð <ð <ð <ð <r   r   Ú__main__)r{   ÚnumpyrV   Únumbar   Únumba.core.typing.cffi_utilsÚcoreÚtypingÚ
cffi_utilsr   Ú
numba.corer   r   Únumba.core.compilerr   r   Únumba.tests.supportr   r	   r
   Únumba.tests.cffi_usecasesÚtestsÚcffi_usecasesr   Úunittestr£   Úenable_pyobjectr5   r   rŸ   Úmainr3   r   r   ú<module>r´      sJ  ðØ €€€Ø Ð Ð Ð à Ð Ð Ð Ð Ð Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø $Ð $Ð $Ð $Ð $Ð $Ð $Ð $Ø 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ø ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?à 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø €€€ð �U‘W”WÐ Ø%)Ð Ô "à�‘”€ð ðh<ð h<ð h<ð h<ð h<ˆxñ h<ô h<ñ Ôðh<ðV ˆzÒÐØ€H„M�O„O€O€O€Oð Ðr   