ó
    ‹Âj„  ã                   ó@  • S r SSKrSSKrSSKrSSKrSSKJr  S rS rS r	S r
S	 rS
 rS rS rS r\R                   " \" 5       SS9r\R%                  SS9r\R)                  SSS9r\R-                  SSSS9  \R-                  S\R.                  " SSS9SS9  \R-                  SS S9  \R)                  S!S"S9r\R-                  S#S$S9  \R-                  S%\R.                  " SSS9S&S9  \R-                  S'\R.                  " SSS9S(S9  \R-                  SS S9  S*S) jrg)+aê  Implementation of the ``cffi-gen-src`` command-line tool.

This module is private; the command line is the only supported
interface. Two subcommands:

``exec-python``
    Execute a Python script that constructs a :class:`cffi.FFI`
    (the same kind of script that the CFFI docs' "Main mode of usage"
    describes) and emit the generated C source.

``read-sources``
    Create the :class:`cffi.FFI` from a separate ``cdef`` file and C
    source prelude, then emit the generated C source.
é    Né   )ÚFFIc                 ó0   • [        XSS9n[        X2U5        g )NÚexec)ÚsourceÚfilenameÚmode)Úcompiler   )Úpysrcr   ÚglobsÚcompileds       ÚH/var/www/website/venv/lib/python3.13/site-packages/cffi/_cffi_gen_src.pyÚ	_execfiler   3   s   € Ü˜e¸VÑD€HÜˆ˜%Õ ó    c                 ó2  • [         R                  R                  U5      nSUS.n[        R                  SS n[        R                  R	                  S[         R                  R                  U5      5         [        XU5        X#;  a  [        SU< S35      eX2   n[        U[        5      (       d  [        U5      (       a  U" 5       n[        U[        5      (       d  [        SU< S35      eUU[        R                  SS& $ ! U[        R                  SS& f = f)	aæ  Execute ``pysrc`` and return the :class:`FFI` object it defines.

The script is executed with ``__name__`` set to ``"cffi.gen_src"``,
so a trailing ``if __name__ == "__main__": ffibuilder.compile()``
block in the script is skipped.

``ffivar`` is the name bound by the script to the :class:`FFI`
object, or to a callable that returns one.

Raises :class:`NameError` if the name is not bound by the script,
or :class:`TypeError` if the name does not resolve to an
:class:`FFI` instance.
zcffi.gen_src)Ú__name__Ú__file__Nr   z.Expected to find the FFI object with the name z, but it was not found.zFound an object with the name z+ but it was not an instance of cffi.api.FFI)ÚosÚpathÚabspathÚsysÚinsertÚdirnamer   Ú	NameErrorÚ
isinstancer   ÚcallableÚ	TypeError)r   r   Úffivarr   Úold_pathÚffis         r   Úfind_ffi_in_python_scriptr!   8   sÝ   € ô �w‰w�‰˜xÓ(€HØ'°XÑ>€EÜ�x‰x™ˆ{€HÜ‡H�H‡O�O�A”r—w‘w—‘ xÓ0Ô1ðÜ�% 5Ô)ØÓÝã+1ð4óð ð ‰mˆÜ˜#œs×#Ñ#¬°¯©á“%ˆCÜ˜#œs×#Ñ#Ýã.4ð7óð ð àŒ�‰‘‰ø�hŒ�‰‘‰ús   Á6A7D ÄDc                 ó^   • [        5       nUR                  U5        UR                  X5        U$ )zACreate an :class:`FFI` from ``cdef`` text and a C source prelude.)r   ÚcdefÚ
set_source)Ú
modulenamer#   ÚcsrcÚ
ffibuilders       r   Úmake_ffi_from_sourcesr(   _   s)   € ä“€JØ‡O�O�DÔØ×Ñ˜*Ô+ØÐr   c                 ón   • [         R                  " 5       nU R                  U5        UR                  5       $ )z=Return the C source that :meth:`FFI.emit_c_code` would write.)ÚioÚStringIOÚemit_c_codeÚgetvalue)r    Úoutputs     r   Úgenerate_c_sourcer/   g   s&   € ä�[Š[‹]€FØ‡O�O�FÔØ�?‰?ÓÐr   c                 ó¼   • U S:X  a   [         R                  R                  U5        g [        U SSS9 nUR                  U5        S S S 5        g ! , (       d  f       g = f)NÚ-Úwúutf-8©Úencoding)r   ÚstdoutÚwriteÚopen)r.   Ú	generatedÚfs      r   Úwrite_c_sourcer;   n   sD   € Ø�ƒ}Ü�
‰
×Ñ˜Ô#ØÜ	ˆf�c GÒ	,°Ø	�‰�	Ô÷ 
-×	,Ö	,ús   ²AÁ
Ac                 ó–   • XL a  g [         R                  R                  U R                  UR                  5      $ ! [         a     gf = f)NTF)r   r   ÚsamefileÚnameÚOSError)Úfile1Úfile2s     r   Úsame_input_filerB   v   s@   € Ø‚~ØðÜ�w‰w×Ñ §
¡
¨E¯J©JÓ7Ð7øÜó Ùðús   ‡3; »
AÁAc                 ó²   • U   [        UR                  5       UR                  U5      nS S S 5        [        W5      n[	        X5        g ! , (       d  f       N%= f©N)r!   Úreadr>   r/   r;   )r.   ÚpyfileÚffi_varr    r9   s        r   Úexec_pythonrH      s<   € Ú	Ü'¨¯©«°v·{±{ÀGÓLˆ÷ 
ä! #Ó&€IÜ�6Õ%÷ 
�ús   ƒ&AÁ
Ac                 óú   • U   U   UR                  5       nUR                  5       nS S S 5        S S S 5        [        UWW5      n[        U5      n[        X5        g ! , (       d  f       N:= f! , (       d  f       NC= frD   )rE   r(   r/   r;   )r.   Úmodule_nameÚ
cdef_inputÚ
csrc_inputr&   r#   r    r9   s           r   Úread_sourcesrM   †   sU   € Ú	’ZØ�‰Ó ˆØ�‰Ó ˆ÷  �ô   ¨T°4Ó
8€CÜ! #Ó&€IÜ�6Õ%÷  •Zú��ús!   ƒA,†!A§A,Á
A)	Á%A,Á,
A:c                  óÀ   • [         R                  (       a0  [        R                  R	                  [         R                  S   5      OSn U R                  S5      (       a  gg)Nr   Ú zcffi-gen-srczpython -m cffi.gen_src)r   Úargvr   r   ÚbasenameÚ
startswith)Úargv0s    r   Ú_progrT   �   s?   € ô .1¯X¯XŒB�G‰G×ÑœSŸX™X a™[Ô)¸2€EØ×Ñ˜×'Ñ'ØØ#r   z-Generate CFFI C source for extension modules.)ÚprogÚdescriptionr	   )Údestúexec-pythonz2Execute a Python script that defines an FFI object)Úhelpz	--ffi-varr'   zFName of the FFI object in the Python script; defaults to 'ffibuilder'.)ÚdefaultrY   rF   Úrr3   r4   zPath to the Python script)ÚtyperY   r.   zOutput path for the C sourceúread-sourcesz>Read cdef and C source prelude files that define an FFI objectrJ   z5Full name of the generated module, including packagesr#   zFile containing C definitionsr&   z File containing C source preludec                 óð  • [         R                  U S9n U R                  S:X  a*  [        U R                  U R
                  U R                  S9  O”U R                  S:X  ao  [        U R                  U R                  5      (       a  [         R                  S5        [        U R                  U R                  U R                  U R                  S9  O[         R                  S5        [         R                  S5        g )	N©ÚargsrX   )r.   rF   rG   r]   z1cdef and csrc are the same file and should not be)r.   rJ   rK   rL   z5a subcommand is required: exec-python or read-sourcesr   )ÚparserÚ
parse_argsr	   rH   r.   rF   rG   rB   r#   r&   ÚerrorrM   rJ   Úexitr_   s    r   Úrunre   É   s§   € Ü×Ñ $ÐÐ'€DØ‡y�y�MÓ!Ü˜4Ÿ;™;¨t¯{©{ÀDÇLÁLÓQØ	�‰�nÓ	$Ü˜4Ÿ9™9 d§i¡i×0Ñ0Ü�L‰LÐLÔMÜØ—;‘;Ø×(Ñ(Ø—y‘yØ—y‘yó		
ô 	�‰ÐLÔMÜ
‡K�K�…Nr   rD   )Ú__doc__Úargparser*   r   r   Úapir   r   r!   r(   r/   r;   rB   rH   rM   rT   ÚArgumentParserra   Úadd_subparsersÚ
subparsersÚ
add_parserÚexec_python_parserÚadd_argumentÚFileTypeÚread_sources_parserre   © r   r   Ú<module>rr      s§  ðñ8ó Û 	Û 	Û 
å ò!ò
$òNòòòò&ò&ò$ð 
×	 Ò	 Ù	‹Ø?ñ
€ð ×"Ñ"¨Ð"Ð/€
à×*Ñ*ØØ	=ð +ð Ð ð × Ñ ØØØ	Qð  ñ ð
 × Ñ ØØ	×	Ò	˜3¨Ñ	1Ø	$ð  ñ ð
 × Ñ ØØ	'ð  ñ ð
 !×+Ñ+ØØ	Ið ,ð Ð ð ×  Ñ  ØØ	@ð !ñ ð ×  Ñ  Ø
Ø	×	Ò	˜3¨Ñ	1Ø	(ð !ñ ð
 ×  Ñ  Ø
Ø	×	Ò	˜3¨Ñ	1Ø	+ð !ñ ð
 ×  Ñ  ØØ	'ð !ñ õr   