Many Python binding methods silently returned raw SwigPyObject pointers
instead of proper Python wrapper objects because the methods_return_instance
dicts were incomplete. This adds the missing entries and activates the
DeprecationWarning in the SWIG typemap fallback path from PR 1.
Return-type wrapping fixes (gnucash_core.py):
GncPrice (new dict — no wrapping existed before):
get_commodity → GncCommodity, get_currency → GncCommodity,
clone → GncPrice, get_value → GncNumeric
GncPriceDB (added to existing dict):
nth_price → GncPrice, lookup_day_t64 → GncPrice,
convert_balance_nearest_before_price_t64 → GncNumeric
GncPriceDB (new list wrapping):
lookup_latest_any_currency → list[GncPrice],
lookup_nearest_before_any_currency_t64 → list[GncPrice],
lookup_nearest_in_time_any_currency_t64 → list[GncPrice]
GncCommodity: obtain_twin → GncCommodity,
get_namespace_ds → GncCommodityNamespace
Account: get_currency_or_parent → GncCommodity,
GetLotList → list[GncLot]
GncLot: get_split_list → list[Split]
Example script cleanup:
Remove type(x).__name__ == 'SwigPyObject' workarounds from
gnc_convenience.py, gncinvoicefkt.py, str_methods.py — these are
no longer needed now that methods return proper wrapper objects.
SWIG typemap (gnucash_core.i):
Activate DeprecationWarning on the .instance fallback path, replacing
the TODO placeholder from the typemap compatibility layer commit.
New test file (test_price_and_wrapping.py):
18 tests covering all wrapping fixes and typemap compatibility,
using in-repo test data (pricedb1.gml2, sample1.gnucash).
Tests auto-skip when XML backend is unavailable.
Add GNC_ACCEPT_WRAPPER macro that generates %typemap(in) entries for
all core engine and business pointer types. These typemaps accept both
raw SWIG pointers (zero-overhead fast path) and ClassFromFunctions
wrapper objects (fallback path that extracts .instance).
This is pure infrastructure for an upcoming change that fixes missing
return-type wrapping in gnucash_core.py. Once methods like
GncPriceDB.nth_price() return proper GncPrice wrapper objects instead
of raw SwigPyObjects, existing code that passes those objects to
gnucash_core_c C functions would break. These typemaps prevent that
breakage: the C functions transparently unwrap the .instance pointer.
Covered types:
Core: Account, Split, Transaction, GNCLot, gnc_commodity,
gnc_commodity_namespace, gnc_commodity_table, GNCPrice,
GNCPriceDB, QofBook, QofSession, GncGUID
Business: GncCustomer, GncEmployee, GncVendor, GncJob,
GncAddress, GncBillTerm, GncTaxTable, GncInvoice, GncEntry
GncOwner is excluded — it has its own custom type-dispatching typemaps.
This also drops the python wrapper for gnc-module. As for the guile wrappers,
python should use other means of loading our shared libraries.
This commit required a few tweaks to the dependency chain as some units
inherited dependency information from gnc-module's public dependency
interface.
This will avoid a ninja-build from picking up a config.h generated by the autotools build
(in the root build directory). Picking up the wrong config.h may lead to all kinds of
subtle issues if the autotools run was done with different options than the cmake run.
It is split into
- /libgnucash (for the non-gui bits)
- /gnucash (for the gui)
- /common (misc source files used by both)
- /bindings (currently only holds python bindings)
This is the first step in restructuring the code. It will need much
more fine tuning later on.