Fix bugs related to unit map 14/297314/2
authorjusung son <jusung07.son@samsung.com>
Thu, 17 Aug 2023 00:05:02 +0000 (09:05 +0900)
committerjusung son <jusung07.son@samsung.com>
Thu, 17 Aug 2023 01:58:33 +0000 (10:58 +0900)
Depending on the parameter marshaling feature,
it is not an error even if there are no parameters.

Change-Id: I4b624b8aff87260a6814776168be9ad13dc37dac
Signed-off-by: jusung son <jusung07.son@samsung.com>
idlc/gen/version2/c_body_generator_array_base_cb.hh
idlc/gen/version2/c_body_generator_base_cb.hh
idlc/gen/version2/c_body_generator_list_base_cb.hh
idlc/gen/version2/c_body_generator_map_base_cb.hh
idlc/gen/version2/c_body_generator_set_base_cb.hh
idlc/gen/version2/c_group_body_generator_cb.hh
idlc/gen/version2/c_proxy_body_generator_cb.hh
idlc/gen/version2/c_stub_body_generator_cb.hh
idlc/gen/version2/cs_generator_base.cc
idlc/gen/version2/cs_generator_base.h
idlc/gen/version2/cs_generator_base_cb.h

index ffadc4285b802a44053ef8748f4262b5fd46fd0b..20d1e717c71e9cc6a1483375a53636792cec1853 100644 (file)
@@ -82,7 +82,6 @@ static void __<PREFIX>_<NAME>_from(rpc_port_parcel_h parcel, void *data)
   <PREFIX>_<NAME>_t *handle = data;
   rpc_port_unit_map_h map;
   char index[12];
-  int ret;
   int i;
 
   if (parcel == nullptr || handle == nullptr) {
@@ -98,14 +97,7 @@ static void __<PREFIX>_<NAME>_from(rpc_port_parcel_h parcel, void *data)
   }
 
   rpc_port_parcel_read(parcel, &map->parcelable, map);
-
-  ret = rpc_port_unit_map_read_int(map, "size", &handle->size);
-  if (ret != RPC_PORT_ERROR_NONE) {
-    _E("Failed to read size. error(%d)", ret);
-    rpc_port_unit_map_destroy(map);
-    set_last_result(ret);
-    return;
-  }
+  rpc_port_unit_map_read_int(map, "size", &handle->size);
 
   handle->value = calloc(handle->size, sizeof(<ELEMENT_TYPE_SIZE>));
   if (handle->value == nullptr) {
@@ -187,7 +179,7 @@ int <PREFIX>_<NAME>_clone(<PREFIX>_<NAME>_h h, <PREFIX>_<NAME>_h *clone)
     return ret;
   }
 
-  ret = rpc_port_unit_map_read_<NAME>(map, "clone", clone);
+  rpc_port_unit_map_read_<NAME>(map, "clone", clone);
   rpc_port_unit_map_destroy(map);
 
   return ret;
@@ -301,46 +293,22 @@ rpc_port_unit_map_write_<TYPE_NAME>(map, index, handle->value[i]);
  */
 constexpr const char CB_STRUCTURE_ARRAY_USER_DEFINED_UNIT_MAP_READ[] =
 R"__c_cb(
-ret = rpc_port_unit_map_read_<TYPE_NAME>(map, index, &handle->value[i]);
-if (ret != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read <TYPE_NAME>. error(%d)", ret);
-  rpc_port_unit_map_destroy(map);
-  set_last_result(ret);
-  return;
-}
+rpc_port_unit_map_read_<TYPE_NAME>(map, index, &handle->value[i]);
 )__c_cb";
 
 constexpr const char CB_STRUCTURE_ARRAY_ENUM_UNIT_MAP_READ[] =
 R"__c_cb(
-ret = rpc_port_unit_map_read_int(map, index, (int *)&handle->value[i]);
-if (ret != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read int. error(%d)", ret);
-  rpc_port_unit_map_destroy(map);
-  set_last_result(ret);
-  return;
-}
+rpc_port_unit_map_read_int(map, index, (int *)&handle->value[i]);
 )__c_cb";
 
 constexpr const char CB_STRUCTURE_ARRAY_BUNDLE_UNIT_MAP_READ[] =
 R"__c_cb(
-ret = rpc_port_unit_map_read_bundle(map, index, &handle->value[i]);
-if (ret != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read bundle. error(%d)", ret);
-  rpc_port_unit_map_destroy(map);
-  set_last_result(ret);
-  return;
-}
+rpc_port_unit_map_read_bundle(map, index, &handle->value[i]);
 )__c_cb";
 
 constexpr const char CB_STRUCTURE_ARRAY_STRING_UNIT_MAP_READ[] =
 R"__c_cb(
-ret = rpc_port_unit_map_read_string(map, index, &handle->value[i]);
-if (ret != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read string. error(%d)", ret);
-  rpc_port_unit_map_destroy(map);
-  set_last_result(ret);
-  return;
-}
+rpc_port_unit_map_read_string(map, index, &handle->value[i]);
 )__c_cb";
 
 /**
@@ -348,13 +316,7 @@ if (ret != RPC_PORT_ERROR_NONE) {
  */
 constexpr const char CB_STRUCTURE_ARRAY_BASE_UNIT_MAP_READ[] =
 R"__c_cb(
