[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C error-returning functions and Guile exceptions
From: |
Andreas Rottmann |
Subject: |
Re: C error-returning functions and Guile exceptions |
Date: |
Fri, 11 Mar 2005 18:03:27 +0100 |
User-agent: |
Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux) |
Greg Troxel <address@hidden> writes:
> 1. Write a C function that wraps `read_stuff ()', checks the
> error code returned and calls `scm_throw ()' if necessary;
>
> It would be cool to extend g-wrap to be able to do this automatically.
>
Indeed.
> There is already support (I think) for multiple return values,
>
Yes.
> so one would need to add a return type 'errno' that is ignored if 0,
> and causes a throw if not.
>
Well, there is even something quite similiar to what Ludovic wants in
guile-gnome; GLib functions can have a GError** as last argument, and
should that get set, the wrapper raises an exception. However, I still
have to think about how that can be translated for the return value
(which is treated somewhat special).
> 2. Find a way to make the BUFFER/READ pair translate into a return
> value of the Scheme function.
>
This touches an area of G-Wrap that is not yet implemented: mapping
multiple arguments on the C side to a single Scheme object. I did not
yet have a real incentive to implement that, but since now there is a
real-world case where this is *really* needed (there are also
functions like that in GTK+ - up to now they have custom wrappers or
are ignored), I might give implementing it a go. So, in the G-Wrap
TODO, I've noted "multiple argument mapping" as a release goal for the
next release. Don't hold your breath, though; this feature needs some
thinking and design. I'll come up with an API proposal here soonish.
>
> One could have vector objects, but recvfrom! already has similar
> behavior, so I'd be tempted to act like that. Strings are really
> arrays, since they have lengths and aren't NULL terminated.
>
IMO, the best match for an "octet buffer" would be an srfi-4
u8vector.
Regards, Rotty
--
Andreas Rottmann | address@hidden | address@hidden | address@hidden
http://yi.org/rotty | GnuPG Key: http://yi.org/rotty/gpg.asc
Fingerprint | DFB4 4EB4 78A4 5EEE 6219 F228 F92F CFC5 01FD 5B62
Any technology not indistinguishable from magic is insufficiently advanced.
-- Terry Pratchett