32 #define _GL_UNISTD_H //Deflect poisonous define of close in Guile's GnuLib 46 #include "swig-runtime.h" 47 #include "guile-mappings.h" 49 #include "gnc-guile-utils.h" 50 #include "glib-guile.h" 59 #include "gnc-engine-guile.h" 62 #define UNUSED_VAR __attribute__ ((unused)) 65 static QofLogModule UNUSED_VAR log_module = GNC_MOD_GUILE;
68 glist_to_scm_list_helper(GList *glist, swig_type_info *wct)
73 for (node = glist; node; node = node->next)
74 list = scm_cons(SWIG_NewPointerObj(node->data, wct, 0), list);
76 return scm_reverse (list);
80 gnc_glist_to_scm_list(GList *glist,
const gchar *wct)
82 swig_type_info *stype = SWIG_TypeQuery(wct);
83 g_return_val_if_fail(stype, SCM_UNDEFINED);
84 return glist_to_scm_list_helper(glist, stype);
88 gnc_scm_list_to_glist(SCM rest)
94 SCM_ASSERT(scm_is_list(rest), rest, SCM_ARG1,
"gnc_scm_list_to_glist");
96 while (!scm_is_null(rest))
100 scm_item = SCM_CAR(rest);
101 rest = SCM_CDR(rest);
103 if (scm_item == SCM_BOOL_F)
105 result = g_list_prepend(result, NULL);
109 if (!SWIG_IsPointer(scm_item))
110 scm_misc_error(
"gnc_scm_list_to_glist",
111 "Item in list not a wcp.", scm_item);
113 item = (
void *)SWIG_PointerAddress(scm_item);
114 result = g_list_prepend(result, item);
118 return g_list_reverse(result);
128 gnc_glist_string_to_scm(GList *glist)
133 for (node = glist; node; node = node->next)
136 list = scm_cons (scm_from_utf8_string(node->data), list);
138 list = scm_cons (SCM_BOOL_F, list);
141 return scm_reverse (list);
155 gnc_scm_to_glist_string(SCM list)
159 while (!scm_is_null (list))
161 if (scm_is_string(SCM_CAR(list)))
165 str = gnc_scm_to_utf8_string (SCM_CAR(list));
167 glist = g_list_prepend (glist, str);
169 list = SCM_CDR (list);
172 return g_list_reverse (glist);
176 gnc_scm_to_gslist_string(SCM list)
178 GSList *gslist = NULL;
180 while (!scm_is_null (list))
182 if (scm_is_string(SCM_CAR(list)))
186 str = gnc_scm_to_utf8_string (SCM_CAR(list));
188 gslist = g_slist_prepend (gslist, str);
190 list = SCM_CDR (list);
193 return g_slist_reverse (gslist);
201 gnc_glist_string_p(SCM list)
203 return scm_is_list(list);