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.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@17939 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Charles Day 2009-02-20 04:37:28 +00:00
parent 6d1e0b75e1
commit 0c09333ce8
2 changed files with 15 additions and 7 deletions

View File

@ -30,7 +30,7 @@ typedef char gchar;
%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);"

View File

@ -125,7 +125,7 @@ gnc_guid2scm(GUID guid)
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 @@ gnc_scm2guid_glist (SCM guids_scm)
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 @@ gnc_scm2KvpValue (SCM value_scm)
}
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;
}