-ret = rpc_port_unit_map_read_<TYPE_NAME>(map, index, &handle->value[i]);
-if (ret != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read <TYPE_NAME>. error(%d)", ret);
-  rpc_port_unit_map_destroy(map);
-  set_last_result(ret);
-  return;
-}
+rpc_port_unit_map_read_<TYPE_NAME>(map, index, &handle->value[i]);
 )__c_cb";
 
 /**
index e530dfb9d880da06d644f3f4e4001496ffde30ef..7c460a9b6e683ecd55c5b6d6a38bc4d248bea911 100644 (file)
@@ -115,25 +115,10 @@ static void __rpc_port_unit_from(rpc_port_parcel_h parcel, void *user_data)
   rpc_port_unit_h unit = user_data;
   unsigned char *raw;
   int size = 0;
-  int ret;
-
-  ret = rpc_port_parcel_read_string(parcel, &unit->name);
-  if (ret != RPC_PORT_ERROR_NONE) {
-    set_last_result(ret);
-    return;
-  }
-
-  ret = rpc_port_parcel_read_string(parcel, &unit->type);
-  if (ret != RPC_PORT_ERROR_NONE) {
-    set_last_result(ret);
-    return;
-  }
 
-  ret = rpc_port_parcel_read_array_count(parcel, &size);
-  if (ret != RPC_PORT_ERROR_NONE) {
-    set_last_result(ret);
-    return;
-  }
+  rpc_port_parcel_read_string(parcel, &unit->name);
+  rpc_port_parcel_read_string(parcel, &unit->type);
+  rpc_port_parcel_read_array_count(parcel, &size);
 
   raw = malloc(size);
   if (raw == nullptr) {
@@ -142,16 +127,10 @@ static void __rpc_port_unit_from(rpc_port_parcel_h parcel, void *user_data)
     return;
   }
 
-  ret = rpc_port_parcel_burst_read(parcel, (void *)raw, size);
-  if (ret != RPC_PORT_ERROR_NONE) {
-    free(raw);
-    set_last_result(ret);;
-    return;
-  }
-
-  ret = rpc_port_parcel_burst_write(unit->parcel, raw, size);
+  rpc_port_parcel_burst_read(parcel, (void *)raw, size);
+  rpc_port_parcel_burst_write(unit->parcel, raw, size);
   free(raw);
-  set_last_result(ret);
+  set_last_result(RPC_PORT_ERROR_NONE);
 }
 
 static void rpc_port_unit_destroy(gpointer user_data)
@@ -434,122 +413,151 @@ static int rpc_port_unit_map_write_<TYPE_NAME>(rpc_port_unit_map_h unit_map,
  */
 constexpr const char CB_UNIT_MAP_USER_DEFINED_READ[] =
 R"__c_cb(
