[options] Move options from app-utils to engine.

Options is required for book options that are stored as part of the data
 file and so belongs in engine.
This commit is contained in:
John Ralls 2022-08-23 09:22:56 -07:00
parent f24f29830b
commit 4ae17d12c7
53 changed files with 1742 additions and 1709 deletions

View File

@ -52,7 +52,6 @@ SCM scm_init_sw_app_utils_module (void);
}
%}
%include "gnc-optiondb.i"
#endif
#if defined(SWIGPYTHON)

View File

@ -82,8 +82,8 @@ GLIST_HELPER_INOUT(GncTaxTableEntryList, SWIGTYPE_p__gncTaxTableEntry);
GLIST_HELPER_INOUT(OwnerList, SWIGTYPE_p__gncOwner);
#if defined(SWIGGUILE)
%typemap(in) GncAccountValue * "$1 = gnc_scm_to_account_value_ptr($input);"
%typemap(out) GncAccountValue * "$result = gnc_account_value_ptr_to_scm($1);"
%typemap(in) GncAccountValue * "$1 = gnc_scm_to_account_value_ptr((GncAccountValue*)$input);"
%typemap(out) GncAccountValue * "$result = gnc_account_value_ptr_to_scm((GncAccountValue*)$1);"
%typemap(in) AccountValueList * {
SCM list = $input;
GList *c_list = NULL;
@ -95,7 +95,7 @@ GLIST_HELPER_INOUT(OwnerList, SWIGTYPE_p__gncOwner);
if (scm_is_false(p_scm) || scm_is_null(p_scm))
p = NULL;
else
p = gnc_scm_to_account_value_ptr(p_scm);
p = gnc_scm_to_account_value_ptr((GncAccountValue*)p_scm);
c_list = g_list_prepend(c_list, p);
list = SCM_CDR(list);
@ -108,7 +108,7 @@ GLIST_HELPER_INOUT(OwnerList, SWIGTYPE_p__gncOwner);
GList *node;
for (node = $1; node; node = node->next)
list = scm_cons(gnc_account_value_ptr_to_scm(node->data), list);
list = scm_cons(gnc_account_value_ptr_to_scm((GncAccountValue*)(node->data)), list);
$result = scm_reverse(list);
}

View File

@ -21,8 +21,14 @@
%module sw_engine
%{
/* Includes the header in the wrapper code */
#include <config.h>
#include <glib.h>
#ifdef __cplusplus
extern "C"
{
#endif
#include <config.h>
#include "qof.h"
#include "qoflog.h"
#include "Query.h"
@ -51,17 +57,25 @@
#include "gncOwner.h"
#include "gncTaxTable.h"
#include "gncVendor.h"
#ifdef __cplusplus
}
#endif
%}
#if defined(SWIGGUILE)
#if defined(SWIGGUILE) //Always C++
%{
extern "C"
{
#include "guile-mappings.h"
SCM scm_init_sw_engine_module (void);
}
%}
%include "gnc-optiondb.i"
#endif
%import "base-typemaps.i"
%apply struct tm* { tm* };
GLIST_HELPER_INOUT(SplitList, SWIGTYPE_p_Split);
GLIST_HELPER_INOUT(TransList, SWIGTYPE_p_Transaction);
GLIST_HELPER_INOUT(LotList, SWIGTYPE_p_GNCLot);

View File

