From 8fefc092b1027f2f28d262636f2d699778d89452 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Mon, 30 Oct 2017 18:04:52 +0100 Subject: [PATCH] [poincare] Change name and API of containType Change-Id: I57617c13a810400a13de774b0abc23db9adf9d15 --- poincare/include/poincare/expression.h | 3 ++- poincare/src/expression.cpp | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/poincare/include/poincare/expression.h b/poincare/include/poincare/expression.h index 579bd9e6a..e8a724aac 100644 --- a/poincare/include/poincare/expression.h +++ b/poincare/include/poincare/expression.h @@ -148,7 +148,8 @@ public: /* Simplification */ static void simplify(Expression ** expressionAddress, Context & context, AngleUnit angleUnit = AngleUnit::Default); - bool containType(Type type) const; + typedef bool (*ExpressionTest)(const Expression * e); + bool recursivelyMatches(ExpressionTest test) const; /* Evaluation Engine * The function evaluate creates a new expression and thus mallocs memory. diff --git a/poincare/src/expression.cpp b/poincare/src/expression.cpp index bb04df094..b17177eda 100644 --- a/poincare/src/expression.cpp +++ b/poincare/src/expression.cpp @@ -95,12 +95,12 @@ Expression * Expression::deepBeautify(Context & context, AngleUnit angleUnit) { return e; } -bool Expression::containType(Type t) const { - if (type() == t) { +bool Expression::recursivelyMatches(ExpressionTest test) const { + if (test(this)) { return true; } for (int i = 0; i < numberOfOperands(); i++) { - if (operand(i)->containType(t)) { + if (test(operand(i))) { return true; } }