gnucash stable: Multiple changes pushed
Christopher Lam
clam at code.gnucash.org
Fri Jul 26 21:15:27 EDT 2024
Updated via https://github.com/Gnucash/gnucash/commit/664b1cb7 (commit)
via https://github.com/Gnucash/gnucash/commit/3e5d6a51 (commit)
from https://github.com/Gnucash/gnucash/commit/3312b5fe (commit)
commit 664b1cb77a80001197851d980b5cff1bc9e9218d
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Jul 27 07:43:37 2024 +0800
[gnc-optiondb.i] instead of scm_list_ref, walk the list
diff --git a/bindings/guile/gnc-optiondb.i b/bindings/guile/gnc-optiondb.i
index 9974fe6f44..3f69876a19 100644
--- a/bindings/guile/gnc-optiondb.i
+++ b/bindings/guile/gnc-optiondb.i
@@ -594,10 +594,9 @@ gnc_option_test_book_destroy(QofBook* book)
%typemap(in) RelativeDatePeriodVec& (RelativeDatePeriodVec period_set)
{
- auto len = scm_is_true($input) ? scm_to_size_t(scm_length($input)) : 0;
- for (std::size_t i = 0; i < len; ++i)
+ for (SCM node = $input; !scm_is_null (node); node = scm_cdr (node))
{
- SCM s_reldateperiod = scm_list_ref($input, scm_from_size_t(i));
+ SCM s_reldateperiod = scm_car (node);
period_set.push_back(scm_relative_date_get_period(s_reldateperiod));
}
$1 = &period_set;
@@ -607,10 +606,9 @@ gnc_option_test_book_destroy(QofBook* book)
{
if (scm_is_true($input))
{
- auto len{scm_to_size_t(scm_length($input))};
- for (std::size_t i = 0; i < len; ++i)
+ for (SCM node = $input; !scm_is_null (node); node = scm_cdr (node))
{
- auto val{scm_list_ref($input, scm_from_size_t(i))};
+ auto val{scm_car (node)};
if (scm_is_unsigned_integer(val, 0, UINT_MAX))
indexes.push_back(scm_to_unsigned_integer(val, 0, UINT_MAX));
}
@@ -621,10 +619,9 @@ gnc_option_test_book_destroy(QofBook* book)
%typemap(in) GncMultichoiceOptionChoices&& (GncMultichoiceOptionChoices choices)
{
using KeyType = GncOptionMultichoiceKeyType;
- auto len = scm_is_true($input) ? scm_to_size_t(scm_length($input)) : 0;
- for (std::size_t i = 0; i < len; ++i)
+ for (SCM node = $input; !scm_is_null (node); node = scm_cdr (node))
{
- SCM vec = scm_list_ref($input, scm_from_size_t(i));
+ SCM vec = scm_car (node);
SCM keyval, v_ref_0 = SCM_SIMPLE_VECTOR_REF(vec, 0);
GncOptionMultichoiceKeyType keytype;
if (scm_is_symbol(v_ref_0))
@@ -656,10 +653,9 @@ gnc_option_test_book_destroy(QofBook* book)
%typemap(in) GncOptionAccountList
{
- auto len = scm_is_true($input) ? scm_to_size_t(scm_length($input)) : 0;
- for (std::size_t i = 0; i < len; ++i)
+ for (SCM node = $input; !scm_is_null (node); node = scm_cdr (node))
{
- SCM s_account = scm_list_ref($input, scm_from_size_t(i));
+ SCM s_account = scm_car (node);
Account* acct = (Account*)SWIG_MustGetPtr(s_account,
SWIGTYPE_p_Account, 1, 0);
if (GNC_IS_ACCOUNT(acct))
@@ -669,10 +665,9 @@ gnc_option_test_book_destroy(QofBook* book)
%typemap(in) GncOptionAccountTypeList& (GncOptionAccountTypeList types)
{
- auto len = scm_is_true($input) ? scm_to_size_t(scm_length($input)) : 0;
- for (std::size_t i = 0; i < len; ++i)
+ for (SCM node = $input; !scm_is_null (node); node = scm_cdr (node))
{
- SCM s_type = scm_list_ref($input, scm_from_size_t(i));
+ SCM s_type = scm_car (node);
GNCAccountType type = (GNCAccountType)scm_to_int(s_type);
types.push_back(type);
}
@@ -681,10 +676,9 @@ gnc_option_test_book_destroy(QofBook* book)
%typemap(in) GncOptionAccountTypeList&& (GncOptionAccountTypeList types)
{
- auto len = scm_is_true($input) ? scm_to_size_t(scm_length($input)) : 0;
- for (std::size_t i = 0; i < len; ++i)
+ for (SCM node = $input; !scm_is_null (node); node = scm_cdr (node))
{
- SCM s_type = scm_list_ref($input, scm_from_size_t(i));
+ SCM s_type = scm_car (node);
GNCAccountType type = (GNCAccountType)scm_to_int(s_type);
types.push_back(type);
}
@@ -693,10 +687,9 @@ gnc_option_test_book_destroy(QofBook* book)
%typemap(in) GncOptionAccountList const & (GncOptionAccountList alist)
{
- auto len = scm_is_true($input) ? scm_to_size_t(scm_length($input)) : 0;
- for (std::size_t i = 0; i < len; ++i)
+ for (SCM node = $input; !scm_is_null (node); node = scm_cdr (node))
{
- SCM s_account = scm_list_ref($input, scm_from_size_t(i));
+ SCM s_account = scm_car (node);
Account* acct = (Account*)SWIG_MustGetPtr(s_account,
SWIGTYPE_p_Account, 1, 0);
if (GNC_IS_ACCOUNT(acct))
@@ -709,9 +702,9 @@ gnc_option_test_book_destroy(QofBook* book)
{
auto len = scm_is_true($input) ? scm_to_size_t(scm_length($input)) : 0;
acclist.reserve(len);
- for (std::size_t i = 0; i < len; ++i)
+ for (SCM node = $input; !scm_is_null (node); node = scm_cdr (node))
{
- SCM s_account = scm_list_ref($input, scm_from_size_t(i));
+ SCM s_account = scm_car (node);
Account* acct = (Account*)SWIG_MustGetPtr(s_account,
SWIGTYPE_p_Account, 1, 0);
if (!GNC_IS_ACCOUNT(acct)) continue;
@@ -1019,10 +1012,9 @@ wrap_unique_ptr(GncOptionDBPtr, GncOptionDB);
{
if (!choice_is_list)
throw std::invalid_argument{"Attempt to set multichoice with a list of values."};
- auto len{scm_to_size_t(scm_length(new_value))};
- for (std::size_t i = 0; i < len; ++i)
+ for (SCM node = new_value; !scm_is_null (node); node = scm_cdr (node))
{
- auto item{scm_list_ref(new_value, scm_from_size_t(i))};
+ auto item{scm_car (node)};
auto item_str{scm_to_str(item)};
auto index{option.permissible_value_index(item_str)};
free (item_str);
commit 3e5d6a510b41c741aad55d5f28f9b437c9962af3
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Fri Jul 26 20:20:42 2024 +0800
[gnc-optiondb.i] don't add null accounts
diff --git a/bindings/guile/gnc-optiondb.i b/bindings/guile/gnc-optiondb.i
index c2ac2e432a..9974fe6f44 100644
--- a/bindings/guile/gnc-optiondb.i
+++ b/bindings/guile/gnc-optiondb.i
@@ -294,6 +294,7 @@ scm_from_value<GncOptionAccountList>(GncOptionAccountList value)
for (auto guid : value)
{
auto acct{xaccAccountLookup(&guid, book)};
+ if (!GNC_IS_ACCOUNT(acct)) continue;
s_list = scm_cons(SWIG_NewPointerObj(acct, SWIGTYPE_p_Account, 0),
s_list);
}
@@ -661,7 +662,7 @@ gnc_option_test_book_destroy(QofBook* book)
SCM s_account = scm_list_ref($input, scm_from_size_t(i));
Account* acct = (Account*)SWIG_MustGetPtr(s_account,
SWIGTYPE_p_Account, 1, 0);
- if (acct)
+ if (GNC_IS_ACCOUNT(acct))
$1.push_back(*qof_entity_get_guid(acct));
}
}
@@ -698,7 +699,7 @@ gnc_option_test_book_destroy(QofBook* book)
SCM s_account = scm_list_ref($input, scm_from_size_t(i));
Account* acct = (Account*)SWIG_MustGetPtr(s_account,
SWIGTYPE_p_Account, 1, 0);
- if (acct)
+ if (GNC_IS_ACCOUNT(acct))
alist.push_back(*qof_entity_get_guid(acct));
}
$1 = &alist;
@@ -713,6 +714,7 @@ gnc_option_test_book_destroy(QofBook* book)
SCM s_account = scm_list_ref($input, scm_from_size_t(i));
Account* acct = (Account*)SWIG_MustGetPtr(s_account,
SWIGTYPE_p_Account, 1, 0);
+ if (!GNC_IS_ACCOUNT(acct)) continue;
acclist.push_back(*qof_entity_get_guid(acct));
}
$1 = &acclist;
@@ -731,6 +733,7 @@ gnc_option_test_book_destroy(QofBook* book)
for (auto guid : $1)
{
auto acct{xaccAccountLookup(&guid, book)};
+ if (!GNC_IS_ACCOUNT(acct)) continue;
$result = scm_cons(SWIG_NewPointerObj(acct, SWIGTYPE_p_Account, 0),
$result);
}
@@ -744,6 +747,7 @@ gnc_option_test_book_destroy(QofBook* book)
for (auto guid : *$1)
{
auto acct{xaccAccountLookup(&guid, book)};
+ if (!GNC_IS_ACCOUNT(acct)) continue;
$result = scm_cons(SWIG_NewPointerObj(acct, SWIGTYPE_p_Account, 0),
$result);
}
Summary of changes:
bindings/guile/gnc-optiondb.i | 52 ++++++++++++++++++++-----------------------
1 file changed, 24 insertions(+), 28 deletions(-)
More information about the gnucash-changes
mailing list