-static int rpc_port_unit_map_read_<TYPE_NAME>(rpc_port_unit_map_h unit_map,
+static void rpc_port_unit_map_read_<TYPE_NAME>(rpc_port_unit_map_h unit_map,
     const char *name, <PARAM_TYPE_OUT>value)
 {
   rpc_port_unit_h unit;
   <PARAM_TYPE_IN>handle;
   int ret;
 
-  if (unit_map == nullptr || name == nullptr || value == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (value == nullptr) {
+    _E("Invalid parameter");
+    return;
+  }
+
+  ret = <PARAM_TYPE_CTOR>((<PARAM_TYPE_OUT>)&handle);
+  if (ret != RPC_PORT_ERROR_NONE) {
+    *value = nullptr;
+    return;
+  }
+
+  *value = handle;
+  if (unit_map == nullptr || name == nullptr) {
+    _E("Invalid parameter");
+    return;
+  }
 
   unit = g_hash_table_lookup(unit_map->table, name);
   if (unit == nullptr) {
     _E("g_hash_table_lookup() is failed. name: %s", name);
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+    return;
   }
 
   if (strncmp(unit->type, "<FULL_TYPE_NAME>", strlen("<FULL_TYPE_NAME>")) != 0) {
     _E("type(%s) is not <FULL_TYPE_NAME>", unit->type);
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+    return;
   }
 
-  ret = <PARAM_TYPE_CTOR>((<PARAM_TYPE_OUT>)&handle);
-  if (ret != RPC_PORT_ERROR_NONE)
-    return ret;
-
-  *value = handle;
   rpc_port_parcel_read(unit->parcel, &handle->parcelable, handle);
-
-  return get_last_result();
 }
 )__c_cb";
 
 constexpr const char CB_UNIT_MAP_DELEGATE_READ[] =
 R"__c_cb(
-static int rpc_port_unit_map_read_delegate(rpc_port_unit_map_h unit_map,
+static void rpc_port_unit_map_read_delegate(rpc_port_unit_map_h unit_map,
     const char *name, rpc_port_delegate_h *value)
 {
   rpc_port_unit_h unit;
   rpc_port_delegate_h delegate;
 
-  if (unit_map == nullptr || name == nullptr || value == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (value == nullptr) {
+    _E("Invalid parameter");
+    return;
+  }
+
+  delegate = rpc_port_delegate_create();
+  *value = delegate;
+
+  if (delegate == nullptr)
+    return;
+
+  if (unit_map == nullptr || name == nullptr) {
+     _E("Invalid parameter");
+    return;
+  }
 
   unit = g_hash_table_lookup(unit_map->table, name);
   if (unit == nullptr) {
     _E("g_hash_table_lookup() is failed. name: %s", name);
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+    return;
   }
 
   if (strcmp(unit->type, "delegate") != 0) {
     _E("type(%s) is not delegate", unit->type);
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+    return;
   }
 
-  delegate = rpc_port_delegate_create();
-  if (delegate == NULL)
-    return RPC_PORT_ERROR_OUT_OF_MEMORY;
-
-  *value = delegate;
   rpc_port_parcel_read(unit->parcel, &delegate->parcelable, delegate);
-
-  return get_last_result();
 }
 )__c_cb";
 
 constexpr const char CB_UNIT_MAP_BUNDLE_READ[] =
 R"__c_cb(
-static int rpc_port_unit_map_read_bundle(rpc_port_unit_map_h unit_map,
+static void rpc_port_unit_map_read_bundle(rpc_port_unit_map_h unit_map,
     const char *name, bundle **value)
 {
   rpc_port_unit_h unit;
 
-  if (unit_map == nullptr || name == nullptr || value == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (value == nullptr) {
+    _E("Invalid parameter");
+    return;
+  }
+
+  if (unit_map == nullptr || name == nullptr) {
+    *value = bundle_create();
+    _E("Invalid parameter");
+    return;
+  }
 
   unit = g_hash_table_lookup(unit_map->table, name);
   if (unit == nullptr) {
     _E("g_hash_table_lookup() is failed. name: %s", name);
     *value = bundle_create();
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+    return;
   }
 
   if (strcmp(unit->type, "bundle") != 0) {
     _E("type(%s) is not bundle", unit->type);
     *value = bundle_create();
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+    return;
   }
 
-  return rpc_port_parcel_read_bundle(unit->parcel, value);
+  rpc_port_parcel_read_bundle(unit->parcel, value);
 }
 )__c_cb";
 
 constexpr const char CB_UNIT_MAP_STRING_READ[] =
 R"__c_cb(
-static int rpc_port_unit_map_read_string(rpc_port_unit_map_h unit_map,
+static void rpc_port_unit_map_read_string(rpc_port_unit_map_h unit_map,
     const char *name, char **value)
 {
   rpc_port_unit_h unit;
 
-  if (unit_map == nullptr || name == nullptr || value == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (value == nullptr) {
+    _E("Invalid parameter");
+    return;
+  }
+
+  if (unit_map == nullptr || name == nullptr) {
+    *value = strdup("");
+    _E("Invalid parameter");
+    return;
+  }
 
   unit = g_hash_table_lookup(unit_map->table, name);
   if (unit == nullptr) {
     _E("g_hash_table_lookup() is failed. name: %s", name);
     *value = strdup("");
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+    return;
   }
 
   if (strcmp(unit->type, "string") != 0) {
     _E("type(%s) is not string", unit->type);
     *value = strdup("");
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+    return;
   }
 
-  return rpc_port_parcel_read_string(unit->parcel, value);
+  rpc_port_parcel_read_string(unit->parcel, value);
 }
 )__c_cb";
 
@@ -560,28 +568,36 @@ static int rpc_port_unit_map_read_string(rpc_port_unit_map_h unit_map,
  */
 constexpr const char CB_UNIT_MAP_BASE_READ[] =
 R"__c_cb(
-static int rpc_port_unit_map_read_<TYPE_NAME>(rpc_port_unit_map_h unit_map,
+static void rpc_port_unit_map_read_<TYPE_NAME>(rpc_port_unit_map_h unit_map,
     const char *name, <PARAM_TYPE>value)
 {
   rpc_port_unit_h unit;
 
-  if (unit_map == nullptr || name == nullptr || value == nullptr)
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  if (value == nullptr) {
+    _E("Invalid parameter");
+    return;
+  }
+
+  if (unit_map == nullptr || name == nullptr) {
+    *value = 0;
+    _E("Invalid parameter");
+    return;
+  }
 
   unit = g_hash_table_lookup(unit_map->table, name);
   if (unit == nullptr) {
     _E("g_hash_table_lookup() is failed. name: %s", name);
     *value = 0;
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+    return;
   }
 
   if (strcmp(unit->type, "<TYPE_NAME>") != 0) {
     _E("type(%s) is not <TYPE_NAME>", unit->type);
     *value = 0;
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+    return;
   }
 
-  return rpc_port_parcel_read_<PARCEL_TYPE>(unit->parcel, value);
+  rpc_port_parcel_read_<PARCEL_TYPE>(unit->parcel, value);
 }
 )__c_cb";
 
@@ -719,7 +735,7 @@ int <PREFIX>_<NAME>_clone(<PREFIX>_<NAME>_h h, <PREFIX>_<NAME>_h *clone)
     return ret;
   }
 
-  ret = rpc_port_unit_map_read_<NAME>(map, "clone", clone);
+  rpc_port_unit_map_read_<NAME>(map, "clone", clone);
   rpc_port_unit_map_destroy(map);
 
   return ret;
@@ -1240,7 +1256,7 @@ int <PREFIX>_get_remote_exception(<PREFIX>_remote_exception_h *h)
     return ret;
   }
 
-  ret = rpc_port_unit_map_read_remote_exception(map, "clone", h);
+  rpc_port_unit_map_read_remote_exception(map, "clone", h);
   rpc_port_unit_map_destroy(map);
 
   return RPC_PORT_ERROR_NONE;
@@ -1277,7 +1293,7 @@ int <PREFIX>_remote_exception_throw(<PREFIX>_remote_exception_h h)
     __<PREFIX>_remote_exception = nullptr;
   }
 
-  ret = rpc_port_unit_map_read_remote_exception(map, "clone", &__<PREFIX>_remote_exception);
+  rpc_port_unit_map_read_remote_exception(map, "clone", &__<PREFIX>_remote_exception);
   rpc_port_unit_map_destroy(map);
 
   return ret;
index 2676464972ab0518d459205498670c9d2277365b..c8d8de756f33847f26becb3b51e59f1e724b7232 100644 (file)
@@ -89,7 +89,6 @@ static void __<PREFIX>_<NAME>_from(rpc_port_parcel_h parcel, void *data)
   <DATA_TYPE>value = nullptr;
   rpc_port_unit_map_h map;
   char index[12];
-  int ret;
   int len = 0;
   int i;
 
@@ -108,13 +107,7 @@ static void __<PREFIX>_<NAME>_from(rpc_port_parcel_h parcel, void *data)
 
   rpc_port_parcel_read(parcel, &map->parcelable, map);
 
-  ret = rpc_port_unit_map_read_int(parcel, "length", &len);
-  if (ret != RPC_PORT_ERROR_NONE) {
-    _E("Failed to read length. error(%d)", ret);
-    rpc_port_unit_map_destroy(map);
-    set_last_result(ret);
-    return;
-  }
+  rpc_port_unit_map_read_int(parcel, "length", &len);
 
   for (i = 0; i < len; ++i) {
     snprintf(index, sizeof(index), "%d", i);
@@ -199,7 +192,7 @@ int <PREFIX>_<NAME>_clone(<PREFIX>_<NAME>_h h, <PREFIX>_<NAME>_h *clone)
     return ret;
   }
 
-  ret = rpc_port_unit_map_read_<NAME>(map, "clone", clone);
+  rpc_port_unit_map_read_<NAME>(map, "clone", clone);
   rpc_port_unit_map_destroy(map);
 
   return ret;
@@ -308,14 +301,7 @@ rpc_port_unit_map_write_<TYPE_NAME>(parcel, index, *value);
 constexpr const char CB_STRUCTURE_LIST_USER_DEFINED_UNIT_MAP_READ[] =
 R"__c_cb(
 value = nullptr;
-ret = rpc_port_unit_map_read_<TYPE_NAME>(map, index, &value);
-if (ret != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read <TYPE_NAME>. error(%d)", ret);
-  rpc_port_unit_map_destroy(map);
-  set_last_result(ret);
-  return;
-}
-
+rpc_port_unit_map_read_<TYPE_NAME>(map, index, &value);
 handle->list = g_list_append(handle->list, value);
 )__c_cb";
 
@@ -329,43 +315,21 @@ if (value == nullptr) {
   return;
 }
 
-ret = rpc_port_unit_map_read_int(map, index, (int*)&value);
-if (ret != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read int. error(%d)", ret);
-  free(value);
-  rpc_port_unit_map_destroy(map);
-  set_last_result(ret);
-  return;
-}
-
+rpc_port_unit_map_read_int(map, index, (int*)&value);
 handle->list = g_list_append(handle->list, value);
 )__c_cb";
 
 constexpr const char CB_STRUCTURE_LIST_BUNDLE_UNIT_MAP_READ[] =
 R"__c_cb(
 value = nullptr;
