From 5be0f5a05864206b2c52804d3e35f05a97e5718e Mon Sep 17 00:00:00 2001 From: Alexandre Bique Date: Fri, 15 May 2009 16:57:28 +0100 Subject: [PATCH] [ozulis] now deleting some fields in AST's destructors --- src/ozulis/generators/ast.cc | 7 +++++-- src/ozulis/generators/generator.hh | 1 + src/ozulis/generators/lib.cc | 11 +++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/ozulis/generators/ast.cc b/src/ozulis/generators/ast.cc index 7ca0664..be45155 100644 --- a/src/ozulis/generators/ast.cc +++ b/src/ozulis/generators/ast.cc @@ -126,8 +126,11 @@ generateAstSource(const char * working_directory) << " }" NL NL; out << " " << node->name << "::~" << node->name << "()" NL - << " {" NL - << " }" NL NL; + << " {" NL; + for (const ag::Attribute * attr = node->attrs; !attr->type.empty(); ++attr) + if (ag::needsDelete(attr->type)) + out << " delete " << attr->name << ";" NL; + out << " }" NL NL; out << " const std::string & " << node->name << "::nodeName() const" NL << " {" NL diff --git a/src/ozulis/generators/generator.hh b/src/ozulis/generators/generator.hh index 75663d2..7946163 100644 --- a/src/ozulis/generators/generator.hh +++ b/src/ozulis/generators/generator.hh @@ -29,6 +29,7 @@ namespace ozulis bool isNode(const std::string & type); bool isVectorOfNode(const std::string & type); bool isPrintable(const std::string & type); + bool needsDelete(const std::string & type); const Node * findNodeByName(const std::string & name); std::vector allAttributes(const Node * node); void appendGeneratedWarning(std::ostream & out); diff --git a/src/ozulis/generators/lib.cc b/src/ozulis/generators/lib.cc index 26f90e5..badbe97 100644 --- a/src/ozulis/generators/lib.cc +++ b/src/ozulis/generators/lib.cc @@ -38,6 +38,17 @@ bool ag::isVectorOfNode(const std::string & type) false; } +bool ag::needsDelete(const std::string & type) +{ + return + type == "std::vector *" || + type == "std::vector *" || + type == "std::vector *" || + type == "std::vector *" || + type == "Scope *" || + false; +} + const ag::Node * ag::findNodeByName(const std::string & name) { -- 2.11.4.GIT