mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Create separate shared library for expression parser and SX instance model.
These functions depend on both libgnc-app-utils and libgnucash-guile, creating a circular dependency when the app-utils bindings are added to libgnucash-guile.
This commit is contained in:
parent
47904a858e
commit
3e2f7bc66a
@ -206,6 +206,7 @@ add_library (gnc-gnome-utils
|
|||||||
target_link_libraries(gnc-gnome-utils
|
target_link_libraries(gnc-gnome-utils
|
||||||
gnc-app-utils
|
gnc-app-utils
|
||||||
gnc-engine
|
gnc-engine
|
||||||
|
gnc-expressions
|
||||||
gnc-backend-xml-utils
|
gnc-backend-xml-utils
|
||||||
gnucash-guile
|
gnucash-guile
|
||||||
PkgConfig::GTK3
|
PkgConfig::GTK3
|
||||||
|
@ -134,6 +134,7 @@ target_link_libraries(gnc-gnome
|
|||||||
gnc-register-core
|
gnc-register-core
|
||||||
gnc-gnome-utils
|
gnc-gnome-utils
|
||||||
gnc-engine
|
gnc-engine
|
||||||
|
gnc-expressions
|
||||||
gnc-html
|
gnc-html
|
||||||
gnc-locale-tax
|
gnc-locale-tax
|
||||||
gnucash-guile
|
gnucash-guile
|
||||||
|
@ -28,6 +28,7 @@ target_compile_definitions(gnc-report PRIVATE -DG_LOG_DOMAIN=\"gnc.report.core\"
|
|||||||
target_link_libraries(gnc-report
|
target_link_libraries(gnc-report
|
||||||
gnc-app-utils
|
gnc-app-utils
|
||||||
gnucash-guile
|
gnucash-guile
|
||||||
|
gnc-expressions-guile
|
||||||
PkgConfig::GTK3
|
PkgConfig::GTK3
|
||||||
${GUILE_LDFLAGS})
|
${GUILE_LDFLAGS})
|
||||||
|
|
||||||
|
@ -22,7 +22,8 @@
|
|||||||
(define-module (gnucash report report-core))
|
(define-module (gnucash report report-core))
|
||||||
|
|
||||||
(eval-when (compile load eval expand)
|
(eval-when (compile load eval expand)
|
||||||
(load-extension "libgnc-report" "scm_init_sw_report_module"))
|
(load-extension "libgnc-report" "scm_init_sw_report_module")
|
||||||
|
(load-extension "libgnc-expressions-guile" "scm_init_sw_expressions_module"))
|
||||||
|
|
||||||
(use-modules (gnucash engine))
|
(use-modules (gnucash engine))
|
||||||
(use-modules (gnucash utilities))
|
(use-modules (gnucash utilities))
|
||||||
|
@ -61,7 +61,7 @@
|
|||||||
(use-modules (gnucash core-utils))
|
(use-modules (gnucash core-utils))
|
||||||
(use-modules (gnucash app-utils))
|
(use-modules (gnucash app-utils))
|
||||||
(use-modules (gnucash report))
|
(use-modules (gnucash report))
|
||||||
|
(use-modules (sw_expressions))
|
||||||
;; account summary report prints a table of account information,
|
;; account summary report prints a table of account information,
|
||||||
;; optionally with clickable links to open the corresponding register
|
;; optionally with clickable links to open the corresponding register
|
||||||
;; window.
|
;; window.
|
||||||
|
@ -7,10 +7,6 @@ include (GncFindLibm)
|
|||||||
# Build the library
|
# Build the library
|
||||||
|
|
||||||
set (app_utils_noinst_HEADERS
|
set (app_utils_noinst_HEADERS
|
||||||
calculation/finvar.h
|
|
||||||
calculation/finproto.h
|
|
||||||
calculation/fin_spl_protos.h
|
|
||||||
calculation/fin_static_proto.h
|
|
||||||
gnc-option-date.hpp
|
gnc-option-date.hpp
|
||||||
gnc-option-impl.hpp
|
gnc-option-impl.hpp
|
||||||
gnc-option-ui.hpp
|
gnc-option-ui.hpp
|
||||||
@ -28,7 +24,6 @@ set (app_utils_HEADERS
|
|||||||
gnc-addr-quickfill.h
|
gnc-addr-quickfill.h
|
||||||
gnc-entry-quickfill.h
|
gnc-entry-quickfill.h
|
||||||
gnc-euro.h
|
gnc-euro.h
|
||||||
gnc-exp-parser.h
|
|
||||||
gnc-gsettings.h
|
gnc-gsettings.h
|
||||||
gnc-help-utils.h
|
gnc-help-utils.h
|
||||||
gnc-helpers.h
|
gnc-helpers.h
|
||||||
@ -37,7 +32,6 @@ set (app_utils_HEADERS
|
|||||||
gnc-optiondb.hpp
|
gnc-optiondb.hpp
|
||||||
gnc-prefs-utils.h
|
gnc-prefs-utils.h
|
||||||
gnc-state.h
|
gnc-state.h
|
||||||
gnc-sx-instance-model.h
|
|
||||||
gnc-ui-util.h
|
gnc-ui-util.h
|
||||||
gnc-ui-balances.h
|
gnc-ui-balances.h
|
||||||
)
|
)
|
||||||
@ -60,8 +54,6 @@ gnc_add_swig_python_command (swig-app-utils-python
|
|||||||
)
|
)
|
||||||
|
|
||||||
set (app_utils_SOURCES
|
set (app_utils_SOURCES
|
||||||
calculation/expression_parser.c
|
|
||||||
calculation/fin.c
|
|
||||||
QuickFill.c
|
QuickFill.c
|
||||||
file-utils.c
|
file-utils.c
|
||||||
gfec.c
|
gfec.c
|
||||||
@ -70,7 +62,6 @@ set (app_utils_SOURCES
|
|||||||
gnc-addr-quickfill.c
|
gnc-addr-quickfill.c
|
||||||
gnc-entry-quickfill.c
|
gnc-entry-quickfill.c
|
||||||
gnc-euro.c
|
gnc-euro.c
|
||||||
gnc-exp-parser.c
|
|
||||||
gnc-gsettings.cpp
|
gnc-gsettings.cpp
|
||||||
gnc-helpers.c
|
gnc-helpers.c
|
||||||
gnc-option-date.cpp
|
gnc-option-date.cpp
|
||||||
@ -78,7 +69,6 @@ set (app_utils_SOURCES
|
|||||||
gnc-option-impl.cpp
|
gnc-option-impl.cpp
|
||||||
gnc-optiondb.cpp
|
gnc-optiondb.cpp
|
||||||
gnc-prefs-utils.c
|
gnc-prefs-utils.c
|
||||||
gnc-sx-instance-model.c
|
|
||||||
gnc-state.c
|
gnc-state.c
|
||||||
gnc-ui-util.c
|
gnc-ui-util.c
|
||||||
gnc-ui-balances.c
|
gnc-ui-balances.c
|
||||||
@ -175,16 +165,95 @@ if (WITH_PYTHON)
|
|||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(expressions_SOURCES
|
||||||
|
calculation/expression_parser.c
|
||||||
|
calculation/fin.c
|
||||||
|
gnc-exp-parser.c
|
||||||
|
gnc-sx-instance-model.c
|
||||||
|
)
|
||||||
|
|
||||||
|
set(expressions_noinstall_HEADERS
|
||||||
|
calculation/finvar.h
|
||||||
|
calculation/finproto.h
|
||||||
|
calculation/fin_spl_protos.h
|
||||||
|
calculation/fin_static_proto.h
|
||||||
|
)
|
||||||
|
set(expressions_HEADERS
|
||||||
|
gnc-exp-parser.h
|
||||||
|
gnc-sx-instance-model.h
|
||||||
|
)
|
||||||
|
|
||||||
install(FILES ${app_utils_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gnucash)
|
set(expressions_all_sources ${expressions_SOURCES} ${expressions_noinstall_HEADERS} ${expressions_HEADERS})
|
||||||
|
|
||||||
|
set_source_files_properties(${expressions_SOURCES} PROPERTIES OBJECT_DEPENDS ${CONFIG_H})
|
||||||
|
add_library(gnc-expressions
|
||||||
|
${expressions_HEADERS}
|
||||||
|
${expressions_SOURCES}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(gnc-expressions
|
||||||
|
PUBLIC
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/calculation
|
||||||
|
${CMAKE_SOURCE_DIR}/bindings/guile
|
||||||
|
${CMAKE_SOURCE_DIR}/libgnucash/app-utils
|
||||||
|
${GUILE_INCLUDE_DIRS}
|
||||||
|
${GLIB2_INCLUDE_DIRS}
|
||||||
|
PRIVATE
|
||||||
|
${CMAKE_SOURCE_DIR}/common
|
||||||
|
${CMAKE_BINARY_DIR}/common)
|
||||||
|
|
||||||
|
target_link_libraries(gnc-expressions
|
||||||
|
PUBLIC
|
||||||
|
gnc-engine
|
||||||
|
gnucash-guile
|
||||||
|
gnc-app-utils
|
||||||
|
${GUILE_LDFLAGS}
|
||||||
|
${GLIB2_LDFLAGS})
|
||||||
|
|
||||||
|
install(TARGETS gnc-expressions
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
#Generate the swig-expressions-guile.c wrapper file
|
||||||
|
gnc_add_swig_guile_command(swig-expressions-guile-c #target
|
||||||
|
SWIG_EXPRESSIONS_GUILE_C swig-expressions-guile.c #outvar, output
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/expressions.i #input
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_SOURCE_DIR}/libgnucash/app-utils;${CMAKE_SOURCE_DIR}/libgnucash/expressions" #includes
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(gnc-expressions-guile SHARED
|
||||||
|
${SWIG_EXPRESSIONS_GUILE_C})
|
||||||
|
|
||||||
|
target_include_directories(gnc-expressions-guile
|
||||||
|
PUBLIC
|
||||||
|
${CMAKE_SOURCE_DIR}/libgnucash/expressions
|
||||||
|
${GUILE_INCLUDE_DIRS}
|
||||||
|
${GLIB2_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
target_link_libraries(gnc-expressions-guile
|
||||||
|
gnc-expressions
|
||||||
|
gnc-engine
|
||||||
|
gnc-app-utils
|
||||||
|
${GUILE_LDFLAGS}
|
||||||
|
${GLIB2_LDFLAGS})
|
||||||
|
|
||||||
|
install(TARGETS gnc-expressions-guile
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
install(FILES ${app_utils_HEADERS} ${expressions_HEADERS}
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gnucash)
|
||||||
|
|
||||||
# And now handle scheme files
|
# And now handle scheme files
|
||||||
|
|
||||||
set (app_utils_SCHEME_1
|
set (app_utils_SCHEME_1
|
||||||
c-interface.scm
|
c-interface.scm
|
||||||
date-utilities.scm
|
date-utilities.scm
|
||||||
fin.scm
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set (app_utils_SCHEME_1a
|
set (app_utils_SCHEME_1a
|
||||||
@ -220,6 +289,18 @@ gnc_add_scheme_targets(scm-app-utils-2
|
|||||||
|
|
||||||
add_custom_target(scm-app-utils ALL DEPENDS scm-app-utils-2 scm-app-utils-1)
|
add_custom_target(scm-app-utils ALL DEPENDS scm-app-utils-2 scm-app-utils-1)
|
||||||
|
|
||||||
|
set(expressions_SCHEME
|
||||||
|
fin.scm)
|
||||||
|
|
||||||
|
set(GUILE_INTERNAL_DEPENDS
|
||||||
|
scm-app-utils-1)
|
||||||
|
|
||||||
|
gnc_add_scheme_targets(scm-expressions
|
||||||
|
SOURCES "${expressions_SCHEME}"
|
||||||
|
OUTPUT_DIR "gnucash/app-utils"
|
||||||
|
DEPENDS "${GUILE_INTERNAL_DEPENDS}"
|
||||||
|
MAKE_LINKS)
|
||||||
|
|
||||||
set_local_dist(app_utils_DIST_local
|
set_local_dist(app_utils_DIST_local
|
||||||
${app_utils_ALL_SOURCES}
|
${app_utils_ALL_SOURCES}
|
||||||
${app_utils_SCHEME_1}
|
${app_utils_SCHEME_1}
|
||||||
@ -228,7 +309,9 @@ set_local_dist(app_utils_DIST_local
|
|||||||
${app_utils_SCHEME_1c}
|
${app_utils_SCHEME_1c}
|
||||||
${app_utils_SCHEME_2}
|
${app_utils_SCHEME_2}
|
||||||
${app_utils_SCHEME_3}
|
${app_utils_SCHEME_3}
|
||||||
app-utils.i gnc-optiondb.i CMakeLists.txt gnc-help-utils.c)
|
${expressions_all_sources}
|
||||||
|
${expressions_SCHEME}
|
||||||
|
app-utils.i gnc-optiondb.i expressions.i CMakeLists.txt gnc-help-utils.c)
|
||||||
|
|
||||||
set(app_utils_DIST
|
set(app_utils_DIST
|
||||||
${app_utils_DIST_local}
|
${app_utils_DIST_local}
|
||||||
|
@ -28,13 +28,11 @@ extern "C"
|
|||||||
#endif
|
#endif
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <gnc-euro.h>
|
#include <gnc-euro.h>
|
||||||
#include <gnc-exp-parser.h>
|
|
||||||
#include <gnc-ui-util.h>
|
#include <gnc-ui-util.h>
|
||||||
#include <gnc-prefs-utils.h>
|
#include <gnc-prefs-utils.h>
|
||||||
#include <gnc-helpers.h>
|
#include <gnc-helpers.h>
|
||||||
#include <gnc-accounting-period.h>
|
#include <gnc-accounting-period.h>
|
||||||
#include <gnc-session.h>
|
#include <gnc-session.h>
|
||||||
#include <gnc-sx-instance-model.h>
|
|
||||||
|
|
||||||
#include "gnc-engine-guile.h"
|
#include "gnc-engine-guile.h"
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -119,23 +117,4 @@ gnc_numeric gnc_convert_from_euro(const gnc_commodity * currency,
|
|||||||
time64 gnc_accounting_period_fiscal_start(void);
|
time64 gnc_accounting_period_fiscal_start(void);
|
||||||
time64 gnc_accounting_period_fiscal_end(void);
|
time64 gnc_accounting_period_fiscal_end(void);
|
||||||
|
|
||||||
%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 *;
|
|
||||||
#endif
|
#endif
|
||||||
|
74
libgnucash/app-utils/expressions.i
Normal file
74
libgnucash/app-utils/expressions.i
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/********************************************************************\
|
||||||
|
* This program is free software; you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation; either version 2 of *
|
||||||
|
* the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License*
|
||||||
|
* along with this program; if not, contact: *
|
||||||
|
* *
|
||||||
|
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||||
|
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||||
|
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||||
|
* *
|
||||||
|
\********************************************************************/
|
||||||
|
|
||||||
|
%module sw_expressions
|
||||||
|
%{
|
||||||
|
#include <gnc-sx-instance-model.h>
|
||||||
|
|
||||||
|
SCM scm_init_sw_expressions_module (void);
|
||||||
|
|
||||||
|
static GDate
|
||||||
|
gnc_time64_to_GDate(SCM x)
|
||||||
|
{
|
||||||
|
time64 time = scm_to_int64 (x);
|
||||||
|
return time64_to_gdate(time);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static SCM
|
||||||
|
gnc_guid2scm(GncGUID guid)
|
||||||
|
{
|
||||||
|
char string[GUID_ENCODING_LENGTH + 1];
|
||||||
|
|
||||||
|
if (!guid_to_string_buff(&guid, string))
|
||||||
|
return SCM_BOOL_F;
|
||||||
|
|
||||||
|
return scm_from_utf8_string(string);
|
||||||
|
}
|
||||||
|
|
||||||
|
static SCM
|
||||||
|
gnc_numeric_to_scm(gnc_numeric arg)
|
||||||
|
{
|
||||||
|
return gnc_numeric_check (arg) ? SCM_BOOL_F :
|
||||||
|
scm_divide (scm_from_int64 (arg.num), scm_from_int64 (arg.denom));
|
||||||
|
}
|
||||||
|
%}
|
||||||
|
#include <gnc-sx-instance-model.h>
|
||||||
|
%import "base-typemaps.i"
|
||||||
|
|
||||||
|
%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 *;
|
@ -10,7 +10,13 @@ set(APP_UTILS_TEST_INCLUDE_DIRS
|
|||||||
${GUILE_INCLUDE_DIRS}
|
${GUILE_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
|
||||||
set(APP_UTILS_TEST_LIBS gnc-app-utils gnc-test-engine test-core ${GIO_LDFLAGS} ${GUILE_LDFLAGS})
|
set(APP_UTILS_TEST_LIBS
|
||||||
|
gnc-app-utils
|
||||||
|
gnc-expressions
|
||||||
|
gnc-test-engine
|
||||||
|
test-core
|
||||||
|
${GIO_LDFLAGS}
|
||||||
|
${GUILE_LDFLAGS})
|
||||||
|
|
||||||
macro(add_app_utils_test _TARGET _SOURCE_FILES)
|
macro(add_app_utils_test _TARGET _SOURCE_FILES)
|
||||||
gnc_add_test(${_TARGET} "${_SOURCE_FILES}" APP_UTILS_TEST_INCLUDE_DIRS APP_UTILS_TEST_LIBS)
|
gnc_add_test(${_TARGET} "${_SOURCE_FILES}" APP_UTILS_TEST_INCLUDE_DIRS APP_UTILS_TEST_LIBS)
|
||||||
|
Loading…
Reference in New Issue
Block a user