Commit Graph

40 Commits

Author SHA1 Message Date
Christopher Lam
6d7f4ec4c8 [engine.i] expose xaccAccountGetSplits in bindings
because xaccAccountGetSplitList will create GList, scan and build SCM
reverse order, and scm_reverse.

xaccAccountGetSplits scans the vector, builds the SCM list in reverse.
2024-10-27 22:22:51 +08:00
Christopher Lam
e2f5c74bb4 [engine.i] VECTORREF_HELPER_INOUT to handle SplitsVec& 2024-10-27 22:22:51 +08:00
Christopher Lam
1718fa0b6e [gnc-pricedb.h] remove unused gnc_pricedb_lookup_at_time64 2024-08-31 20:45:32 +08:00
Christopher Lam
d1807b6c15 [engine.i] move gnc_accounts_and_all_descendants to engine.i 2024-06-07 18:10:40 +08:00
Christopher Lam
4c29f69d67 [engine.i] even faster gnc_get_match_commodity_splits
gnc_get_match_commodity_splits needs to scan the account splitlists to
find suitable splits upto end_date. Because splitlist is date-sorted,
use gnc_account_foreach_split_until_date to avoid scanning later
splits.
2024-05-02 22:21:31 +08:00
Christopher Lam
68f60fef68 [engine.i] gnc_get_match_commodity_splits from scheme to c++
The scheme version is very inefficient: (1) it uses QofQuery to
retrieve all splits, and QofQuery is slow. (2) The whole splitlist
typically is thousands splits long needs to be converted from C to
guile via consing and reverse. (3) The scheme list is immediately
filtered to select "interesting" splits only.

This function performs all of the above using Account's efficient
methods, selecting only interesting splits into a GList. This list is
then converted to scheme via cons and reverse.
2024-04-22 19:34:02 +08:00
Christopher Lam
cb7196a393 [base-typemaps.i] add VECTOR_HELPER_INOUT for Split* and Account*
efficiently convert std::vector<Obj> to/from guile list of objects
2024-04-22 19:34:02 +08:00
Christopher Lam
94368f4cb4 [Account.cpp] SplitsVec&, ensure xaccAccountGetSplitList is freed 2024-04-16 21:41:48 +08:00
Richard Cohen
3c0b051ab0 Valgrind: fix "Mismatched free/delete" for gnc_print_time64, qof_print_date
... when called from guile e.g. test-transaction and lots of other tests

- gchar will also get the char* typemap, by typedef reduction

==119964== Mismatched free() / delete / delete []
==119964==    at 0x4847A1F: operator delete[](void*) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==119964==    by 0x669F3E4: _wrap_gnc_print_time64(scm_unused_struct*, scm_unused_struct*) (swig-engine.cpp:38533)
...

