home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / man / cecil.txt < prev    next >
Text File  |  1999-06-05  |  3KB  |  76 lines

  1.  
  2.                                    Cecil
  3.                                       
  4.    Here is the information you need if you want to call some Eiffel
  5.    features from C code. To call C functions/macros from Eiffel see the
  6.    documentation about [1]externals (man/external in the distribution).
  7.    
  8.    In order to call some Eiffel feature from C, you must use the -cecil
  9.    <cecil_file> option with command compile or compile_to_c. The
  10.    <cecil_file> allows you to give the list of features you want to call
  11.    from C. The corresponding stub routines will be automatically
  12.    generated by SmallEiffel.
  13.    When the -cecil option is used, command compile_to_c also produces an
  14.    additional C heading file which includes the needed C prototypes.
  15.    
  16.    Your <cecil_file> must contain at least two lines. The first line is
  17.    the name of the C heading file to produce (it may be useful if you
  18.    need to create a C library). Other lines have the following structure:
  19.    
  20.                 <c_name> <living_eiffel_type> <feature_name>
  21.                                       
  22.    The <c_name> is the name of the C function defined by compile_to_c to
  23.    wrap the Eiffel call. The couple <living_eiffel_type> <feature_name>
  24.    gives the complete name of the Eiffel feature to call. For example:
  25.    
  26.                       IsEiffelStringEmpty STRING empty
  27.                            STRINGitem STRING item
  28.                           strgrtr STRING infix ">"
  29.                   array_of_int_count ARRAY[INTEGER] count
  30.                                   X_f X f
  31.                                       
  32.    Keep in mind that the <living_eiffel_type> must be really alive: if
  33.    <living_eiffel_type> is ARRAY[INTEGER] for example, your Eiffel
  34.    program is supposed to create at least one ARRAY[INTEGER].
  35.    
  36.    The name of the feature to call, <feature_name> may even be an infix
  37.    or a prefix feature name. The syntax is the same as the one used in
  38.    Eiffel source.
  39.    
  40.    Since attributes are features, if is of course possible to access them
  41.    with this mechanism.
  42.    
  43.    A call to X_f in the C code is equivalent to a call to x.f in Eiffel,
  44.    with x of type X or any descendant of X. Indeed,X_f takes care of late
  45.    binding. This means that X_f can be called on any (Current) argument
  46.    of type X or heir of X.
  47.    
  48.    As <cecil_file> is parsed by the SmallEiffel parser, it may contain
  49.    Eiffel comments.
  50.    
  51.    Here is one example of a Cecil file (others can be found in
  52.    directories SmallEiffel/lib_show/cecil/example*):
  53. -- The name of the include C file :
  54. eiffel.h
  55. -- The features you want to call from C :
  56. array_of_animal_item    ARRAY[ANIMAL]   item
  57. array_of_animal_lower   ARRAY[ANIMAL]   lower
  58. array_of_animal_upper   ARRAY[ANIMAL]   upper
  59. cry                     ANIMAL          cry
  60. string_to_external      STRING          to_external
  61.  
  62.    People who tinker with the C code generated by SmallEiffel, not
  63.    limiting themselves to the Cecil and/or external interfaces, should
  64.    also read [2]this page about the C code generated by SmallEiffel.
  65.    Otherwise they might get into trouble.
  66.    
  67.                                    [Line]
  68.    Copyright © Dominique COLNET and Suzanne COLLIN - [3]<colnet@loria.fr>
  69.               Last update: Monday December 7th, 1998, by OZ. 
  70.  
  71. References
  72.  
  73.    1. file://localhost/home/colnet/SmallEiffel/man/man/external.html
  74.    2. file://localhost/home/colnet/SmallEiffel/man/man/c_code.html
  75.    3. mailto:colnet@loria.fr
  76.