Fix bugs of c generator 34/171434/1
authorHwankyu Jhun <h.jhun@samsung.com>
Mon, 5 Mar 2018 04:28:39 +0000 (13:28 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 5 Mar 2018 04:29:42 +0000 (13:29 +0900)
- Fixes a wrong indentation
- Fixes wrong parameters
- Fixes header generator base

Change-Id: I63d7c4572e99aa78582218e3ff8bb5b713bb0251
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
idlc/c_gen/c_gen_base.cc
idlc/c_gen/c_header_gen_base.cc
idlc/c_gen/c_stub_body_gen.cc
idlc/c_gen/c_stub_header_gen.cc

index 055519b..a0f9f15 100644 (file)
@@ -302,9 +302,9 @@ std::string CGeneratorBase::GetParamTypeString(
       type.ToString() == "list" ||
       type.ToString() == "array") {
     if (direction == ParameterType::Direction::IN)
-      return "rpc_port_" + type.ToString() + "_h ";
+      return "rpc_port_" + GetFullNameFromType(type) + "_h ";
     else
-      return "rpc_port_" + type.ToString() + "_h *";
+      return "rpc_port_" + GetFullNameFromType(type) + "_h *";
   }
 
   if (type.ToString() == "string") {
index 78920cd..47b6c26 100644 (file)
@@ -52,14 +52,22 @@ void CHeaderGeneratorBase::GenExplicitLinkageClose(std::ofstream& stream) {
 
 void CHeaderGeneratorBase::GenStructures(std::ofstream& stream) {
   for (auto& i : GetDocument().GetBlocks()) {
-    if (i->GetType() != Block::TYPE_STRUCTURE)
-      continue;
-
-    const Structure &st = static_cast<const Structure&>(*i);
-    GenStructure(stream, st);
-    for (auto& j : st.GetElements().GetElms()) {
-      auto& t = j->GetType();
-      AddStructureFromType(t);
+    if (i->GetType() == Block::TYPE_STRUCTURE) {
+      const Structure &st = static_cast<const Structure&>(*i);
+      GenStructure(stream, st);
+      for (auto& j : st.GetElements().GetElms()) {
+       auto& t = j->GetType();
+       AddStructureFromType(t);
+      }
+    } else {
+      const Interface &inf = static_cast<const Interface&>(*i);
+      for (auto& d : inf.GetDeclarations().GetDecls()) {
+        for (auto& p : d->GetParameters().GetParams()) {
+          if (TypeIsDelegator(inf, p->GetParameterType().GetBaseType()))
+            continue;
+          AddStructureFromType(p->GetParameterType().GetBaseType());
+        }
+      }
     }
   }
 
index 8550724..d178f98 100644 (file)
@@ -390,7 +390,7 @@ std::string CStubBodyGen::GetMethodString(const Interface& inf,
 
   if (decl.GetMethodType() == Declaration::MethodType::SYNC &&
       decl.GetType().ToString() != "void") {
-    str += GetReturnTypeString(decl.GetType()) + " ret = ";
+    str += GetReturnTypeString(decl.GetType()) + "ret = ";
   }
 
   str += "context->callback." + decl.GetID() + "(context";
@@ -695,7 +695,7 @@ void CStubBodyGen::GenInterfaceDelegatorInvoker(std::ofstream& stream,
           str += "rpc_port_" + decl.GetID() + "_h h";
           for (auto& i : decl.GetParameters().GetParams()) {
             str += ", ";
-            str += ConvertTypeToString(i->GetParameterType().GetDirection(),
+            str += GetParamTypeString(i->GetParameterType().GetDirection(),
                 i->GetParameterType().GetBaseType()) + i->GetID();
           }
           return str;
index fe60036..d13b8f1 100644 (file)
@@ -192,7 +192,7 @@ void CStubHeaderGen::GenInterfaceDelegatorInvoker(
         for (auto& i : decl.GetParameters().GetParams()) {
           str += ", ";
           str += GetParamTypeString(i->GetParameterType().GetDirection(),
-              i->GetParameterType().GetBaseType()) + " " + i->GetID();
+              i->GetParameterType().GetBaseType()) + i->GetID();
         }
         return str;
       }