Re: GEC Compilation of Externals
"Brian Heilig" <Brian.Heilig-tdt4z+Mb/[email protected]>
| Newsgroups | gmane.comp.lang.eiffel.gobo.general |
|---|---|
| Message-ID | <[email protected]> |
I wrote:
> I seem to remember trying this and it didn't work in some cases.
> It's been a while. I'll try it again when I get a chance.
>
> Brian
I remember now. I figured out how to make statements work with all
three compilers by adding a semi-colon, just as you suggested. What I
couldn't figure out were functions, for example:
sizeof: INTEGER is
-- Size to allocate (in bytes)
external
"C inline use <windows.h>"
alias
"sizeof (struct _COMMTIMEOUTS)"
end
becomes
/* COM_TIMEOUTS.sizeof */
T4 T78f6(T0* C)
{
T4 R = 0;
sizeof (struct _COMMTIMEOUTS)
return R;
}
for GEC. While SE generates the following code:
/*COM_TIMEOUTS*/
T2 r232sizeof(se_dump_stack*caller){
T2 R=0;
...
R=(sizeof (struct _COMMTIMEOUTS));
...
return R;
}
and ISE generates the following code:
EIF_INTEGER_32 Fa9f3k0 (EIF_REFERENCE Current)
{
...
EIF_INTEGER_32 Result = (EIF_INTEGER_32) 0;
...
Result = (EIF_INTEGER_32)(sizeof (struct _COMMTIMEOUTS));
...
return Result;
}
Eric, you mentioned implementing externals according to the ECMA
specification. I agree that you have done that, but I don't think the
inline mechanism is not specified well (from ECMA-367):
8.31.14 Semantics: C Inline semantics
In an external routine er of the inline form, an External_name of the
form alias C_text denotes the algorithm defined, according to the
semantics of the C language, by a C function that has:
As its signature, the signature specified by er.
As its body, C_text after replacement of every occurrence of $a,
where the lower name of a is the lower name of one of the formal
arguments of er, by a.
When implementing a function, simply replacing C_text will not do. A
return statement is necessary. In addition, consider the following
example from ETL3 (http://se.inf.ethz.ch/~meyer/ongoing/etl/others.pdf
para 31.11):
an_inline_function (x,y: INTEGER): INTEGER
external "[
C
inline
use <stdio.h>
]"
alias "[
if ($x > 5) {
some_c_function ($y, cvar++);
}
]"
end
This can't work because C_text does not return a value as the
signature of `an_inline_function' suggests it should.
Brian
------------------------ Yahoo! Groups Sponsor --------------------~-->
Protect your PC from spy ware with award winning anti spy technology. It's free.
http://us.click.yahoo.com/97bhrC/LGxNAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~->
To Post a message, send it to: [email protected]
To Unsubscribe, send a blank message to: gobo-eiffel-unsubscribe-B11MqFFcr06IwRZHo2/[email protected]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/gobo-eiffel/
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/