From 253db1ac2c5e75f2708e7bb79d03108e97237970 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Mon, 2 Jul 2018 14:12:03 +0200 Subject: [PATCH] castedNode() -> typedNode() --- char_layout_node.h | 2 +- expression_reference.h | 8 ++++---- float_node.h | 2 +- layout_cursor.cpp | 8 ++++---- layout_reference.cpp | 2 +- layout_reference.h | 4 ++-- test.cpp | 16 ++++++++-------- tree_reference.h | 6 +++--- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/char_layout_node.h b/char_layout_node.h index 44b8c1e62..329774c7d 100644 --- a/char_layout_node.h +++ b/char_layout_node.h @@ -51,7 +51,7 @@ class CharLayoutRef : public LayoutReference { public: CharLayoutRef(char c) : LayoutReference() { if (!(this->node()->isAllocationFailure())) { - this->castedNode()->setChar(c); + this->typedNode()->setChar(c); } } }; diff --git a/expression_reference.h b/expression_reference.h index 0702d4790..c85781448 100644 --- a/expression_reference.h +++ b/expression_reference.h @@ -28,22 +28,22 @@ public: } float approximate() const { - return this->castedNode()->approximate(); + return this->typedNode()->approximate(); } void deepReduce() { - return this->castedNode()->deepReduce(); + return this->typedNode()->deepReduce(); } void shallowReduce() { - return this->castedNode()->shallowReduce(); + return this->typedNode()->shallowReduce(); } void sortChildren() { for (int i = this->numberOfChildren()-1; i > 0; i--) { bool isSorted = true; for (int j = 0; j < this->numberOfChildren()-1; j++) { - if (this->childAtIndex(j).castedNode()->type() > this->childAtIndex(j+1).castedNode()->type()) { + if (this->childAtIndex(j).typedNode()->type() > this->childAtIndex(j+1).typedNode()->type()) { this->swapChildren(j, j+1); isSorted = false; } diff --git a/float_node.h b/float_node.h index da9cf2851..22a9d177c 100644 --- a/float_node.h +++ b/float_node.h @@ -26,7 +26,7 @@ class FloatRef : public ExpressionReference { public: FloatRef(float f) : ExpressionReference() { if (!(this->node()->isAllocationFailure())) { - this->castedNode()->setFloat(f); + this->typedNode()->setFloat(f); } } }; diff --git a/layout_cursor.cpp b/layout_cursor.cpp index aff142e85..2b65f2eaa 100644 --- a/layout_cursor.cpp +++ b/layout_cursor.cpp @@ -20,19 +20,19 @@ int LayoutCursor::middleLeftPoint() { /* Move */ void LayoutCursor::moveLeft(bool * shouldRecomputeLayout) { - layoutReference().castedNode()->moveCursorLeft(this, shouldRecomputeLayout); + layoutReference().typedNode()->moveCursorLeft(this, shouldRecomputeLayout); } void LayoutCursor::moveRight(bool * shouldRecomputeLayout) { - layoutReference().castedNode()->moveCursorRight(this, shouldRecomputeLayout); + layoutReference().typedNode()->moveCursorRight(this, shouldRecomputeLayout); } void LayoutCursor::moveAbove(bool * shouldRecomputeLayout) { - layoutReference().castedNode()->moveCursorUp(this, shouldRecomputeLayout); + layoutReference().typedNode()->moveCursorUp(this, shouldRecomputeLayout); } void LayoutCursor::moveUnder(bool * shouldRecomputeLayout) { - layoutReference().castedNode()->moveCursorDown(this, shouldRecomputeLayout); + layoutReference().typedNode()->moveCursorDown(this, shouldRecomputeLayout); } diff --git a/layout_reference.cpp b/layout_reference.cpp index 42c6455d8..587dd6c8f 100644 --- a/layout_reference.cpp +++ b/layout_reference.cpp @@ -16,7 +16,7 @@ TreeNode * LayoutRef::FailedAllocationStaticNode() { template LayoutCursor LayoutReference::cursor() const { - return LayoutCursor(this->castedNode()); + return LayoutCursor(this->typedNode()); } template LayoutCursor LayoutReference::cursor() const; diff --git a/layout_reference.h b/layout_reference.h index 521a41997..547128dc1 100644 --- a/layout_reference.h +++ b/layout_reference.h @@ -32,11 +32,11 @@ public: } int layoutOrigin() { - return this->castedNode()->layoutOrigin(); + return this->typedNode()->layoutOrigin(); } int absoluteOrigin() { - return this->castedNode()->absoluteOrigin(); + return this->typedNode()->absoluteOrigin(); } }; diff --git a/test.cpp b/test.cpp index 0be075366..0ccbb6c98 100644 --- a/test.cpp +++ b/test.cpp @@ -237,8 +237,8 @@ void testSimplify() { assert_expression_approximates_to(a, 3); assert(a.numberOfChildren() == 1); - assert(a.childAtIndex(0).castedNode()->type() == ExpressionNode::Type::Float); - assert(a.childAtIndex(0).castedNode()->approximate() == 3.0f); + assert(a.childAtIndex(0).typedNode()->type() == ExpressionNode::Type::Float); + assert(a.childAtIndex(0).typedNode()->approximate() == 3.0f); } void testChildSort() { @@ -251,15 +251,15 @@ void testChildSort() { FloatRef(3.0f)); a.addChild(FloatRef(0.0f)); - assert(a.childAtIndex(0).castedNode()->type() == ExpressionNode::Type::Float); - assert(a.childAtIndex(1).castedNode()->type() == ExpressionNode::Type::Addition); - assert(a.childAtIndex(2).castedNode()->type() == ExpressionNode::Type::Float); + assert(a.childAtIndex(0).typedNode()->type() == ExpressionNode::Type::Float); + assert(a.childAtIndex(1).typedNode()->type() == ExpressionNode::Type::Addition); + assert(a.childAtIndex(2).typedNode()->type() == ExpressionNode::Type::Float); a.sortChildren(); - assert(a.childAtIndex(0).castedNode()->type() == ExpressionNode::Type::Float); - assert(a.childAtIndex(1).castedNode()->type() == ExpressionNode::Type::Float); - assert(a.childAtIndex(2).castedNode()->type() == ExpressionNode::Type::Addition); + assert(a.childAtIndex(0).typedNode()->type() == ExpressionNode::Type::Float); + assert(a.childAtIndex(1).typedNode()->type() == ExpressionNode::Type::Float); + assert(a.childAtIndex(2).typedNode()->type() == ExpressionNode::Type::Addition); } diff --git a/tree_reference.h b/tree_reference.h index c28123e8a..0143a4bf2 100644 --- a/tree_reference.h +++ b/tree_reference.h @@ -68,10 +68,10 @@ public: return TreeReference(this->node()); } - T * castedNode() const { + T * typedNode() const { // TODO: Here, assert that the node type is indeed T // ?? Might be allocation failure, not T - return static_cast(TreePool::sharedPool()->node(m_identifier)); + return static_cast(node()); } TreeNode * node() const { @@ -163,7 +163,7 @@ public: TreeReference p = parent(); int indexInParentNode = node()->indexInParent(); int currentRetainCount = node()->retainCount(); - TreeNode * staticAllocFailNode = castedNode()->failedAllocationStaticNode(); + TreeNode * staticAllocFailNode = typedNode()->failedAllocationStaticNode(); // Move the node to the end of the pool and decrease children count of parent TreePool::sharedPool()->move(node(), TreePool::sharedPool()->last());