-ret = rpc_port_unit_map_read_bundle(map, index, &value);
-if (ret != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read bundle. error(%d)", ret);
-  rpc_port_unit_map_destroy(map);
-  set_last_result(ret);
-  return;
-}
-
+rpc_port_unit_map_read_bundle(map, index, &value);
 handle->list = g_list_append(handle->list, value);
 )__c_cb";
 
 constexpr const char CB_STRUCTURE_LIST_STRING_UNIT_MAP_READ[] =
 R"__c_cb(
 value = nullptr;
-ret = rpc_port_unit_map_read_string(map, index, &value);
-if (ret != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read string. error(%d)", ret);
-  rpc_port_unit_map_destroy(map);
-  set_last_result(ret);
-  return;
-}
-
+rpc_port_unit_map_read_string(map, index, &value);
 handle->list = g_list_append(handle->list, value);
 )__c_cb";
 
@@ -383,15 +347,7 @@ if (value == nullptr) {
   return;
 }
 
-ret = rpc_port_unit_map_read_<TYPE_NAME>(map, index, value);
-if (ret != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read <TYPE_NAME>. error(%d)", ret);
-  free(value);
-  rpc_port_unit_map_destroy(map);
-  set_last_result(ret);
-  return;
-}
-
+rpc_port_unit_map_read_<TYPE_NAME>(map, index, value);
 handle->list = g_list_append(handle->list, value);
 )__c_cb";
 
index af727f6ae928b623b0cb03349d632c0c11d2edf3..036cf378545de6cb767d426779e1d1e3821a6823 100644 (file)
@@ -143,13 +143,7 @@ static void __<PREFIX>_<NAME>_from(rpc_port_parcel_h parcel, void *data)
 
   rpc_port_parcel_read(parcel, &map->parcelable, map);
 
-  ret = rpc_port_unit_map_read_int(map, "size", &size);
-  if (ret != RPC_PORT_ERROR_NONE) {
-    _E("Failed to read size. error(%d)", ret);
-    rpc_port_unit_map_destroy(map);
-    set_last_result(ret);
-    return;
-  }
+  rpc_port_unit_map_read_int(map, "size", &size);
 
   for (i = 0; i < size; ++i) {
     snprintf(name, sizeof(name), "key-%d", i);
@@ -247,7 +241,7 @@ int <PREFIX>_<NAME>_clone(<PREFIX>_<NAME>_h h, <PREFIX>_<NAME>_h *clone)
     return ret;
   }
 
-  ret = rpc_port_unit_map_read_<NAME>(map, "clone", clone);
+  rpc_port_unit_map_read_<NAME>(map, "clone", clone);
   rpc_port_unit_map_destroy(map);
 
   return ret;
index fad02c5e62c19af6a4045d9a72cb145aa2f4e8cd..124526c6d62991f65ebbfa5ad66d8f4bde733107 100644 (file)
@@ -128,13 +128,7 @@ static void __<PREFIX>_<NAME>_from(rpc_port_parcel_h parcel, void *data)
 
   rpc_port_parcel_read(parcel, &map->parcelable, map);
 
-  ret = rpc_port_unit_map_read_int(map, "size", &size);
-  if (ret != RPC_PORT_ERROR_NONE) {
-    _E("Failed to read size. error(%d)", ret);
-    rpc_port_unit_map_destroy(map);
-    set_last_result(ret);
-    return;
-  }
+  rpc_port_unit_map_read_int(map, "size", &size);
 
   for (i = 0; i < size; ++i) {
     snprintf(name, sizeof(name), "key-%d", i);
@@ -230,7 +224,7 @@ int <PREFIX>_<NAME>_clone(<PREFIX>_<NAME>_h h, <PREFIX>_<NAME>_h *clone)
     return ret;
   }
 
