Refactor AST 93/268693/2
authorjh9216.park <jh9216.park@samsung.com>
Thu, 30 Dec 2021 02:41:30 +0000 (21:41 -0500)
committerjh9216.park <jh9216.park@samsung.com>
Thu, 30 Dec 2021 04:56:38 +0000 (23:56 -0500)
- Make some containers iterable
- Signature change for some methods

Change-Id: I6213264eeb18c7ebcc99b86304bc7bb344cb05e3
Signed-off-by: jh9216.park <jh9216.park@samsung.com>
51 files changed:
idlc/ast/attribute.cc
idlc/ast/attribute.h
idlc/ast/declaration.cc
idlc/ast/declaration.h
idlc/ast/element.cc
idlc/ast/element.h
idlc/ast/parameter.cc
idlc/ast/parameter.h
idlc/ast/tidlc.yy
idlc/ast/tidlc_y.cpp
idlc/gen/c_body_gen_base.cc
idlc/gen/c_gen_base.cc
idlc/gen/c_header_gen_base.cc
idlc/gen/c_proxy_body_gen.cc
idlc/gen/c_proxy_header_gen.cc
idlc/gen/c_stub_body_gen.cc
idlc/gen/c_stub_header_gen.cc
idlc/gen/cpp_gen_base.cc
idlc/gen/cpp_proxy_body_gen.cc
idlc/gen/cpp_proxy_header_gen.cc
idlc/gen/cpp_stub_body_gen.cc
idlc/gen/cpp_stub_header_gen.cc
idlc/gen/cs_gen_base.cc
idlc/gen/cs_proxy_gen.cc
idlc/gen/cs_stub_gen.cc
idlc/gen/generator.cc
idlc/gen_cion/c_cion_body_gen_base.cc
idlc/gen_cion/c_cion_gen_base.cc
idlc/gen_cion/c_cion_header_gen_base.cc
idlc/gen_cion/c_cion_proxy_body_gen.cc
idlc/gen_cion/c_cion_proxy_header_gen.cc
idlc/gen_cion/c_cion_stub_body_gen.cc
idlc/gen_cion/c_cion_stub_header_gen.cc
idlc/gen_cion/cpp_cion_gen_base.cc
idlc/gen_cion/cpp_cion_proxy_body_gen.cc
idlc/gen_cion/cpp_cion_proxy_header_gen.cc
idlc/gen_cion/cpp_cion_stub_body_gen.cc
idlc/gen_cion/cpp_cion_stub_header_gen.cc
idlc/gen_cion/cs_cion_gen_base.cc
idlc/gen_cion/cs_cion_proxy_gen.cc
idlc/gen_cion/cs_cion_stub_gen.cc
idlc/gen_cion/java_cion_common_gen.cc
idlc/gen_cion/java_cion_gen_base.cc
idlc/gen_cion/java_cion_proxy_gen.cc
idlc/gen_cion/java_cion_structure_gen.cc
idlc/gen_cion/java_cion_stub_gen.cc
tests/unit_tests/attribute_unittest.cc
tests/unit_tests/declaration_unittest.cc
tests/unit_tests/element_unittest.cc
tests/unit_tests/interface_unittest.cc
tests/unit_tests/structure_unittest.cc

index 6fcf86d..dd9dd40 100644 (file)
@@ -36,22 +36,27 @@ const unsigned Attribute::GetLine() const {
   return line_;
 }
 
