← Back
Editing: _cffi_gen_src.cpython-312.pyc
� 4��j� � � � d Z ddlZddlZddlZddlZddlmZ d� Zd� Zd� Z d� Z d � Zd � Zd� Z d� Zd � Z ej e� d�� Zej% d�� Zej) dd�� Zej- ddd�� ej- d ej. dd�� d�� ej- dd �� ej) d!d"�� Zej- d#d$�� ej- d% ej. dd�� d&�� ej- d' ej. dd�� d(�� ej- dd �� d*d)�Zy)+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 �: � t | |d�� }t |||� y )N�exec)�source�filename�mode)�compiler )�pysrcr �globs�compileds �N/root/parts/certbot/install/lib/python3.12/site-packages/cffi/_cffi_gen_src.py� _execfiler 3 s � ��e�h�V�D�H���5�%� � c � � t j j |� }d|d�}t j dd }t j j dt j j |� � t | ||� ||vrt d|�d�� �|| }t |t � st |� r |� }t |t � st d|�d�� �||t j dd S # |t j dd w xY w) 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. zcffi.gen_src)�__name__�__file__Nr z.Expected to find the FFI object with the name z, but it was not found.zFound 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�� � �F�m���#�s�#��� ��%�C��#�s�#��.4�7�� � ��������h������s �6A'C1 �1Dc �` � t � }|j |� |j | |� |S )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�����*�d�+��r c �l � t j � }| j |� |j � S )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&