diff --git a/libgnucash/app-utils/gnc-option-impl.cpp b/libgnucash/app-utils/gnc-option-impl.cpp index 7c4e795fc5..5a6f0e9c74 100644 --- a/libgnucash/app-utils/gnc-option-impl.cpp +++ b/libgnucash/app-utils/gnc-option-impl.cpp @@ -725,35 +725,6 @@ GncOptionValue::deserialize(const std::string& str) noexcept return true; } -template <> void -GncOptionValue::set_value(SCM new_value) -{ - if (m_value) - scm_gc_unprotect_object(m_value); - m_value = new_value; - scm_gc_protect_object(m_value); -} - -template <> void -GncOptionValue::set_default_value(SCM new_value) -{ - if (m_value) - scm_gc_unprotect_object(m_value); - if (m_default_value) - scm_gc_unprotect_object(m_default_value); - m_value = m_default_value = new_value; - scm_gc_protect_object(m_value); - scm_gc_protect_object(m_default_value); -} - -template <> void -GncOptionValue::reset_default_value() -{ - if (m_value) - scm_gc_unprotect_object(m_value); - m_value = m_default_value; - scm_gc_protect_object(m_value); -} std::string GncOptionAccountListValue::serialize() const noexcept { @@ -947,7 +918,6 @@ template GncOptionValue::GncOptionValue(const GncOptionValue&); template GncOptionValue::GncOptionValue(const GncOptionValue&); template GncOptionValue::GncOptionValue(const GncOptionValue&); template GncOptionValue::GncOptionValue(const GncOptionValue&); -template GncOptionValue::GncOptionValue(const GncOptionValue&); template void GncOptionValue::set_value(bool); template void GncOptionValue::set_value(int); template void GncOptionValue::set_value(int64_t); @@ -999,7 +969,6 @@ template std::string GncOptionValue::serialize() const noexcept; template std::string GncOptionValue::serialize() const noexcept; template std::string GncOptionValue::serialize() const noexcept; template std::string GncOptionValue::serialize() const noexcept; -template std::string GncOptionValue::serialize() const noexcept; template std::string GncOptionValue::serialize() const noexcept; template std::string GncOptionRangeValue::serialize() const noexcept; template std::string GncOptionRangeValue::serialize() const noexcept; @@ -1012,7 +981,6 @@ template bool GncOptionValue::deserialize(const std::string&) noexc template bool GncOptionValue::deserialize(const std::string&) noexcept; template bool GncOptionValue::deserialize(const std::string&) noexcept; template bool GncOptionValue::deserialize(const std::string&) noexcept; -template bool GncOptionValue::deserialize(const std::string&) noexcept; template bool GncOptionValue::deserialize(const std::string&) noexcept; template bool GncOptionRangeValue::deserialize(const std::string&) noexcept; template bool GncOptionRangeValue::deserialize(const std::string&) noexcept; diff --git a/libgnucash/app-utils/gnc-option-impl.hpp b/libgnucash/app-utils/gnc-option-impl.hpp index 6bd82dc546..d126e3ea7a 100644 --- a/libgnucash/app-utils/gnc-option-impl.hpp +++ b/libgnucash/app-utils/gnc-option-impl.hpp @@ -93,38 +93,16 @@ public: ValueType value, GncOptionUIType ui_type = GncOptionUIType::INTERNAL) : OptionClassifier{section, name, key, doc_string}, - m_ui_type(ui_type), m_value{value}, m_default_value{value} { - if constexpr(std::is_same_v, SCM>) { - if (value) { - scm_gc_protect_object(m_value); - scm_gc_protect_object(m_default_value); - } - } - } + m_ui_type(ui_type), m_value{value}, m_default_value{value} { } GncOptionValue(const GncOptionValue& from) : OptionClassifier{from.m_section, from.m_name, from.m_sort_tag, from.m_doc_string}, m_ui_type(from.get_ui_type()), m_value{from.get_value()}, - m_default_value{from.get_default_value()} - { - if constexpr(std::is_same_v, SCM>) { - if (m_value) - scm_gc_protect_object(m_value); - if (m_default_value) - scm_gc_protect_object(m_default_value); - } - } + m_default_value{from.get_default_value()}{} GncOptionValue(GncOptionValue&&) = default; GncOptionValue& operator=(const GncOptionValue&) = default; GncOptionValue& operator=(GncOptionValue&&) = default; - ~GncOptionValue() { - if constexpr(std::is_same_v, SCM>) { - if (m_value) - scm_gc_unprotect_object(m_value); - if (m_default_value) - scm_gc_unprotect_object(m_default_value); - } - } + ~GncOptionValue() = default; ValueType get_value() const { return m_value; } ValueType get_default_value() const { return m_default_value; } void set_value(ValueType new_value); @@ -297,8 +275,7 @@ template>(std::istream& iss, OptType& opt) { std::decay_t value; - if constexpr (std::is_same_v, SCM> || - std::is_same_v, const _gncOwner*> || + if constexpr (std::is_same_v, const _gncOwner*> || std::is_same_v, const _QofQuery*>) return iss; else diff --git a/libgnucash/app-utils/gnc-option.cpp b/libgnucash/app-utils/gnc-option.cpp index e69bc0c021..c113a6db6f 100644 --- a/libgnucash/app-utils/gnc-option.cpp +++ b/libgnucash/app-utils/gnc-option.cpp @@ -433,16 +433,6 @@ GncOption::in_stream(std::istream& iss) }, *m_option); } -GncOption* -gnc_make_SCM_option(const char* section, const char* name, - const char* key, const char* doc_string, - SCM value, GncOptionUIType ui_type) -{ - return new GncOption(section, name, key, doc_string, - reinterpret_cast(value), ui_type); -} - - /* We must instantiate all of the templates we need here because we don't expose * the template implementation in the public header. */ @@ -460,8 +450,6 @@ template GncOption::GncOption(const char*, const char*, const char*, // const char*, double, GncOptionUIType); template GncOption::GncOption(const char*, const char*, const char*, const char*, std::string, GncOptionUIType); -template GncOption::GncOption(const char*, const char*, const char*, - const char*, SCM, GncOptionUIType); template GncOption::GncOption(const char*, const char*, const char*, const char*, const QofQuery*, GncOptionUIType); template GncOption::GncOption(const char*, const char*, const char*, @@ -480,7 +468,6 @@ template const Account* GncOption::get_value() const; template RelativeDatePeriod GncOption::get_value() const; template GncOptionAccountList GncOption::get_value() const; template GncMultichoiceOptionIndexVec GncOption::get_value() const; -template SCM GncOption::get_value() const; template GncOptionReportPlacementVec GncOption::get_value() const; template bool GncOption::get_default_value() const; @@ -495,7 +482,6 @@ template const Account* GncOption::get_default_value() const; template RelativeDatePeriod GncOption::get_default_value() const; template GncOptionAccountList GncOption::get_default_value() const; template GncMultichoiceOptionIndexVec GncOption::get_default_value() const; -template SCM GncOption::get_default_value() const; template GncOptionReportPlacementVec GncOption::get_default_value() const; template void GncOption::set_value(bool); @@ -512,7 +498,6 @@ template void GncOption::set_value(RelativeDatePeriod); template void GncOption::set_value(size_t); template void GncOption::set_value(GncOptionAccountList); template void GncOption::set_value(GncMultichoiceOptionIndexVec); -template void GncOption::set_value(SCM); template void GncOption::set_value(GncOptionReportPlacementVec); template void GncOption::set_default_value(bool); @@ -528,7 +513,6 @@ template void GncOption::set_default_value(RelativeDatePeriod); template void GncOption::set_default_value(size_t); template void GncOption::set_default_value(GncOptionAccountList); template void GncOption::set_default_value(GncMultichoiceOptionIndexVec); -template void GncOption::set_default_value(SCM); template void GncOption::set_default_value(GncOptionReportPlacementVec); template void GncOption::get_limits(double&, double&, double&) const noexcept; diff --git a/libgnucash/app-utils/gnc-option.hpp b/libgnucash/app-utils/gnc-option.hpp index e46fa92164..9cb97acff3 100644 --- a/libgnucash/app-utils/gnc-option.hpp +++ b/libgnucash/app-utils/gnc-option.hpp @@ -104,7 +104,6 @@ using GncOptionVariant = std::variant, GncOptionQofInstanceValue, GncOptionValue, GncOptionValue, - GncOptionValue, GncOptionValue, GncOptionAccountListValue, GncOptionAccountSelValue, @@ -256,14 +255,6 @@ gnc_make_option(const char* section, const char* name, return new GncOption(section, name, key, doc_string, value, ui_type); } -/** - * Free function wrapping GncOption's constructor using an SCM value. - * To work around SWIG_Guile's typedef of SCM to unsigned long - */ -GncOption* gnc_make_SCM_option(const char* section, const char* name, - const char* key, const char* doc_string, - SCM value, GncOptionUIType ui_type); - #endif //GNC_OPTION_HPP_ /** @} diff --git a/libgnucash/app-utils/gnc-optiondb.cpp b/libgnucash/app-utils/gnc-optiondb.cpp index 9d06fb951a..b36a1ba605 100644 --- a/libgnucash/app-utils/gnc-optiondb.cpp +++ b/libgnucash/app-utils/gnc-optiondb.cpp @@ -831,16 +831,6 @@ gnc_register_owner_option(GncOptionDB* db, const char* section, db->register_option(section, std::move(option)); } -void -gnc_register_internal_option(GncOptionDB* db, const char* section, - const char* name, const char* key, - const char* doc_string, SCM value) -{ - GncOption option{section, name, key, doc_string, value, - GncOptionUIType::INTERNAL}; - db->register_option(section, std::move(option)); -} - void gnc_register_invoice_option(GncOptionDB* db, const char* section, const char* name, const char* key, @@ -1249,22 +1239,6 @@ gnc_option_db_lookup_qofinstance_value(GncOptionDB* odb, const char* section, return option->get_value(); } -SCM -gnc_option_db_lookup_scm_value(GncOptionDB* odb, const char* section, - const char* name) -{ - auto option{odb->find_option(section, name)}; - return option->get_value(); -} - -void -gnc_option_db_set_scm_value(GncOptionDB* odb, const char* section, - const char* name, SCM value) -{ - auto option{odb->find_option(section, name)}; - option->set_value(value); -} - // Force creation of templates template void gnc_register_number_range_option(GncOptionDBPtr& db, const char* section, const char* name, diff --git a/libgnucash/app-utils/gnc-optiondb.h b/libgnucash/app-utils/gnc-optiondb.h index 8078459d5d..88d12300d5 100644 --- a/libgnucash/app-utils/gnc-optiondb.h +++ b/libgnucash/app-utils/gnc-optiondb.h @@ -166,31 +166,6 @@ const QofInstance* gnc_option_db_lookup_qofinstance_value(GncOptionDB*, const char*, const char*); -/** - * Retrieve the GList* value of an option in the GncOptionDB - * - * @param odb the GncOptionDB - * @param section the section in which the option is stored - * @param name the option name - * @return the GList* of the value or nullptr if the option isn't found - * or if its value isn't a string. - */ -SCM gnc_option_db_lookup_scm_value(GncOptionDB*, const char*, const char*); - -/** - * Set the GList* value of an option in the GncOptionDB. - * - * The value will not be saved if the option is not in the GncOptionDB or if the - * type of the option isn't string or text. - * - * @param odb the GncOptionDB - * @param section the section in which the option is stored - * @param name the option name - * @param value the value to be stored in the option. - */ -void gnc_option_db_set_scm_value(GncOptionDB*, const char*, - const char*, SCM); - #ifdef __cplusplus } #endif diff --git a/libgnucash/app-utils/gnc-optiondb.hpp b/libgnucash/app-utils/gnc-optiondb.hpp index d92f145053..25920f4c2a 100644 --- a/libgnucash/app-utils/gnc-optiondb.hpp +++ b/libgnucash/app-utils/gnc-optiondb.hpp @@ -571,35 +571,6 @@ inline void gnc_register_color_option(GncOptionDBPtr& db, const char* section, gnc_register_color_option(db.get(), section, name, key, doc_string, value); } -/** - * Create a new internal string option and register it in the options database. - * - * Internal options are used for passing state data in some reports. As the name - * suggests they do not create UI elements in options dialogs. - * @param db A GncOptionDB* for calling from C. Caller retains ownership. - * @param section The database section for the option. - * @param name The option name. - * @param doc_string A description of the option. This will be used in tooltips and should be marked for translation. - * @param value The initial and default value for the option. - */ -void gnc_register_internal_option(GncOptionDB* db, const char* section, - const char* name, const char* key, - const char* doc_string, SCM value); - - -/** - * As above but takes a const GncOptionDBPtr& (const std::unique_ptr&) for calling from C++. - */ -inline void gnc_register_internal_option(GncOptionDBPtr& db, - const char* section, const char* name, - const char* key, - const char* doc_string, - SCM value) -{ - gnc_register_internal_option(db.get(), section, name, key, - doc_string, value); -} - void gnc_register_internal_option(GncOptionDBPtr& db, const char* section, const char* name, const char* key, diff --git a/libgnucash/app-utils/gnc-optiondb.i b/libgnucash/app-utils/gnc-optiondb.i index bff5ee3d41..8f696e0f08 100644 --- a/libgnucash/app-utils/gnc-optiondb.i +++ b/libgnucash/app-utils/gnc-optiondb.i @@ -1243,13 +1243,6 @@ inline SCM return_scm_value(ValueType value) return scm_simple_format(SCM_BOOL_F, plain_format_str, scm_val); } - if constexpr (is_same_decayed_v>) - { - auto scm_val{scm_list_1(return_scm_value(option.get_value()))}; - return scm_simple_format(SCM_BOOL_F, ticked_format_str, - scm_val); - } if constexpr (is_same_decayed_v>) { diff --git a/libgnucash/app-utils/options.scm b/libgnucash/app-utils/options.scm index 702fca981d..51086d6b27 100644 --- a/libgnucash/app-utils/options.scm +++ b/libgnucash/app-utils/options.scm @@ -270,8 +270,13 @@ (GncOptionUIType-INTERNAL))) ((string? default) (gnc-make-string-option section name key desc default (GncOptionUIType-INTERNAL))) + ((procedure? default) + (format #t "gnc:make-internal-option passed procedure resolving to ~a~%" (default)) + (gnc-make-bool-option section name key desc #f (GncOptionUIType-INTERNAL))) (else - (gnc-make-SCM-option section name key desc default type))))) + (format #t "gnc:make-internal-option passed something unknown that looks like ~a~%" default) + (gnc-make-bool-option section name key desc #f (GncOptionUIType-INTERNAL)))))) + (define-public (gnc:make-owner-option section name key docstring getter validator owner-type) (issue-deprecation-warning "gnc:make-owner-option is deprecated. Make and register the option in one command with gnc-register-owner-option.") (let* ((ui-type (cond