[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Modifiers (revisited)
> Date: Mon, 13 May 96 14:07:52 EDT
> From: Mike Griebling <grieblm@trt.allied.com>
>
>
> Given the definitions in this file would it be possible to declare a
> module as being a C interface module AND then override the C interface
> to declare a procedure inside this module as being an ordinary Oberon-2
> procedure?
>
> For example, I would want something like:
>
> MODULE Files0 [FOREIGN "C"; LINK OBJ "Files.o" END];
>
> [bunch of C interfaces]
>
> PROCEDURE Ob2Proc [NATIVE] (VAR arg: INTEGER);
> BEGIN
> [some Oberon-2 code]
> END Ob2Proc;
>
> END Files0.
>
> In the above, every procedure is contained in File.o except the Ob2Proc
> which is an Oberon-2 procedure. Is the above possible? Or would it be
> better to declare a standard Oberon-2 module and then declare all the
> C procedures explicitly as being external?
This is possible (except that I dubbed the flag HAS_BODY instead of
NATIVE).
There are some drawbacks, though. The word FOREIGN signals that the
following declarations have standard Oberon-2 semantics. This means
that you have to add some flags to the C interfaces, because they
don't comply to the Oberon rules. Otherwise: Yes, it should work.
Another possibility is to write an INTERFACE module for File.o and
import this into Files0.Mod. In this case Files0.Mod can be
implemented as a standard module.
What you can't do is to write a _standard_ module and add any system
flags to it (i.e. add any C interface declarations to it). Those
flags, and procedure declarations without bodies, are only available
in modules that have "[ FOREIGN|INTERFACE ... ]" in their heading.
>
> Michael G.
-- mva