> Curious: how does green card know that getxy is a macro and that x
> and y are out parameters... do you have to tell it?
More or less. GreenCard definitions are of the form of the form:
%fun foo ::
...
%call
...
GreenCard fills in the obvious code (i.e., result = foo(args)) if y
> > What's wrong with just doing this in the plain FFI?
>
> > foreign import ccall "getyx" getyx
> > :: Ptr Window -> Ptr CInt -> Ptr CInt -> IO ()
>
> > Have I missed something?
>
> You need at least one wrapper because getyx is a macro. Note that the
> arguments are ints _not_ in
>> > Secondly, does anyone have any suggestions on how to provide an
>> > interface to this?
>>
>> > void getyx(WINDOW *win, int y, int x);
> What's wrong with just doing this in the plain FFI?
> foreign import ccall "getyx" getyx
> :: Ptr Window -> Ptr CInt -> Ptr CInt -> IO ()
Alastair Reid <[EMAIL PROTECTED]> writes:
> Hugs supports:
>
> data Window
>
> and I believe GHC and NHC do too. (Malcolm, SimonM: please shout if I
> overstate.)
nhc98 does not support blank data declarations.
Regards,
Malcolm
___
FFI maili
> -Original Message-
> From: Alastair Reid [mailto:[EMAIL PROTECTED]]
> Sent: 02 July 2002 18:34
> To: Ian Lynagh
> Cc: [EMAIL PROTECTED]
> Subject: Re: More C interfacing issues
>
>
>
> > Firstly, some ncurses calls return a *WINDOW and others ta
> Uh, oh! Don't even try this if you ever want to be thread-safe! :-}
Yeah, I know.
For what it's worth, it's not what GreenCard does with the native Hugs
backend (at least, it wasn't last time I looked). Hugs primitives are
allowed to return tuples of values so they do. It's a shame C doe
On Tue, Jul 02, 2002 at 06:34:02PM +0100, Alastair Reid wrote:
>
> > Firstly, some ncurses calls return a *WINDOW and others take one as
> > an argument but you never actually look at the contents of one
> > yourself. I have defined "data Window = Window" and am using Ptr
> > Window for the types
Alastair Reid wrote:
> [...] 3 wrapper functions more or less like this:
>
> static int x;
> static int y;
> void wrap_getyx(WINDOW *win) { getyx(win,x,y); }
> int getx(void) { return x; }
> int gety(void) { return y; }
> [...]
Uh, oh! Don't even try this if you ever want to be
> Firstly, some ncurses calls return a *WINDOW and others take one as
> an argument but you never actually look at the contents of one
> yourself. I have defined "data Window = Window" and am using Ptr
> Window for the types of these. However, this means I get a warning
> about an unused construc