Skip to content

Commit

Permalink
Remove virtual from set_parent_for_children (#296)
Browse files Browse the repository at this point in the history
* Remove virtual from set_parent_for_children (issue #296)
 - set_parent_for_children is called only in the constructors. The
    virtual keyword unnecessary and generates only confusion.
 - Remove virtual from set_parent_for_children (issue #295)
 - set_parent_in_children() visibility is now private

Co-authored-by: Tristan Carel <[email protected]>

fixes #295
  • Loading branch information
cattabiani authored Apr 16, 2020
1 parent 54e41a8 commit 25e654c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
4 changes: 0 additions & 4 deletions src/language/templates/ast/ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ void Ast::set_parent(Ast* p) {
parent = p;
}

void Ast::set_parent_in_children() {
throw std::runtime_error("set_parent_in_children not implemented");
}


{% for node in nodes %}

Expand Down
17 changes: 6 additions & 11 deletions src/language/templates/ast/ast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,14 +348,6 @@ struct Ast: public std::enable_shared_from_this<Ast> {
* \ref Check Ast::parent for more information
*/
virtual void set_parent(Ast* p);

/**
*\brief Set this object as parent for all the children
*
* This should be called in every object (with children) constructor
* to set the parents.
*/
virtual void set_parent_in_children();
};

/** @} */ // end of ast_class
Expand Down Expand Up @@ -714,12 +706,15 @@ struct Ast: public std::enable_shared_from_this<Ast> {
{% endif %}

{% if node.children %}
private:
/**
* \brief Set parents in children
*\brief Set this object as parent for all the children
*
* Usually called in constructors
* This should be called in every object (with children) constructor
* to set parents. Since it is called only in the constructors it
* should not be virtual to avoid ambiguities (issue #295).
*/
virtual void set_parent_in_children() override;
void set_parent_in_children();
{% endif %}
};

Expand Down

0 comments on commit 25e654c

Please sign in to comment.