-  ret = rpc_port_unit_map_read_<NAME>(map, "clone", clone);
+  rpc_port_unit_map_read_<NAME>(map, "clone", clone);
   rpc_port_unit_map_destroy(map);
 
   return ret;
index 877ec9f62e0087b3839f0b1d01b745ed64665d02..f0dbd457dc8c5cf9dfcd6fd40b7d4ce7ebcd24ef 100644 (file)
@@ -604,11 +604,7 @@ rpc_port_unit_map_write_int(map_, "<ARG_NAME>", (int)<ARG>);
 constexpr const char CB_INTERFACE_METHOD_USER_DEFINED_UNIT_MAP_READ[] =
 R"__c_cb(
 <ARG> = nullptr;
-ret_ = rpc_port_unit_map_read_<TYPE_NAME>(map_, "<ARG_NAME>", &<ARG>);
-if (ret_ != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read <TYPE_NAME>. error(%d)", ret_);
-  goto out;
-}
+rpc_port_unit_map_read_<TYPE_NAME>(map_, "<ARG_NAME>", &<ARG>);
 )__c_cb";
 
 /**
@@ -617,12 +613,7 @@ if (ret_ != RPC_PORT_ERROR_NONE) {
  */
 constexpr const char CB_INTERFACE_METHOD_EMUM_UNIT_MAP_READ[] =
 R"__c_cb(
-res_ = rpc_port_unit_map_read_int(map_, "<ARG_NAME>", (int *)&<ARG>);
-if (res_ != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read <TYPE_NAME>. error(%d)", res_);
-  rpc_port_unit_map_destroy(map_);
-  break;
-}
+rpc_port_unit_map_read_int(map_, "<ARG_NAME>", (int *)&<ARG>);
 )__c_cb";
 
 /**
@@ -632,11 +623,7 @@ if (res_ != RPC_PORT_ERROR_NONE) {
 constexpr const char CB_INTERFACE_METHOD_BUNDLE_UNIT_MAP_READ[] =
 R"__c_cb(
 <ARG> = nullptr;
-ret_ = rpc_port_unit_map_read_bundle(map_, "<ARG_NAME>", &<ARG>);
-if (ret_ != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read bundle. error(%d)", ret_);
-  goto out;
-}
+rpc_port_unit_map_read_bundle(map_, "<ARG_NAME>", &<ARG>);
 )__c_cb";
 
 /**
@@ -646,11 +633,7 @@ if (ret_ != RPC_PORT_ERROR_NONE) {
 constexpr const char CB_INTERFACE_METHOD_STRING_UNIT_MAP_READ[] =
 R"__c_cb(
 <ARG> = nullptr;
-ret_ = rpc_port_unit_map_read_string(map_, "<ARG_NAME>", &<ARG>);
-if (ret_ != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read string. error(%d)", ret_);
-  goto out;
-}
+= rpc_port_unit_map_read_string(map_, "<ARG_NAME>", &<ARG>);
 )__c_cb";
 
 /**
@@ -660,11 +643,7 @@ if (ret_ != RPC_PORT_ERROR_NONE) {
  */
 constexpr const char CB_INTERFACE_METHOD_BASE_UNIT_MAP_READ[] =
 R"__c_cb(
-ret_ = rpc_port_unit_map_read_<TYPE_NAME>(map_, "<ARG_NAME>", &<ARG>);
-if (ret_ != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read <TYPE_NAME>. error(%d)", ret_);
-  goto out;
-}
+rpc_port_unit_map_read_<TYPE_NAME>(map_, "<ARG_NAME>", &<ARG>);
 )__c_cb";
 
 /**
index 94e71ff1d9e21e201ae8277fcdbc1ab6f8b9d55f..4cd74af3f72ba5c526c144f44ee1140ae6f8997c 100644 (file)
@@ -185,7 +185,6 @@ static void __<PREFIX>_<NAME>_<DELEGATE_NAME>_from(rpc_port_parcel_h parcel, voi
 {
   <PREFIX>_<NAME>_<DELEGATE_NAME>_h h = data;
   rpc_port_unit_map_h map;
-  int ret;
 
   if (parcel == nullptr || h == nullptr) {
     _E("Invalid parameter");
@@ -201,28 +200,14 @@ static void __<PREFIX>_<NAME>_<DELEGATE_NAME>_from(rpc_port_parcel_h parcel, voi
   }
 
   rpc_port_parcel_read(parcel, &map->parcelable, map);
+  rpc_port_unit_map_read_int(map, "id", &h->id);
+  rpc_port_unit_map_read_int(map, "seq_id", &h->seq_id);
+  rpc_port_unit_map_read_bool(map, "once", &h->once);
 
-  ret = rpc_port_unit_map_read_int(map, "id", &h->id);
-  if (ret != RPC_PORT_ERROR_NONE) {
-    _E("Failed to read id. error(%d)", ret);
-    rpc_port_unit_map_destroy(map);
-    set_last_result(ret);
-    return;
-  }
-
-  ret = rpc_port_unit_map_read_int(map, "seq_id", &h->seq_id);
-  if (ret != RPC_PORT_ERROR_NONE) {
-    _E("Failed to read seq_id. error(%d)", ret);
-    rpc_port_unit_map_destroy(map);
-    set_last_result(ret);
-    return;
-  }
-
-  ret = rpc_port_unit_map_read_bool(map, "once", &h->once);
   rpc_port_unit_map_destroy(map);
 
   _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false");
-  set_last_result(ret);
+  set_last_result(RPC_PORT_ERROR_NONE);
 }
 
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_create(<PREFIX>_<NAME>_<DELEGATE_NAME>_h *h)
@@ -289,7 +274,7 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_clone(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, <
     return ret;
   }
 
-  ret = rpc_port_unit_map_read_<NAME>_<DELEGATE_NAME>(map, "clone", clone);
+  rpc_port_unit_map_read_<NAME>_<DELEGATE_NAME>(map, "clone", clone);
   rpc_port_unit_map_destroy(map);
 
   return ret;
@@ -405,7 +390,7 @@ static void __<PREFIX>_<NAME>_<DELEGATE_NAME>_delegate_handler(GList **delegates
   <PREFIX>_<NAME>_<DELEGATE_NAME>_h handle;
   GList *iter;
   bool once;
-  int ret_;
+
   <DELEGATE_ARGS_DECL>
 
   <DELEGATE_UNIT_MAP_READ>
@@ -431,7 +416,6 @@ static void __<PREFIX>_<NAME>_<DELEGATE_NAME>_delegate_handler(GList **delegates
     }
   }
 
-out:
   <DELEGATE_ARGS_FREE>
   return;
 }
@@ -443,11 +427,7 @@ out:
  */
 constexpr const char CB_INTERFACE_DELEGATE_USER_DEFINED_UNIT_MAP_READ[] =
 R"__c_cb(
