File: external.html

package info (click to toggle)
smarteiffel 1.1-11
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 12,288 kB
  • ctags: 40,785
  • sloc: ansic: 35,791; lisp: 4,036; sh: 1,783; java: 895; ruby: 613; python: 209; makefile: 115; csh: 78; cpp: 50
file content (112 lines) | stat: -rw-r--r-- 4,015 bytes parent folder | download | duplicates (2)
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&nbsp;"C", external&nbsp;"C&nbsp;inline", external&nbsp;"C&nbsp;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&nbsp;"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 &copy; Dominique COLNET and Suzanne COLLIN -
<A HREF="mailto:SmartEiffel@loria.fr">&lt;SmartEiffel@loria.fr&gt;</A> <BR>
<!-- hhmts start -->
Last modified: Tue Feb 11 12:15:02 CET 2003
<!-- hhmts end -->
<BR>
</FONT></I><BR></P></CENTER>