g-wrap-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mapping one Scheme argument to two C arguments


From: Ludovic Courtès
Subject: Re: Mapping one Scheme argument to two C arguments
Date: Tue, 29 Mar 2005 14:51:29 +0200
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.3 (gnu/linux)

Hi Andy,

Andy Wingo <address@hidden> writes:

> Sneaky ;) I think there's probably a cleaner way to do this, but this
> method is convenient.

I wish there was.  :-)

Actually, I find the use of G-Wrap somewhat problematic whenever a C
argument doesn't necessarily map to a Scheme argument.  In some cases,
when you have a C function that "eats" a C argument a modify it, you'd
prefer its Scheme binding to return a brand new object:

  /* Fill in (and grow) BUF with new stuff.  */
  void produce_stuff (buffer_t buf);

  -> (produce-stuff)

     |= #u8(1 2 3)

In this example, from the C viewpoint, BUF is an input argument [*].
However, on the Scheme side, we don't want it to be considered as an
argument (neither input nor output) but rather as a return value.  So
there should be a way to tell G-Wrap that (i) this argument exists in C
but must not show up in Scheme, (ii) some initialization stuff must be
done with this "automatic argument" before calling the underlying C
function, (iii) this thing must finally be wrapped it with a relevant
Scheme type and maybe destroyed.

This all seems pretty hard to do since neither `in', nor `out', nor
`inout' seem to fit well this usage pattern -- and using it would be
pretty sneaky anyway.  ;-)  Ideally, one would like to write custom
`function-wrapper-cg' and `call-cg' methods for this type of function.
Unfortunately, `function-wrapper-cg' isn't part of the actual framework
(it's only in `(g-wrap guile)').

Any suggestion?

Thanks,
Ludovic.

[*] One can think of this as a `GString' object,
    http://developer.gnome.org/doc/API/2.0/glib/glib-Strings.html .




reply via email to

[Prev in Thread] Current Thread [Next in Thread]