30 #include "guile-mappings.h"
31 #include "gnc-guile-utils.h"
32 #include "swig-runtime.h"
33 #include "glib-helpers.h"
37 glist_to_scm_list_helper(GList *glist, swig_type_info *wct)
42 for (node = glist; node; node = node->next)
43 list = scm_cons(SWIG_NewPointerObj(node->data, wct, 0), list);
45 return scm_reverse (list);
49 gnc_glist_to_scm_list(GList *glist, gchar *wct)
51 swig_type_info *stype = SWIG_TypeQuery(wct);
52 g_return_val_if_fail(stype, SCM_UNDEFINED);
53 return glist_to_scm_list_helper(glist, stype);
57 gnc_scm_list_to_glist(SCM rest)
63 SCM_ASSERT(scm_is_list(rest), rest, SCM_ARG1,
"gnc_scm_list_to_glist");
65 while (!scm_is_null(rest))
69 scm_item = SCM_CAR(rest);
72 if (scm_item == SCM_BOOL_F)
74 result = g_list_prepend(result, NULL);
78 if (!SWIG_IsPointer(scm_item))
79 scm_misc_error(
"gnc_scm_list_to_glist",
80 "Item in list not a wcp.", scm_item);
82 item = (
void *)SWIG_PointerAddress(scm_item);
83 result = g_list_prepend(result, item);
87 return g_list_reverse(result);
97 gnc_glist_string_to_scm(GList *glist)
102 for (node = glist; node; node = node->next)
105 list = scm_cons (scm_from_utf8_string(node->data), list);
107 list = scm_cons (SCM_BOOL_F, list);
110 return scm_reverse (list);
124 gnc_scm_to_glist_string(SCM list)
128 while (!scm_is_null (list))
130 if (scm_is_string(SCM_CAR(list)))
134 str = gnc_scm_to_utf8_string (SCM_CAR(list));
136 glist = g_list_prepend (glist, g_strdup (str));
139 list = SCM_CDR (list);
142 return g_list_reverse (glist);
146 gnc_scm_to_gslist_string(SCM list)
148 GSList *gslist = NULL;
150 while (!scm_is_null (list))
152 if (scm_is_string(SCM_CAR(list)))
156 str = gnc_scm_to_utf8_string (SCM_CAR(list));
158 gslist = g_slist_prepend (gslist, g_strdup (str));
161 list = SCM_CDR (list);
164 return g_slist_reverse (gslist);
172 gnc_glist_string_p(SCM list)
174 return scm_is_list(list);