Re: [ooc-compiler] Handling C "in" parameters
Brought to you by:
mva
|
From: Stewart G. <sgr...@ii...> - 2005-02-18 09:02:31
|
Hi August, >> I suggest that you do something like this: >> >> PROCEDURE ["SDL_PollEvent"] PollEvent*(VAR event: Event): C.int; > > Yes, this is the ideal solution. I didn't know that VAR parameters and > pointers were compatible in this case. In this context, a VAR parameter is a kind of "enhanced" pointer since it can point to an object on the stack or the heap. For Oberon-2 RECORDS, the compiler passes the pointer and an additional hidden argument which is its type descriptor. For heap-based records, it uses the type descriptor from the heap object. For stack-based records it uses the descriptor for the (static) type of the record. For foreign "C" records, there is of course no type information. You can declare "VAR event [NIL_COMPAT]" which allows you to pass NIL as the reference for a VAR parameter. > By the way, I have heard of a C header to Oberon-2 conversion tool > called H2O. Do you know where I can get it? Its in the CVS repository. Check this message for some details: http://sourceforge.net/mailarchive/message.php?msg_id=10766629 Since I'm also interested, I tried compiling the libsdl headers. The current CVS version of H2O handles version 1.2.7 of libsdl. By that, I mean that it compiles the "C" code, and produces compilable Oberon-2 modules (with a couple of small manual changes). If you like, I can e-mail you the generated files. It needs a little work to be properly usable, but may save you some time over doing manual translation. Cheers, Stewart |