-ret_ = rpc_port_unit_map_read_<TYPE_NAME>(map, "<ARG>", &<ARG>);
-if (ret_ != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read <TYPE_NAME>. error(%d)", ret_);
-  goto out;
-}
+rpc_port_unit_map_read_<TYPE_NAME>(map, "<ARG>", &<ARG>);
 )__c_cb";
 
 /**
@@ -455,11 +435,7 @@ if (ret_ != RPC_PORT_ERROR_NONE) {
  */
 constexpr const char CB_INTERFACE_DELEGATE_BUNDLE_UNIT_MAP_READ[] =
 R"__c_cb(
-ret_ = rpc_port_unit_map_read_bundle(map, "<ARG>", &<ARG>);
-if (ret_ != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read bundle. error(%d)", ret_);
-  goto out;
-}
+rpc_port_unit_map_read_bundle(map, "<ARG>", &<ARG>);
 )__c_cb";
 
 /**
@@ -467,11 +443,7 @@ if (ret_ != RPC_PORT_ERROR_NONE) {
  */
 constexpr const char CB_INTERFACE_DELEGATE_STRING_UNIT_MAP_READ[] =
 R"__c_cb(
-ret_ = rpc_port_unit_map_read_string(map, "<ARG>", &<ARG>);
-if (ret_ != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read string. error(%d)", ret_);
-  goto out;
-}
+rpc_port_unit_map_read_string(map, "<ARG>", &<ARG>);
 )__c_cb";
 
 /**
@@ -480,11 +452,7 @@ if (ret_ != RPC_PORT_ERROR_NONE) {
  */
 constexpr const char CB_INTERFACE_DELEGATE_ENUM_UNIT_MAP_READ[] =
 R"__c_cb(
-ret_ = rpc_port_unit_map_read_int(map, "<ARG_NAME>", (int *)&<ARG>);
-if (ret_ != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read <TYPE_NAME>. error(%d)", ret_);
-  goto out;
-}
+rpc_port_unit_map_read_int(map, "<ARG_NAME>", (int *)&<ARG>);
 )__c_cb";
 
 
@@ -494,11 +462,7 @@ if (ret_ != RPC_PORT_ERROR_NONE) {
  */
 constexpr const char CB_INTERFACE_DELEGATE_BASE_UNIT_MAP_READ[] =
 R"__c_cb(
-ret_ = rpc_port_unit_map_read_<TYPE_NAME>(map, "<ARG_NAME>", &<ARG>);
-if (ret_ != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read <TYPE_NAME>. error(%d)", ret_);
-  goto out;
-}
+rpc_port_unit_map_read_<TYPE_NAME>(map, "<ARG_NAME>", &<ARG>);
 )__c_cb";
 
 /**
@@ -600,13 +564,8 @@ R"__c_cb(
 static void __<PREFIX>_<NAME>_process_received_event(GList **delegates, rpc_port_unit_map_h map)
 {
   rpc_port_delegate_h delegate;
-  int ret;
 
-  ret = rpc_port_unit_map_read_delegate(map, "delegate", &delegate);
-  if (ret != RPC_PORT_ERROR_NONE) {
-    _E("Failed to read delegate. error(%d)", ret);
-    return;
-  }
+  rpc_port_unit_map_read_delegate(map, "delegate", &delegate);
 
   _W("id(%d), seq_id(%d)", delegate->id, delegate->seq_id);
 
@@ -1266,12 +1225,7 @@ rpc_port_unit_map_write_int(map_, "<ARG_NAME>", (int)<ARG>);
  */
 constexpr const char CB_INTERFACE_METHOD_USER_DEFINED_UNIT_MAP_READ[] =
 R"__c_cb(
-res_ = rpc_port_unit_map_read_<TYPE_NAME>(map_, "<ARG_NAME>", &<ARG>);
-if (res_ != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read <TYPE_NAME>. error(%d)", res_);
-  rpc_port_unit_map_destroy(map_);
-  break;
-}
+ rpc_port_unit_map_read_<TYPE_NAME>(map_, "<ARG_NAME>", &<ARG>);
 )__c_cb";
 
 /**
@@ -1280,12 +1234,7 @@ if (res_ != RPC_PORT_ERROR_NONE) {
  */
 constexpr const char CB_INTERFACE_METHOD_BUNDLE_UNIT_MAP_READ[] =
 R"__c_cb(
