Add scheme wrapper for SX cashflow calculation, including a typemap for the resulting GHashTable.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19531 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Christian Stimming 2010-09-01 16:23:50 +00:00
parent 4b3ef0786d
commit 4e7014e48a
3 changed files with 41 additions and 0 deletions

View File

@ -13,6 +13,7 @@
#include <gnc-session.h>
#include <gnc-component-manager.h>
#include <guile-util.h>
#include <app-utils/gnc-sx-instance-model.h>
#include "engine-helpers.h"
@ -111,3 +112,23 @@ gint gnc_process_get_fd(const Process *proc, const guint std_fd);
void gnc_detach_process(Process *proc, const gboolean kill_it);
time_t gnc_parse_time_to_timet(const gchar *s, const gchar *format);
%typemap(out) GHashTable * {
SCM table = scm_c_make_hash_table (g_hash_table_size($1) + 17);
GHashTableIter iter;
gpointer key, value;
g_hash_table_iter_init (&iter, $1);
while (g_hash_table_iter_next (&iter, &key, &value)) {
const GncGUID* c_guid = (const GncGUID*) key;
const gnc_numeric* c_numeric = (const gnc_numeric*) value;
SCM scm_guid = gnc_guid2scm(*c_guid);
SCM scm_numeric = gnc_numeric_to_scm(*c_numeric);
scm_hash_set_x(table, scm_guid, scm_numeric);
}
g_hash_table_destroy($1);
$result = table;
}
GHashTable* gnc_sx_all_instantiate_cashflow_all(GDate range_start, GDate range_end);
%clear GHashTable *;

View File

@ -1673,6 +1673,17 @@ void gnc_sx_all_instantiate_cashflow(GList *all_sxes,
g_list_foreach(all_sxes, instantiate_cashflow_cb, &userdata);
}
GHashTable* gnc_sx_all_instantiate_cashflow_all(GDate range_start, GDate range_end)
{
GHashTable *result_map = gnc_g_hash_new_guid_numeric();
GList *all_sxes = gnc_book_get_schedxactions(gnc_get_current_book())->sx_list;
gnc_sx_all_instantiate_cashflow(all_sxes,
&range_start, &range_end,
result_map, NULL);
return result_map;
}
// Local Variables:
// mode: c
// indent-tabs-mode: nil

View File

@ -254,6 +254,15 @@ void gnc_sx_all_instantiate_cashflow(GList *all_sxes,
const GDate *range_start, const GDate *range_end,
GHashTable* map, GList **creation_errors);
/** Simplified wrapper around gnc_sx_all_instantiate_cashflow(): Run
* that function on all SX of the current book for the given date
* range. Ignore any potential error messages. Returns a newly
* allocated GHashTable with the result, which is a GHashTable<GUID*,
* gnc_numeric*>, identical to what gnc_g_hash_new_guid_numeric()
* would return. The returned value must be free'd with
* g_hash_table_destroy. */
GHashTable* gnc_sx_all_instantiate_cashflow_all(GDate range_start, GDate range_end);
G_END_DECLS
#endif // _GNC_SX_INSTANCE_MODEL_H