The script

This takes only a little extra work; since the __dict__ symbol table contains entries for the module's classes as well, it's a relatively easy matter to shunt off code generation for class objects into functions from the script. In fact, the only difference between the script and the previous two is that all you need to supply is a module name; the script will generate an eiffel class with the same name, and classes for all contained Python classes, prepending the name of the module. The command re, then, will generate not only the RE class, but also the RE__DUMMY class, the RE_MATCHOBJECT class, and the RE_REGEXOBJECT class.

Python modules can be nested, as in a_module.a_submodule.a_subsubmodule; to handle this, the make_all_eiffel_stubs script simply treats this as the name of a single module, replacing periods with underscores to generate an Eiffel-compatible name (for example, exporting the above module would generate the appallingly long-named A_MODULE_A_SUBMODULE_A_SUBSUBMODULE Eiffel class; if that module exported the class a_class, the generated Eiffel class name would be the even more unfortunate A_MODULE_A_SUBMODULE_A_SUBSUBMODULE_A_CLASS)

The addition of Makefile targets for the automatically-generated classes makes including this sort of automation in a makefile relatively easy:

Example 10-5. Makefile targets for the generated classes, from the re_test example

#change this to show the automatically-created Eiffel files
GENERATED_EIFFEL_FILES = re.e re__dummy.e re_matchobject.e re_regexobject.e
#generated by the ePolyglot script ""
	$(PYTHON) $(SCRIPTPATH)/ re appending GENERATED_EIFFEL_FILES to a list of "clean me" files, the build can be easily cleaned by the use of a dummy target.