g-wrap and glib container types...

Robert Graham Merkel rgmerk@mira.net
Tue, 7 Nov 2000 10:24:50 +1100

Rob Browning writes:
 > Robert and I have been trying to figure out how to handle glib
 > container types (like GList, GSList, GArray, GHashTable, etc.) cleanly
 > from g-wrap.  Last time I thought hard about this, I thought I wanted
 > to teach g-wrap how to handle these things directly, but I've since
 > changed my opinion to be closer to what (I think) Robert was
 > suggesting.
 > Consider the function
 >   GArray* frob_accounts(GList *accounts);
 > Conceivably you might want to be able to call this from the scheme side
 > by passing it a GList* pointer-token, or a regular scheme list of
 > Account* pointer-tokens.  Likewise, sometimes you might just want it
 > to return a GArray* pointer-token, and sometimes you might want a
 > scheme array.
 > Because of the variety of possible desires, and because we don't want
 > to have to have a bunch of different functions on the scheme side call
 > the same C side function but with different parameter/return value
 > semantics, I now agree with Robert (presuming that I'm recalling his
 > argument correctly) that we should just go the "helper conversion
 > function" route.

Yep, that makes sense.

However, one minor concern, particularly if you want to wrap parts of 
glib itself.  A lot of those functions are access functions that take
a pointer to a glib container and return a void * (a gpointer,
actually) that is a pointer to an entry in the container.

Can we pass the returned gpointer to functions that take, say, 
Account *?

Robert Merkel	                           rgmerk@mira.net