Fix C generator related enumeration 02/288402/1
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 16 Feb 2023 06:31:14 +0000 (06:31 +0000)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 16 Feb 2023 06:31:14 +0000 (06:31 +0000)
The generated enumeration value is changed to the uppercase.
The prefix of the enumeration is added to the value as below:
<PREFIX>_<NAME>_<OWNER_NAME>_<ENUM_VALUE>
e.g. RPC_PORT_PROXY_MESSAGE_CHANNEL_CLIENT

Change-Id: I7020361f4f1f8ef7ba81071fa4adf7c8801071a6
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
idlc/gen/c_gen_base.cc
idlc/gen/version2/c_header_generator_base.cc
idlc/gen/version2/c_header_generator_base_cb.hh

index 25bf554..2aa922d 100644 (file)
@@ -477,9 +477,9 @@ std::string CGeneratorBase::GetEnumTypeString(
   }
 
   if (direction == ParameterType::Direction::IN)
-    return GetHandlePrefix() + "_" + block_id + "_" + type_id + " ";
+    return GetHandlePrefix() + "_" + block_id + "_" + type_id + "_e ";
   else
-    return GetHandlePrefix() + "_" + block_id + "_" + type_id + " *";
+    return GetHandlePrefix() + "_" + block_id + "_" + type_id + "_e *";
 }
 
 std::string CGeneratorBase::GetParamTypeString(
index d17f058..5004317 100644 (file)
@@ -59,17 +59,19 @@ void CHeaderGeneratorBase::GenEnum(std::ofstream& stream,
   for (auto& e : block.GetEnums()) {
     std::string enums;
     for (auto& f : e->GetFields()) {
+      enums += GetHandlePrefix() + "_" + e->GetID() + "_" + block.GetID() + "_";
       if (f->GetValue().empty())
         enums += f->GetID() + "," + NLine(1);
       else
         enums += f->GetID() + " = " + f->GetValue() + "," + NLine(1);
     }
 
-    ReplaceAll(CB_ENUM_BASE, {{"<ENUMS>", enums},
-                              {"<PREFIX>", GetHandlePrefix()},
-                              {"<NAME>", e->GetID()},
-                              {"<OWNER_NAME>", block.GetID()}})
-        .Transform([&](std::string str) { return SmartIndent(str); })
+    ReplaceAll(CB_ENUM_BASE)
+        .ChangeToUpper("<ENUMS>", enums)
+        .Change("<PREFIX>", GetHandlePrefix())
+        .Change("<NAME>", e->GetID())
+        .Change("<OWNER_NAME>", block.GetID())
+        .Transform([&](std::string code) { return SmartIndent(code); })
         .Out(stream);
   }
 }
@@ -80,9 +82,9 @@ void CHeaderGeneratorBase::GenStructureArrayBase(std::ofstream& stream,
   auto& type = elm->GetType();
   std::string id;
 
-  auto n = type.ToString().find('.');
+  auto pos = type.ToString().find('.');
   if (type.GetUserDefinedType() == BaseType::UserType::ENUM &&
-        n == std::string::npos)
+      pos == std::string::npos)
     id = GetEnumBockString(type.ToString());
   else
     id = st.GetID();
index edec0ec..7199a2f 100644 (file)
@@ -32,7 +32,7 @@ R"__c_cb(
  */
 typedef enum  {
   <ENUMS>
-} <PREFIX>_<OWNER_NAME>_<NAME>;
+} <PREFIX>_<OWNER_NAME>_<NAME>_e;
 )__c_cb";
 
 /**