@ -9,24 +9,24 @@ gnc_add_swig_guile_command (swig-core-utils-guile-c
${CORE_UTILS_HEADERS}
)
# Generate the swig-engine.c wrapper file
set(SWIG_ARGS "-c++" "-procdoc" "sw-gnc-option-doc" "-procdocformat" "plain")
# Generate the swig-engine.cpp wrapper file
gnc_swig_extract_header_files (gnc-engine ENGINE_HEADERS)
gnc_add_swig_guile_command (swig-engine-c
SWIG_ENGINE_C swig-engine.c
gnc_add_swig_guile_command (swig-engine-cpp
SWIG_ENGINE_CPP swig-engine.cpp
${CMAKE_SOURCE_DIR}/bindings/engine.i
"${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_SOURCE_DIR}/libgnucash/engine"
${ENGINE_HEADERS}
${CMAKE_SOURCE_DIR}/bindings/business-core.i
${CMAKE_SOURCE_DIR}/bindings/engine-common.i
${CMAKE_CURRENT_SOURCE_DIR}/gnc-optiondb.i #additional dependencies
)
# Generate the swig-app-utils-guile.cpp wrapper file
set(SWIG_ARGS "-c++" "-procdoc" "sw-gnc-option-doc" "-procdocformat" "plain")
gnc_add_swig_guile_command (swig-apputils-guile-cpp #target
SWIG_APP_UTILS_GUILE_CPP swig-app-utils-guile.cpp #outvar, output
${CMAKE_CURRENT_SOURCE_DIR}/../app-utils.i #input
"${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_SOURCE_DIR}/libgnucash/app-utils" #includes
${CMAKE_CURRENT_SOURCE_DIR}/gnc-optiondb.i #additional dependencies
)
unset(SWIG_ARGS)
@ -46,7 +46,7 @@ set(guile_HEADERS
set(guile_SOURCES
glib-guile.c
gnc-engine-guile.c
gnc-engine-guile.cpp
gnc-guile-bindings.c
gnc-guile-utils.c
gnc-helpers.c
@ -56,7 +56,7 @@ add_library(gnucash-guile SHARED
${guile_SOURCES}
${guile_HEADERS}
${SWIG_CORE_UTILS_GUILE_C}
${SWIG_ENGINE_C}
${SWIG_ENGINE_CPP}
${SWIG_APP_UTILS_GUILE_CPP})
add_dependencies(gnucash-guile
@ -167,17 +167,19 @@ gnc_add_scheme_targets(scm-engine-2
OUTPUT_DIR gnucash
DEPENDS "scm-engine-1;${GUILE_DEPENDS}")
add_custom_target(scm-engine ALL DEPENDS scm-engine-2 scm-engine-1 scm-engine-0)
gnc_add_scheme_targets(scm-options
SOURCES options.scm
OUTPUT_DIR gnucash
DEPENDS "scm-engine-2;scm-core-utils;${GUILE_DEPENDS}")
add_custom_target(scm-engine ALL DEPENDS scm-options scm-engine-2 scm-engine-1 scm-engine-0)
set (app_utils_SCHEME_1
c-interface.scm
date-utilities.scm
)
set (app_utils_SCHEME_1a
options.scm
)
set (app_utils_SCHEME_2
app-utils.scm
)
@ -194,16 +196,10 @@ gnc_add_scheme_targets(scm-app-utils-1
DEPENDS "${GUILE_DEPENDS}"
MAKE_LINKS)
gnc_add_scheme_targets(scm-app-utils-1a
SOURCES "${app_utils_SCHEME_1a}"
OUTPUT_DIR "gnucash/app-utils"
DEPENDS "scm-app-utils-1"
MAKE_LINKS)
gnc_add_scheme_targets(scm-app-utils-2
SOURCES "${app_utils_SCHEME_2}"
OUTPUT_DIR "gnucash"
DEPENDS "scm-app-utils-1a"
DEPENDS "scm-app-utils-1"
MAKE_LINKS)
add_custom_target(scm-app-utils ALL DEPENDS scm-app-utils-2 scm-app-utils-1)
@ -235,7 +231,7 @@ set_local_dist(guile_DIST_local
${app_utils_SCHEME_2}
${app_utils_SCHEME_3}
${expressions_SCHEME}
expressions.i)
gnc-optiondb.i expressions.i)
set(guile_DIST ${guile_DIST_local} ${test_guile_DIST} PARENT_SCOPE)

View File

@ -28,7 +28,6 @@
(load-and-reexport (sw_app_utils)
(gnucash app-utils date-utilities)
(gnucash app-utils options)
(gnucash app-utils c-interface))
(re-export HOOK-SAVE-OPTIONS)

View File

@ -1,5 +1,5 @@
/********************************************************************\
* gnc-engine-guile.c -- engine helper functions for guile *
* gnc-engine-guile.cpp -- engine helper functions for guile *
* Copyright (C) 2000 Linas Vepstas <linas@linas.org> *
* Copyright (C) 2001 Linux Developers Group, Inc. *
* *
@ -26,8 +26,9 @@
#include "swig-runtime.h"
#include <libguile.h>
#include <string.h>
#include <cstring>
extern "C"
{
#include "Account.h"
#include "engine-helpers.h"
#include "gnc-engine-guile.h"
@ -39,7 +40,7 @@
#include "gnc-guile-utils.h"
#include <qof.h>
#include <qofbookslots.h>
}
#ifndef HAVE_STRPTIME
# include "strptime.h"
@ -150,42 +151,42 @@ typedef enum
static QofQueryCompare
gnc_query_scm2compare (SCM how_scm)
{
return scm_to_int(how_scm);
return static_cast<QofQueryCompare>(scm_to_int(how_scm));
}
/* QofStringMatch */
static QofStringMatch
gnc_query_scm2string (SCM how_scm)
{
return scm_to_int(how_scm);
return static_cast<QofStringMatch>(scm_to_int(how_scm));
}
/* QofDateMatch */
static QofDateMatch
gnc_query_scm2date (SCM how_scm)
{
return scm_to_int(how_scm);
return static_cast<QofDateMatch>(scm_to_int(how_scm));
}
/* QofNumericMatch */
static QofNumericMatch
gnc_query_scm2numericop (SCM how_scm)
{
return scm_to_int(how_scm);
return static_cast<QofNumericMatch>(scm_to_int(how_scm));
}
/* QofGuidMatch */
static QofGuidMatch
gnc_query_scm2guid (SCM how_scm)
{
return scm_to_int(how_scm);
return static_cast<QofGuidMatch>(scm_to_int(how_scm));
}
/* QofCharMatch */
static QofCharMatch
gnc_query_scm2char (SCM how_scm)
{
return scm_to_int(how_scm);
return static_cast<QofCharMatch>(scm_to_int(how_scm));
}
static QofGuidMatch
@ -258,7 +259,7 @@ gnc_scm2bitfield (SCM field_scm)
static cleared_match_t
gnc_scm2cleared_match_how (SCM how_scm)
{
return gnc_scm2bitfield (how_scm);
return static_cast<cleared_match_t>(gnc_scm2bitfield (how_scm));
}
static gboolean
@ -295,7 +296,7 @@ gnc_guid_glist2scm (const GList *account_guids)
for (node = account_guids; node; node = node->next)
{
GncGUID *guid = node->data;
auto guid = static_cast<GncGUID*>(node->data);
if (guid)
guids = scm_cons (gnc_guid2scm (*guid), guids);
@ -307,15 +308,15 @@ gnc_guid_glist2scm (const GList *account_guids)
static GList *
gnc_scm2guid_glist (SCM guids_scm)
{
GList *guids = NULL;
GList *guids = nullptr;
if (!scm_is_list (guids_scm))
return NULL;
return nullptr;
while (!scm_is_null (guids_scm))
{
SCM guid_scm = SCM_CAR (guids_scm);
GncGUID *guid = NULL;
GncGUID *guid = nullptr;
if (guid_scm != SCM_BOOL_F)
{
@ -371,7 +372,7 @@ gnc_query_path2scm (const GSList *path)
for (node = path; node; node = node->next)
{
const char *key = node->data;
auto key = static_cast<const char *>(node->data);
if (key)
path_scm = scm_cons (scm_from_utf8_string (key), path_scm);
@ -383,10 +384,10 @@ gnc_query_path2scm (const GSList *path)
GSList *
gnc_query_scm2path (SCM path_scm)
{
GSList *path = NULL;
GSList *path = nullptr;
if (!scm_is_list (path_scm))
return NULL;
return nullptr;
while (!scm_is_null (path_scm))
{
@ -420,7 +421,7 @@ static SCM
gnc_queryterm2scm (const QofQueryTerm *qt)
{
SCM qt_scm = SCM_EOL;
QofQueryPredData *pd = NULL;
QofQueryPredData *pd = nullptr;
qt_scm = scm_cons (gnc_query_path2scm (qof_query_term_get_param_path (qt)),
qt_scm);
@ -432,7 +433,7 @@ gnc_queryterm2scm (const QofQueryTerm *qt)
if (!g_strcmp0 (pd->type_name, QOF_TYPE_STRING))
{
query_string_t pdata = (query_string_t) pd;
auto pdata = (query_string_t) pd;
qt_scm = scm_cons (scm_from_long (pdata->options), qt_scm);
qt_scm = scm_cons (SCM_BOOL (pdata->is_regex), qt_scm);
@ -441,7 +442,7 @@ gnc_queryterm2scm (const QofQueryTerm *qt)
}
else if (!g_strcmp0 (pd->type_name, QOF_TYPE_DATE))
{
query_date_t pdata = (query_date_t) pd;
auto pdata = (query_date_t) pd;
qt_scm = scm_cons (scm_from_long (pdata->options), qt_scm);
qt_scm = scm_cons (scm_from_int64 (pdata->date), qt_scm);
@ -449,7 +450,7 @@ gnc_queryterm2scm (const QofQueryTerm *qt)
}
else if (!g_strcmp0 (pd->type_name, QOF_TYPE_NUMERIC))
{
query_numeric_t pdata = (query_numeric_t) pd;
auto pdata = (query_numeric_t) pd;
qt_scm = scm_cons (scm_from_long (pdata->options), qt_scm);
qt_scm = scm_cons (gnc_query_numeric2scm (pdata->amount), qt_scm);
@ -457,7 +458,7 @@ gnc_queryterm2scm (const QofQueryTerm *qt)
}
else if (!g_strcmp0 (pd->type_name, QOF_TYPE_GUID))
{
query_guid_t pdata = (query_guid_t) pd;
auto pdata = (query_guid_t) pd;
qt_scm = scm_cons (scm_from_long (pdata->options), qt_scm);
qt_scm = scm_cons (gnc_guid_glist2scm (pdata->guids), qt_scm);
@ -465,28 +466,28 @@ gnc_queryterm2scm (const QofQueryTerm *qt)
}
else if (!g_strcmp0 (pd->type_name, QOF_TYPE_INT64))
{
query_int64_t pdata = (query_int64_t) pd;
auto pdata = (query_int64_t) pd;
qt_scm = scm_cons (scm_from_int64 (pdata->val), qt_scm);
}
else if (!g_strcmp0 (pd->type_name, QOF_TYPE_DOUBLE))
{
query_double_t pdata = (query_double_t) pd;
auto pdata = (query_double_t) pd;
qt_scm = scm_cons (scm_from_double (pdata->val), qt_scm);
}
else if (!g_strcmp0 (pd->type_name, QOF_TYPE_BOOLEAN))
{
query_boolean_t pdata = (query_boolean_t) pd;
auto pdata = (query_boolean_t) pd;
qt_scm = scm_cons (SCM_BOOL (pdata->val), qt_scm);
}
else if (!g_strcmp0 (pd->type_name, QOF_TYPE_CHAR))
{
query_char_t pdata = (query_char_t) pd;
auto pdata = (query_char_t) pd;
qt_scm = scm_cons (scm_from_long (pdata->options), qt_scm);
qt_scm = scm_cons (pdata->char_list ? scm_from_utf8_string (pdata->char_list) : SCM_BOOL_F, qt_scm);
@ -504,16 +505,16 @@ gnc_queryterm2scm (const QofQueryTerm *qt)
static QofQuery *
gnc_scm2query_term_query_v2 (SCM qt_scm)
{
QofQuery *q = NULL;
QofQueryPredData *pd = NULL;
QofQuery *q = nullptr;
QofQueryPredData *pd = nullptr;
SCM scm;
gchar *type = NULL;
GSList *path = NULL;
gchar *type = nullptr;
GSList *path = nullptr;
gboolean inverted = FALSE;
QofQueryCompare compare_how;
if (!scm_is_list (qt_scm) || scm_is_null (qt_scm))
return NULL;
return nullptr;
do
{
@ -720,17 +721,17 @@ static QofQuery *
gnc_scm2query_term_query_v1 (SCM query_term_scm)
{
gboolean ok = FALSE;
gchar * pd_type = NULL;
gchar * pr_type = NULL;
gchar * pd_type = nullptr;
gchar * pr_type = nullptr;
gboolean sense = FALSE;
QofQuery *q = NULL;
QofQuery *q = nullptr;
SCM scm;
if (!scm_is_list (query_term_scm) ||
scm_is_null (query_term_scm))
{
PINFO ("null term");
return NULL;
return nullptr;
}
do
@ -985,7 +986,7 @@ gnc_scm2query_term_query_v1 (SCM query_term_scm)
if (gnc_scm2balance_match_how (scm, &how) == FALSE)
break;
xaccQueryAddBalanceMatch (q, how, QOF_QUERY_OR);
xaccQueryAddBalanceMatch (q, static_cast<QofQueryCompare>(how), QOF_QUERY_OR);
ok = TRUE;
}
@ -1038,7 +1039,7 @@ gnc_scm2query_term_query_v1 (SCM query_term_scm)
}
qof_query_destroy (q);
return NULL;
return nullptr;
}
static QofQuery *
@ -1051,7 +1052,7 @@ gnc_scm2query_term_query (SCM query_term_scm, query_version_t vers)
case gnc_QUERY_v2:
return gnc_scm2query_term_query_v2 (query_term_scm);
default:
return NULL;
return nullptr;
}
}
@ -1066,9 +1067,9 @@ gnc_query_terms2scm (const GList *terms)
SCM and_terms = SCM_EOL;
GList *and_node;
for (and_node = or_node->data; and_node; and_node = and_node->next)
for (and_node = static_cast<GList*>(or_node->data); and_node; and_node = and_node->next)
{
QofQueryTerm *qt = and_node->data;
auto qt = static_cast<QofQueryTerm*>(and_node->data);
SCM qt_scm;
qt_scm = gnc_queryterm2scm (qt);
@ -1087,10 +1088,10 @@ gnc_query_terms2scm (const GList *terms)
static QofQuery *
gnc_scm2query_and_terms (SCM and_terms, query_version_t vers)
{
QofQuery *q = NULL;
QofQuery *q = nullptr;
if (!scm_is_list (and_terms))
return NULL;
return nullptr;
while (!scm_is_null (and_terms))
{
@ -1128,10 +1129,10 @@ gnc_scm2query_and_terms (SCM and_terms, query_version_t vers)
static QofQuery *
gnc_scm2query_or_terms (SCM or_terms, query_version_t vers)
{
QofQuery *q = NULL;
QofQuery *q = nullptr;
if (!scm_is_list (or_terms))
return NULL;
return nullptr;
q = qof_query_create_for(GNC_ID_SPLIT);
@ -1175,7 +1176,7 @@ gnc_query_sort2scm (const QofQuerySort *qs)
GSList *path;
path = qof_query_sort_get_param_path (qs);
if (path == NULL)
if (path == nullptr)
return SCM_BOOL_F;
sort_scm = scm_cons (gnc_query_path2scm (path), sort_scm);
@ -1194,7 +1195,7 @@ gnc_query_scm2sort (SCM sort_scm, GSList **path, gint *options, gboolean *inc)
gboolean i;
g_return_val_if_fail (path && options && inc, FALSE);
g_return_val_if_fail (*path == NULL, FALSE);
g_return_val_if_fail (*path == nullptr, FALSE);
/* This is ok -- it means we have an empty sort. Don't do anything */
if (scm_is_bool (sort_scm))
@ -1294,86 +1295,86 @@ gnc_query2scm (QofQuery *q)
static GSList *
gnc_query_sort_to_list (const gchar * symbol)
{
GSList *path = NULL;
GSList *path = nullptr;
if (!symbol)
return NULL;
return nullptr;
if (!g_strcmp0 (symbol, "by-none"))
{
path = NULL;
path = nullptr;
}
else if (!g_strcmp0 (symbol, "by-standard"))
{
path = g_slist_prepend (path, QUERY_DEFAULT_SORT);
path = g_slist_prepend (path, (gpointer) QUERY_DEFAULT_SORT);
}
else if (!g_strcmp0 (symbol, "by-date") ||
!g_strcmp0 (symbol, "by-date-rounded"))
{
path = g_slist_prepend (path, TRANS_DATE_POSTED);
path = g_slist_prepend (path, SPLIT_TRANS);
path = g_slist_prepend (path, (gpointer) TRANS_DATE_POSTED);
path = g_slist_prepend (path, (gpointer) SPLIT_TRANS);
}
else if (!g_strcmp0 (symbol, "by-date-entered") ||
!g_strcmp0 (symbol, "by-date-entered-rounded"))
{
path = g_slist_prepend (path, TRANS_DATE_ENTERED);
path = g_slist_prepend (path, SPLIT_TRANS);
path = g_slist_prepend (path, (gpointer) TRANS_DATE_ENTERED);
path = g_slist_prepend (path, (gpointer) SPLIT_TRANS);
}
else if (!g_strcmp0 (symbol, "by-date-reconciled") ||
!g_strcmp0 (symbol, "by-date-reconciled-rounded"))
{
path = g_slist_prepend (path, SPLIT_DATE_RECONCILED);
path = g_slist_prepend (path, (gpointer) SPLIT_DATE_RECONCILED);
}
else if (!g_strcmp0 (symbol, "by-num"))
{
path = g_slist_prepend (path, TRANS_NUM);
path = g_slist_prepend (path, SPLIT_TRANS);
path = g_slist_prepend (path, (gpointer) TRANS_NUM);
path = g_slist_prepend (path, (gpointer) SPLIT_TRANS);
}
else if (!g_strcmp0 (symbol, "by-amount"))
{
path = g_slist_prepend (path, SPLIT_VALUE);
path = g_slist_prepend (path, (gpointer) SPLIT_VALUE);
}
else if (!g_strcmp0 (symbol, "by-memo"))
{
path = g_slist_prepend (path, SPLIT_MEMO);
path = g_slist_prepend (path, (gpointer) SPLIT_MEMO);
}
else if (!g_strcmp0 (symbol, "by-desc"))
{
path = g_slist_prepend (path, TRANS_DESCRIPTION);
path = g_slist_prepend (path, SPLIT_TRANS);
path = g_slist_prepend (path, (gpointer) TRANS_DESCRIPTION);
path = g_slist_prepend (path, (gpointer) SPLIT_TRANS);
}
else if (!g_strcmp0 (symbol, "by-reconcile"))
{
path = g_slist_prepend (path, SPLIT_RECONCILE);
path = g_slist_prepend (path, (gpointer) SPLIT_RECONCILE);
}
else if (!g_strcmp0 (symbol, "by-account-full-name"))
{
path = g_slist_prepend (path, SPLIT_ACCT_FULLNAME);
path = g_slist_prepend (path, (gpointer) SPLIT_ACCT_FULLNAME);
}
else if (!g_strcmp0 (symbol, "by-account-code"))
{
path = g_slist_prepend (path, ACCOUNT_CODE_);
path = g_slist_prepend (path, SPLIT_ACCOUNT);
path = g_slist_prepend (path, (gpointer) ACCOUNT_CODE_);
path = g_slist_prepend (path, (gpointer) SPLIT_ACCOUNT);
}
else if (!g_strcmp0 (symbol, "by-corr-account-full-name"))
{
path = g_slist_prepend (path, SPLIT_CORR_ACCT_NAME);
path = g_slist_prepend (path, (gpointer) SPLIT_CORR_ACCT_NAME);
}
else if (!g_strcmp0 (symbol, "by-corr-account-code"))
{
path = g_slist_prepend (path, SPLIT_CORR_ACCT_CODE);
path = g_slist_prepend (path, (gpointer) SPLIT_CORR_ACCT_CODE);
}
else
@ -1387,11 +1388,11 @@ gnc_query_sort_to_list (const gchar * symbol)
static QofQuery *
gnc_scm2query_v1 (SCM query_scm)
{
QofQuery *q = NULL;
QofQuery *q = nullptr;
gboolean ok = TRUE;
gchar * primary_sort = NULL;
gchar * secondary_sort = NULL;
gchar * tertiary_sort = NULL;
gchar * primary_sort = nullptr;
gchar * secondary_sort = nullptr;
gchar * tertiary_sort = nullptr;
gboolean primary_increasing = TRUE;
gboolean secondary_increasing = TRUE;
gboolean tertiary_increasing = TRUE;
@ -1534,7 +1535,7 @@ gnc_scm2query_v1 (SCM query_scm)
else
{
qof_query_destroy (q);
q = NULL;
q = nullptr;
}
g_free (primary_sort);
@ -1547,10 +1548,10 @@ gnc_scm2query_v1 (SCM query_scm)
static QofQuery *
gnc_scm2query_v2 (SCM query_scm)
{
QofQuery *q = NULL;
QofQuery *q = nullptr;
gboolean ok = TRUE;
gchar * search_for = NULL;
GSList *sp1 = NULL, *sp2 = NULL, *sp3 = NULL;
gchar * search_for = nullptr;
GSList *sp1 = nullptr, *sp2 = nullptr, *sp3 = nullptr;
gint so1 = 0, so2 = 0, so3 = 0;
gboolean si1 = TRUE, si2 = TRUE, si3 = TRUE;
int max_results = -1;
@ -1668,7 +1669,7 @@ gnc_scm2query_v2 (SCM query_scm)
else
{
qof_query_destroy (q);
q = NULL;
q = nullptr;
}
g_free (search_for);
@ -1681,11 +1682,11 @@ gnc_scm2query (SCM query_scm)
{
SCM q_type;
gchar *type;
QofQuery *q = NULL;
QofQuery *q = nullptr;
/* Not a list or NULL? No need to go further */
/* Not a list or nullptr? No need to go further */
if (!scm_is_list (query_scm) || scm_is_null (query_scm))
return NULL;
return nullptr;
/* Grab the 'type' (for v2 and above) */
q_type = SCM_CAR (query_scm);
@ -1699,14 +1700,14 @@ gnc_scm2query (SCM query_scm)
}
else
{
return NULL;
return nullptr;
}
}
/* Ok, the LHS is the version and the RHS is the actual query list */
type = gnc_scm_symbol_to_locale_string (q_type);
if (!type)
return NULL;
return nullptr;
if (!g_strcmp0 (type, "query-v2"))
q = gnc_scm2query_v2 (SCM_CDR (query_scm));
@ -1745,7 +1746,7 @@ gnc_numeric_to_scm(gnc_numeric arg)
static SCM
gnc_generic_to_scm(const void *cx, const gchar *type_str)
{
swig_type_info * stype = NULL;
swig_type_info * stype = nullptr;
void *x = (void*) cx;
if (!x) return SCM_BOOL_F;
@ -1763,17 +1764,17 @@ gnc_generic_to_scm(const void *cx, const gchar *type_str)
static void *
gnc_scm_to_generic(SCM scm, const gchar *type_str)
{
swig_type_info * stype = NULL;
swig_type_info * stype = nullptr;
stype = SWIG_TypeQuery(type_str);
if (!stype)
{
PERR("Unknown SWIG Type: %s ", type_str);
return NULL;
return nullptr;
}
if (!SWIG_IsPointerOfType(scm, stype))
return NULL;
return nullptr;
return SWIG_MustGetPtr(scm, stype, 1, 0);
}
@ -1781,7 +1782,7 @@ gnc_scm_to_generic(SCM scm, const gchar *type_str)
gnc_commodity *
gnc_scm_to_commodity(SCM scm)
{
return gnc_scm_to_generic(scm, "_p_gnc_commodity");
return static_cast<gnc_commodity*>(gnc_scm_to_generic(scm, "_p_gnc_commodity"));
}
SCM
@ -1799,7 +1800,7 @@ gnc_book_to_scm (const QofBook *book)
static swig_type_info *
get_acct_type ()
{
static swig_type_info * account_type = NULL;
static swig_type_info * account_type = nullptr;
if (!account_type)
account_type = SWIG_TypeQuery("_p_Account");
@ -1810,7 +1811,7 @@ get_acct_type ()
GncAccountValue * gnc_scm_to_account_value_ptr (SCM valuearg)
{
GncAccountValue *res;
Account *acc = NULL;
Account *acc = nullptr;
gnc_numeric value;
swig_type_info * account_type = get_acct_type();
SCM val;
@ -1818,9 +1819,9 @@ GncAccountValue * gnc_scm_to_account_value_ptr (SCM valuearg)
/* Get the account */
val = SCM_CAR (valuearg);
if (!SWIG_IsPointerOfType (val, account_type))
return NULL;
return nullptr;
acc = SWIG_MustGetPtr(val, account_type, 1, 0);
acc = static_cast<Account*>(SWIG_MustGetPtr(val, account_type, 1, 0));
/* Get the value */
val = SCM_CDR (valuearg);
@ -1859,7 +1860,7 @@ typedef struct
static void
delete_scm_hook (gpointer data)
{
GncScmDangler *scm = data;
auto scm = static_cast<GncScmDangler*>(data);
scm_gc_unprotect_object(scm->proc);
g_free(scm);
}
@ -1903,7 +1904,7 @@ gnc_hook_add_scm_dangler (const gchar *name, SCM proc)
time64
gnc_parse_time_to_time64 (const gchar *s, const gchar *format)
{
struct tm tm;
struct tm tm{};
g_return_val_if_fail(s && format, -1);

View File

@ -27,42 +27,54 @@
#include <glib.h>
#include <libguile.h>
#ifdef __cplusplus
extern "C"
{
#endif
#include "gnc-engine.h"
#include <gncTaxTable.h> /* for GncAccountValue */
#include <gncTaxTable.h> /* for GncAccountValue */
#include "gnc-hooks.h"
/* Helpers for various conversions to and from guile */
GDate gnc_time64_to_GDate(SCM x);
GDate gnc_time64_to_GDate(SCM x);
SCM gnc_guid2scm(GncGUID guid);
SCM gnc_guid2scm(GncGUID guid);
GncGUID gnc_scm2guid(SCM guid_scm);
int gnc_guid_p(SCM guid_scm);
int gnc_guid_p(SCM guid_scm);
/* for a list of strings */
GSList * gnc_query_scm2path (SCM path_scm);
GSList* gnc_query_scm2path(SCM path_scm);
/* These two functions convert a query object into a scheme
* representation of the query and vice-versa. They do not
* simply convert a query pointer to a guile query pointer! */
SCM gnc_query2scm (QofQuery * q);
QofQuery * gnc_scm2query (SCM query_scm);
SCM gnc_query2scm(QofQuery* q);
QofQuery* gnc_scm2query(SCM query_scm);
SCM gnc_numeric_to_scm(gnc_numeric arg);
gnc_numeric gnc_scm_to_numeric(SCM arg);
gnc_commodity * gnc_scm_to_commodity(SCM scm);
SCM gnc_commodity_to_scm (const gnc_commodity *commodity);
SCM gnc_book_to_scm (const QofBook *book);
gnc_commodity* gnc_scm_to_commodity(SCM scm);
SCM gnc_commodity_to_scm(const gnc_commodity* commodity);
SCM gnc_book_to_scm(const QofBook* book);
/* Conversion routines used with tax tables */
GncAccountValue * gnc_scm_to_account_value_ptr (SCM valuearg);
SCM gnc_account_value_ptr_to_scm (GncAccountValue *);
GncAccountValue* gnc_scm_to_account_value_ptr(SCM valuearg);
SCM gnc_account_value_ptr_to_scm(GncAccountValue*);
/**
* add Scheme-style danglers from a hook
*/
void gnc_hook_add_scm_dangler(const gchar *name, SCM proc);
void gnc_hook_add_scm_dangler(const gchar* name, SCM proc);
/** Convert a time string to calendar time representation. Combine strptime and
* mktime into a single function to avoid the need to wrap struct tm *.
@ -72,5 +84,9 @@ void gnc_hook_add_scm_dangler(const gchar *name, SCM proc);
* @param format Format specification.
*
* @return The time in seconds since unix epoch, or -1 on error */
time64 gnc_parse_time_to_time64 (const gchar *s, const gchar *format);
time64 gnc_parse_time_to_time64(const gchar* s, const gchar* format);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -80,14 +80,6 @@ SCM scm_init_sw_gnc_optiondb_module(void);
%include <std_string.i>
%import <base-typemaps.i>
%import (module="sw_engine") <gnc-budget.h>
%import (module="sw_engine") <gncOwner.h>
%import (module="sw_engine") <gncCustomer.h>
%import (module="sw_engine") <gncEmployee.h>
%import (module="sw_engine") <gncVendor.h>
%import (module="sw_engine") <gncTaxTable.h>
%import (module="sw_engine") <gncInvoice.h>
%import (module="sw_engine") <gncJob.h>
/* Implementation Note: Plain overloads failed to compile because
* auto value{option.get_value()};
@ -158,6 +150,12 @@ SCM scm_init_sw_gnc_optiondb_module(void);
}
%inline %{
static inline QofBook*
get_current_book(void )
{
return qof_session_get_book(gnc_get_current_session());
}
template <typename ValueType> inline SCM
scm_from_value(ValueType value);
/*{
@ -278,7 +276,7 @@ template <>inline SCM
scm_from_value<GncOptionAccountList>(GncOptionAccountList value)
{
SCM s_list = SCM_EOL;
auto book{gnc_get_current_book()};
auto book{get_current_book()};
for (auto guid : value)
{
auto acct{xaccAccountLookup(&guid, book)};
@ -409,14 +407,14 @@ scm_to_value<gnc_commodity*>(SCM new_value)
if (len > 1)
name_space = scm_to_utf8_string(scm_list_ref(new_value,
scm_from_uint(1)));
auto book{gnc_get_current_book()};
auto book{get_current_book()};
auto table = gnc_commodity_table_get_table(book);
return gnc_commodity_table_lookup(table, name_space.c_str(),
mnemonic.c_str());
}
if (scm_is_string(new_value))
{
auto book{gnc_get_current_book()};
auto book{get_current_book()};
auto table = gnc_commodity_table_get_table(book);
std::string mnemonic{scm_to_utf8_string(new_value)};
return gnc_commodity_table_lookup(table, "CURRENCY", mnemonic.c_str());
@ -501,7 +499,7 @@ QofBook*
gnc_option_test_book_new()
{
auto session = gnc_get_current_session();
return gnc_get_current_book();
return get_current_book();
}
void
@ -689,7 +687,7 @@ gnc_option_test_book_destroy(QofBook* book)
%typemap(out) GncOptionAccountList
{
$result = SCM_EOL;
auto book{gnc_get_current_book()};
auto book{get_current_book()};
for (auto guid : $1)
{
auto acct{xaccAccountLookup(&guid, book)};
@ -702,7 +700,7 @@ gnc_option_test_book_destroy(QofBook* book)
%typemap(out) const GncOptionAccountList&
{
$result = SCM_EOL;
auto book{gnc_get_current_book()};
auto book{get_current_book()};
for (auto guid : *$1)
{
auto acct{xaccAccountLookup(&guid, book)};
@ -1426,7 +1424,7 @@ inline SCM return_scm_value(ValueType value)
auto strval{scm_to_utf8_string(new_value)};
GncGUID guid;
string_to_guid(strval, &guid);
auto book{gnc_get_current_book()};
auto book{get_current_book()};
option.set_value(xaccAccountLookup(&guid, book));
}
else
@ -1508,7 +1506,7 @@ inline SCM return_scm_value(ValueType value)
auto strval{scm_to_utf8_string(new_value)};
GncGUID guid;
string_to_guid(strval, &guid);
auto book{gnc_get_current_book()};
auto book{get_current_book()};
option.set_default_value(xaccAccountLookup(&guid, book));
}
else

View File

@ -17,13 +17,13 @@
;; 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
;; Boston, MA 02110-1301, USA gnu@gnu.org
(define-module (gnucash app-utils options))
(define-module (gnucash options))
(eval-when (compile load eval expand)
(load-extension "libgnucash-guile" "scm_init_sw_app_utils_module"))
(use-modules (gnucash core-utils))
(use-modules (gnucash engine))
(use-modules (sw_engine))
(use-modules (sw_app_utils))
(use-modules (gnucash utilities))
(use-modules (srfi srfi-1))
@ -348,12 +348,6 @@
;; invoice pointers may be used to set the value of the option. The
;; option always returns a single invoice pointer.
(use-modules (gnucash core-utils))
(use-modules (gnucash engine))
(use-modules (gnucash utilities))
(use-modules (gnucash app-utils options))
(use-modules (sw_app_utils))
(export gnc:*business-label*)
(export gnc:*company-name*)
(export gnc:*company-addy*)

View File

@ -60,6 +60,7 @@ set (scm_tests_with_srfi64_SOURCES
test-business-core.scm
test-scm-engine.scm
test-scm-kvpvalue.scm
test-options.scm
)
if (HAVE_SRFI64)
@ -117,7 +118,6 @@ set(test_app_utils_scheme_SOURCES
set (test_app_utils_scheme_SRFI64_SOURCES
test-date-utilities.scm
test-options.scm
)
gnc_add_scheme_test_targets(scm-test-load-app-utils-module

View File

@ -23,7 +23,7 @@
(use-modules (srfi srfi-64))
(use-modules (tests srfi64-extras))
(use-modules (gnucash app-utils options))
(use-modules (gnucash options))
(use-modules (sw_app_utils))
(use-modules (sw_engine))

View File

@ -2,8 +2,10 @@
;; Load the C++ option implementation, avoiding the options.scm ones.
(eval-when
(compile load eval expand)
(load-extension "libgnucash-guile" "scm_init_sw_app_utils_module"))
(load-extension "libgnucash-guile" "scm_init_sw_app_utils_module")
(load-extension "libgnucash-guile" "scm_init_sw_engine_module"))
(use-modules (sw_app_utils))
(use-modules (sw_engine))
(use-modules (srfi srfi-64))
(use-modules (tests srfi64-extras))

View File

@ -76,7 +76,7 @@ main_helper (void *closure, int argc, char **argv)
{
int count = 50;
scm_c_use_module("gnucash app-utils");
scm_c_use_module("gnucash options");
if (argc > 1)
count = atoi (argv[1]);

View File

@ -110,7 +110,7 @@ run_tests (void)
static void
main_helper (void *closure, int argc, char **argv)
{
scm_c_use_module("gnucash app-utils");
scm_c_use_module("gnucash options");
xaccLogDisable ();

View File

@ -67,17 +67,17 @@ extern "C"
#include <sstream>
#include "dialog-options.hpp"
#include <gnc-optiondb.hpp>
#include <gnc-optiondb-impl.hpp>
#include "gnc-optiondb.hpp"
#include "gnc-optiondb-impl.hpp"
#define GNC_PREF_CLOCK_24H "clock-24h"
#include <gnc-option.hpp>
#include "gnc-option.hpp"
//#include <gnc-option-impl.hpp>
#include <gnc-optiondb.hpp>
#include <gnc-option-uitype.hpp>
#include <gnc-option-ui.hpp>
#include "gnc-optiondb.hpp"
#include "gnc-option-uitype.hpp"
#include "gnc-option-ui.hpp"
#define FUNC_NAME G_STRFUNC
/* TODO: clean up "register-stocks" junk

View File

@ -33,8 +33,8 @@
#include <vector>
#include <libguile.h>
#include <gnc-option-uitype.hpp>
#include <gnc-option-ui.hpp>
#include "gnc-option-uitype.hpp"
#include "gnc-option-ui.hpp"
/** @fn WidgetCreateFunc
* Function pointer for per-option-type GtkWidget constructors.

View File

@ -76,7 +76,7 @@ extern "C"
#include "gnc-warnings.h"
#include "gnc-window.h"
#include "gnc-prefs.h"
#include <gnc-optiondb.h>
#include "gnc-optiondb.h"
#include "gnc-autosave.h"
#include "print-session.h"
#ifdef MAC_INTEGRATION

View File

@ -68,7 +68,7 @@ extern "C"
#include "gnc-engine.h"
}
#include <dialog-options.hpp>
#include <gnc-optiondb.h>
#include "gnc-optiondb.h"
static QofLogModule log_module = GNC_MOD_IMPORT;

View File

@ -48,7 +48,7 @@ extern "C"
#include <exception>
#include <dialog-options.hpp>
#include <gnc-option.hpp>
#include "gnc-option.hpp"
#define FUNC_NAME G_STRFUNC

View File

@ -42,7 +42,7 @@ extern "C"
#include "dialog-report-column-view.hpp"
#include <dialog-options.hpp>
#include <gnc-report.h>
#include <gnc-optiondb-impl.hpp>
#include "gnc-optiondb-impl.hpp"
enum available_cols
{

View File

@ -42,7 +42,7 @@ extern "C"
}
#include "gnc-report.h"
#include <dialog-options.hpp>
#include <gnc-optiondb.h>
#include "gnc-optiondb.h"
#define DIALOG_STYLE_SHEETS_CM_CLASS "style-sheets-dialog"
#define GNC_PREFS_GROUP "dialogs.style-sheet"

View File

@ -79,7 +79,7 @@ extern "C"
#include <memory>
#include <gnc-report.h>
#include <gnc-optiondb-impl.hpp>
#include "gnc-optiondb-impl.hpp"
/* NW: you can add GNC_MOD_REPORT to gnc-engine.h
or simply define it locally. Any unique string with

View File

@ -30,7 +30,7 @@ extern "C"
#endif
//#include "gnc-html.h"
#include "qof.h"
#include <gnc-optiondb.h>
#include "gnc-optiondb.h"
typedef struct gnc_report_window_s gnc_report_window;

View File

@ -28,7 +28,7 @@
#include <glib.h>
#include <libguile.h>
#ifdef __cplusplus
#include <gnc-optiondb.hpp>
#include "gnc-optiondb.hpp"
extern "C"
{
#endif

View File

@ -31,7 +31,7 @@
(use-modules (sw_report))
(use-modules (gnucash core-utils))
(use-modules (gnucash app-utils options))
(use-modules (gnucash options))
(use-modules (gnucash report html-document))
(use-modules (ice-9 regex))

View File

@ -25,6 +25,7 @@
(use-modules (gnucash core-utils))
(use-modules (gnucash app-utils))
(use-modules (gnucash options))
(export gnc:options-add-report-date!)
(export gnc:options-add-date-interval!)

View File

@ -40,7 +40,8 @@
(use-modules (gnucash report html-utilities))
(load-and-reexport (sw_report)
(sw_engine))
(sw_engine)
(gnucash options))
(export <report>)
(export gnc:all-report-template-guids)

View File

@ -1,6 +1,7 @@
(use-modules (ice-9 textual-ports))
(use-modules (ice-9 popen))
(use-modules (gnucash engine))
(use-modules (sw_engine))
(use-modules (gnucash utilities))
(use-modules (gnucash app-utils))
(use-modules (tests test-engine-extras))

View File

@ -24,7 +24,6 @@
(use-modules (gnucash engine))
(use-modules (gnucash utilities))
(use-modules (gnucash core-utils))
(use-modules (gnucash app-utils))
(use-modules (gnucash report))
(use-modules (srfi srfi-13))
(use-modules (gnucash html))

View File

@ -39,7 +39,6 @@
(use-modules (gnucash engine))
(use-modules (gnucash utilities))
(use-modules (gnucash core-utils))
(use-modules (gnucash app-utils))
(use-modules (gnucash report))
(use-modules (gnucash html))

View File

@ -38,7 +38,6 @@
(use-modules (gnucash engine))
(use-modules (gnucash utilities))
(use-modules (gnucash core-utils)) ; for gnc:version and (G_ ...)
(use-modules (gnucash app-utils))
(use-modules (gnucash report))
(use-modules (gnucash html))

View File

@ -27,7 +27,6 @@
(use-modules (gnucash engine))
(use-modules (gnucash utilities))
(use-modules (gnucash core-utils))
(use-modules (gnucash app-utils))
(use-modules (gnucash report))
(use-modules (srfi srfi-13))
(use-modules (srfi srfi-14))

View File

@ -6,28 +6,16 @@ include (GncFindLibm)
# Build the library
set (app_utils_noinst_HEADERS
gnc-option-date.hpp
gnc-option-impl.hpp
gnc-option-ui.hpp
gnc-option-uitype.hpp
gnc-optiondb-impl.hpp
)
set (app_utils_HEADERS
QuickFill.h
file-utils.h
gnc-basic-gobject.h
gnc-account-merge.h
gnc-accounting-period.h
gnc-addr-quickfill.h
gnc-entry-quickfill.h
gnc-euro.h
gnc-gsettings.h
gnc-help-utils.h
gnc-option.hpp
gnc-optiondb.h
gnc-optiondb.hpp
gnc-prefs-utils.h
gnc-state.h
gnc-ui-util.h
@ -38,15 +26,10 @@ set (app_utils_SOURCES
QuickFill.c
file-utils.c
gnc-account-merge.c
gnc-accounting-period.c
gnc-addr-quickfill.c
gnc-entry-quickfill.c
gnc-euro.c
gnc-gsettings.cpp
gnc-option-date.cpp
gnc-option.cpp
gnc-option-impl.cpp
gnc-optiondb.cpp
gnc-prefs-utils.c
gnc-state.c
gnc-ui-util.c
@ -60,7 +43,7 @@ if (NOT STANDARD_MATH_LIBRARY_FOUND)
message(FATAL_ERROR "An implementation of the standard C function pow() is required and is supported neither by the C runtime nor libm.so.")
endif()
set(app_utils_ALL_SOURCES ${app_utils_SOURCES} ${app_utils_HEADERS} ${app_utils_noinst_HEADERS})
set(app_utils_ALL_SOURCES ${app_utils_SOURCES} ${app_utils_HEADERS})
set(app_utils_ALL_LIBRARIES
gnc-engine
${GLIB_LDFLAGS}
@ -173,8 +156,7 @@ set_local_dist(app_utils_DIST_local
${app_utils_SCHEME_2}
${app_utils_SCHEME_3}
${expressions_all_sources}
${expressions_SCHEME}
app-utils.i gnc-optiondb.i expressions.i CMakeLists.txt gnc-help-utils.c)
CMakeLists.txt gnc-help-utils.c)
set(app_utils_DIST

View File

@ -23,16 +23,17 @@ macro(add_app_utils_test _TARGET _SOURCE_FILES)
endmacro()
gnc_add_test_with_guile(test-exp-parser test-exp-parser.c
APP_UTILS_TEST_INCLUDE_DIRS APP_UTILS_TEST_LIBS scm-expressions
)
APP_UTILS_TEST_INCLUDE_DIRS APP_UTILS_TEST_LIBS
)
add_dependencies(test-exp-parser scm-expressions)
add_app_utils_test(test-print-parse-amount test-print-parse-amount.cpp)
gnc_add_test_with_guile(test-sx test-sx.cpp
APP_UTILS_TEST_INCLUDE_DIRS APP_UTILS_TEST_LIBS
)
set(gtest_gnc_option_SOURCES
gtest-gnc-option.cpp
gtest-gnc-optiondb.cpp)
../../engine/test/gtest-gnc-option.cpp
../../engine/test/gtest-gnc-optiondb.cpp)
set(gtest_gnc_option_INCLUDES
${MODULEPATH}
@ -64,8 +65,8 @@ set_dist_list(test_app_utils_DIST
test-exp-parser.c
test-print-parse-amount.cpp
test-sx.cpp
gtest-gnc-option.cpp
gtest-gnc-optiondb.cpp
../../engine/test/gtest-gnc-option.cpp
../../engine/test/gtest-gnc-optiondb.cpp
test-c-interface.scm
test-date-utilities.scm
test-options.scm

File diff suppressed because it is too large Load Diff

View File

@ -15,6 +15,11 @@ set(engine_noinst_HEADERS
gnc-int128.hpp
gnc-lot.h
gnc-lot-p.h
gnc-option-date.hpp
gnc-option-impl.hpp
gnc-option-ui.hpp
gnc-option-uitype.hpp
gnc-optiondb-impl.hpp
gnc-pricedb-p.h
policy-p.h
qofbook-p.h
@ -44,6 +49,7 @@ set (engine_HEADERS
cap-gains.h
cashobjects.h
engine-helpers.h
gnc-accounting-period.h
gnc-aqbanking-templates.h
gnc-budget.h
gnc-commodity.h
@ -55,6 +61,9 @@ set (engine_HEADERS
gnc-hooks.h
gnc-numeric.h
gnc-numeric.hpp
gnc-option.hpp
gnc-optiondb.h
gnc-optiondb.hpp
gnc-pricedb.h
gnc-rational.hpp
gnc-rational-rounding.hpp
@ -140,6 +149,7 @@ set (engine_SOURCES
Transaction.c
cap-gains.c
cashobjects.c
gnc-accounting-period.c
gnc-aqbanking-templates.cpp
gnc-budget.cpp
gnc-commodity.c
@ -152,6 +162,10 @@ set (engine_SOURCES
gnc-int128.cpp
gnc-lot.c
gnc-numeric.cpp
gnc-option-date.cpp
gnc-option.cpp
gnc-option-impl.cpp
gnc-optiondb.cpp
gnc-pricedb.c
gnc-rational.cpp
gnc-session.c

View File

@ -47,7 +47,7 @@
#include "gnc-date.h"
#include "gnc-prefs.h"
#include "qof.h"
#include "gnc-ui-util.h"
#include "gnc-session.h"
static const QofLogModule log_module = G_LOG_DOMAIN;
static time64 gnc_accounting_period_start_time64 (GncAccountingPeriod which,
@ -103,7 +103,7 @@ get_fy_end (void)
QofBook *book;
GDate *date = NULL;
book = gnc_get_current_book();
book = qof_session_get_book(gnc_get_current_session());
qof_instance_get (QOF_INSTANCE (book), "fy-end", &date, NULL);
return date;
}

View File

@ -22,14 +22,14 @@
#include "gnc-option-date.hpp"
#include <array>
#include <gnc-datetime.hpp>
#include "gnc-datetime.hpp"
#include <iostream>
#include <cassert>
#include <algorithm>
extern "C"
{
#include <gnc-accounting-period.h>
#include "gnc-accounting-period.h"
}
#define N_(string) string //So that xgettext will find it

View File

@ -33,7 +33,7 @@
extern "C"
{
#include <gnc-date.h>
#include "gnc-date.h"
}
#include <vector>

View File

@ -23,8 +23,8 @@
//#include "options.h"
#include "gnc-option-impl.hpp"
#include <gnc-datetime.hpp>
#include <guid.hpp>
#include "gnc-datetime.hpp"
#include "guid.hpp"
#include <cassert>
#include <sstream>
#include <numeric>
@ -32,7 +32,8 @@
extern "C"
{
#include "gnc-accounting-period.h"
#include "gnc-ui-util.h"
#include "gnc-session.h"
#include "gncOwner.h"
}
static const QofLogModule log_module{"gnc.options"};
@ -52,11 +53,22 @@ make_gnc_item(const QofInstance* inst)
return std::make_pair(std::move(type), std::move(*const_cast<GncGUID*>(guid)));
}
static inline QofBook*
get_current_book(void)
{
return qof_session_get_book(gnc_get_current_session());
}
static inline Account*
get_current_root_account(void)
{
return gnc_book_get_root_account(get_current_book());
}
static const QofInstance*
qof_instance_from_gnc_item(const GncItem& item)
{
auto [type, guid] = item;
auto book{gnc_get_current_book()};
auto book{get_current_book()};
auto coll{qof_book_get_collection(book, type)};
return static_cast<QofInstance*>(qof_collection_lookup_entity(coll, &guid));
}
@ -177,7 +189,7 @@ static gnc_commodity*
gnc_commodity_from_namespace_and_mnemonic(std::string_view name_space,
std::string_view mnemonic)
{
auto book{gnc_get_current_book()};
auto book{get_current_book()};
auto table = gnc_commodity_table_get_table(book);
return gnc_commodity_table_lookup(table, name_space.data(),
mnemonic.data());
@ -283,7 +295,7 @@ GncOptionAccountListValue::validate(const GncOptionAccountList& values) const
}
if (m_allowed.empty())
return true;
auto book{gnc_get_current_book()};
auto book{get_current_book()};
for(auto& guid : values)
{
if (std::find(m_allowed.begin(), m_allowed.end(),
@ -314,12 +326,12 @@ GncOptionAccountListValue::get_default_value() const
if (m_allowed.empty())
return retval;
auto root{gnc_get_current_root_account()};
auto root{get_current_root_account()};
auto account_list{gnc_account_get_descendants_sorted(root)};
if (!account_list)
return retval;
auto book{gnc_get_current_book()};
auto book{get_current_book()};
for (auto node = account_list; node; node = g_list_next (node))
{
if (std::find(m_allowed.begin(), m_allowed.end(),
@ -379,7 +391,7 @@ GncOptionAccountSelValue::validate(const Account* value) const
const Account*
GncOptionAccountSelValue::get_value() const
{
auto book{gnc_get_current_book()};
auto book{get_current_book()};
return guid_equal(guid_null(), &m_value) ? get_default_value() :
xaccAccountLookup(&m_value, book);
}
@ -390,7 +402,7 @@ GncOptionAccountSelValue::get_default_value() const
if (!guid_equal(guid_null(), &m_default_value))
{
auto book{gnc_get_current_book()};
auto book{get_current_book()};
return xaccAccountLookup(&m_default_value, book);
}
@ -401,7 +413,7 @@ GncOptionAccountSelValue::get_default_value() const
return nullptr;
const Account* retval{nullptr};
auto root{gnc_get_current_root_account()};
auto root{get_current_root_account()};
auto account_list{gnc_account_get_descendants_sorted(root)};
if (!account_list)
return nullptr;
@ -595,7 +607,7 @@ qof_instance_from_guid(GncGUID* guid, GncOptionUIType type)
qof_type = "Account";
break;
}
auto book{gnc_get_current_book()};
auto book{get_current_book()};
auto col{qof_book_get_collection(book, qof_type)};
return QOF_INSTANCE(qof_collection_lookup_entity(col, guid));
}

View File

@ -37,12 +37,12 @@
extern "C"
{
#include <config.h>
#include <qof.h>
#include <Account.h>
#include <gnc-budget.h>
#include <gnc-commodity.h>
#include "qof.h"
#include "Account.h"
#include "gnc-budget.h"
#include "gnc-commodity.h"
}
#include <gnc-datetime.hpp>
#include "gnc-datetime.hpp"
#include <string>
#include <utility>
#include <vector>

View File

@ -30,7 +30,7 @@ static const char* log_module{"gnc.app-utils.gnc-option"};
extern "C"
{
#include <qoflog.h>
#include "qoflog.h"
}
template <typename ValueType,

View File

@ -42,7 +42,7 @@
#include <tuple>
#include "gnc-option-ui.hpp"
#include "gnc-option-date.hpp"
#include <guid.hpp>
#include "guid.hpp"
struct OptionClassifier;
class GncOptionUIItem;

View File

@ -42,13 +42,13 @@
extern "C"
{
#include <config.h>
#include <qof.h>
#include <gncInvoice.h>
#include <gncCustomer.h>
#include <gncEmployee.h>
#include <gncJob.h>
#include <gncVendor.h>
#include <gncTaxTable.h>
#include "qof.h"
#include "gncInvoice.h"
#include "gncCustomer.h"
#include "gncEmployee.h"
#include "gncJob.h"
#include "gncVendor.h"
#include "gncTaxTable.h"
}
using GncOptionVec = std::vector<GncOption>;

View File

@ -25,9 +25,9 @@
#include <string>
#include <limits>
#include <sstream>
#include <kvp-value.hpp>
#include <qofbookslots.h>
#include <guid.hpp>
#include "kvp-value.hpp"
#include "qofbookslots.h"
#include "guid.hpp"
#include "gnc-optiondb.h"
#include "gnc-optiondb.hpp"
#include "gnc-optiondb-impl.hpp"
@ -35,7 +35,7 @@
extern "C"
{
#include <gnc-session.h>
#include "gnc-session.h"
}
constexpr const char* log_module{G_LOG_DOMAIN};

View File

@ -68,11 +68,11 @@ extern "C"
{
#endif
#include <config.h>
#include <Account.h>
#include <gnc-budget.h>
#include <gnc-commodity.h>
#include <gncInvoice.h>
#include <gncTaxTable.h>
#include "Account.h"
#include "gnc-budget.h"
#include "gnc-commodity.h"
#include "gncInvoice.h"
#include "gncTaxTable.h"
/**
* Create an empty option database.

View File

@ -41,14 +41,14 @@
extern "C"
{
#include <config.h>
#include <Account.h>
#include <gnc-budget.h>
#include <gnc-commodity.h>
#include <gncInvoice.h>
#include <gncTaxTable.h>
#include "Account.h"
#include "gnc-budget.h"
#include "gnc-commodity.h"
#include "gncInvoice.h"
#include "gncTaxTable.h"
}
#include "gnc-option.hpp"
#include <gnc-datetime.hpp>
#include "gnc-datetime.hpp"
class GncOptionDB;

View File

@ -22,21 +22,21 @@
*******************************************************************/
#include <gtest/gtest.h>
#include <gnc-option.hpp>
#include <gnc-option-impl.hpp>
#include <gnc-option-ui.hpp>
#include <guid.hpp>
#include "gnc-option.hpp"
#include "gnc-option-impl.hpp"
#include "gnc-option-ui.hpp"
#include "guid.hpp"
extern "C"
{
#include <config.h>
#include <qof.h>
#include <Account.h>
#include <gnc-budget.h>
#include <gnc-commodity.h>
#include <gnc-date.h>
#include "qof.h"
#include "Account.h"
#include "gnc-budget.h"
#include "gnc-commodity.h"
#include "gnc-date.h"
#include <time.h>
#include <gnc-ui-util.h>
#include <gnc-session.h>
#include "gnc-ui-util.h"
#include "gnc-session.h"
}
TEST(GncOption, test_string_ctor)

View File

@ -22,16 +22,16 @@
*******************************************************************/
#include <gtest/gtest.h>
#include <gnc-optiondb.hpp>
#include <gnc-optiondb-impl.hpp>
#include <gnc-option-ui.hpp>
#include <kvp-value.hpp>
#include "gnc-optiondb.hpp"
#include "gnc-optiondb-impl.hpp"
#include "gnc-option-ui.hpp"
#include "kvp-value.hpp"
#include <glib-2.0/glib.h>
extern "C"
{
#include <gnc-ui-util.h>
#include <gnc-session.h>
#include "gnc-ui-util.h"
#include "gnc-session.h"
}
using GncOptionDBPtr = std::unique_ptr<GncOptionDB>;

View File

@ -8,7 +8,7 @@ bindings/guile/date-utilities.scm
bindings/guile/engine.scm
bindings/guile/fin.scm
bindings/guile/glib-guile.c
bindings/guile/gnc-engine-guile.c
bindings/guile/gnc-engine-guile.cpp
bindings/guile/gnc-guile-bindings.c
bindings/guile/gnc-guile-utils.c
bindings/guile/gnc-helpers.c
@ -507,7 +507,6 @@ libgnucash/app-utils/calculation/expression_parser.c
libgnucash/app-utils/calculation/fin.c
libgnucash/app-utils/file-utils.c
libgnucash/app-utils/gfec.c
libgnucash/app-utils/gnc-accounting-period.c
libgnucash/app-utils/gnc-account-merge.c
libgnucash/app-utils/gnc-addr-quickfill.c
libgnucash/app-utils/gnc-entry-quickfill.c
@ -515,10 +514,6 @@ libgnucash/app-utils/gnc-euro.c
libgnucash/app-utils/gnc-exp-parser.c
libgnucash/app-utils/gnc-gsettings.cpp
libgnucash/app-utils/gnc-help-utils.c
libgnucash/app-utils/gnc-option.cpp
libgnucash/app-utils/gnc-option-date.cpp
libgnucash/app-utils/gnc-optiondb.cpp
libgnucash/app-utils/gnc-option-impl.cpp
libgnucash/app-utils/gnc-prefs-utils.c
libgnucash/app-utils/gnc-state.c
libgnucash/app-utils/gnc-sx-instance-model.c
@ -605,6 +600,7 @@ libgnucash/engine/Account.cpp
libgnucash/engine/cap-gains.c
libgnucash/engine/cashobjects.c
libgnucash/engine/engine-helpers.c
libgnucash/engine/gnc-accounting-period.c
libgnucash/engine/gncAddress.c
libgnucash/engine/gnc-aqbanking-templates.cpp
libgnucash/engine/gncBillTerm.c
@ -627,6 +623,10 @@ libgnucash/engine/gncInvoice.c
libgnucash/engine/gncJob.c
libgnucash/engine/gnc-lot.c
libgnucash/engine/gnc-numeric.cpp
libgnucash/engine/gnc-option.cpp
libgnucash/engine/gnc-option-date.cpp
libgnucash/engine/gnc-optiondb.cpp
libgnucash/engine/gnc-option-impl.cpp
libgnucash/engine/gncOrder.c
libgnucash/engine/gncOwner.c
libgnucash/engine/gnc-pricedb.c