Fix bugs related to ref keyword 79/312979/2
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 18 Jun 2024 05:04:58 +0000 (14:04 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 18 Jun 2024 05:14:06 +0000 (14:14 +0900)
The ref parameter must be written and read.

Change-Id: I0a98164213c033329ad7b58262b9669caec6cdf3
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
idlc/gen/c_proxy_body_gen.cc
idlc/gen/c_stub_body_gen.cc
idlc/gen/version2/c_proxy_body_generator.cc
idlc/gen/version2/c_stub_body_generator.cc
idlc/gen/version2/cpp_proxy_body_generator.cc
idlc/gen/version2/cpp_stub_body_generator.cc

index 1efe1f40675a8ba02b9ad2c280ed8bd90f7a23ec..94da9ad6f1f28d12f8c9bfdd66804e9b2f44d133 100644 (file)
@@ -62,15 +62,14 @@ void CProxyBodyGen::GenInterfaceDefs(std::ofstream& stream) {
 }
 
 void CProxyBodyGen::GenInterfaceDef(std::ofstream& stream,
-    const Interface& iface) {
-   for (const auto& d : iface.GetDeclarations()) {
-    if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
-      continue;
+                                    const Interface& iface) {
+  for (const auto& d : iface.GetDeclarations()) {
+    if (d->GetMethodType() != Declaration::MethodType::DELEGATE) continue;
 
     GenInterfaceDelegateDef(stream, iface, *d);
   }
 
-   GenInterfaceBaseDef(stream, iface);
+  GenInterfaceBaseDef(stream, iface);
 }
 
 // @see #CB_INTERFACE_DELEGATE_DEF
@@ -159,7 +158,8 @@ void CProxyBodyGen::GenInterfaceDelegateEnumBase(std::ofstream& stream,
     if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
       continue;
 
-    enums += GetHandlePrefix() + "_" + iface.GetID() + "_DELEGATE_" + d->GetID();
+    enums +=
+        GetHandlePrefix() + "_" + iface.GetID() + "_DELEGATE_" + d->GetID();
     enums += " = " + std::to_string(num++) + ",";
     enums += NLine(1);
   }
@@ -419,9 +419,12 @@ std::string CProxyBodyGen::GenMethodParcelWrite(const Interface& iface,
   std::string code;
   for (const auto& p : decl.GetParameters()) {
     auto& param_type = p->GetParameterType();
-    if (param_type.GetDirection() != ParameterType::Direction::IN)
+    if (param_type.GetDirection() == ParameterType::Direction::OUT)
       continue;
 
+    std::string param_name =
+        param_type.GetDirection() == ParameterType::Direction::REF
+            ? "*" + p->GetID() : p->GetID();
     std::string parcel_write_code;
     auto& type = param_type.GetBaseType();
     if (IsDelegateType(iface, type) ||
@@ -433,23 +436,23 @@ std::string CProxyBodyGen::GenMethodParcelWrite(const Interface& iface,
           p->GetID());
       std::string name = GetFullNameFromType(type, iface);
       parcel_write_code += GetPrivateSharingString(type, iface, "h->port",
-          p->GetID());
+          param_name);
     } else if (type.ToString() == "bundle") {
       parcel_write_code = ReplaceAll(CB_INTERFACE_METHOD_BUNDLE_PARCEL_WRITE,
-          "<ARG>", p->GetID());
+          "<ARG>", param_name);
     } else if (type.ToString() == "string") {
       parcel_write_code = ReplaceAll(CB_INTERFACE_METHOD_STRING_PARCEL_WRITE,
-          "<ARG>", p->GetID());
+          "<ARG>", "STRING_GET(" + param_name + ")");
     } else if (type.ToString() == "file") {
       parcel_write_code = ReplaceAll(CB_INTERFACE_METHOD_STRING_PARCEL_WRITE,
-          "<ARG>", p->GetID());
+          "<ARG>", param_name);
       parcel_write_code += GetPrivateSharingString(type, iface, "h->port",
-          p->GetID());
+          param_name);
     } else {
       parcel_write_code = ReplaceAll(CB_INTERFACE_METHOD_BASE_PARCEL_WRITE,
           "<PARCEL_TYPE>", GetParcelType(type));
       parcel_write_code = ReplaceAll(parcel_write_code, "<ARG>",
-          p->GetID());
+          param_name);
     }
 
     code += parcel_write_code;
