Fix C++ Generator of version 2
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 25 Apr 2024 02:00:17 +0000 (11:00 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 18 Jun 2024 06:25:37 +0000 (15:25 +0900)
- Add setting the initialization value

Change-Id: I7226c5892c948a75b044fd6ca21257ac8c67ec10
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
idlc/gen/version2/cpp_generator_base.cc
idlc/gen/version2/cpp_generator_base_cb.hh

index 61f8b7ab093b4013f9150fdfb604b3be3b9c610e..83f3135d62fd83c7284fc51ed00d70e155baf987 100644 (file)
@@ -898,7 +898,8 @@ std::string CppGeneratorBase::GenUnitImplDeserializer(const BaseType& type) {
   } else {
     code = ReplaceAll(CB_UNIT_IMPL_DESERIALIZER_BASE)
         .Change("<TYPE>", ConvertTypeToString(type))
-        .Change("<PARCEL_TYPE>", GetParcelType(type));
+        .Change("<PARCEL_TYPE>", GetParcelType(type))
+        .Change("<SET_INIT_VALUE>", GetSettingInitValue(type));
   }
 
   return RemoveLine(code);
@@ -912,7 +913,8 @@ std::string CppGeneratorBase::GenUnitMapBaseRead(const Structure& st) {
   for (auto& elm : st.GetElements()) {
     code += ReplaceAll(CB_UNIT_MAP_BASE_READ)
         .Change("<TYPE>", ConvertTypeToString(elm->GetType()))
-        .Change("<NAME>", elm->GetID());
+        .Change("<NAME>", elm->GetID())
+        .Change("<SET_INIT_VALUE>", GetSettingInitValue(elm->GetType()));
   }
 
   return code;
index aaeda07aa6a6cff6dd81495c52d5b5c057ba0704..237da748844dcc7f1a75aa77404db06c317e6cf1 100644 (file)
@@ -820,10 +820,11 @@ for (int index = 0; index < tmp_size; ++index) {
 
 /**
  * <NAME> The name of the element of the value.
+ * <SET_INIT_VALUE> The setting initialization value.
  */
 constexpr const char CB_UNIT_MAP_BASE_READ[] =
 R"__cpp_cb(
-<TYPE> tmp_<NAME>;
+<TYPE> tmp_<NAME><SET_INIT_VALUE>;
 unit_map.Read("<NAME>", tmp_<NAME>);
 value.Set<NAME>(tmp_<NAME>);
 )__cpp_cb";
@@ -905,10 +906,11 @@ if (tmp_filename != nullptr) {
 /**
  * <TYPE> The type of the parameter.
  * <PARCEL_TYPE> The type of the parcel type of the parameter.
+ * <SET_INIT_VALUE> The setting initialization value.
  */
 constexpr const char CB_UNIT_IMPL_DESERIALIZER_BASE[] =
 R"__cpp_cb(
-<TYPE> tmp_value;
+<TYPE> tmp_value<SET_INIT_VALUE>;
 rpc_port_parcel_read_<PARCEL_TYPE>(GetParcel(), &tmp_value);
 value = tmp_value;
 )__cpp_cb";
@@ -918,7 +920,7 @@ value = tmp_value;
  */
 constexpr const char CB_UNIT_IMPL_DESERIALIZER_ENUM[] =
 R"__cpp_cb(
-int tmp_value;
+int tmp_value = -1;
 rpc_port_parcel_read_int32(GetParcel(), &tmp_value);
 value = static_cast<<TYPE>>(tmp_value);
 )__cpp_cb";