Here is the information you need if you want to call some Eiffel
features from C code. To call C functions/macros from Eiffel see
the documentation about externals
In order to call some Eiffel feature from C, you must use the
-cecil <cecil_file> option with command compile
The <cecil_file> allows you to give the list of features
you want to call from C. The corresponding stub routines will be
automatically generated by SmartEiffel.
Your <cecil_file> must contain at least two lines. The first line is the name of the C heading file to produce (it may be useful if you need to create a C library). Other lines have the following structure:
The <c_name> is the name of the C function defined by compile_to_c to wrap the Eiffel call. The couple <live_eiffel_type> <feature_name> gives the complete name of the Eiffel feature to call. For example:
Keep in mind that the <live_eiffel_type> must be really live: if <live_eiffel_type> is ARRAY[INTEGER] for example, your Eiffel program is supposed to create at least one ARRAY[INTEGER].
The name of the feature to call, <feature_name> may even be an infix or a prefix feature name. The syntax is the same as the one used in Eiffel source.
Since attributes are features, if is of course possible to access them with this mechanism.
A call to X_f in the C code is equivalent to a call to x.f in Eiffel, with x of type X or any descendant of X. Indeed, X_f takes care of late binding. This means that X_f can be called on any (Current) argument of type X or heir of X.
As <cecil_file> is parsed by the SmartEiffel parser, it may contain Eiffel comments.
Here is one example of a Cecil file (others can be found in directories SmartEiffel/tutorial/cecil/example*):
-- The name of the include C file : eiffel.h -- The features you want to call from C : array_of_animal_item ARRAY[ANIMAL] item array_of_animal_lower ARRAY[ANIMAL] lower array_of_animal_upper ARRAY[ANIMAL] upper cry ANIMAL cry string_to_external STRING to_externalPeople who tinker with the C code generated by SmartEiffel, not limiting themselves to the Cecil and/or external interfaces, should also read this page about the C code generated by SmartEiffel. Otherwise they might get into trouble.