@@ -502,7 +505,7 @@ std::string CProxyBodyGen::GenMethodArgs(const Interface& iface,
   std::string args_code;
   for (const auto& p : decl.GetParameters()) {
     auto& param_type = p->GetParameterType();
-    if (param_type.GetDirection() != ParameterType::Direction::OUT)
+    if (param_type.GetDirection() == ParameterType::Direction::IN)
       continue;
 
     auto& type = param_type.GetBaseType();
@@ -553,7 +556,7 @@ std::string CProxyBodyGen::GenMethodParcelRead(const Interface& iface,
   std::string parcel_read_code;
   for (const auto& p : decl.GetParameters()) {
     auto& param_type = p->GetParameterType();
-    if (param_type.GetDirection() != ParameterType::Direction::OUT)
+    if (param_type.GetDirection() == ParameterType::Direction::IN)
       continue;
 
     auto& type = param_type.GetBaseType();
index 61195e944a10148ca2a9a526b345d812ca30e002..087ab08d708eb822442319913d49c879bd682a5a 100644 (file)
@@ -428,7 +428,7 @@ std::string CStubBodyGen::GenMethodHandlerParcelRead(const Interface& iface,
   for (const auto& p : decl.GetParameters()) {
     std::string parcel_read_code;
     auto& param_type = p->GetParameterType();
-    if (param_type.GetDirection() != ParameterType::Direction::IN)
+    if (param_type.GetDirection() == ParameterType::Direction::OUT)
       continue;
 
     auto& type = param_type.GetBaseType();
index 4fbdd4d9213ebc7f5b2223beaf2c29e00be83fe6..95b964729f5b8bbea816a973977bbc1fa42d2b0f 100644 (file)
@@ -253,7 +253,7 @@ std::string CProxyBodyGenerator::GenMethodUnitMapWrite(const Interface& iface,
     } else if (type.ToString() == "string") {
       code += ReplaceAll(CB_INTERFACE_METHOD_STRING_UNIT_MAP_WRITE)
           .Change("<ARG_NAME>", param->GetID())
-          .Change("<ARG>", arg);
+          .Change("<ARG>", "STRING_GET(" + arg + ")");
     } else if (type.ToString() == "file") {
       code += ReplaceAll(CB_INTERFACE_METHOD_STRING_UNIT_MAP_WRITE)
           .Change("<ARG_NAME>", param->GetID())
index 3cedd41de81abe3f16b4dbac5ca98b969465a8e1..f968c4c94f62631d2c786703eb6dbcbb5357572f 100644 (file)
@@ -553,7 +553,7 @@ std::string CStubBodyGenerator::GenMethodUnitMapWriteBase(
   } else if (type.ToString() == "string") {
     parcel_write_code = ReplaceAll(CB_INTERFACE_METHOD_STRING_UNIT_MAP_WRITE)
         .Change("<ARG_NAME>", arg_name)
-        .Change("<ARG>", arg);
+        .Change("<ARG>", "STRING_GET(" + arg + ")");
   } else if (type.ToString() == "file") {
     parcel_write_code = ReplaceAll(CB_INTERFACE_METHOD_STRING_UNIT_MAP_WRITE)
         .Change("<ARG_NAME>", arg_name)
index ec246310db7793b8da7b64b3ee1e78c984867d8b..25b73b4e68384ea1621509f6cf57757486adf88f 100644 (file)
@@ -212,8 +212,8 @@ std::string CppProxyBodyGenerator::GenInterfaceMethodSerialize(
     const Declaration& decl) {
   std::string code;
   for (auto& param : decl.GetParameters()) {
-    if (param->GetParameterType().GetDirection() !=
-        ParameterType::Direction::IN)
+    if (param->GetParameterType().GetDirection() ==
+        ParameterType::Direction::OUT)
       continue;
 
     code += ReplaceAll(CB_INTERFACE_METHOD_UNIT_MAP_WRITE)
index 5072c75887e900c183382bb58d43d39a2ebf02dc..a5cc93c8fe3b142e87293866c2a617d58c1e41b3 100644 (file)
@@ -297,8 +297,8 @@ std::string CppStubBodyGenerator::GenInterfaceServiceBaseDeserialize(
           .Change("<NAME>", param->GetID());
     }
 
-    if (param->GetParameterType().GetDirection() !=
-        ParameterType::Direction::IN)
+    if (param->GetParameterType().GetDirection() ==
+        ParameterType::Direction::OUT)
       continue;
 
     code += RemoveLine(