==119948== Mismatched free() / delete / delete []
==119948==    at 0x4847A1F: operator delete[](void*) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==119948==    by 0x6F6B431: _wrap_qof_print_date(scm_unused_struct*) (swig-engine.cpp:39124)
...
2023-06-20 10:20:44 +01:00
Richard Cohen
1cec0cb3f3 Use internal extern "C" { ... } for C++
- removes warnings compiling swig engine
...
[ 10%] Generating swig-engine.cpp
.../libgnucash/engine/engine-helpers.h:31: Warning 313: Unrecognized extern type "C++".
.../libgnucash/engine/gnc-date.h:83: Warning 313: Unrecognized extern type "C++".
.../libgnucash/engine/qofquery.h:90: Warning 302: Identifier 'QofQuery' redefined (ignored),
.../libgnucash/engine/gnc-option.hpp:55: Warning 302: previous definition of 'QofQuery'.
.../libgnucash/engine/gnc-commodity.h:56: Warning 313: Unrecognized extern type "C++".
.../libgnucash/engine/gncBusiness.h:40: Warning 313: Unrecognized extern type "C++".
.../libgnucash/engine/gncEntry.h:37: Warning 313: Unrecognized extern type "C++".
2023-01-23 18:40:01 +00:00
John Ralls
61673ec919 [c++ options] Rearrange header includes to avoid windows.h conflicts.
Since SWIG guile pulls in libguile early the options headers must
be included in a begin block.
2023-01-08 16:09:32 -08:00
Christopher Lam
bfc325f63c Merge branch 'maint' 2022-11-27 16:12:46 +08:00
Christopher Lam
3d8a28898d [gnc-budget] gnc_budget_get_account_period_note returns a const
to harmonize with all other char getters
2022-11-19 10:35:49 +08:00
Geert Janssens
7765e13704 Bindings - move log wrappers into the swig interface files
They are only used for guile (and possibly python, so there's
no need to carry them around in core-utils.
2022-10-02 11:50:26 -07:00
Geert Janssens
e5c6f6026b Remove support code that was only used by price-quotes.scm 2022-10-02 11:50:26 -07:00
John Ralls
4ae17d12c7 [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.
2022-08-25 22:09:56 -07:00
John Ralls
cf5da9fffd Resolve merge conflicts. 2021-11-12 19:56:29 -08:00
Christopher Lam
171ce9413b Don't g_strdup char* returned by scm_to_locale_string
Previous code was returning a duplicated string and released the
original one. It's no better than returning the original returned
char* instead.
2021-10-16 22:50:09 +08:00
Christopher Lam
19a91f041e Revert "g_list_free swigged GList* arguments"
This reverts commit 16184daf95. Was
causing an unexplained GNC_IS_ACCOUNT assertion failure in
account_foreach_descendant.
2021-10-16 22:49:05 +08:00
Christopher Lam
16184daf95 g_list_free swigged GList* arguments
used by xaccQueryAddAccountMatch and gnc_price_list_equal. SplitList
TransList LotList and CommodityList are not currently being passed as
arguments.
2021-10-16 12:57:03 +08:00
Christopher Lam
d0f7daf4cf Revert "[engine.i] QofQueryParamList * args must be freed"
This reverts commit 72a3ebbba3. Freeing
does not apply to all qof_query_* calls.
2021-09-11 15:45:32 +08:00
Christopher Lam
72a3ebbba3 [engine.i] QofQueryParamList * args must be freed 2021-09-11 14:59:18 +08:00
Christopher Lam
37cb886de5 [engine.i] gnc_budget_get_account_period_note to be freed by the caller
amendment to last commit.

this pair of changes was necessary to allow the GValue to be unset.
2021-08-25 09:17:25 +08:00
Christopher Lam
929cb3d0c1 [engine.i] free swigged GList* arg 2021-08-24 00:13:45 +08:00
Christopher Lam
9bc44c62e6 [engine.i] free GSList* key_path arg to qof_book_get_option
Addendum to 6c8af6aab need to specify exact typemap target.
2021-08-20 17:01:42 +08:00
Christopher Lam
6c8af6aab1 [engine.i] free GSList* arg to qof_book_get_option 2021-08-20 09:03:37 +08:00
Christopher Lam
de1ad9367a g_free gnc_ctime which returns a new gchar* 2021-08-05 21:42:31 +08:00
Christopher Lam
e0d953bfc8 [swig] %newobject to g_free gchar* functions 2021-08-03 12:14:12 +08:00
Christopher Lam
9767c86337 [engine.i] some GLists must be freed 2021-07-29 23:56:10 +08:00
John Ralls
81c5ac6689 Remove the incomplete book-currency code.
Not everything from the 6 Book-Currency commits is removed: Switching
the Num and split-action fields and restricting edits of transactions
older than n days were included and those changes are left in place.

Some other partly-implemented features were also part of these commits
and were removed: Options for setting a default capital gains account
and currency, completion of the LIFO cap-gains policy, and creation of
a list of cap-gains policies.

If any of these are to be revived they should each be done in a separate
feature branch and submitted via Github pull request for a code review
before merging; a design discussion on gnucash-devel before restarting
work is also advisable.
2021-07-10 17:29:11 -07:00
Dong Lin
75209c024f Update price database for imported transactions
When a transaction is added from the ledger, price database is updated properly.
But if the transaction is imported, there is no price db update.

This change adds the proper pricedb update in the import path (qfx/ofx/qif).
Tested with make check
2021-03-09 10:39:56 -08:00
Christopher Lam
0d10d1e234 [engine.i] swigify CLEARED-ALL
to be used by trep-engine.scm
2020-09-15 18:30:24 +08:00
John Ralls
8ff5af4c19 Decouple QofBook creation from QofSession.
So that we don't create two books when loading a session.
Step 1 to not having a dirty book when we think we should have no
book at all.
2020-05-08 15:59:41 -07:00
Geert Janssens
45cfb8937a Merge branch 'maint'
Resolves most merge conflicts. The only bit I was unable
to merge from maint into master is the use of match-lambda
in category-barchart.scm. This will have to be redone manually.
2020-01-14 19:56:35 +01:00
Geert Janssens
6a3505d01f app-utils - move price-quotes support functions directly into bindings
- wrappers for glib functions go into glib-guile
- engine convenience functions go into gnc-engine-guile
2019-12-06 19:59:12 +01:00
Geert Janssens
2e1b9f937b engine - drop guile wrappers for obsolete functions
These were marked deprecated early in the 3.x release cycle.
2019-12-06 19:59:11 +01:00
Geert Janssens
c46c9682eb engine/test - move guile related tests to bindings 2019-12-06 19:59:11 +01:00
Geert Janssens
02511401b7 bindings/guile cosmetic - rename source files for consistency 2019-12-06 19:59:11 +01:00
Geert Janssens
3d4cc63d73 bindings - ensure engine is initialized before any scm code interfaces with it
This is done by invoking gnc_engine_init in the swig initialization routine
2019-12-06 19:59:11 +01:00
Geert Janssens
1c7f835f47 engine - move guile code to bindings/guile
This commit tries to do the minimum necessary to move the guile bits from engine
to bindings/guile. As engine is a very central piece in the software, this unfortunately
still touches many other source files:

- A few helper objects have been squashed together:
  * engine-helpers-guile.[ch] (of which the c part is extracted from engine-helpers.c)
  * gncBusGuile.[ch]
  * gnc-hooks-scm.[ch]
- The initialization function of gncmod-engine no longer initializes the scm bits.
  Any scm code that wants to interact with the engine code now has to load
  the (gnucash engine) scm module, or sometimes (gnucash business-core).
  The bulk of changes in this commit actually is updating all the scm consumers to do so.
- scm-scm target has been removed. Instead (gnucash utilities) is part
  of scm-engine. A few dependency graphs have been updated for this.

More refinements will be in followup commits.
2019-12-06 19:59:11 +01:00