diff --git a/bindings/guile/gnc-optiondb.i b/bindings/guile/gnc-optiondb.i index 9e8e8f4710..77edfaff93 100644 --- a/bindings/guile/gnc-optiondb.i +++ b/bindings/guile/gnc-optiondb.i @@ -1080,6 +1080,18 @@ wrap_unique_ptr(GncOptionDBPtr, GncOptionDB); return scm_cons(desig, scm_from_int(val)); } + static SCM + get_scm_value(const GncOptionRangeValue& option) + { + return scm_from_double(option.get_value()); + } + + static SCM + get_scm_default_value(const GncOptionRangeValue& option) + { + return scm_from_double(option.get_default_value()); + } + static SCM get_scm_value(const GncOptionDateValue& option) { @@ -1285,14 +1297,14 @@ inline SCM return_scm_value(ValueType value) is_same_decayed_v>) { - auto serial{option.serialize()}; - if (serial.empty()) + auto serial{get_scm_value(option)}; + if (serial == SCM_BOOL_F) { return no_value; } else { - auto scm_str{scm_list_1(scm_from_utf8_string(serial.c_str()))}; + auto scm_str{scm_list_1(serial)}; return scm_simple_format(SCM_BOOL_F, ticked_format_str, scm_str); } } @@ -1368,10 +1380,11 @@ inline SCM return_scm_value(ValueType value) if constexpr (is_same_decayed_v>) { - if (scm_is_pair(new_value)) - option.set_value(scm_to_int(scm_cdr(new_value))); - else - option.set_value(scm_to_int(new_value)); + auto value_num{scm_is_pair(new_value) ? scm_cdr(new_value) : new_value}; + int value_int = scm_is_exact_integer(value_num) ? + scm_to_int(value_num) : + static_cast(scm_to_double(value_num)); + option.set_value(value_int); return; } if constexpr (is_same_decayed_vnumber (GncOption-serialize option))) (gnc:generate-restore-forms odb "options")) )) (test-end "test-gnc-number-range-option-to-scheme")) @@ -460,10 +475,10 @@ veritatis et quasi architecto beatae vitae dicta sunt, explicabo.") (test-equal "number-plot unchanged" test-unchanged-section-output-template (gnc:generate-restore-forms odb "options")) (let ((option (gnc:lookup-option odb "foo" "bar")) - (test-template test-literal-output-template)) - (gnc:option-set-value option 42) + (test-template test-number-range-output-template)) + (gnc:option-set-value option 48) (test-equal "number-plot form" - (test-template (GncOption-serialize option)) + (test-template (string->number (GncOption-serialize option))) (gnc:generate-restore-forms odb "options")) )) (test-end "test-gnc-number-plot-size-option-to-scheme"))