Swig type mapping for GUID's

Charles Day cedayiv at gmail.com
Wed Feb 18 10:42:21 EST 2009


On Wed, Feb 18, 2009 at 7:03 AM, Derek Atkins <warlord at mit.edu> wrote:

> Charles Day <cedayiv at gmail.com> writes:
>
> > I have a question about the current type mapping that swig does for GUID
> > pointers. Currently, if a C function returns a GUID* that is a null
> pointer
> > (== NULL), swig converts it to SCM_UNDEFINED and hands that to guile.
> From
> > src/base-typemaps.i:
> > %typemap(out) GUID * " $result = ($1) ? gnc_guid2scm(*($1)):
> SCM_UNDEFINED;
> > "
> >
> > Unfortunately, returning SCM_UNDEFINED to guile causes the variable on
> the
> > guile side to become unbound, leading to crashes (bug #530819, for
> example).
> > There is apparently no way to test for this condition from guile, so it
> > seems to me that swig should never return SCM_UNDEFINED to guile.
> >
> > Does anyone know why the type mapping has been defined this way?
> Shouldn't
> > it be redefined to return SCM_BOOL_F instead?
>
> Either that or gnc_guid2scm(guidnull()) ??
> I'm not sure why it is the way it is, nor am I sure what it SHOULD be.
> SCM_BOOL_F probably is correct.
>

qof_instance_get_guid() can return a normal GUID, guid_null(), or NULL (upon
failure). So it seems there ought to be a way for the caller (Scheme) to
distinguish between the last two. Having #f returned to Scheme seems like a
natural fit, as #f is returned by many Scheme procedures to indicate a bad
result.

A second issue is how GUID's are currently handled within Scheme. To
represent, say, a C split in Scheme, a record is filled out with the values
of each field (e.g. date, amount, account). The "account" is stored in
Scheme by use of its GUID, which may not exist if the split has not yet been
assigned to an account. How do we intend to represent this situation in
Scheme? I don't see any code that handles this, and #f would seem to be
appropriate.


> > Cheers,
> > Charles
>
> -derek
>
> --
>       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
>       Member, MIT Student Information Processing Board  (SIPB)
>       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
>       warlord at MIT.EDU                        PGP key available
>


More information about the gnucash-devel mailing list