-res_ = rpc_port_unit_map_read_bundle(map_, "<ARG_NAME>", &<ARG>);
-if (res_ != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read bundle. error(%d)", res_);
-  rpc_port_unit_map_destroy(map_);
-  break;
-}
+rpc_port_unit_map_read_bundle(map_, "<ARG_NAME>", &<ARG>);
 )__c_cb";
 
 /**
@@ -1294,12 +1243,7 @@ if (res_ != RPC_PORT_ERROR_NONE) {
  */
 constexpr const char CB_INTERFACE_METHOD_STRING_UNIT_MAP_READ[] =
 R"__c_cb(
-res_ = rpc_port_unit_map_read_string(map_, "<ARG_NAME>", &<ARG>);
-if (res_ != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read string. error(%d)", res_);
-  rpc_port_unit_map_destroy(map_);
-  break;
-}
+rpc_port_unit_map_read_string(map_, "<ARG_NAME>", &<ARG>);
 )__c_cb";
 
 /**
@@ -1308,12 +1252,7 @@ if (res_ != RPC_PORT_ERROR_NONE) {
  */
 constexpr const char CB_INTERFACE_METHOD_EMUM_UNIT_MAP_READ[] =
 R"__c_cb(
-res_ = rpc_port_unit_map_read_int(map_, "<ARG_NAME>", (int *)&<ARG>);
-if (res_ != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read <TYPE_NAME>. error(%d)", res_);
-  rpc_port_unit_map_destroy(map_);
-  break;
-}
+rpc_port_unit_map_read_int(map_, "<ARG_NAME>", (int *)&<ARG>);
 )__c_cb";
 
 /**
@@ -1323,12 +1262,7 @@ if (res_ != RPC_PORT_ERROR_NONE) {
  */
 constexpr const char CB_INTERFACE_METHOD_BASE_UNIT_MAP_READ[] =
 R"__c_cb(
-res_ = rpc_port_unit_map_read_<TYPE_NAME>(map_, "<ARG_NAME>", &<ARG>);
-if (res_ != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read <TYPE_NAME>. error(%d)", res_);
-  rpc_port_unit_map_destroy(map_);
-  break;
-}
+rpc_port_unit_map_read_<TYPE_NAME>(map_, "<ARG_NAME>", &<ARG>);
 )__c_cb";
 
 /**
index a43d682bc00b7a44bd6eb0d8e282a4a5ac1e5837..acdea3aedb613ac732a159aa052dd18e65d8f58b 100644 (file)
@@ -736,7 +736,6 @@ static void __<PREFIX>_<NAME>_<DELEGATE_NAME>_from(rpc_port_parcel_h parcel, voi
 {
   <PREFIX>_<NAME>_<DELEGATE_NAME>_h h = user_data;
   rpc_port_unit_map_h map;
-  int ret;
 
   if (parcel == nullptr || h == nullptr) {
     _E("Invalid parameter");
@@ -753,27 +752,14 @@ static void __<PREFIX>_<NAME>_<DELEGATE_NAME>_from(rpc_port_parcel_h parcel, voi
 
   rpc_port_parcel_read(parcel, &map->parcelable, map);
 
-  ret = rpc_port_unit_map_read_int(map, "id", &h->id);
-  if (ret != RPC_PORT_ERROR_NONE) {
-    _E("Failed to read id. error(%d)", ret);
-    rpc_port_unit_map_destroy(map);
-    set_last_result(ret);
-    return;
-  }
+  rpc_port_unit_map_read_int(map, "id", &h->id);
+  rpc_port_unit_map_read_int(map, "seq_id", &h->seq_id);
+  rpc_port_unit_map_read_bool(map, "once", &h->once);
 
-  ret = rpc_port_unit_map_read_int(map, "seq_id", &h->seq_id);
-  if (ret != RPC_PORT_ERROR_NONE) {
-    _E("Failed to read seq_id. error(%d)", ret);
-    rpc_port_unit_map_destroy(map);
-    set_last_result(ret);
-    return;
-  }
-
-  ret = rpc_port_unit_map_read_bool(map, "once", &h->once);
   rpc_port_unit_map_destroy(map);
 
   _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false");
-  set_last_result(ret);
+  set_last_result(RPC_PORT_ERROR_NONE);
 }
 
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_create(<PREFIX>_<NAME>_<DELEGATE_NAME>_h *h)
@@ -845,7 +831,7 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_clone(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, <
     return ret;
   }
 
-  ret = rpc_port_unit_map_read_<NAME>_<DELEGATE_NAME>(map, "clone", clone);
+  rpc_port_unit_map_read_<NAME>_<DELEGATE_NAME>(map, "clone", clone);
   rpc_port_unit_map_destroy(map);
 
   (*clone)->port = h->port;
@@ -1060,11 +1046,7 @@ rpc_port_unit_map_write_<TYPE_NAME>(map_, "<ARG_NAME>", <ARG>);
  */
 constexpr const char CB_INTERFACE_METHOD_EMUM_UNIT_MAP_READ[] =
 R"__c_cb(
-ret_ = rpc_port_unit_map_read_int(map, "<ARG_NAME>", (int *)&<ARG>);
-if (ret_ != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read enum. error(%d)", ret_);
-  goto out;
-}
+rpc_port_unit_map_read_int(map, "<ARG_NAME>", (int *)&<ARG>);
 )__c_cb";
 
 /**
@@ -1074,11 +1056,7 @@ if (ret_ != RPC_PORT_ERROR_NONE) {
  */
 constexpr const char CB_INTERFACE_METHOD_USER_DEFINED_UNIT_MAP_READ[] =
 R"__c_cb(
