1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
<!-- Title = calling external code from Eiffel -->
<TABLE BORDER=0 CELLSPACING=5 CELLPADDING=5 COLS=1 WIDTH="100%" BGCOLOR="#3366FF" NOSAVE >
<TR NOSAVE>
<TD NOSAVE>
<CENTER><FONT COLOR="#FFFFFF" SIZE=+3><B>Externals</B></FONT></CENTER>
</TD>
</TR>
</TABLE>
<BR><BR>
<P>
Here is the information you need if you want to call C code, C++ code as
well as Java code from your Eiffel code (to call an Eiffel feature from
C, C++ or Java see
<A HREF="cecil.html"><code>cecil documentation</code></A>).
</P>
<P>
Below is the current list of SmartEiffel <I>external</I> language specifications.
</P>
<BR>
<TABLE BORDER=0 COLS=1 WIDTH="100%" BGCOLOR="#3366FF" NOSAVE >
<TR NOSAVE>
<TD NOSAVE><FONT COLOR="#FFFFFF" SIZE="+2">external "C"</FONT></TD>
</TR>
</TABLE>
<P>
The most common way to call external C code from Eiffel is to use
the <I>external "C"</I> feature definition as described in the book
"Eiffel The Language".
The best is to start to browse examples of the SmartEiffel
distribution in directory <TT>tutorial/external/C</TT> where you'll
find
<TT>external "C", external "C inline", external "C macro"</TT>
examples.
</P>
<BR>
<TABLE BORDER=0 COLS=1 WIDTH="100%" BGCOLOR="#3366FF" NOSAVE >
<TR NOSAVE>
<TD NOSAVE><FONT COLOR="#FFFFFF" SIZE="+2">external "C++"</FONT></TD>
</TR>
</TABLE>
<P>
The most common way to call external C++ code from Eiffel is to use
the <I>external C++</I> feature definition as described in the book
"Eiffel The Language".
The best is to start to browse examples of the SmartEiffel
distribution in directory <TT>tutorial/external/C++</TT> where you'll find
<TT>external "C++"</TT> examples.
</P>
<TABLE BORDER=0 COLS=1 WIDTH="100%" BGCOLOR="#3366FF" NOSAVE >
<TR NOSAVE>
<TD NOSAVE><FONT COLOR="#FFFFFF" SIZE="+2">external "Java"</FONT></TD>
</TR>
</TABLE>
<P>
A brand new interface to call Java method or Java static method is also
available. Obviously, this one is only supported when using the
<TT>compile_to_jvm</TT> command (conversely, previous one are only supported
when using the <TT>compile_to_c</TT> command).
Again, and especially for this brand new one, the best is to start to browse
examples of the SmartEiffel distribution in directory
<TT>tutorial/external/Java</TT>.
</P>
<TABLE BORDER=0 COLS=1 WIDTH="100%" BGCOLOR="#3366FF" NOSAVE >
<TR NOSAVE>
<TD NOSAVE><FONT COLOR="#FFFFFF" SIZE="+2">external "SmartEiffel"</FONT></TD>
</TR>
</TABLE>
<P>
This external specification is reserved to the SmartEiffel compiler itself.
Do not use it. Such a feature is directly supported both by <TT>compile_to_c</TT> and
<TT>compile_to_jvm</TT>.
For example, <I>infix "+"</I> of class INTEGER is directly
mapped as C '+' by <TT>compile_to_c</TT> and mapped as an <TT>iadd</TT>
JVM byte-code by <TT>compile_to_jvm</TT>.
</P>
<TABLE BORDER=0 COLS=1 WIDTH="100%" BGCOLOR="#3366FF" NOSAVE >
<TR NOSAVE>
<TD NOSAVE><FONT COLOR="#FFFFFF" SIZE="+2">Inlining C Code (or assembly code)</FONT></TD>
</TR>
</TABLE>
<P>
Another way to call C code from Eiffel is to use "c_inline_c" or
"c_inline_h" as defined in our GENERAL class.
The argument of "c_inline_c" (or "c_inline_h") must always be a manifest string
which may contains the C code you want to put in lieu.
<BR>
Using c_inline_[c/h] also implies you do know <B>exactly</B> the C code
SmartEiffel produces. For portability, it is also much better to use previous
solutions.
<BR>
People who tinker with the C code generated by SmartEiffel, not limiting
themselves to the Cecil and/or external interfaces, should also read
<A HREF="c_code.html">this page about the C code generated by SmartEiffel</A>,
Otherwise they might get into trouble.
</P>
<CENTER><P><IMG SRC="se-line.gif" ALT="[Line]" HEIGHT=16 WIDTH=550>
<BR>
<I><FONT SIZE=-1>Copyright © Dominique COLNET and Suzanne COLLIN -
<A HREF="mailto:SmartEiffel@loria.fr"><SmartEiffel@loria.fr></A> <BR>
<!-- hhmts start -->
Last modified: Tue Feb 11 12:15:02 CET 2003
<!-- hhmts end -->
<BR>
</FONT></I><BR></P></CENTER>
|