-void Attributes::Add(Attribute* attr) {
-  attrs_.emplace_back(attr);
+void Attributes::Add(std::unique_ptr<Attribute> attr) {
+  attrs_.push_back(std::move(attr));
 }
 
-const std::list<std::unique_ptr<Attribute>>& Attributes::GetAttrs() const {
-  return attrs_;
-}
-
-bool Attributes::Exist(Attribute* attr) const {
+bool Attributes::Exist(const Attribute& attr) const {
   for (auto& a : attrs_) {
-    if (a->GetKey() == attr->GetKey() &&
-        a->GetValue() == attr->GetValue())
+    if (a->GetKey() == attr.GetKey() &&
+        a->GetValue() == attr.GetValue())
       return true;
   }
 
   return false;
 }
 
+std::list<std::unique_ptr<Attribute>>::const_iterator
+Attributes::begin() const {
+  return attrs_.cbegin();
+}
+
+std::list<std::unique_ptr<Attribute>>::const_iterator Attributes::end() const {
+  return attrs_.cend();
+}
+
 }  // namespace tidl
index 360348e..989ce76 100644 (file)
@@ -39,9 +39,10 @@ class Attribute {
 
 class Attributes {
  public:
-  void Add(Attribute* attr);
-  const std::list<std::unique_ptr<Attribute>>& GetAttrs() const;
-  bool Exist(Attribute* attr) const;
+  void Add(std::unique_ptr<Attribute> attr);
+  bool Exist(const Attribute& attr) const;
+  std::list<std::unique_ptr<Attribute>>::const_iterator begin() const;
+  std::list<std::unique_ptr<Attribute>>::const_iterator end() const;
 
  private:
   std::list<std::unique_ptr<Attribute>> attrs_;
index 400225a..c3b4352 100644 (file)
@@ -52,21 +52,27 @@ const std::string& Declaration::GetComments() const {
   return comments_;
 }
 
-void Declarations::Add(Declaration* decl) {
-  decls_.emplace_back(decl);
+void Declarations::Add(std::unique_ptr<Declaration> decl) {
+  decls_.push_back(std::move(decl));
 }
 
-const std::list<std::unique_ptr<Declaration>>& Declarations::GetDecls() const {
-  return decls_;
-}
-
-bool Declarations::Exist(Declaration* decl) const {
+bool Declarations::Exist(const Declaration& decl) const {
   for (auto& d : decls_) {
-    if (d->GetID() == decl->GetID())
+    if (d->GetID() == decl.GetID())
       return true;
   }
 
   return false;
 }
 
+std::list<std::unique_ptr<Declaration>>::const_iterator
+Declarations::begin() const {
+  return decls_.cbegin();
+}
+
+std::list<std::unique_ptr<Declaration>>::const_iterator
+Declarations::end() const {
+  return decls_.cend();
+}
+
 }  // namespace tidl
index 13f81dd..47ff701 100644 (file)
@@ -56,9 +56,10 @@ class Declaration {
 
 class Declarations {
  public:
-  void Add(Declaration* decl);
-  const std::list<std::unique_ptr<Declaration>>& GetDecls() const;
-  bool Exist(Declaration* decl) const;
+  void Add(std::unique_ptr<Declaration> decl);
+  bool Exist(const Declaration& decl) const;
+  std::list<std::unique_ptr<Declaration>>::const_iterator begin() const;
+  std::list<std::unique_ptr<Declaration>>::const_iterator end() const;
 
  private:
   std::list<std::unique_ptr<Declaration>> decls_;
index 1594a2a..41f24ad 100644 (file)
@@ -42,21 +42,26 @@ const std::string& Element::GetComments() const {
   return comments_;
 }
 
-void Elements::Add(Element* elm) {
-  elms_.emplace_back(elm);
+void Elements::Add(std::unique_ptr<Element> elm) {
+  elms_.push_back(std::move(elm));
 }
 
-const std::list<std::unique_ptr<Element>>& Elements::GetElms() const {
-  return elms_;
-}
-
-bool Elements::Exist(Element* elm) const {
+bool Elements::Exist(const Element& elm) const {
   for (auto& e : elms_) {
-    if (e->GetID() == elm->GetID())
+    if (e->GetID() == elm.GetID())
       return true;
   }
 
   return false;
 }
 
+std::list<std::unique_ptr<Element>>::const_iterator
+Elements::begin() const {
+  return elms_.cbegin();
+}
+
+std::list<std::unique_ptr<Element>>::const_iterator Elements::end() const {
+  return elms_.cend();
+}
+
 }  // namespace tidl
index ca1b56c..51228d4 100644 (file)
@@ -45,9 +45,10 @@ class Element {
 
 class Elements {
  public:
-  void Add(Element* elm);
-  const std::list<std::unique_ptr<Element>>& GetElms() const;
-  bool Exist(Element* elm) const;
+  void Add(std::unique_ptr<Element> elm);
+  bool Exist(const Element& elm) const;
+  std::list<std::unique_ptr<Element>>::const_iterator begin() const;
+  std::list<std::unique_ptr<Element>>::const_iterator end() const;
 
  private:
   std::list<std::unique_ptr<Element>> elms_;
index 1199bb2..7e673e1 100644 (file)
@@ -36,17 +36,13 @@ const unsigned Parameter::GetLine() const {
   return line_;
 }
 
-void Parameters::Add(Parameter* param) {
-  params_.emplace_back(param);
+void Parameters::Add(std::unique_ptr<Parameter> param) {
+  params_.push_back(std::move(param));
 }
 
-const std::list<std::unique_ptr<Parameter>>& Parameters::GetParams() const {
-  return params_;
-}
-
-bool Parameters::Exist(Parameter* param) const {
+bool Parameters::Exist(const Parameter& param) const {
   for (auto& p : params_) {
-    if (p->GetID() == param->GetID())
+    if (p->GetID() == param.GetID())
       return true;
   }
 
@@ -62,5 +58,14 @@ bool Parameters::Exist(std::string type_name) const {
   return false;
 }
 
+std::list<std::unique_ptr<Parameter>>::const_iterator
+Parameters::begin() const {
+  return params_.cbegin();
+}
+
+std::list<std::unique_ptr<Parameter>>::const_iterator Parameters::end() const {
+  return params_.cend();
+}
+
 }  // namespace tidl
 
index 2e7abe8..6194211 100644 (file)
@@ -41,10 +41,11 @@ class Parameter {
 
 class Parameters {
  public:
-  void Add(Parameter* param);
-  const std::list<std::unique_ptr<Parameter>>& GetParams() const;
-  bool Exist(Parameter* param) const;
+  void Add(std::unique_ptr<Parameter> param);
+  bool Exist(const Parameter& param) const;
   bool Exist(std::string type_name) const;
+  std::list<std::unique_ptr<Parameter>>::const_iterator begin() const;
+  std::list<std::unique_ptr<Parameter>>::const_iterator end() const;
 
  private:
   std::list<std::unique_ptr<Parameter>> params_;
index 6c864c8..bab90b1 100644 (file)
@@ -152,17 +152,17 @@ structure_block: T_STRUCTURE T_ID T_BRACE_OPEN elements T_BRACE_CLOSE {
 elements: element {
     $$ = new (std::nothrow) tidl::Elements();
     if ($$ != nullptr) {
-      $$->Add($1);
+      $$->Add(std::unique_ptr<tidl::Element>($1));
     }
   }
   | elements element {
     $$ = $1;
     if ($2 != nullptr) {
-      if ($$->Exist($2)) {
+      if ($$->Exist(*$2)) {
         ps->ReportError("syntax error. \"Already Exists\".", $2->GetLine());
         delete $2;
       } else {
-        $$->Add($2);
+        $$->Add(std::unique_ptr<tidl::Element>($2));
       }
     }
   }
@@ -194,17 +194,17 @@ element: raw_type T_ID T_SEMICOLON {
 attributes: attribute {
     $$ = new (std::nothrow) tidl::Attributes();
     if ($$ != nullptr) {
-      $$->Add($1);
+      $$->Add(std::unique_ptr<tidl::Attribute>($1));
     }
   }
   | attributes T_COMMA attribute {
     $$ = $1;
     if ($3 != nullptr) {
-      if ($$->Exist($3)) {
+      if ($$->Exist(*$3)) {
         ps->ReportError("syntax error. \"Already Exist\".", $3->GetLine());
         delete $3;
       } else {
-        $$->Add($3);
+        $$->Add(std::unique_ptr<tidl::Attribute>($3));
       }
     }
   }
@@ -266,17 +266,17 @@ interface_block: T_INTERFACE T_ID T_BRACE_OPEN declarations T_BRACE_CLOSE {
 declarations: declaration {
     $$ = new (std::nothrow) tidl::Declarations();
     if ($$ != nullptr) {
-      $$->Add($1);
+      $$->Add(std::unique_ptr<tidl::Declaration>($1));
     }
   }
   | declarations declaration {
     $$ = $1;
     if ($2 != nullptr) {
-      if ($$->Exist($2)) {
+      if ($$->Exist(*$2)) {
         ps->ReportError("syntax error. \"Already Exists\".", $2->GetLine());
         delete $2;
       } else {
-        $$->Add($2);
+        $$->Add(std::unique_ptr<tidl::Declaration>($2));
       }
     }
   }
@@ -346,17 +346,17 @@ declaration: base_type T_ID T_LEFT parameter_list T_RIGHT T_SEMICOLON {
 parameter_list: parameter {
     $$ = new tidl::Parameters();
     if ($1 != nullptr) {
-      $$->Add($1);
+      $$->Add(std::unique_ptr<tidl::Parameter>($1));
     }
   }
   | parameter_list T_COMMA parameter {
     $$ = $1;
     if ($3 != nullptr) {
-      if ($$->Exist($3)) {
+      if ($$->Exist(*$3)) {
         ps->ReportError("syntax error. \"Already Exists\".", $3->GetLine());
         delete $3;
       } else {
-        $$->Add($3);
+        $$->Add(std::unique_ptr<tidl::Parameter>($3));
       }
     }
   }
index d50ff60..0fe462f 100644 (file)
@@ -1336,7 +1336,7 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
                   {
     ((*yyvalp).elms) = new (std::nothrow) tidl::Elements();
     if (((*yyvalp).elms) != nullptr) {
-      ((*yyvalp).elms)->Add((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm));
+      ((*yyvalp).elms)->Add(std::unique_ptr<tidl::Element>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm)));
     }
   }
 #line 1343 "/home/gogo/work/tidl/idlc/ast/tidlc_y.cpp"
@@ -1347,11 +1347,11 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
                      {
     ((*yyvalp).elms) = (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.elms);
     if ((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm) != nullptr) {
-      if (((*yyvalp).elms)->Exist((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm))) {
+      if (((*yyvalp).elms)->Exist(*(YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm))) {
         ps->ReportError("syntax error. \"Already Exists\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm)->GetLine());
         delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm);
       } else {
-        ((*yyvalp).elms)->Add((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm));
+        ((*yyvalp).elms)->Add(std::unique_ptr<tidl::Element>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm)));
       }
     }
   }
@@ -1409,7 +1409,7 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
                       {
     ((*yyvalp).attrs) = new (std::nothrow) tidl::Attributes();
     if (((*yyvalp).attrs) != nullptr) {
-      ((*yyvalp).attrs)->Add((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr));
+      ((*yyvalp).attrs)->Add(std::unique_ptr<tidl::Attribute>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr)));
     }
   }
 #line 1416 "/home/gogo/work/tidl/idlc/ast/tidlc_y.cpp"
@@ -1420,11 +1420,11 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
                                  {
     ((*yyvalp).attrs) = (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.attrs);
     if ((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr) != nullptr) {
-      if (((*yyvalp).attrs)->Exist((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr))) {
+      if (((*yyvalp).attrs)->Exist(*(YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr))) {
         ps->ReportError("syntax error. \"Already Exist\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr)->GetLine());
         delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr);
       } else {
-        ((*yyvalp).attrs)->Add((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr));
+        ((*yyvalp).attrs)->Add(std::unique_ptr<tidl::Attribute>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr)));
       }
     }
   }
@@ -1530,7 +1530,7 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
                           {
     ((*yyvalp).decls) = new (std::nothrow) tidl::Declarations();
     if (((*yyvalp).decls) != nullptr) {
-      ((*yyvalp).decls)->Add((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl));
+      ((*yyvalp).decls)->Add(std::unique_ptr<tidl::Declaration>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl)));
     }
   }
 #line 1537 "/home/gogo/work/tidl/idlc/ast/tidlc_y.cpp"
@@ -1541,11 +1541,11 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
                              {
     ((*yyvalp).decls) = (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.decls);
     if ((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl) != nullptr) {
-      if (((*yyvalp).decls)->Exist((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl))) {
+      if (((*yyvalp).decls)->Exist(*(YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl))) {
         ps->ReportError("syntax error. \"Already Exists\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl)->GetLine());
         delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl);
       } else {
-        ((*yyvalp).decls)->Add((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl));
+        ((*yyvalp).decls)->Add(std::unique_ptr<tidl::Declaration>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl)));
       }
     }
   }
@@ -1676,7 +1676,7 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
                           {
     ((*yyvalp).params) = new tidl::Parameters();
     if ((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param) != nullptr) {
-      ((*yyvalp).params)->Add((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param));
+      ((*yyvalp).params)->Add(std::unique_ptr<tidl::Parameter>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param)));
     }
   }
 #line 1683 "/home/gogo/work/tidl/idlc/ast/tidlc_y.cpp"
@@ -1687,11 +1687,11 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
                                      {
     ((*yyvalp).params) = (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.params);
     if ((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param) != nullptr) {
-      if (((*yyvalp).params)->Exist((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param))) {
+      if (((*yyvalp).params)->Exist(*(YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param))) {
         ps->ReportError("syntax error. \"Already Exists\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param)->GetLine());
         delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param);
       } else {
-        ((*yyvalp).params)->Add((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param));
+        ((*yyvalp).params)->Add(std::unique_ptr<tidl::Parameter>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param)));
       }
     }
   }
index 87e97af..929c7ce 100644 (file)
@@ -43,14 +43,14 @@ CBodyGeneratorBase::CBodyGeneratorBase(std::shared_ptr<Document> doc)
   for (auto& b : GetDocument().GetBlocks()) {
     if (b->GetType() == Block::TYPE_STRUCTURE) {
       auto& st = static_cast<const Structure&>(*b);
-      for (auto& e : st.GetElements().GetElms()) {
+      for (const auto& e : st.GetElements()) {
         auto& type = e->GetType();
         AddStructureFromType(type);
       }
     } else {
       auto& iface = static_cast<const Interface&>(*b);
-      for (auto& d : iface.GetDeclarations().GetDecls()) {
-        for (auto& p : d->GetParameters().GetParams()) {
+      for (const auto& d : iface.GetDeclarations()) {
+        for (const auto& p : d->GetParameters()) {
           auto& type = p->GetParameterType().GetBaseType();
           if (IsDelegateType(iface, type))
             continue;
@@ -122,7 +122,7 @@ void CBodyGeneratorBase::GenStructureDef(std::ofstream& stream,
 // @see #CB_STRUCTURE_ARRAY_DEF
 void CBodyGeneratorBase::GenStructureArrayDef(std::ofstream& stream,
     const Structure& st) {
-  auto& elm = st.GetElements().GetElms().front();
+  auto& elm = *(st.GetElements().begin());
   auto& type = elm->GetType();
   auto element_type = GetDataTypeString(type, false);
 
@@ -261,7 +261,7 @@ std::string CBodyGeneratorBase::GenArrayElementsFree(
 // @see #CB_STRUCTURE_ARRAY_BASE
 void CBodyGeneratorBase::GenStructureArrayBase(std::ofstream& stream,
     const Structure& st) {
-  auto& elm = st.GetElements().GetElms().front();
+  auto& elm = *(st.GetElements().begin());
   auto& type = elm->GetType();
   auto param_type_in = GetParamTypeString(ParameterType::Direction::IN, type);
   auto param_type_out = GetParamTypeString(ParameterType::Direction::OUT, type);
@@ -409,7 +409,7 @@ std::string CBodyGeneratorBase::GenListCallbackParamType(
 // @see #CB_STRUCTURE_LIST_BASE
 void CBodyGeneratorBase::GenStructureListBase(std::ofstream& stream,
     const Structure& st) {
-  auto& elm = st.GetElements().GetElms().front();
+  auto& elm = *(st.GetElements().begin());
   auto& type = elm->GetType();
   auto param_type = GetParamTypeString(ParameterType::Direction::IN, type);
 
@@ -430,7 +430,7 @@ void CBodyGeneratorBase::GenStructureListBase(std::ofstream& stream,
 
 std::string CBodyGeneratorBase::GenBaseElements(const Elements& elms) {
   std::string code;
-  for (auto& elm : elms.GetElms()) {
+  for (const auto& elm : elms) {
     auto& type = elm->GetType();
     auto param_type = GetDataTypeString(type, false);
     code += param_type + elm->GetID() + ";";
@@ -467,7 +467,7 @@ std::string CBodyGeneratorBase::GenBaseElementFree(
 
 std::string CBodyGeneratorBase::GenBaseElementsFree(const Elements& elms) {
   std::string code;
-  for (auto& elm : elms.GetElms())
+  for (const auto& elm : elms)
     code += GenBaseElementFree(elm);
 
   return RemoveLine(code);
@@ -479,7 +479,7 @@ std::string CBodyGeneratorBase::GenBaseElementsFree(const Elements& elms) {
 // @see #CB_STRUCTURE_BASE_BASE_PARCEL_WRITE
 std::string CBodyGeneratorBase::GenBaseParcelWrite(const Elements& elms) {
   std::string code;
-  for (auto& elm : elms.GetElms()) {
+  for (const auto& elm : elms) {
     std::string parcel_write_code;
     auto& type = elm->GetType();
     if (type.IsUserDefinedType() ||
@@ -513,7 +513,7 @@ std::string CBodyGeneratorBase::GenBaseParcelWrite(const Elements& elms) {
 // @see #CB_STRUCTURE_BASE_BASE_PARCEL_READ
 std::string CBodyGeneratorBase::GenBaseParcelRead(const Elements& elms) {
   std::string code;
-  for (auto& elm : elms.GetElms()) {
+  for (const auto& elm : elms) {
     std::string parcel_read_code;
     auto& type = elm->GetType();
     if (type.IsUserDefinedType() ||
@@ -614,7 +614,7 @@ std::string CBodyGeneratorBase::GenBaseGet(
 std::string CBodyGeneratorBase::GenBaseSetGet(const std::string& name,
     const Elements& elms) {
   std::string code;
-  for (auto& elm : elms.GetElms()) {
+  for (const auto& elm : elms) {
     auto& type = elm->GetType();
     auto param_type_in = GetParamTypeString(ParameterType::Direction::IN, type);
     auto param_type_out = GetParamTypeString(ParameterType::Direction::OUT,
@@ -663,11 +663,11 @@ const std::string& CBodyGeneratorBase::GetParcelType(const BaseType& type) {
 }
 
 bool CBodyGeneratorBase::HasListFile(const Interface& iface) {
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     if (IsProxy() && d->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
 
-    for (auto& p : d->GetParameters().GetParams()) {
+    for (const auto& p : d->GetParameters()) {
       auto& param_type = p->GetParameterType();
       auto& type = param_type.GetBaseType();
       auto name = GetFullNameFromType(type, iface);
index 1787130..5fe1a23 100644 (file)
@@ -134,12 +134,12 @@ void CGeneratorBase::AddStructureFromType(const BaseType& type) {
   assert(t != nullptr);
 
   std::string type_name = GetFullNameFromType(type);
-  Element* elm = new Element(type_name, t, "", __LINE__);
+  auto elm = std::unique_ptr<Element>(new Element(type_name, t, "", __LINE__));
   assert(elm != nullptr);
 
   Elements* elms = new Elements();
   assert(elms != nullptr);
-  elms->Add(elm);
+  elms->Add(std::move(elm));
 
   auto* st = new Structure(type_name, elms, "", __LINE__);
   assert(st != nullptr);
@@ -168,12 +168,12 @@ void CGeneratorBase::AddStructureFromType(const BaseType& type,
   assert(t != nullptr);
 
   std::string type_name = GetFullNameFromType(type, iface);
-  Element* elm = new Element(type_name, t, "", __LINE__);
+  auto elm = std::unique_ptr<Element>(new Element(type_name, t, "", __LINE__));
   assert(elm != nullptr);
 
   Elements* elms = new Elements();
   assert(elms != nullptr);
-  elms->Add(elm);
+  elms->Add(std::move(elm));
 
   auto* st = new Structure(type_name, elms, "", __LINE__);
   assert(st != nullptr);
index a0bb243..256d497 100644 (file)
@@ -31,14 +31,14 @@ CHeaderGeneratorBase::CHeaderGeneratorBase(std::shared_ptr<Document> doc)
   for (auto& b : GetDocument().GetBlocks()) {
     if (b->GetType() == Block::TYPE_STRUCTURE) {
       auto& st = static_cast<const Structure&>(*b);
-      for (auto& e : st.GetElements().GetElms()) {
+      for (const auto& e : st.GetElements()) {
         auto& type = e->GetType();
         AddStructureFromType(type);
       }
     } else {
       auto& iface = static_cast<const Interface&>(*b);
-      for (auto& d : iface.GetDeclarations().GetDecls()) {
-        for (auto& p : d->GetParameters().GetParams()) {
+      for (const auto& d : iface.GetDeclarations()) {
+        for (const auto& p : d->GetParameters()) {
           auto& type = p->GetParameterType().GetBaseType();
           if (IsDelegateType(iface, type))
             continue;
@@ -112,7 +112,7 @@ void CHeaderGeneratorBase::GenStructureHandle(std::ofstream& stream,
 // @see #CB_STRUCTURE_ARRAY_BASE
 void CHeaderGeneratorBase::GenStructureArrayBase(std::ofstream& stream,
     const Structure& st) {
-  auto& elm = st.GetElements().GetElms().front();
+  auto& elm = *(st.GetElements().begin());
   auto& type = elm->GetType();
   auto param_type_in = GetParamTypeString(ParameterType::Direction::IN, type);
   auto param_type_out = GetParamTypeString(ParameterType::Direction::OUT, type);
@@ -130,7 +130,7 @@ void CHeaderGeneratorBase::GenStructureArrayBase(std::ofstream& stream,
 // @see #CB_STRUCTURE_LIST_BASE
 void CHeaderGeneratorBase::GenStructureListBase(std::ofstream& stream,
     const Structure& st) {
-  auto& elm = st.GetElements().GetElms().front();
+  auto& elm = *(st.GetElements().begin());
   auto& type = elm->GetType();
   auto param_type = GetParamTypeString(ParameterType::Direction::IN, type);
 
@@ -151,7 +151,7 @@ void CHeaderGeneratorBase::GenStructureBase(std::ofstream& stream,
   str = ReplaceAll(str, "<NAME>", st.GetID());
   stream << SmartIndent(str);
 
-  for (auto& e : st.GetElements().GetElms()) {
+  for (const auto& e : st.GetElements()) {
     auto& type = e->GetType();
     auto param_type_in = GetParamTypeString(ParameterType::Direction::IN, type);
     auto param_type_out = GetParamTypeString(ParameterType::Direction::OUT, type);
index 9eac4a9..c4a3fa6 100644 (file)
@@ -63,7 +63,7 @@ void CProxyBodyGen::GenInterfaceDefs(std::ofstream& stream) {
 
 void CProxyBodyGen::GenInterfaceDef(std::ofstream& stream,
     const Interface& iface) {
-   for (auto& d : iface.GetDeclarations().GetDecls()) {
+   for (const auto& d : iface.GetDeclarations()) {
     if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
       continue;
 
@@ -110,7 +110,7 @@ void CProxyBodyGen::GenInterface(std::ofstream& stream,
     const Interface& iface) {
   GenInterfaceDelegateEnumBase(stream, iface);
 
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
       continue;
 
@@ -121,7 +121,7 @@ void CProxyBodyGen::GenInterface(std::ofstream& stream,
   GenInterfaceMethodEnumBase(stream, iface);
   GenInterfaceBase(stream, iface);
 
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
 
@@ -149,7 +149,7 @@ void CProxyBodyGen::GenInterfaceDelegateEnumBase(std::ofstream& stream,
     const Interface& iface) {
   unsigned int num = 1;
   std::string enums;
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
       continue;
 
@@ -174,7 +174,7 @@ void CProxyBodyGen::GenInterfaceDelegateEnumBase(std::ofstream& stream,
 std::string CProxyBodyGen::GenDelegateArgsDecl(const Interface& iface,
     const Declaration& decl) {
   std::string code;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     auto& param_type = p->GetParameterType();
     auto& type = param_type.GetBaseType();
     code += GetArgTypeString(type, iface) + p->GetID() + " = " +
@@ -191,7 +191,7 @@ std::string CProxyBodyGen::GenDelegateArgsDecl(const Interface& iface,
 std::string CProxyBodyGen::GenDelegateParcelRead(const Interface& iface,
     const Declaration& decl) {
   std::string code;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     std::string param_read_code;
     auto& param_type = p->GetParameterType();
     auto& type = param_type.GetBaseType();
@@ -230,7 +230,7 @@ std::string CProxyBodyGen::GenDelegateParcelRead(const Interface& iface,
 std::string CProxyBodyGen::GenDelegateArgsFree(const Interface& iface,
     const Declaration& decl, bool& has_free) {
   std::string code;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     std::string param_free_code;
     auto& param_type = p->GetParameterType();
     auto& type = param_type.GetBaseType();
@@ -264,7 +264,7 @@ std::string CProxyBodyGen::GenDelegateArgsFree(const Interface& iface,
 
 std::string CProxyBodyGen::GenDelegateCallbackArgs(const Declaration& decl) {
   std::string code;
-  for (auto& p : decl.GetParameters().GetParams())
+  for (const auto& p : decl.GetParameters())
     code += ", " + p->GetID();
 
   return code;
@@ -300,7 +300,7 @@ void CProxyBodyGen::GenInterfaceDelegateBase(std::ofstream& stream,
 void CProxyBodyGen::GenInterfaceDelegateTable(std::ofstream& stream,
     const Interface& iface) {
   std::string delegate_handlers;
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
       continue;
 
@@ -340,7 +340,7 @@ void CProxyBodyGen::GenInterfaceMethodEnumBase(std::ofstream& stream,
   enums += GetHandlePrefix() + "_" + iface.GetID() + "_METHOD_CALLBACK_,";
   enums += NLine(1);
 
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
 
@@ -363,7 +363,7 @@ void CProxyBodyGen::GenInterfaceMethodEnumBase(std::ofstream& stream,
 std::string CProxyBodyGen::GenMethodParams(const Interface& iface,
     const Declaration& decl) {
   std::string params;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     params += ", ";
     auto& param_type = p->GetParameterType();
     auto& type = param_type.GetBaseType();
@@ -377,7 +377,7 @@ std::string CProxyBodyGen::GenMethodParams(const Interface& iface,
 std::string CProxyBodyGen::GenMethodParamsCheck(const Interface& iface,
     const Declaration& decl) {
   std::string params_check;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     auto& param_type = p->GetParameterType();
     auto& type = param_type.GetBaseType();
     if (IsDelegateType(iface, type) ||
@@ -403,7 +403,7 @@ std::string CProxyBodyGen::GenMethodParamsCheck(const Interface& iface,
 std::string CProxyBodyGen::GenMethodParcelWrite(const Interface& iface,
     const Declaration& decl) {
   std::string code;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     auto& param_type = p->GetParameterType();
     if (param_type.GetDirection() != ParameterType::Direction::IN)
       continue;
@@ -448,7 +448,7 @@ std::string CProxyBodyGen::GenMethodParcelWrite(const Interface& iface,
 std::string CProxyBodyGen::GenMethodDelegateAppend(const Interface& iface,
     const Declaration& decl) {
   std::string code;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     auto& param_type = p->GetParameterType();
     auto& type = param_type.GetBaseType();
     if (IsDelegateType(iface, type)) {
@@ -492,7 +492,7 @@ std::string CProxyBodyGen::GenMethodAsyncBase(const Interface& iface,
 std::string CProxyBodyGen::GenMethodArgs(const Interface& iface,
     const Declaration& decl) {
   std::string args_code;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     auto& param_type = p->GetParameterType();
     if (param_type.GetDirection() != ParameterType::Direction::OUT)
       continue;
@@ -543,7 +543,7 @@ std::string CProxyBodyGen::GenMethodParcelRead(const Interface& iface,
     const Declaration& decl) {
   std::string code;
   std::string parcel_read_code;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     auto& param_type = p->GetParameterType();
     if (param_type.GetDirection() != ParameterType::Direction::OUT)
       continue;
index e2231a4..5be03de 100644 (file)
@@ -48,7 +48,7 @@ void CProxyHeaderGen::GenInterfaceHandles(std::ofstream& stream) {
 
     auto& iface = static_cast<const Interface&>(*b);
     GenInterfaceHandle(stream, iface);
-    for (auto& d : iface.GetDeclarations().GetDecls()) {
+    for (const auto& d : iface.GetDeclarations()) {
       if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
         continue;
 
@@ -92,7 +92,7 @@ void CProxyHeaderGen::GenInterfaces(std::ofstream& stream) {
 
 void CProxyHeaderGen::GenInterface(std::ofstream& stream,
     const Interface& iface) {
-  for (auto& d: iface.GetDeclarations().GetDecls()) {
+  for (const auto& d: iface.GetDeclarations()) {
     if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
       continue;
 
@@ -101,7 +101,7 @@ void CProxyHeaderGen::GenInterface(std::ofstream& stream,
 
   GenInterfaceBase(stream, iface);
 
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
 
@@ -123,7 +123,7 @@ void CProxyHeaderGen::GenInterfaceBase(std::ofstream& stream,
 std::string CProxyHeaderGen::GenDelegateParams(const Interface& iface,
     const Declaration& decl) {
   std::string params;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     params += ", ";
     auto& param_type = p->GetParameterType();
     auto& type = param_type.GetBaseType();
@@ -150,7 +150,7 @@ void CProxyHeaderGen::GenInterfaceDelegateBase(std::ofstream& stream,
 std::string CProxyHeaderGen::GenMethodParams(const Interface& iface,
     const Declaration& decl) {
   std::string params;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     params += ", ";
     auto& param_type = p->GetParameterType();
     auto& type = param_type.GetBaseType();
index 8b3d759..28ad801 100644 (file)
@@ -95,7 +95,7 @@ std::string CStubBodyGen::GenMethodEnums(const Interface& iface) {
 
   method_enums += RemoveLine(method_enum);
 
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
 
@@ -129,7 +129,7 @@ void CStubBodyGen::GenInterfaceMethodEnumBase(std::ofstream& stream,
 std::string CStubBodyGen::GenDelegateEnums(const Interface& iface) {
   unsigned int num = 1;
   std::string method_enums;
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
       continue;
 
@@ -177,7 +177,7 @@ void CStubBodyGen::GenInterfaceDefs(std::ofstream& stream) {
 void CStubBodyGen::GenInterfaceDef(std::ofstream& stream,
     const Interface& iface) {
   bool has_delegate = false;
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
       continue;
 
@@ -249,7 +249,7 @@ void CStubBodyGen::GenInterfaces(std::ofstream& stream) {
 
 void CStubBodyGen::GenInterface(std::ofstream& stream, const Interface& iface) {
   bool has_delegate = false;
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
       continue;
 
@@ -257,7 +257,7 @@ void CStubBodyGen::GenInterface(std::ofstream& stream, const Interface& iface) {
     has_delegate = true;
   }
 
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
 
@@ -287,7 +287,7 @@ void CStubBodyGen::GenInterfaceContextBase(std::ofstream& stream,
 std::string CStubBodyGen::GenDelegateParams(const Interface& iface,
     const Declaration& decl) {
   std::string params;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     params += ", ";
     auto& param_type = p->GetParameterType();
     auto& type = param_type.GetBaseType();
@@ -301,7 +301,7 @@ std::string CStubBodyGen::GenDelegateParams(const Interface& iface,
 std::string CStubBodyGen::GenDelegateParamsCheck(const Interface& iface,
     const Declaration& decl) {
   std::string params_check;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     auto& param_type = p->GetParameterType();
     auto& type = param_type.GetBaseType();
     if (IsDelegateType(iface, type) ||
@@ -324,7 +324,7 @@ std::string CStubBodyGen::GenDelegateParamsCheck(const Interface& iface,
 std::string CStubBodyGen::GenDelegateParcelWrite(const Interface& iface,
     const Declaration& decl) {
   std::string code;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     std::string parcel_write_code;
     auto& param_type = p->GetParameterType();
     auto& type = param_type.GetBaseType();
@@ -384,7 +384,7 @@ void CStubBodyGen::GenInterfaceDelegateBase(std::ofstream& stream,
 std::string CStubBodyGen::GenMethodHandlerArgsDecl(const Interface& iface,
     const Declaration& decl) {
   std::string args_decl;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     auto& param_type = p->GetParameterType();
     auto& type = param_type.GetBaseType();
     args_decl += GetArgTypeString(type, iface) + p->GetID() + " = " +
@@ -408,7 +408,7 @@ std::string CStubBodyGen::GenMethodHandlerArgsDecl(const Interface& iface,
 std::string CStubBodyGen::GenMethodHandlerParcelRead(const Interface& iface,
     const Declaration& decl) {
   std::string code;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     std::string parcel_read_code;
     auto& param_type = p->GetParameterType();
     if (param_type.GetDirection() != ParameterType::Direction::IN)
@@ -461,7 +461,7 @@ std::string CStubBodyGen::GenMethodHandlerCallbackInvoke(
     code = ReplaceAll(code, "<RES_SET>", "");
 
   std::string args;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     args += ", ";
     auto& param_type = p->GetParameterType();
     if (param_type.GetDirection() != ParameterType::Direction::IN)
@@ -496,7 +496,7 @@ std::string CStubBodyGen::GenMethodHandlerParcelWrite(const Interface& iface,
   code = ReplaceAll(code, "<UPPERCASE_NAME>", name);
 
   std::string parcel_write_code;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     auto& param_type = p->GetParameterType();
     if (param_type.GetDirection() == ParameterType::Direction::IN)
       continue;
@@ -568,7 +568,7 @@ std::string CStubBodyGen::GenMethodHandlerArgsFree(const Interface& iface,
     const Declaration& decl) {
   std::string free_code;
   std::string code;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     auto& param_type = p->GetParameterType();
     auto& type = param_type.GetBaseType();
     if (IsDelegateType(iface, type) ||
@@ -643,7 +643,7 @@ void CStubBodyGen::GenInterfaceMethodHandlerBase(std::ofstream& stream,
 // @see #CB_INTERFACE_METHOD_HANDLER
 std::string CStubBodyGen::GenMethodHandlers(const Interface& iface) {
   std::string code;
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
 
@@ -690,7 +690,7 @@ void CStubBodyGen::GenInterfaceCallbackPortCheck(std::ofstream& stream,
 // @see #CB_INTERFACE_TRUSTED_SET
 std::string CStubBodyGen::GenAccessControlSet(const Interface& iface) {
   std::string code;
-  for (auto& attr : iface.GetAttributes().GetAttrs()) {
+  for (const auto& attr : iface.GetAttributes()) {
     if (attr->GetKey() == "privilege") {
       std::string privilege_add = ReplaceAll(CB_INTERFACE_PRIVILEGE_ADD, {
           { "<NAME>", iface.GetID() },
index 1eb5f67..1b3543b 100644 (file)
@@ -48,7 +48,7 @@ void CStubHeaderGen::GenInterfaceHandles(std::ofstream& stream) {
 
     auto& iface = static_cast<const Interface&>(*b);
     GenInterfaceContextHandle(stream, iface);
-    for (auto& d : iface.GetDeclarations().GetDecls()) {
+    for (const auto& d : iface.GetDeclarations()) {
       if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
         continue;
 
@@ -87,7 +87,7 @@ void CStubHeaderGen::GenInterfaceCallbacks(std::ofstream& stream) {
 
     auto& iface = static_cast<const Interface&>(*b);
     GenInterfaceCallbackBase(stream, iface);
-    for (auto& d : iface.GetDeclarations().GetDecls()) {
+    for (const auto& d : iface.GetDeclarations()) {
       if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
         continue;
 
@@ -110,7 +110,7 @@ void CStubHeaderGen::GenInterfaceCallbackBase(std::ofstream& stream,
 std::string CStubHeaderGen::GenMethodParams(const Interface& iface,
     const Declaration& decl) {
   std::string params;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     params += ", ";
     auto& param_type = p->GetParameterType();
     auto& type = param_type.GetBaseType();
@@ -148,7 +148,7 @@ void CStubHeaderGen::GenInterfaces(std::ofstream& stream) {
 void CStubHeaderGen::GenInterface(std::ofstream& stream,
     const Interface& iface) {
   GenInterfaceContextBase(stream, iface);
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
       continue;
 
@@ -172,7 +172,7 @@ void CStubHeaderGen::GenInterfaceContextBase(std::ofstream& stream,
 std::string CStubHeaderGen::GenDelegateParams(const Interface& iface,
     const Declaration& decl) {
   std::string params;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     params += ", ";
     auto& param_type = p->GetParameterType();
     auto& type = param_type.GetBaseType();
@@ -199,7 +199,7 @@ void CStubHeaderGen::GenInterfaceDelegateBase(std::ofstream& stream,
 // @see #CB_INTERFACE_METHOD_CALLBACK_DECL
 std::string CStubHeaderGen::GenMethodCallbackDecls(const Interface& iface) {
   std::string method_callback_decls;
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
 
index 77f8ad5..7f83b86 100644 (file)
@@ -92,7 +92,7 @@ void CppGeneratorBase::GenStructureForHeader(std::ofstream& stream,
       [&]()->std::string {
         std::string str;
         int n = 1;
-        for (auto& i : st.GetElements().GetElms()) {
+        for (const auto& i : st.GetElements()) {
           if (n != 1)
             str += ", ";
           str += ConvertTypeToString(i->GetType()) + " " + i->GetID();
@@ -102,7 +102,7 @@ void CppGeneratorBase::GenStructureForHeader(std::ofstream& stream,
       });
 
     stream << NLine(1);
-    for (auto& i : st.GetElements().GetElms()) {
+    for (const auto& i : st.GetElements()) {
       GenSetter(stream, *i);
       GenGetter(stream, *i);
       stream << NLine(1);
@@ -112,7 +112,7 @@ void CppGeneratorBase::GenStructureForHeader(std::ofstream& stream,
     GenTemplate(variable, stream,
       [&]()->std::string {
         std::string str;
-        for (auto& i : st.GetElements().GetElms()) {
+        for (const auto& i : st.GetElements()) {
           str += NLine(1) + Tab(1)
               + ConvertTypeToString(i->GetType()) + " "
               + i->GetID() + "_";
@@ -206,7 +206,7 @@ void CppGeneratorBase::GenStructureForBody(std::ofstream& stream,
                       "##::##($$)\n" \
                       "    : $$ {}";
 
-  for (auto& i : st.GetElements().GetElms()) {
+  for (const auto& i : st.GetElements()) {
     std::pair<std::string, std::string> p;
 
     p.first = ConvertTypeToString(i->GetType());
@@ -273,7 +273,7 @@ void CppGeneratorBase::GenSerializer(std::ofstream& stream, const Structure& st,
 
   stream << " ";
   GenBrace(stream, 0, [&]() {
-    for (auto& i : st.GetElements().GetElms()) {
+    for (const auto& i : st.GetElements()) {
       stream << AddIndent(TAB_SIZE,
           ConvertTypeToSerializer(i->GetType(),
               "param.Get" + i->GetID() + "()", "h"));
@@ -305,7 +305,7 @@ void CppGeneratorBase::GenDeSerializer(std::ofstream& stream,
 
   stream << " ";
   GenBrace(stream, 0, [&]() {
-    for (auto& i : st.GetElements().GetElms()) {
+    for (const auto& i : st.GetElements()) {
       stream << AddIndent(TAB_SIZE,
           ConvertTypeToDeserializer(i->GetType(), i->GetID(), "h"));
       stream << Tab(1) << "param.Set" << i->GetID() << "(std::move("
@@ -405,16 +405,16 @@ void CppGeneratorBase::GenListSerializer(std::ofstream& stream, bool proto) {
   for (auto& i : GetDocument().GetBlocks()) {
     if (i->GetType() == Block::TYPE_STRUCTURE) {
       const Structure& st = static_cast<const Structure&>(*i);
-      for (auto& j : st.GetElements().GetElms()) {
+      for (const auto& j : st.GetElements()) {
         auto& t = j->GetType();
         AddSerializerList(t);
       }
     } else if (i->GetType() == Block::TYPE_INTERFACE) {
       const Interface& iface = static_cast<const Interface&>(*i);
-      for (auto& j : iface.GetDeclarations().GetDecls()) {
+      for (const auto& j : iface.GetDeclarations()) {
         auto& t = j->GetType();
         AddSerializerList(t);
-        for (auto& k : j->GetParameters().GetParams()) {
+        for (const auto& k : j->GetParameters()) {
           auto& t1 = k->GetParameterType().GetBaseType();
           AddSerializerList(t1);
         }
@@ -435,7 +435,7 @@ void CppGeneratorBase::GenMethodId(std::ofstream& stream,
     int cnt = 2;
     stream << Tab(2) << "__Result = 0," << NLine(1);
     stream << Tab(2) << "__Callback = 1," << NLine(1);
-    for (auto& i : iface.GetDeclarations().GetDecls()) {
+    for (const auto& i : iface.GetDeclarations()) {
       if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
         continue;
       stream << Tab(2)
@@ -450,7 +450,7 @@ void CppGeneratorBase::GenDelegateId(std::ofstream& stream,
   stream << Tab(1) << "enum class DelegateId : int ";
   GenBrace(stream, TAB_SIZE, [&]() {
     int cnt = 1;
-    for (auto& i : iface.GetDeclarations().GetDecls()) {
+    for (const auto& i : iface.GetDeclarations()) {
         if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
           continue;
         stream << Tab(2)
@@ -468,7 +468,7 @@ void CppGeneratorBase::GenParameters(std::ofstream& stream,
 std::string CppGeneratorBase::GetParameters(const Parameters& ps) {
   bool first = true;
   std::string ret;
-  for (auto& i : ps.GetParams()) {
+  for (const auto& i : ps) {
     if (!first) {
       ret += ", ";
     }
@@ -622,7 +622,7 @@ void CppGeneratorBase::GenBodyCallbacks(std::ofstream& stream,
                                    const Interface& iface, bool is_proxy) {
   stream << ReplaceAll(CB_CALLBACK_BASE, "##", iface.GetID());
 
-  for (auto& i : iface.GetDeclarations().GetDecls()) {
+  for (const auto& i : iface.GetDeclarations()) {
     if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
           continue;
     GenBodyCallback(stream, iface, *i, is_proxy);
@@ -644,7 +644,7 @@ void CppGeneratorBase::GenBodyCallback(std::ofstream& stream,
       },
       [&]()->std::string {
         std::string m;
-        for (auto& i : decl.GetParameters().GetParams()) {
+        for (const auto& i : decl.GetParameters()) {
           auto& pt = i->GetParameterType();
           m += AddIndent(TAB_SIZE,
               GenPrivateSharingRequest(pt.GetBaseType(), i->GetID()));
@@ -664,7 +664,7 @@ void CppGeneratorBase::GenBodyCallback(std::ofstream& stream,
       [&]()->std::string {
         int cnt = 1;
         std::string ret;
-        for (auto& i : decl.GetParameters().GetParams()) {
+        for (const auto& i : decl.GetParameters()) {
           std::string v = "param" + std::to_string(cnt);
           std::string c = ConvertTypeToDeserializer(
               i->GetParameterType().GetBaseType(), v, "parcel");
@@ -674,7 +674,8 @@ void CppGeneratorBase::GenBodyCallback(std::ofstream& stream,
 
         cnt = 1;
         ret += Tab(1) + "OnReceived(";
-        for (int i = 0; i < decl.GetParameters().GetParams().size(); i++) {
+        for (auto i = decl.GetParameters().begin();
+            i != decl.GetParameters().end(); ++i) {
           if (cnt != 1) {
             ret += ", ";
           }
@@ -699,7 +700,7 @@ void CppGeneratorBase::GenHeaderCallbacks(std::ofstream& stream,
   }
   stream << CB_CALLBACK_BASE_HEADER_BACK;
 
-  for (auto& i : iface.GetDeclarations().GetDecls()) {
+  for (const auto& i : iface.GetDeclarations()) {
     if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
           continue;
     GenHeaderCallback(stream, *i, is_proxy);
index 56b9a32..ac8db10 100644 (file)
@@ -122,7 +122,7 @@ void CppProxyBodyGen::GenMethods(std::ofstream& stream,
                                  const Interface& iface) {
   auto& decls = iface.GetDeclarations();
 
-  for (auto& i : decls.GetDecls()) {
+  for (const auto& i : decls) {
     if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
 
@@ -144,7 +144,7 @@ void CppProxyBodyGen::GenInvocation(std::ofstream& stream,
          << decl.GetID() << "));" << NLine(1);
   std::string m;
   std::string l;
-  for (auto& i : decl.GetParameters().GetParams()) {
+  for (const auto& i : decl.GetParameters()) {
     auto& pt = i->GetParameterType();
     if (pt.GetDirection() == ParameterType::Direction::OUT)
       continue;
@@ -176,7 +176,7 @@ void CppProxyBodyGen::GenInvocation(std::ofstream& stream,
 
   auto parcel_read = [&]() -> std::string {
         std::string code;
-        for (auto& i : decl.GetParameters().GetParams()) {
+        for (const auto& i : decl.GetParameters()) {
           if (i->GetParameterType().GetDirection() ==
               ParameterType::Direction::IN)
           continue;
index 305cabc..05924df 100644 (file)
@@ -92,7 +92,7 @@ void CppProxyHeaderGen::GenMethods(std::ofstream& stream,
                                    const Interface& iface) {
   auto& decls = iface.GetDeclarations();
 
-  for (auto& i : decls.GetDecls()) {
+  for (const auto& i : decls) {
     if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
 
index 3e50889..6082bed 100644 (file)
@@ -110,7 +110,7 @@ void CppStubBodyGen::GenConstructor(std::ofstream& stream,
                                     const Interface& iface) {
   stream << ReplaceAll(CB_CTOR_FRONT, "##", iface.GetID());
 
-  for (auto& i : iface.GetAttributes().GetAttrs()) {
+  for (const auto& i : iface.GetAttributes()) {
     if (i->GetKey() == "privilege") {
       stream << Tab(1) << "rpc_port_stub_add_privilege(stub_, \""
              << i->GetValue() << "\");" << NLine(1);
@@ -145,7 +145,7 @@ void CppStubBodyGen::GenReceivedEvent(std::ofstream& stream,
     stream << code;
   }
 
-  for (auto& i : iface.GetDeclarations().GetDecls()) {
+  for (const auto& i : iface.GetDeclarations()) {
     if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
     stream << Tab(2) << "case static_cast<int>(MethodId::"
@@ -173,7 +173,7 @@ void CppStubBodyGen::GenInvocation(std::ofstream& stream,
   int cnt = 1;
 
   // Deserialize
-  for (auto& i : decl.GetParameters().GetParams()) {
+  for (const auto& i : decl.GetParameters()) {
     if (i->GetParameterType().GetDirection() == ParameterType::Direction::OUT) {
       cnt++;
       continue;
@@ -198,7 +198,7 @@ void CppStubBodyGen::GenInvocation(std::ofstream& stream,
   }
 
   m += "b->" + decl.GetID() + "(";
-  for (auto& i : decl.GetParameters().GetParams()) {
+  for (const auto& i : decl.GetParameters()) {
     if (cnt != 1) {
       m += ", ";
     }
@@ -229,7 +229,7 @@ void CppStubBodyGen::GenInvocation(std::ofstream& stream,
   cnt = 0;
   m = "rpc_port_parcel_write_int32(" \
       "result, static_cast<int>(MethodId::__Result));\n";
-  for (auto& i : decl.GetParameters().GetParams()) {
+  for (const auto& i : decl.GetParameters()) {
     auto& pt = i->GetParameterType();
     cnt++;
     if (pt.GetDirection() == ParameterType::Direction::IN)
index 3e6e78f..386b269 100644 (file)
@@ -104,7 +104,7 @@ void CppStubHeaderGen::GenServiceBase(std::ofstream& stream,
   stream << CB_SERVICE_BASE_FRONT;
   auto& decls = iface.GetDeclarations();
 
-  for (auto& i : decls.GetDecls()) {
+  for (const auto& i : decls) {
     if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
     if (!i->GetComments().empty())
index 2507315..bef1498 100644 (file)
@@ -66,7 +66,7 @@ void CsGeneratorBase::GenStructure(std::ofstream& stream, const Structure& st) {
 
   stream << Tab(1) <<"public sealed class " << st.GetID() << NLine(1);
   GenBrace(stream, TAB_SIZE, [&]() {
-    for (auto& i : st.GetElements().GetElms()) {
+    for (const auto& i : st.GetElements()) {
       GenTemplate(CB_PROPERTY, stream,
         [&]()->std::string {
           return ConvertTypeToString(i->GetType());
@@ -98,7 +98,7 @@ void CsGeneratorBase::GenSerializer(std::ofstream& stream,
   stream << NLine(1) << Tab(3) << "private static void Serialize(Parcel h, "
                    << st.GetID() << " param)" << NLine(1);
   GenBrace(stream, TAB_SIZE * 3, [&]() {
-    for (auto& i : st.GetElements().GetElms()) {
+    for (const auto& i : st.GetElements()) {
       auto& t = i->GetType();
       if (!t.IsUserDefinedType() && t.GetMetaType() == nullptr) {
         stream << Tab(4) << "h.Write"
@@ -117,7 +117,7 @@ void CsGeneratorBase::GenSerializer(std::ofstream& stream,
   stream << Tab(3) << "private static void Deserialize(Parcel h, "
                    << st.GetID() << " param)" << NLine(1);
   GenBrace(stream, TAB_SIZE * 3, [&]() {
-    for (auto& i : st.GetElements().GetElms()) {
+    for (const auto& i : st.GetElements()) {
       auto& t = i->GetType();
       if (!t.IsUserDefinedType() && t.GetMetaType() == nullptr) {
         stream << Tab(4) << "var " << i->GetID() << " = "
@@ -213,16 +213,16 @@ void CsGeneratorBase::GenListSerializer(std::ofstream& stream) {
   for (auto& i : GetDocument().GetBlocks()) {
     if (i->GetType() == Block::TYPE_STRUCTURE) {
       const Structure& st = static_cast<const Structure&>(*i);
-      for (auto& j : st.GetElements().GetElms()) {
+      for (const auto& j : st.GetElements()) {
         auto& t = j->GetType();
         AddSerializerList(t);
       }
     } else if (i->GetType() == Block::TYPE_INTERFACE) {
       const Interface& iface = static_cast<const Interface&>(*i);
-      for (auto& j : iface.GetDeclarations().GetDecls()) {
+      for (const auto& j : iface.GetDeclarations()) {
         auto& t = j->GetType();
         AddSerializerList(t);
-        for (auto& k : j->GetParameters().GetParams()) {
+        for (const auto& k : j->GetParameters()) {
           auto& t1 = k->GetParameterType().GetBaseType();
           AddSerializerList(t1);
         }
@@ -355,7 +355,7 @@ void CsGeneratorBase::GenMethodId(std::ofstream& stream,
     int cnt = 2;
     stream << Tab(4) << "__Result = 0," << NLine(1);
     stream << Tab(4) << "__Callback = 1," << NLine(1);
-    for (auto& i : iface.GetDeclarations().GetDecls()) {
+    for (const auto& i : iface.GetDeclarations()) {
       if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
         continue;
       stream << Tab(4)
@@ -369,7 +369,7 @@ void CsGeneratorBase::GenDelegateId(std::ofstream& stream,
   stream << Tab(3) << "private enum DelegateId : int" << NLine(1);
   GenBrace(stream, TAB_SIZE * 3, [&]() {
     int cnt = 1;
-    for (auto& i : iface.GetDeclarations().GetDecls()) {
+    for (const auto& i : iface.GetDeclarations()) {
         if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
           continue;
         stream << Tab(4)
@@ -398,7 +398,7 @@ void CsGeneratorBase::GenParameters(std::ofstream& stream,
 std::string CsGeneratorBase::GetParameters(const Parameters& ps) {
   bool first = true;
   std::string ret;
-  for (auto& i : ps.GetParams()) {
+  for (const auto& i : ps) {
     if (!first) {
       ret += ", ";
     }
@@ -422,7 +422,7 @@ void CsGeneratorBase::GenCallbacks(std::ofstream& stream,
                                    const Interface& iface, bool is_proxy) {
   stream << CB_CALLBACK_BASE;
 
-  for (auto& i : iface.GetDeclarations().GetDecls()) {
+  for (const auto& i : iface.GetDeclarations()) {
     if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
           continue;
     GenCallback(stream, *i, iface.GetID(), is_proxy);
@@ -466,7 +466,7 @@ void CsGeneratorBase::GenReceivedEvent(std::ofstream& stream,
          << NLine(1);
   GenBrace(stream, TAB_SIZE * 4, [&]() {
     int cnt = 1;
-    for (auto& i : decl.GetParameters().GetParams()) {
+    for (const auto& i : decl.GetParameters()) {
       std::string v = "param" + std::to_string(cnt);
       std::string c = ConvertTypeToDeserializer(
           i->GetParameterType().GetBaseType(), v, "parcel", true, id);
@@ -476,7 +476,8 @@ void CsGeneratorBase::GenReceivedEvent(std::ofstream& stream,
 
     cnt = 1;
     stream << Tab(5) << "Received?.Invoke(";
-    for (int i = 0; i < decl.GetParameters().GetParams().size(); i++) {
+    for (auto i = decl.GetParameters().begin();
+            i != decl.GetParameters().end(); ++i) {
       if (cnt != 1) {
         stream << ", ";
       }
@@ -498,7 +499,7 @@ void CsGeneratorBase::GenInvokeMethod(std::ofstream& stream,
       },
       [&]()->std::string {
         std::string m;
-        for (auto& i : decl.GetParameters().GetParams()) {
+        for (const auto& i : decl.GetParameters()) {
           auto& pt = i->GetParameterType();
           m += ConvertTypeToSerializer(pt.GetBaseType(), i->GetID(), "p", id);
         }
index 8d8d88c..790f520 100644 (file)
@@ -104,7 +104,7 @@ void CsProxyGen::GenConnectMethod(std::ofstream& stream,
 void CsProxyGen::GenMethods(std::ofstream& stream, const Interface& iface) {
   auto& decls = iface.GetDeclarations();
 
-  for (auto& i : decls.GetDecls()) {
+  for (const auto& i : decls) {
     if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
 
@@ -125,7 +125,7 @@ void CsProxyGen::GenInvocation(std::ofstream& stream, const Declaration& decl) {
   GenTemplate(CB_INVOCATION_PRE, stream,
     [&]()->std::string {
       std::string st;
-      for (auto& i : decl.GetParameters().GetParams()) {
+      for (const auto& i : decl.GetParameters()) {
         auto& pt = i->GetParameterType();
         if (pt.GetDirection() == ParameterType::Direction::OUT)
           continue;
@@ -145,7 +145,7 @@ void CsProxyGen::GenInvocation(std::ofstream& stream, const Declaration& decl) {
          + "p.WriteInt((int)MethodId." + decl.GetID() + ");" + NLine(1);
       std::string m;
       std::string l;
-      for (auto& i : decl.GetParameters().GetParams()) {
+      for (const auto& i : decl.GetParameters()) {
         auto& pt = i->GetParameterType();
         if (pt.GetDirection() == ParameterType::Direction::OUT)
           continue;
@@ -173,7 +173,7 @@ void CsProxyGen::GenInvocation(std::ofstream& stream, const Declaration& decl) {
       st += NLine(1) + AddIndent(TAB_SIZE * 5, CB_INVOCATION_RECEIVE);
       st += NLine(1);
 
-      for (auto& i : decl.GetParameters().GetParams()) {
+      for (const auto& i : decl.GetParameters()) {
         if (i->GetParameterType().GetDirection() ==
             ParameterType::Direction::IN) {
           continue;
index 5cf40fd..fe57d41 100644 (file)
@@ -90,7 +90,7 @@ void CsStubGen::GenServiceBase(std::ofstream& stream, const Interface& iface) {
 
 void CsStubGen::GenDeclarations(std::ofstream& stream,
                                 const Declarations& decls) {
-  for (auto& i : decls.GetDecls()) {
+  for (const auto& i : decls) {
     if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
     if (!i->GetComments().empty())
@@ -104,7 +104,7 @@ void CsStubGen::GenDeclarations(std::ofstream& stream,
 void CsStubGen::GenReceivedEvent(std::ofstream& stream,
     const Interface& iface) {
   stream << CB_ON_RECEIVED_EVENT_FRONT;
-  for (auto& i : iface.GetDeclarations().GetDecls()) {
+  for (const auto& i : iface.GetDeclarations()) {
     if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
     stream << Tab(7) << "case MethodId." << i->GetID() << ":" << NLine(1);
@@ -120,7 +120,7 @@ void CsStubGen::GenInvocation(std::ofstream& stream, const Declaration& decl) {
   int cnt = 1;
 
   // Deserialize
-  for (auto& i : decl.GetParameters().GetParams()) {
+  for (const auto& i : decl.GetParameters()) {
     if (i->GetParameterType().GetDirection() == ParameterType::Direction::OUT) {
       cnt++;
       continue;
@@ -144,7 +144,7 @@ void CsStubGen::GenInvocation(std::ofstream& stream, const Declaration& decl) {
   }
 
   m += "b." + decl.GetID() + "(";
-  for (auto& i : decl.GetParameters().GetParams()) {
+  for (const auto& i : decl.GetParameters()) {
     if (cnt != 1) {
       m += ", ";
     }
@@ -169,7 +169,7 @@ void CsStubGen::GenInvocation(std::ofstream& stream, const Declaration& decl) {
 
   cnt = 0;
   m = CB_INVOCATION_RESULT_PRE;
-  for (auto& i : decl.GetParameters().GetParams()) {
+  for (const auto& i : decl.GetParameters()) {
     auto& pt = i->GetParameterType();
     cnt++;
     if (pt.GetDirection() == ParameterType::Direction::IN)
@@ -203,7 +203,7 @@ void CsStubGen::GenCtor(std::ofstream& stream, const Interface& iface) {
       return iface.GetID();
     });
 
-  for (auto& i : iface.GetAttributes().GetAttrs()) {
+  for (const auto& i : iface.GetAttributes()) {
     if (i->GetKey() == "privilege") {
       stream << Tab(4) << "AddPrivilege(\""
              << i->GetValue() << "\");" << NLine(1);
index 790ff22..9e541a0 100644 (file)
@@ -121,7 +121,7 @@ bool Generator::IsDelegateType(const BaseType& type) {
 
 bool Generator::IsDelegateType(const Interface& inf,
                                const BaseType& type) {
-  for (auto& i : inf.GetDeclarations().GetDecls()) {
+  for (const auto& i : inf.GetDeclarations()) {
     if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
       continue;
     if (i->GetID() == type.ToString())
index 5fde939..c44192f 100644 (file)
@@ -43,14 +43,14 @@ CCionBodyGeneratorBase::CCionBodyGeneratorBase(std::shared_ptr<Document> doc)
   for (auto& b : GetDocument().GetBlocks()) {
     if (b->GetType() == Block::TYPE_STRUCTURE) {
       auto& st = static_cast<const Structure&>(*b);
-      for (auto& e : st.GetElements().GetElms()) {
+      for (const auto& e : st.GetElements()) {
         auto& type = e->GetType();
         AddStructureFromType(type);
       }
     } else {
       auto& iface = static_cast<const Interface&>(*b);
-      for (auto& d : iface.GetDeclarations().GetDecls()) {
-        for (auto& p : d->GetParameters().GetParams()) {
+      for (const auto& d : iface.GetDeclarations()) {
+        for (const auto& p : d->GetParameters()) {
           auto& type = p->GetParameterType().GetBaseType();
           if (IsDelegateType(iface, type))
             continue;
@@ -122,7 +122,7 @@ void CCionBodyGeneratorBase::GenStructureArrayDef(std::ofstream& stream,
       GetHandlePrefix());
   code = ReplaceAll(code, "<NAME>", st.GetID());
 
-  auto& elm = st.GetElements().GetElms().front();
+  auto& elm = *(st.GetElements().begin());
   auto& type = elm->GetType();
   auto element_type = GetDataTypeString(type, false);
   code = ReplaceAll(code, "<ELEMENT_TYPE>", element_type);
@@ -259,7 +259,7 @@ void CCionBodyGeneratorBase::GenStructureArrayBase(std::ofstream& stream,
       GetHandlePrefix());
   code = ReplaceAll(code, "<NAME>", st.GetID());
 
-  auto& elm = st.GetElements().GetElms().front();
+  auto& elm = *(st.GetElements().begin());
   code = ReplaceAll(code, "<PARCEL_WRITE>", GenArrayParcelWrite(elm));
   code = ReplaceAll(code, "<PARCEL_READ>", GenArrayParcelRead(elm));
 
@@ -408,7 +408,7 @@ void CCionBodyGeneratorBase::GenStructureListBase(std::ofstream& stream,
       GetHandlePrefix());
   code = ReplaceAll(code, "<NAME>", st.GetID());
 
-  auto& elm = st.GetElements().GetElms().front();
+  auto& elm = *(st.GetElements().begin());
   auto& type = elm->GetType();
   code = ReplaceAll(code, "<DATA_TYPE>", GetDataTypeString(type, true));
   code = ReplaceAll(code, "<DATA_FREE>", GenListDataFree(elm));
@@ -428,7 +428,7 @@ void CCionBodyGeneratorBase::GenStructureListBase(std::ofstream& stream,
 
 std::string CCionBodyGeneratorBase::GenBaseElements(const Elements& elms) {
   std::string code;
-  for (auto& elm : elms.GetElms()) {
+  for (const auto& elm : elms) {
     auto& type = elm->GetType();
     auto param_type = GetDataTypeString(type, false);
     code += param_type + elm->GetID() + ";";
@@ -465,7 +465,7 @@ std::string CCionBodyGeneratorBase::GenBaseElementFree(
 
 std::string CCionBodyGeneratorBase::GenBaseElementsFree(const Elements& elms) {
   std::string code;
-  for (auto& elm : elms.GetElms())
+  for (const auto& elm : elms)
     code += GenBaseElementFree(elm);
 
   return RemoveLine(code);
@@ -477,7 +477,7 @@ std::string CCionBodyGeneratorBase::GenBaseElementsFree(const Elements& elms) {
 // @see #CB_STRUCTURE_BASE_BASE_PARCEL_WRITE
 std::string CCionBodyGeneratorBase::GenBaseParcelWrite(const Elements& elms) {
   std::string code;
-  for (auto& elm : elms.GetElms()) {
+  for (const auto& elm : elms) {
     std::string parcel_write_code;
     auto& type = elm->GetType();
     if (type.IsUserDefinedType() ||
@@ -511,7 +511,7 @@ std::string CCionBodyGeneratorBase::GenBaseParcelWrite(const Elements& elms) {
 // @see #CB_STRUCTURE_BASE_BASE_PARCEL_READ
 std::string CCionBodyGeneratorBase::GenBaseParcelRead(const Elements& elms) {
   std::string code;
-  for (auto& elm : elms.GetElms()) {
+  for (const auto& elm : elms) {
     std::string parcel_read_code;
     auto& type = elm->GetType();
     if (type.IsUserDefinedType() ||
@@ -612,7 +612,7 @@ std::string CCionBodyGeneratorBase::GenBaseGet(
 std::string CCionBodyGeneratorBase::GenBaseSetGet(const std::string& name,
     const Elements& elms) {
   std::string code;
-  for (auto& elm : elms.GetElms()) {
+  for (const auto& elm : elms) {
     std::string set_get_code = ReplaceAll(CB_STRUCTURE_BASE_SET_GET,
         "<PREFIX>", GetHandlePrefix());
     set_get_code = ReplaceAll(set_get_code, "<NAME>", name);
@@ -663,11 +663,11 @@ const std::string& CCionBodyGeneratorBase::GetParcelType(const BaseType& type) {
 
 
 bool CCionBodyGeneratorBase::HasListFile(const Interface& iface) {
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     if (IsProxy() && d->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
 
-    for (auto& p : d->GetParameters().GetParams()) {
+    for (const auto& p : d->GetParameters()) {
       auto& param_type = p->GetParameterType();
       auto& type = param_type.GetBaseType();
       auto name = GetFullNameFromType(type, iface);
@@ -680,8 +680,8 @@ bool CCionBodyGeneratorBase::HasListFile(const Interface& iface) {
 }
 
 bool CCionBodyGeneratorBase::HasFile(const Interface& iface) {
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
-    for (auto& p : d->GetParameters().GetParams()) {
+  for (const auto& d : iface.GetDeclarations()) {
+    for (const auto& p : d->GetParameters()) {
       auto& param_type = p->GetParameterType();
       auto& type = param_type.GetBaseType();
       auto name = GetFullNameFromType(type, iface);
@@ -708,7 +708,7 @@ CCionBodyGeneratorBase::FileParamType CCionBodyGeneratorBase::HasFile(const Inte
 }
 
 CCionBodyGeneratorBase::FileParamType CCionBodyGeneratorBase::HasFile(const Interface& iface, const Declaration& decl, bool is_proxy) {
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     auto& param_type = p->GetParameterType();
     if (is_proxy) {
       if (param_type.GetDirection() != ParameterType::Direction::IN)
@@ -741,7 +741,7 @@ void CCionBodyGeneratorBase::GenFilePayloadSend(std::ofstream& stream, bool is_p
       continue;
 
     auto& iface = static_cast<const Interface&>(*i);
-    for (auto& d : iface.GetDeclarations().GetDecls()) {
+    for (const auto& d : iface.GetDeclarations()) {
        param_type = HasFile(iface, *d, is_proxy);
        if (param_type != NotExist)
          break;
@@ -846,7 +846,7 @@ std::string CCionBodyGeneratorBase::GetFilePayloadSendString(const Interface& if
 std::string CCionBodyGeneratorBase::GenSecurityString(const Interface& iface) {
   std::string security_path;
 
-  for (auto& attr : iface.GetAttributes().GetAttrs()) {
+  for (const auto& attr : iface.GetAttributes()) {
     if (attr->GetKey() == "ca_path")
       security_path += ReplaceAll(CB_INTERFACE_SECURITY_CA, "<ARG>", attr->GetValue());
     else if (attr->GetKey() == "cert_path")
index d03bea4..a639349 100644 (file)
@@ -136,12 +136,12 @@ void CCionGeneratorBase::AddStructureFromType(const BaseType& type) {
   assert(t != nullptr);
 
   std::string type_name = GetFullNameFromType(type);
-  Element* elm = new Element(type_name, t, "", __LINE__);
+  auto elm = std::unique_ptr<Element>(new Element(type_name, t, "", __LINE__));
   assert(elm != nullptr);
 
   Elements* elms = new Elements();
   assert(elms != nullptr);
-  elms->Add(elm);
+  elms->Add(std::move(elm));
 
   auto* st = new Structure(type_name, elms, "", __LINE__);
   assert(st != nullptr);
@@ -170,12 +170,12 @@ void CCionGeneratorBase::AddStructureFromType(const BaseType& type,
   assert(t != nullptr);
 
   std::string type_name = GetFullNameFromType(type, iface);
-  Element* elm = new Element(type_name, t, "", __LINE__);
+  auto elm = std::unique_ptr<Element>(new Element(type_name, t, "", __LINE__));
   assert(elm != nullptr);
 
   Elements* elms = new Elements();
   assert(elms != nullptr);
-  elms->Add(elm);
+  elms->Add(std::move(elm));
 
   auto* st = new Structure(type_name, elms, "", __LINE__);
   assert(st != nullptr);
index 6e8e759..9df250e 100644 (file)
@@ -31,14 +31,14 @@ CCionHeaderGeneratorBase::CCionHeaderGeneratorBase(std::shared_ptr<Document> doc
   for (auto& b : GetDocument().GetBlocks()) {
     if (b->GetType() == Block::TYPE_STRUCTURE) {
       auto& st = static_cast<const Structure&>(*b);
-      for (auto& e : st.GetElements().GetElms()) {
+      for (const auto& e : st.GetElements()) {
         auto& type = e->GetType();
         AddStructureFromType(type);
       }
     } else {
       auto& iface = static_cast<const Interface&>(*b);
-      for (auto& d : iface.GetDeclarations().GetDecls()) {
-        for (auto& p : d->GetParameters().GetParams()) {
+      for (const auto& d : iface.GetDeclarations()) {
+        for (const auto& p : d->GetParameters()) {
           auto& type = p->GetParameterType().GetBaseType();
           if (IsDelegateType(iface, type))
             continue;
@@ -114,7 +114,7 @@ void CCionHeaderGeneratorBase::GenStructureArrayBase(std::ofstream& stream,
       GetHandlePrefix());
   str = ReplaceAll(str, "<NAME>", st.GetID());
 
-  auto& elm = st.GetElements().GetElms().front();
+  auto& elm = *(st.GetElements().begin());
   auto& type = elm->GetType();
   auto param_type = GetParamTypeString(ParameterType::Direction::IN, type);
   str = ReplaceAll(str, "<PARAM_TYPE_IN>", param_type);
@@ -132,7 +132,7 @@ void CCionHeaderGeneratorBase::GenStructureListBase(std::ofstream& stream,
       GetHandlePrefix());
   str = ReplaceAll(str, "<NAME>", st.GetID());
 
-  auto& elm = st.GetElements().GetElms().front();
+  auto& elm = *(st.GetElements().begin());
   auto& type = elm->GetType();
   auto param_type = GetParamTypeString(ParameterType::Direction::IN, type);
   str = ReplaceAll(str, "<PARAM_TYPE_IN>", param_type);
@@ -147,7 +147,7 @@ void CCionHeaderGeneratorBase::GenStructureBase(std::ofstream& stream,
   str = ReplaceAll(str, "<NAME>", st.GetID());
   stream << SmartIndent(str);
 
-  for (auto& e : st.GetElements().GetElms()) {
+  for (const auto& e : st.GetElements()) {
     str = ReplaceAll(CB_STRUCTURE_BASE_SET_GET, "<PREFIX>", GetHandlePrefix());
     str = ReplaceAll(str, "<NAME>", st.GetID());
 
index 07196d8..2b77f9e 100644 (file)
@@ -63,7 +63,7 @@ void CCionProxyBodyGen::GenInterfaceDefs(std::ofstream& stream) {
 
 void CCionProxyBodyGen::GenInterfaceDef(std::ofstream& stream,
     const Interface& iface) {
-   for (auto& d : iface.GetDeclarations().GetDecls()) {
+   for (const auto& d : iface.GetDeclarations()) {
     if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
       continue;
 
@@ -107,7 +107,7 @@ void CCionProxyBodyGen::GenInterfaces(std::ofstream& stream) {
 void CCionProxyBodyGen::GenInterface(std::ofstream& stream, const Interface& iface) {
   GenInterfaceDelegateEnumBase(stream, iface);
 
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
       continue;
 
@@ -118,7 +118,7 @@ void CCionProxyBodyGen::GenInterface(std::ofstream& stream, const Interface& ifa
   GenInterfaceMethodEnumBase(stream, iface);
   GenInterfaceBase(stream, iface);
 
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
 
@@ -148,7 +148,7 @@ void CCionProxyBodyGen::GenInterfaceDelegateEnumBase(std::ofstream& stream,
     const Interface& iface) {
   unsigned int num = 1;
   std::string enums;
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
       continue;
 
@@ -172,7 +172,7 @@ void CCionProxyBodyGen::GenInterfaceDelegateEnumBase(std::ofstream& stream,
 std::string CCionProxyBodyGen::GenDelegateArgsDecl(const Interface& iface,
     const Declaration& decl) {
   std::string code;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     auto& param_type = p->GetParameterType();
     auto& type = param_type.GetBaseType();
     code += GetArgTypeString(type, iface) + p->GetID() + " = " +
@@ -189,7 +189,7 @@ std::string CCionProxyBodyGen::GenDelegateArgsDecl(const Interface& iface,
 std::string CCionProxyBodyGen::GenDelegateParcelRead(const Interface& iface,
     const Declaration& decl) {
   std::string code;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     std::string param_read_code;
     auto& param_type = p->GetParameterType();
     auto& type = param_type.GetBaseType();
@@ -228,7 +228,7 @@ std::string CCionProxyBodyGen::GenDelegateParcelRead(const Interface& iface,
 std::string CCionProxyBodyGen::GenDelegateArgsFree(const Interface& iface,
     const Declaration& decl, bool& has_free) {
   std::string code;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     std::string param_free_code;
     auto& param_type = p->GetParameterType();
     auto& type = param_type.GetBaseType();
@@ -262,7 +262,7 @@ std::string CCionProxyBodyGen::GenDelegateArgsFree(const Interface& iface,
 
 std::string CCionProxyBodyGen::GenDelegateCallbackArgs(const Declaration& decl) {
   std::string code;
-  for (auto& p : decl.GetParameters().GetParams())
+  for (const auto& p : decl.GetParameters())
     code += ", " + p->GetID();
 
   return code;
@@ -301,7 +301,7 @@ void CCionProxyBodyGen::GenInterfaceDelegateBase(std::ofstream& stream,
 void CCionProxyBodyGen::GenInterfaceDelegateTable(std::ofstream& stream,
     const Interface& iface) {
   std::string delegate_handlers;
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
       continue;
 
@@ -339,7 +339,7 @@ void CCionProxyBodyGen::GenInterfaceMethodEnumBase(std::ofstream& stream,
   enums += GetHandlePrefix() + "_" + iface.GetID() + "_METHOD_CALLBACK_,";
   enums += NLine(1);
 
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
 
@@ -361,7 +361,7 @@ void CCionProxyBodyGen::GenInterfaceMethodEnumBase(std::ofstream& stream,
 std::string CCionProxyBodyGen::GenMethodParams(const Interface& iface,
     const Declaration& decl) {
   std::string params;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     params += ", ";
     auto& param_type = p->GetParameterType();
     auto& type = param_type.GetBaseType();
@@ -375,7 +375,7 @@ std::string CCionProxyBodyGen::GenMethodParams(const Interface& iface,
 std::string CCionProxyBodyGen::GenMethodParamsCheck(const Interface& iface,
     const Declaration& decl) {
   std::string params_check;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     auto& param_type = p->GetParameterType();
     auto& type = param_type.GetBaseType();
     if (IsDelegateType(iface, type) ||
@@ -401,7 +401,7 @@ std::string CCionProxyBodyGen::GenMethodParamsCheck(const Interface& iface,
 std::string CCionProxyBodyGen::GenMethodParcelWrite(const Interface& iface,
     const Declaration& decl) {
   std::string code;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     auto& param_type = p->GetParameterType();
     if (param_type.GetDirection() != ParameterType::Direction::IN)
       continue;
@@ -444,7 +444,7 @@ std::string CCionProxyBodyGen::GenMethodParcelWrite(const Interface& iface,
 std::string CCionProxyBodyGen::GenMethodDelegateAppend(const Interface& iface,
     const Declaration& decl) {
   std::string code;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     auto& param_type = p->GetParameterType();
     auto& type = param_type.GetBaseType();
     if (IsDelegateType(iface, type)) {
@@ -494,7 +494,7 @@ std::string CCionProxyBodyGen::GenMethodAsyncBase(const Interface& iface,
 std::string CCionProxyBodyGen::GenMethodArgs(const Interface& iface,
     const Declaration& decl) {
   std::string args_code;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     auto& param_type = p->GetParameterType();
     if (param_type.GetDirection() != ParameterType::Direction::OUT)
       continue;
@@ -545,7 +545,7 @@ std::string CCionProxyBodyGen::GenMethodParcelRead(const Interface& iface,
     const Declaration& decl) {
   std::string code;
   std::string parcel_read_code;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     auto& param_type = p->GetParameterType();
     if (param_type.GetDirection() != ParameterType::Direction::OUT)
       continue;
index 90d8a43..21bd773 100644 (file)
@@ -48,7 +48,7 @@ void CCionProxyHeaderGen::GenInterfaceHandles(std::ofstream& stream) {
 
     auto& iface = static_cast<const Interface&>(*b);
     GenInterfaceHandle(stream, iface);
-    for (auto& d : iface.GetDeclarations().GetDecls()) {
+    for (const auto& d : iface.GetDeclarations()) {
       if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
         continue;
 
@@ -90,7 +90,7 @@ void CCionProxyHeaderGen::GenInterfaces(std::ofstream& stream) {
 
 void CCionProxyHeaderGen::GenInterface(std::ofstream& stream,
     const Interface& iface) {
-  for (auto& d: iface.GetDeclarations().GetDecls()) {
+  for (const auto& d: iface.GetDeclarations()) {
     if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
       continue;
 
@@ -99,7 +99,7 @@ void CCionProxyHeaderGen::GenInterface(std::ofstream& stream,
 
   GenInterfaceBase(stream, iface);
 
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
 
@@ -120,7 +120,7 @@ void CCionProxyHeaderGen::GenInterfaceBase(std::ofstream& stream,
 std::string CCionProxyHeaderGen::GenDelegateParams(const Interface& iface,
     const Declaration& decl) {
   std::string params;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     params += ", ";
     auto& param_type = p->GetParameterType();
     auto& type = param_type.GetBaseType();
@@ -146,7 +146,7 @@ void CCionProxyHeaderGen::GenInterfaceDelegateBase(std::ofstream& stream,
 std::string CCionProxyHeaderGen::GenMethodParams(const Interface& iface,
     const Declaration& decl) {
   std::string params;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     params += ", ";
     auto& param_type = p->GetParameterType();
     auto& type = param_type.GetBaseType();
index 59da93a..af8494b 100644 (file)
@@ -90,7 +90,7 @@ std::string CCionStubBodyGen::GenMethodEnums(const Interface& iface) {
   method_enum = ReplaceAll(method_enum, "<UPPERCASE_METHOD_NAME>", "CALLBACK_");
   method_enums += RemoveLine(method_enum);
 
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
 
@@ -123,7 +123,7 @@ void CCionStubBodyGen::GenInterfaceMethodEnumBase(std::ofstream& stream,
 std::string CCionStubBodyGen::GenDelegateEnums(const Interface& iface) {
   unsigned int num = 1;
   std::string method_enums;
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
       continue;
 
@@ -169,7 +169,7 @@ void CCionStubBodyGen::GenInterfaceDefs(std::ofstream& stream) {
 
 void CCionStubBodyGen::GenInterfaceDef(std::ofstream& stream,
     const Interface& iface) {
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
       continue;
 
@@ -211,14 +211,14 @@ void CCionStubBodyGen::GenInterfaces(std::ofstream& stream) {
 }
 
 void CCionStubBodyGen::GenInterface(std::ofstream& stream, const Interface& iface) {
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
       continue;
 
     GenInterfaceDelegateBase(stream, iface, *d);
   }
 
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
 
@@ -243,7 +243,7 @@ void CCionStubBodyGen::GenInterfaceContextBase(std::ofstream& stream,
 std::string CCionStubBodyGen::GenDelegateParams(const Interface& iface,
     const Declaration& decl) {
   std::string params;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     params += ", ";
     auto& param_type = p->GetParameterType();
     auto& type = param_type.GetBaseType();
@@ -257,7 +257,7 @@ std::string CCionStubBodyGen::GenDelegateParams(const Interface& iface,
 std::string CCionStubBodyGen::GenDelegateParamsCheck(const Interface& iface,
     const Declaration& decl) {
   std::string params_check;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     auto& param_type = p->GetParameterType();
     auto& type = param_type.GetBaseType();
     if (IsDelegateType(iface, type) ||
@@ -280,7 +280,7 @@ std::string CCionStubBodyGen::GenDelegateParamsCheck(const Interface& iface,
 std::string CCionStubBodyGen::GenDelegateParcelWrite(const Interface& iface,
     const Declaration& decl) {
   std::string code;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     std::string parcel_write_code;
     auto& param_type = p->GetParameterType();
     auto& type = param_type.GetBaseType();
@@ -348,7 +348,7 @@ void CCionStubBodyGen::GenInterfaceDelegateBase(std::ofstream& stream,
 std::string CCionStubBodyGen::GenMethodHandlerArgsDecl(const Interface& iface,
     const Declaration& decl) {
   std::string args_decl;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     auto& param_type = p->GetParameterType();
     auto& type = param_type.GetBaseType();
     args_decl += GetArgTypeString(type, iface) + p->GetID() + " = " +
@@ -372,7 +372,7 @@ std::string CCionStubBodyGen::GenMethodHandlerArgsDecl(const Interface& iface,
 std::string CCionStubBodyGen::GenMethodHandlerParcelRead(const Interface& iface,
     const Declaration& decl) {
   std::string code;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     std::string parcel_read_code;
     auto& param_type = p->GetParameterType();
     if (param_type.GetDirection() != ParameterType::Direction::IN)
@@ -425,7 +425,7 @@ std::string CCionStubBodyGen::GenMethodHandlerCallbackInvoke(
     code = ReplaceAll(code, "<RES_SET>", "");
 
   std::string args;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     args += ", ";
     auto& param_type = p->GetParameterType();
     if (param_type.GetDirection() != ParameterType::Direction::IN)
@@ -461,7 +461,7 @@ std::string CCionStubBodyGen::GenMethodHandlerParcelWrite(const Interface& iface
       name);
 
   std::string parcel_write_code;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     auto& param_type = p->GetParameterType();
     if (param_type.GetDirection() == ParameterType::Direction::IN)
       continue;
@@ -531,7 +531,7 @@ std::string CCionStubBodyGen::GenMethodHandlerArgsFree(const Interface& iface,
     const Declaration& decl) {
   std::string free_code;
   std::string code;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     auto& param_type = p->GetParameterType();
     auto& type = param_type.GetBaseType();
     if (IsDelegateType(iface, type) ||
@@ -613,7 +613,7 @@ void CCionStubBodyGen::GenInterfaceMethodHandlerBase(std::ofstream& stream,
 // @see #CB_INTERFACE_METHOD_HANDLER
 std::string CCionStubBodyGen::GenMethodHandlers(const Interface& iface) {
   std::string code;
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
 
index 033ff56..7452baf 100644 (file)
@@ -46,7 +46,7 @@ void CCionStubHeaderGen::GenInterfaceHandles(std::ofstream& stream) {
       continue;
 
     auto& iface = static_cast<const Interface&>(*b);
-    for (auto& d : iface.GetDeclarations().GetDecls()) {
+    for (const auto& d : iface.GetDeclarations()) {
       if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
         continue;
       GenInterfaceDelegateHandle(stream, iface, *d);
@@ -72,7 +72,7 @@ void CCionStubHeaderGen::GenInterfaceCallbacks(std::ofstream& stream) {
 
     auto& iface = static_cast<const Interface&>(*b);
     GenInterfaceCallbackBase(stream, iface);
-    for (auto& d : iface.GetDeclarations().GetDecls()) {
+    for (const auto& d : iface.GetDeclarations()) {
       if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
         continue;
 
@@ -94,7 +94,7 @@ void CCionStubHeaderGen::GenInterfaceCallbackBase(std::ofstream& stream,
 std::string CCionStubHeaderGen::GenMethodParams(const Interface& iface,
     const Declaration& decl) {
   std::string params;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     params += ", ";
     auto& param_type = p->GetParameterType();
     auto& type = param_type.GetBaseType();
@@ -130,7 +130,7 @@ void CCionStubHeaderGen::GenInterfaces(std::ofstream& stream) {
 
 void CCionStubHeaderGen::GenInterface(std::ofstream& stream,
     const Interface& iface) {
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
       continue;
 
@@ -142,7 +142,7 @@ void CCionStubHeaderGen::GenInterface(std::ofstream& stream,
 std::string CCionStubHeaderGen::GenDelegateParams(const Interface& iface,
     const Declaration& decl) {
   std::string params;
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     params += ", ";
     auto& param_type = p->GetParameterType();
     auto& type = param_type.GetBaseType();
@@ -168,7 +168,7 @@ void CCionStubHeaderGen::GenInterfaceDelegateBase(std::ofstream& stream,
 // @see #CB_INTERFACE_METHOD_CALLBACK_DECL
 std::string CCionStubHeaderGen::GenMethodCallbackDecls(const Interface& iface) {
   std::string method_callback_decls;
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
 
index ebba91f..de424ff 100644 (file)
@@ -92,7 +92,7 @@ void CppCionGeneratorBase::GenStructureForHeader(std::ofstream& stream,
       [&]()->std::string {
         std::string str;
         int n = 1;
-        for (auto& i : st.GetElements().GetElms()) {
+        for (const auto& i : st.GetElements()) {
           if (n != 1)
             str += ", ";
           str += ConvertTypeToString(i->GetType()) + " " + i->GetID();
@@ -102,7 +102,7 @@ void CppCionGeneratorBase::GenStructureForHeader(std::ofstream& stream,
       });
 
     stream << NLine(1);
-    for (auto& i : st.GetElements().GetElms()) {
+    for (const auto& i : st.GetElements()) {
       GenSetter(stream, *i);
       GenGetter(stream, *i);
       stream << NLine(1);
@@ -112,7 +112,7 @@ void CppCionGeneratorBase::GenStructureForHeader(std::ofstream& stream,
     GenTemplate(variable, stream,
       [&]()->std::string {
         std::string str;
-        for (auto& i : st.GetElements().GetElms()) {
+        for (const auto& i : st.GetElements()) {
           str += NLine(1) + Tab(1)
               + ConvertTypeToString(i->GetType()) + " "
               + i->GetID() + "_";
@@ -206,7 +206,7 @@ void CppCionGeneratorBase::GenStructureForBody(std::ofstream& stream,
                       "##::##($$)\n" \
                       "    : $$ {}";
 
-  for (auto& i : st.GetElements().GetElms()) {
+  for (const auto& i : st.GetElements()) {
     std::pair<std::string, std::string> p;
 
     p.first = ConvertTypeToString(i->GetType());
@@ -273,7 +273,7 @@ void CppCionGeneratorBase::GenSerializer(std::ofstream& stream, const Structure&
 
   stream << " ";
   GenBrace(stream, 0, [&]() {
-    for (auto& i : st.GetElements().GetElms()) {
+    for (const auto& i : st.GetElements()) {
       stream << AddIndent(TAB_SIZE,
           ConvertTypeToSerializer(i->GetType(),
               "param.Get" + i->GetID() + "()", "h"));
@@ -305,7 +305,7 @@ void CppCionGeneratorBase::GenDeSerializer(std::ofstream& stream,
 
   stream << " ";
   GenBrace(stream, 0, [&]() {
-    for (auto& i : st.GetElements().GetElms()) {
+    for (const auto& i : st.GetElements()) {
       stream << AddIndent(TAB_SIZE,
           ConvertTypeToDeserializer(i->GetType(), i->GetID(), "h"));
       stream << Tab(1) << "param.Set" << i->GetID() << "(std::move("
@@ -402,16 +402,16 @@ void CppCionGeneratorBase::GenListSerializer(std::ofstream& stream, bool proto)
   for (auto& i : GetDocument().GetBlocks()) {
     if (i->GetType() == Block::TYPE_STRUCTURE) {
       const Structure& st = static_cast<const Structure&>(*i);
-      for (auto& j : st.GetElements().GetElms()) {
+      for (const auto& j : st.GetElements()) {
         auto& t = j->GetType();
         AddSerializerList(t);
       }
     } else if (i->GetType() == Block::TYPE_INTERFACE) {
       const Interface& iface = static_cast<const Interface&>(*i);
-      for (auto& j : iface.GetDeclarations().GetDecls()) {
+      for (const auto& j : iface.GetDeclarations()) {
         auto& t = j->GetType();
         AddSerializerList(t);
-        for (auto& k : j->GetParameters().GetParams()) {
+        for (const auto& k : j->GetParameters()) {
           auto& t1 = k->GetParameterType().GetBaseType();
           AddSerializerList(t1);
         }
@@ -432,7 +432,7 @@ void CppCionGeneratorBase::GenMethodId(std::ofstream& stream,
     int cnt = 2;
     stream << Tab(2) << "__Result = 0," << NLine(1);
     stream << Tab(2) << "__Callback = 1," << NLine(1);
-    for (auto& i : iface.GetDeclarations().GetDecls()) {
+    for (const auto& i : iface.GetDeclarations()) {
       if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
         continue;
       stream << Tab(2)
@@ -447,7 +447,7 @@ void CppCionGeneratorBase::GenDelegateId(std::ofstream& stream,
   stream << Tab(1) << "enum class DelegateId : int ";
   GenBrace(stream, TAB_SIZE, [&]() {
     int cnt = 1;
-    for (auto& i : iface.GetDeclarations().GetDecls()) {
+    for (const auto& i : iface.GetDeclarations()) {
         if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
           continue;
         stream << Tab(2)
@@ -465,7 +465,7 @@ void CppCionGeneratorBase::GenParameters(std::ofstream& stream,
 std::string CppCionGeneratorBase::GetParameters(const Parameters& ps) {
   bool first = true;
   std::string ret;
-  for (auto& i : ps.GetParams()) {
+  for (const auto& i : ps) {
     if (!first) {
       ret += ", ";
     }
@@ -607,7 +607,7 @@ void CppCionGeneratorBase::GenBodyCallbacks(std::ofstream& stream,
                                    const Interface& iface, bool is_proxy) {
   stream << ReplaceAll(CB_CALLBACK_BASE, "##", iface.GetID());
 
-  for (auto& i : iface.GetDeclarations().GetDecls()) {
+  for (const auto& i : iface.GetDeclarations()) {
     if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
           continue;
     GenBodyCallback(stream, iface, *i, is_proxy);
@@ -637,7 +637,7 @@ void CppCionGeneratorBase::GenBodyCallback(std::ofstream& stream,
       },
       [&]()->std::string {
         std::string m;
-        for (auto& i : decl.GetParameters().GetParams()) {
+        for (const auto& i : decl.GetParameters()) {
           auto& pt = i->GetParameterType();
           m += AddIndent(TAB_SIZE,
               GenPrivateSharingRequest(pt.GetBaseType(), i->GetID()));
@@ -657,7 +657,7 @@ void CppCionGeneratorBase::GenBodyCallback(std::ofstream& stream,
       [&]()->std::string {
         int cnt = 1;
         std::string ret;
-        for (auto& i : decl.GetParameters().GetParams()) {
+        for (const auto& i : decl.GetParameters()) {
           std::string v = "param" + std::to_string(cnt);
           std::string c = ConvertTypeToDeserializer(
               i->GetParameterType().GetBaseType(), v, "parcel");
@@ -667,7 +667,8 @@ void CppCionGeneratorBase::GenBodyCallback(std::ofstream& stream,
 
         cnt = 1;
         ret += Tab(1) + "OnReceived(";
-        for (int i = 0; i < decl.GetParameters().GetParams().size(); i++) {
+        for (auto i = decl.GetParameters().begin();
+            i != decl.GetParameters().end(); ++i) {
           if (cnt != 1) {
             ret += ", ";
           }
@@ -692,7 +693,7 @@ void CppCionGeneratorBase::GenHeaderCallbacks(std::ofstream& stream,
   }
   stream << CB_CALLBACK_BASE_HEADER_BACK;
 
-  for (auto& i : iface.GetDeclarations().GetDecls()) {
+  for (const auto& i : iface.GetDeclarations()) {
     if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
           continue;
     GenHeaderCallback(stream, *i, is_proxy);
index 5ea467d..05dd623 100644 (file)
@@ -122,7 +122,7 @@ void CppCionProxyBodyGen::GenMethods(std::ofstream& stream,
                                  const Interface& iface) {
   auto& decls = iface.GetDeclarations();
 
-  for (auto& i : decls.GetDecls()) {
+  for (const auto& i : decls) {
     if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
 
@@ -167,7 +167,7 @@ void CppCionProxyBodyGen::GenInvocation(std::ofstream& stream,
          << decl.GetID() << "));" << NLine(1);
   std::string m;
   std::string l;
-  for (auto& i : decl.GetParameters().GetParams()) {
+  for (const auto& i : decl.GetParameters()) {
     auto& pt = i->GetParameterType();
     if (pt.GetDirection() == ParameterType::Direction::OUT)
       continue;
@@ -203,7 +203,7 @@ void CppCionProxyBodyGen::GenInvocation(std::ofstream& stream,
   }
 
   stream << CB_INVOCATION_RECEIVE << NLine(1);
-  for (auto& i : decl.GetParameters().GetParams()) {
+  for (const auto& i : decl.GetParameters()) {
     if (i->GetParameterType().GetDirection() == ParameterType::Direction::IN) {
       continue;
     }
@@ -222,7 +222,7 @@ void CppCionProxyBodyGen::GenInvocation(std::ofstream& stream,
   }
 
   std::string f;
-  for (auto& i : decl.GetParameters().GetParams()) {
+  for (const auto& i : decl.GetParameters()) {
     auto& pt = i->GetParameterType();
     if (pt.GetDirection() == ParameterType::Direction::OUT)
       continue;
index 7006284..b0b11db 100644 (file)
@@ -92,7 +92,7 @@ void CppCionProxyHeaderGen::GenMethods(std::ofstream& stream,
                                    const Interface& iface) {
   auto& decls = iface.GetDeclarations();
 
-  for (auto& i : decls.GetDecls()) {
+  for (const auto& i : decls) {
     if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
 
index 56b90fb..925926e 100644 (file)
@@ -134,7 +134,7 @@ void CppCionStubBodyGen::GenCionDataReceivedEvent(std::ofstream& stream,
       });
   }
 
-  for (auto& i : iface.GetDeclarations().GetDecls()) {
+  for (const auto& i : iface.GetDeclarations()) {
     if (i->GetMethodType() == Declaration::MethodType::DELEGATE ||
         i->GetMethodType() == Declaration::MethodType::ASYNC)
       continue;
@@ -175,7 +175,7 @@ void CppCionStubBodyGen::GenCionPayloadReceivedEvent(std::ofstream& stream,
       return iface.GetID();
     });
 
-  for (auto& i : iface.GetDeclarations().GetDecls()) {
+  for (const auto& i : iface.GetDeclarations()) {
     if (i->GetMethodType() == Declaration::MethodType::DELEGATE ||
         i->GetMethodType() == Declaration::MethodType::SYNC)
       continue;
@@ -211,7 +211,7 @@ void CppCionStubBodyGen::GenInvocation(std::ofstream& stream,
   int cnt = 1;
 
   // Deserialize
-  for (auto& i : decl.GetParameters().GetParams()) {
+  for (const auto& i : decl.GetParameters()) {
     if (i->GetParameterType().GetDirection() == ParameterType::Direction::OUT) {
       cnt++;
       continue;
@@ -236,7 +236,7 @@ void CppCionStubBodyGen::GenInvocation(std::ofstream& stream,
   }
 
   m += "b->" + decl.GetID() + "(";
-  for (auto& i : decl.GetParameters().GetParams()) {
+  for (const auto& i : decl.GetParameters()) {
     if (cnt != 1) {
       m += ", ";
     }
@@ -267,7 +267,7 @@ void CppCionStubBodyGen::GenInvocation(std::ofstream& stream,
   cnt = 0;
   m = "rpc_port_parcel_write_int32(" \
       "result, static_cast<int>(MethodId::__Result));\n";
-  for (auto& i : decl.GetParameters().GetParams()) {
+  for (const auto& i : decl.GetParameters()) {
     auto& pt = i->GetParameterType();
     cnt++;
     if (pt.GetDirection() == ParameterType::Direction::IN)
index 389a673..4877d80 100644 (file)
@@ -104,7 +104,7 @@ void CppCionStubHeaderGen::GenServiceBase(std::ofstream& stream,
   stream << CB_SERVICE_BASE_FRONT;
   auto& decls = iface.GetDeclarations();
 
-  for (auto& i : decls.GetDecls()) {
+  for (const auto& i : decls) {
     if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
     if (!i->GetComments().empty())
index 9d08f1f..86d679f 100644 (file)
@@ -65,7 +65,7 @@ void CsCionGeneratorBase::GenStructure(std::ofstream& stream, const Structure& s
 
   stream << Tab(1) <<"public sealed class " << st.GetID() << NLine(1);
   GenBrace(stream, TAB_SIZE, [&]() {
-    for (auto& i : st.GetElements().GetElms()) {
+    for (const auto& i : st.GetElements()) {
       GenTemplate(CB_PROPERTY, stream,
         [&]()->std::string {
           return ConvertTypeToString(i->GetType());
@@ -97,7 +97,7 @@ void CsCionGeneratorBase::GenSerializer(std::ofstream& stream,
   stream << NLine(1) << Tab(3) << "private static void Serialize(Parcel h, "
                    << st.GetID() << " param)" << NLine(1);
   GenBrace(stream, TAB_SIZE * 3, [&]() {
-    for (auto& i : st.GetElements().GetElms()) {
+    for (const auto& i : st.GetElements()) {
       auto& t = i->GetType();
       if (!t.IsUserDefinedType() && t.GetMetaType() == nullptr) {
         stream << Tab(4) << "h.Write"
@@ -116,7 +116,7 @@ void CsCionGeneratorBase::GenSerializer(std::ofstream& stream,
   stream << Tab(3) << "private static void Deserialize(Parcel h, "
                    << st.GetID() << " param)" << NLine(1);
   GenBrace(stream, TAB_SIZE * 3, [&]() {
-    for (auto& i : st.GetElements().GetElms()) {
+    for (const auto& i : st.GetElements()) {
       auto& t = i->GetType();
       if (!t.IsUserDefinedType() && t.GetMetaType() == nullptr) {
         stream << Tab(4) << "var " << i->GetID() << " = "
@@ -199,7 +199,7 @@ bool CsCionGeneratorBase::HasFile(const BaseType& type) {
 }
 
 bool CsCionGeneratorBase::HasFile(const Interface& iface, const Declaration& decl, bool is_proxy) {
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     auto& param_type = p->GetParameterType();
     if (is_proxy) {
       if (param_type.GetDirection() != ParameterType::Direction::IN)
@@ -226,7 +226,7 @@ bool CsCionGeneratorBase::HasFile(const Interface& iface, const Declaration& dec
 void CsCionGeneratorBase::GenShareFile(std::ofstream& stream, const Interface& iface, bool is_proxy) {
   bool hasFile = false;
 
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     hasFile = HasFile(iface, *d, is_proxy);
     if (hasFile == true)
       break;
@@ -305,16 +305,16 @@ void CsCionGeneratorBase::GenListSerializer(std::ofstream& stream) {
   for (auto& i : GetDocument().GetBlocks()) {
     if (i->GetType() == Block::TYPE_STRUCTURE) {
       const Structure& st = static_cast<const Structure&>(*i);
-      for (auto& j : st.GetElements().GetElms()) {
+      for (const auto& j : st.GetElements()) {
         auto& t = j->GetType();
         AddSerializerList(t);
       }
     } else if (i->GetType() == Block::TYPE_INTERFACE) {
       const Interface& iface = static_cast<const Interface&>(*i);
-      for (auto& j : iface.GetDeclarations().GetDecls()) {
+      for (const auto& j : iface.GetDeclarations()) {
         auto& t = j->GetType();
         AddSerializerList(t);
-        for (auto& k : j->GetParameters().GetParams()) {
+        for (const auto& k : j->GetParameters()) {
           auto& t1 = k->GetParameterType().GetBaseType();
           AddSerializerList(t1);
         }
@@ -447,7 +447,7 @@ void CsCionGeneratorBase::GenMethodId(std::ofstream& stream,
     int cnt = 2;
     stream << Tab(4) << "__Result = 0," << NLine(1);
     stream << Tab(4) << "__Callback = 1," << NLine(1);
-    for (auto& i : iface.GetDeclarations().GetDecls()) {
+    for (const auto& i : iface.GetDeclarations()) {
       if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
         continue;
       stream << Tab(4)
@@ -461,7 +461,7 @@ void CsCionGeneratorBase::GenDelegateId(std::ofstream& stream,
   stream << Tab(3) << "private enum DelegateId : int" << NLine(1);
   GenBrace(stream, TAB_SIZE * 3, [&]() {
     int cnt = 1;
-    for (auto& i : iface.GetDeclarations().GetDecls()) {
+    for (const auto& i : iface.GetDeclarations()) {
         if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
           continue;
         stream << Tab(4)
@@ -490,7 +490,7 @@ void CsCionGeneratorBase::GenParameters(std::ofstream& stream,
 std::string CsCionGeneratorBase::GetParameters(const Parameters& ps) {
   bool first = true;
   std::string ret;
-  for (auto& i : ps.GetParams()) {
+  for (const auto& i : ps) {
     if (!first) {
       ret += ", ";
     }
@@ -514,7 +514,7 @@ void CsCionGeneratorBase::GenCallbacks(std::ofstream& stream,
                                    const Interface& iface, bool is_proxy) {
   stream << CB_CALLBACK_BASE;
 
-  for (auto& i : iface.GetDeclarations().GetDecls()) {
+  for (const auto& i : iface.GetDeclarations()) {
     if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
           continue;
     GenCallback(stream, *i, iface.GetID(), is_proxy);
@@ -576,7 +576,7 @@ void CsCionGeneratorBase::GenReceivedEvent(std::ofstream& stream,
          << NLine(1);
   GenBrace(stream, TAB_SIZE * 4, [&]() {
     int cnt = 1;
-    for (auto& i : decl.GetParameters().GetParams()) {
+    for (const auto& i : decl.GetParameters()) {
       std::string v = "param" + std::to_string(cnt);
       std::string c = ConvertTypeToDeserializer(
           i->GetParameterType().GetBaseType(), v, "parcel", true, id);
@@ -586,7 +586,8 @@ void CsCionGeneratorBase::GenReceivedEvent(std::ofstream& stream,
 
     cnt = 1;
     stream << Tab(5) << "Received?.Invoke(";
-    for (int i = 0; i < decl.GetParameters().GetParams().size(); i++) {
+    for (auto i = decl.GetParameters().begin();
+        i != decl.GetParameters().end(); ++i) {
       if (cnt != 1) {
         stream << ", ";
       }
@@ -608,7 +609,7 @@ void CsCionGeneratorBase::GenInvokeMethod(std::ofstream& stream,
       },
       [&]()->std::string {
         std::string m;
-        for (auto& i : decl.GetParameters().GetParams()) {
+        for (const auto& i : decl.GetParameters()) {
           auto& pt = i->GetParameterType();
           m += ConvertTypeToSerializer(pt.GetBaseType(), i->GetID(), "p", id);
         }
@@ -616,7 +617,7 @@ void CsCionGeneratorBase::GenInvokeMethod(std::ofstream& stream,
       },
       [&]()->std::string {
         std::string m;
-        for (auto& i : decl.GetParameters().GetParams()) {
+        for (const auto& i : decl.GetParameters()) {
           auto& pt = i->GetParameterType();
           if(HasFile(pt.GetBaseType()))
             m += "_serverBase.TryShareFile(" + i->GetID() + ");\n";
index f33cd7c..7266b08 100644 (file)
@@ -85,7 +85,7 @@ void CsCionProxyGen::GenCtor(std::ofstream& stream, const Interface& iface) {
   bool securityCheck = false;
   std::string m = "public $$(string serviceName) : base(serviceName, new SecurityInfo {";
 
-  for (auto& attr : iface.GetAttributes().GetAttrs()) {
+  for (const auto& attr : iface.GetAttributes()) {
     if (attr->GetKey() == "ca_path") {
       m += "CaPath = \"" + attr->GetValue() + "\", ";
       securityCheck = true;
@@ -126,7 +126,7 @@ void CsCionProxyGen::GenConnectMethod(std::ofstream& stream,
 void CsCionProxyGen::GenMethods(std::ofstream& stream, const Interface& iface) {
   auto& decls = iface.GetDeclarations();
 
-  for (auto& i : decls.GetDecls()) {
+  for (const auto& i : decls) {
     if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
 
@@ -151,7 +151,7 @@ void CsCionProxyGen::GenInvocation(std::ofstream& stream, const Declaration& dec
          + "p.WriteInt((int)MethodId." + decl.GetID() + ");" + NLine(1);
       std::string m;
       std::string l;
-      for (auto& i : decl.GetParameters().GetParams()) {
+      for (const auto& i : decl.GetParameters()) {
         auto& pt = i->GetParameterType();
         if (pt.GetDirection() == ParameterType::Direction::OUT)
           continue;
@@ -175,7 +175,7 @@ void CsCionProxyGen::GenInvocation(std::ofstream& stream, const Declaration& dec
         st += CB_SYNC_INVOCATION_MID;
       }
 
-      for (auto& i : decl.GetParameters().GetParams()) {
+      for (const auto& i : decl.GetParameters()) {
          auto& pt = i->GetParameterType();
          if (pt.GetDirection() == ParameterType::Direction::OUT)
            continue;
@@ -197,7 +197,7 @@ void CsCionProxyGen::GenInvocation(std::ofstream& stream, const Declaration& dec
         return st;
       }
 
-      for (auto& i : decl.GetParameters().GetParams()) {
+      for (const auto& i : decl.GetParameters()) {
         if (i->GetParameterType().GetDirection() ==
             ParameterType::Direction::IN) {
           continue;
index aa71ab6..4aaadc1 100644 (file)
@@ -93,7 +93,7 @@ void CsCionStubGen::GenServiceBase(std::ofstream& stream, const Interface& iface
 
 void CsCionStubGen::GenDeclarations(std::ofstream& stream,
                                 const Declarations& decls) {
-  for (auto& i : decls.GetDecls()) {
+  for (const auto& i : decls) {
     if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
     if (!i->GetComments().empty())
@@ -107,7 +107,7 @@ void CsCionStubGen::GenDeclarations(std::ofstream& stream,
 void CsCionStubGen::GenReceivedSyncEvent(std::ofstream& stream,
     const Interface& iface) {
   stream << CB_ON_RECEIVED_SYNC_EVENT_FRONT;
-  for (auto& i : iface.GetDeclarations().GetDecls()) {
+  for (const auto& i : iface.GetDeclarations()) {
     if (i->GetMethodType() != Declaration::MethodType::SYNC)
       continue;
     stream << Tab(7) << "case MethodId." << i->GetID() << ":" << NLine(1);
@@ -122,7 +122,7 @@ void CsCionStubGen::GenReceivedSyncEvent(std::ofstream& stream,
 void CsCionStubGen::GenReceivedAsyncEvent(std::ofstream& stream,
     const Interface& iface) {
   stream << CB_ON_RECEIVED_ASYNC_EVENT_FRONT;
-  for (auto& i : iface.GetDeclarations().GetDecls()) {
+  for (const auto& i : iface.GetDeclarations()) {
     if (i->GetMethodType() != Declaration::MethodType::ASYNC)
       continue;
     stream << Tab(6) << "case MethodId." << i->GetID() << ":" << NLine(1);
@@ -138,7 +138,7 @@ void CsCionStubGen::GenSyncInvocation(std::ofstream& stream, const Declaration&
   int cnt = 1;
 
   // Deserialize
-  for (auto& i : decl.GetParameters().GetParams()) {
+  for (const auto& i : decl.GetParameters()) {
     if (i->GetParameterType().GetDirection() == ParameterType::Direction::OUT) {
       cnt++;
       continue;
@@ -162,7 +162,7 @@ void CsCionStubGen::GenSyncInvocation(std::ofstream& stream, const Declaration&
   }
 
   m += "b." + decl.GetID() + "(";
-  for (auto& i : decl.GetParameters().GetParams()) {
+  for (const auto& i : decl.GetParameters()) {
     if (cnt != 1) {
       m += ", ";
     }
@@ -184,7 +184,7 @@ void CsCionStubGen::GenSyncInvocation(std::ofstream& stream, const Declaration&
   // Serialize
   cnt = 0;
   m = CB_INVOCATION_RESULT_PRE;
-  for (auto& i : decl.GetParameters().GetParams()) {
+  for (const auto& i : decl.GetParameters()) {
     auto& pt = i->GetParameterType();
     cnt++;
     if (pt.GetDirection() == ParameterType::Direction::IN)
@@ -213,7 +213,7 @@ void CsCionStubGen::GenAsyncInvocation(std::ofstream& stream, const Declaration&
   int cnt = 1;
 
   // Deserialize
-  for (auto& i : decl.GetParameters().GetParams()) {
+  for (const auto& i : decl.GetParameters()) {
     if (i->GetParameterType().GetDirection() == ParameterType::Direction::OUT) {
       cnt++;
       continue;
@@ -235,7 +235,7 @@ void CsCionStubGen::GenAsyncInvocation(std::ofstream& stream, const Declaration&
   }
 
   m += "b." + decl.GetID() + "(";
-  for (auto& i : decl.GetParameters().GetParams()) {
+  for (const auto& i : decl.GetParameters()) {
     if (cnt != 1) {
       m += ", ";
     }
@@ -271,7 +271,7 @@ void CsCionStubGen::GenCtor(std::ofstream& stream, const Interface& iface) {
   bool securityCheck = false;
   std::string m = "public $$(string serviceName, string displayName) : base(serviceName, displayName, new SecurityInfo {";
 
-  for (auto& attr : iface.GetAttributes().GetAttrs()) {
+  for (const auto& attr : iface.GetAttributes()) {
     if (attr->GetKey() == "ca_path") {
       m += "CaPath = \"" + attr->GetValue() + "\", ";
       securityCheck = true;
index c418c7b..ba90ca6 100644 (file)
@@ -84,7 +84,7 @@ std::string JavaCionCommonGen::GetDelegateId() {
       continue;
 
     Interface& iface = static_cast<Interface&>(*i);
-    for (auto& d : iface.GetDeclarations().GetDecls()) {
+    for (const auto& d : iface.GetDeclarations()) {
       if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
         continue;
 
index 409a0c7..3272922 100644 (file)
@@ -71,7 +71,7 @@ void JavaCionGeneratorBase::GenMethodId(std::ofstream& stream,
   int cnt = 2;
   stream << Tab(1) << "public static final int __RESULT = 0;" << NLine(2);
   stream << Tab(1) << "public static final int __CALLBACK = 1;" << NLine(2);
-  for (auto& i : iface.GetDeclarations().GetDecls()) {
+  for (const auto& i : iface.GetDeclarations()) {
     if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
     stream << Tab(1)
@@ -114,7 +114,7 @@ std::string JavaCionGeneratorBase::ConvertTypeToString(
 std::string JavaCionGeneratorBase::GetParameters(const Parameters& ps) {
   bool first = true;
   std::string ret;
-  for (auto& i : ps.GetParams()) {
+  for (const auto& i : ps) {
     if (!first) {
       ret += ", ";
     }
@@ -245,7 +245,7 @@ void JavaCionGeneratorBase::GenSerializer(std::ofstream& stream,
   stream << Tab(1) << "private static void serialize(CionParcel h, "
                    << st.GetID() << " param) ";
   GenBrace(stream, TAB_SIZE * 1, [&]() {
-    for (auto& i : st.GetElements().GetElms()) {
+    for (const auto& i : st.GetElements()) {
       auto& t = i->GetType();
       if (!t.IsUserDefinedType() && t.GetMetaType() == nullptr) {
         stream << Tab(2) << "h.write"
@@ -267,7 +267,7 @@ void JavaCionGeneratorBase::GenSerializer(std::ofstream& stream,
   stream << Tab(1) << "private static void deserialize(CionParcel h, "
                    << st.GetID() << " param) ";
   GenBrace(stream, TAB_SIZE * 1, [&]() {
-    for (auto& i : st.GetElements().GetElms()) {
+    for (const auto& i : st.GetElements()) {
       auto& t = i->GetType();
       if (!t.IsUserDefinedType() && t.GetMetaType() == nullptr) {
         stream << Tab(2) << ConvertTypeToString(t)
@@ -371,16 +371,16 @@ void JavaCionGeneratorBase::GenListSerializer(std::ofstream& stream) {
   for (auto& i : GetDocument().GetBlocks()) {
     if (i->GetType() == Block::TYPE_STRUCTURE) {
       const Structure& st = static_cast<const Structure&>(*i);
-      for (auto& j : st.GetElements().GetElms()) {
+      for (const auto& j : st.GetElements()) {
         auto& t = j->GetType();
         AddSerializerList(t);
       }
     } else if (i->GetType() == Block::TYPE_INTERFACE) {
       const Interface& iface = static_cast<const Interface&>(*i);
-      for (auto& j : iface.GetDeclarations().GetDecls()) {
+      for (const auto& j : iface.GetDeclarations()) {
         auto& t = j->GetType();
         AddSerializerList(t);
-        for (auto& k : j->GetParameters().GetParams()) {
+        for (const auto& k : j->GetParameters()) {
           auto& t1 = k->GetParameterType().GetBaseType();
           AddSerializerList(t1);
         }
@@ -407,7 +407,7 @@ std::string JavaCionGeneratorBase::ConvertTypeToParcelType(const std::string& ke
 
 void JavaCionGeneratorBase::GenCallbacks(std::ofstream& stream,
     const Interface& iface, bool is_proxy) {
-  for (auto& i : iface.GetDeclarations().GetDecls()) {
+  for (const auto& i : iface.GetDeclarations()) {
     if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
           continue;
     if (is_proxy)
@@ -442,7 +442,7 @@ void JavaCionGeneratorBase::GenCallbackStub(std::ofstream& stream,
   str = ReplaceAll(str, "<DELEGATOR_NAME>",decl.GetID());
 
   std::string ser;
-  for (auto& i : decl.GetParameters().GetParams()) {
+  for (const auto& i : decl.GetParameters()) {
     auto& pt = i->GetParameterType();
     ser += ConvertTypeToSerializer(pt.GetBaseType(), i->GetID(), "p", id);
   }
@@ -451,7 +451,7 @@ void JavaCionGeneratorBase::GenCallbackStub(std::ofstream& stream,
   str = ReplaceAll(str, "<SERIALIZE>", ser);
 
   std::string share;
-  for (auto& i : decl.GetParameters().GetParams()) {
+  for (const auto& i : decl.GetParameters()) {
     auto& pt = i->GetParameterType();
     if(HasFile(pt.GetBaseType()))
       share += "_serverBase.shareFile(" + i->GetID() + ");\n";
@@ -468,7 +468,7 @@ std::string JavaCionGeneratorBase::GetOnInvoked(const Declaration& decl,
     const std::string& id) {
   std::string str;
   int cnt = 1;
-  for (auto& i : decl.GetParameters().GetParams()) {
+  for (const auto& i : decl.GetParameters()) {
     std::string v = "param" + std::to_string(cnt);
     std::string c = ConvertTypeToDeserializer(
         i->GetParameterType().GetBaseType(), v, "parcel", true, id);
@@ -479,7 +479,8 @@ std::string JavaCionGeneratorBase::GetOnInvoked(const Declaration& decl,
   cnt = 1;
   str += Tab(3);
   str += "onInvoked(";
-  for (int i = 0; i < decl.GetParameters().GetParams().size(); i++) {
+  for (auto i = decl.GetParameters().begin();
+      i != decl.GetParameters().end(); ++i) {
     if (cnt != 1) {
       str += ", ";
     }
@@ -604,7 +605,7 @@ void JavaCionGeneratorBase::GenVersion(std::ofstream& stream) {
 void JavaCionGeneratorBase::GenDelegateId(std::ofstream& stream,
     const Interface& iface) {
   int cnt = 1;
-  for (auto& i : iface.GetDeclarations().GetDecls()) {
+  for (const auto& i : iface.GetDeclarations()) {
       if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
         continue;
       stream << Tab(1) << "private static final int __"
@@ -616,7 +617,7 @@ void JavaCionGeneratorBase::GenShareFile(std::ofstream& stream,
     const Interface& iface, bool is_proxy) {
   bool hasFile = false;
 
-  for (auto& d : iface.GetDeclarations().GetDecls()) {
+  for (const auto& d : iface.GetDeclarations()) {
     hasFile = HasFile(iface, *d, is_proxy);
     if (hasFile == true)
       break;
@@ -657,7 +658,7 @@ bool JavaCionGeneratorBase::HasFile(const Interface& iface, const BaseType& type
 }
 
 bool JavaCionGeneratorBase::HasFile(const Interface& iface, const Declaration& decl, bool is_proxy) {
-  for (auto& p : decl.GetParameters().GetParams()) {
+  for (const auto& p : decl.GetParameters()) {
     auto& param_type = p->GetParameterType();
     if (is_proxy) {
       if (param_type.GetDirection() != ParameterType::Direction::IN)
index adc9529..5ec4ffc 100644 (file)
@@ -80,7 +80,7 @@ void JavaCionProxyGen::GenCtor(std::ofstream& stream, const Interface& iface) {
 
   m += Tab(1) + "super(context, serviceName, new SecurityInfo(";
 
-  for (auto& attr : iface.GetAttributes().GetAttrs()) {
+  for (const auto& attr : iface.GetAttributes()) {
     if (attr->GetKey() == "ca_path") {
       m += "\"" + attr->GetValue() + "\", ";
       securityCheck = true;
@@ -120,7 +120,7 @@ void JavaCionProxyGen::GenConnectMethod(std::ofstream& stream,
 void JavaCionProxyGen::GenMethods(std::ofstream& stream, const Interface& iface) {
   auto& decls = iface.GetDeclarations();
 
-  for (auto& i : decls.GetDecls()) {
+  for (const auto& i : decls) {
     if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
 
@@ -144,7 +144,7 @@ void JavaCionProxyGen::GenInvocation(std::ofstream& stream, const Declaration& d
          + "p.write(__" + decl.GetID() + ");" + NLine(1);
       std::string m;
       std::string l;
-      for (auto& i : decl.GetParameters().GetParams()) {
+      for (const auto& i : decl.GetParameters()) {
         auto& pt = i->GetParameterType();
         if (pt.GetDirection() == ParameterType::Direction::OUT)
           continue;
@@ -170,7 +170,7 @@ void JavaCionProxyGen::GenInvocation(std::ofstream& stream, const Declaration& d
         st += CB_SYNC_INVOCATION_MID;
       }
 
-      for (auto& i : decl.GetParameters().GetParams()) {
+      for (const auto& i : decl.GetParameters()) {
          auto& pt = i->GetParameterType();
          if (pt.GetDirection() == ParameterType::Direction::OUT)
            continue;
@@ -192,7 +192,7 @@ void JavaCionProxyGen::GenInvocation(std::ofstream& stream, const Declaration& d
         return st;
       }
 
-      for (auto& i : decl.GetParameters().GetParams()) {
+      for (const auto& i : decl.GetParameters()) {
         if (i->GetParameterType().GetDirection() ==
             ParameterType::Direction::IN) {
           continue;
index a61f3f9..0ea2210 100644 (file)
@@ -59,7 +59,7 @@ void JavaCionStructureGen::GenStructure(std::ofstream& stream,
     GenTemplate(variable, stream,
       [&]()->std::string {
         std::string str;
-        for (auto& i : st.GetElements().GetElms()) {
+        for (const auto& i : st.GetElements()) {
           str += NLine(1) + Tab(1) + "private ";
           if (i->GetType().GetMetaType() == nullptr) {
             str += ConvertTypeToString(i->GetType()) + " "
@@ -75,7 +75,7 @@ void JavaCionStructureGen::GenStructure(std::ofstream& stream,
         return str;
       });
 
-    for (auto& i : st.GetElements().GetElms()) {
+    for (const auto& i : st.GetElements()) {
       GenSetter(stream, *i);
       GenGetter(stream, *i);
       stream << NLine(1);
index 4b51d55..d26a48e 100644 (file)
@@ -85,7 +85,7 @@ void JavaCionStubGen::GenServiceBase(std::ofstream& stream, const Interface& ifa
 
 void JavaCionStubGen::GenDeclarations(std::ofstream& stream,
                                 const Declarations& decls) {
-  for (auto& i : decls.GetDecls()) {
+  for (const auto& i : decls) {
     if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
     if (!i->GetComments().empty())
@@ -99,7 +99,7 @@ void JavaCionStubGen::GenDeclarations(std::ofstream& stream,
 void JavaCionStubGen::GenReceivedSyncEvent(std::ofstream& stream,
     const Interface& iface) {
   stream << CB_ON_RECEIVED_SYNC_EVENT_FRONT;
-  for (auto& i : iface.GetDeclarations().GetDecls()) {
+  for (const auto& i : iface.GetDeclarations()) {
     if (i->GetMethodType() != Declaration::MethodType::SYNC)
       continue;
     stream << Tab(4) << "case __" << i->GetID() << ": ";
@@ -114,7 +114,7 @@ void JavaCionStubGen::GenReceivedSyncEvent(std::ofstream& stream,
 void JavaCionStubGen::GenReceivedAsyncEvent(std::ofstream& stream,
     const Interface& iface) {
   stream << CB_ON_RECEIVED_ASYNC_EVENT_FRONT;
-  for (auto& i : iface.GetDeclarations().GetDecls()) {
+  for (const auto& i : iface.GetDeclarations()) {
     if (i->GetMethodType() != Declaration::MethodType::ASYNC)
       continue;
     stream << Tab(4) << "case __" << i->GetID() << ": ";
@@ -132,7 +132,7 @@ void JavaCionStubGen::GenSyncInvocation(std::ofstream& stream, const Declaration
   // Serialize
   int cnt = 0;
   std::string m = CB_INVOCATION_RESULT_PRE;
-  for (auto& i : decl.GetParameters().GetParams()) {
+  for (const auto& i : decl.GetParameters()) {
     auto& pt = i->GetParameterType();
     cnt++;
     if (pt.GetDirection() == ParameterType::Direction::IN)
@@ -161,7 +161,7 @@ bool JavaCionStubGen::GenAsyncInvocation(std::ofstream& stream, const Declaratio
   int cnt = 1;
 
   // Deserialize
-  for (auto& i : decl.GetParameters().GetParams()) {
+  for (const auto& i : decl.GetParameters()) {
     std::string v = "param" + std::to_string(cnt);
     auto& pt = i->GetParameterType();
     if (pt.GetDirection() == ParameterType::Direction::OUT) {
@@ -196,7 +196,7 @@ bool JavaCionStubGen::GenAsyncInvocation(std::ofstream& stream, const Declaratio
   }
 
   m += "b." + decl.GetID() + "(";
-  for (auto& i : decl.GetParameters().GetParams()) {
+  for (const auto& i : decl.GetParameters()) {
     if (cnt != 1) {
       m += ", ";
     }
@@ -235,7 +235,7 @@ void JavaCionStubGen::GenCtor(std::ofstream& stream, const Interface& iface) {
   std::string m = "public $$(Context context, String serviceName, String displayName) {\n";
   m += Tab(1) + "super(context, serviceName, displayName, new SecurityInfo(";
 
-  for (auto& attr : iface.GetAttributes().GetAttrs()) {
+  for (const auto& attr : iface.GetAttributes()) {
     if (attr->GetKey() == "ca_path") {
       m += "\"" + attr->GetValue() + "\", ";
       securityCheck = true;
index e001f4c..869c87d 100644 (file)
@@ -67,28 +67,28 @@ TEST_F(AttributesTest, Attributes_Constructor) {
 }
 
 TEST_F(AttributesTest, Attributes_Add) {
-  tidl::Attributes* attrs = new tidl::Attributes();
-  EXPECT_NE(attrs, nullptr);
-  attrs->Add(new tidl::Attribute("key", "value", __LINE__));
+  tidl::Attributes attrs;
+  attrs.Add(std::unique_ptr<tidl::Attribute>(new tidl::Attribute(
+      "key", "value", __LINE__)));
 
   bool flag = false;
-  for (auto& attr : attrs->GetAttrs()) {
+  for (const auto& attr : attrs) {
     if (attr->GetKey() == "key" &&
         attr->GetValue() == "value")
       flag = true;
   }
   EXPECT_EQ(flag, true);
-  delete attrs;
 }
 
-TEST_F(AttributesTest, Attributes_GetAttrs) {
-  tidl::Attributes* attrs = new tidl::Attributes();
-  EXPECT_NE(attrs, nullptr);
-  attrs->Add(new tidl::Attribute("key1", "value1", __LINE__));
-  attrs->Add(new tidl::Attribute("key2", "value2", __LINE__));
+TEST_F(AttributesTest, Attributes_range_for) {
+  tidl::Attributes attrs;
+  attrs.Add(std::unique_ptr<tidl::Attribute>(new tidl::Attribute(
+      "key1", "value1", __LINE__)));
+  attrs.Add(std::unique_ptr<tidl::Attribute>(new tidl::Attribute(
+      "key2", "value2", __LINE__)));
 
   int count = 0;
-  for (auto& attr : attrs->GetAttrs()) {
+  for (const auto& attr : attrs) {
     if (attr->GetKey() == "key1" &&
         attr->GetValue() == "value1")
       count++;
@@ -97,16 +97,12 @@ TEST_F(AttributesTest, Attributes_GetAttrs) {
       count++;
   }
   EXPECT_EQ(count, 2);
-  delete attrs;
 }
 
 TEST_F(AttributesTest, Attributes_Exist) {
-  tidl::Attributes* attrs = new tidl::Attributes();
-  EXPECT_NE(attrs, nullptr);
-  attrs->Add(new tidl::Attribute("key", "value", __LINE__));
-  tidl::Attribute* attr = new tidl::Attribute("key", "value", __LINE__);
-  EXPECT_NE(attr, nullptr);
-  EXPECT_EQ(attrs->Exist(attr), true);
-  delete attr;
-  delete attrs;
+  tidl::Attributes attrs;
+  attrs.Add(std::unique_ptr<tidl::Attribute>(new tidl::Attribute(
+      "key", "value", __LINE__)));
+  tidl::Attribute attr("key", "value", __LINE__);
+  EXPECT_EQ(attrs.Exist(attr), true);
 }
index 776341d..fe9e0ec 100644 (file)
@@ -29,44 +29,37 @@ class DeclarationTest : public testing::Test {
   virtual void SetUp() {
     params = new tidl::Parameters();
     EXPECT_NE(params, nullptr);
-    params->Add(new tidl::Parameter("test1",
-          new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
-    params->Add(new tidl::Parameter("test2",
-          new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
+    params->Add(std::unique_ptr<tidl::Parameter>(new tidl::Parameter("test1",
+        new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__)));
+    params->Add(std::unique_ptr<tidl::Parameter>(new tidl::Parameter("test2",
+        new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__)));
   }
   virtual void TearDown() {}
 };
 
 TEST_F(DeclarationTest, Declaration_Constructor) {
-  tidl::Declaration* decl = new tidl::Declaration("test",
-      new tidl::BaseType("int", ""), params, "", __LINE__);
-  EXPECT_NE(decl, nullptr);
-  delete decl;
+  tidl::Declaration decl("test", new tidl::BaseType("int", ""), params, "",
+      __LINE__);
 }
 
 TEST_F(DeclarationTest, Declaration_GetID) {
-  tidl::Declaration* decl = new tidl::Declaration("test",
-      new tidl::BaseType("int", ""), params, "", __LINE__);
-  EXPECT_NE(decl, nullptr);
-  EXPECT_EQ(decl->GetID(), "test");
-  delete decl;
+  tidl::Declaration decl("test", new tidl::BaseType("int", ""), params, "",
+      __LINE__);
+  EXPECT_EQ(decl.GetID(), "test");
 }
 
 TEST_F(DeclarationTest, Declaration_GetType) {
-  tidl::Declaration* decl = new tidl::Declaration("test",
-      new tidl::BaseType("int", ""), params, "", __LINE__);
-  EXPECT_NE(decl, nullptr);
-  EXPECT_EQ(decl->GetType().ToString(), "int");
-  delete decl;
+  tidl::Declaration decl("test", new tidl::BaseType("int", ""), params, "",
+      __LINE__);
+  EXPECT_EQ(decl.GetType().ToString(), "int");
 }
 
 TEST_F(DeclarationTest, Declaration_GetParameters) {
-  tidl::Declaration* decl = new tidl::Declaration("test",
-      new tidl::BaseType("int", ""), params, "", __LINE__);
-  EXPECT_NE(decl, nullptr);
+  tidl::Declaration decl("test", new tidl::BaseType("int", ""), params, "",
+      __LINE__);
 
   int count = 0;
-  for (auto& param : decl->GetParameters().GetParams()) {
+  for (const auto& param : decl.GetParameters()) {
     if (param->GetID() == "test1" &&
         param->GetParameterType().GetBaseType().ToString() == "int")
       count++;
@@ -75,105 +68,82 @@ TEST_F(DeclarationTest, Declaration_GetParameters) {
       count++;
   }
   EXPECT_EQ(count, 2);
-
-  delete decl;
 }
 
 TEST_F(DeclarationTest, Declaration_GetMethodType) {
-  tidl::Declaration* decl = new tidl::Declaration("test",
-      new tidl::BaseType("int", ""), params, "", __LINE__,
-      tidl::Declaration::MethodType::DELEGATE);
-  EXPECT_NE(decl, nullptr);
-  EXPECT_EQ(decl->GetMethodType(), tidl::Declaration::MethodType::DELEGATE);
-  delete decl;
+  tidl::Declaration decl("test", new tidl::BaseType("int", ""), params, "",
+      __LINE__, tidl::Declaration::MethodType::DELEGATE);
+  EXPECT_EQ(decl.GetMethodType(), tidl::Declaration::MethodType::DELEGATE);
 }
 
 TEST_F(DeclarationTest, Declaration_GetComments) {
   std::string comments = "Test Declaration";
-  tidl::Declaration* decl = new tidl::Declaration("test",
-      new tidl::BaseType("int", ""), params, comments, __LINE__);
-  EXPECT_NE(decl, nullptr);
-  EXPECT_EQ(decl->GetComments(), comments);
-  delete decl;
+  tidl::Declaration decl("test", new tidl::BaseType("int", ""), params,
+      comments, __LINE__);
+  EXPECT_EQ(decl.GetComments(), comments);
 }
 
 TEST_F(DeclarationTest, Declaration_GetLine) {
   unsigned line = __LINE__;
-  tidl::Declaration* decl = new tidl::Declaration("test",
-      new tidl::BaseType("int", ""), params, "", line);
-  EXPECT_NE(decl, nullptr);
-  EXPECT_EQ(decl->GetLine(), line);
-  delete decl;
+  tidl::Declaration decl("test", new tidl::BaseType("int", ""), params, "",
+      line);
+  EXPECT_EQ(decl.GetLine(), line);
 }
 
 class DeclarationsTest : public testing::Test {
  public:
-  tidl::Declaration* decl;
-
   virtual void SetUp() {}
   virtual void TestDown() {}
-  void PrepareDeclaration() {
+  std::unique_ptr<tidl::Declaration> PrepareDeclaration() {
     tidl::Parameters* params = new tidl::Parameters();
     EXPECT_NE(params, nullptr);
-    params->Add(new tidl::Parameter("test1",
-          new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
-    params->Add(new tidl::Parameter("test2",
-          new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
-    decl = new tidl::Declaration("test",
-        new tidl::BaseType("int", ""), params, "", __LINE__);
+    params->Add(std::unique_ptr<tidl::Parameter>(new tidl::Parameter("test1",
+        new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__)));
+    params->Add(std::unique_ptr<tidl::Parameter>(new tidl::Parameter("test2",
+        new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__)));
+    auto decl = std::unique_ptr<tidl::Declaration>(new tidl::Declaration(
+        "test", new tidl::BaseType("int", ""), params, "", __LINE__));
     EXPECT_NE(decl, nullptr);
+    return decl;
   }
 };
 
 TEST_F(DeclarationsTest, Declarations_Constructor) {
-  tidl::Declarations* decls = new tidl::Declarations();
-  EXPECT_NE(decls, nullptr);
-  delete decls;
+  tidl::Declarations decls;
 }
 
 TEST_F(DeclarationsTest, Declarations_Add) {
-  tidl::Declarations* decls = new tidl::Declarations();
-  EXPECT_NE(decls, nullptr);
-  PrepareDeclaration();
-  decls->Add(decl);
+  tidl::Declarations decls;
+  decls.Add(PrepareDeclaration());
 
   bool flag = false;
-  for (auto& d : decls->GetDecls()) {
+  for (const auto& d : decls) {
     if (d->GetID() == "test")
       flag = true;
   }
   EXPECT_EQ(flag, true);
-  delete decls;
 }
 
-TEST_F(DeclarationsTest, Declarations_GetDecls) {
-  tidl::Declarations* decls = new tidl::Declarations();
-  EXPECT_NE(decls, nullptr);
-  PrepareDeclaration();
-  decls->Add(decl);
+TEST_F(DeclarationsTest, Declarations_range_for) {
+  tidl::Declarations decls;
+  decls.Add(PrepareDeclaration());
 
   bool flag = false;
-  for (auto& d : decls->GetDecls()) {
+  for (auto& d : decls) {
     if (d->GetID() == "test")
       flag = true;
   }
   EXPECT_EQ(flag, true);
-  delete decls;
 }
 
 TEST_F(DeclarationsTest, Declarations_Exist) {
-  tidl::Declarations* decls = new tidl::Declarations();
-  EXPECT_NE(decls, nullptr);
-  PrepareDeclaration();
-  decls->Add(decl);
+  tidl::Declarations decls;
+  decls.Add(PrepareDeclaration());
   tidl::Parameters* testParams = new tidl::Parameters();
   EXPECT_NE(testParams, nullptr);
-  testParams->Add(new tidl::Parameter("test1",
-        new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
-  tidl::Declaration* testDecl = new tidl::Declaration("test",
+  testParams->Add(std::unique_ptr<tidl::Parameter>(new tidl::Parameter("test1",
+        new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__)));
+  tidl::Declaration testDecl("test",
         new tidl::BaseType("int", ""), testParams, "", __LINE__);
-  EXPECT_NE(testDecl, nullptr);
-  EXPECT_EQ(decls->Exist(testDecl), true);
-  delete testDecl;
-  delete decls;
+  EXPECT_EQ(decls.Exist(testDecl), true);
 }
index 8ef351c..d174b9e 100644 (file)
@@ -27,44 +27,29 @@ class ElementTest : public testing::Test {
 };
 
 TEST_F(ElementTest, Element_Contstructor) {
-  tidl::Element* elm = new tidl::Element("test",
-      new tidl::BaseType("int", ""), "", __LINE__);
-  EXPECT_NE(elm, nullptr);
-  delete elm;
+  tidl::Element elm("test", new tidl::BaseType("int", ""), "", __LINE__);
 }
 
 TEST_F(ElementTest, Element_GetID) {
-  tidl::Element* elm = new tidl::Element("test",
-      new tidl::BaseType("int", ""), "", __LINE__);
-  EXPECT_NE(elm, nullptr);
-  EXPECT_EQ(elm->GetID(), "test");
-  delete elm;
+  tidl::Element elm("test", new tidl::BaseType("int", ""), "", __LINE__);
+  EXPECT_EQ(elm.GetID(), "test");
 }
 
 TEST_F(ElementTest, Element_GetType) {
-  tidl::Element* elm = new tidl::Element("test",
-      new tidl::BaseType("int", ""), "", __LINE__);
-  EXPECT_NE(elm, nullptr);
-  EXPECT_EQ(elm->GetType().ToString(), "int");
-  delete elm;
+  tidl::Element elm("test", new tidl::BaseType("int", ""), "", __LINE__);
+  EXPECT_EQ(elm.GetType().ToString(), "int");
 }
 
 TEST_F(ElementTest, Element_GetLine) {
   unsigned line = __LINE__;
-  tidl::Element* elm = new tidl::Element("test",
-      new tidl::BaseType("int", ""), "", line);
-  EXPECT_NE(elm, nullptr);
-  EXPECT_EQ(elm->GetLine(), line);
-  delete elm;
+  tidl::Element elm("test", new tidl::BaseType("int", ""), "", line);
+  EXPECT_EQ(elm.GetLine(), line);
 }
 
 TEST_F(ElementTest, Element_GetComments) {
   std::string comments = "Test comments";
-  tidl::Element* elm = new tidl::Element("test",
-      new tidl::BaseType("int", ""), comments, __LINE__);
-  EXPECT_NE(elm, nullptr);
-  EXPECT_EQ(elm->GetComments(), comments);
-  delete elm;
+  tidl::Element elm("test", new tidl::BaseType("int", ""), comments, __LINE__);
+  EXPECT_EQ(elm.GetComments(), comments);
 }
 
 class ElementsTest : public testing::Test {
@@ -74,39 +59,32 @@ class ElementsTest : public testing::Test {
 };
 
 TEST_F(ElementsTest, Elements_Constructor) {
-  tidl::Elements* elms = new tidl::Elements();
-  EXPECT_NE(elms, nullptr);
-  delete elms;
+  tidl::Elements elms();
 }
 
 TEST_F(ElementsTest, Elements_Add) {
-  tidl::Element* elm = new tidl::Element("test",
-      new tidl::BaseType("int", ""), "", __LINE__);
-  EXPECT_NE(elm, nullptr);
-  tidl::Elements* elms = new tidl::Elements();
-  EXPECT_NE(elms, nullptr);
-  elms->Add(elm);
+  tidl::Elements elms;
+  elms.Add(std::unique_ptr<tidl::Element>(
+      new tidl::Element("test", new tidl::BaseType("int", ""), "", __LINE__)));
 
   bool flag = false;
-  for (auto& elm : elms->GetElms()) {
+  for (const auto& elm : elms) {
     if (elm->GetID() == "test" &&
         elm->GetType().ToString() == "int")
       flag = true;
   }
   EXPECT_EQ(flag, true);
-  delete elms;
 }
 
-TEST_F(ElementsTest, Elements_Getelms) {
-  tidl::Elements* elms = new tidl::Elements();
-  EXPECT_NE(elms, nullptr);
-  elms->Add(new tidl::Element("test1", new tidl::BaseType("int", ""),
-      "", __LINE__));
-  elms->Add(new tidl::Element("test2", new tidl::BaseType("char *", ""),
-      "", __LINE__));
+TEST_F(ElementsTest, Elements_range_for) {
+  tidl::Elements elms;
+  elms.Add(std::unique_ptr<tidl::Element>(new tidl::Element(
+      "test1", new tidl::BaseType("int", ""), "", __LINE__)));
+  elms.Add(std::unique_ptr<tidl::Element>(new tidl::Element(
+      "test2", new tidl::BaseType("char *", ""), "", __LINE__)));
 
   int count = 0;
-  for (auto& elm : elms->GetElms()) {
+  for (auto& elm : elms) {
     if (elm->GetID() == "test1" &&
         elm->GetType().ToString() == "int")
       count++;
@@ -115,20 +93,12 @@ TEST_F(ElementsTest, Elements_Getelms) {
       count++;
   }
   EXPECT_EQ(count, 2);
-  delete elms;
 }
 
 TEST_F(ElementsTest, Elements_Exist) {
-  tidl::Element* elm = new tidl::Element("test",
-      new tidl::BaseType("int", ""), "", __LINE__);
-  EXPECT_NE(elm, nullptr);
-  tidl::Elements* elms = new tidl::Elements();
-  EXPECT_NE(elms, nullptr);
-  elms->Add(elm);
-  tidl::Element* elm2 = new tidl::Element("test",
-      new tidl::BaseType("int", ""), "", __LINE__);
-  EXPECT_NE(elm, nullptr);
-  EXPECT_EQ(elms->Exist(elm2), true);
-  delete elm2;
-  delete elms;
+  tidl::Elements elms;
+  elms.Add(std::unique_ptr<tidl::Element>(new tidl::Element("test",
+      new tidl::BaseType("int", ""), "", __LINE__)));
+  tidl::Element elm2("test", new tidl::BaseType("int", ""), "", __LINE__);
+  EXPECT_EQ(elms.Exist(elm2), true);
 }
index 780aca5..c2e2878 100644 (file)
@@ -27,16 +27,16 @@ class InterfaceTest : public testing::Test {
   virtual void SetUp() {
     tidl::Parameters* params = new tidl::Parameters();
     EXPECT_NE(params, nullptr);
-    params->Add(new tidl::Parameter("test1",
-          new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
-    params->Add(new tidl::Parameter("test2",
-          new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
+    params->Add(std::unique_ptr<tidl::Parameter>(new tidl::Parameter("test1",
+          new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__)));
+    params->Add(std::unique_ptr<tidl::Parameter>(new tidl::Parameter("test2",
+          new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__)));
     tidl::Declaration* decl = new tidl::Declaration("test",
         new tidl::BaseType("int", ""), params, "", __LINE__);
     EXPECT_NE(decl, nullptr);
     decls = new tidl::Declarations();
     EXPECT_NE(decls, nullptr);
-    decls->Add(decl);
+    decls->Add(std::unique_ptr<tidl::Declaration>(decl));
   }
   virtual void TearDown() {}
 };
@@ -54,7 +54,7 @@ TEST_F(InterfaceTest, Interface_GetDeclrations) {
   EXPECT_NE(interface, nullptr);
 
   bool flag = false;
-  for (auto& d : interface->GetDeclarations().GetDecls()) {
+  for (const auto& d : interface->GetDeclarations()) {
     if (d->GetID() == "test")
       flag = true;
   }
index 4e68e98..9abab7c 100644 (file)
@@ -27,10 +27,10 @@ class StructureTest : public testing::Test {
   virtual void SetUp() {
     elms = new tidl::Elements();
     EXPECT_NE(elms, nullptr);
-    elms->Add(new tidl::Element("test1", new tidl::BaseType("int", ""),
-        "", __LINE__));
-    elms->Add(new tidl::Element("test2", new tidl::BaseType("char *", ""),
-        "", __LINE__));
+    elms->Add(std::unique_ptr<tidl::Element>(new tidl::Element("test1",
+        new tidl::BaseType("int", ""), "", __LINE__)));
+    elms->Add(std::unique_ptr<tidl::Element>(new tidl::Element("test2",
+        new tidl::BaseType("char *", ""), "", __LINE__)));
   }
   virtual void TearDown() {}
 };
@@ -48,7 +48,7 @@ TEST_F(StructureTest, Structure_GetElements) {
   EXPECT_NE(structure, nullptr);
 
   int count = 0;
-  for (auto& elm : elms->GetElms()) {
+  for (const auto& elm : *elms) {
     if (elm->GetID() == "test1" &&
         elm->GetType().ToString() == "int")
       count++;