-ret_ = rpc_port_unit_map_read_<TYPE_NAME>(map, "<ARG_NAME>", &<ARG>);
-if (ret_ != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read <TYPE_NAME>. error(%d)", ret_);
-  goto out;
-}
+rpc_port_unit_map_read_<TYPE_NAME>(map, "<ARG_NAME>", &<ARG>);
 )__c_cb";
 
 /**
@@ -1087,11 +1065,7 @@ if (ret_ != RPC_PORT_ERROR_NONE) {
  */
 constexpr const char CB_INTERFACE_METHOD_BUNDLE_UNIT_MAP_READ[] =
 R"__c_cb(
-ret_ = rpc_port_unit_map_read_bundle(map, "<ARG_NAME>", &<ARG>);
-if (ret_ != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read bundle. error(%d)", ret_);
-  goto out;
-}
+rpc_port_unit_map_read_bundle(map, "<ARG_NAME>", &<ARG>);
 )__c_cb";
 
 /**
@@ -1100,11 +1074,7 @@ if (ret_ != RPC_PORT_ERROR_NONE) {
  */
 constexpr const char CB_INTERFACE_METHOD_STRING_UNIT_MAP_READ[] =
 R"__c_cb(
-ret_ = rpc_port_unit_map_read_string(map, "<ARG_NAME>", &<ARG>);
-if (ret_ != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read string. error(%d)", ret_);
-  goto out;
-}
+rpc_port_unit_map_read_string(map, "<ARG_NAME>", &<ARG>);
 )__c_cb";
 
 /*
@@ -1112,11 +1082,7 @@ if (ret_ != RPC_PORT_ERROR_NONE) {
  */
 constexpr const char CB_INTERFACE_METHOD_DELEGATE_UNIT_MAP_READ[] =
 R"__c_cb(
-ret_ = rpc_port_unit_map_read_delegate(map, "<ARG>", (rpc_port_delegate_h *)&<ARG>);
-if (ret_ != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read delegate. error(%d)", ret_);
-  goto out;
-}
+rpc_port_unit_map_read_delegate(map, "<ARG>", (rpc_port_delegate_h *)&<ARG>);
 
 if (context_->lem_cb.is_LEM) {
   <ARG>->lem_instance = strdup(context_->instance);
@@ -1138,11 +1104,7 @@ if (context_->lem_cb.is_LEM) {
  */
 constexpr const char CB_INTERFACE_METHOD_BASE_UNIT_MAP_READ[] =
 R"__c_cb(
-ret_ = rpc_port_unit_map_read_<TYPE_NAME>(map, "<ARG_NAME>", &<ARG>);
-if (ret_ != RPC_PORT_ERROR_NONE) {
-  _E("Failed to read <TYPE_NAME>. error(%d)", ret_);
-  goto out;
-}
+rpc_port_unit_map_read_<TYPE_NAME>(map, "<ARG_NAME>", &<ARG>);
 )__c_cb";
 
 
index 3d72736806035a7ad8db989204c4f5b58b79b589..ef5b5ab6b3df3bf701403463c50673a2efecc583 100644 (file)
@@ -547,6 +547,22 @@ std::string CsGeneratorBase::GenUnitMapParamType(const BaseType& base_type,
   return ret;
 }
 
+std::string CsGeneratorBase::GenUnitMapParamInit(const Interface& iface,
+                                                 const BaseType& base_type,
+                                                 const std::string& type_str) {
+  std::string ret;
+
+  if (base_type.GetUserDefinedType() == BaseType::UserType::DELEGATE) {
+    ret = "value = new CallbackBase(1, false);";
+  } else if (type_str == "string") {
+    ret = "value = new string(\"\");";
+  } else {
+    ret = "value = new " + type_str + "();";
+  }
+
+  return ret;
+}
+
 std::string CsGeneratorBase::GetEnumTypeString(const BaseType& base_type) {
   std::string ret = base_type.GetFullName(true);
   auto pos = ret.find('.');
@@ -680,6 +696,8 @@ std::string CsGeneratorBase::GenUnitMapReadWrite(const Interface& iface) {
     code +=
         ReplaceAll(CB_UNITMAP_READ_READ_BASE)
             .Change("<PARAM_TYPE>", GenUnitMapParamType(base_type, type_str))
+            .Change("<PARAM_INIT>",
+                    GenUnitMapParamInit(iface, base_type, type_str))
             .Change("<UINT_READ>",
                     GenUnitMaUintRead(iface, base_type, type_str));
     code +=
index 88805eda3e4dc20df079f8f74b59ec9fb0484685..67549600027eb2a5d876a3566ddc064237336389 100644 (file)
@@ -104,6 +104,9 @@ class CsGeneratorBase : public Generator {
   std::string GenListWrite(const BaseType& type, const std::string& type_str);
   std::string GenListRead(const BaseType& type, const std::string& type_str);
   std::string GetLengthName(const BaseType& type);
+  std::string GenUnitMapParamInit(const Interface& iface,
+                                  const BaseType& base_type,
+                                  const std::string& type_str);
 
  private:
   std::map<std::string, std::string> type_map_;
index 54b85e7c02d686730cf36d67ecd2ba779e659022..6c6d98062e32c41139d34f33f8c834870dfbd5db 100644 (file)
@@ -65,15 +65,18 @@ const char CB_UNITMAP_READ_READ_BASE[] =
 R"__cs_cb(
 internal void Read(string name, string type, out <PARAM_TYPE> value)
 {
+    <PARAM_INIT>
     if (map.ContainsKey(name) == false)
     {
-        throw new InvalidOperationException("Not exist key " + name);
+        Tizen.Log.Error("RPC_PORT", "Not exist key " + name);
+        return;
     }
 
     Unit unit = map[name];
     if (unit.type != type)
     {
-        throw new InvalidOperationException("type is not " + type + " : " + unit.type);
+        Tizen.Log.Error("RPC_PORT", "type is not " + type + " : " + unit.type);
+        return;
     }
     <UINT_READ>
 }