From 5e325fa41de86607bca14eb262ee72eed3ebb56d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=C3=B6hler?= Date: Sat, 6 Oct 2007 23:05:16 +0000 Subject: [PATCH] #483796, Fancy Invoice: Convert the elements of an AccountValueList when wrapping. GLIST_HELPER_INOUT does not touch the single elements and GncAccountValue typemaps do not work here. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16554 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/base-typemaps.i | 2 +- src/business/business-core/business-core.i | 30 +++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/base-typemaps.i b/src/base-typemaps.i index d33a1d61b4..9b17c91a06 100644 --- a/src/base-typemaps.i +++ b/src/base-typemaps.i @@ -41,7 +41,7 @@ typedef char gchar; GList *c_list = NULL; while (!SCM_NULLP(list)) { - Account *p; + void *p; SCM p_scm = SCM_CAR(list); if (SCM_FALSEP(p_scm) || SCM_NULLP(p_scm)) diff --git a/src/business/business-core/business-core.i b/src/business/business-core/business-core.i index 25ae7f589a..12b8d32cf9 100644 --- a/src/business/business-core/business-core.i +++ b/src/business/business-core/business-core.i @@ -64,10 +64,38 @@ static GncEmployee * gncEmployeeLookupFlip(GUID g, QofBook *b) %} GLIST_HELPER_INOUT(EntryList, SWIGTYPE_p__gncEntry); -GLIST_HELPER_INOUT(AccountValueList, SWIGTYPE_p__gncAccountValue); %typemap(in) GncAccountValue * "$1 = gnc_scm_to_account_value_ptr($input);" %typemap(out) GncAccountValue * "$result = gnc_account_value_ptr_to_scm($1);" +%typemap(in) AccountValueList * { + SCM list = $input; + GList *c_list = NULL; + + while (!SCM_NULLP(list)) { + GncAccountValue *p; + + SCM p_scm = SCM_CAR(list); + if (SCM_FALSEP(p_scm) || SCM_NULLP(p_scm)) + p = NULL; + else + p = gnc_scm_to_account_value_ptr(p_scm); + + c_list = g_list_prepend(c_list, p); + list = SCM_CDR(list); + } + + $1 = g_list_reverse(c_list); +} +%typemap(out) AccountValueList * { + SCM list = SCM_EOL; + GList *node; + + for (node = $1; node; node = node->next) + list = scm_cons(gnc_account_value_ptr_to_scm(node->data), list); + + $result = scm_reverse(list); +} + /* Parse the header files to generate wrappers */