KvpValue * gnc_scm_to_kvp_value_ptr(SCM val) { if (scm_is_rational(val)) { if (scm_is_exact(val) && (scm_is_signed_integer(val, INT64_MIN, INT64_MAX) || scm_is_unsigned_integer(val, INT64_MIN, INT64_MAX))) { return new KvpValue{scm_to_int64(val)}; } else if (scm_is_exact(val) && (scm_is_signed_integer(scm_numerator(val), INT64_MIN, INT64_MAX) || scm_is_unsigned_integer(scm_numerator(val), INT64_MIN, INT64_MAX)) && (scm_is_signed_integer(scm_denominator(val), INT64_MIN, INT64_MAX) || (scm_is_unsigned_integer(scm_denominator(val), INT64_MIN, INT64_MAX)))) { return new KvpValue{gnc_scm_to_numeric(val)}; } else { return new KvpValue{scm_to_double(val)}; } } else if (gnc_guid_p(val)) { auto guid = gnc_scm2guid(val); auto tmpguid = guid_copy(&guid); return new KvpValue{tmpguid}; } else if (gnc_timepair_p(val)) { Timespec ts = gnc_timepair2timespec(val); return new KvpValue{ts}; } else if (scm_is_string(val)) { return new KvpValue{gnc_scm_to_utf8_string(val)}; } else if (SWIG_IsPointerOfType(val, SWIG_TypeQuery("_p_KvpFrame"))) { #define FUNC_NAME G_STRFUNC auto vp_frame = SWIG_MustGetPtr(val, SWIG_TypeQuery("_p_KvpFrame"), 1, 0); KvpFrame *frame = static_cast<KvpFrame*>(vp_frame); #undef FUNC_NAME return new KvpValue{frame}; } /* FIXME: add list handler here */ return NULL; }
KvpValue * gnc_scm_to_kvp_value_ptr(SCM val) { if (scm_is_number(val)) { /* in guile 1.8 (exact? ) only works on numbers */ if (scm_is_exact (val) && gnc_gh_gint64_p(val)) { return new KvpValue{scm_to_int64(val)}; } else { return new KvpValue{scm_to_double(val)}; } } else if (gnc_numeric_p(val)) { return new KvpValue{gnc_scm_to_numeric(val)}; } else if (gnc_guid_p(val)) { auto guid = gnc_scm2guid(val); auto tmpguid = guid_copy(&guid); return new KvpValue{tmpguid}; } else if (gnc_timepair_p(val)) { Timespec ts = gnc_timepair2timespec(val); return new KvpValue{ts}; } else if (scm_is_string(val)) { return new KvpValue{gnc_scm_to_utf8_string(val)}; } else if (SWIG_IsPointerOfType(val, SWIG_TypeQuery("_p_KvpFrame"))) { #define FUNC_NAME G_STRFUNC auto vp_frame = SWIG_MustGetPtr(val, SWIG_TypeQuery("_p_KvpFrame"), 1, 0); KvpFrame *frame = static_cast<KvpFrame*>(vp_frame); #undef FUNC_NAME return new KvpValue{frame}; } /* FIXME: add list handler here */ return NULL; }
static int build_owner_report (GncOwner *owner, Account *acc) { SCM args; SCM func; SCM arg; g_return_val_if_fail (owner, -1); args = SCM_EOL; func = scm_c_eval_string ("gnc:owner-report-create"); g_return_val_if_fail (scm_is_procedure (func), -1); if (acc) { swig_type_info * qtype = SWIG_TypeQuery("_p_Account"); g_return_val_if_fail (qtype, -1); arg = SWIG_NewPointerObj(acc, qtype, 0); g_return_val_if_fail (arg != SCM_UNDEFINED, -1); args = scm_cons (arg, args); } else { args = scm_cons (SCM_BOOL_F, args); } arg = SWIG_NewPointerObj(owner, SWIG_TypeQuery("_p__gncOwner"), 0); g_return_val_if_fail (arg != SCM_UNDEFINED, -1); args = scm_cons (arg, args); /* Apply the function to the args */ arg = scm_apply (func, args, SCM_EOL); g_return_val_if_fail (scm_is_exact (arg), -1); return scm_to_int (arg); }
static int build_aging_report (GncOwnerType owner_type) { gchar *report_name = NULL; gchar *report_title = NULL; SCM args; SCM func; SCM arg; args = SCM_EOL; switch (owner_type) { case GNC_OWNER_NONE : case GNC_OWNER_UNDEFINED : case GNC_OWNER_EMPLOYEE : case GNC_OWNER_JOB : { return -1; } case GNC_OWNER_VENDOR : { report_name = "gnc:payables-report-create"; report_title = _("Vendor Listing"); break; } case GNC_OWNER_CUSTOMER : { report_name = "gnc:receivables-report-create"; report_title = _("Customer Listing"); break; } } /* Find report generator function in guile */ func = scm_c_eval_string (report_name); g_return_val_if_fail (scm_is_procedure (func), -1); /* Option Show zero's ? - Yes for the listing report */ arg = SCM_BOOL_T; args = scm_cons (arg, args); g_return_val_if_fail (arg != SCM_UNDEFINED, -1); /* Option Report title */ arg = scm_from_locale_string (report_title); args = scm_cons (arg, args); /* Option Account - Using False to select default account * * XXX I'm not sure if it would make sense to use another * account than default */ arg = SCM_BOOL_F; args = scm_cons (arg, args); g_return_val_if_fail (arg != SCM_UNDEFINED, -1); /* Apply the function to the args */ arg = scm_apply (func, args, SCM_EOL); g_return_val_if_fail (scm_is_exact (arg), -1); return scm_to_int (arg); }