From c69a7faa5dafbac878674fe05e97a3ffbb6992c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Thu, 9 Aug 2018 14:10:07 +0200 Subject: [PATCH] [poiuncare] Start fixing Power header: --- poincare/include/poincare/power.h | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/poincare/include/poincare/power.h b/poincare/include/poincare/power.h index b7371394d..1e1a621a7 100644 --- a/poincare/include/poincare/power.h +++ b/poincare/include/poincare/power.h @@ -1,7 +1,6 @@ #ifndef POINCARE_POWER_H #define POINCARE_POWER_H -#include #include #include #include @@ -13,8 +12,11 @@ class Power; class PowerNode : public ExpressionNode { public: - // TreeNode + // Allocation Failure static PowerNode * FailedAllocationStaticNode(); + PowerNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } + + // TreeNode size_t size() const override { return sizeof(PowerNode); } #if TREE_LOG const char * description() const override { return "Division"; } @@ -27,22 +29,25 @@ public: virtual Expression setSign(Sign s, Context & context, Preferences::AngleUnit angleUnit) const override; int polynomialDegree(char symbolName) const override; - int privateGetPolynomialCoefficients(char symbolName, Expression * coefficients[]) const override; - template static std::complex compute(const std::complex c, const std::complex d); + int getPolynomialCoefficients(char symbolName, Expression coefficients[]) const override; + private: + template static Complex compute(const std::complex c, const std::complex d); constexpr static int k_maxNumberOfTermsInExpandedMultinome = 25; constexpr static int k_maxExactPowerMatrix = 100; - /* Property */ + /* Layout */ LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override; - bool needsParenthesesWithParent(SerializableNode * parentNode) const override; + + /* Serialize */ + bool needsParenthesesWithParent(const SerializationHelperInterface * parent) const override; int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override { - return LayoutHelper::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name()); + return SerializationHelper::Infix(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name()); } static const char * name() { return "^"; } /* Simplify */ - Expression shallowReduce(Context& context, Preferences::AngleUnit angleUnit) override; - Expression * shallowBeautify(Context & context, Preferences::AngleUnit angleUnit) override; + Expression shallowReduce(Context& context, Preferences::AngleUnit angleUnit) const override; + Expression * shallowBeautify(Context & context, Preferences::AngleUnit angleUnit) const override; int simplificationOrderGreaterType(const Expression * e, bool canBeInterrupted) const override; int simplificationOrderSameType(const ExpressionNode * e, bool canBeInterrupted) const override; Expression * simplifyPowerPower(Power * p, Expression * r, Context & context, Preferences::AngleUnit angleUnit); @@ -75,9 +80,10 @@ class Power : public Expression { public: Power(Expression base, Expression exponent); Power(const PowerNode * n) : Expression(n) {} - Expression setSign(Sign s, Context & context, Preferences::AngleUnit angleUnit) const; Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit) const; + Expression * shallowBeautify(Context & context, Preferences::AngleUnit angleUnit) const; + int getPolynomialCoefficients(char symbolName, Expression coefficients[]) const; };