Chapter 17. The supporting Python scripts for code generation

The ePolyglot support libraries contain six stubs of Python code, each performing a single significant task. These scripts are not particularly robust, in that they do not check for accuracy of inputs, etc.; they are designed to be automated through makefile targets rather than used by humans. See the sample makefiles in the examples directory for suggested usage.

eiffel_object.py. The eiffel_object.py file contains the base class eiffel_object, which is used as the base for all Python shadow classes (classes in Python which manipulate Eiffel objects through an opaque pointer). The base eiffel_object class comes with one data feature, swig_pointer, which stores the string representation of the pointer to the Eiffel object, and a function set_pointer to set this value. See the eiffel_from_python and scripting_eiffel examples for its usage.

make_python_shadow_classes.py. The make_python_shadow_classes.py script is used to create all the required shadow classes to automate Eiffel objects in the given project. It takes two command-line arguments: the filename of the CECIL file which will be used to list exported Eiffel features (typically cecil.se), and the filename of the generated documentation file, produced by SWIG (typically eiffel-glue_wrap.doc). Because it requires a file which is generated by SWIG, you must run SWIG on the desired module interface file first. This file (typically eiffel-glue.i) is generated by the make_eiffel_glue_i.py script. See the eiffel_from_python and scripting_eiffel examples for its usage.

make_eiffel_glue_i.py. This script takes a C-compatible header file produced by SmallEiffel in conjunction with a CECIL file. Typically, this file will be named eiffel-glue.h. The script takes the exported Eiffel functions and spits out a SWIG-compatible interface definition file. See the eiffel_from_python and scripting_eiffel examples for its usage.

make_eiffel_stub.py. This script takes a Python module name and class name as an argument and generates an Eiffel source file to standard output for the appropriate shadow class (used from Eiffel to automate Python objects). It is usually used in conjunction with make_all_eiffel_stubs.py to export the contents of a module. See the smtp example for its usage.

make_eiffel_module_stub.py. This script takes a Python module name and generates an Eiffel source file to standard output to shadow the services of that module. Typically, however, using a module also entails using many of its module-defined classes. To export the entire contents of a module, including Eiffel shadow classes for each of the module-defined Python classes, it is generally better to use make_all_eiffel_stubs.py

make_all_eiffel_stubs.py. This script takes a Python module name and generates several Eiffel source files, named appropriately. It also generates one Eiffel source file for each class that the module defines, named in the MODULENAME_CLASSNAME convention. Useful for exporting entire Python modules at once, and the preferred method for doing so. See the re example for its usage.