From bf5d1537a21647631d4ecbd9e5a13be81957a04f Mon Sep 17 00:00:00 2001 From: "Hanna K." Date: Sat, 29 Jun 2024 07:02:06 +0200 Subject: [PATCH] Fix binary compatibility with previous versions --- libqalculate/Function.cc | 1 - libqalculate/Function.h | 1 - libqalculate/MathStructure.cc | 7 +++++-- libqalculate/Variable.cc | 1 - libqalculate/Variable.h | 3 --- 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/libqalculate/Function.cc b/libqalculate/Function.cc index 2f1caa1e..c5d03a43 100644 --- a/libqalculate/Function.cc +++ b/libqalculate/Function.cc @@ -788,7 +788,6 @@ bool MathFunction::representsNumber(const MathStructure &vargs, bool allow_units bool MathFunction::representsRational(const MathStructure &vargs, bool allow_units) const {return representsInteger(vargs, allow_units);} bool MathFunction::representsNonComplex(const MathStructure &vargs, bool allow_units) const {return representsReal(vargs, allow_units);} bool MathFunction::representsReal(const MathStructure &vargs, bool allow_units) const {return representsRational(vargs, allow_units);} -bool MathFunction::representsFinite(const MathStructure &vargs, bool allow_units) const {return representsReal(vargs, allow_units);} bool MathFunction::representsComplex(const MathStructure&, bool) const {return false;} bool MathFunction::representsNonZero(const MathStructure &vargs, bool allow_units) const {return representsPositive(vargs, allow_units) || representsNegative(vargs, allow_units);} bool MathFunction::representsEven(const MathStructure&, bool) const {return false;} diff --git a/libqalculate/Function.h b/libqalculate/Function.h index 26a797d6..2f8f2d8d 100644 --- a/libqalculate/Function.h +++ b/libqalculate/Function.h @@ -197,7 +197,6 @@ class MathFunction : public ExpressionItem { virtual bool representsRational(const MathStructure&, bool = false) const; virtual bool representsNonComplex(const MathStructure&, bool = false) const; virtual bool representsReal(const MathStructure&, bool = false) const; - virtual bool representsFinite(const MathStructure&, bool = false) const; virtual bool representsComplex(const MathStructure&, bool = false) const; virtual bool representsNonZero(const MathStructure&, bool = false) const; virtual bool representsEven(const MathStructure&, bool = false) const; diff --git a/libqalculate/MathStructure.cc b/libqalculate/MathStructure.cc index 5b10e68b..254dbc1f 100644 --- a/libqalculate/MathStructure.cc +++ b/libqalculate/MathStructure.cc @@ -1045,11 +1045,14 @@ bool MathStructure::representsReal(bool allow_units) const { bool MathStructure::representsFinite(bool allow_units) const { switch(m_type) { case STRUCT_NUMBER: {return !o_number.includesInfinity();} - case STRUCT_VARIABLE: {return o_variable->representsFinite(allow_units);} + case STRUCT_VARIABLE: { + if(o_variable->isKnown()) return ((KnownVariable*) o_variable)->get().representsFinite(allow_units); + return o_variable->representsReal(allow_units); + } case STRUCT_SYMBOLIC: {return CALCULATOR->defaultAssumptions()->isReal();} case STRUCT_FUNCTION: { if(o_function->id() == FUNCTION_ID_STRIP_UNITS && SIZE == 1) return CHILD(0).representsFinite(true); - return (function_value && function_value->representsFinite(allow_units)) || o_function->representsFinite(*this, allow_units); + return (function_value && function_value->representsFinite(allow_units)) || o_function->representsReal(*this, allow_units); } case STRUCT_UNIT: {return allow_units;} case STRUCT_DATETIME: {return allow_units;} diff --git a/libqalculate/Variable.cc b/libqalculate/Variable.cc index eea5fe64..0f0918cf 100644 --- a/libqalculate/Variable.cc +++ b/libqalculate/Variable.cc @@ -527,7 +527,6 @@ bool KnownVariable::representsFraction(bool allow_units) {return get().represent bool KnownVariable::representsNumber(bool allow_units) {return get().representsNumber(allow_units);} bool KnownVariable::representsRational(bool allow_units) {return get().representsRational(allow_units);} bool KnownVariable::representsReal(bool allow_units) {return get().representsReal(allow_units);} -bool KnownVariable::representsFinite(bool allow_units) {return get().representsFinite(allow_units);} bool KnownVariable::representsNonComplex(bool allow_units) {return get().representsNonComplex(allow_units);} bool KnownVariable::representsComplex(bool allow_units) {return get().representsComplex(allow_units);} bool KnownVariable::representsNonZero(bool allow_units) {return get().representsNonZero(allow_units);} diff --git a/libqalculate/Variable.h b/libqalculate/Variable.h index 1e3a151b..0faf803b 100644 --- a/libqalculate/Variable.h +++ b/libqalculate/Variable.h @@ -156,7 +156,6 @@ class Variable : public ExpressionItem { virtual bool representsNumber(bool = false) {return false;} virtual bool representsRational(bool = false) {return false;} virtual bool representsReal(bool = false) {return false;} - virtual bool representsFinite(bool b = false) {return representsReal(b);} virtual bool representsNonComplex(bool b = false) {return representsReal(b);} virtual bool representsComplex(bool = false) {return false;} virtual bool representsNonZero(bool = false) {return false;} @@ -337,7 +336,6 @@ class KnownVariable : public Variable { virtual bool representsNumber(bool = false); virtual bool representsRational(bool = false); virtual bool representsReal(bool = false); - virtual bool representsFinite(bool = false); virtual bool representsNonComplex(bool = false); virtual bool representsComplex(bool = false); virtual bool representsNonZero(bool = false); @@ -392,7 +390,6 @@ class DynamicVariable : public KnownVariable { virtual bool representsNumber(bool = false) {return true;} virtual bool representsRational(bool = false) {return false;} virtual bool representsReal(bool = false) {return true;} - virtual bool representsFinite(bool b = false) {return representsReal(b);} virtual bool representsComplex(bool = false) {return false;} virtual bool representsNonZero(bool = false) {return true;} virtual bool representsEven(bool = false) {return false;}