Re: More C interfacing issues

2002-07-03 Thread Alastair Reid
> 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

RE: More C interfacing issues

2002-07-03 Thread Simon Marlow
> > 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

Re: More C interfacing issues

2002-07-03 Thread Alastair Reid
>> > 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 ()

Re: More C interfacing issues

2002-07-03 Thread Malcolm Wallace
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

RE: More C interfacing issues

2002-07-03 Thread Simon Marlow
> -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

Re: More C interfacing issues

2002-07-02 Thread Alastair Reid
> 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

Re: More C interfacing issues

2002-07-02 Thread Ian Lynagh
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

Re: More C interfacing issues

2002-07-02 Thread Sven Panne
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

Re: More C interfacing issues

2002-07-02 Thread Alastair Reid
> 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