r17939 - gnucash/trunk/src - Bug #570887: Change the swig type mapping for GUID* so that Scheme can tell the difference between a GUID* that is NULL, and a GUID* pointing to storage containing the "null" GUID. Previously the former case returned SCM_UNDEFINED to Scheme, which would unbind Scheme variables and make crashes. Now SCM_BOOL_F is used instead, and Scheme code can check for a NULL by comparing to #f.
Charles Day
cedayiv at cvs.gnucash.org
Thu Feb 19 23:37:28 EST 2009
Author: cedayiv
Date: 2009-02-19 23:37:28 -0500 (Thu, 19 Feb 2009)
New Revision: 17939
Trac: http://svn.gnucash.org/trac/changeset/17939
Modified:
gnucash/trunk/src/base-typemaps.i
gnucash/trunk/src/engine/engine-helpers.c
Log:
Bug #570887: Change the swig type mapping for GUID* so that Scheme can tell the difference between a GUID* that is NULL, and a GUID* pointing to storage containing the "null" GUID. Previously the former case returned SCM_UNDEFINED to Scheme, which would unbind Scheme variables and make crashes. Now SCM_BOOL_F is used instead, and Scheme code can check for a NULL by comparing to #f.
Modified: gnucash/trunk/src/base-typemaps.i
===================================================================
--- gnucash/trunk/src/base-typemaps.i 2009-02-20 03:03:05 UTC (rev 17938)
+++ gnucash/trunk/src/base-typemaps.i 2009-02-20 04:37:28 UTC (rev 17939)
@@ -30,7 +30,7 @@
%typemap(in) GUID "$1 = gnc_scm2guid($input);"
%typemap(out) GUID "$result = gnc_guid2scm($1);"
%typemap(in) GUID * (GUID g) " g = gnc_scm2guid($input); $1 = &g; "
-%typemap(out) GUID * " $result = ($1) ? gnc_guid2scm(*($1)): SCM_UNDEFINED; "
+%typemap(out) GUID * " $result = ($1) ? gnc_guid2scm(*($1)): SCM_BOOL_F; "
%typemap(in) gnc_numeric "$1 = gnc_scm_to_numeric($input);"
%typemap(out) gnc_numeric "$result = gnc_numeric_to_scm($1);"
Modified: gnucash/trunk/src/engine/engine-helpers.c
===================================================================
--- gnucash/trunk/src/engine/engine-helpers.c 2009-02-20 03:03:05 UTC (rev 17938)
+++ gnucash/trunk/src/engine/engine-helpers.c 2009-02-20 04:37:28 UTC (rev 17939)
@@ -125,7 +125,7 @@
char string[GUID_ENCODING_LENGTH + 1];
if (!guid_to_string_buff(&guid, string))
- return SCM_UNDEFINED;
+ return SCM_BOOL_F;
return scm_makfrom0str(string);
}
@@ -409,10 +409,13 @@
while (!SCM_NULLP (guids_scm))
{
SCM guid_scm = SCM_CAR (guids_scm);
- GUID *guid;
+ GUID *guid = NULL;
- guid = guid_malloc ();
- *guid = gnc_scm2guid (guid_scm);
+ if (guids_scm != SCM_BOOL_F)
+ {
+ guid = guid_malloc ();
+ *guid = gnc_scm2guid (guid_scm);
+ }
guids = g_list_prepend (guids, guid);
@@ -663,8 +666,13 @@
}
case KVP_TYPE_GUID: {
- GUID guid = gnc_scm2guid (val_scm);
- value = kvp_value_new_guid (&guid);
+ if (val_scm != SCM_BOOL_F)
+ {
+ GUID guid = gnc_scm2guid (val_scm);
+ value = kvp_value_new_guid (&guid);
+ }
+ else
+ value = NULL;
break;
}
More information about the gnucash-changes
mailing list