[aitt] Implement C generator 47/278847/18
authorjusung <jusung07.son@samsung.com>
Wed, 27 Jul 2022 01:58:44 +0000 (10:58 +0900)
committerjusung <jusung07.son@samsung.com>
Thu, 11 Aug 2022 08:02:17 +0000 (17:02 +0900)
Change-Id: I168ec93328da2f05e59251533fbc4a1d12eaee06
Signed-off-by: jusung <jusung07.son@samsung.com>
92 files changed:
Makefile.dibs
idlc/CMakeLists.txt
idlc/gen/generator.h
idlc/gen_aitt_plugin/aitt_plugin_c_transportable.cc [new file with mode: 0644]
idlc/gen_aitt_plugin/aitt_plugin_c_transportable.h [new file with mode: 0644]
idlc/gen_aitt_plugin/aitt_plugin_internal_body_gen.cc [new file with mode: 0644]
idlc/gen_aitt_plugin/aitt_plugin_internal_body_gen.h [new file with mode: 0644]
idlc/gen_aitt_plugin/aitt_plugin_internal_body_gen_cb.h [new file with mode: 0644]
idlc/gen_aitt_plugin/aitt_plugin_internal_header_gen.cc [new file with mode: 0644]
idlc/gen_aitt_plugin/aitt_plugin_internal_header_gen.h [new file with mode: 0644]
idlc/gen_aitt_plugin/aitt_plugin_internal_header_gen_cb.h [new file with mode: 0644]
idlc/gen_aitt_plugin/aitt_plugin_loader.cc [new file with mode: 0644]
idlc/gen_aitt_plugin/aitt_plugin_loader.h [new file with mode: 0644]
idlc/gen_cion/c_cion_body_gen_array_base_cb.h
idlc/gen_cion/c_cion_body_gen_base.cc
idlc/gen_cion/c_cion_body_gen_base.h
idlc/gen_cion/c_cion_body_gen_base_cb.h
idlc/gen_cion/c_cion_body_gen_list_base_cb.h
idlc/gen_cion/c_cion_gen_base.cc
idlc/gen_cion/c_cion_gen_base.h
idlc/gen_cion/c_cion_gen_base_cb.h
idlc/gen_cion/c_cion_group_body_gen.cc
idlc/gen_cion/c_cion_group_body_gen.h
idlc/gen_cion/c_cion_group_body_gen_cb.h
idlc/gen_cion/c_cion_group_header_gen.cc
idlc/gen_cion/c_cion_group_header_gen.h
idlc/gen_cion/c_cion_group_header_gen_cb.h
idlc/gen_cion/c_cion_header_gen_base.cc
idlc/gen_cion/c_cion_header_gen_base.h
idlc/gen_cion/c_cion_header_gen_base_cb.h
idlc/gen_cion/c_cion_proxy_body_gen.cc
idlc/gen_cion/c_cion_proxy_body_gen.h
idlc/gen_cion/c_cion_proxy_body_gen_cb.h
idlc/gen_cion/c_cion_proxy_header_gen.cc
idlc/gen_cion/c_cion_proxy_header_gen.h
idlc/gen_cion/c_cion_proxy_header_gen_cb.h
idlc/gen_cion/c_cion_stub_body_gen.cc
idlc/gen_cion/c_cion_stub_body_gen.h
idlc/gen_cion/c_cion_stub_body_gen_cb.h
idlc/gen_cion/c_cion_stub_header_gen.cc
idlc/gen_cion/c_cion_stub_header_gen.h
idlc/gen_cion/c_cion_stub_header_gen_cb.h
idlc/gen_cion/c_transportable.h
idlc/gen_cion/cion_plugin_base.cc
idlc/gen_cion/cion_plugin_base.h
idlc/gen_cion/cpp_cion_gen_base.cc
idlc/gen_cion/cpp_cion_gen_base.h
idlc/gen_cion/cpp_cion_group_body_gen.cc
idlc/gen_cion/cpp_cion_group_body_gen.h
idlc/gen_cion/cpp_cion_group_header_gen.cc
idlc/gen_cion/cpp_cion_group_header_gen.h
idlc/gen_cion/cpp_cion_proxy_body_gen.cc
idlc/gen_cion/cpp_cion_proxy_body_gen.h
idlc/gen_cion/cpp_cion_proxy_header_gen.cc
idlc/gen_cion/cpp_cion_proxy_header_gen.h
idlc/gen_cion/cpp_cion_stub_body_gen.cc
idlc/gen_cion/cpp_cion_stub_body_gen.h
idlc/gen_cion/cpp_cion_stub_header_gen.cc
idlc/gen_cion/cpp_cion_stub_header_gen.h
idlc/gen_cion/cs_cion_gen_base.cc
idlc/gen_cion/cs_cion_gen_base.h
idlc/gen_cion/cs_cion_group_gen.cc
idlc/gen_cion/cs_cion_group_gen.h
idlc/gen_cion/cs_cion_proxy_gen.cc
idlc/gen_cion/cs_cion_proxy_gen.h
idlc/gen_cion/cs_cion_stub_gen.cc
idlc/gen_cion/cs_cion_stub_gen.h
idlc/gen_cion/default_c_transportable.cc
idlc/gen_cion/default_c_transportable.h
idlc/gen_cion/java_cion_common_gen.cc
idlc/gen_cion/java_cion_common_gen.h
idlc/gen_cion/java_cion_gen_base.cc
idlc/gen_cion/java_cion_gen_base.h
idlc/gen_cion/java_cion_group_gen.cc
idlc/gen_cion/java_cion_group_gen.h
idlc/gen_cion/java_cion_group_repo_gen.cc
idlc/gen_cion/java_cion_group_repo_gen.h
idlc/gen_cion/java_cion_proxy_gen.cc
idlc/gen_cion/java_cion_proxy_gen.h
idlc/gen_cion/java_cion_proxy_repo_gen.cc
idlc/gen_cion/java_cion_proxy_repo_gen.h
idlc/gen_cion/java_cion_structure_gen.cc
idlc/gen_cion/java_cion_structure_gen.h
idlc/gen_cion/java_cion_stub_gen.cc
idlc/gen_cion/java_cion_stub_gen.h
idlc/gen_cion/java_cion_stub_repo_gen.cc
idlc/gen_cion/java_cion_stub_repo_gen.h
idlc/gen_cion/java_cion_utility_gen.cc
idlc/gen_cion/java_cion_utility_gen.h
idlc/main.cc
tests/build_tests/CMakeLists.txt
tests/build_tests/prebuild.sh

index 676e812026fafe1af33797ef6c31d5b5768b2b0d..6f30787190ccfac1c60b0c2f057ff2fa5f28198f 100644 (file)
@@ -62,6 +62,10 @@ SRC_FILES := \
        idlc/gen_cion/java_cion_stub_gen.cc \
        idlc/gen_cion/java_cion_stub_repo_gen.cc \
        idlc/gen_cion/java_cion_utility_gen.cc \
+       idlc/gen_aitt_plugin/aitt_plugin_c_transportable.cc \
+       idlc/gen_aitt_plugin/aitt_plugin_internal_body_gen.cc \
+       idlc/gen_aitt_plugin/aitt_plugin_internal_header_gen.cc \
+       idlc/gen_aitt_plugin/aitt_plugin_loader.cc \
        idlc/options.cc \
        idlc/main.cc
 
index 6b3f69fd62e2ceac24c8bafca7ed1540283c0095..ee785362a2a59a3ae7eb1e525e07aeb6e6f0d9ad 100644 (file)
@@ -28,6 +28,7 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCES)
 AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/ast AST_GEN_SOURCES)
 AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/gen GEN_SOURCES)
 AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/gen_cion GEN_CION_SOURCES)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/gen_aitt_plugin GEN_AITT_PLUGIN_SOURCES)
 
 BISON_TARGET(TIDLC ${CMAKE_CURRENT_SOURCE_DIR}/ast/tidlc.yy ${CMAKE_CURRENT_SOURCE_DIR}/ast/tidlc_y.cpp)
 FLEX_TARGET(TIDLC ${CMAKE_CURRENT_SOURCE_DIR}/ast/tidlc.ll ${CMAKE_CURRENT_SOURCE_DIR}/ast/tidlc_l.cpp)
@@ -38,6 +39,7 @@ ADD_EXECUTABLE(${PROJECT_NAME}
        ${FLEX_TIDLC_OUTPUTS}
        ${GEN_SOURCES}
        ${GEN_CION_SOURCES}
+       ${GEN_AITT_PLUGIN_SOURCES}
        ${SOURCES}
        )
 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIBPKGS_LIBRARIES} ${EXE_STATIC})
index b3529ad03a927192d18d24ad46eed7f94d3c3738..1a771fbb17237b74a80521782e741f299c85d7fd 100755 (executable)
@@ -57,6 +57,14 @@ class Generator {
     return isProxy_;
   }
 
+  void EnableGeneratedAPI(bool enable) {
+    isGenAPI_ = enable;
+  }
+
+  bool IsGeneratedAPI() {
+    return isGenAPI_;
+  }
+
   void SetType(int type) {
     type_ = type;
   }
@@ -129,6 +137,7 @@ class Generator {
   std::ofstream out_file_;
   bool hasNamespace_ = true;
   bool isProxy_ = true;
+  bool isGenAPI_ = false;
   int type_ = 0;
 };
 
diff --git a/idlc/gen_aitt_plugin/aitt_plugin_c_transportable.cc b/idlc/gen_aitt_plugin/aitt_plugin_c_transportable.cc
new file mode 100644 (file)
index 0000000..7a1ddf6
--- /dev/null
@@ -0,0 +1,1216 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "idlc/gen_aitt_plugin/aitt_plugin_c_transportable.h"
+
+#include <utility>
+
+#include "idlc/gen/replace_all.h"
+
+namespace {
+
+constexpr const char __CLINET_FILE_SEND[] =
+R"__c_cb(
+    plugin_payload_h pl;
+    int ret = plugin_payload_create(&pl, AITT_PLUGIN_PAYLOAD_TYPE_FILE);
+
+    if (ret != AITT_PLUGIN_ERROR_NONE) {
+      _E("Failed to plugin_payload_create : %d", ret);
+      return ret;
+    }
+
+    ret = plugin_payload_set_file_path(pl, <FILE_PATH>);
+    if (ret != AITT_PLUGIN_ERROR_NONE) {
+      _E("Failed to plugin_payload_set_file_path : %d - %s", ret, value);
+      plugin_payload_destroy(pl);
+      return ret;
+    }
+
+    ret = plugin_client_send_payload_async(<CLIENT_H>, pl, NULL, NULL);
+    if (ret != AITT_PLUGIN_ERROR_NONE) {
+      _E("Failed to plugin_client_send_payload_async : %d - %s", ret, value);
+      plugin_payload_destroy(pl);
+      return ret;
+    }
+
+    plugin_payload_destroy(pl);
+)__c_cb";
+
+constexpr const char __SERVER_FILE_SEND[] =
+R"__c_cb(
+    plugin_payload_h pl;
+    int r = plugin_payload_create(&pl, AITT_PLUGIN_PAYLOAD_TYPE_FILE);
+
+    if (r != AITT_PLUGIN_ERROR_NONE) {
+      _E("Failed to plugin_payload_create : %d", r);
+      return r;
+    }
+
+    r = plugin_payload_set_file_path(pl, <FILE_PATH>);
+    if (r != AITT_PLUGIN_ERROR_NONE) {
+      _E("Failed to plugin_payload_set_file_path : %d - %s", r, value);
+      plugin_payload_destroy(pl);
+      return r;
+    }
+
+    r = plugin_server_send_payload_async(<SERVER_H>, <PEER_H>, pl, NULL, NULL);
+    if (r != AITT_PLUGIN_ERROR_NONE) {
+      _E("Failed to plugin_server_send_payload_async : %d - %s", r, value);
+      plugin_payload_destroy(pl);
+      return r;
+    }
+
+    plugin_payload_destroy(pl);
+)__c_cb";
+
+constexpr const char __SERVER_REGISTER[] =
+R"__c_cb(
+
+  ret = plugin_server_create(&__<NAME>.stub, service_name, display_name, broker_ip, broker_port, user_name, password, my_ip, protocols);
+  if (ret != AITT_PLUGIN_ERROR_NONE) {
+    _E("Failed to create stub handle. error(%d)", ret);
+    <PREFIX>_<NAME>_unregister();
+    return ret;
+  }
+
+  ret = plugin_server_add_connection_result_cb(__<NAME>.stub, __<PREFIX>_<NAME>_connection_result_cb, &__<NAME>);
+  if (ret != AITT_PLUGIN_ERROR_NONE) {
+    _E("Failed to add connection result event callback");
+    <PREFIX>_<NAME>_unregister();
+    return ret;
+  }
+
+  ret = plugin_server_add_payload_received_cb(__<NAME>.stub, __<PREFIX>_<NAME>_payload_received_cb, &__<NAME>);
+  if (ret != AITT_PLUGIN_ERROR_NONE) {
+    _E("Failed to add payload recieved event callback");
+    <PREFIX>_<NAME>_unregister();
+    return ret;
+  }
+
+  ret = plugin_server_add_disconnected_cb(__<NAME>.stub, __<PREFIX>_<NAME>_disconnected_cb, &__<NAME>);
+  if (ret != AITT_PLUGIN_ERROR_NONE) {
+    _E("Failed to add disconnected event callback");
+    <PREFIX>_<NAME>_unregister();
+    return ret;
+  }
+
+  ret = plugin_server_set_data_received_cb(__<NAME>.stub, __<PREFIX>_<NAME>_data_received_cb, &__<NAME>);
+  if (ret != AITT_PLUGIN_ERROR_NONE) {
+    _E("Failed to add data recieved event callback");
+    <PREFIX>_<NAME>_unregister();
+    return ret;
+  }
+
+  ret = plugin_server_listen(__<NAME>.stub, __<PREFIX>_<NAME>_connection_request_cb, &__<NAME>);
+  if (ret != AITT_PLUGIN_ERROR_NONE) {
+    _E("Failed to listen events. error(%d)", ret);
+    <PREFIX>_<NAME>_unregister();
+    return ret;
+  }
+)__c_cb";
+
+constexpr const char __SERVER_UNREGISTER[] =
+R"__c_cb(
+  if (__<NAME>.stub) {
+    plugin_server_destroy(__<NAME>.stub);
+    __<NAME>.stub = nullptr;
+  }
+)__c_cb";
+
+constexpr const char __SERVER_ACCEPT[] =
+R"__c_cb(
+  ret = plugin_server_accept(__<NAME>.stub, peer_info);
+  if (ret != AITT_PLUGIN_ERROR_NONE)
+    _E("Failed to accept. error(%d)", ret);
+)__c_cb";
+
+constexpr const char __SERVER_REJECT[] =
+R"__c_cb(
+  ret = plugin_server_reject(__<NAME>.stub, peer_info, reason);
+  if (ret != AITT_PLUGIN_ERROR_NONE)
+    _E("Failed to reject. error(%d)", ret);
+)__c_cb";
+
+constexpr const char __SERVER_SET_DISPLAY_NAME[] =
+R"__c_cb(
+  ret = plugin_server_set_display_name(__<NAME>.stub, display_name);
+  if (ret != AITT_PLUGIN_ERROR_NONE)
+    _E("Failed to set display name. error(%d)", ret);
+)__c_cb";
+
+constexpr const char __CLIENT_TRY_CONNECT[] =
+R"__c_cb(
+  ret = plugin_client_connect(<CLIENT>, <PEER>);
+  if (ret != AITT_PLUGIN_ERROR_NONE) {
+    _E("Failed to connect to stub. error(%d)", ret);
+    return ret;
+  }
+)__c_cb";
+
+constexpr const char __CLIENT_DISCONNECT[] =
+R"__c_cb(
+  ret = plugin_client_disconnect(<CLIENT>);
+  if (ret != AITT_PLUGIN_ERROR_NONE) {
+    _E("Failed to disconnect to stub. error(%d)", ret);
+    return ret;
+  }
+)__c_cb";
+
+constexpr const char __CLIENT_TRY_DISCOVERY[] =
+R"__c_cb(
+  ret = plugin_client_try_discovery(<CLIENT>, __<PREFIX>_<NAME>_discovered, h);
+  if (ret != AITT_PLUGIN_ERROR_NONE) {
+    _E("Failed to discovery to stub. error(%d)", ret);
+    return ret;
+  }
+)__c_cb";
+
+constexpr const char __CLIENT_STOP_DISCOVERY[] =
+R"__c_cb(
+  ret = plugin_client_stop_discovery(<CLIENT>);
+  if (ret != AITT_PLUGIN_ERROR_NONE) {
+    _E("Failed to stop discovery to stub. error(%d)", ret);
+    return ret;
+  }
+)__c_cb";
+
+constexpr const char __CLIENT_SEND_ASYNC[] =
+R"__c_cb(
+  res_ = plugin_payload_create(&<PAYLOAD>, AITT_PLUGIN_PAYLOAD_TYPE_DATA);
+  if (res_ != AITT_PLUGIN_ERROR_NONE) {
+    _E("Failed to plugin_payload_create : %d", res_);
+    plugin_payload_destroy(<PAYLOAD>);
+    goto out;
+  }
+
+  res_ = plugin_payload_set_data(<PAYLOAD>, (const unsigned char*)data_, <SIZE>);
+  if (res_ != AITT_PLUGIN_ERROR_NONE) {
+    _E("Failed to plugin_payload_set_data : %d", res_);
+    plugin_payload_destroy(<PAYLOAD>);
+    goto out;
+  }
+
+  res_ = plugin_client_send_payload_async(<CLIENT>, <PAYLOAD>, NULL, NULL);
+  plugin_payload_destroy(<PAYLOAD>);
+  if (res_ != AITT_PLUGIN_ERROR_NONE) {
+    _E("Failed to plugin_client_send_payload_async : %d", res_);
+    goto out;
+  }
+)__c_cb";
+
+constexpr const char __CLIENT_SEND[] =
+R"__c_cb(
+  res_ = plugin_client_send_data(<CLIENT>, <DATA>, <DATA_SIZE> , 5 * 1000, &<RET_DATA>, &<RET_DATA_SIZE>);
+  if (res_ != AITT_PLUGIN_ERROR_NONE) {
+    _E("Failed to send parcel. error(%d)", res_);
+    goto out;
+  }
+)__c_cb";
+
+constexpr const char __SERVER_SEND_ASYNC[] =
+R"__c_cb(
+  ret_ = plugin_payload_create(&<PAYLOAD>, AITT_PLUGIN_PAYLOAD_TYPE_DATA);
+  if (ret_ != AITT_PLUGIN_ERROR_NONE) {
+    _E("Failed to plugin_payload_create : %d", ret_);
+    plugin_payload_destroy(<PAYLOAD>);
+    goto out;
+  }
+
+  ret_ = plugin_payload_set_data(<PAYLOAD>, (const unsigned char*)data_, <SIZE>);
+  if (ret_ != AITT_PLUGIN_ERROR_NONE) {
+    _E("Failed to plugin_payload_set_data : %d", ret_);
+    plugin_payload_destroy(<PAYLOAD>);
+    goto out;
+  }
+
+  ret_ = plugin_server_send_payload_async(<SERVER>, peer_info, <PAYLOAD>, NULL, NULL);
+  plugin_payload_destroy(<PAYLOAD>);
+  if (ret_ != AITT_PLUGIN_ERROR_NONE) {
+    _E("Failed to plugin_client_send_payload_async : %d", ret_);
+    goto out;
+  }
+)__c_cb";
+
+constexpr const char __GROUP_PUBLISH[] =
+R"__c_cb(
+  res_ = plugin_payload_create(&pl_, AITT_PLUGIN_PAYLOAD_TYPE_DATA);
+  if (res_ != AITT_PLUGIN_ERROR_NONE) {
+    _E("Failed to plugin_payload_create : %d", res_);
+    plugin_payload_destroy(pl_);
+    goto out;
+  }
+
+  res_ = plugin_payload_set_data(pl_, (const unsigned char*)data_, data_size_);
+  if (res_ != AITT_PLUGIN_ERROR_NONE) {
+    _E("Failed to plugin_payload_set_data : %d", res_);
+    plugin_payload_destroy(pl_);
+    goto out;
+  }
+
+  res_ = plugin_group_publish(h->group, pl_);
+  plugin_payload_destroy(pl_);
+  if (res_ != AITT_PLUGIN_ERROR_NONE) {
+    _E("Failed to plugin_group_publish : %d", res_);
+    goto out;
+  }
+)__c_cb";
+
+constexpr const char __CLIENT_CREATE[] =
+R"__c_cb(
+  ret = plugin_client_create(&handle->client, service_name, broker_ip, broker_port, user_name, password, my_ip, protocols);
+  if (ret != AITT_PLUGIN_ERROR_NONE) {
+    _E("Failed to create proxy handle. error(%d)", ret);
+    <PREFIX>_<NAME>_destroy(handle);
+    return ret;
+  }
+
+  handle->callback = *callback;
+  handle->user_data = user_data;
+
+  ret = plugin_client_add_connection_result_cb(handle->client, __<PREFIX>_<NAME>_connection_result, handle);
+  if (ret != AITT_PLUGIN_ERROR_NONE) {
+    _E("Failed to add connection result cb. error(%d)", ret);
+    <PREFIX>_<NAME>_destroy(handle);
+    return ret;
+  }
+
+  ret = plugin_client_add_disconnected_cb(handle->client, __<PREFIX>_<NAME>_disconnected, handle);
+  if (ret != AITT_PLUGIN_ERROR_NONE) {
+    _E("Failed to add disconnected event cb. error(%d)", ret);
+    <PREFIX>_<NAME>_destroy(handle);
+    return ret;
+  }
+
+  ret = plugin_client_add_payload_received_cb(handle->client, __<PREFIX>_<NAME>_received, handle);
+  if (ret != AITT_PLUGIN_ERROR_NONE) {
+    _E("Failed to add received event cb. error(%d)", ret);
+    <PREFIX>_<NAME>_destroy(handle);
+    return ret;
+  }
+)__c_cb";
+
+constexpr const char __GROUP_CREATE[] =
+R"__c_cb(
+  ret = plugin_group_create(&handle->group, topic_name, broker_ip, broker_port, user_name, password, my_ip, protocols);
+  if (ret != AITT_PLUGIN_ERROR_NONE) {
+    _E("Failed to create group handle. error(%d)", ret);
+    <PREFIX>_<NAME>_destroy(handle);
+    return ret;
+  }
+
+  handle->callback = *callback;
+  handle->user_data = user_data;
+
+  ret = plugin_group_add_joined_cb(handle->group, __<PREFIX>_<NAME>_joined_cb, handle);
+  if (ret != AITT_PLUGIN_ERROR_NONE) {
+    _E("Failed to add connection result cb. error(%d)", ret);
+    <PREFIX>_<NAME>_destroy(handle);
+    return ret;
+  }
+
+  ret = plugin_group_add_left_cb(handle->group, __<PREFIX>_<NAME>_left_cb, handle);
+  if (ret != AITT_PLUGIN_ERROR_NONE) {
+    _E("Failed to add disconnected event cb. error(%d)", ret);
+    <PREFIX>_<NAME>_destroy(handle);
+    return ret;
+  }
+
+  ret = plugin_group_add_payload_received_cb(handle->group, __<PREFIX>_<NAME>_received, handle);
+  if (ret != AITT_PLUGIN_ERROR_NONE) {
+    _E("Failed to add received event cb. error(%d)", ret);
+    <PREFIX>_<NAME>_destroy(handle);
+    return ret;
+  }
+
+  ret = plugin_group_subscribe(handle->group);
+  if (ret != AITT_PLUGIN_ERROR_NONE) {
+    _E("Failed to subscribe event. error(%d)", ret);
+    <PREFIX>_<NAME>_destroy(handle);
+    return ret;
+  }
+
+  *h = handle;
+)__c_cb";
+
+constexpr const char __GROUP_DESTROY[] =
+R"__c_cb(
+  if (h->group) {
+    plugin_group_unsubscribe(h->group);
+    plugin_group_destroy(h->group);
+  }
+)__c_cb";
+
+constexpr const char __CLIENT_DESTROY[] =
+R"__c_cb(
+  if (h->client)
+    plugin_client_destroy(h->client);
+)__c_cb";
+
+constexpr const char __PEER_INFO_CLONE[] =
+    "plugin_peer_info_clone(<SRC_PEER>, <DEST_PEER>);";
+
+constexpr const char __SERVER_FOREACH_CONNECTED_PEER_INFO[] =
+    "plugin_server_foreach_connected_peer_info(__<NAME>.stub, callback, user_data);";
+
+constexpr const char __SERVER_SET_ONDEMAND_LAUNCH_ENABLED[] =
+R"__c_cb(
+  int ret;
+
+  ret = plugin_server_set_on_demand_launch_enabled(__<NAME>.stub, enable);
+  if (ret != AITT_PLUGIN_ERROR_NONE)
+    _E("Failed to set ondemand launch enable. error(%d)", ret);
+
+  return ret;
+)__c_cb";
+
+constexpr const char __COMMON_HEADER_HANDLES[] =
+R"__c_cb(
+
+typedef enum _<MODULE_PREFIX>_error {
+  AITT_PLUGIN_ERROR_NONE = TIZEN_ERROR_NONE, /**< Success */
+  AITT_PLUGIN_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */
+  AITT_PLUGIN_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+  AITT_PLUGIN_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
+  AITT_PLUGIN_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+  AITT_PLUGIN_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Function not implemented */
+  AITT_PLUGIN_ERROR_ALREADY_IN_PROGRESS = TIZEN_ERROR_ALREADY_IN_PROGRESS, /**< Already in progress */
+  AITT_PLUGIN_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */
+  AITT_PLUGIN_ERROR_TIMED_OUT = TIZEN_ERROR_TIMED_OUT, /**< Timed out */
+  AITT_PLUGIN_ERROR_OPERATION_FAILED = TIZEN_ERROR_CION | 0x01, /**< Operation failed */
+} <MODULE_PREFIX>_error_e;
+
+enum AittProtocol {
+  AITT_TYPE_MQTT = (0x1 << 0),   // Publish message through the MQTT
+  AITT_TYPE_TCP = (0x1 << 1),   // Publish message to peers using the TCP
+  AITT_TYPE_UDP = (0x1 << 2),   // Publish message to peers using the UDP
+  AITT_TYPE_SRTP = (0x1 << 3),   // Publish message to peers using the SRTP
+  AITT_TYPE_WEBRTC = (0x1 << 4),  // Publish message to peers using the WEBRTC
+};
+
+/**
+  * @brief The aitt plugin peer info handle.
+  */
+typedef void *<MODULE_PREFIX>_peer_info_h;
+
+)__c_cb";
+
+constexpr const char __COMMON_HEADER_CONNECTION_RESULT_HANDLE[] =
+R"__c_cb(
+typedef enum _aitt_connection_status_e {
+  AITT_PLUGIN_CONNECTION_STATUS_OK, /**< Connection is ok **/
+  AITT_PLUGIN_CONNECTION_STATUS_REJECTED, /**< Connection is rejected **/
+  AITT_PLUGIN_CONNECTION_STATUS_ERROR, /**< Connection error occurs **/
+} <MODULE_PREFIX>_connection_status_e;
+
+/**
+ * @brief The Aitt plugin connection result handle.
+ */
+typedef void *<MODULE_PREFIX>_connection_result_h;
+)__c_cb";
+
+constexpr const char __COMMON_HEADER_PAYLOAD_HANDLE[] =
+R"__c_cb(
+/**
+ * @brief Enumeration for <MODULE_PREFIX>_payload transfer status types.
+ */
+typedef enum _payload_transfer_status_e {
+  AITT_PLUGIN_PAYLOAD_TRANSFER_STATUS_SUCCESS, /**< Transfer is success **/
+  AITT_PLUGIN_PAYLOAD_TRANSFER_STATUS_FAILURE, /**< Transfer is failed **/
+  AITT_PLUGIN_PAYLOAD_TRANSFER_STATUS_IN_PROGRESS, /**< Transfer is in progress **/
+} <MODULE_PREFIX>_payload_transfer_status_e;
+
+/**
+  * @brief The <MODULE_PREFIX>_payload handle.
+  */
+ typedef void *<MODULE_PREFIX>_payload_h;
+
+)__c_cb";
+
+constexpr const char __COMMON_HEADER_PAYLOAD_BASE[] =
+R"__c_cb(
+/**
+  * @brief Saves the payload as a file.
+  * @remarks The @a path is absolute path.
+  * @remarks If the media storage is used, %http://tizen.org/privilege/mediastorage privilege is necessary. \n
+  *          If the external storage is used, %http://tizen.org/privilege/externalstorage privilege is necessary.
+  * @param[in] payload The <MODULE_PREFIX>_payload handle
+  * @param[in] path The path of file
+  * @return @c 0 on success, otherwise a negative error value
+  * @retval #AITT_PLUGIN_ERROR_NONE Successful
+  * @retval #AITT_PLUGIN_ERROR_PERMISSION_DENIED Permission denied
+  * @retval #AITT_PLUGIN_ERROR_INVALID_PARAMETER Invalid parameter
+  * @retval #AITT_PLUGIN_ERROR_OPERATION_FAILED Operation failed
+  */
+int <MODULE_PREFIX>_payload_save_as_file(<MODULE_PREFIX>_payload_h payload, const char *path);
+
+/**
+  * @brief Gets the name of received file from the payload.
+  * @remarks @a file_name must be released using free().
+  * @param[in] payload The <MODULE_PREFIX>_payload handle
+  * @param[out] file_name The name of file
+  * @return @c 0 on success, otherwise a negative error value
+  * @retval #AITT_PLUGIN_ERROR_NONE Successful
+  * @retval #AITT_PLUGIN_ERROR_INVALID_PARAMETER Invalid parameter
+  * @retval #AITT_PLUGIN_ERROR_OUT_OF_MEMORY Out of memory
+  */
+
+int <MODULE_PREFIX>_payload_get_received_file_name(<MODULE_PREFIX>_payload_h payload,
+    char **file_name);
+
+/**
+  * @brief Gets the size of currently received file from the payload.
+  * @param[in] payload The <MODULE_PREFIX>_payload handle
+  * @param[out] bytes The size of file
+  * @return @c 0 on success, otherwise a negative error value
+  * @retval #AITT_PLUGIN_ERROR_NONE Successful
+  * @retval #AITT_PLUGIN_ERROR_INVALID_PARAMETER Invalid parameter
+  */
+int <MODULE_PREFIX>_payload_get_received_bytes(<MODULE_PREFIX>_payload_h payload, uint64_t *bytes);
+
+/**
+  * @brief Gets the total size of file from the payload.
+  * @param[in] payload The <MODULE_PREFIX>_payload handle
+  * @param[out] bytes The size of file
+  * @return @c 0 on success, otherwise a negative error value
+  * @retval #AITT_PLUGIN_ERROR_NONE Successful
+  * @retval #AITT_PLUGIN_ERROR_INVALID_PARAMETER Invalid parameter
+  */
+int <MODULE_PREFIX>_payload_get_total_bytes(<MODULE_PREFIX>_payload_h payload, uint64_t *bytes);
+)__c_cb";
+
+constexpr const char __COMMON_HEADER_COMMON_BASE[] =
+R"__c_cb(
+/**
+  * @brief Creates a clone of aitt plugin peer info handle.
+  * @remarks @a peer_info_clone must be released using <MODULE_PREFIX>_peer_info_destroy().
+  * @param[in] peer_info The aitt plugin peer information handle
+  * @param[out] peer_info_clone The cloned peer information handle
+  * @return @c 0 on success, otherwise a negative error value
+  * @retval #AITT_PLUGIN_ERROR_NONE Successful
+  * @retval #AITT_PLUGIN_ERROR_INVALID_PARAMETER Invalid parameter
+  * @retval #AITT_PLUGIN_ERROR_OUT_OF_MEMORY Out of memory
+  * @retval #AITT_PLUGIN_ERROR_IO_ERROR IO error
+  * @see <MODULE_PREFIX>_peer_info_destroy()
+  */
+int <MODULE_PREFIX>_peer_info_clone(const <MODULE_PREFIX>_peer_info_h peer_info,
+    <MODULE_PREFIX>_peer_info_h *peer_info_clone);
+
+/**
+  * @brief Destroys the peer info handle and releases all its resources.
+  * @param[in] peer_info The aitt plugin peer information handle
+  * @return @c 0 on success, otherwise a negative error value
+  * @retval #AITT_PLUGIN_ERROR_NONE Successful
+  * @retval #AITT_PLUGIN_ERROR_INVALID_PARAMETER Invalid parameter
+  * @see <MODULE_PREFIX>_peer_info_clone()
+  */
+int <MODULE_PREFIX>_peer_info_destroy(<MODULE_PREFIX>_peer_info_h peer_info);
+
+/**
+  * @brief Gets the device ID.
+  * @remarks @a device_id must be released using free().
+  * @param[in] peer_info The aitt plugin peer information handle
+  * @param[out] device_id The device ID
+  * @return @c 0 on success, otherwise a negative error value
+  * @retval #AITT_PLUGIN_ERROR_NONE Successful
+  * @retval #AITT_PLUGIN_ERROR_INVALID_PARAMETER Invalid parameter
+  * @retval #AITT_PLUGIN_ERROR_OUT_OF_MEMORY Out of memory
+  */
+int <MODULE_PREFIX>_peer_info_get_device_id(<MODULE_PREFIX>_peer_info_h peer_info,
+    char **device_id);
+
+/**
+  * @brief Gets the device name.
+  * @remarks @a device_name must be released using free().
+  * @param[in] peer_info The aitt plugin peer information handle
+  * @param[out] device_name The device name
+  * @return @c 0 on success, otherwise a negative error value
+  * @retval #AITT_PLUGIN_ERROR_NONE Successful
+  * @retval #AITT_PLUGIN_ERROR_INVALID_PARAMETER Invalid parameter
+  * @retval #AITT_PLUGIN_ERROR_OUT_OF_MEMORY Out of memory
+  */
+int <MODULE_PREFIX>_peer_info_get_device_name(<MODULE_PREFIX>_peer_info_h peer_info,
+    char **device_name);
+
+/**
+  * @brief Gets the device's platform.
+  * @remarks @a device_platform must be released using free().
+  * @param[in] peer_info The aitt plugin peer information handle
+  * @param[out] device_platform The platform name
+  * @return @c 0 on success, otherwise a negative error value
+  * @retval #AITT_PLUGIN_ERROR_NONE Successful
+  * @retval #AITT_PLUGIN_ERROR_INVALID_PARAMETER Invalid parameter
+  * @retval #AITT_PLUGIN_ERROR_OUT_OF_MEMORY Out of memory
+  */
+int <MODULE_PREFIX>_peer_info_get_device_platform(<MODULE_PREFIX>_peer_info_h peer_info,
+    char **device_platform);
+
+/**
+  * @brief Gets the device's platform version.
+  * @remarks @a device_platform_version must be released using free().
+  * @param[in] peer_info The aitt plugin peer information handle
+  * @param[out] device_platform_version The platform version
+  * @return @c 0 on success, otherwise a negative error value
+  * @retval #AITT_PLUGIN_ERROR_NONE Successful
+  * @retval #AITT_PLUGIN_ERROR_INVALID_PARAMETER Invalid parameter
+  * @retval #AITT_PLUGIN_ERROR_OUT_OF_MEMORY Out of memory
+  */
+int <MODULE_PREFIX>_peer_info_get_device_platform_version(<MODULE_PREFIX>_peer_info_h peer_info,
+    char **device_platform_version);
+
+/**
+  * @brief Gets the device's type.
+  * @remarks @a device_type must be released using free().
+  * @param[in] peer_info The aitt plugin peer information handle
+  * @param[out] device_type Device type
+  * @return @c 0 on success, otherwise a negative error value
+  * @retval #AITT_PLUGIN_ERROR_NONE Successful
+  * @retval #AITT_PLUGIN_ERROR_INVALID_PARAMETER Invalid parameter
+  * @retval #AITT_PLUGIN_ERROR_OUT_OF_MEMORY Out of memory
+  */
+int <MODULE_PREFIX>_peer_info_get_device_type(<MODULE_PREFIX>_peer_info_h peer_info,
+    char **device_type);
+
+/**
+  * @brief Gets application ID of peer.
+  * @remarks @a app_id must be released using free().
+  * @param[in] peer_info The aitt plugin peer information handle
+  * @param[out] app_id The application ID
+  * @return @c 0 on success, otherwise a negative error value
+  * @retval #AITT_PLUGIN_ERROR_NONE Successful
+  * @retval #AITT_PLUGIN_ERROR_INVALID_PARAMETER Invalid parameter
+  * @retval #AITT_PLUGIN_ERROR_OUT_OF_MEMORY Out of memory
+  */
+int <MODULE_PREFIX>_peer_info_get_app_id(<MODULE_PREFIX>_peer_info_h peer_info,
+    char **app_id);
+
+/**
+  * @brief Gets application version of peer.
+  * @remarks @a app_version must be released using free().
+  * @param[in] peer_info The aitt plugin peer information handle
+  * @param[out] app_version The application version
+  * @return @c 0 on success, otherwise a negative error value
+  * @retval #AITT_PLUGIN_ERROR_NONE Successful
+  * @retval #AITT_PLUGIN_ERROR_INVALID_PARAMETER Invalid parameter
+  * @retval #AITT_PLUGIN_ERROR_OUT_OF_MEMORY Out of memory
+  */
+int <MODULE_PREFIX>_peer_info_get_app_version(<MODULE_PREFIX>_peer_info_h peer_info,
+    char **app_version);
+
+/**
+  * @brief Gets UUID of peer.
+  * @remarks @a uuid must be released using free().
+  * @param[in] peer_info The aitt plugin peer information handle
+  * @param[out] uuid The UUID
+  * @return @c 0 on success, otherwise a negative error value
+  * @retval #AITT_PLUGIN_ERROR_NONE Successful
+  * @retval #AITT_PLUGIN_ERROR_INVALID_PARAMETER Invalid parameter
+  * @retval #AITT_PLUGIN_ERROR_OUT_OF_MEMORY Out of memory
+  */
+int <MODULE_PREFIX>_peer_info_get_uuid(<MODULE_PREFIX>_peer_info_h peer_info,
+    char **uuid);
+
+/**
+  * @brief Gets display name of peer.
+  * @details The custom name for service name. \n
+  *          It is possible that @a display_name does not exist.
+  * @remarks @a display_name must be released using free().
+  * @param[in] peer_info The aitt plugin peer information handle
+  * @param[out] display_name The display name
+  * @return @c 0 on success, otherwise a negative error value
+  * @retval #AITT_PLUGIN_ERROR_NONE Successful
+  * @retval #AITT_PLUGIN_ERROR_INVALID_PARAMETER Invalid parameter
+  * @retval #AITT_PLUGIN_ERROR_OUT_OF_MEMORY Out of memory
+  */
+int <MODULE_PREFIX>_peer_info_get_display_name(<MODULE_PREFIX>_peer_info_h peer_info,
+    char **display_name);
+)__c_cb";
+
+constexpr const char __COMMON_HEADER_CONNECTION_RESULT_BASE[] =
+R"__c_cb(
+/**
+ * @brief Gets the connection result status.
+ * @param[in] result The connection result handle
+ * @param[out] status Connection result status
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #AITT_PLUGIN_ERROR_NONE Successful
+ * @retval #AITT_PLUGIN_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int <MODULE_PREFIX>_connection_result_get_status(const <MODULE_PREFIX>_connection_result_h result,
+         <MODULE_PREFIX>_connection_status_e *status);
+
+/**
+ * @brief Gets the connection result reason.
+ * @remarks @a reason must be released using free().
+ * @param[in] result The connection result handle
+ * @param[out] reason Connection result reason, should be freed after use
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #AITT_PLUGIN_ERROR_NONE Successful
+ * @retval #AITT_PLUGIN_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #AITT_PLUGIN_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int <MODULE_PREFIX>_connection_result_get_reason(const <MODULE_PREFIX>_connection_result_h result,
+        char **reason);
+)__c_cb";
+
+constexpr const char __COMMON_BODY_PEERINFO_BASE[] =
+R"__c_cb(
+int <MODULE_PREFIX>_peer_info_clone(const <MODULE_PREFIX>_peer_info_h peer_info,
+    <MODULE_PREFIX>_peer_info_h *peer_info_clone) {
+  return  plugin_peer_info_clone(peer_info, peer_info_clone);
+}
+
+int <MODULE_PREFIX>_peer_info_destroy(<MODULE_PREFIX>_peer_info_h peer_info) {
+  return plugin_peer_info_destroy(peer_info);
+}
+
+int <MODULE_PREFIX>_peer_info_get_device_id(<MODULE_PREFIX>_peer_info_h peer_info,
+    char **device_id) {
+  return plugin_peer_info_get_device_id(peer_info, device_id);
+}
+
+int <MODULE_PREFIX>_peer_info_get_device_name(<MODULE_PREFIX>_peer_info_h peer_info,
+    char **device_name) {
+  return plugin_peer_info_get_device_name(peer_info, device_name);
+}
+
+int <MODULE_PREFIX>_peer_info_get_device_platform(<MODULE_PREFIX>_peer_info_h peer_info,
+    char **device_platform) {
+  return plugin_peer_info_get_device_platform(peer_info, device_platform);
+}
+
+int <MODULE_PREFIX>_peer_info_get_device_platform_version(<MODULE_PREFIX>_peer_info_h peer_info,
+    char **device_platform_version) {
+  return plugin_peer_info_get_device_platform_version(peer_info, device_platform_version);
+}
+
+int <MODULE_PREFIX>_peer_info_get_device_type(<MODULE_PREFIX>_peer_info_h peer_info,
+    char **device_type) {
+  return plugin_peer_info_get_device_type(peer_info, device_type);
+}
+
+int <MODULE_PREFIX>_peer_info_get_app_id(<MODULE_PREFIX>_peer_info_h peer_info,
+    char **app_id) {
+  return plugin_peer_info_get_app_id(peer_info, app_id);
+}
+
+int <MODULE_PREFIX>_peer_info_get_app_version(<MODULE_PREFIX>_peer_info_h peer_info,
+    char **app_version) {
+  return plugin_peer_info_get_app_version(peer_info,  app_version);
+}
+
+int <MODULE_PREFIX>_peer_info_get_uuid(<MODULE_PREFIX>_peer_info_h peer_info,
+    char **uuid) {
+  return plugin_peer_info_get_uuid(peer_info, uuid);
+}
+
+int <MODULE_PREFIX>_peer_info_get_display_name(<MODULE_PREFIX>_peer_info_h peer_info,
+    char **display_name) {
+  return plugin_peer_info_get_display_name(peer_info, display_name);
+}
+)__c_cb";
+
+/**
+ * <PREFIX> The prefix of the connection result.
+ */
+constexpr const char __COMMON_BODY_CONNECTION_RESULT_BASE[] =
+R"__c_cb(
+int <MODULE_PREFIX>_connection_result_get_status(const <MODULE_PREFIX>_connection_result_h result,
+    <MODULE_PREFIX>_connection_status_e *status) {
+  return plugin_connection_result_get_status(result,(plugin_connection_status_e *)status);
+}
+
+int <MODULE_PREFIX>_connection_result_get_reason(const <MODULE_PREFIX>_connection_result_h result,
+    char **reason) {
+  return plugin_connection_result_get_reason(result, reason);
+}
+)__c_cb";
+
+/**
+ * <PREFIX> The prefix of the payload.
+ */
+constexpr const char __COMMON_BODY_PAYLOAD_BASE[] =
+R"__c_cb(
+int <MODULE_PREFIX>_payload_save_as_file(<MODULE_PREFIX>_payload_h payload, const char *path) {
+  return plugin_payload_save_as_file(payload, path);
+}
+
+int <MODULE_PREFIX>_payload_get_received_file_name(<MODULE_PREFIX>_payload_h payload,
+    char **file_name) {
+  return plugin_payload_get_received_file_name(payload, file_name);
+}
+
+int <MODULE_PREFIX>_payload_get_received_bytes(<MODULE_PREFIX>_payload_h payload, uint64_t *bytes) {
+  return plugin_payload_get_received_bytes( payload, bytes);
+}
+
+int <MODULE_PREFIX>_payload_get_total_bytes(<MODULE_PREFIX>_payload_h payload, uint64_t *bytes) {
+  return plugin_payload_get_total_bytes( payload, bytes);
+}
+)__c_cb";
+
+constexpr const char __INCLUDE_HEADER_DEF[] =
+R"__c_cb(
+#include <stdlib.h>
+#include <stdint.h>
+)__c_cb";
+
+constexpr const char __SERVER_HEADER_EXTRA[] =
+R"__c_cb(
+/**
+ * @brief Registers the set of the callback functions and the service_name.
+ * @details This function registers the set of the callback functions to handle stub events.
+ *          And, the <MODULE_PREFIX>_server_listen() is called internally to handle events.
+
+ * @privilege %http://tizen.org/privilege/d2d.datasharing \n
+ *            %http://tizen.org/privilege/internet
+ * @param[in] service_name The name of service
+ * @param[in] display_name The display name of service
+ * @param[in] broker_ip IP address of the broker to connect to
+ * @param[in] port The network port to connect to. Usually 1883
+ * @param[in] user_name The user name to connect to
+ * @param[in] password The Password to connect to
+ * @param[in] my_ip Own device ip address for connecting by others
+ * @param[in] protocols value of @a aitt_protocol_e. The value can be bitwise-or'd
+ * @param[in] callback The set of callback functions to handle stub events
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_NOT_SUPPORTED Not supported
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #<ERROR_PREFIX>_ERROR_IO_ERROR IO error
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #<ERROR_PREFIX>_ERROR_OPERATION_FAILED Operation failed
+ * @retval #<ERROR_PREFIX>_ERROR_PERMISSION_DENIED Permission denied
+ * @see <PREFIX>_<NAME>_unregister()
+ * @see #<PREFIX>_<NAME>_callback_s
+ */
+int <PREFIX>_<NAME>_register(const char *service_name, const char *display_name,
+    const char *broker_ip, int broker_port, const char *user_name,
+    const char *password, const char *my_ip, int protocols,
+    <PREFIX>_<NAME>_callback_s *callback, void *user_data);
+)__c_cb";
+
+constexpr const char __SERVER_BODY_EXTRA[] =
+R"__c_cb(
+int <PREFIX>_<NAME>_register(const char *service_name, const char *display_name,
+    const char *broker_ip, int broker_port, const char *user_name,
+    const char *password, const char *my_ip, int protocols,
+    <PREFIX>_<NAME>_callback_s *callback, void *user_data)
+)__c_cb";
+
+constexpr const char __CLIENT_HEADER_EXTRA[] =
+R"__c_cb(
+/**
+ * @brief Creates a <PREFIX>_<NAME> handle.
+ * @remarks The @a h handle should be released using
+ *          the <PREFIX>_<NAME>_destroy() if it's no longer needed.
+ * @privilege %http://tizen.org/privilege/d2d.datasharing \n
+ *            %http://tizen.org/privilege/internet
+ * @param[in] service_name The name of service
+ * @param[in] broker_ip IP address of the broker to connect to
+ * @param[in] port The network port to connect to. Usually 1883.
+ * @param[in] user_name The user name to connect to
+ * @param[in] password The Password to connect to
+ * @param[in] my_ip Own device ip address for connecting by others
+ * @param[in] protocols value of @a aitt_protocol_e. The value can be bitwise-or'd.
+ * @param[in] callback The set of callback functions to handle proxy events
+ * @param[in] user_data The user data to be passed to the callback function
+ * @param[out] h The <PREFIX>_<NAME> handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY Out of memory
+ * @see <PREFIX>_<NAME>_destroy()
+ * @see #<PREFIX>_<NAME>_callback_s
+ */
+int <PREFIX>_<NAME>_create(const char *service_name, const char *broker_ip, int broker_port,
+    const char *user_name, const char *password, const char *my_ip, int protocols,
+    <PREFIX>_<NAME>_callback_s *callback, void *user_data, <PREFIX>_<NAME>_h *h);
+)__c_cb";
+
+constexpr const char __CLIENT_BODY_EXTRA[] =
+R"__c_cb(
+int <PREFIX>_<NAME>_create(const char *service_name, const char *broker_ip, int broker_port,
+    const char *user_name, const char *password, const char *my_ip, int protocols,
+    <PREFIX>_<NAME>_callback_s *callback, void *user_data, <PREFIX>_<NAME>_h *h)
+)__c_cb";
+
+
+constexpr const char __GROUP_HEADER_EXTRA[] =
+R"__c_cb(
+/**
+ * @brief Creates a <PREFIX>_<NAME> handle.
+ * @remarks The @a h handle should be released using
+ *          the <PREFIX>_<NAME>_destroy() if it's no longer needed.
+ *
+ * @privilege %http://tizen.org/privilege/d2d.datasharing
+ *            %http://tizen.org/privilege/internet
+ * @param[in] topic_name topic_name The name of topic
+ * @param[in] broker_ip IP address of the broker to connect to
+ * @param[in] port The network port to connect to. Usually 1883.
+ * @param[in] user_name The user name to connect to
+ * @param[in] password The Password to connect to
+ * @param[in] my_ip Own device ip address for connecting by others
+ * @param[in] protocols value of @a aitt_protocol_e. The value can be bitwise-or'd.
+ * @param[in] callback The set of callback functions to handle events
+ * @param[in] user_data The user data to be passed to the callback function
+ * @param[out] h The <PREFIX>_<NAME> handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #AITT_PLUGIN_ERROR_NONE Successful
+ * @retval #AITT_PLUGIN_ERROR_NOT_SUPPORTED Not supported
+ * @retval #AITT_PLUGIN_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #AITT_PLUGIN_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #AITT_PLUGIN_ERROR_PERMISSION_DENIED Permission denied
+
+ * @see <PREFIX>_<NAME>_destroy()
+ * @see #<PREFIX>_<NAME>_callback_s
+ */
+int <PREFIX>_<NAME>_create(const char *topic_name, const char *broker_ip, int broker_port,
+    const char *user_name, const char *password,
+    const char *my_ip, int protocols,
+    <PREFIX>_<NAME>_callback_s *callback, void *user_data, <PREFIX>_<NAME>_h *h);
+)__c_cb";
+
+constexpr const char __GROUP_BODY_EXTRA[] =
+R"__c_cb(
+int <PREFIX>_<NAME>_create(const char *topic_name, const char *broker_ip, int broker_port,
+    const char *user_name, const char *password,
+    const char *my_ip, int protocols,
+    <PREFIX>_<NAME>_callback_s *callback, void *user_data, <PREFIX>_<NAME>_h *h)
+)__c_cb";
+
+
+}  // namespace
+
+namespace tidl {
+
+std::string AittPluginCTransportable::GenInclude(bool body, int type) const {
+  if (!body)
+    return __INCLUDE_HEADER_DEF;
+
+  switch (type) {
+  case 1:
+  {
+    return "#include \"aitt_plugin_proxy_internal.h\"";
+  }
+  case 2:
+  {
+    return "#include \"aitt_plugin_stub_internal.h\"";
+  }
+  case 3:
+  {
+    return "#include \"aitt_plugin_group_internal.h\"";
+  }
+  default:
+    return {};
+  }
+}
+
+std::string AittPluginCTransportable::GenHeaderBase() const {
+  return __COMMON_HEADER_COMMON_BASE;
+}
+
+std::string AittPluginCTransportable::GenHeaderPayloadHandle() const {
+  return __COMMON_HEADER_PAYLOAD_HANDLE;
+}
+
+std::string AittPluginCTransportable::GenHeaderCommonHandle() const {
+  return __COMMON_HEADER_HANDLES;
+}
+
+std::string AittPluginCTransportable::GenHeaderConnectionHandle() const {
+  return __COMMON_HEADER_CONNECTION_RESULT_HANDLE;
+}
+
+std::string AittPluginCTransportable::GenHeaderPayloadBase() const {
+  return __COMMON_HEADER_PAYLOAD_BASE;
+}
+
+std::string AittPluginCTransportable::GenHeaderConnectionBase() const {
+  return __COMMON_HEADER_CONNECTION_RESULT_BASE;
+}
+
+std::string AittPluginCTransportable::GenBodyPayloadBase() const {
+  return __COMMON_BODY_PAYLOAD_BASE;
+}
+
+std::string AittPluginCTransportable::GenBodyConnectionBase() const {
+  return __COMMON_BODY_CONNECTION_RESULT_BASE;
+}
+
+std::string AittPluginCTransportable::GenBodyPeerInfoBase() const {
+  return __COMMON_BODY_PEERINFO_BASE;
+}
+
+std::string AittPluginCTransportable::GenProxyPrefix() const {
+  return "aitt_plugin_proxy";
+}
+
+std::string AittPluginCTransportable::GenStubPrefix() const {
+  return "aitt_plugin_stub";
+}
+
+std::string AittPluginCTransportable::GenGroupPrefix() const {
+  return "aitt_plugin_group";
+}
+
+std::string AittPluginCTransportable::GenModulePrefix() const {
+  return "aitt_plugin";
+}
+
+std::string AittPluginCTransportable::GenErrorPrefix() const {
+  return "AITT_PLUGIN";
+}
+
+std::string AittPluginCTransportable::GenServerExtra(bool body) const {
+  if (body)
+    return __SERVER_BODY_EXTRA;
+  else
+    return __SERVER_HEADER_EXTRA;
+}
+
+std::string AittPluginCTransportable::GenClientExtra(bool body) const {
+  if (body)
+    return __CLIENT_BODY_EXTRA;
+  else
+    return __CLIENT_HEADER_EXTRA;
+}
+
+std::string AittPluginCTransportable::GenGroupExtra(bool body) const {
+  if (body)
+    return __GROUP_BODY_EXTRA;
+  else
+    return __GROUP_HEADER_EXTRA;
+}
+
+std::string AittPluginCTransportable::GenClientSendAsync(std::string client,
+    std::string payload, std::string size) const {
+  return std::string(ReplaceAll(__CLIENT_SEND_ASYNC, {
+      { "<CLIENT>", client },
+      { "<PAYLOAD>", payload},
+      { "<SIZE>", size} }));
+}
+
+std::string AittPluginCTransportable::GenClientSend(std::string client,
+    std::string data, std::string data_size,
+    std::string ret_data, std::string ret_data_size) const {
+  return std::string(ReplaceAll(__CLIENT_SEND, {
+      { "<CLIENT>", client },
+      { "<DATA>", data},
+      { "<DATA_SIZE>", data_size},
+      { "<RET_DATA>", ret_data},
+      { "<RET_DATA_SIZE>", ret_data_size} }));
+}
+
+std::string AittPluginCTransportable::GenServerSendAsync(std::string server,
+    std::string client,
+    std::string payload, std::string size) const {
+  return std::string(ReplaceAll(__SERVER_SEND_ASYNC, {
+      { "<SERVER>", server },
+      { "<CLIENT>", client},
+      { "<PAYLOAD>", payload},
+      { "<SIZE>", size} }));
+}
+
+std::string AittPluginCTransportable::GenServerFileSend(std::string path,
+    std::string server, std::string peer) const {
+  return std::string(ReplaceAll(__SERVER_FILE_SEND, {
+      { "<FILE_PATH>", path },
+      { "<SERVER_H>", server },
+      { "<PEER_H>", peer } }));
+}
+
+std::string AittPluginCTransportable::GenClientFileSend(std::string path,
+    std::string client) const {
+  return std::string(ReplaceAll(__CLINET_FILE_SEND, {
+      { "<FILE_PATH>", path },
+      { "<CLIENT_H>", client } }));
+}
+
+std::string AittPluginCTransportable::GenGroupType() const {
+  return "plugin_group_h";
+}
+
+std::string AittPluginCTransportable::GenPayloadTransferStatusType(bool internal_type) const {
+  if (internal_type)
+    return "transfer_status_e";
+  else
+    return "<MODULE_PREFIX>_payload_transfer_status_e";
+}
+
+std::string AittPluginCTransportable::GenPeerInfoType() const {
+  return "<MODULE_PREFIX>_peer_info_h";
+}
+
+std::string AittPluginCTransportable::GenPeerInfoDestroy(std::string peer) const {
+  return std::string(ReplaceAll("<MODULE_PREFIX>_peer_info_destroy(<PEER>);", {
+      { "<PEER>", peer } }));
+}
+
+std::string AittPluginCTransportable::GenPayloadType(bool internal_type) const {
+  if (internal_type)
+  return "plugin_payload_h";
+  else
+  return "<MODULE_PREFIX>_payload_h";
+}
+
+std::string AittPluginCTransportable::GenClientType() const {
+  return "plugin_client_h";
+}
+
+std::string AittPluginCTransportable::GenSecurityType(bool definition) const {
+  return "";
+}
+
+std::string AittPluginCTransportable::GenServerType() const {
+  return "plugin_server_h";
+}
+
+std::string AittPluginCTransportable::GenClientTryConnect(std::string client,
+    std::string peer) const {
+  return std::string(ReplaceAll(__CLIENT_TRY_CONNECT, {
+      { "<CLIENT>", client },
+      { "<PEER>", peer } }));
+}
+
+std::string AittPluginCTransportable::GenClientDisconnect(
+    std::string client) const {
+  return std::string(ReplaceAll(__CLIENT_DISCONNECT, {
+      { "<CLIENT>", client } }));
+}
+
+std::string AittPluginCTransportable::GenClientTryDiscovery(
+    std::string client) const {
+  return std::string(ReplaceAll(__CLIENT_TRY_DISCOVERY, {
+      { "<CLIENT>", client } }));
+}
+
+std::string AittPluginCTransportable::GenClientStopDiscovery(
+    std::string client) const {
+  return std::string(ReplaceAll(__CLIENT_STOP_DISCOVERY, {
+      { "<CLIENT>", client } }));
+}
+
+std::string AittPluginCTransportable::GenServerRegister() const {
+  return __SERVER_REGISTER;
+}
+
+std::string AittPluginCTransportable::GenServerUnregister() const {
+  return __SERVER_UNREGISTER;
+}
+
+std::string AittPluginCTransportable::GenClientExtraHeader() const {
+  return "";
+}
+
+std::string AittPluginCTransportable::GenClientExtraBody() const {
+  return "";
+}
+
+std::string AittPluginCTransportable::GenServerExtraHeader() const {
+  return "";
+}
+
+std::string AittPluginCTransportable::GenServerExtraBody() const {
+  return "";
+}
+
+std::string AittPluginCTransportable::GenServerAccept() const {
+  return __SERVER_ACCEPT;
+}
+
+std::string AittPluginCTransportable::GenServerReject() const {
+  return __SERVER_REJECT;
+}
+
+std::string AittPluginCTransportable::GenServerSetDisplayName() const {
+  return __SERVER_SET_DISPLAY_NAME;
+}
+
+std::string AittPluginCTransportable::GenGroupPublish() const {
+  return __GROUP_PUBLISH;
+}
+
+std::string AittPluginCTransportable::GenPayloadTypeEnum() const {
+  return "plugin_payload_type_e";
+}
+
+std::string AittPluginCTransportable::GenPayloadTypeData() const {
+  return "AITT_PLUGIN_PAYLOAD_TYPE_DATA";
+}
+
+std::string AittPluginCTransportable::GenPayloadTypeFile() const {
+  return "AITT_PLUGIN_PAYLOAD_TYPE_FILE";
+}
+
+std::string AittPluginCTransportable::GenPayloadGetType() const {
+  return "ret = plugin_payload_get_type(payload, &type);";
+}
+
+std::string AittPluginCTransportable::GenErrorNone() const {
+  return "AITT_PLUGIN_ERROR_NONE";
+}
+
+std::string AittPluginCTransportable::GenPayloadGetData() const {
+  return "ret = plugin_payload_get_data(payload, &data, &data_len);";
+}
+
+std::string AittPluginCTransportable::GenClientCreate() const {
+  return __CLIENT_CREATE;
+}
+
+std::string AittPluginCTransportable::GenGroupCreate() const {
+  return __GROUP_CREATE;
+}
+
+std::string AittPluginCTransportable::GenGroupDestroy() const {
+  return __GROUP_DESTROY;
+}
+
+std::string AittPluginCTransportable::GenClientDestroy() const {
+  return __CLIENT_DESTROY;
+}
+
+std::string AittPluginCTransportable::GenSetSecurityCA(std::string arg) const {
+  return "";
+}
+
+std::string AittPluginCTransportable::GenSetSecurityCert(std::string arg) const {
+  return "";
+}
+
+std::string AittPluginCTransportable::GenSetSecurityPrivateKey(std::string arg) const {
+  return "";
+}
+
+std::string AittPluginCTransportable::GenPeerInfoClone(std::string src_peer,
+      std::string dest_peer) const {
+  return std::string(ReplaceAll(__PEER_INFO_CLONE, {
+      { "<SRC_PEER>", src_peer },
+      { "<DEST_PEER>", dest_peer } }));
+}
+
+std::string AittPluginCTransportable::GenServerForeachConnectedPeerInfo(
+    std::string name) const {
+  return std::string(ReplaceAll(__SERVER_FOREACH_CONNECTED_PEER_INFO, {
+      { "<NAME>", name } }));
+}
+
+}  // namespace tidl
diff --git a/idlc/gen_aitt_plugin/aitt_plugin_c_transportable.h b/idlc/gen_aitt_plugin/aitt_plugin_c_transportable.h
new file mode 100644 (file)
index 0000000..8cdaada
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IDLC_GEN_AITT_PLUGIN_C_TRANSPORTABLE_H_
+#define IDLC_GEN_AITT_PLUGIN_C_TRANSPORTABLE_H_
+
+#include <string>
+
+#include "idlc/gen_cion/c_transportable.h"
+
+namespace tidl {
+
+class AittPluginCTransportable : public CTransportable {
+ public:
+  virtual ~AittPluginCTransportable() = default;
+  std::string GenInclude(bool body = true, int type = 0) const override;
+  std::string GenHeaderBase() const override;
+  std::string GenHeaderPayloadHandle() const override;
+  std::string GenHeaderCommonHandle() const override;
+  std::string GenHeaderConnectionHandle() const override;
+  std::string GenHeaderPayloadBase() const override;
+  std::string GenHeaderConnectionBase() const override;
+  std::string GenBodyPayloadBase() const override;
+  std::string GenBodyConnectionBase() const override;
+  std::string GenBodyPeerInfoBase() const override;
+  std::string GenProxyPrefix() const override;
+  std::string GenStubPrefix() const override;
+  std::string GenGroupPrefix() const override;
+  std::string GenModulePrefix() const override;
+  std::string GenErrorPrefix() const override;
+  std::string GenServerExtra(bool body = true) const override;
+  std::string GenClientExtra(bool body = true) const override;
+  std::string GenGroupExtra(bool body = true) const override;
+  std::string GenClientSendAsync(std::string client,
+      std::string payload, std::string size) const override;
+  std::string GenClientSend(std::string client, std::string data,
+      std::string data_size, std::string ret_data,
+      std::string ret_data_size) const override;
+  std::string GenServerSendAsync(std::string server, std::string client,
+      std::string payload, std::string size) const override;
+  std::string GenServerFileSend(std::string path,
+      std::string server, std::string peer) const override;
+  std::string GenClientFileSend(std::string path,
+      std::string client) const override;
+  std::string GenGroupType() const override;
+  std::string GenPayloadTransferStatusType(bool internal_type = false) const override;
+  std::string GenPeerInfoType() const override;
+  std::string GenPeerInfoDestroy(std::string peer) const override;
+  std::string GenPayloadType(bool internal_type = false) const override;
+  std::string GenClientType() const override;
+  std::string GenSecurityType(bool definition = true) const override;
+  std::string GenServerType() const override;
+  std::string GenClientTryConnect(std::string client,
+      std::string peer) const override;
+  std::string GenClientDisconnect(std::string client) const override;
+  std::string GenClientTryDiscovery(std::string client) const override;
+  std::string GenClientStopDiscovery(std::string client) const override;
+  std::string GenServerRegister() const override;
+  std::string GenServerUnregister() const override;
+  std::string GenClientExtraHeader() const override;
+  std::string GenClientExtraBody() const override;
+  std::string GenServerExtraHeader() const override;
+  std::string GenServerExtraBody() const override;
+  std::string GenServerAccept() const override;
+  std::string GenServerReject() const override;
+  std::string GenServerSetDisplayName() const override;
+  std::string GenGroupPublish() const override;
+  std::string GenPayloadTypeEnum() const override;
+  std::string GenPayloadTypeData() const override;
+  std::string GenPayloadTypeFile() const override;
+  std::string GenPayloadGetType() const override;
+  std::string GenErrorNone() const override;
+  std::string GenPayloadGetData() const override;
+  std::string GenClientCreate() const override;
+  std::string GenGroupCreate() const override;
+  std::string GenGroupDestroy() const override;
+  std::string GenClientDestroy() const override;
+  std::string GenSetSecurityCA(std::string arg) const override;
+  std::string GenSetSecurityCert(std::string arg) const override;
+  std::string GenSetSecurityPrivateKey(std::string arg) const override;
+  std::string GenPeerInfoClone(std::string src_peer,
+      std::string dest_peer) const override;
+  std::string GenServerForeachConnectedPeerInfo(std::string name) const override;
+};
+
+}  // namespace tidl
+
+#endif  // IDLC_GEN_AITT_PLUGIN_C_TRANSPORTABLE_H_
diff --git a/idlc/gen_aitt_plugin/aitt_plugin_internal_body_gen.cc b/idlc/gen_aitt_plugin/aitt_plugin_internal_body_gen.cc
new file mode 100644 (file)
index 0000000..86b2dc0
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <algorithm>
+
+#include "idlc/gen_aitt_plugin/aitt_plugin_internal_body_gen.h"
+#include "idlc/gen_aitt_plugin/aitt_plugin_internal_body_gen_cb.h"
+
+namespace tidl {
+
+AittPluginInternalBodyGen::AittPluginInternalBodyGen(std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans)
+    : CCionBodyGeneratorBase(doc, trans) {
+}
+
+void AittPluginInternalBodyGen::OnInitGen(std::ofstream& stream) {
+  GenVersion(stream);
+  GenGNUSourceDefinition(stream);
+  GenIncludeHeader(stream);
+  GenLogTag(stream, std::string("AITT_PLUGIN_INTERNAL"));
+  GenLogDefinition(stream);
+  GenBody(stream);
+  GenPluginInit(stream);
+}
+
+
+void AittPluginInternalBodyGen::GenPluginInit(std::ofstream& stream) {
+  stream << CB_PLUGIN_INIT_BASE;
+}
+
+void AittPluginInternalBodyGen::GenIncludeHeader(std::ofstream& stream) {
+  stream << tidl::ReplaceAll(CB_INTERNAL_HEADER, "<PREFIX>", GetHandlePrefix());
+}
+
+void AittPluginInternalBodyGen::GenLoadModule(std::ofstream& stream) {
+  stream << CB_LOAD_MOUDLE_BASE;
+  stream << CB_LOAD_MOUDLE_PAYLOAD;
+  stream << CB_LOAD_MOUDLE_PEERINFO;
+  stream << CB_LOAD_MOUDLE_CONNECTION;
+
+  switch (GetType()) {
+    case 1:
+    {
+      stream << CB_LOAD_MOUDLE_CLIENT;
+      break;
+    }
+    case 2:
+    {
+      stream << CB_LOAD_MOUDLE_SERVER;
+      break;
+    }
+    case 3:
+    {
+      stream << CB_LOAD_MOUDLE_GROUP;
+      break;
+    }
+    default:
+      break;
+  }
+  stream << CB_LOAD_MOUDLE_BASE_RETURN;
+}
+
+void AittPluginInternalBodyGen::GenBody(std::ofstream& stream) {
+  stream << CB_BODY_BASE;
+  switch (GetType()) {
+    case 1:
+    {
+      stream << CB_BODY_CLIENT;
+      break;
+    }
+    case 2:
+    {
+      stream << CB_BODY_SERVER;
+      break;
+    }
+    case 3:
+    {
+      stream << CB_BODY_GROUP;
+      break;
+    }
+
+    default:
+      break;
+  }
+
+  GenLoadModule(stream);
+}
+
+void AittPluginInternalBodyGen::OnFiniGen(std::ofstream& stream) {
+}
+
+}  // namespace tidl
diff --git a/idlc/gen_aitt_plugin/aitt_plugin_internal_body_gen.h b/idlc/gen_aitt_plugin/aitt_plugin_internal_body_gen.h
new file mode 100644 (file)
index 0000000..0228e4f
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IDLC_AITT_PLUGIN_C_INTERNAL_BODY_GEN_H_
+#define IDLC_AITT_PLUGIN_C_INTERNAL_BODY_GEN_H_
+
+#include <memory>
+#include <string>
+
+#include "idlc/gen_cion/c_cion_body_gen_base.h"
+
+namespace tidl {
+
+class AittPluginInternalBodyGen : public CCionBodyGeneratorBase {
+ public:
+  explicit AittPluginInternalBodyGen(std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans);
+  virtual ~AittPluginInternalBodyGen() = default;
+
+  void OnInitGen(std::ofstream& stream) override;
+  void OnFiniGen(std::ofstream& stream) override;
+
+ private:
+  void GenPluginInit(std::ofstream& stream);
+  void GenIncludeHeader(std::ofstream& stream);
+  void GenLoadModule(std::ofstream& stream);
+  void GenBody(std::ofstream& stream);
+};
+
+}  // namespace tidl
+
+#endif  // IDLC_AITT_PLUGIN_C_INTERNAL_BODY_GEN_H_
diff --git a/idlc/gen_aitt_plugin/aitt_plugin_internal_body_gen_cb.h b/idlc/gen_aitt_plugin/aitt_plugin_internal_body_gen_cb.h
new file mode 100644 (file)
index 0000000..eae21a3
--- /dev/null
@@ -0,0 +1,516 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IDLC_C_AITT_PLUGIN_GEN_INTERNAL_BODY_GEN_CB_H_
+#define IDLC_C_AITT_PLUGIN_GEN_INTERNAL_BODY_GEN_CB_H_
+
+constexpr const char CB_INTERNAL_HEADER[] =
+R"__c_cb(
+
+#include <dlfcn.h>
+#include <stdio.h>
+#include <dlog.h>
+
+#include "<PREFIX>_internal.h"
+
+)__c_cb";
+
+constexpr const char CB_LOAD_MOUDLE_SERVER[] =
+R"__c_cb(
+  if (!__load_server_channel())
+    goto out;
+)__c_cb";
+
+constexpr const char CB_LOAD_MOUDLE_PAYLOAD[] =
+R"__c_cb(
+  if (!__load_payload())
+    goto out;
+)__c_cb";
+
+constexpr const char CB_LOAD_MOUDLE_PEERINFO[] =
+R"__c_cb(
+  if (!__load_peerinfo())
+    goto out;
+)__c_cb";
+
+constexpr const char CB_LOAD_MOUDLE_CONNECTION[] =
+R"__c_cb(
+  if (!__load_connection())
+    goto out;
+)__c_cb";
+
+constexpr const char CB_LOAD_MOUDLE_CLIENT[] =
+R"__c_cb(
+  if (!__load_client_channel())
+    goto out;
+)__c_cb";
+
+constexpr const char CB_LOAD_MOUDLE_GROUP[] =
+R"__c_cb(
+  if (!__load_group_channel())
+    goto out;
+)__c_cb";
+
+constexpr const char CB_PLUGIN_INIT_BASE[] =
+R"__c_cb(
+PLUGIN_CTOR static void _plugin_init(void)
+{
+  __load_module();
+}
+)__c_cb";
+
+constexpr const char CB_LOAD_MOUDLE_BASE[] =
+R"__c_cb(
+static void __load_module() {
+  plugin_handle = dlopen(LIBAITT_PLUGIN_INFO, RTLD_LAZY | RTLD_GLOBAL);
+  if (!plugin_handle) {
+    LOGE("Failed to load - %s", dlerror());
+    return;
+  }
+)__c_cb";
+
+constexpr const char CB_LOAD_MOUDLE_BASE_RETURN[] =
+R"__c_cb(
+  return;
+
+out:
+
+  dlclose(plugin_handle);
+}
+)__c_cb";
+
+constexpr const char CB_BODY_BASE[] =
+R"__c_cb(
+
+#define LIBAITT_PLUGIN_INFO "/usr/lib/libaitt_plugin.so"
+static void *plugin_handle;
+
+#define PLUGIN_CTOR __attribute__((constructor))
+
+static bool __load_payload() {
+  plugin_payload_create = dlsym(plugin_handle,
+      "aitt_plugin_payload_create");
+  if (!plugin_payload_create) {
+    LOGE("Failed to find plugin_payload_create");
+    return false;
+  }
+
+  plugin_payload_destroy = dlsym(plugin_handle,
+      "aitt_plugin_payload_destroy");
+  if (!plugin_payload_destroy) {
+    LOGE("Failed to find plugin_payload_destroy");
+    return false;
+  }
+
+  plugin_payload_get_type = dlsym(plugin_handle,
+      "aitt_plugin_payload_get_type");
+  if (!plugin_payload_get_type) {
+    LOGE("Failed to find plugin_payload_get_type");
+    return false;
+  }
+
+  plugin_payload_get_data = dlsym(plugin_handle,
+      "aitt_plugin_payload_get_data");
+  if (!plugin_payload_get_data) {
+    LOGE("Failed to find plugin_payload_get_data");
+    return false;
+  }
+
+  plugin_payload_set_data = dlsym(plugin_handle,
+      "aitt_plugin_payload_set_data");
+  if (!plugin_payload_set_data) {
+    LOGE("Failed to find plugin_payload_set_data");
+    return false;
+  }
+
+  plugin_payload_save_as_file = dlsym(plugin_handle,
+      "aitt_plugin_payload_save_as_file");
+  if (!plugin_payload_save_as_file) {
+    LOGE("Failed to find plugin_payload_save_as_file");
+    return false;
+  }
+
+  plugin_payload_get_received_file_name = dlsym(plugin_handle,
+      "aitt_plugin_payload_get_received_file_name");
+  if (!plugin_payload_get_received_file_name) {
+    LOGE("Failed to find plugin_payload_get_received_file_name");
+    return false;
+  }
+
+  plugin_payload_get_received_bytes = dlsym(plugin_handle,
+      "aitt_plugin_payload_get_received_bytes");
+  if (!plugin_payload_get_received_bytes) {
+    LOGE("Failed to init plugin_payload_get_received_bytes");
+    return false;
+  }
+
+  plugin_payload_get_total_bytes = dlsym(plugin_handle,
+      "aitt_plugin_payload_get_total_bytes");
+  if (!plugin_payload_get_total_bytes) {
+    LOGE("Failed to find plugin_payload_get_total_bytes");
+    return false;
+  }
+
+  plugin_payload_set_file_path = dlsym(plugin_handle,
+      "aitt_plugin_payload_set_file_path");
+  if (!plugin_payload_set_file_path) {
+    LOGE("Failed to find plugin_payload_set_file_path");
+    return false;
+  }
+
+  plugin_payload_get_payload_id = dlsym(plugin_handle,
+      "aitt_plugin_payload_get_payload_id");
+  if (!plugin_payload_get_payload_id) {
+    LOGE("Failed to find plugin_payload_get_payload_id");
+    return false;
+  }
+
+  return true;
+}
+
+static bool __load_peerinfo() {
+  plugin_peer_info_clone = dlsym(plugin_handle,
+      "aitt_plugin_peer_info_clone");
+  if (!plugin_peer_info_clone) {
+    LOGE("Failed to find plugin_peer_info_clone");
+    return false;
+  }
+
+  plugin_peer_info_destroy = dlsym(plugin_handle,
+      "aitt_plugin_peer_info_destroy");
+  if (!plugin_peer_info_destroy) {
+    LOGE("Failed to find plugin_peer_info_destroy");
+    return false;
+  }
+
+  plugin_peer_info_get_device_id = dlsym(plugin_handle,
+      "aitt_plugin_peer_info_get_device_id");
+  if (!plugin_peer_info_get_device_id) {
+    LOGE("Failed to find plugin_peer_info_get_device_id");
+    return false;
+  }
+
+  plugin_peer_info_get_device_name = dlsym(plugin_handle,
+      "aitt_plugin_peer_info_get_device_name");
+  if (!plugin_peer_info_get_device_name) {
+    LOGE("Failed to find plugin_peer_info_get_device_name");
+    return false;
+  }
+
+  plugin_peer_info_get_device_platform = dlsym(plugin_handle,
+      "aitt_plugin_peer_info_get_device_platform");
+  if (!plugin_peer_info_get_device_platform) {
+    LOGE("Failed to find plugin_peer_info_get_device_platform");
+    return false;
+  }
+
+  plugin_peer_info_get_device_platform_version = dlsym(plugin_handle,
+      "aitt_plugin_peer_info_get_device_platform_version");
+  if (!plugin_peer_info_get_device_platform_version) {
+    LOGE("Failed to find plugin_peer_info_get_device_platform_version");
+    return false;
+  }
+
+  plugin_peer_info_get_device_type = dlsym(plugin_handle,
+      "aitt_plugin_peer_info_get_device_type");
+  if (!plugin_peer_info_get_device_type) {
+    LOGE("Failed to find plugin_peer_info_get_device_type");
+    return false;
+  }
+
+  plugin_peer_info_get_app_id = dlsym(plugin_handle,
+      "aitt_plugin_peer_info_get_app_id");
+  if (!plugin_peer_info_get_app_id) {
+    LOGE("Failed to init plugin_peer_info_get_app_id");
+    return false;
+  }
+
+  plugin_peer_info_get_app_version = dlsym(plugin_handle,
+      "aitt_plugin_peer_info_get_app_version");
+  if (!plugin_peer_info_get_app_version) {
+    LOGE("Failed to find plugin_peer_info_get_app_version");
+    return false;
+  }
+
+  plugin_peer_info_get_uuid = dlsym(plugin_handle,
+      "aitt_plugin_peer_info_get_uuid");
+  if (!plugin_peer_info_get_uuid) {
+    LOGE("Failed to find plugin_peer_info_get_uuid");
+    return false;
+  }
+
+  plugin_peer_info_get_display_name = dlsym(plugin_handle,
+      "aitt_plugin_peer_info_get_display_name");
+  if (!plugin_peer_info_get_display_name) {
+    LOGE("Failed to find plugin_peer_info_get_display_name");
+    return false;
+  }
+
+  return true;
+}
+
+static bool __load_connection() {
+  plugin_connection_result_get_status = dlsym(plugin_handle,
+      "aitt_plugin_connection_result_get_status");
+  if (!plugin_connection_result_get_status) {
+    LOGE("Failed to find plugin_connection_result_get_status");
+    return false;
+  }
+
+  plugin_connection_result_get_reason = dlsym(plugin_handle,
+      "aitt_plugin_connection_result_get_reason");
+  if (!plugin_connection_result_get_reason) {
+    LOGE("Failed to find plugin_connection_result_get_reason");
+    return false;
+  }
+
+  return true;
+}
+)__c_cb";
+
+constexpr const char CB_BODY_GROUP[] =
+R"__c_cb(
+static bool __load_group_channel() {
+  plugin_group_create = dlsym(plugin_handle, "aitt_plugin_group_create");
+  if (!plugin_group_create) {
+    LOGE("Failed to find plugin_group_create");
+    return false;
+  }
+
+  plugin_group_destroy = dlsym(plugin_handle,
+      "aitt_plugin_group_destroy");
+  if (!plugin_group_destroy) {
+    LOGE("Failed to find plugin_group_destroy");
+    return false;
+  }
+
+  plugin_group_subscribe = dlsym(plugin_handle,
+      "aitt_plugin_group_subscribe");
+  if (!plugin_group_subscribe) {
+    LOGE("Failed to find plugin_group_subscribe");
+    return false;
+  }
+
+  plugin_group_unsubscribe = dlsym(plugin_handle,
+      "aitt_plugin_group_unsubscribe");
+  if (!plugin_group_unsubscribe) {
+    LOGE("Failed to find plugin_group_unsubscribe");
+    return false;
+  }
+
+  plugin_group_publish = dlsym(plugin_handle,
+      "aitt_plugin_group_publish");
+  if (!plugin_group_publish) {
+    LOGE("Failed to find plugin_group_publish");
+    return false;
+  }
+
+  plugin_group_add_payload_received_cb = dlsym(plugin_handle,
+      "aitt_plugin_group_add_payload_received_cb");
+  if (!plugin_group_add_payload_received_cb) {
+    LOGE("Failed to find plugin_group_add_payload_received_cb");
+    return false;
+  }
+
+  plugin_group_add_joined_cb = dlsym(plugin_handle,
+      "aitt_plugin_group_add_joined_cb");
+  if (!(*plugin_group_add_joined_cb)) {
+    LOGE("Failed to find plugin_group_add_joined_cb");
+    return false;
+  }
+
+  plugin_group_add_left_cb = dlsym(plugin_handle,
+      "aitt_plugin_group_add_left_cb");
+  if (!plugin_group_add_left_cb) {
+    LOGE("Failed to init plugin_group_add_left_cb");
+    return false;
+  }
+
+  return true;
+}
+)__c_cb";
+
+constexpr const char CB_BODY_CLIENT[] =
+R"__c_cb(
+static bool __load_client_channel() {
+  plugin_client_create = dlsym(plugin_handle, "aitt_plugin_client_create");
+  if (!plugin_client_create) {
+    LOGE("Failed to find plugin_client_create");
+    return false;
+  }
+
+  plugin_client_destroy = dlsym(plugin_handle,
+      "aitt_plugin_client_destroy");
+  if (!plugin_client_destroy) {
+    LOGE("Failed to find plugin_client_destroy");
+    return false;
+  }
+
+  plugin_client_try_discovery = dlsym(plugin_handle,
+      "aitt_plugin_client_try_discovery");
+  if (!plugin_client_try_discovery) {
+    LOGE("Failed to find plugin_client_try_discovery");
+    return false;
+  }
+
+  plugin_client_stop_discovery = dlsym(plugin_handle,
+      "aitt_plugin_client_stop_discovery");
+  if (!plugin_client_stop_discovery) {
+    LOGE("Failed to find plugin_client_stop_discovery");
+    return false;
+  }
+
+  plugin_client_connect = dlsym(plugin_handle,
+      "aitt_plugin_client_connect");
+  if (!plugin_client_connect) {
+    LOGE("Failed to find plugin_client_connect");
+    return false;
+  }
+
+  plugin_client_disconnect = dlsym(plugin_handle,
+      "aitt_plugin_client_disconnect");
+  if (!plugin_client_disconnect) {
+    LOGE("Failed to find plugin_client_disconnect");
+    return false;
+  }
+
+  plugin_client_send_data = dlsym(plugin_handle,
+      "aitt_plugin_client_send_data");
+  if (!(*plugin_client_send_data)) {
+    LOGE("Failed to find plugin_client_send_data");
+    return false;
+  }
+
+  plugin_client_send_payload_async = dlsym(plugin_handle,
+      "aitt_plugin_client_send_payload_async");
+  if (!plugin_client_send_payload_async) {
+    LOGE("Failed to init plugin_client_send_payload_async");
+    return false;
+  }
+
+  plugin_client_add_connection_result_cb = dlsym(plugin_handle,
+      "aitt_plugin_client_add_connection_result_cb");
+  if (!plugin_client_add_connection_result_cb) {
+    LOGE("Failed to find plugin_client_add_connection_result_cb");
+    return false;
+  }
+
+  plugin_client_add_payload_received_cb = dlsym(plugin_handle,
+        "aitt_plugin_client_add_payload_received_cb");
+  if (!plugin_client_add_payload_received_cb) {
+    LOGE("Failed to find plugin_client_add_payload_received_cb");
+    return false;
+  }
+
+  plugin_client_add_disconnected_cb = dlsym(plugin_handle,
+      "aitt_plugin_client_add_disconnected_cb");
+  if (!plugin_client_add_disconnected_cb) {
+    LOGE("Failed to find plugin_client_add_disconnected_cb");
+    return false;
+  }
+
+  return true;
+}
+)__c_cb";
+
+constexpr const char CB_BODY_SERVER[] =
+R"__c_cb(
+static bool __load_server_channel() {
+  plugin_server_create = dlsym(plugin_handle, "aitt_plugin_server_create");
+  if (!plugin_server_create) {
+    LOGE("Failed to find plugin_server_create");
+    return false;
+  }
+
+  plugin_server_add_connection_result_cb = dlsym(plugin_handle,
+      "aitt_plugin_server_add_connection_result_cb");
+  if (!plugin_server_add_connection_result_cb) {
+    LOGE("Failed to find plugin_server_add_connection_result_cb");
+    return false;
+  }
+
+  plugin_server_add_payload_received_cb = dlsym(plugin_handle,
+      "aitt_plugin_server_add_payload_received_cb");
+  if (!plugin_server_add_payload_received_cb) {
+    LOGE("Failed to find plugin_server_add_payload_received_cb");
+    return false;
+  }
+
+  plugin_server_add_disconnected_cb = dlsym(plugin_handle,
+      "aitt_plugin_server_add_disconnected_cb");
+  if (!plugin_server_add_disconnected_cb) {
+    LOGE("Failed to find plugin_server_add_disconnected_cb");
+    return false;
+  }
+
+  plugin_server_set_data_received_cb = dlsym(plugin_handle,
+      "aitt_plugin_server_set_data_received_cb");
+  if (!plugin_server_set_data_received_cb) {
+    LOGE("Failed to find plugin_server_set_data_received_cb");
+    return false;
+  }
+
+  plugin_server_listen = dlsym(plugin_handle, "aitt_plugin_server_listen");
+  if (!plugin_server_listen) {
+    LOGE("Failed to find plugin_server_listen");
+    return false;
+  }
+
+  plugin_server_foreach_connected_peer_info = dlsym(plugin_handle,
+      "aitt_plugin_server_foreach_connected_peer_info");
+  if (!(*plugin_server_foreach_connected_peer_info)) {
+    LOGE("Failed to find plugin_server_foreach_connected_peer_info");
+    return false;
+  }
+
+  plugin_server_accept = dlsym(plugin_handle, "aitt_plugin_server_accept");
+  if (!plugin_server_accept) {
+    LOGE("Failed to init plugin_server_accept");
+    return false;
+  }
+
+  plugin_server_reject = dlsym(plugin_handle, "aitt_plugin_server_reject");
+  if (!plugin_server_reject) {
+    LOGE("Failed to find plugin_server_reject");
+    return false;
+  }
+
+  plugin_server_set_display_name = dlsym(plugin_handle,
+        "aitt_plugin_server_set_display_name");
+  if (!plugin_server_set_display_name) {
+    LOGE("Failed to find plugin_server_set_display_name");
+    return false;
+  }
+
+  plugin_server_send_payload_async = dlsym(plugin_handle,
+      "aitt_plugin_server_send_payload_async");
+  if (!plugin_server_send_payload_async) {
+    LOGE("Failed to find plugin_server_send_payload_async");
+    return false;
+  }
+
+  plugin_server_destroy = dlsym(plugin_handle,
+      "aitt_plugin_server_destroy");
+  if (!plugin_server_destroy) {
+    LOGE("Failed to find plugin_server_destroy");
+    return false;
+  }
+
+  return true;
+}
+)__c_cb";
+
+#endif  // IDLC_C_AITT_PLUGIN_GEN_INTERNAL_BODY_GEN_CB_H_
diff --git a/idlc/gen_aitt_plugin/aitt_plugin_internal_header_gen.cc b/idlc/gen_aitt_plugin/aitt_plugin_internal_header_gen.cc
new file mode 100644 (file)
index 0000000..972b92c
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "idlc/gen_aitt_plugin/aitt_plugin_internal_header_gen.h"
+
+namespace {
+#include "idlc/gen_aitt_plugin/aitt_plugin_internal_header_gen_cb.h"
+}
+
+namespace tidl {
+
+AittPluginInternalHeaderGen::AittPluginInternalHeaderGen(std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans)
+    : CCionHeaderGeneratorBase(doc, trans) {}
+
+void AittPluginInternalHeaderGen::OnInitGen(std::ofstream& stream) {
+  GenVersion(stream);
+
+  stream << CB_HEADER_START;
+  stream << CB_HEADER_DEF_COMMON;
+
+  switch (GetType()) {
+    case 1:
+    {
+      stream << CB_HEADER_DEF_CLIENT;
+      stream << CB_HEADER_FUN_CLIENT;
+      break;
+    }
+    case 2:
+    {
+      stream << CB_HEADER_DEF_SERVER;
+      stream << CB_HEADER_FUN_SERVER;
+      break;
+    }
+    case 3:
+    {
+      stream << CB_HEADER_DEF_GROUP;
+      stream << CB_HEADER_FUN_GROUP;
+      break;
+    }
+    default:
+      break;
+  }
+  stream << CB_HEADER_FUN_COMMOM;
+
+}
+
+void AittPluginInternalHeaderGen::OnFiniGen(std::ofstream& stream) {
+  GenExplicitLinkageClose(stream);
+}
+
+}  // namespace tidl
diff --git a/idlc/gen_aitt_plugin/aitt_plugin_internal_header_gen.h b/idlc/gen_aitt_plugin/aitt_plugin_internal_header_gen.h
new file mode 100644 (file)
index 0000000..bbefc4d
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IDLC_AITT_PLUGIN_C_INTERNAL_HEADER_GEN_H_
+#define IDLC_AITT_PLUGIN_C_INTERNAL_HEADER_GEN_H_
+
+#include <memory>
+#include <string>
+
+#include "idlc/gen_cion/c_cion_header_gen_base.h"
+
+namespace tidl {
+
+class AittPluginInternalHeaderGen : public CCionHeaderGeneratorBase {
+ public:
+  explicit AittPluginInternalHeaderGen(std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans);
+  virtual ~AittPluginInternalHeaderGen() = default;
+
+  void OnInitGen(std::ofstream& stream) override;
+  void OnFiniGen(std::ofstream& stream) override;
+};
+
+}  // namespace tidl
+
+#endif  // IDLC_AITT_PLUGIN_C_INTERNAL_HEADER_GEN_H_
\ No newline at end of file
diff --git a/idlc/gen_aitt_plugin/aitt_plugin_internal_header_gen_cb.h b/idlc/gen_aitt_plugin/aitt_plugin_internal_header_gen_cb.h
new file mode 100644 (file)
index 0000000..b11e589
--- /dev/null
@@ -0,0 +1,212 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IDLC_C_AITT_PLUGIN_GEN_INTERNAL_HEADER_GEN_CB_H_
+#define IDLC_C_AITT_PLUGIN_GEN_INTERNAL_HEADER_GEN_CB_H_
+constexpr const char CB_HEADER_START[] =
+R"__c_cb(
+
+#pragma once
+
+#include <stdlib.h>
+#include <stdbool.h>
+#include <stdint.h>
+
+#include <tizen.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum _transfer_status_e {
+  SUCCESS, /**< Transfer is success **/
+  FAILURE, /**< Transfer is failed **/
+  IN_PROGRESS, /**< Transfer is in progress **/
+} transfer_status_e;
+
+typedef enum _payload_type_e {
+  AITT_PLUGIN_PAYLOAD_TYPE_DATA, /**< Data type payload **/
+  AITT_PLUGIN_PAYLOAD_TYPE_FILE, /**< File type payload **/
+} plugin_payload_type_e;
+
+typedef enum _connection_status_e {
+  CONNECTION_STATUS_OK, /**< Connection is ok **/
+  CONNECTION_STATUS_REJECTED, /**< Connection is rejected **/
+  CONNECTION_STATUS_ERROR, /**< Connection error occurs **/
+} plugin_connection_status_e;
+)__c_cb";
+
+constexpr const char CB_HEADER_DEF_COMMON[] =
+R"__c_cb(
+typedef void *plugin_peer_info_h;
+typedef void *plugin_connection_result_h;
+typedef void *plugin_payload_h;
+typedef void *plugin_payload_async_result_h;
+)__c_cb";
+
+constexpr const char CB_HEADER_DEF_SERVER[] =
+R"__c_cb(
+typedef void *plugin_server_h;
+
+typedef void (*plugin_server_connection_result_cb)(
+    const char *service_name, const plugin_peer_info_h peer_info,
+    const plugin_connection_result_h result, void *user_data);
+typedef void (*plugin_server_payload_received_cb)(const char *service_name,
+    const plugin_peer_info_h peer_info, const plugin_payload_h payload,
+    transfer_status_e status, void *user_data);
+typedef void (*plugin_server_connection_request_cb)(const char *service_name,
+    const plugin_peer_info_h peer_info, void *user_data);
+typedef void (*plugin_server_disconnected_cb)(const char *service_name,
+    const plugin_peer_info_h peer_info, void *user_data);
+typedef void (*plugin_server_data_received_cb)(const char *service_name,
+    const plugin_peer_info_h peer_info, const unsigned char *data,
+    unsigned int data_size, unsigned char **return_data,
+    unsigned int *return_data_size, void *user_data);
+typedef bool (*plugin_server_connected_peer_info_cb)(
+    const plugin_peer_info_h peer_info, void *user_data);
+typedef void (*plugin_server_payload_async_result_cb)(
+    const plugin_payload_async_result_h result, void *user_data);
+)__c_cb";
+
+constexpr const char CB_HEADER_DEF_GROUP[] =
+R"__c_cb(
+typedef void *plugin_group_h;
+
+typedef void (*plugin_group_payload_received_cb)(const char *topic_name,
+    const plugin_peer_info_h peer_info, plugin_payload_h payload,
+    void *user_data);
+typedef void (*plugin_group_joined_cb)(const char *topic_name,
+    const plugin_peer_info_h peer_info, void *user_data);
+
+typedef void (*plugin_group_left_cb)(const char *topic_name,
+    const plugin_peer_info_h peer_info, void *user_data);
+)__c_cb";
+
+constexpr const char CB_HEADER_DEF_CLIENT[] =
+R"__c_cb(
+typedef void *plugin_client_h;
+
+typedef void (*plugin_client_server_discovered_cb)(const char *service_name,
+    const plugin_peer_info_h peer_info, void *user_data);
+typedef void (*plugin_client_connection_result_cb)(
+    const char *service_name, const plugin_peer_info_h peer_info,
+    const plugin_connection_result_h result, void *user_data);
+typedef void (*plugin_client_payload_async_result_cb)(
+    const plugin_payload_async_result_h result, void *user_data);
+typedef void (*plugin_client_payload_received_cb)(const char *service_name,
+    const plugin_peer_info_h peer_info, const plugin_payload_h payload,
+    transfer_status_e status, void *user_data);
+typedef void (*plugin_client_disconnected_cb)(const char *service_name,
+    const plugin_peer_info_h peer_info, void *user_data);
+)__c_cb";
+
+constexpr const char CB_HEADER_FUN_GROUP[] =
+R"__c_cb(
+int (*plugin_group_create)(plugin_group_h *, const char *,
+    const char *, int , const char *, const char *,
+    const char *, int);
+int (*plugin_group_destroy)(plugin_group_h);
+int (*plugin_group_subscribe)(plugin_group_h);
+int (*plugin_group_unsubscribe)(plugin_group_h);
+int (*plugin_group_publish)(plugin_group_h, plugin_payload_h);
+int (*plugin_group_add_payload_received_cb)(plugin_group_h,
+    plugin_group_payload_received_cb, void *);
+int (*plugin_group_add_joined_cb)(plugin_group_h,
+    plugin_group_joined_cb, void *);
+int (*plugin_group_add_left_cb)(plugin_group_h,
+  plugin_group_left_cb, void *);
+)__c_cb";
+
+constexpr const char CB_HEADER_FUN_CLIENT[] =
+R"__c_cb(
+int (*plugin_client_create)(plugin_client_h *, const char *,
+    const char *, int , const char *, const char *,
+    const char *, int);
+int (*plugin_client_destroy)(plugin_client_h);
+int (*plugin_client_try_discovery)(plugin_client_h,
+    plugin_client_server_discovered_cb, void *);
+int (*plugin_client_stop_discovery)(plugin_client_h);
+int (*plugin_client_connect)(plugin_client_h, const plugin_peer_info_h);
+int (*plugin_client_disconnect)(plugin_client_h);
+int (*plugin_client_send_data)(plugin_client_h, unsigned char *,
+    unsigned int, int, unsigned char **, unsigned int *);
+int (*plugin_client_send_payload_async)(plugin_client_h,
+    plugin_payload_h, plugin_client_payload_async_result_cb, void *);
+int (*plugin_client_add_connection_result_cb)(plugin_client_h,
+    plugin_client_connection_result_cb, void *);
+int (*plugin_client_add_payload_received_cb)(plugin_client_h,
+    plugin_client_payload_received_cb, void *);
+int (*plugin_client_add_disconnected_cb)(plugin_client_h,
+    plugin_client_disconnected_cb, void *);
+)__c_cb";
+
+constexpr const char CB_HEADER_FUN_SERVER[] =
+R"__c_cb(
+int (*plugin_server_create)(plugin_server_h *, const char *,
+    const char *, const char *, int ,const char *, const char *, const char *, int);
+int (*plugin_server_add_connection_result_cb)(plugin_server_h,
+    plugin_server_connection_result_cb, void *);
+int (*plugin_server_add_payload_received_cb)(plugin_server_h,
+    plugin_server_payload_received_cb, void *);
+int (*plugin_server_add_disconnected_cb)(plugin_server_h,
+    plugin_server_disconnected_cb, void *);
+int (*plugin_server_set_data_received_cb)(plugin_server_h,
+    plugin_server_data_received_cb , void *);
+int (*plugin_server_destroy)(plugin_server_h);
+int (*plugin_server_listen)(plugin_server_h,
+    plugin_server_connection_request_cb, void *);
+int (*plugin_server_foreach_connected_peer_info)(plugin_server_h,
+    plugin_server_connected_peer_info_cb, void *);
+int (*plugin_server_accept)(plugin_server_h, const plugin_peer_info_h);
+int (*plugin_server_reject)(plugin_server_h,const plugin_peer_info_h,
+    const char *);
+int (*plugin_server_set_display_name)(plugin_server_h, const char *);
+int (*plugin_server_send_payload_async)(plugin_server_h,
+    plugin_peer_info_h, plugin_payload_h,
+    plugin_server_payload_async_result_cb, void *);
+)__c_cb";
+
+constexpr const char CB_HEADER_FUN_COMMOM[] =
+R"__c_cb(
+int (*plugin_payload_create)(plugin_payload_h *, plugin_payload_type_e);
+int (*plugin_payload_destroy)(plugin_payload_h);
+int (*plugin_payload_get_type)(plugin_payload_h, plugin_payload_type_e *);
+int (*plugin_payload_get_data)(plugin_payload_h, unsigned char **, unsigned int *);
+int (*plugin_payload_set_data)(plugin_payload_h, const unsigned char *, unsigned int);
+int (*plugin_payload_save_as_file)(plugin_payload_h, const char *);
+int (*plugin_payload_get_received_file_name)(plugin_payload_h, char **);
+int (*plugin_payload_get_received_bytes)(plugin_payload_h, uint64_t *);
+int (*plugin_payload_get_total_bytes)(plugin_payload_h, uint64_t *);
+int (*plugin_payload_set_file_path)(plugin_payload_h, const char *);
+int (*plugin_payload_get_payload_id)(plugin_payload_h, char **);
+
+int (*plugin_peer_info_clone)(const plugin_peer_info_h, plugin_peer_info_h *);
+int (*plugin_peer_info_destroy)(plugin_peer_info_h);
+int (*plugin_peer_info_get_device_id)(plugin_peer_info_h, char **);
+int (*plugin_peer_info_get_device_name)(plugin_peer_info_h, char **);
+int (*plugin_peer_info_get_device_platform)(plugin_peer_info_h, char **);
+int (*plugin_peer_info_get_device_platform_version)(plugin_peer_info_h, char **);
+int (*plugin_peer_info_get_device_type)(plugin_peer_info_h, char **);
+int (*plugin_peer_info_get_app_id)(plugin_peer_info_h, char **);
+int (*plugin_peer_info_get_app_version)(plugin_peer_info_h, char **);
+int (*plugin_peer_info_get_uuid)(plugin_peer_info_h, char **);
+int (*plugin_peer_info_get_display_name)(plugin_peer_info_h, char **);
+
+int (*plugin_connection_result_get_status)(const plugin_connection_result_h, plugin_connection_status_e *);
+int (*plugin_connection_result_get_reason)(const plugin_connection_result_h, char **reason);
+)__c_cb";
+
+#endif  // IDLC_C_AITT_PLUGIN_GEN_INTERNAL_HEADER_GEN_CB_H_
diff --git a/idlc/gen_aitt_plugin/aitt_plugin_loader.cc b/idlc/gen_aitt_plugin/aitt_plugin_loader.cc
new file mode 100644 (file)
index 0000000..e1d75f2
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "idlc/gen_aitt_plugin/aitt_plugin_loader.h"
+
+#include "idlc/gen_aitt_plugin/aitt_plugin_c_transportable.h"
+#include "idlc/gen_cion/default_cpp_transportable.h"
+#include "idlc/gen_cion/default_java_transportable.h"
+#include "idlc/gen_cion/default_cs_transportable.h"
+
+namespace tidl {
+
+AIttPluginLoader::AIttPluginLoader(const std::string& plugin_path) {
+  if (plugin_path.empty()) {
+    C_.reset(new AittPluginCTransportable());
+//    Cpp_.reset(new DefaultCppTransportable());
+//    Cs_.reset(new DefaultCsTransportable());
+//    Java_.reset(new DefaultJavaTransportable());
+  } else {
+    // TODO
+  }
+}
+
+const CTransportable& AIttPluginLoader::C() {
+  return *C_;
+}
+
+const CppTransportable& AIttPluginLoader::Cpp() {
+  return *Cpp_;
+}
+
+const CsTransportable& AIttPluginLoader::Cs() {
+ return *Cs_;
+
+}
+
+const JavaTransportable& AIttPluginLoader::Java() {
+ return *Java_;
+}
+}  // namespace tidl
diff --git a/idlc/gen_aitt_plugin/aitt_plugin_loader.h b/idlc/gen_aitt_plugin/aitt_plugin_loader.h
new file mode 100644 (file)
index 0000000..75de7c4
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IDLC_GEN_AITT_PLUGIN_LOADER_H_
+#define IDLC_GEN_AITT_PLUGIN_LOADER_H_
+
+#include <memory>
+#include <string>
+
+#include "idlc/gen_cion/transportable.h"
+
+namespace tidl {
+
+class AIttPluginLoader : public Transportable {
+ public:
+  explicit AIttPluginLoader(const std::string& plugin_path);
+
+  const CTransportable& C() override;
+  const CppTransportable& Cpp() override;
+  const CsTransportable& Cs() override;
+  const JavaTransportable& Java() override;
+
+ private:
+  std::unique_ptr<CTransportable> C_;
+  std::unique_ptr<CppTransportable> Cpp_;
+  std::unique_ptr<CsTransportable> Cs_;
+  std::unique_ptr<JavaTransportable> Java_;
+};
+
+}  // namespace tidl
+
+#endif  // IDLC_GEN_AITT_PLUGIN_LOADER_H_
\ No newline at end of file
index f34b84ffaff01a6a592699dd12ed1edc9ab7c690..481a241841f00475d9cec4347c84a33872ded7e0 100644 (file)
@@ -69,21 +69,21 @@ static void __<PREFIX>_<NAME>_from(rpc_port_parcel_h parcel, void *data)
 
   if (parcel == nullptr || h == nullptr) {
     _E("Invalid parameter");
-    set_last_result(CION_ERROR_INVALID_PARAMETER);
+    set_last_result(<ERROR_PREFIX>_ERROR_INVALID_PARAMETER);
     return;
   }
 
   ret = rpc_port_parcel_read_array_count(parcel, &h->size);
   if (ret != RPC_PORT_ERROR_NONE) {
     _E("Failed to read array count. error(%d)", ret);
-    set_last_result(CION_ERROR_INVALID_PARAMETER);
+    set_last_result(<ERROR_PREFIX>_ERROR_INVALID_PARAMETER);
     return;
   }
 
   h->value = calloc(h->size, sizeof(<ELEMENT_TYPE_SIZE>));
   if (h->value == nullptr) {
     _E("Out of memory");
-    set_last_result(CION_ERROR_OUT_OF_MEMORY);
+    set_last_result(<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY);
     return;
   }
 
@@ -91,7 +91,7 @@ static void __<PREFIX>_<NAME>_from(rpc_port_parcel_h parcel, void *data)
     <PARCEL_READ>
   }
 
-  set_last_result(CION_ERROR_NONE);
+  set_last_result(<ERROR_PREFIX>_ERROR_NONE);
 }
 
 int <PREFIX>_<NAME>_create(<PREFIX>_<NAME>_h *h)
@@ -100,13 +100,13 @@ int <PREFIX>_<NAME>_create(<PREFIX>_<NAME>_h *h)
 
   if (h == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   handle = calloc(1, sizeof(<PREFIX>_<NAME>_t));
   if (handle == nullptr) {
     _E("Out of memory");
-    return CION_ERROR_OUT_OF_MEMORY;
+    return <ERROR_PREFIX>_ERROR_OUT_OF_MEMORY;
   }
 
   handle->parcelable.to = __<PREFIX>_<NAME>_to;
@@ -114,21 +114,21 @@ int <PREFIX>_<NAME>_create(<PREFIX>_<NAME>_h *h)
 
   *h = handle;
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_destroy(<PREFIX>_<NAME>_h h)
 {
   if (h == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   <ELEMENTS_FREE>
 
   free(h);
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_clone(<PREFIX>_<NAME>_h h, <PREFIX>_<NAME>_h *clone)
@@ -139,17 +139,17 @@ int <PREFIX>_<NAME>_clone(<PREFIX>_<NAME>_h h, <PREFIX>_<NAME>_h *clone)
 
   if (h == nullptr || clone == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   ret = <PREFIX>_<NAME>_create(&handle);
-  if (ret != CION_ERROR_NONE) {
+  if (ret != <ERROR_PREFIX>_ERROR_NONE) {
     _E("Failed to create handle. error(%d)", ret);
     return ret;
   }
 
   ret = rpc_port_parcel_create(&parcel);
-  if (ret != CION_ERROR_NONE) {
+  if (ret != <ERROR_PREFIX>_ERROR_NONE) {
     _E("Failed to create parcel handle. error(%d)", ret);
     <PREFIX>_<NAME>_destroy(handle);
     return ret;
@@ -160,7 +160,7 @@ int <PREFIX>_<NAME>_clone(<PREFIX>_<NAME>_h h, <PREFIX>_<NAME>_h *clone)
   ret = get_last_result();
   rpc_port_parcel_destroy(parcel);
 
-  if (ret != CION_ERROR_NONE) {
+  if (ret != <ERROR_PREFIX>_ERROR_NONE) {
     _E("Failed to read data. error(%d)", ret);
     <PREFIX>_<NAME>_destroy(handle);
     return ret;
@@ -168,7 +168,7 @@ int <PREFIX>_<NAME>_clone(<PREFIX>_<NAME>_h h, <PREFIX>_<NAME>_h *clone)
 
   *clone = handle;
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_set(<PREFIX>_<NAME>_h h, <PARAM_TYPE_IN>*value, int size)
@@ -179,11 +179,11 @@ int <PREFIX>_<NAME>_set(<PREFIX>_<NAME>_h h, <PARAM_TYPE_IN>*value, int size)
 
   if (h == nullptr || value == nullptr || size <= 0) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   ret = <PREFIX>_<NAME>_create(&handle);
-  if (ret != CION_ERROR_NONE) {
+  if (ret != <ERROR_PREFIX>_ERROR_NONE) {
     _E("Failed to create handle. error(%d)", ret);
     return ret;
   }
@@ -192,7 +192,7 @@ int <PREFIX>_<NAME>_set(<PREFIX>_<NAME>_h h, <PARAM_TYPE_IN>*value, int size)
   handle->size = size;
 
   ret = <PREFIX>_<NAME>_clone(handle, &clone);
-  if (ret != CION_ERROR_NONE) {
+  if (ret != <ERROR_PREFIX>_ERROR_NONE) {
     _E("Failed to clone handle. error(%d)", ret);
     handle->value = nullptr;
     handle->size = 0;
@@ -211,7 +211,7 @@ int <PREFIX>_<NAME>_set(<PREFIX>_<NAME>_h h, <PARAM_TYPE_IN>*value, int size)
   clone->size = 0;
   <PREFIX>_<NAME>_destroy(clone);
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_get(<PREFIX>_<NAME>_h h, <PARAM_TYPE_OUT>*value, int *size)
@@ -221,11 +221,11 @@ int <PREFIX>_<NAME>_get(<PREFIX>_<NAME>_h h, <PARAM_TYPE_OUT>*value, int *size)
 
   if (h == nullptr || value == nullptr || size == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   ret = <PREFIX>_<NAME>_clone(h, &handle);
-  if (ret != CION_ERROR_NONE) {
+  if (ret != <ERROR_PREFIX>_ERROR_NONE) {
     _E("Failed to clone handle. error(%d)", ret);
     return ret;
   }
@@ -237,7 +237,7 @@ int <PREFIX>_<NAME>_get(<PREFIX>_<NAME>_h h, <PARAM_TYPE_OUT>*value, int *size)
   handle->size = 0;
   <PREFIX>_<NAME>_destroy(handle);
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 )__c_cb";
 
@@ -271,7 +271,7 @@ rpc_port_parcel_write_<PARCEL_TYPE>(parcel, h->value[i]);
 constexpr const char CB_STRUCTURE_ARRAY_USER_DEFINED_PARCEL_READ[] =
 R"__c_cb(
 ret = <PREFIX>_<NAME>_create(&value);
-if (ret != CION_ERROR_NONE) {
+if (ret != <ERROR_PREFIX>_ERROR_NONE) {
   _E("Failed to create handle. error(%d)", ret);
   set_last_result(ret);
   return;
@@ -293,7 +293,7 @@ value = nullptr;
 rpc_port_parcel_read_bundle(parcel, &value);
 if (value == nullptr) {
   _E("Failed to read data");
-  set_last_result(CION_ERROR_OUT_OF_MEMORY);
+  set_last_result(<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY);
   return;
 }
 
@@ -306,7 +306,7 @@ value = nullptr;
 rpc_port_parcel_read_string(parcel, &value);
 if (value == nullptr) {
   _E("Failed to read data");
-  set_last_result(CION_ERROR_OUT_OF_MEMORY);
+  set_last_result(<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY);
   return;
 }
 
index bf6708715d07c473c2d73a358e588949c11ea097..1a72427e352a49c42a6338c509ba814c0c9fb072 100644 (file)
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <algorithm>
 #include <cstring>
 #include <vector>
 
@@ -24,8 +25,9 @@
 
 namespace tidl {
 
-CCionBodyGeneratorBase::CCionBodyGeneratorBase(std::shared_ptr<Document> doc)
-    : CCionGeneratorBase(doc) {
+CCionBodyGeneratorBase::CCionBodyGeneratorBase(
+    std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans)
+    : CCionGeneratorBase(doc, trans) {
   parcel_type_map_ = {
     {"none", ""},
     {"char", "byte"},
@@ -79,7 +81,9 @@ void CCionBodyGeneratorBase::GenIncludeHeader(std::ofstream& stream) {
 
 void CCionBodyGeneratorBase::GenLogTag(std::ofstream& stream,
     const std::string& log_tag) {
-  std::string code(ReplaceAll(CB_LOG_TAG, "<LOG_TAG>", log_tag));
+  std::string tag = log_tag;
+  std::transform(tag.begin(), tag.end(), tag.begin(), ::toupper);
+  std::string code(ReplaceAll(CB_LOG_TAG, "<LOG_TAG>", tag));
   stream << code;
 }
 
@@ -216,9 +220,11 @@ std::string CCionBodyGeneratorBase::GenArrayParcelRead(
         GetHandlePrefix());
     code = ReplaceAll(code, "<NAME>", GetFullNameFromType(type));
   } else if (type.ToString() == "bundle") {
-    code = std::string(CB_STRUCTURE_ARRAY_BUNDLE_PARCEL_READ);
+    code = ReplaceAll(CB_STRUCTURE_ARRAY_BUNDLE_PARCEL_READ,
+        "<ERROR_PREFIX>", GetTransportable().C().GenErrorPrefix());
   } else if (type.ToString() == "string" || type.ToString() == "file") {
-    code = std::string(CB_STRUCTURE_ARRAY_STRING_PARCEL_READ);
+    code = ReplaceAll(CB_STRUCTURE_ARRAY_STRING_PARCEL_READ,
+        "<ERROR_PREFIX>", GetTransportable().C().GenErrorPrefix());
   } else {
     code = ReplaceAll(CB_STRUCTURE_ARRAY_BASE_PARCEL_READ, "<PARCEL_TYPE>",
         GetParcelType(type));
@@ -255,28 +261,27 @@ std::string CCionBodyGeneratorBase::GenArrayElementsFree(
 // @see #CB_STRUCTURE_ARRAY_BASE
 void CCionBodyGeneratorBase::GenStructureArrayBase(std::ofstream& stream,
     const Structure& st) {
-  std::string code(ReplaceAll(CB_STRUCTURE_ARRAY_BASE, "<PREFIX>",
-      GetHandlePrefix()));
-  code = ReplaceAll(code, "<NAME>", st.GetID());
-
   auto& elm = *(st.GetElements().begin());
-  code = ReplaceAll(code, "<PARCEL_WRITE>", GenArrayParcelWrite(elm));
-  code = ReplaceAll(code, "<PARCEL_READ>", GenArrayParcelRead(elm));
-
   auto& type = elm->GetType();
-  auto param_type = GetParamTypeString(ParameterType::Direction::IN, type);
-  code = ReplaceAll(code, "<PARAM_TYPE_IN>", param_type);
-  param_type = GetParamTypeString(ParameterType::Direction::OUT, type);
-  code = ReplaceAll(code, "<PARAM_TYPE_OUT>", param_type);
-
-  auto element_type = GetDataTypeString(type, false);
-  code = ReplaceAll(code, "<ELEMENT_TYPE>", element_type);
-  auto element_type_size = GetDataTypeString(type, false);
-  element_type_size = RemoveLastSpaces(element_type_size);
-  code = ReplaceAll(code, "<ELEMENT_TYPE_SIZE>", element_type_size);
-  code = ReplaceAll(code, "<ELEMENTS_FREE>", GenArrayElementsFree(elm));
 
-  stream << SmartIndent(code);
+  ReplaceAll(CB_STRUCTURE_ARRAY_BASE)
+      .Change("<PREFIX>", GetHandlePrefix())
+      .Change("<NAME>", st.GetID())
+      .Change("<PARCEL_WRITE>", GenArrayParcelWrite(elm))
+      .Change("<PARCEL_READ>", GenArrayParcelRead(elm))
+      .Change("<PARAM_TYPE_IN>", GetParamTypeString(
+          ParameterType::Direction::IN, type))
+      .Change("<PARAM_TYPE_OUT>", GetParamTypeString(
+          ParameterType::Direction::OUT, type))
+      .Change("<ELEMENT_TYPE>", GetDataTypeString(type, false))
+      .Change("<ELEMENT_TYPE_SIZE>", RemoveLastSpaces(
+          GetDataTypeString(type, false)))
+      .Change("<ELEMENTS_FREE>", GenArrayElementsFree(elm))
+      .Change("<ERROR_PREFIX>", GetTransportable().C().GenErrorPrefix())
+      .Transform([&](std::string str) {
+        return SmartIndent(str);
+      })
+      .Out(stream);
 }
 
 // @see #CB_STRUCTURE_LIST_USER_DEFINED_FREE
@@ -404,26 +409,25 @@ std::string CCionBodyGeneratorBase::GenListCallbackParamType(
 // @see #CB_STRUCTURE_LIST_BASE
 void CCionBodyGeneratorBase::GenStructureListBase(std::ofstream& stream,
     const Structure& st) {
-  std::string code(ReplaceAll(CB_STRUCTURE_LIST_BASE, "<PREFIX>",
-      GetHandlePrefix()));
-  code = ReplaceAll(code, "<NAME>", st.GetID());
 
   auto& elm = *(st.GetElements().begin());
   auto& type = elm->GetType();
-  code = ReplaceAll(code, "<DATA_TYPE>", GetDataTypeString(type, true));
-  code = ReplaceAll(code, "<DATA_FREE>", GenListDataFree(elm));
-
-  auto param_type = GetParamTypeString(ParameterType::Direction::IN, type);
-  code = ReplaceAll(code, "<PARAM_TYPE_IN>", param_type);
-
-  code = ReplaceAll(code, "<PARCEL_WRITE>", GenListParcelWrite(elm));
-  code = ReplaceAll(code, "<PARCEL_READ>", GenListParcelRead(elm));
-
-  code = ReplaceAll(code, "<LIST_ADD>", GenListAdd(elm));
-  code = ReplaceAll(code, "<CALLBACK_PARAM_TYPE>",
-      GenListCallbackParamType(elm));
-
-  stream << SmartIndent(code);
+  ReplaceAll(CB_STRUCTURE_LIST_BASE)
+      .Change("<PREFIX>", GetHandlePrefix())
+      .Change("<NAME>", st.GetID())
+      .Change("<DATA_TYPE>", GetDataTypeString(type, true))
+      .Change("<DATA_FREE>", GenListDataFree(elm))
+      .Change("<PARAM_TYPE_IN>", GetParamTypeString(
+          ParameterType::Direction::IN, type))
+      .Change("<PARCEL_WRITE>", GenListParcelWrite(elm))
+      .Change("<PARCEL_READ>", GenListParcelRead(elm))
+      .Change("<LIST_ADD>", GenListAdd(elm))
+      .Change("<CALLBACK_PARAM_TYPE>", GenListCallbackParamType(elm))
+      .Change("<ERROR_PREFIX>", GetTransportable().C().GenErrorPrefix())
+      .Transform([&](std::string str) {
+        return SmartIndent(str);
+      })
+      .Out(stream);
 }
 
 std::string CCionBodyGeneratorBase::GenBaseElements(const Elements& elms) {
@@ -438,6 +442,18 @@ std::string CCionBodyGeneratorBase::GenBaseElements(const Elements& elms) {
   return code;
 }
 
+void CCionBodyGeneratorBase::GenCommonFuntions(std::ofstream& stream) {
+  std::string code = GetTransportable().C().GenBodyPeerInfoBase();
+  if(GetType() != 3) {
+    code += GetTransportable().C().GenBodyConnectionBase();
+    code += GetTransportable().C().GenBodyPayloadBase();
+  }
+
+  ReplaceAll(code,"<PREFIX>", GetHandlePrefix())
+      .Change("<MODULE_PREFIX>", GetMoudlePrefix())
+      .Out(stream);
+}
+
 // @see #CB_STRUCTURE_BASE_USER_DEFINED_FREE
 // @see #CB_STRUCTURE_BASE_BUNDLE_FREE
 // @see #CB_STRUCTURE_BASE_STRING_FREE
@@ -649,6 +665,9 @@ void CCionBodyGeneratorBase::GenStructureBase(std::ofstream& stream,
 
   code += GenBaseSetGet(st.GetID(), elms);
 
+  code = ReplaceAll(code, "<ERROR_PREFIX>",
+      GetTransportable().C().GenErrorPrefix());
+
   stream << SmartIndent(code);
 }
 
@@ -771,6 +790,11 @@ void CCionBodyGeneratorBase::GenFilePayloadSend(std::ofstream& stream, bool is_p
         GetTransportable().C().GenServerFileSend("value",
             "server", "peer_info"));
   }
+
+  code = ReplaceAll(code)
+             .Change("<ERROR_PREFIX>", GetTransportable().C().GenErrorPrefix())
+             .Change("<MODULE_PREFIX>", GetMoudlePrefix());
+
   stream << SmartIndent(code);
 }
 
@@ -790,8 +814,11 @@ void CCionBodyGeneratorBase::GenPrivateSharingListSet(std::ofstream& stream) {
   if (!has_list_file)
     return;
 
-  stream << SmartIndent(std::string(CB_PRIVATE_SHARING_LIST_SET));
-}
+  std::string code(ReplaceAll(CB_PRIVATE_SHARING_LIST_SET,
+      "<ERROR_PREFIX>", GetTransportable().C().GenErrorPrefix()));
+
+  stream << SmartIndent(code);
+ }
 
 // @see #CB_LIST_FILE_SET_PAYLOAD
 // @see #CB_ARRAY_FILE_SET_PRIVATE_SHARING
@@ -847,8 +874,17 @@ std::string CCionBodyGeneratorBase::GetFilePayloadFreeString(const Interface& if
 
 std::string CCionBodyGeneratorBase::GetFilePayloadSendString(const Interface& iface,
     const Declaration& decl, bool is_proxy) {
-  if (HasFile(iface, decl, is_proxy) != NotExist)
-    return is_proxy?  CB_FILE_PAYLOAD_SEND_CLIENT : CB_FILE_PAYLOAD_SEND_SERVER;
+  if (HasFile(iface, decl, is_proxy) != NotExist) {
+    std::string code;
+    if (is_proxy)
+      code = ReplaceAll(CB_FILE_PAYLOAD_SEND_CLIENT,
+                 "<MODULE_PREFIX>", GetMoudlePrefix());
+    else
+      code = ReplaceAll(CB_FILE_PAYLOAD_SEND_SERVER,
+                 "<MODULE_PREFIX>", GetMoudlePrefix());
+
+    return code;
+  }
 
   return {};
 }
index e782c8c5df4e3bf9c83278bf9f88391871dc2dc6..d4444b73c304fed7ee18b792ea445b618b995289 100644 (file)
@@ -32,7 +32,8 @@ class CCionBodyGeneratorBase : public CCionGeneratorBase {
      File,
      ArrayFile
    };
-  explicit CCionBodyGeneratorBase(std::shared_ptr<Document> doc);
+  explicit CCionBodyGeneratorBase(std::shared_ptr<Document> doc,
+      std::shared_ptr<tidl::Transportable> trans);
   virtual ~CCionBodyGeneratorBase() = default;
 
   void GenStructureDefs(std::ofstream& stream);
@@ -55,6 +56,9 @@ class CCionBodyGeneratorBase : public CCionGeneratorBase {
   std::string GetFilePayloadSendString(const Interface& iface,
       const Declaration& decl, bool is_proxy);
   std::string GenSecurityString(const Interface& iface);
+  void GenCommonFuntions(std::ofstream& stream);
+  void GenFilePayloadFuntions(std::ofstream& stream);
+
  private:
   void GenStructureDef(std::ofstream& stream, const Structure& st);
   void GenStructureBaseDef(std::ofstream& stream, const Structure& st);
index 4da6d3af7ebbc6e2f1666c098db46e9742165c51..ecd9bc58b51c3288957593833a7acbf85cc33d6b 100644 (file)
@@ -96,13 +96,13 @@ static void __<PREFIX>_<NAME>_from(rpc_port_parcel_h parcel, void *data)
 
   if (parcel == nullptr || h == nullptr) {
     _E("Invalid parameter");
-    set_last_result(CION_ERROR_INVALID_PARAMETER);
+    set_last_result(<ERROR_PREFIX>_ERROR_INVALID_PARAMETER);
     return;
   }
 
   <PARCEL_READ>
 
-  set_last_result(CION_ERROR_NONE);
+  set_last_result(<ERROR_PREFIX>_ERROR_NONE);
 }
 
 int <PREFIX>_<NAME>_create(<PREFIX>_<NAME>_h *h)
@@ -111,13 +111,13 @@ int <PREFIX>_<NAME>_create(<PREFIX>_<NAME>_h *h)
 
   if (h == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   handle = calloc(1, sizeof(<PREFIX>_<NAME>_t));
   if (handle == nullptr) {
     _E("Out of memory");
-    return CION_ERROR_OUT_OF_MEMORY;
+    return <ERROR_PREFIX>_ERROR_OUT_OF_MEMORY;
   }
 
   handle->parcelable.to = __<PREFIX>_<NAME>_to;
@@ -125,21 +125,21 @@ int <PREFIX>_<NAME>_create(<PREFIX>_<NAME>_h *h)
 
   *h = handle;
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_destroy(<PREFIX>_<NAME>_h h)
 {
   if (h == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   <ELEMENTS_FREE>
 
   free(h);
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_clone(<PREFIX>_<NAME>_h h, <PREFIX>_<NAME>_h *clone)
@@ -150,17 +150,17 @@ int <PREFIX>_<NAME>_clone(<PREFIX>_<NAME>_h h, <PREFIX>_<NAME>_h *clone)
 
   if (h == nullptr || clone == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   ret = <PREFIX>_<NAME>_create(&handle);
-  if (ret != CION_ERROR_NONE) {
+  if (ret != <ERROR_PREFIX>_ERROR_NONE) {
     _E("Failed to create handle. error(%d)", ret);
     return ret;
   }
 
   ret = rpc_port_parcel_create(&parcel);
-  if (ret != CION_ERROR_NONE) {
+  if (ret != <ERROR_PREFIX>_ERROR_NONE) {
     _E("Failed to create parcel handle. error(%d)", ret);
     <PREFIX>_<NAME>_destroy(handle);
     return ret;
@@ -171,7 +171,7 @@ int <PREFIX>_<NAME>_clone(<PREFIX>_<NAME>_h h, <PREFIX>_<NAME>_h *clone)
   ret = get_last_result();
   rpc_port_parcel_destroy(parcel);
 
-  if (ret != CION_ERROR_NONE) {
+  if (ret != <ERROR_PREFIX>_ERROR_NONE) {
     _E("Failed to read data. error(%d)", ret);
     <PREFIX>_<NAME>_destroy(handle);
     return ret;
@@ -179,7 +179,7 @@ int <PREFIX>_<NAME>_clone(<PREFIX>_<NAME>_h h, <PREFIX>_<NAME>_h *clone)
 
   *clone = handle;
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 )__c_cb";
 
@@ -248,12 +248,12 @@ R"__c_cb(
 <PREFIX>_<NAME>_create(&h-><ELEMENT_NAME>);
 if (h-><ELEMENT_NAME> == nullptr) {
   _E("Failed to create handle");
-  set_last_result(CION_ERROR_OUT_OF_MEMORY);
+  set_last_result(<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY);
   return;
 }
 
 rpc_port_parcel_read(parcel, &h-><ELEMENT_NAME>->parcelable, h-><ELEMENT_NAME>);
-if (get_last_result() != CION_ERROR_NONE) {
+if (get_last_result() != <ERROR_PREFIX>_ERROR_NONE) {
   _E("Failed to read data");
   return;
 }
@@ -267,7 +267,7 @@ R"__c_cb(
 rpc_port_parcel_read_bundle(parcel, &h-><ELEMENT_NAME>);
 if (h-><ELEMENT_NAME> == nullptr) {
   _E("Failed to read data");
-  set_last_result(CION_ERROR_OUT_OF_MEMORY);
+  set_last_result(<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY);
   return;
 }
 )__c_cb";
@@ -280,7 +280,7 @@ R"__c_cb(
 rpc_port_parcel_read_string(parcel, &h-><ELEMENT_NAME>);
 if (h-><ELEMENT_NAME> == nullptr) {
   _E("Failed to read data");
-  set_last_result(CION_ERROR_OUT_OF_MEMORY);
+  set_last_result(<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY);
   return;
 }
 )__c_cb";
@@ -337,11 +337,11 @@ int ret;
 
 if (h == nullptr || value == nullptr) {
   _E("Invalid parameter");
-  return CION_ERROR_INVALID_PARAMETER;
+  return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
 }
 
 ret = <PREFIX>_<NAME>_clone(value, &new_value);
-if (ret != CION_ERROR_NONE) {
+if (ret != <ERROR_PREFIX>_ERROR_NONE) {
   _E("Failed to clone handle. error(%d)", ret);
   return ret;
 }
@@ -350,7 +350,7 @@ if (ret != CION_ERROR_NONE) {
 
 h-><ELEMENT_NAME> = new_value;
 
-return CION_ERROR_NONE;
+return <ERROR_PREFIX>_ERROR_NONE;
 )__c_cb";
 
 /**
@@ -364,20 +364,20 @@ bundle *new_value;
 
 if (h == nullptr || value == nullptr) {
   _E("Invalid parameter");
-  return CION_ERROR_INVALID_PARAMETER;
+  return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
 }
 
 new_value = bundle_dup(value);
 if (new_value == nullptr) {
   _E("Failed to duplicate value");
-  return CION_ERROR_OUT_OF_MEMORY;
+  return <ERROR_PREFIX>_ERROR_OUT_OF_MEMORY;
 }
 
 <ELEMENT_FREE>
 
 h-><ELEMENT_NAME> = new_value;
 
-return CION_ERROR_NONE;
+return <ERROR_PREFIX>_ERROR_NONE;
 )__c_cb";
 
 /**
@@ -391,20 +391,20 @@ char *new_value;
 
 if (h == nullptr || value == nullptr) {
   _E("Invalid parameter");
-  return CION_ERROR_INVALID_PARAMETER;
+  return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
 }
 
 new_value = strdup(value);
 if (new_value == nullptr) {
   _E("Failed to duplicate value");
-  return CION_ERROR_OUT_OF_MEMORY;
+  return <ERROR_PREFIX>_ERROR_OUT_OF_MEMORY;
 }
 
 <ELEMENT_FREE>
 
 h-><ELEMENT_NAME> = new_value;
 
-return CION_ERROR_NONE;
+return <ERROR_PREFIX>_ERROR_NONE;
 )__c_cb";
 
 /**
@@ -414,12 +414,12 @@ constexpr const char CB_STRUCTURE_BASE_BASE_SET[] =
 R"__c_cb(
 if (h == nullptr) {
   _E("Invalid parameter");
-  return CION_ERROR_INVALID_PARAMETER;
+  return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
 }
 
 h-><ELEMENT_NAME> = value;
 
-return CION_ERROR_NONE;
+return <ERROR_PREFIX>_ERROR_NONE;
 )__c_cb";
 
 /**
@@ -434,23 +434,23 @@ int ret;
 
 if (h == nullptr || value == nullptr) {
   _E("Invalid parameter");
-  return CION_ERROR_INVALID_PARAMETER;
+  return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
 }
 
 if (h-><ELEMENT_NAME> == nullptr) {
   _E("<ELEMENT_NAME> is nullptr");
-  return CION_ERROR_INVALID_PARAMETER;
+  return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
 }
 
 ret = <PREFIX>_<NAME>_clone(h-><ELEMENT_NAME>, &new_value);
-if (ret != CION_ERROR_NONE) {
+if (ret != <ERROR_PREFIX>_ERROR_NONE) {
   _E("Failed to clone handle. error(%d)", ret);
   return ret;
 }
 
 *value = new_value;
 
-return CION_ERROR_NONE;
+return <ERROR_PREFIX>_ERROR_NONE;
 )__c_cb";
 
 /**
@@ -462,23 +462,23 @@ bundle *new_value;
 
 if (h == nullptr || value == nullptr) {
   _E("Invalid parameter");
-  return CION_ERROR_INVALID_PARAMETER;
+  return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
 }
 
 if (h-><ELEMENT_NAME> == nullptr) {
   _E("<ELEMENT_NAME> is nullptr");
-  return CION_ERROR_INVALID_PARAMETER;
+  return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
 }
 
 new_value = bundle_dup(h-><ELEMENT_NAME>);
 if (new_value == nullptr) {
   _E("Failed to duplicate value");
-  return CION_ERROR_OUT_OF_MEMORY;
+  return <ERROR_PREFIX>_ERROR_OUT_OF_MEMORY;
 }
 
 *value = new_value;
 
-return CION_ERROR_NONE;
+return <ERROR_PREFIX>_ERROR_NONE;
 )__c_cb";
 
 /**
@@ -490,23 +490,23 @@ char *new_value;
 
 if (h == nullptr || value == nullptr) {
   _E("Invalid parameter");
-  return CION_ERROR_INVALID_PARAMETER;
+  return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
 }
 
 if (h-><ELEMENT_NAME> == nullptr) {
   _E("<ELEMENT_NAME> is nullptr");
-  return CION_ERROR_INVALID_PARAMETER;
+  return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
 }
 
 new_value = strdup(h-><ELEMENT_NAME>);
 if (new_value == nullptr) {
   _E("Failed to duplicate value");
-  return CION_ERROR_OUT_OF_MEMORY;
+  return <ERROR_PREFIX>_ERROR_OUT_OF_MEMORY;
 }
 
 *value = new_value;
 
-return CION_ERROR_NONE;
+return <ERROR_PREFIX>_ERROR_NONE;
 )__c_cb";
 
 /**
@@ -516,31 +516,31 @@ constexpr const char CB_STRUCTURE_BASE_BASE_GET[] =
 R"__c_cb(
 if (h == nullptr || value == nullptr) {
   _E("Invalid parameter");
-  return CION_ERROR_INVALID_PARAMETER;
+  return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
 }
 
 *value = h-><ELEMENT_NAME>;
 
-return CION_ERROR_NONE;
+return <ERROR_PREFIX>_ERROR_NONE;
 )__c_cb";
 
 
 constexpr const char CB_INTERFACE_METHOD_FILE_PAYLOAD_SENDER_CLIENT_DEF[] =
-R"__c_cb(static int __cion_file_payload_send(<CLIENT_T> client, GList *list))__c_cb";
+R"__c_cb(static int __<MODULE_PREFIX>_file_payload_send(<CLIENT_T> client, GList *list))__c_cb";
 
 constexpr const char CB_INTERFACE_METHOD_FILE_PAYLOAD_SENDER_SERVER_DEF[] =
-R"__c_cb(static int __cion_file_payload_send(<SERVER_T> server, const <PEER_T> peer_info, GList *list))__c_cb";
+R"__c_cb(static int __<MODULE_PREFIX>_file_payload_send(<SERVER_T> server, const <PEER_T> peer_info, GList *list))__c_cb";
 
 constexpr const char CB_INTERFACE_METHOD_FILE_PAYLOAD_SENDER_DEF[] =
 R"__c_cb(<FILE_PAYLOAD_SENDER_DEF>
 {
   const char *value;
   GList *iter;
-  int ret = CION_ERROR_NONE;
+  int ret = <ERROR_PREFIX>_ERROR_NONE;
 
   if (g_list_length(list) == 0) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   iter = list;
@@ -568,13 +568,13 @@ static int __rpc_port_set_private_sharing_list(rpc_port_h port, GList *list)
         size = g_list_length(list);
         if (size == 0) {
                 _E("Invalid parameter");
-                return CION_ERROR_INVALID_PARAMETER;
+                return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
         }
 
         array_file = calloc(size, sizeof(const char*));
         if (array_file == nullptr) {
                 _E("Out of memory");
-                return CION_ERROR_OUT_OF_MEMORY;
+                return <ERROR_PREFIX>_ERROR_OUT_OF_MEMORY;
         }
 
         iter = list;
@@ -631,16 +631,16 @@ R"__c_cb(g_list_free(payload_files_);)__c_cb";
 
 constexpr const char CB_FILE_PAYLOAD_SEND_CLIENT[] =
 R"__c_cb(
-res_ = __cion_file_payload_send(h->client, payload_files_);
-if (res_ != CION_ERROR_NONE) {
-  _E("Failed to __cion_file_payload_send : %d", res_);
+res_ = __<MODULE_PREFIX>_file_payload_send(h->client, payload_files_);
+if (res_ != <ERROR_PREFIX>_ERROR_NONE) {
+  _E("Failed to __<MODULE_PREFIX>_file_payload_send : %d", res_);
   goto out;
 }
 )__c_cb";
 
 constexpr const char CB_FILE_PAYLOAD_SEND_SERVER[] =
 R"__c_cb(
-__cion_file_payload_send(__<NAME>.stub, peer_info, payload_files_);
+__<MODULE_PREFIX>_file_payload_send(__<NAME>.stub, peer_info, payload_files_);
 )__c_cb";
 
 
index ad33a2552f2203430193cd0dee2bc41f1aba951f..e52f1d89ba98c1f71542b55dcf9d751568ce5f24 100644 (file)
@@ -73,14 +73,14 @@ static void __<PREFIX>_<NAME>_from(rpc_port_parcel_h parcel, void *data)
 
   if (parcel == nullptr || h == nullptr) {
     _E("Invalid parameter");
-    set_last_result(CION_ERROR_INVALID_PARAMETER);
+    set_last_result(<ERROR_PREFIX>_ERROR_INVALID_PARAMETER);
     return;
   }
 
   ret = rpc_port_parcel_read_array_count(parcel, &len);
   if (ret != RPC_PORT_ERROR_NONE) {
     _E("Failed to read array count. error(%d)", ret);
-    set_last_result(CION_ERROR_INVALID_PARAMETER);
+    set_last_result(<ERROR_PREFIX>_ERROR_INVALID_PARAMETER);
     return;
   }
 
@@ -88,7 +88,7 @@ static void __<PREFIX>_<NAME>_from(rpc_port_parcel_h parcel, void *data)
     <PARCEL_READ>
   }
 
-  set_last_result(CION_ERROR_NONE);
+  set_last_result(<ERROR_PREFIX>_ERROR_NONE);
 }
 
 int <PREFIX>_<NAME>_create(<PREFIX>_<NAME>_h *h)
@@ -97,13 +97,13 @@ int <PREFIX>_<NAME>_create(<PREFIX>_<NAME>_h *h)
 
   if (h == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   handle = calloc(1, sizeof(<PREFIX>_<NAME>_t));
   if (handle == nullptr) {
     _E("Out of memory");
-    return CION_ERROR_OUT_OF_MEMORY;
+    return <ERROR_PREFIX>_ERROR_OUT_OF_MEMORY;
   }
 
   handle->parcelable.to = __<PREFIX>_<NAME>_to;
@@ -111,7 +111,7 @@ int <PREFIX>_<NAME>_create(<PREFIX>_<NAME>_h *h)
 
   *h = handle;
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_destroy(<PREFIX>_<NAME>_h h)
@@ -121,7 +121,7 @@ int <PREFIX>_<NAME>_destroy(<PREFIX>_<NAME>_h h)
 
   if (h == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   if (h->list) {
@@ -137,7 +137,7 @@ int <PREFIX>_<NAME>_destroy(<PREFIX>_<NAME>_h h)
 
   free(h);
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_clone(<PREFIX>_<NAME>_h h, <PREFIX>_<NAME>_h *clone)
@@ -148,11 +148,11 @@ int <PREFIX>_<NAME>_clone(<PREFIX>_<NAME>_h h, <PREFIX>_<NAME>_h *clone)
 
   if (h == nullptr || clone == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   ret = <PREFIX>_<NAME>_create(&handle);
-  if (ret != CION_ERROR_NONE) {
+  if (ret != <ERROR_PREFIX>_ERROR_NONE) {
     _E("Failed to create handle. error(%d)", ret);
     return ret;
   }
@@ -161,7 +161,7 @@ int <PREFIX>_<NAME>_clone(<PREFIX>_<NAME>_h h, <PREFIX>_<NAME>_h *clone)
   if (ret != RPC_PORT_ERROR_NONE) {
     _E("Failed to create parcel handle. error(%d)", ret);
     <PREFIX>_<NAME>_destroy(handle);
-    return CION_ERROR_OUT_OF_MEMORY;
+    return <ERROR_PREFIX>_ERROR_OUT_OF_MEMORY;
   }
 
   rpc_port_parcel_write(parcel, &h->parcelable, h);
@@ -169,7 +169,7 @@ int <PREFIX>_<NAME>_clone(<PREFIX>_<NAME>_h h, <PREFIX>_<NAME>_h *clone)
   ret = get_last_result();
   rpc_port_parcel_destroy(parcel);
 
-  if (ret != CION_ERROR_NONE) {
+  if (ret != <ERROR_PREFIX>_ERROR_NONE) {
     _E("Failed to read data. error(%d)", ret);
     <PREFIX>_<NAME>_destroy(handle);
     return ret;
@@ -177,7 +177,7 @@ int <PREFIX>_<NAME>_clone(<PREFIX>_<NAME>_h h, <PREFIX>_<NAME>_h *clone)
 
   *clone = handle;
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_add(<PREFIX>_<NAME>_h h, <PARAM_TYPE_IN>value)
@@ -192,7 +192,7 @@ int <PREFIX>_<NAME>_foreach(<PREFIX>_<NAME>_h h, <PREFIX>_<NAME>_cb callback, vo
 
   if (h == nullptr || callback == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   iter = h->list;
@@ -203,7 +203,7 @@ int <PREFIX>_<NAME>_foreach(<PREFIX>_<NAME>_h h, <PREFIX>_<NAME>_cb callback, vo
       break;
   }
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_remove(<PREFIX>_<NAME>_h h, unsigned int nth)
@@ -213,31 +213,31 @@ int <PREFIX>_<NAME>_remove(<PREFIX>_<NAME>_h h, unsigned int nth)
 
   if (h == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   found = g_list_nth(h->list, nth);
   if (found == nullptr)
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
 
   value = found->data;
   h->list = g_list_remove_link(h->list, found);
   <DATA_FREE>
   g_list_free(found);
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_length(<PREFIX>_<NAME>_h h, unsigned int *length)
 {
   if (h == nullptr || length == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   *length = g_list_length(h->list);
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 )__c_cb";
 
@@ -271,14 +271,14 @@ rpc_port_parcel_write_<PARCEL_TYPE>(parcel, *value);
 constexpr const char CB_STRUCTURE_LIST_USER_DEFINED_PARCEL_READ[] =
 R"__c_cb(
 ret = <PREFIX>_<NAME>_create(&value);
-if (ret != CION_ERROR_NONE) {
+if (ret != <ERROR_PREFIX>_ERROR_NONE) {
   _E("Failed to create handle. error(%d)", ret);
   set_last_result(ret);
   return;
 }
 
 rpc_port_parcel_read(parcel, &value->parcelable, value);
-if (get_last_result() != CION_ERROR_NONE) {
+if (get_last_result() != <ERROR_PREFIX>_ERROR_NONE) {
   _E("Failed to read data. error(%d)", get_last_result());
   <PREFIX>_<NAME>_destroy(value);
   return;
@@ -292,7 +292,7 @@ R"__c_cb(
 rpc_port_parcel_read_bundle(parcel, &value);
 if (value == nullptr) {
   _E("Failed to read data");
-  set_last_result(CION_ERROR_OUT_OF_MEMORY);
+  set_last_result(<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY);
   return;
 }
 
@@ -305,7 +305,7 @@ R"__c_cb(
 rpc_port_parcel_read_string(parcel, &value);
 if (value == nullptr) {
   _E("Failed to read data");
-  set_last_result(CION_ERROR_OUT_OF_MEMORY);
+  set_last_result(<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY);
   return;
 }
 
@@ -322,7 +322,7 @@ R"__c_cb(
 value = calloc(1, sizeof(sizeof(<VALUE_TYPE>)));
 if (value == nullptr) {
   _E("Out of memory");
-  set_last_result(CION_ERROR_OUT_OF_MEMORY);
+  set_last_result(<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY);
   return;
 }
 
@@ -342,16 +342,16 @@ int ret;
 
 if (h == nullptr || value == nullptr) {
   _E("Invalid parameter");
-  return CION_ERROR_INVALID_PARAMETER;
+  return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
 }
 
 ret = <PREFIX>_<NAME>_clone(value, &new_value);
-if (ret != CION_ERROR_NONE)
+if (ret != <ERROR_PREFIX>_ERROR_NONE)
   return ret;
 
 h->list = g_list_append(h->list, new_value);
 
-return CION_ERROR_NONE;
+return <ERROR_PREFIX>_ERROR_NONE;
 )__c_cb";
 
 constexpr const char CB_STRUCTURE_LIST_BUNDLE_ADD[] =
@@ -360,18 +360,18 @@ bundle *new_value;
 
 if (h == nullptr || value == nullptr) {
   _E("Invalid parameter");
-  return CION_ERROR_INVALID_PARAMETER;
+  return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
 }
 
 new_value = bundle_dup(value);
 if (new_value == nullptr) {
   _E("Failed to duplicate value");
-  return CION_ERROR_OUT_OF_MEMORY;
+  return <ERROR_PREFIX>_ERROR_OUT_OF_MEMORY;
 }
 
 h->list = g_list_append(h->list, new_value);
 
-return CION_ERROR_NONE;
+return <ERROR_PREFIX>_ERROR_NONE;
 )__c_cb";
 
 constexpr const char CB_STRUCTURE_LIST_STRING_ADD[] =
@@ -380,18 +380,18 @@ char *new_value;
 
 if (h == nullptr || value == nullptr) {
   _E("Invalid parameter");
-  return CION_ERROR_INVALID_PARAMETER;
+  return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
 }
 
 new_value = strdup(value);
 if (new_value == nullptr) {
   _E("Failed to duplicate value");
-  return CION_ERROR_OUT_OF_MEMORY;
+  return <ERROR_PREFIX>_ERROR_OUT_OF_MEMORY;
 }
 
 h->list = g_list_append(h->list, new_value);
 
-return CION_ERROR_NONE;
+return <ERROR_PREFIX>_ERROR_NONE;
 )__c_cb";
 
 /**
@@ -403,20 +403,20 @@ R"__c_cb(
 
 if (h == nullptr) {
   _E("Invalid parameter");
-  return CION_ERROR_INVALID_PARAMETER;
+  return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
 }
 
 new_value = calloc(1, sizeof(<VALUE_TYPE>));
 if (new_value == nullptr) {
   _E("Out of memory");
-  return CION_ERROR_OUT_OF_MEMORY;
+  return <ERROR_PREFIX>_ERROR_OUT_OF_MEMORY;
 }
 
 *new_value = value;
 
 h->list = g_list_append(h->list, new_value);
 
-return CION_ERROR_NONE;
+return <ERROR_PREFIX>_ERROR_NONE;
 )__c_cb";
 
 /**
index e806157815d57410eda357800fc437d6e9362927..39d219c96f58ed6441e31fb2f6f95cc5152ad8eb 100644 (file)
 
 namespace {
 #include "idlc/gen_cion/c_cion_gen_base_cb.h"
-
-constexpr const char PREFIX_CION_PROXY[] = "cion_proxy";
-constexpr const char PREFIX_CION_STUB[] = "cion_stub";
-constexpr const char PREFIX_CION_GROUP[] = "cion_group";
-
 }  // namespace
 
 namespace tidl {
 
-CCionGeneratorBase::CCionGeneratorBase(std::shared_ptr<Document> doc)
-    : CionPluginBase(std::move(doc)) {
+CCionGeneratorBase::CCionGeneratorBase(std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans)
+    : CionPluginBase(std::move(doc), trans) {
   structures_.clear();
   type_map_ = {
       {"char", "char "},
@@ -367,7 +362,9 @@ void CCionGeneratorBase::GenIncludeDefaultHeaders(std::ofstream& stream,
     str = CB_HEADER;
   }
 
-  stream << ReplaceAll(str, "<INCLUDE>", GetTransportable().C().GenInclude());
+  str = ReplaceAll(str, "<INCLUDE>", GetTransportable().C().GenInclude(body, GetType()));
+  str = ReplaceAll(str, "<PREFIX>", GetHandlePrefix());
+  stream << str;
 }
 
 void CCionGeneratorBase::GenGNUSourceDefinition(std::ofstream& stream) {
@@ -461,17 +458,26 @@ std::string CCionGeneratorBase::GetErrorValue(const BaseType& type) {
   return "-1";
 }
 
+std::string CCionGeneratorBase::GetMoudlePrefix() {
+  std::string prefix = GetTransportable().C().GenModulePrefix();
+
+  if (!HasNamespace() || !IsGeneratedAPI())
+    return prefix;
+
+  return prefix + "_" + GetFileNamespace();
+}
+
 std::string CCionGeneratorBase::GetHandlePrefix() {
   std::string prefix;
   switch(static_cast<tidl::Options::Type>(GetType())) {
   case tidl::Options::Type::TYPE_STUB:
-    prefix = PREFIX_CION_STUB;
+    prefix = GetTransportable().C().GenStubPrefix();
     break;
   case tidl::Options::Type::TYPE_PROXY:
-    prefix = PREFIX_CION_PROXY;
+    prefix = GetTransportable().C().GenProxyPrefix();
     break;
   case tidl::Options::Type::TYPE_GROUP:
-    prefix = PREFIX_CION_GROUP;
+    prefix = GetTransportable().C().GenGroupPrefix();
     break;
   default:
     break;
index 4bd0a14ad624f11f57dd9796ccf4131a78720c46..2e0a4a4ff2b31588b78dd80bcd4e4e8e16aaad0a 100644 (file)
@@ -29,7 +29,7 @@ namespace tidl {
 
 class CCionGeneratorBase : public CionPluginBase {
  public:
-  explicit CCionGeneratorBase(std::shared_ptr<Document> doc);
+  explicit CCionGeneratorBase(std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans);
   virtual ~CCionGeneratorBase() = default;
 
   std::string RemoveLine(std::string lines, unsigned int line_num = 1);
@@ -57,6 +57,7 @@ class CCionGeneratorBase : public CionPluginBase {
   void GenIncludeDefaultHeaders(std::ofstream& stream, bool body = true);
   void GenGNUSourceDefinition(std::ofstream& stream);
   std::string GetHandlePrefix();
+  std::string GetMoudlePrefix();
   std::string RemoveLastSpaces(const std::string& str);
 
  private:
index bd6aeede3bc39ec4f5c7918d5c08a99b3cc217c1..f258b77a5115483a412446e61c03e5f4e66aaab8 100644 (file)
@@ -49,8 +49,8 @@ R"__c_cb(
 #include <libgen.h>
 #include <glib.h>
 #include <dlog.h>
-<INCLUDE>
 #include <rpc-port-parcel.h>
+<INCLUDE>
 )__c_cb";
 
 #endif  // IDLC_C_CION_GEN_C_GEN_BASE_CB_H_
\ No newline at end of file
index e8bc72fe327613e011cd6646370f17a4398b7137..3ab33a9f386f56c9174e60ba07d15c07631b392a 100644 (file)
@@ -22,8 +22,8 @@
 namespace tidl {
 
 CCionGroupBodyGen::CCionGroupBodyGen(std::shared_ptr<Document> doc,
-    std::shared_ptr<Options> options)
-    : CCionBodyGeneratorBase(doc), options_(std::move(options)) {
+    std::shared_ptr<Options> options, std::shared_ptr<tidl::Transportable> trans)
+    : CCionBodyGeneratorBase(doc, trans), options_(std::move(options)) {
 }
 
 void CCionGroupBodyGen::OnInitGen(std::ofstream& stream) {
@@ -31,7 +31,7 @@ void CCionGroupBodyGen::OnInitGen(std::ofstream& stream) {
   GenGNUSourceDefinition(stream);
   GenIncludeDefaultHeaders(stream);
   GenIncludeHeader(stream);
-  GenLogTag(stream, std::string("CION_GROUP"));
+  GenLogTag(stream, GetTransportable().C().GenGroupPrefix());
   GenLogDefinition(stream);
   GenBaseDefinition(stream);
   GenInterfaceMethodHandlerType(stream);
@@ -39,6 +39,7 @@ void CCionGroupBodyGen::OnInitGen(std::ofstream& stream) {
   GenStructureDefs(stream);
   GenInterfaceDefs(stream);
   GenStructures(stream);
+  GenCommonFuntions(stream);
   GenInterfaces(stream);
 }
 
@@ -117,6 +118,8 @@ void CCionGroupBodyGen::GenInterfaceEnum(std::ofstream& stream,
 void CCionGroupBodyGen::GenInterfaceMethodHandlerType(std::ofstream& stream) {
   std::string code(ReplaceAll(CB_INTERFACE_METHOD_HANDLER_TYPE,
       "<PEER_INFO_T>", GetTransportable().C().GenPeerInfoType()));
+  code = ReplaceAll(code, "<MODULE_PREFIX>", GetMoudlePrefix());
+
   stream << SmartIndent(code);
 }
 
@@ -194,21 +197,25 @@ void CCionGroupBodyGen::GenInterfaceBase(std::ofstream& stream,
   std::string prefix = GetHandlePrefix();
   std::string name = iface.GetID();
   ReplaceAll(CB_INTERFACE_BASE)
+      .Change("<EXTRA>", GetTransportable().C().GenGroupExtra())
+      .Change("<MODULE_PREFIX>", GetMoudlePrefix())
       .Change("<GROUP_CREATE>", GetTransportable().C().GenGroupCreate())
-      .Change("<PREFIX>", prefix)
       .Change("<NAME>", name)
       .ChangeToUpper("<UPPERCASE_PREFIX>", prefix)
       .ChangeToUpper("<UPPERCASE_NAME>", name)
       .Change("<SET_SECURITY>", GenSecurityString(iface))
       .Change("<PEER_INFO_T>", GetTransportable().C().GenPeerInfoType())
       .Change("<SECURITY_T>", GetTransportable().C().GenSecurityType())
-      .Change("<PAYLOAD_T>", GetTransportable().C().GenPayloadType())
+      .Change("<PAYLOAD_T>", GetTransportable().C().GenPayloadType(true))
       .Change("<PAYLOAD_TYPE_E>", GetTransportable().C().GenPayloadTypeEnum())
       .Change("<PAYLOAD_GET_TYPE>", GetTransportable().C().GenPayloadGetType())
       .Change("<ERROR_NONE>", GetTransportable().C().GenErrorNone())
       .Change("<PAYLOAD_TYPE_DATA>", GetTransportable().C().GenPayloadTypeData())
       .Change("<PAYLOAD_GET_DATA>", GetTransportable().C().GenPayloadGetData())
       .Change("<GROUP_DESTROY>", GetTransportable().C().GenGroupDestroy())
+      .Change("<ERROR_PREFIX>", GetTransportable().C().GenErrorPrefix())
+      .Change("<MODULE_PREFIX>", GetMoudlePrefix())
+      .Change("<PREFIX>", prefix)
       .Transform([&](std::string str) {
         return SmartIndent(str);
       })
@@ -219,7 +226,6 @@ void CCionGroupBodyGen::GenInterfaceBase(std::ofstream& stream,
 void CCionGroupBodyGen::GenInterfaceMethodHandlerBase(std::ofstream& stream,
     const Interface& iface, const Declaration& decl) {
   ReplaceAll(CB_INTERFACE_METHOD_HANDLER_BASE, {
-      { "<PREFIX>", GetHandlePrefix() },
       { "<NAME>", iface.GetID() },
       { "<METHOD_NAME>", decl.GetID() },
       { "<METHOD_HANDLER_ARGS_DECL>", GenMethodHandlerArgsDecl(iface, decl) },
@@ -228,7 +234,10 @@ void CCionGroupBodyGen::GenInterfaceMethodHandlerBase(std::ofstream& stream,
       { "<METHOD_HANDLER_CALLBACK_INVOKE>",
           GenMethodHandlerCallbackInvoke(decl) },
       { "<METHOD_HANDLER_ARGS_FREE>", GenMethodHandlerArgsFree(iface, decl) },
-      { "<PEER_INFO_T>", GetTransportable().C().GenPeerInfoType() }
+      { "<ERROR_PREFIX>", GetTransportable().C().GenErrorPrefix() },
+      { "<PEER_INFO_T>", GetTransportable().C().GenPeerInfoType() },
+      { "<MODULE_PREFIX>", GetMoudlePrefix() },
+      { "<PREFIX>", GetHandlePrefix() }
   })
   .Transform([&](std::string str){
     return SmartIndent(str);
@@ -453,8 +462,10 @@ std::string CCionGroupBodyGen::GenMethodAsyncBase(const Interface& iface,
       .ChangeToUpper("<UPPERCASE_NAME>", name)
       .ChangeToUpper("<UPPERCASE_METHOD_NAME>", method_name)
       .Change("<METHOD_PARCEL_WRITE>", GenMethodParcelWrite(iface, decl))
-      .Change("<PAYLOAD_T>", GetTransportable().C().GenPayloadType())
-      .Change("<GROUP_PUBLISH>", GetTransportable().C().GenGroupPublish()));
+      .Change("<PAYLOAD_T>", GetTransportable().C().GenPayloadType(true))
+      .Change("<MODULE_PREFIX>", GetMoudlePrefix())
+      .Change("<GROUP_PUBLISH>", GetTransportable().C().GenGroupPublish())
+      .Change("<ERROR_PREFIX>", GetTransportable().C().GenErrorPrefix()));
   return code;
 }
 
index c75015b9c973ceb6e18e19e1c80b35be408e8d80..bf1922b10e06a292cf1ec85e98b97e90568f9cd9 100644 (file)
@@ -28,7 +28,7 @@ namespace tidl {
 class CCionGroupBodyGen : public CCionBodyGeneratorBase {
  public:
   explicit CCionGroupBodyGen(std::shared_ptr<Document> doc,
-      std::shared_ptr<Options> options);
+      std::shared_ptr<Options> options, std::shared_ptr<tidl::Transportable> trans);
   virtual ~CCionGroupBodyGen() = default;
 
   void OnInitGen(std::ofstream& stream) override;
index d1c8a94eaf2993b5c5af23bc94584b088d42dcb1..b48ccc14aa16f054afba20241875c6a1c9c80f6f 100644 (file)
@@ -20,7 +20,7 @@
 
 constexpr const char CB_INTERFACE_METHOD_HANDLER_TYPE[] =
 R"__c_cb(
-typedef int (*cion_group_method_handler)(const <PEER_INFO_T> peer_info, rpc_port_parcel_h parcel, void *data);
+typedef int (*_group_method_handler)(const <PEER_INFO_T> peer_info, rpc_port_parcel_h parcel, void *data);
 )__c_cb";
 
 /**
@@ -85,7 +85,7 @@ R"__c_cb(
 typedef struct <PREFIX>_<NAME>_s {
   char *topic_name;
   <GROUP_T> group;
-  <SECURITY_T> security;
+  <SECURITY_T>
   <PREFIX>_<NAME>_callback_s callback;
   GRecMutex mutex;
   void *user_data;
@@ -107,12 +107,12 @@ R"__c_cb(
 static int __<PREFIX>_<NAME>_method_<METHOD_NAME>_handler(const <PEER_INFO_T> peer_info, rpc_port_parcel_h parcel, void *user_data)
 {
   <PREFIX>_<NAME>_t *h = user_data;
-  int ret_ = CION_ERROR_NONE;
+  int ret_ = <ERROR_PREFIX>_ERROR_NONE;
 
   <METHOD_HANDLER_ARGS_DECL>
   if (h == nullptr || h->group == nullptr) {
     _E("Invalid parameter");
-    ret_ = CION_ERROR_INVALID_PARAMETER;
+    ret_ = <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
     goto out;
   }
   <METHOD_HANDLER_PARCEL_READ>
@@ -135,7 +135,7 @@ constexpr const char CB_INTERFACE_BASE[] =
 R"__c_cb(
 static int __<PREFIX>_<NAME>_process_received_event(<PREFIX>_<NAME>_t *h, const <PEER_INFO_T> peer_info, rpc_port_parcel_h parcel)
 {
-  int ret = CION_ERROR_NONE;
+  int ret = <ERROR_PREFIX>_ERROR_NONE;
   int cmd = -1;
 
   rpc_port_parcel_read_int32(parcel, &cmd);
@@ -144,7 +144,7 @@ static int __<PREFIX>_<NAME>_process_received_event(<PREFIX>_<NAME>_t *h, const
       ret = __<NAME>_method_table[cmd](peer_info, parcel, h);
   } else {
     _W("Invalid protocol. cmd(%d)", cmd);
-    ret = CION_ERROR_INVALID_PARAMETER;
+    ret = <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   return ret;
@@ -183,13 +183,13 @@ static void __<PREFIX>_<NAME>_received(const char *topic_name,
 
   <PAYLOAD_GET_TYPE>
   if (ret != <ERROR_NONE> || type != <PAYLOAD_TYPE_DATA>) {
-    _E("Faled to cion_payload_get_type : [%d][%d]", ret, type);
+    _E("Faled to <MODULE_PREFIX>_payload_get_type : [%d][%d]", ret, type);
     return;
   }
 
   <PAYLOAD_GET_DATA>
   if (ret != <ERROR_NONE>) {
-     _E("Faled to cion_payload_get_data : %d", ret);
+     _E("Faled to <MODULE_PREFIX>_payload_get_data : %d", ret);
      return;
    }
 
@@ -205,26 +205,25 @@ static void __<PREFIX>_<NAME>_received(const char *topic_name,
 
 }
 
-int <PREFIX>_<NAME>_create(const char *topic_name, <PREFIX>_<NAME>_callback_s *callback, void *user_data, <PREFIX>_<NAME>_h *h)
-{
+<EXTRA> {
   <PREFIX>_<NAME>_t *handle;
   int ret;
-  <SECURITY_T> security;
+  <SECURITY_T>
 
   if (topic_name == nullptr || callback == nullptr || h == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   if (callback->joined == nullptr || callback->left == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   handle = calloc(1, sizeof(<PREFIX>_<NAME>_t));
   if (handle == nullptr) {
     _E("Out of memory");
-    return CION_ERROR_OUT_OF_MEMORY;
+    return <ERROR_PREFIX>_ERROR_OUT_OF_MEMORY;
   }
 
   g_rec_mutex_init(&handle->mutex);
@@ -233,18 +232,18 @@ int <PREFIX>_<NAME>_create(const char *topic_name, <PREFIX>_<NAME>_callback_s *c
   if (handle->topic_name == nullptr) {
     _E("Failed to duplicate topic name");
     <PREFIX>_<NAME>_destroy(handle);
-    return CION_ERROR_OUT_OF_MEMORY;
+    return <ERROR_PREFIX>_ERROR_OUT_OF_MEMORY;
   }
   <GROUP_CREATE>
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_destroy(<PREFIX>_<NAME>_h h)
 {
   if (h == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   g_rec_mutex_lock(&h->mutex);
@@ -258,7 +257,7 @@ int <PREFIX>_<NAME>_destroy(<PREFIX>_<NAME>_h h)
 
   free(h);
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 )__c_cb";
 
@@ -286,7 +285,7 @@ void <PREFIX>_<NAME>_invoke_<METHOD_NAME>(<PREFIX>_<NAME>_h h<METHOD_PARAMS>)
 
   if (h == nullptr<METHOD_PARAMS_CHECK>) {
     _E("Invalid parameter");
-    set_last_result(CION_ERROR_INVALID_PARAMETER);
+    set_last_result(<ERROR_PREFIX>_ERROR_INVALID_PARAMETER);
     return;
   }
 
@@ -294,12 +293,12 @@ void <PREFIX>_<NAME>_invoke_<METHOD_NAME>(<PREFIX>_<NAME>_h h<METHOD_PARAMS>)
   if (h->group == nullptr) {
     _E("Not connected");
     g_rec_mutex_unlock(&h->mutex);
-    set_last_result(CION_ERROR_INVALID_PARAMETER);
+    set_last_result(<ERROR_PREFIX>_ERROR_INVALID_PARAMETER);
     return;
   }
 
   res_ = rpc_port_parcel_create(&parcel_);
-  if (res_ != CION_ERROR_NONE) {
+  if (res_ != <ERROR_PREFIX>_ERROR_NONE) {
     _E("Failed to create parcel handle. error(%d)", res_);
     g_rec_mutex_unlock(&h->mutex);
     set_last_result(res_);
@@ -367,12 +366,12 @@ R"__c_cb(
 <PREFIX>_<NAME>_create(&<ARG>);
 if (<ARG> == nullptr) {
   _E("Failed to create handle");
-  ret_ = CION_ERROR_OUT_OF_MEMORY;
+  ret_ = <ERROR_PREFIX>_ERROR_OUT_OF_MEMORY;
   goto out;
 }
 
 rpc_port_parcel_read(parcel, &<ARG>->parcelable, <ARG>);
-if (get_last_result() != CION_ERROR_NONE) {
+if (get_last_result() != <ERROR_PREFIX>_ERROR_NONE) {
   _E("Failed to read data");
   <PREFIX>_<NAME>_destroy(<ARG>);
   <ARG> = nullptr;
@@ -433,7 +432,7 @@ if (h->callback.<METHOD_NAME>)
 constexpr const char CB_INTERFACE_METHOD_DELEGATE_PARCEL_READ[] =
 R"__c_cb(
 ret_ = <PREFIX>_<NAME>_create(&<ARG>);
-if (ret_ != CION_ERROR_NONE) {
+if (ret_ != <ERROR_PREFIX>_ERROR_NONE) {
   _E("Failed to create handle. error(%d)", ret_);
   goto out;
 }
@@ -441,7 +440,7 @@ if (ret_ != CION_ERROR_NONE) {
 __<PREFIX>_<NAME>_set_peerInfo(<ARG>, peer_info);
 rpc_port_parcel_read(parcel, &<ARG>->parcelable, <ARG>);
 ret_ = get_last_result();
-if (ret_ != CION_ERROR_NONE) {
+if (ret_ != <ERROR_PREFIX>_ERROR_NONE) {
   _E("Failed to read data. error(%d)", ret_);
   goto out;
 }
@@ -462,7 +461,7 @@ if (<ARG>)
  */
 constexpr const char CB_INTERFACE_METHOD_TABLE[] =
 R"__c_cb(
-static cion_group_method_handler __<NAME>_method_table[] = {
+static _group_method_handler __<NAME>_method_table[] = {
   <METHOD_HANDLERS>
 };
 )__c_cb";
@@ -476,7 +475,7 @@ R"__c_cb(
 rpc_port_parcel_read_bundle(parcel, &<ARG>);
 if (<ARG> == nullptr) {
   _E("Failed to read data");
-  ret_ = CION_ERROR_OUT_OF_MEMORY;
+  ret_ = <ERROR_PREFIX>_ERROR_OUT_OF_MEMORY;
   goto out;
 
 }
@@ -491,7 +490,7 @@ R"__c_cb(
 rpc_port_parcel_read_string(parcel, &<ARG>);
 if (<ARG> == nullptr) {
   _E("Failed to read data");
-  ret_ = CION_ERROR_OUT_OF_MEMORY;
+  ret_ = <ERROR_PREFIX>_ERROR_OUT_OF_MEMORY;
   goto out;
 }
 )__c_cb";
index 6aaedbf60769d9c1908e8b8766cb82217a2c643c..75d346dc0dcc237dcc011f6e1f37af38124788e6 100644 (file)
@@ -22,8 +22,9 @@ namespace {
 
 namespace tidl {
 
-CCionGroupHeaderGen::CCionGroupHeaderGen(std::shared_ptr<Document> doc)
-    : CCionHeaderGeneratorBase(doc) {
+CCionGroupHeaderGen::CCionGroupHeaderGen(std::shared_ptr<Document> doc,
+    std::shared_ptr<tidl::Transportable> trans)
+    : CCionHeaderGeneratorBase(doc, trans) {
 }
 
 void CCionGroupHeaderGen::OnInitGen(std::ofstream& stream) {
@@ -31,9 +32,11 @@ void CCionGroupHeaderGen::OnInitGen(std::ofstream& stream) {
   GenPragmaOnce(stream);
   GenIncludeDefaultHeaders(stream, false);
   GenExplicitLinkageOpen(stream);
+  GenCommonHandles(stream);
   GenStructureHandles(stream);
   GenInterfaceHandles(stream);
   GenStructures(stream);
+  GenCommonBase(stream);
   GenInterfaceCallbacks(stream);
   GenInterfaces(stream);
 }
@@ -71,9 +74,10 @@ void CCionGroupHeaderGen::GenInterfaceCallbacks(std::ofstream& stream) {
 void CCionGroupHeaderGen::GenInterfaceCallbackBase(std::ofstream& stream,
     const Interface& iface) {
   ReplaceAll(CB_INTERFACE_CALLBACK_BASE)
-      .Change("<PREFIX>", GetHandlePrefix())
       .Change("<NAME>", iface.GetID())
       .Change("<PEER_INFO_T>", GetTransportable().C().GenPeerInfoType())
+      .Change("<MODULE_PREFIX>", GetMoudlePrefix())
+      .Change("<PREFIX>", GetHandlePrefix())
       .Transform([&](std::string code) {
         return SmartIndent(code);
       })
@@ -85,11 +89,12 @@ void CCionGroupHeaderGen::GenInterfaceMethodCallbackBase(std::ofstream& stream,
     const Interface& iface, const Declaration& decl) {
   ReplaceAll(CB_INTERFACE_METHOD_CALLBACK_BASE, {
       { "<RETURN_TYPE>", GetReturnTypeString(decl.GetType()) },
-      { "<PREFIX>", GetHandlePrefix() },
       { "<NAME>", iface.GetID() },
       { "<METHOD_NAME>", decl.GetID() },
       { "<METHOD_PARAMS>", GenMethodParams(iface, decl) },
-      { "<PEER_INFO_T>", GetTransportable().C().GenPeerInfoType() }
+      { "<PEER_INFO_T>", GetTransportable().C().GenPeerInfoType() },
+      { "<MODULE_PREFIX>", GetMoudlePrefix() },
+      { "<PREFIX>", GetHandlePrefix() },
   })
   .Transform([&](std::string code) {
     return SmartIndent(code);
@@ -136,9 +141,11 @@ void CCionGroupHeaderGen::GenInterface(std::ofstream& stream,
 void CCionGroupHeaderGen::GenInterfaceBase(std::ofstream& stream,
     const Interface& iface) {
   ReplaceAll(CB_INTERFACE_BASE, {
+      { "<EXTRA>", GetTransportable().C().GenGroupExtra(false) },
       { "<PREFIX>", GetHandlePrefix() },
       { "<NAME>", iface.GetID()},
-      { "<METHOD_CALLBACK_DECLS>", GenMethodCallbackDecls(iface) }
+      { "<METHOD_CALLBACK_DECLS>", GenMethodCallbackDecls(iface) },
+      { "<ERROR_PREFIX>", GetTransportable().C().GenErrorPrefix() }
   })
   .Transform([&](std::string code) {
     return SmartIndent(code);
@@ -188,7 +195,9 @@ void CCionGroupHeaderGen::GenInterfaceMethodBase(std::ofstream& stream,
       { "<PREFIX>", GetHandlePrefix() },
       { "<NAME>", iface.GetID() },
       { "<METHOD_NAME>", decl.GetID() },
-      { "<METHOD_PARAMS>", GenMethodParams(iface, decl) }
+      { "<METHOD_PARAMS>", GenMethodParams(iface, decl) },
+      { "<MODULE_PREFIX>", GetMoudlePrefix() },
+      { "<ERROR_PREFIX>", GetTransportable().C().GenErrorPrefix() }
   })
   .Transform([&](std::string code) {
     return SmartIndent(code);
index 2025b36b3321b75df6a4ee42571db196965d7feb..b12132d74a4f4baa0f98016a5199ad0b92ed2141 100644 (file)
@@ -26,7 +26,8 @@ namespace tidl {
 
 class CCionGroupHeaderGen : public CCionHeaderGeneratorBase {
  public:
-  explicit CCionGroupHeaderGen(std::shared_ptr<Document> doc);
+  explicit CCionGroupHeaderGen(std::shared_ptr<Document> doc,
+      std::shared_ptr<tidl::Transportable> trans);
   virtual ~CCionGroupHeaderGen() = default;
 
   void OnInitGen(std::ofstream& stream) override;
index 6dfbc520bbad0481f99941344170004a95b30b4a..4b31a8d8641f6057c45928e6cd243c759d3596f3 100644 (file)
@@ -39,10 +39,10 @@ R"__c_cb(
  * @brief Called when a peer joins a topic.
  *
  * @param[in] h The <PREFIX>_<NAME> handle
- * @param[in] peer_info The Cion peer information handle \n
+ * @param[in] peer_info The <MODULE_PREFIX> peer information handle \n
  *            The @a peer_info can be used only in the callback. To use outside, make a copy.
  * @param[in] user_data The user data
- * @see cion_peer_info_clone()
+ * @see <MODULE_PREFIX>_peer_info_clone()
  * @see #<PREFIX>_<NAME>_callback_s
  */
 typedef void (*<PREFIX>_<NAME>_joined_cb)(<PREFIX>_<NAME>_h h,
@@ -52,10 +52,10 @@ typedef void (*<PREFIX>_<NAME>_joined_cb)(<PREFIX>_<NAME>_h h,
  * @brief Called when a peer leaves a topic.
  *
  * @param[in] h The <PREFIX>_<NAME> handle
- * @param[in] peer_info The Cion peer information handle \n
+ * @param[in] peer_info The <MODULE_PREFIX> peer information handle \n
  *            The @a peer_info can be used only in the callback. To use outside, make a copy.
  * @param[in] user_data The user data
- * @see cion_peer_info_clone()
+ * @see <MODULE_PREFIX>_peer_info_clone()
  * @see #<PREFIX>_<NAME>_callback_s
  */
 typedef void (*<PREFIX>_<NAME>_left_cb)(<PREFIX>_<NAME>_h h,
@@ -83,30 +83,7 @@ typedef struct {
   <METHOD_CALLBACK_DECLS>
 } <PREFIX>_<NAME>_callback_s;
 
-/**
- * @brief Creates a <PREFIX>_<NAME> handle.
- * @remarks The @a h handle should be released using
- *          the <PREFIX>_<NAME>_destroy() if it's no longer needed.
- *
- * @privilege %http://tizen.org/privilege/d2d.datasharing
- *            %http://tizen.org/privilege/internet
- *
- * @param[in] topic_name topic_name The name of topic
- * @param[in] callback The set of callback functions to handle events
- * @param[in] user_data The user data to be passed to the callback function
- * @param[out] h The <PREFIX>_<NAME> handle
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_NOT_SUPPORTED Not supported
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CION_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #CION_ERROR_PERMISSION_DENIED Permission denied
-
- * @see <PREFIX>_<NAME>_destroy()
- * @see #<PREFIX>_<NAME>_callback_s
- */
-int <PREFIX>_<NAME>_create(const char *topic_name, <PREFIX>_<NAME>_callback_s *callback, void *user_data, <PREFIX>_<NAME>_h *h);
+<EXTRA>
 
 /**
  * @brief Destroys the <PREFIX>_<NAME> handle.
@@ -114,8 +91,8 @@ int <PREFIX>_<NAME>_create(const char *topic_name, <PREFIX>_<NAME>_callback_s *c
  * @param[in] h The <PREFIX>_<NAME> handle
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
  * @see <PREFIX>_<NAME>_create()
  */
 int <PREFIX>_<NAME>_destroy(<PREFIX>_<NAME>_h h);
@@ -134,11 +111,11 @@ R"__c_cb(
 /**
  * @brief Called when the payload is received.
  *
- * @param[in] peer_info  The Cion peer information handle \n
+ * @param[in] peer_info  The <MODULE_PREFIX> peer information handle \n
  *            The @a peer_info can be used only in the callback. To use outside, make a copy.
  * @param[in] ...
  * @param[in] user_data The user data passed from the registration function
- * @see cion_peer_info_clone()
+ * @see <MODULE_PREFIX>_peer_info_clone()
  * @see #<PREFIX>_<NAME>_callback_s;
  */
 typedef <RETURN_TYPE> (*<PREFIX>_<NAME>_<METHOD_NAME>_cb)(const <PEER_INFO_T> peer_info<METHOD_PARAMS>, void *user_data);
@@ -171,10 +148,10 @@ R"__c_cb(
  * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section.
  * @param[in] h The <PREFIX>_<NAME> handle
  * @param[in] ...
- * @exception #CION_ERROR_NONE Successful
- * @exception #CION_ERROR_INVALID_PARAMETER Invalid parameter
- * @exception #CION_ERROR_OUT_OF_MEMORY Out of memory
- * @exception #CION_ERROR_IO_ERROR I/O error
+ * @exception #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @exception #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception #<ERROR_PREFIX>_ERROR_IO_ERROR I/O error
  */
 <RETURN_TYPE><PREFIX>_<NAME>_invoke_<METHOD_NAME>(<PREFIX>_<NAME>_h h<METHOD_PARAMS>);
 )__c_cb";
index 8bbbd07ac8f2d6a1454eb2d267d4715593a5ac12..23fa60909388ed0d25b18bcd27cf4f0d99964dfa 100644 (file)
@@ -26,8 +26,8 @@ namespace {
 
 namespace tidl {
 
-CCionHeaderGeneratorBase::CCionHeaderGeneratorBase(std::shared_ptr<Document> doc)
-    : CCionGeneratorBase(doc) {
+CCionHeaderGeneratorBase::CCionHeaderGeneratorBase(std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans)
+    : CCionGeneratorBase(doc, trans) {
   for (auto& b : GetDocument().GetBlocks()) {
     if (b->GetType() == Block::TYPE_STRUCTURE) {
       auto& st = static_cast<const Structure&>(*b);
@@ -70,6 +70,49 @@ void CCionHeaderGeneratorBase::GenExplicitLinkageClose(std::ofstream& stream) {
   stream << CB_EXPLICIT_LINKAGE_CLOSE;
 }
 
+void CCionHeaderGeneratorBase::GenCommonHandles(std::ofstream& stream) {
+  ReplaceAll(GetTransportable().C().GenHeaderCommonHandle())
+      .Change("<PREFIX>", GetHandlePrefix())
+      .Change("<MODULE_PREFIX>", GetMoudlePrefix())
+      .Out(stream);
+}
+
+void CCionHeaderGeneratorBase::GenFileHandle(std::ofstream& stream) {
+  ReplaceAll(GetTransportable().C().GenHeaderPayloadHandle())
+      .Change("<ERROR_PREFIX>", GetTransportable().C().GenErrorPrefix())
+      .Change("<PREFIX>", GetHandlePrefix())
+      .Change("<MODULE_PREFIX>", GetMoudlePrefix())
+      .Out(stream);
+}
+
+void CCionHeaderGeneratorBase::GenFileBase(std::ofstream& stream) {
+  ReplaceAll(GetTransportable().C().GenHeaderPayloadBase())
+      .Change("<PREFIX>", GetHandlePrefix())
+      .Change("<MODULE_PREFIX>", GetMoudlePrefix())
+      .Out(stream);
+}
+
+void CCionHeaderGeneratorBase::GenConnectionHandle(std::ofstream& stream) {
+  ReplaceAll(GetTransportable().C().GenHeaderConnectionHandle())
+      .Change("<PREFIX>", GetHandlePrefix())
+      .Change("<MODULE_PREFIX>", GetMoudlePrefix())
+      .Out(stream);
+}
+
+void CCionHeaderGeneratorBase::GenConnectionBase(std::ofstream& stream) {
+  ReplaceAll(GetTransportable().C().GenHeaderConnectionBase())
+      .Change("<PREFIX>", GetHandlePrefix())
+      .Change("<MODULE_PREFIX>", GetMoudlePrefix())
+      .Out(stream);
+}
+
+void CCionHeaderGeneratorBase::GenCommonBase(std::ofstream& stream) {
+  ReplaceAll(GetTransportable().C().GenHeaderBase())
+      .Change("<PREFIX>", GetHandlePrefix())
+      .Change("<MODULE_PREFIX>", GetMoudlePrefix())
+      .Out(stream);
+}
+
 void CCionHeaderGeneratorBase::GenStructureHandles(std::ofstream& stream) {
   for (auto& b : GetDocument().GetBlocks()) {
     if (b->GetType() == Block::TYPE_STRUCTURE) {
@@ -123,6 +166,7 @@ void CCionHeaderGeneratorBase::GenStructureArrayBase(std::ofstream& stream,
           GetParamTypeString(ParameterType::Direction::IN, type))
       .Change("<PARAM_TYPE_OUT>",
           GetParamTypeString(ParameterType::Direction::OUT, type))
+      .Change("<ERROR_PREFIX>", GetTransportable().C().GenErrorPrefix())
       .Transform([&](std::string str) {
         return SmartIndent(str);
       })
@@ -140,6 +184,7 @@ void CCionHeaderGeneratorBase::GenStructureListBase(std::ofstream& stream,
       .Change("<NAME>", st.GetID())
       .Change("<PARAM_TYPE_IN>",
           GetParamTypeString(ParameterType::Direction::IN, type))
+      .Change("<ERROR_PREFIX>", GetTransportable().C().GenErrorPrefix())
       .Transform([&](std::string str) {
         return SmartIndent(str);
       })
@@ -152,6 +197,7 @@ void CCionHeaderGeneratorBase::GenStructureBase(std::ofstream& stream,
   ReplaceAll(CB_STRUCTURE_BASE)
       .Change("<PREFIX>", GetHandlePrefix())
       .Change("<NAME>", st.GetID())
+      .Change("<ERROR_PREFIX>", GetTransportable().C().GenErrorPrefix())
       .Transform([&](std::string str) {
         return SmartIndent(str);
       })
@@ -168,6 +214,7 @@ void CCionHeaderGeneratorBase::GenStructureBase(std::ofstream& stream,
         .Change("<PARAM_TYPE_OUT>",
             GetParamTypeString(ParameterType::Direction::OUT, type))
         .Change("<ELEMENT_NAME>", e->GetID())
+        .Change("<ERROR_PREFIX>", GetTransportable().C().GenErrorPrefix())
         .Transform([&](std::string str) {
           return SmartIndent(str);
         })
index 9724d469ef128842a2ed347605f97e00503b289f..0bdef42e9658332d66c09df892f433515731b1e7 100644 (file)
@@ -27,7 +27,7 @@ namespace tidl {
 
 class CCionHeaderGeneratorBase : public CCionGeneratorBase {
  public:
-  explicit CCionHeaderGeneratorBase(std::shared_ptr<Document> doc);
+  explicit CCionHeaderGeneratorBase(std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans);
   virtual ~CCionHeaderGeneratorBase() = default;
 
   void GenPragmaOnce(std::ofstream& stream);
@@ -35,6 +35,12 @@ class CCionHeaderGeneratorBase : public CCionGeneratorBase {
   void GenExplicitLinkageClose(std::ofstream& stream);
   void GenStructureHandles(std::ofstream& stream);
   void GenStructures(std::ofstream& stream);
+  void GenCommonHandles(std::ofstream& stream);
+  void GenCommonBase(std::ofstream& stream);
+  void GenFileHandle(std::ofstream& stream);
+  void GenFileBase(std::ofstream& stream);
+  void GenConnectionHandle(std::ofstream& stream);
+  void GenConnectionBase(std::ofstream& stream);
 
  private:
   void GenStructureHandle(std::ofstream& stream, const Structure& st);
index 690b2311df38e6949d6f26a92c50cfb5658279dd..1c1cd824a4f48e1448b0e68cba5e491bfe1590db 100644 (file)
@@ -60,9 +60,9 @@ R"__c_cb(
  * @param[out] h The <PREFIX>_<NAME> handle that is newly created
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY Out of memory
  * @see <PREFIX>_<NAME>_destroy()
  */
 int <PREFIX>_<NAME>_create(<PREFIX>_<NAME>_h *h);
@@ -73,8 +73,8 @@ int <PREFIX>_<NAME>_create(<PREFIX>_<NAME>_h *h);
  * @param[in] h The <PREFIX>_<NAME> handle
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
  * @see <PREFIX>_<NAME>_create()
  */
 int <PREFIX>_<NAME>_destroy(<PREFIX>_<NAME>_h h);
@@ -88,9 +88,9 @@ int <PREFIX>_<NAME>_destroy(<PREFIX>_<NAME>_h h);
  * @param[out] clone If successful, a new created <PREFIX>_<NAME> handle will be returned
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY Out of memory
  * @see <PREFIX>_<NAME>_destroy()
  */
 int <PREFIX>_<NAME>_clone(<PREFIX>_<NAME>_h h, <PREFIX>_<NAME>_h *clone);
@@ -105,9 +105,9 @@ int <PREFIX>_<NAME>_clone(<PREFIX>_<NAME>_h h, <PREFIX>_<NAME>_h *clone);
  * @param[in] size The size of the array
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY Out of memory
  * @see <PREFIX>_<NAME>_get()
  */
 int <PREFIX>_<NAME>_set(<PREFIX>_<NAME>_h h, <PARAM_TYPE_IN>*value, int size);
@@ -121,9 +121,9 @@ int <PREFIX>_<NAME>_set(<PREFIX>_<NAME>_h h, <PARAM_TYPE_IN>*value, int size);
  * @param[out] size The size of the array
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY Out of memory
  * @see <PREFIX>_<NAME>_set()
  */
 int <PREFIX>_<NAME>_get(<PREFIX>_<NAME>_h h, <PARAM_TYPE_OUT>*value, int *size);
@@ -156,9 +156,9 @@ typedef bool (*<PREFIX>_<NAME>_cb)(<PARAM_TYPE_IN>value, void *user_data);
  * @param[out] h The <PREFIX>_<NAME> handle that is newly created
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY Out of memory
  * @see <PREFIX>_<NAME>_destroy()
  */
 int <PREFIX>_<NAME>_create(<PREFIX>_<NAME>_h *h);
@@ -169,8 +169,8 @@ int <PREFIX>_<NAME>_create(<PREFIX>_<NAME>_h *h);
  * @param[in] The <PREFIX>_<NAME> handle
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
  * @see <PREFIX>_<NAME>_create()
  */
 int <PREFIX>_<NAME>_destroy(<PREFIX>_<NAME>_h h);
@@ -184,9 +184,9 @@ int <PREFIX>_<NAME>_destroy(<PREFIX>_<NAME>_h h);
  * @param[out] clone If successful, a new created <PREFIX>_<NAME> handle will be returned
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY Out of memory
  * @see <PREFIX>_<NAME>_destroy()
  */
 int <PREFIX>_<NAME>_clone(<PREFIX>_<NAME>_h h, <PREFIX>_<NAME>_h *clone);
@@ -200,9 +200,9 @@ int <PREFIX>_<NAME>_clone(<PREFIX>_<NAME>_h h, <PREFIX>_<NAME>_h *clone);
  * @param[in] value The value
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY Out of memory
  * @see <PREFIX>_<NAME>_remove()
  */
 int <PREFIX>_<NAME>_add(<PREFIX>_<NAME>_h h, <PARAM_TYPE_IN>value);
@@ -217,8 +217,8 @@ int <PREFIX>_<NAME>_add(<PREFIX>_<NAME>_h h, <PARAM_TYPE_IN>value);
  * @param[in] user_data The user data to be passed to the callback function
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
  * @see <PREFIX>_<NAME>_cb()
  */
 int <PREFIX>_<NAME>_foreach(<PREFIX>_<NAME>_h h, <PREFIX>_<NAME>_cb callback, void *user_data);
@@ -230,8 +230,8 @@ int <PREFIX>_<NAME>_foreach(<PREFIX>_<NAME>_h h, <PREFIX>_<NAME>_cb callback, vo
  * @param[in] nth The position of the element
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
  */
 int <PREFIX>_<NAME>_remove(<PREFIX>_<NAME>_h h, unsigned int nth);
 
@@ -242,8 +242,8 @@ int <PREFIX>_<NAME>_remove(<PREFIX>_<NAME>_h h, unsigned int nth);
  * @param[out] length The number of elements
  * @return @c on 0 success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
  */
 int <PREFIX>_<NAME>_length(<PREFIX>_<NAME>_h h, unsigned int *length);
 )__c_cb";
@@ -262,9 +262,9 @@ R"__c_cb(
  * @param[out] h The <PREFIX>_<NAME> handle that is newly created
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMTER Invaid parameter
- * @retval #CION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMTER Invaid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY Out of memory
  * @see <PREFIX>_<NAME>_destroy()
  */
 int <PREFIX>_<NAME>_create(<PREFIX>_<NAME>_h *h);
@@ -275,9 +275,9 @@ int <PREFIX>_<NAME>_create(<PREFIX>_<NAME>_h *h);
  * @param[in] h The <PREFIX>_<NAME> handle
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY Out of memory
  * @see <PREFIX>_<NAME>_create()
  */
 int <PREFIX>_<NAME>_destroy(<PREFIX>_<NAME>_h h);
@@ -291,9 +291,9 @@ int <PREFIX>_<NAME>_destroy(<PREFIX>_<NAME>_h h);
  * @param[out] clone If successful, a new created <PREFIX>_<NAME> handle will be returned
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY Out of memory
  * @see <PREFIX>_<NAME>_destroy()
  */
 int <PREFIX>_<NAME>_clone(<PREFIX>_<NAME>_h h, <PREFIX>_<NAME>_h *clone);
@@ -317,9 +317,9 @@ R"__c_cb(
  * @param[in] value The <ELEMENT_NAME>
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY Out of memory
  * @see <PREFIX>_<NAME>_get_<ELEMENT_NAME>()
  */
 int <PREFIX>_<NAME>_set_<ELEMENT_NAME>(<PREFIX>_<NAME>_h h, <PARAM_TYPE_IN>value);
@@ -332,9 +332,9 @@ int <PREFIX>_<NAME>_set_<ELEMENT_NAME>(<PREFIX>_<NAME>_h h, <PARAM_TYPE_IN>value
  * @param[out] value The <ELEMENT_NAME>
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY Out of memory
  * @see <PREFIX>_<NAME>_set_<ELEMENT_NAME>
  */
 int <PREFIX>_<NAME>_get_<ELEMENT_NAME>(<PREFIX>_<NAME>_h h, <PARAM_TYPE_OUT>value);
index d11de20119fc9533edee57ee8890335c54cf25cb..346d0abc64a20ca3d621482c458860f6672f4f91 100644 (file)
@@ -22,8 +22,8 @@
 namespace tidl {
 
 CCionProxyBodyGen::CCionProxyBodyGen(std::shared_ptr<Document> doc,
-    std::shared_ptr<Options> options)
-    : CCionBodyGeneratorBase(doc), options_(std::move(options)) {
+    std::shared_ptr<Options> options, std::shared_ptr<tidl::Transportable> trans)
+    : CCionBodyGeneratorBase(doc, trans), options_(std::move(options)) {
 }
 
 void CCionProxyBodyGen::OnInitGen(std::ofstream& stream) {
@@ -31,7 +31,7 @@ void CCionProxyBodyGen::OnInitGen(std::ofstream& stream) {
   GenGNUSourceDefinition(stream);
   GenIncludeDefaultHeaders(stream);
   GenIncludeHeader(stream);
-  GenLogTag(stream, std::string("CION_PROXY"));
+  GenLogTag(stream, GetTransportable().C().GenProxyPrefix());
   GenLogDefinition(stream);
   GenBaseDefinition(stream);
   GenInterfaceDelegateCallback(stream);
@@ -39,6 +39,7 @@ void CCionProxyBodyGen::OnInitGen(std::ofstream& stream) {
   GenInterfaceDefs(stream);
   GenFilePayloadSend(stream, true);
   GenStructures(stream);
+  GenCommonFuntions(stream);
   GenInterfaces(stream);
 }
 
@@ -95,6 +96,7 @@ void CCionProxyBodyGen::GenInterfaceBaseDef(std::ofstream& stream,
       { "<NAME>", iface.GetID() },
       { "<PEER_INFO_T>", GetTransportable().C().GenPeerInfoType() },
       { "<CLIENT_T>", GetTransportable().C().GenClientType() },
+      { "<MODULE_PREFIX>", GetMoudlePrefix() },
       { "<SECURITY_T>", GetTransportable().C().GenSecurityType() }
   })
   .Transform([&](std::string code) {
@@ -151,7 +153,7 @@ void CCionProxyBodyGen::GenInterfaceBase(std::ofstream& stream,
       .Change("<CLIENT_STOP_DISCOVERY>",
           GetTransportable().C().GenClientStopDiscovery("h->client"))
       .Change("<CLIENT_CREATE>", GetTransportable().C().GenClientCreate())
-      .Change("<PREFIX>", prefix)
+      .Change("<EXTRA>", GetTransportable().C().GenClientExtra())
       .Change("<NAME>", name)
       .ChangeToUpper("<UPPERCASE_PREFIX>", prefix)
       .ChangeToUpper("<UPPERCASE_NAME>", name)
@@ -159,7 +161,7 @@ void CCionProxyBodyGen::GenInterfaceBase(std::ofstream& stream,
       .Change("<PEER_INFO_T>", GetTransportable().C().GenPeerInfoType())
       .Change("<PAYLOAD_T>", GetTransportable().C().GenPayloadType())
       .Change("<PAYLOAD_TRANSFER_STATUS_T>",
-          GetTransportable().C().GenPayloadTransferStatusType())
+          GetTransportable().C().GenPayloadTransferStatusType(true))
       .Change("<SECURITY_T>", GetTransportable().C().GenSecurityType())
       .Change("<PAYLOAD_TYPE_E>", GetTransportable().C().GenPayloadTypeEnum())
       .Change("<PAYLOAD_GET_TYPE>", GetTransportable().C().GenPayloadGetType())
@@ -168,6 +170,9 @@ void CCionProxyBodyGen::GenInterfaceBase(std::ofstream& stream,
       .Change("<PAYLOAD_TYPE_FILE>", GetTransportable().C().GenPayloadTypeFile())
       .Change("<PAYLOAD_GET_DATA>", GetTransportable().C().GenPayloadGetData())
       .Change("<CLIENT_DESTROY>", GetTransportable().C().GenClientDestroy())
+      .Change("<ERROR_PREFIX>", GetTransportable().C().GenErrorPrefix())
+      .Change("<MODULE_PREFIX>", GetMoudlePrefix())
+      .Change("<PREFIX>", prefix)
       .Transform([&](std::string code) {
         return SmartIndent(code);
       })
@@ -322,6 +327,7 @@ void CCionProxyBodyGen::GenInterfaceDelegateBase(std::ofstream& stream,
       .Change("<DELEGATE_ARGS_FREE>", delegate_args_free)
       .Change("<DELEGATE_CALLBACK_ARGS>", GenDelegateCallbackArgs(decl))
       .Change("<GOTO_STATEMENT>", has_free ? "out:" + NLine(1) : "")
+      .Change("<ERROR_PREFIX>", GetTransportable().C().GenErrorPrefix())
       .Transform([&](std::string code) {
         return SmartIndent(code);
       })
@@ -521,7 +527,9 @@ std::string CCionProxyBodyGen::GenMethodAsyncBase(const Interface& iface,
       .Change("<PAYLOAD_T>", GetTransportable().C().GenPayloadType())
       .Change("<CLIENT_SEND_ASYNC>",
           GetTransportable().C().GenClientSendAsync(
-              "h->client", "pl_", "data_size_")));
+              "h->client", "pl_", "data_size_"))
+      .Change("<MODULE_PREFIX>", GetMoudlePrefix())
+      .Change("<ERROR_PREFIX>", GetTransportable().C().GenErrorPrefix()));
 
   return code;
 }
@@ -625,7 +633,9 @@ std::string CCionProxyBodyGen::GenMethodBase(const Interface& iface,
           decl))
       .Change("<CLIENT_SEND>", GetTransportable().C().GenClientSend(
           "h->client", "data_", "data_size_",
-          "return_data_", "return_data_size_")));
+          "return_data_", "return_data_size_"))
+      .Change("<MODULE_PREFIX>", GetMoudlePrefix())
+      .Change("<ERROR_PREFIX>", GetTransportable().C().GenErrorPrefix()));
   return code;
 }
 
index f1a9b006cbee089553740230467d6cec1cb3fe49..c70a4cc30ed7f8593b89a26230d7e0251889f4b1 100644 (file)
@@ -28,7 +28,7 @@ namespace tidl {
 class CCionProxyBodyGen : public CCionBodyGeneratorBase {
  public:
   explicit CCionProxyBodyGen(std::shared_ptr<Document> doc,
-      std::shared_ptr<Options> options);
+      std::shared_ptr<Options> options, std::shared_ptr<tidl::Transportable> trans);
   virtual ~CCionProxyBodyGen() = default;
 
   void OnInitGen(std::ofstream& stream) override;
index 40f6fa1cb10dca2ec99891d37f441e4f98b77f41..68513c74808a145b9678cac10688c2943c882781 100644 (file)
@@ -19,7 +19,7 @@
 
 constexpr const char CB_INTERFACE_DELEGATE_CALLBACK[] =
 R"__c_cb(
-typedef void (*cion_proxy_delegate_cb)(GList **delegates, rpc_port_parcel_h parcel, int id, int seq_id);
+typedef void (*_proxy_delegate_cb)(GList **delegates, rpc_port_parcel_h parcel, int id, int seq_id);
 )__c_cb";
 
 /**
@@ -88,7 +88,7 @@ static void __<PREFIX>_<NAME>_<DELEGATE_NAME>_from(rpc_port_parcel_h parcel, voi
 
   if (parcel == nullptr || h == nullptr) {
     _E("Invalid parameter");
-    set_last_result(CION_ERROR_INVALID_PARAMETER);
+    set_last_result(<ERROR_PREFIX>_ERROR_INVALID_PARAMETER);
     return;
   }
 
@@ -99,7 +99,7 @@ static void __<PREFIX>_<NAME>_<DELEGATE_NAME>_from(rpc_port_parcel_h parcel, voi
   rpc_port_parcel_read_bool(parcel, &h->once);
 
   _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false");
-  set_last_result(CION_ERROR_NONE);
+  set_last_result(<ERROR_PREFIX>_ERROR_NONE);
 }
 
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_create(<PREFIX>_<NAME>_<DELEGATE_NAME>_h *h)
@@ -109,13 +109,13 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_create(<PREFIX>_<NAME>_<DELEGATE_NAME>_h *h)
 
   if (h == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   handle = calloc(1, sizeof(<PREFIX>_<NAME>_<DELEGATE_NAME>_t));
   if (handle == nullptr) {
     _E("Out of memory");
-    return CION_ERROR_OUT_OF_MEMORY;
+    return <ERROR_PREFIX>_ERROR_OUT_OF_MEMORY;
   }
 
   handle->parcelable.to = __<PREFIX>_<NAME>_<DELEGATE_NAME>_to;
@@ -126,21 +126,21 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_create(<PREFIX>_<NAME>_<DELEGATE_NAME>_h *h)
 
   *h = handle;
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_destroy(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h)
 {
   if (h == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   _W("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false");
 
   free(h);
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_clone(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, <PREFIX>_<NAME>_<DELEGATE_NAME>_h *clone)
@@ -151,17 +151,17 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_clone(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, <
 
   if (h == nullptr || clone == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   ret = <PREFIX>_<NAME>_<DELEGATE_NAME>_create(&handle);
-  if (ret != CION_ERROR_NONE) {
+  if (ret != <ERROR_PREFIX>_ERROR_NONE) {
     _E("Failed to create handle. error(%d)", ret);
     return ret;
   }
 
   ret = rpc_port_parcel_create(&parcel);
-  if (ret != CION_ERROR_NONE) {
+  if (ret != <ERROR_PREFIX>_ERROR_NONE) {
     _E("Failed to create parcel handle. error(%d)", ret);
     <PREFIX>_<NAME>_<DELEGATE_NAME>_destroy(handle);
     return ret;
@@ -172,7 +172,7 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_clone(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, <
   ret = get_last_result();
   rpc_port_parcel_destroy(parcel);
 
-  if (ret != CION_ERROR_NONE) {
+  if (ret != <ERROR_PREFIX>_ERROR_NONE) {
     _E("Failed to read data. error(%d)", ret);
     <PREFIX>_<NAME>_<DELEGATE_NAME>_destroy(handle);
     return ret;
@@ -183,68 +183,68 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_clone(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, <
 
   *clone = handle;
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_set_callback(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, <PREFIX>_<NAME>_<DELEGATE_NAME>_cb callback, void *user_data)
 {
   if (h == nullptr || callback == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   h->callback = callback;
   h->user_data = user_data;
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_set_once(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, bool once)
 {
   if (h == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   h->once = once;
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_get_id(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, int *id)
 {
   if (h == nullptr || id == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   *id = h->id;
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_get_seq_id(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, int *seq_id)
 {
   if (h == nullptr || seq_id == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   *seq_id = h->seq_id;
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_is_once(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, bool *once)
 {
   if (h == nullptr || once == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   *once = h->once;
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_get_tag(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, char **tag)
@@ -254,19 +254,19 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_get_tag(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h,
 
   if (h == nullptr || tag == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   snprintf(buf, sizeof(buf), "%d::%d", h->id, h->seq_id);
   new_tag = strdup(buf);
   if (new_tag == nullptr) {
     _E("Out of memory");
-    return CION_ERROR_OUT_OF_MEMORY;
+    return <ERROR_PREFIX>_ERROR_OUT_OF_MEMORY;
   }
 
   *tag = new_tag;
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_dispose(<PREFIX>_<NAME>_h proxy, <PREFIX>_<NAME>_<DELEGATE_NAME>_h h)
@@ -275,20 +275,20 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_dispose(<PREFIX>_<NAME>_h proxy, <PREFIX>_<N
 
   if (proxy == nullptr || h == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   found = g_list_find(proxy->delegates, h);
   if (found == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   proxy->delegates = g_list_remove_link(proxy->delegates, found);
   <PREFIX>_<NAME>_<DELEGATE_NAME>_destroy(h);
   g_list_free(found);
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 static void __<PREFIX>_<NAME>_<DELEGATE_NAME>_delegate_handler(GList **delegates, rpc_port_parcel_h parcel, int id, int seq_id)
@@ -340,7 +340,7 @@ if (<ARG> == nullptr) {
 }
 
 rpc_port_parcel_read(parcel, &<ARG>->parcelable, <ARG>);
-if (get_last_result() != CION_ERROR_NONE) {
+if (get_last_result() != <ERROR_PREFIX>_ERROR_NONE) {
   _E("Failed to read data");
   goto out;
 }
@@ -415,7 +415,7 @@ if (<ARG>)
  */
 constexpr const char CB_INTERFACE_DELEGATE_TABLE[] =
 R"__c_cb(
-static cion_proxy_delegate_cb __<PREFIX>_<NAME>_delegate_table[] = {
+static _proxy_delegate_cb __<PREFIX>_<NAME>_delegate_table[] = {
   <DELEGATE_HANDLERS>
 };
 )__c_cb";
@@ -452,7 +452,7 @@ R"__c_cb(
 typedef struct <PREFIX>_<NAME>_s {
   char *service_name;
   <CLIENT_T> client;
-  <SECURITY_T> security;
+  <SECURITY_T>
   <PREFIX>_<NAME>_callback_s callback;
   void *user_data;
   GList *delegates;
@@ -512,7 +512,7 @@ static void __<PREFIX>_<NAME>_consume_command(unsigned char *data, unsigned int
 }
 
 static void __<PREFIX>_<NAME>_connection_result(const char *service_name, const <PEER_INFO_T> peer_info,
-    const cion_connection_result_h result, void *user_data)
+    const <MODULE_PREFIX>_connection_result_h result, void *user_data)
 {
   <PREFIX>_<NAME>_h h = user_data;
 
@@ -556,14 +556,14 @@ static void __<PREFIX>_<NAME>_received(const char *service_name,
 
   <PAYLOAD_GET_TYPE>
   if (ret != <ERROR_NONE>) {
-         _E("Faled to cion_payload_get_type : %d", ret);
+         _E("Faled to <MODULE_PREFIX>_payload_get_type : %d", ret);
          return;
   }
 
   if (type == <PAYLOAD_TYPE_DATA>) {
     <PAYLOAD_GET_DATA>
     if (ret != <ERROR_NONE>) {
-      _E("Faled to cion_payload_get_data : %d", ret);
+      _E("Faled to <MODULE_PREFIX>_payload_get_data : %d", ret);
       return;
     }
 
@@ -592,26 +592,25 @@ static void __<PREFIX>_<NAME>_received(const char *service_name,
 
 }
 
-int <PREFIX>_<NAME>_create(const char *service_name, <PREFIX>_<NAME>_callback_s *callback, void *user_data, <PREFIX>_<NAME>_h *h)
-{
+<EXTRA> {
   <PREFIX>_<NAME>_t *handle;
   int ret;
-  <SECURITY_T> security;
+  <SECURITY_T>
 
   if (service_name == nullptr || callback == nullptr || h == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   if (callback->connection_result == nullptr || callback->disconnected == nullptr || callback->discovered == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   handle = calloc(1, sizeof(<PREFIX>_<NAME>_t));
   if (handle == nullptr) {
     _E("Out of memory");
-    return CION_ERROR_OUT_OF_MEMORY;
+    return <ERROR_PREFIX>_ERROR_OUT_OF_MEMORY;
   }
 
   g_rec_mutex_init(&handle->mutex);
@@ -620,20 +619,20 @@ int <PREFIX>_<NAME>_create(const char *service_name, <PREFIX>_<NAME>_callback_s
   if (handle->service_name == nullptr) {
     _E("Failed to duplicate service name");
     <PREFIX>_<NAME>_destroy(handle);
-    return CION_ERROR_OUT_OF_MEMORY;
+    return <ERROR_PREFIX>_ERROR_OUT_OF_MEMORY;
   }
   <CLIENT_CREATE>
 
   *h = handle;
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_destroy(<PREFIX>_<NAME>_h h)
 {
   if (h == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   g_rec_mutex_lock(&h->mutex);
@@ -648,7 +647,7 @@ int <PREFIX>_<NAME>_destroy(<PREFIX>_<NAME>_h h)
 
   free(h);
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_try_connect(<PREFIX>_<NAME>_h h, const <PEER_INFO_T> peer_info)
@@ -657,12 +656,12 @@ int <PREFIX>_<NAME>_try_connect(<PREFIX>_<NAME>_h h, const <PEER_INFO_T> peer_in
 
   if (h == nullptr || h->client == nullptr || peer_info == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   <CLIENT_TRY_CONNECT>
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 
@@ -672,12 +671,12 @@ int <PREFIX>_<NAME>_disconnect(<PREFIX>_<NAME>_h h)
 
   if (h == nullptr || h->client == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   <CLIENT_DISCONNECT>
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_try_discovery(<PREFIX>_<NAME>_h h)
@@ -686,12 +685,12 @@ int <PREFIX>_<NAME>_try_discovery(<PREFIX>_<NAME>_h h)
 
    if (h == nullptr || h->client == nullptr) {
         _E("Invalid parameter");
-        return CION_ERROR_INVALID_PARAMETER;
+        return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
    }
 
   <CLIENT_TRY_DISCOVERY>
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_stop_discovery(<PREFIX>_<NAME>_h h)
@@ -700,12 +699,12 @@ int <PREFIX>_<NAME>_stop_discovery(<PREFIX>_<NAME>_h h)
 
   if (h == nullptr || h->client == nullptr) {
        _E("Invalid parameter");
-       return CION_ERROR_INVALID_PARAMETER;
+       return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   <CLIENT_STOP_DISCOVERY>
 
- return CION_ERROR_NONE;
+ return <ERROR_PREFIX>_ERROR_NONE;
 }
 )__c_cb";
 
@@ -734,7 +733,7 @@ void <PREFIX>_<NAME>_invoke_<METHOD_NAME>(<PREFIX>_<NAME>_h h<METHOD_PARAMS>)
 
   if (h == nullptr<METHOD_PARAMS_CHECK>) {
     _E("Invalid parameter");
-    set_last_result(CION_ERROR_INVALID_PARAMETER);
+    set_last_result(<ERROR_PREFIX>_ERROR_INVALID_PARAMETER);
     return;
   }
 
@@ -742,12 +741,12 @@ void <PREFIX>_<NAME>_invoke_<METHOD_NAME>(<PREFIX>_<NAME>_h h<METHOD_PARAMS>)
   if (h->client == nullptr) {
     _E("Not connected");
     g_rec_mutex_unlock(&h->mutex);
-    set_last_result(CION_ERROR_INVALID_PARAMETER);
+    set_last_result(<ERROR_PREFIX>_ERROR_INVALID_PARAMETER);
     return;
   }
 
   res_ = rpc_port_parcel_create(&parcel_);
-  if (res_ != CION_ERROR_NONE) {
+  if (res_ != <ERROR_PREFIX>_ERROR_NONE) {
     _E("Failed to create parcel handle. error(%d)", res_);
     g_rec_mutex_unlock(&h->mutex);
     set_last_result(res_);
@@ -809,14 +808,14 @@ R"__c_cb(
 
   if (h == nullptr<METHOD_PARAMS_CHECK>) {
     _E("Invalid parameter");
-    set_last_result(CION_ERROR_INVALID_PARAMETER);
+    set_last_result(<ERROR_PREFIX>_ERROR_INVALID_PARAMETER);
     return ret_;
   }
 
   g_rec_mutex_lock(&h->mutex);
   if (h->client == nullptr) {
     _E("Not connected");
-    set_last_result(CION_ERROR_INVALID_PARAMETER);
+    set_last_result(<ERROR_PREFIX>_ERROR_INVALID_PARAMETER);
     g_rec_mutex_unlock(&h->mutex);
     return ret_;
   }
@@ -847,7 +846,7 @@ R"__c_cb(
   __<PREFIX>_<NAME>_consume_command(return_data_, return_data_size_, &parcel_);
   if (parcel_ == nullptr) {
     _E("Invalid protocol");
-    res_ = CION_ERROR_IO_ERROR;
+    res_ = <ERROR_PREFIX>_ERROR_IO_ERROR;
     goto out;
   }
 
@@ -910,12 +909,12 @@ R"__c_cb(
 <PREFIX>_<NAME>_create(&<ARG>);
 if (<ARG> == nullptr) {
   _E("Failed to create handle");
-  res_ = CION_ERROR_OUT_OF_MEMORY;
+  res_ = <ERROR_PREFIX>_ERROR_OUT_OF_MEMORY;
   goto out;
 }
 
 rpc_port_parcel_read(parcel_, &<ARG>->parcelable, <ARG>);
-if (get_last_result() != CION_ERROR_NONE) {
+if (get_last_result() != <ERROR_PREFIX>_ERROR_NONE) {
   _E("Failed to read data");
   <PREFIX>_<NAME>_destroy(<ARG>);
   <ARG> = nullptr;
@@ -933,7 +932,7 @@ R"__c_cb(
 rpc_port_parcel_read_bundle(parcel_, &<ARG>);
 if (<ARG> == nullptr) {
   _E("Failed to read data");
-  res_ = CION_ERROR_OUT_OF_MEMORY;
+  res_ = <ERROR_PREFIX>_ERROR_OUT_OF_MEMORY;
   goto out;
 
 }
@@ -948,7 +947,7 @@ R"__c_cb(
 rpc_port_parcel_read_string(parcel_, &<ARG>);
 if (<ARG> == nullptr) {
   _E("Failed to read data");
-  res_ = CION_ERROR_OUT_OF_MEMORY;
+  res_ = <ERROR_PREFIX>_ERROR_OUT_OF_MEMORY;
   goto out;
 }
 )__c_cb";
index 528af9b86a22a7a7f9460ff58eb67d0191d17972..d1f71e8e661c783ba77662b2c5085fcaed6a066b 100644 (file)
@@ -22,8 +22,8 @@ namespace {
 
 namespace tidl {
 
-CCionProxyHeaderGen::CCionProxyHeaderGen(std::shared_ptr<Document> doc)
-    : CCionHeaderGeneratorBase(doc) {
+CCionProxyHeaderGen::CCionProxyHeaderGen(std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans)
+    : CCionHeaderGeneratorBase(doc, trans) {
 }
 
 void CCionProxyHeaderGen::OnInitGen(std::ofstream& stream) {
@@ -31,8 +31,14 @@ void CCionProxyHeaderGen::OnInitGen(std::ofstream& stream) {
   GenPragmaOnce(stream);
   GenIncludeDefaultHeaders(stream, false);
   GenExplicitLinkageOpen(stream);
+  GenCommonHandles(stream);
+  GenConnectionHandle(stream);
+  GenFileHandle(stream);
   GenStructureHandles(stream);
   GenInterfaceHandles(stream);
+  GenCommonBase(stream);
+  GenConnectionBase(stream);
+  GenFileBase(stream);
   GenStructures(stream);
   GenInterfaces(stream);
 }
@@ -113,12 +119,15 @@ void CCionProxyHeaderGen::GenInterface(std::ofstream& stream,
 void CCionProxyHeaderGen::GenInterfaceBase(std::ofstream& stream,
     const Interface& iface) {
   std::string code(ReplaceAll(CB_INTERFACE_BASE, {
+      { "<EXTRA>", GetTransportable().C().GenClientExtra(false) },
       { "<PREFIX>", GetHandlePrefix() },
       { "<NAME>", iface.GetID() },
       { "<PEER_INFO_T>", GetTransportable().C().GenPeerInfoType() },
       { "<PAYLOAD_T>", GetTransportable().C().GenPayloadType() },
       { "<PAYLOAD_TRANSFER_STATUS_T>",
-          GetTransportable().C().GenPayloadTransferStatusType() }
+          GetTransportable().C().GenPayloadTransferStatusType() },
+      { "<MODULE_PREFIX>", GetMoudlePrefix() },
+      { "<ERROR_PREFIX>", GetTransportable().C().GenErrorPrefix() }
   }));
 
   stream << SmartIndent(code);
@@ -145,7 +154,8 @@ void CCionProxyHeaderGen::GenInterfaceDelegateBase(std::ofstream& stream,
       { "<PREFIX>", GetHandlePrefix() },
       { "<NAME>", iface.GetID() },
       { "<DELEGATE_NAME>", decl.GetID() },
-      { "<DELEGATE_PARAMS>", GenDelegateParams(iface, decl) }
+      { "<DELEGATE_PARAMS>", GenDelegateParams(iface, decl) },
+      { "<ERROR_PREFIX>", GetTransportable().C().GenErrorPrefix() }
   }));
 
   stream << SmartIndent(code);
@@ -173,7 +183,8 @@ void CCionProxyHeaderGen::GenInterfaceMethodBase(std::ofstream& stream,
       { "<PREFIX>", GetHandlePrefix() },
       { "<NAME>", iface.GetID() },
       { "<METHOD_NAME>", decl.GetID() },
-      { "<METHOD_PARAMS>", GenMethodParams(iface, decl) }
+      { "<METHOD_PARAMS>", GenMethodParams(iface, decl) },
+      { "<ERROR_PREFIX>", GetTransportable().C().GenErrorPrefix() }
   }));
   stream << SmartIndent(code);
 }
index ec714061a1d3b2966cfbcf94c0cfe52d5056ab2d..12d99b12c6a0111038a2441f74c09e2ad864515b 100644 (file)
@@ -26,7 +26,7 @@ namespace tidl {
 
 class CCionProxyHeaderGen : public CCionHeaderGeneratorBase {
  public:
-  explicit CCionProxyHeaderGen(std::shared_ptr<Document> doc);
+  explicit CCionProxyHeaderGen(std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans);
   virtual ~CCionProxyHeaderGen() = default;
 
   void OnInitGen(std::ofstream& stream) override;
index 969fe40e588300202cef0b2dedd883c8e2ae4668..0f1e11e70e37cfce4ec881b0b26ddebdab797734 100644 (file)
@@ -61,9 +61,9 @@ typedef void (*<PREFIX>_<NAME>_<DELEGATE_NAME>_cb)(void *user_data<DELEGATE_PARA
  * @param[out] h The <PREFIX>_<NAME>_<DELEGATE_NAME> handle
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CION_ERROR_OUT_OF_MEMORY Out of memorya
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY Out of memorya
  * @see <PREFIX>_<NAME>_<DELEGATE_NAME>_destroy()
  * @see <PREFIX>_<NAME>_<DELEGATE_NAME>_dispose()
  * @see <PREFIX>_<NAME>_<DELEGATE_NAME>_set_callback()
@@ -77,8 +77,8 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_create(<PREFIX>_<NAME>_<DELEGATE_NAME>_h *h)
  * @param[in] h The <PREFIX>_<NAME>_<DELEGATE_NAME> handle
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
  * @see <PREFIX>_<NAME>_<DELEGATE_NAME>_create()
  */
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_destroy(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h);
@@ -92,9 +92,9 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_destroy(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h)
  * @param[out] clone If successful, a new created <PREFIX>_<NAME>_<DELEGATE_NAME> handle will be returned
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY Out of memory
  * @see <PREFIX>_<NAME>_<DELEGATE_NAME>_destroy()
  */
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_clone(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, <PREFIX>_<NAME>_<DELEGATE_NAME>_h *clone);
@@ -107,8 +107,8 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_clone(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, <
  * @param[in] user_data The user data to be passed to the callback function
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
  */
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_set_callback(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, <PREFIX>_<NAME>_<DELEGATE_NAME>_cb callback, void *user_data);
 
@@ -124,8 +124,8 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_set_callback(<PREFIX>_<NAME>_<DELEGATE_NAME>
  * @param[in] once The flag if it's true, the delegate will be deleted after invocation
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
  */
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_set_once(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, bool once);
 
@@ -136,8 +136,8 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_set_once(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h
  * @param[out] id The ID
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
  */
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_get_id(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, int *id);
 
@@ -148,8 +148,8 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_get_id(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h,
  * @param[out] seq_id The Sequence ID
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
  */
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_get_seq_id(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, int *seq_id);
 
@@ -160,8 +160,8 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_get_seq_id(<PREFIX>_<NAME>_<DELEGATE_NAME>_h
  * @param[out] once The flag, it's true, the handle is for one-time
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
  */
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_is_once(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, bool *once);
 
@@ -173,9 +173,9 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_is_once(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h,
  * @param[out] tag The tag
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY Out of memory
  */
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_get_tag(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, char **tag);
 
@@ -186,8 +186,8 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_get_tag(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h,
  * @param[in] h The <PREFIX>_<NAME>_<DELEGATE_NAME> handle
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
  * @see <PREFIX>_<NAME>_<DELEGATE_NAME>_create()
  */
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_dispose(<PREFIX>_<NAME>_h proxy, <PREFIX>_<NAME>_<DELEGATE_NAME>_h h);
@@ -203,11 +203,13 @@ R"__c_cb(
  * @brief Called when the connection is accepted or rejected.
  *
  * @param[in] h The <PREFIX>_<NAME> handle
+ * @param[in] result The handle for connection result \n
+ *            The @a result can be used only in the callback. To use outside, make a copy.
  * @param[in] user_data The user data passed from the registeration function
  * @see #<PREFIX>_<NAME>_callback_s
  */
 typedef void (*<PREFIX>_<NAME>_connection_result_cb)(<PREFIX>_<NAME>_h h,
-    const cion_connection_result_h result, void *user_data);
+    const <MODULE_PREFIX>_connection_result_h result, void *user_data);
 
 /**
  * @brief Called when the proxy is disconnected.
@@ -222,14 +224,13 @@ typedef void (*<PREFIX>_<NAME>_disconnected_cb)(<PREFIX>_<NAME>_h h, void *user_
 /**
  * @brief Called when the stub is discovered.
  *
- * @param[in] h The <PREFIX>_<NAME> handle
- * @param[in] peer_info The Cion peer information handle \n
+ * @param[in] peer_info The <MODULE_PREFIX> peer information handle \n
  *            The @a peer_info can be used only in the callback. To use outside, make a copy.
  * @param[in] user_data The user data passed from the registeration function
  * @see #<PREFIX>_<NAME>_callback_s
- * @see #cion_peer_info_get_app_id()
- * @see #cion_peer_info_get_display_name()
- * @see #cion_peer_info_clone()
+ * @see #<MODULE_PREFIX>_peer_info_get_app_id()
+ * @see #<MODULE_PREFIX>_peer_info_get_display_name()
+ * @see #<MODULE_PREFIX>_peer_info_clone()
  * @par Sample code:
  * @code
 
@@ -238,7 +239,7 @@ void <PREFIX>_<NAME>_stub_discovered_cb(const <PEER_INFO_T> peer_info, void *use
   <PREFIX>_<NAME>_h handle = user_data;
   char *app_id = NULL;
 
-  cion_peer_info_get_app_id(peer_info, &app_id);
+  <MODULE_PREFIX>_peer_info_get_app_id(peer_info, &app_id);
   LOGI("stub_discovered(%s)", app_id);
 
   <PREFIX>_<NAME>_try_connect(handle, peer_info);
@@ -253,7 +254,7 @@ typedef void (*<PREFIX>_<NAME>_stub_discovered_cb)(const <PEER_INFO_T> peer_info
 /**
  * @brief Called when the payload is received.
  *
- * @param[in] peer_info The Cion peer information handle \n
+ * @param[in] peer_info The <MODULE_PREFIX> peer information handle \n
  *            The @a peer_info can be used only in the callback. To use outside, make a copy.
  * @param[in] payload The received payload \n
  *            The @a payload can be used only in the callback. \n
@@ -261,7 +262,7 @@ typedef void (*<PREFIX>_<NAME>_stub_discovered_cb)(const <PEER_INFO_T> peer_info
  * @param[in] status The status of transfer
  * @param[in] user_data The user data passed from the registeration function
  * @see #<PREFIX>_<NAME>_callback_s
- * @see #cion_peer_info_clone()
+ * @see #<MODULE_PREFIX>_peer_info_clone()
  *
  * @par Sample code:
  * @code
@@ -277,12 +278,12 @@ void <PREFIX>_<NAME>__file_received_cb(const <PEER_INFO_T> peer_info, const <PAY
   uint64_t bytes, total;
   char data_path_buff[512];
 
-  cion_peer_info_get_app_id(peer_info, &app_id);
-  cion_payload_get_total_bytes(payload, &total);
-  cion_payload_get_received_bytes(payload, &bytes);
-  cion_payload_get_received_file_name(payload, &file_name);
+  <MODULE_PREFIX>_peer_info_get_app_id(peer_info, &app_id);
+  <MODULE_PREFIX>_payload_get_total_bytes(payload, &total);
+  <MODULE_PREFIX>_payload_get_received_bytes(payload, &bytes);
+  <MODULE_PREFIX>_payload_get_received_file_name(payload, &file_name);
 
-  if (status == CION_PAYLOAD_TRANSFER_STATUS_SUCCESS) {
+  if (status == <ERROR_PREFIX>_PAYLOAD_TRANSFER_STATUS_SUCCESS) {
     data_path = app_get_data_path();
     if (data_path == NULL) {
       LOGE("failed to get data path.");
@@ -290,7 +291,7 @@ void <PREFIX>_<NAME>__file_received_cb(const <PEER_INFO_T> peer_info, const <PAY
      }
 
     snprintf(data_path_buff, 512, "%s%s", data_path, file_name);
-    ret = cion_payload_save_as_file(payload, data_path_buff);
+    ret = <MODULE_PREFIX>_payload_save_as_file(payload, data_path_buff);
     free(data_path);
     LOGI("save file %s : %d", data_path_buff, ret);
   } else {
@@ -324,24 +325,7 @@ typedef struct {
   <PREFIX>_<NAME>_file_received_cb file_received;  /**< This callback function is called when when the payload is received. */
 } <PREFIX>_<NAME>_callback_s;
 
-/**
- * @brief Creates a <PREFIX>_<NAME> handle.
- * @remarks The @a h handle should be released using
- *          the <PREFIX>_<NAME>_destroy() if it's no longer needed.
- *
- * @param[in] service_name The name of service
- * @param[in] callback The set of callback functions to handle proxy events
- * @param[in] user_data The user data to be passed to the callback function
- * @param[out] h The <PREFIX>_<NAME> handle
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CION_ERROR_OUT_OF_MEMORY Out of memory
- * @see <PREFIX>_<NAME>_destroy()
- * @see #<PREFIX>_<NAME>_callback_s
- */
-int <PREFIX>_<NAME>_create(const char *service_name, <PREFIX>_<NAME>_callback_s *callback, void *user_data, <PREFIX>_<NAME>_h *h);
+<EXTRA>
 
 /**
  * @brief Destroys the <PREFIX>_<NAME> handle.
@@ -349,8 +333,8 @@ int <PREFIX>_<NAME>_create(const char *service_name, <PREFIX>_<NAME>_callback_s
  * @param[in] h The <PREFIX>_<NAME> handle
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
  * @see <PREFIX>_<NAME>_create()
  */
 int <PREFIX>_<NAME>_destroy(<PREFIX>_<NAME>_h h);
@@ -360,14 +344,14 @@ int <PREFIX>_<NAME>_destroy(<PREFIX>_<NAME>_h h);
  * @privilege http://tizen.org/privilege/d2d.datasharing
  *
  * @param[in] h The <PREFIX>_<NAME> handle
- * @param[in] peer_info The Cion peer information handle
+ * @param[in] peer_info The <MODULE_PREFIX> peer information handle
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_PERMISSION_DENIED Permission denied
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CION_ERROR_INVALID_OPERATION Invalid operation
- * @retval #CION_ERROR_IO_ERROR IO error
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #<ERROR_PREFIX>_ERROR_IO_ERROR IO error
  */
 int <PREFIX>_<NAME>_try_connect(<PREFIX>_<NAME>_h h, const <PEER_INFO_T> peer_info);
 
@@ -377,8 +361,8 @@ int <PREFIX>_<NAME>_try_connect(<PREFIX>_<NAME>_h h, const <PEER_INFO_T> peer_in
  * @param[in] h The <PREFIX>_<NAME> handle
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
  * @see <PREFIX>_<NAME>_create()
  */
 int <PREFIX>_<NAME>_disconnect(<PREFIX>_<NAME>_h h);
@@ -390,10 +374,10 @@ int <PREFIX>_<NAME>_disconnect(<PREFIX>_<NAME>_h h);
  * @param[in] h The <PREFIX>_<NAME> handle
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CION_ERROR_ALREADY_IN_PROGRESS Already in progress
- * @retval #CION_ERROR_IO_ERROR IO error
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_ALREADY_IN_PROGRESS Already in progress
+ * @retval #<ERROR_PREFIX>_ERROR_IO_ERROR IO error
  * @see <PREFIX>_<NAME>_stub_discovered_cb
  */
 int <PREFIX>_<NAME>_try_discovery(<PREFIX>_<NAME>_h h);
@@ -404,9 +388,9 @@ int <PREFIX>_<NAME>_try_discovery(<PREFIX>_<NAME>_h h);
  * @param[in] h The <PREFIX>_<NAME> handle
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CION_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_OPERATION Invalid operation
  * @see <PREFIX>_<NAME>_stub_discovered_cb
  */
 int <PREFIX>_<NAME>_stop_discovery(<PREFIX>_<NAME>_h h);
@@ -430,10 +414,10 @@ R"__c_cb(
  * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section.
  * @param[in] h The <PREFIX>_<NAME> handle
  * @param[in] ...
- * @exception #CION_ERROR_NONE Successful
- * @exception #CION_ERROR_INVALID_PARAMETER Invalid parameter
- * @exception #CION_ERROR_OUT_OF_MEMORY Out of memory
- * @exception #CION_ERROR_IO_ERROR I/O error
+ * @exception #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @exception #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception #<ERROR_PREFIX>_ERROR_IO_ERROR I/O error
  */
 <RETURN_TYPE><PREFIX>_<NAME>_invoke_<METHOD_NAME>(<PREFIX>_<NAME>_h h<METHOD_PARAMS>);
 )__c_cb";
index c6bccc5a8a7a2ddb17351a58fdfadaf23e054818..36488b3f51bb299c8c80d79c7b978dc36e44f65c 100644 (file)
@@ -22,8 +22,8 @@
 namespace tidl {
 
 CCionStubBodyGen::CCionStubBodyGen(std::shared_ptr<Document> doc,
-    std::shared_ptr<Options> options)
-    : CCionBodyGeneratorBase(doc), options_(options) {
+    std::shared_ptr<Options> options, std::shared_ptr<tidl::Transportable> trans)
+    : CCionBodyGeneratorBase(doc, trans), options_(options) {
 }
 
 void CCionStubBodyGen::OnInitGen(std::ofstream& stream) {
@@ -31,7 +31,7 @@ void CCionStubBodyGen::OnInitGen(std::ofstream& stream) {
   GenGNUSourceDefinition(stream);
   GenIncludeDefaultHeaders(stream);
   GenIncludeHeader(stream);
-  GenLogTag(stream, std::string("CION_STUB"));
+  GenLogTag(stream, GetTransportable().C().GenStubPrefix());
   GenLogDefinition(stream);
   GenBaseDefinition(stream);
   GenThreadEnableDefinition(stream);
@@ -41,6 +41,7 @@ void CCionStubBodyGen::OnInitGen(std::ofstream& stream) {
   GenInterfaceDefs(stream);
   GenFilePayloadSend(stream, false);
   GenStructures(stream);
+  GenCommonFuntions(stream);
   GenInterfaces(stream);
 }
 
@@ -59,6 +60,7 @@ void CCionStubBodyGen::GenThreadEnableDefinition(std::ofstream& stream) {
 void CCionStubBodyGen::GenInterfaceMethodHandlerType(std::ofstream& stream) {
   std::string code(ReplaceAll(CB_INTERFACE_METHOD_HANDLER_TYPE,
       "<PEER_INFO_T>", GetTransportable().C().GenPeerInfoType()));
+  code = ReplaceAll(code, "<MODULE_PREFIX>", GetMoudlePrefix());
 
   stream << SmartIndent(code);
 }
@@ -186,10 +188,11 @@ void CCionStubBodyGen::GenInterfaceDef(std::ofstream& stream,
 void CCionStubBodyGen::GenInterfaceDelegateDef(std::ofstream& stream,
     const Interface& iface, const Declaration& decl) {
   std::string code(ReplaceAll(CB_INTERFACE_DELEGATE_DEF, {
-      { "<PREFIX>", GetHandlePrefix() },
       { "<NAME>", iface.GetID() },
       { "<DELEGATE_NAME>", decl.GetID() },
-      { "<PEER_INFO_T>", GetTransportable().C().GenPeerInfoType() }
+      { "<PEER_INFO_T>", GetTransportable().C().GenPeerInfoType() },
+      { "<MODULE_PREFIX>", GetMoudlePrefix() },
+      { "<PREFIX>", GetHandlePrefix() }
   }));
 
   stream << SmartIndent(code);
@@ -242,9 +245,11 @@ void CCionStubBodyGen::GenInterface(std::ofstream& stream, const Interface& ifac
 void CCionStubBodyGen::GenInterfaceContextBase(std::ofstream& stream,
     const Interface& iface) {
   std::string code(ReplaceAll(CB_INTERFACE_CONTEXT_BASE, {
-      { "<PREFIX>", GetHandlePrefix() },
       { "<NAME>", iface.GetID() },
-      { "<PEER_INFO_T>", GetTransportable().C().GenPeerInfoType() }
+      { "<PEER_INFO_T>", GetTransportable().C().GenPeerInfoType() },
+      { "<ERROR_PREFIX>", GetTransportable().C().GenErrorPrefix() },
+      { "<MODULE_PREFIX>", GetMoudlePrefix() },
+      { "<PREFIX>", GetHandlePrefix() }
   }));
 
   stream << SmartIndent(code);
@@ -338,7 +343,6 @@ void CCionStubBodyGen::GenInterfaceDelegateBase(std::ofstream& stream,
   std::string file_def = GetFilePayloadDefString(iface, decl, false);
 
   std::string code(ReplaceAll(CB_INTERFACE_DELEGATE_BASE, {
-      { "<PREFIX>", GetHandlePrefix() },
       { "<FILE_LIST_SEND>", file_send },
       { "<FILE_LIST_FREE>", file_free },
       { "<SERVER_SEND_ASYNC>", GetTransportable().C().GenServerSendAsync(
@@ -359,7 +363,10 @@ void CCionStubBodyGen::GenInterfaceDelegateBase(std::ofstream& stream,
               .GenPeerInfoClone("h->peer_info", "&handle->peer_info") },
       { "<PEER_INFO_CLONE2>",
           GetTransportable().C()
-              .GenPeerInfoClone("peer_info", "&h->peer_info") }
+              .GenPeerInfoClone("peer_info", "&h->peer_info") },
+      { "<ERROR_PREFIX>", GetTransportable().C().GenErrorPrefix() },
+      { "<MODULE_PREFIX>", GetMoudlePrefix() },
+      { "<PREFIX>", GetHandlePrefix() }
   }));
 
   stream << SmartIndent(code);
@@ -611,7 +618,6 @@ void CCionStubBodyGen::GenInterfaceMethodHandlerBase(std::ofstream& stream,
   std::string file_free = GetFilePayloadFreeString(iface, decl);
 
   std::string code(ReplaceAll(CB_INTERFACE_METHOD_HANDLER_BASE, {
-      { "<PREFIX>", GetHandlePrefix() },
       { "<FILE_LIST_SEND>", file_send },
       { "<NAME>", iface.GetID() },
       { "<METHOD_NAME>", decl.GetID() },
@@ -622,7 +628,10 @@ void CCionStubBodyGen::GenInterfaceMethodHandlerBase(std::ofstream& stream,
       { "<METHOD_HANDLER_PARCEL_WRITE>",  GenMethodHandlerParcelWrite(iface, decl) },
       { "<FILE_LIST_FREE>", file_free },
       { "<METHOD_HANDLER_ARGS_FREE>", GenMethodHandlerArgsFree(iface, decl) },
-      { "<PEER_INFO_T>", GetTransportable().C().GenPeerInfoType() }
+      { "<ERROR_PREFIX>", GetTransportable().C().GenErrorPrefix() },
+      { "<PEER_INFO_T>", GetTransportable().C().GenPeerInfoType() },
+      { "<MODULE_PREFIX>", GetMoudlePrefix() },
+      { "<PREFIX>", GetHandlePrefix() }
   }));
 
   stream << SmartIndent(code);
@@ -673,13 +682,13 @@ void CCionStubBodyGen::GenInterfaceBase(std::ofstream& stream,
       { "<SERVER_REJECT>", GetTransportable().C().GenServerReject() },
       { "<SERVER_SET_DISPLAY_NAME>",
           GetTransportable().C().GenServerSetDisplayName() },
-      { "<PREFIX>", GetHandlePrefix() },
+      { "<EXTRA>", GetTransportable().C().GenServerExtra() },
       { "<NAME>", iface.GetID() },
       { "<SET_SECURITY>", GenSecurityString(iface) },
       { "<PEER_INFO_T>", GetTransportable().C().GenPeerInfoType() },
       { "<PAYLOAD_T>", GetTransportable().C().GenPayloadType() },
       { "<PAYLOAD_TRANSFER_STATUS_T>",
-          GetTransportable().C().GenPayloadTransferStatusType() },
+          GetTransportable().C().GenPayloadTransferStatusType(true) },
       { "<SECURITY_T>", GetTransportable().C().GenSecurityType() },
       { "<PAYLOAD_TYPE_E>", GetTransportable().C().GenPayloadTypeEnum() },
       { "<PAYLOAD_GET_TYPE>", GetTransportable().C().GenPayloadGetType() },
@@ -688,7 +697,9 @@ void CCionStubBodyGen::GenInterfaceBase(std::ofstream& stream,
       { "<PAYLOAD_TYPE_FILE>", GetTransportable().C().GenPayloadTypeFile() },
       { "<PAYLOAD_GET_DATA>", GetTransportable().C().GenPayloadGetData() },
       { "<SERVER_FOREACH_CONNECTED_PEER_INFO>", GetTransportable().C().GenServerForeachConnectedPeerInfo(iface.GetID()) },
-      { "<SERVER_SET_ONDEMAND_LAUNCH_ENABLED>", GetTransportable().C().GenServerSetOnDemandLaunchEnabled(iface.GetID()) }
+      { "<ERROR_PREFIX>", GetTransportable().C().GenErrorPrefix() },
+      { "<MODULE_PREFIX>", GetMoudlePrefix() },
+      { "<PREFIX>", GetHandlePrefix() }
   }));
 
   stream << SmartIndent(code);
index dd9a2b16a58bef75d55316cc814fdc7275527380..81c8452d192d0d60483a8999df9dca30ec0b08da 100644 (file)
@@ -28,7 +28,7 @@ namespace tidl {
 class CCionStubBodyGen : public CCionBodyGeneratorBase {
  public:
   explicit CCionStubBodyGen(std::shared_ptr<Document> doc,
-      std::shared_ptr<Options> options);
+      std::shared_ptr<Options> options, std::shared_ptr<tidl::Transportable> trans);
   virtual ~CCionStubBodyGen() = default;
 
   void OnInitGen(std::ofstream& stream) override;
index b28eaee840868c9d5ee9bb5d88eaf5cfab5f8782..06082d73d47c0f26c5e3bac9f3eebe487bb7c7af 100644 (file)
@@ -27,7 +27,7 @@ R"__c_cb(
  */
 constexpr const char CB_INTERFACE_METHOD_HANDLER_TYPE[] =
 R"__c_cb(
-typedef int (*cion_stub_method_handler)(const <PEER_INFO_T> peer_info, rpc_port_parcel_h parcel, rpc_port_parcel_h return_parcel, void *data);
+typedef int (*_stub_method_handler)(const <PEER_INFO_T> peer_info, rpc_port_parcel_h parcel, rpc_port_parcel_h return_parcel, void *data);
 )__c_cb";
 
 /**
@@ -83,7 +83,7 @@ constexpr const char CB_INTERFACE_BASE_DEF[] =
 R"__c_cb(
 typedef struct <PREFIX>_<NAME>_s {
   <SERVER_T> stub;
-  <SECURITY_T> security;
+  <SECURITY_T>
   <PREFIX>_<NAME>_callback_s callback;
   void *user_data;
   GRecMutex mutex;
@@ -117,7 +117,7 @@ constexpr const char CB_INTERFACE_CONTEXT_BASE[] =
 R"__c_cb(
 static int __<PREFIX>_<NAME>_process_received_event(<PREFIX>_<NAME>_t *h, const <PEER_INFO_T> peer_info, rpc_port_parcel_h parcel, rpc_port_parcel_h return_parcel)
 {
-  int ret = CION_ERROR_NONE;
+  int ret = <ERROR_PREFIX>_ERROR_NONE;
   int cmd = -1;
 
   rpc_port_parcel_read_int32(parcel, &cmd);
@@ -126,7 +126,7 @@ static int __<PREFIX>_<NAME>_process_received_event(<PREFIX>_<NAME>_t *h, const
       ret = __<NAME>_method_table[cmd](peer_info, parcel, return_parcel, h);
   } else {
     _W("Invalid protocol. cmd(%d)", cmd);
-    ret = CION_ERROR_INVALID_PARAMETER;
+    ret = <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   return ret;
@@ -168,7 +168,7 @@ static void __<PREFIX>_<NAME>_<DELEGATE_NAME>_from(rpc_port_parcel_h parcel, voi
 
   if (parcel == nullptr || h == nullptr) {
     _E("Invalid parameter");
-    set_last_result(CION_ERROR_INVALID_PARAMETER);
+    set_last_result(<ERROR_PREFIX>_ERROR_INVALID_PARAMETER);
     return;
   }
 
@@ -179,7 +179,7 @@ static void __<PREFIX>_<NAME>_<DELEGATE_NAME>_from(rpc_port_parcel_h parcel, voi
   rpc_port_parcel_read_bool(parcel, &h->once);
 
   _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false");
-  set_last_result(CION_ERROR_NONE);
+  set_last_result(<ERROR_PREFIX>_ERROR_NONE);
 }
 
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_create(<PREFIX>_<NAME>_<DELEGATE_NAME>_h *h)
@@ -189,13 +189,13 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_create(<PREFIX>_<NAME>_<DELEGATE_NAME>_h *h)
 
   if (h == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   handle = calloc(1, sizeof(<PREFIX>_<NAME>_<DELEGATE_NAME>_t));
   if (handle == nullptr) {
     _E("Out of memory");
-    return CION_ERROR_OUT_OF_MEMORY;
+    return <ERROR_PREFIX>_ERROR_OUT_OF_MEMORY;
   }
 
   handle->parcelable.to = __<PREFIX>_<NAME>_<DELEGATE_NAME>_to;
@@ -208,14 +208,14 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_create(<PREFIX>_<NAME>_<DELEGATE_NAME>_h *h)
 
   *h = handle;
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_destroy(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h)
 {
   if (h == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   _W("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false");
@@ -224,7 +224,7 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_destroy(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h)
 
   free(h);
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_clone(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, <PREFIX>_<NAME>_<DELEGATE_NAME>_h *clone)
@@ -234,11 +234,11 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_clone(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, <
 
   if (h == nullptr || clone == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   ret = <PREFIX>_<NAME>_<DELEGATE_NAME>_create(&handle);
-  if (ret != CION_ERROR_NONE) {
+  if (ret != <ERROR_PREFIX>_ERROR_NONE) {
     _E("Failed to create handle. error(%d)", ret);
     return ret;
   }
@@ -250,43 +250,43 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_clone(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, <
 
   *clone = handle;
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_get_id(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, int *id)
 {
   if (h == nullptr || id == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   *id = h->id;
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_get_seq_id(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, int *seq_id)
 {
   if (h == nullptr || seq_id == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   *seq_id = h->seq_id;
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_is_once(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, bool *once)
 {
   if (h == nullptr || once == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   *once = h->once;
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_get_tag(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, char **tag)
@@ -296,26 +296,26 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_get_tag(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h,
 
   if (h == nullptr || tag == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   snprintf(buf, sizeof(buf), "%d::%d", h->id, h->seq_id);
   value = strdup(buf);
   if (value == nullptr) {
     _E("Out of memory");
-    return CION_ERROR_OUT_OF_MEMORY;
+    return <ERROR_PREFIX>_ERROR_OUT_OF_MEMORY;
   }
 
   *tag = value;
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 static int __<PREFIX>_<NAME>_<DELEGATE_NAME>_set_peerInfo(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, const <PEER_INFO_T> peer_info)
 {
   if (h == nullptr || peer_info == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   return <PEER_INFO_CLONE2>
@@ -334,19 +334,19 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_invoke(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h<D
 
   if (h == nullptr || h->peer_info == nullptr<DELEGATE_PARAMS_CHECK>) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   peer_info = h->peer_info;
 
   if (h->once && !h->valid) {
     _E("The delegate handle is already used");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
   g_rec_mutex_lock(&__<NAME>.mutex);
 
   ret_ = rpc_port_parcel_create(&parcel_);
-  if (ret_ != CION_ERROR_NONE) {
+  if (ret_ != <ERROR_PREFIX>_ERROR_NONE) {
     _E("Failed to create parcel handle. error(%d)", ret_);
     g_rec_mutex_unlock(&__<NAME>.mutex);
     return ret_;
@@ -428,13 +428,13 @@ R"__c_cb(
 static int __<PREFIX>_<NAME>_method_<METHOD_NAME>_handler(const <PEER_INFO_T> peer_info, rpc_port_parcel_h parcel, rpc_port_parcel_h return_parcel, void *user_data)
 {
   <PREFIX>_<NAME>_t *h = user_data;
-  int ret_ = CION_ERROR_NONE;
+  int ret_ = <ERROR_PREFIX>_ERROR_NONE;
   <FILE_LIST_DEF>
 
   <METHOD_HANDLER_ARGS_DECL>
   if (h == nullptr || h->stub == nullptr) {
     _E("Invalid parameter");
-    ret_ = CION_ERROR_INVALID_PARAMETER;
+    ret_ = <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
     goto out;
   }
   <METHOD_HANDLER_PARCEL_READ>
@@ -457,7 +457,7 @@ static int __<PREFIX>_<NAME>_method_<METHOD_NAME>_handler(const <PEER_INFO_T> pe
 constexpr const char CB_INTERFACE_METHOD_DELEGATE_PARCEL_READ[] =
 R"__c_cb(
 ret_ = <PREFIX>_<NAME>_create(&<ARG>);
-if (ret_ != CION_ERROR_NONE) {
+if (ret_ != <ERROR_PREFIX>_ERROR_NONE) {
   _E("Failed to create handle. error(%d)", ret_);
   goto out;
 }
@@ -465,7 +465,7 @@ if (ret_ != CION_ERROR_NONE) {
 __<PREFIX>_<NAME>_set_peerInfo(<ARG>, peer_info);
 rpc_port_parcel_read(parcel, &<ARG>->parcelable, <ARG>);
 ret_ = get_last_result();
-if (ret_ != CION_ERROR_NONE) {
+if (ret_ != <ERROR_PREFIX>_ERROR_NONE) {
   _E("Failed to read data. error(%d)", ret_);
   goto out;
 }
@@ -479,14 +479,14 @@ if (ret_ != CION_ERROR_NONE) {
 constexpr const char CB_INTERFACE_METHOD_USER_DEFINED_PARCEL_READ[] =
 R"__c_cb(
 ret_ = <PREFIX>_<NAME>_create(&<ARG>);
-if (ret_ != CION_ERROR_NONE) {
+if (ret_ != <ERROR_PREFIX>_ERROR_NONE) {
   _E("Failed to create handle. error(%d)", ret_);
   goto out;
 }
 
 rpc_port_parcel_read(parcel, &<ARG>->parcelable, <ARG>);
 ret_ = get_last_result();
-if (ret_ != CION_ERROR_NONE) {
+if (ret_ != <ERROR_PREFIX>_ERROR_NONE) {
   _E("Failed to read data. error(%d)", ret_);
   goto out;
 }
@@ -500,7 +500,7 @@ R"__c_cb(
 rpc_port_parcel_read_bundle(parcel, &<ARG>);
 if (<ARG> == nullptr) {
   _E("Failed to read data");
-  ret_ = CION_ERROR_OUT_OF_MEMORY;
+  ret_ = <ERROR_PREFIX>_ERROR_OUT_OF_MEMORY;
   goto out;
 }
 )__c_cb";
@@ -513,7 +513,7 @@ R"__c_cb(
 rpc_port_parcel_read_string(parcel, &<ARG>);
 if (<ARG> == nullptr) {
   _E("Failed to read data");
-  ret_ = CION_ERROR_OUT_OF_MEMORY;
+  ret_ = <ERROR_PREFIX>_ERROR_OUT_OF_MEMORY;
   goto out;
 }
 )__c_cb";
@@ -621,7 +621,7 @@ if (<ARG>)
  */
 constexpr const char CB_INTERFACE_METHOD_TABLE[] =
 R"__c_cb(
-static cion_stub_method_handler __<NAME>_method_table[] = {
+static _stub_method_handler __<NAME>_method_table[] = {
   <METHOD_HANDLERS>
 };
 )__c_cb";
@@ -654,7 +654,7 @@ static void __<PREFIX>_<NAME>_disconnected_cb(const char *service_name,
 }
 
 static void __<PREFIX>_<NAME>_connection_result_cb(const char *service_name, const <PEER_INFO_T> peer_info,
-    const cion_connection_result_h result, void *user_data)
+    const <MODULE_PREFIX>_connection_result_h result, void *user_data)
 {
   <PREFIX>_<NAME>_t *h = user_data;
 
@@ -678,14 +678,14 @@ static void __<PREFIX>_<NAME>_payload_received_cb(const char *service_name,
 
   <PAYLOAD_GET_TYPE>
   if (ret != <ERROR_NONE>) {
-         _E("Faled to cion_payload_get_type : %d", ret);
+         _E("Faled to <MODULE_PREFIX>_payload_get_type : %d", ret);
          return;
   }
 
   if (type == <PAYLOAD_TYPE_DATA>) {
     <PAYLOAD_GET_DATA>
     if (ret != <ERROR_NONE>) {
-      _E("Faled to cion_payload_get_data : %d", ret);
+      _E("Faled to <MODULE_PREFIX>_payload_get_data : %d", ret);
       return;
     }
 
@@ -724,7 +724,7 @@ static void __<PREFIX>_<NAME>_data_received_cb(const char *service_name,
   }
 
   ret = rpc_port_parcel_create(&return_parcel);
-  if (ret != CION_ERROR_NONE) {
+  if (ret != <ERROR_PREFIX>_ERROR_NONE) {
     _E("Failed to create parcel handle. error(%d)", ret);
     rpc_port_parcel_destroy(parcel);
     return;
@@ -760,19 +760,18 @@ static void __<PREFIX>_<NAME>_connection_request_cb(const char *service_name,
 
 }
 
-int <PREFIX>_<NAME>_register(const char *service_name, const char *display_name, <PREFIX>_<NAME>_callback_s *callback, void *user_data)
-{
+<EXTRA>{
   int ret;
-  <SECURITY_T> security;
+  <SECURITY_T>
 
   if (callback == nullptr || callback->connection_result == nullptr || callback->disconnected == nullptr || callback->connection_request == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   if (__<NAME>.stub) {
     _E("Already exists");
-    return CION_ERROR_NONE;
+    return <ERROR_PREFIX>_ERROR_NONE;
   }
 
   g_rec_mutex_init(&__<NAME>.mutex);
@@ -781,7 +780,7 @@ int <PREFIX>_<NAME>_register(const char *service_name, const char *display_name,
 
   <SERVER_REGISTER>
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_unregister(void)
@@ -792,21 +791,21 @@ int <PREFIX>_<NAME>_unregister(void)
 
   <SERVER_UNREGISTER>
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_foreach_peer_info(<PREFIX>_<NAME>_peer_info_cb callback, void *user_data)
 {
   if (callback == nullptr) {
     _E("Invalid parameter");
-    return CION_ERROR_INVALID_PARAMETER;
+    return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   g_rec_mutex_lock(&__<NAME>.mutex);
   <SERVER_FOREACH_CONNECTED_PEER_INFO>
   g_rec_mutex_unlock(&__<NAME>.mutex);
 
-  return CION_ERROR_NONE;
+  return <ERROR_PREFIX>_ERROR_NONE;
 }
 
 int <PREFIX>_<NAME>_accept(const <PEER_INFO_T> peer_info)
@@ -815,7 +814,7 @@ int <PREFIX>_<NAME>_accept(const <PEER_INFO_T> peer_info)
 
   if (peer_info == nullptr) {
         _E("Invalid parameter");
-        return CION_ERROR_INVALID_PARAMETER;
+        return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
   <SERVER_ACCEPT>
 
@@ -828,7 +827,7 @@ int <PREFIX>_<NAME>_reject(const <PEER_INFO_T> peer_info, const char *reason)
 
   if (peer_info == nullptr) {
         _E("Invalid parameter");
-        return CION_ERROR_INVALID_PARAMETER;
+        return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
   }
 
   <SERVER_REJECT>
@@ -841,20 +840,14 @@ int <PREFIX>_<NAME>_set_display_name(const char *display_name)
   int ret;
 
   if (display_name == nullptr) {
-         _E("Invalid parameter");
-         return CION_ERROR_INVALID_PARAMETER;
+      _E("Invalid parameter");
+      return <ERROR_PREFIX>_ERROR_INVALID_PARAMETER;
    }
 
   <SERVER_SET_DISPLAY_NAME>
 
   return ret;
 }
-
-int <PREFIX>_<NAME>_set_ondemand_launch_enabled(bool enable)
-{
-  <SERVER_SET_ONDEMAND_LAUNCH_ENABLED>
-}
-
 )__c_cb";
 
 #endif  // IDLC_C_CION_GEN_C_STUB_BODY_GEN_CB_H_
index c1fc7eb1042d04d7428616607fa15292b2d769df..135f0af3241f6e2eee5f73e4eafaf2ee8808b47b 100644 (file)
@@ -22,16 +22,22 @@ namespace {
 
 namespace tidl {
 
-CCionStubHeaderGen::CCionStubHeaderGen(std::shared_ptr<Document> doc)
-    : CCionHeaderGeneratorBase(doc) {}
+CCionStubHeaderGen::CCionStubHeaderGen(std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans)
+    : CCionHeaderGeneratorBase(doc, trans) {}
 
 void CCionStubHeaderGen::OnInitGen(std::ofstream& stream) {
   GenVersion(stream);
   GenPragmaOnce(stream);
   GenIncludeDefaultHeaders(stream, false);
   GenExplicitLinkageOpen(stream);
+  GenCommonHandles(stream);
+  GenConnectionHandle(stream);
+  GenFileHandle(stream);
   GenStructureHandles(stream);
   GenInterfaceHandles(stream);
+  GenCommonBase(stream);
+  GenConnectionBase(stream);
+  GenFileBase(stream);
   GenStructures(stream);
   GenInterfaceCallbacks(stream);
   GenInterfaces(stream);
@@ -86,12 +92,14 @@ void CCionStubHeaderGen::GenInterfaceCallbacks(std::ofstream& stream) {
 void CCionStubHeaderGen::GenInterfaceCallbackBase(std::ofstream& stream,
     const Interface& iface) {
   std::string code(ReplaceAll(CB_INTERFACE_CALLBACK_BASE, {
-      { "<PREFIX>", GetHandlePrefix() },
       { "<NAME>", iface.GetID() },
       { "<PEER_INFO_T>", GetTransportable().C().GenPeerInfoType() },
       { "<PAYLOAD_T>", GetTransportable().C().GenPayloadType() },
       { "<PAYLOAD_TRANSFER_STATUS_T>",
-          GetTransportable().C().GenPayloadTransferStatusType() }
+          GetTransportable().C().GenPayloadTransferStatusType() },
+      { "<MODULE_PREFIX>", GetMoudlePrefix() },
+      { "<ERROR_PREFIX>", GetTransportable().C().GenErrorPrefix() },
+      { "<PREFIX>", GetHandlePrefix() },
   }));
 
   stream << SmartIndent(code);
@@ -116,11 +124,12 @@ void CCionStubHeaderGen::GenInterfaceMethodCallbackBase(std::ofstream& stream,
     const Interface& iface, const Declaration& decl) {
   std::string code(ReplaceAll(CB_INTERFACE_METHOD_CALLBACK_BASE, {
       { "<RETURN_TYPE>", GetReturnTypeString(decl.GetType()) },
-      { "<PREFIX>", GetHandlePrefix() },
       { "<NAME>", iface.GetID() },
       { "<METHOD_NAME>", decl.GetID() },
       { "<METHOD_PARAMS>", GenMethodParams(iface, decl) },
-      { "<PEER_INFO_T>", GetTransportable().C().GenPeerInfoType() }
+      { "<PEER_INFO_T>", GetTransportable().C().GenPeerInfoType() },
+      { "<MODULE_PREFIX>", GetMoudlePrefix() },
+      { "<PREFIX>", GetHandlePrefix() }
   }));
 
   stream << SmartIndent(code);
@@ -165,10 +174,11 @@ std::string CCionStubHeaderGen::GenDelegateParams(const Interface& iface,
 void CCionStubHeaderGen::GenInterfaceDelegateBase(std::ofstream& stream,
     const Interface& iface, const Declaration& decl) {
   std::string code(ReplaceAll(CB_INTERFACE_DELEGATE_BASE, {
-      { "<PREFIX>", GetHandlePrefix() },
       { "<NAME>", iface.GetID() },
       { "<DELEGATE_NAME>", decl.GetID() },
-      { "<DELEGATE_PARAMS>", GenDelegateParams(iface, decl) }
+      { "<DELEGATE_PARAMS>", GenDelegateParams(iface, decl) },
+      { "<ERROR_PREFIX>", GetTransportable().C().GenErrorPrefix() },
+      { "<PREFIX>", GetHandlePrefix() }
   }));
 
   stream << SmartIndent(code);
@@ -199,10 +209,13 @@ std::string CCionStubHeaderGen::GenMethodCallbackDecls(const Interface& iface) {
 void CCionStubHeaderGen::GenInterfaceBase(std::ofstream& stream,
     const Interface& iface) {
   std::string code(ReplaceAll(CB_INTERFACE_BASE, {
-      { "<PREFIX>", GetHandlePrefix() },
+      { "<EXTRA>", GetTransportable().C().GenServerExtra(false) },
       { "<NAME>", iface.GetID() },
       { "<METHOD_CALLBACK_DECLS>", GenMethodCallbackDecls(iface) },
-      { "<PEER_INFO_T>", GetTransportable().C().GenPeerInfoType() }
+      { "<PEER_INFO_T>", GetTransportable().C().GenPeerInfoType() },
+      { "<ERROR_PREFIX>", GetTransportable().C().GenErrorPrefix() },
+      { "<MODULE_PREFIX>", GetMoudlePrefix() },
+      { "<PREFIX>", GetHandlePrefix() }
   }));
 
   stream << SmartIndent(code);
index 7f4c539e2a7fbd6adefc1cf2697149670859a677..2ada031f2ea99fe2bdb12aa68445d2f7088fde68 100644 (file)
@@ -26,7 +26,7 @@ namespace tidl {
 
 class CCionStubHeaderGen : public CCionHeaderGeneratorBase {
  public:
-  explicit CCionStubHeaderGen(std::shared_ptr<Document> doc);
+  explicit CCionStubHeaderGen(std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans);
   virtual ~CCionStubHeaderGen() = default;
 
   void OnInitGen(std::ofstream& stream) override;
index 44a80da549587cefb5b27d8a23ab3b8732a76bfc..7dcf3fd8d2dc26fbb1a9702995f3e2582c1c6549 100644 (file)
@@ -44,9 +44,9 @@ R"__c_cb(
  * @param[out] h The <PREFIX>_<NAME>_<DELEGATE_NAME> handle
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY Out of memory
  * @see <PREFIX>_<NAME>_<DELEGATE_NAME>_destroy()
  */
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_create(<PREFIX>_<NAME>_<DELEGATE_NAME>_h *h);
@@ -57,8 +57,8 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_create(<PREFIX>_<NAME>_<DELEGATE_NAME>_h *h)
  * @param[in] h The <PREFIX>_<NAME>_<DELEGATE_NAME> handle
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
  * @see <PREFIX>_<NAME>_<DELEGATE_NAME>_clone()
  */
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_destroy(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h);
@@ -72,9 +72,9 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_destroy(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h)
  * @param[out] clone If successful, a new created <PREFIX>_<NAME>_<DELEGATE_NAME> handle will be returned
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY Out of memory
  * @see <PREFIX>_<NAME>_<DELEGATE_NAME>_destroy()
  */
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_clone(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, <PREFIX>_<NAME>_<DELEGATE_NAME>_h *clone);
@@ -86,8 +86,8 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_clone(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, <
  * @param[out] id The ID
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
  */
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_get_id(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, int *id);
 
@@ -98,8 +98,8 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_get_id(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h,
  * @param[out] seq_id The Sequence ID
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
  */
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_get_seq_id(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, int *seq_id);
 
@@ -110,8 +110,8 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_get_seq_id(<PREFIX>_<NAME>_<DELEGATE_NAME>_h
  * @param[out] once The flag, it's true, the handle is for one-time
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
  */
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_is_once(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, bool *once);
 
@@ -123,9 +123,9 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_is_once(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h,
  * @param[out] tag The tag
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY Out of memory
  */
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_get_tag(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h, char **tag);
 
@@ -136,10 +136,10 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_get_tag(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h,
  * @param[in] ...
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CION_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #CION_ERROR_IO_ERROR I/O error
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #<ERROR_PREFIX>_ERROR_IO_ERROR I/O error
  */
 int <PREFIX>_<NAME>_<DELEGATE_NAME>_invoke(<PREFIX>_<NAME>_<DELEGATE_NAME>_h h<DELEGATE_PARAMS>);
 )__c_cb";
@@ -154,25 +154,25 @@ R"__c_cb(
  * @brief Called when the proxy is connected.
  * @details The callback function is called when the proxy is connected to the stub.
  *
- * @param[in] peer_info The Cion peer information handle
+ * @param[in] peer_info The <MODULE_PREFIX> peer information handle
  *            The @a peer_info can be used only in the callback. To use outside, make a copy.
  * @param[in] result The handle for connection result
  * @param[in] user_data The user data passed from the registration function
  * @see #<PREFIX>_<NAME>_callback_s
- * @see #cion_peer_info_clone()
+ * @see #<MODULE_PREFIX>_peer_info_clone()
  */
 typedef void (*<PREFIX>_<NAME>_connection_result_cb)(const <PEER_INFO_T> peer_info,
-    const cion_connection_result_h result, void *user_data);
+    const <MODULE_PREFIX>_connection_result_h result, void *user_data);
 
 /**
  * @brief Called when the proxy is disconnected.
  * @details The callback function is called when the proxy is disconnected from the stub.
  *
- * @param[in] peer_info The Cion peer information handle
+ * @param[in] peer_info The <MODULE_PREFIX> peer information handle
  *            The @a peer_info can be used only in the callback. To use outside, make a copy.
  * @param[in] user_data The user data passed from the registration function
  * @see #<PREFIX>_<NAME>_callback_s
- * @see #cion_peer_info_clone()
+ * @see #<MODULE_PREFIX>_peer_info_clone()
  */
 typedef void (*<PREFIX>_<NAME>_disconnected_cb)(const <PEER_INFO_T> peer_info, void *user_data);
 
@@ -191,7 +191,7 @@ typedef bool (*<PREFIX>_<NAME>_peer_info_cb)(const <PEER_INFO_T> peer_info, void
 /**
  * @brief Called when the payload is received.
  *
- * @param[in] peer_info The Cion peer information handle \n
+ * @param[in] peer_info The <MODULE_PREFIX> peer information handle \n
  *            The @a peer_info can be used only in the callback. To use outside, make a copy.
  * @param[in] payload The received payload \n
  *            The @a payload can be used only in the callback. \n
@@ -199,13 +199,13 @@ typedef bool (*<PREFIX>_<NAME>_peer_info_cb)(const <PEER_INFO_T> peer_info, void
  * @param[in] status The status of transfer
  * @param[in] user_data The user data passed from the registeration function
  * @see #<PREFIX>_<NAME>_callback_s
- * @see #cion_peer_info_clone()
+ * @see #<MODULE_PREFIX>_peer_info_clone()
  *
  * @par Sample code:
  * @code
 
 void <PREFIX>_<NAME>__file_received_cb(const <PEER_INFO_T> peer_info, const <PAYLOAD_T> payload,
-               <PAYLOAD_TRANSFER_STATUS_T> status, void *user_data)
+    <PAYLOAD_TRANSFER_STATUS_T> status, void *user_data)
 {
   <PREFIX>_<NAME>_h handle = user_data;
 
@@ -215,12 +215,12 @@ void <PREFIX>_<NAME>__file_received_cb(const <PEER_INFO_T> peer_info, const <PAY
   uint64_t bytes, total;
   char data_path_buff[512];
 
-  cion_peer_info_get_app_id(peer_info, &app_id);
-  cion_payload_get_total_bytes(payload, &total);
-  cion_payload_get_received_bytes(payload, &bytes);
-  cion_payload_get_received_file_name(payload, &file_name);
+  <MODULE_PREFIX>_peer_info_get_app_id(peer_info, &app_id);
+  <MODULE_PREFIX>_payload_get_total_bytes(payload, &total);
+  <MODULE_PREFIX>_payload_get_received_bytes(payload, &bytes);
+  <MODULE_PREFIX>_payload_get_received_file_name(payload, &file_name);
 
-  if (status == CION_PAYLOAD_TRANSFER_STATUS_SUCCESS) {
+  if (status == <ERROR_PREFIX>_PAYLOAD_TRANSFER_STATUS_SUCCESS) {
     data_path = app_get_data_path();
     if (data_path == NULL) {
       LOGE("failed to get data path.");
@@ -228,7 +228,7 @@ void <PREFIX>_<NAME>__file_received_cb(const <PEER_INFO_T> peer_info, const <PAY
       }
 
     snprintf(data_path_buff, 512, "%s%s", data_path, file_name);
-    ret = cion_payload_save_as_file(payload, data_path_buff);
+    ret = <MODULE_PREFIX>_payload_save_as_file(payload, data_path_buff);
     free(data_path);
     LOGI("save file %s : %d", data_path_buff, ret);
   } else {
@@ -249,11 +249,11 @@ typedef void (*<PREFIX>_<NAME>_file_received_cb)(const <PEER_INFO_T> peer_info,
 /**
  * @brief Called when a connection is requested.
  * @since_tizen 6.5
- * @param[in] peer_info The Cion peer information handle \n
+ * @param[in] peer_info The <MODULE_PREFIX> peer information handle \n
  *            The @a peer_info can be used only in the callback. To use outside, make a copy.
  * @param[in] user_data The user data passed from the registration function
  * @see #<PREFIX>_<NAME>_register()
- * @see #cion_peer_info_clone()
+ * @see #<MODULE_PREFIX>_peer_info_clone()
  *
  * @par Sample code:
  * @code
@@ -263,7 +263,7 @@ void <PREFIX>_<NAME>_connection_request_cb(const <PEER_INFO_T> peer_info, void *
 
   char *app_version = NULL;
 
-  cion_peer_info_get_app_version(peer_info, &app_version);
+  <MODULE_PREFIX>_peer_info_get_app_version(peer_info, &app_version);
 
   if(strcmp(app_version, "1.1") == 0) {
     <PREFIX>_<NAME>_accept(peer_info);
@@ -320,30 +320,7 @@ typedef struct {
   <METHOD_CALLBACK_DECLS>
 } <PREFIX>_<NAME>_callback_s;
 
-/**
- * @brief Registers the set of the callback functions and the service_name.
- * @details This function registers the set of the callback functions to handle stub events.
- *          And, the cion_server_listen() is called internally to handle events.
-
- * @privilege http://tizen.org/privilege/d2d.datasharing
- * @param[in] service_name The name of service
- * @param[in] display_name The display name of service
- * @param[in] callback The set of callback functions to handle stub events
- * @param[in] user_data The user data to be passed to the callback function
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_NOT_SUPPORTED Not supported
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CION_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #CION_ERROR_IO_ERROR IO error
- * @retval #CION_ERROR_INVALID_OPERATION Invalid operation
- * @retval #CION_ERROR_OPERATION_FAILED Operation failed
- * @retval #CION_ERROR_PERMISSION_DENIED Permission denied
- * @see <PREFIX>_<NAME>_unregister()
- * @see #<PREFIX>_<NAME>_callback_s
- */
-int <PREFIX>_<NAME>_register(const char *service_name, const char *display_name, <PREFIX>_<NAME>_callback_s *callback, void *user_data);
+<EXTRA>
 
 /**
  * @brief Unregisters the registered service_name.
@@ -357,8 +334,8 @@ int <PREFIX>_<NAME>_unregister(void);
  * @param[in] user_data The user data to be passed to the callback function
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
  * @see <PREFIX>_<NAME>_peer_info_cb()
  */
 int <PREFIX>_<NAME>_foreach_peer_info(<PREFIX>_<NAME>_peer_info_cb callback, void *user_data);
@@ -366,11 +343,11 @@ int <PREFIX>_<NAME>_foreach_peer_info(<PREFIX>_<NAME>_peer_info_cb callback, voi
 /**
  * @brief Accepts the connection request from a peer.
 
- * @param[in] peer_info The Cion peer information handle
+ * @param[in] peer_info The <MODULE_PREFIX> peer information handle
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
  * @see   <PREFIX>_<NAME>_register()
  * @see   <PREFIX>_<NAME>_connection_request_cb()
  */
@@ -379,12 +356,12 @@ int <PREFIX>_<NAME>_accept(const <PEER_INFO_T> peer_info);
 /**
  * @brief Rejects the connection request from a peer.
 
- * @param[in] peer_info The Cion peer information handle
+ * @param[in] peer_info The <MODULE_PREFIX> peer information handle
  * @param[in] reason The reason of reject
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
  * @see   <PREFIX>_<NAME>_register()
  * @see   <PREFIX>_<NAME>_connection_request_cb()
  */
@@ -397,31 +374,14 @@ int <PREFIX>_<NAME>_reject(const <PEER_INFO_T> peer_info, const char *reason);
  * @param[in] display_name The display name
  * @return @c 0 on success,
  *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CION_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #CION_ERROR_IO_ERROR IO error
- * @see   cion_peer_info_get_display_name()
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #<ERROR_PREFIX>_ERROR_IO_ERROR IO error
+ * @see   <MODULE_PREFIX>_peer_info_get_display_name()
  */
 int <PREFIX>_<NAME>_set_display_name(const char *display_name);
 
-/**
- * @brief Sets on-demand launch state.
- * @details If the on-demand launch state is enabled, the server is launched on demand
- *          when the request comes.
- * @privilege http://tizen.org/privilege/d2d.remotelaunch
-
- * @param[in] enabled The enable state
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #CION_ERROR_NONE Successful
- * @retval #CION_ERROR_PERMISSION_DENIED Permission denied
- * @retval #CION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CION_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #CION_ERROR_IO_ERROR IO error
- */
-int <PREFIX>_<NAME>_set_ondemand_launch_enabled(bool enable);
-
 )__c_cb";
 
 /**
index c8a3d83bb63417f482f91418f3fb535ae77f5c41..b245c45c876fb8aadccddbe02a65ab7fc0427c0c 100644 (file)
@@ -25,7 +25,24 @@ namespace tidl {
 class CTransportable {
  public:
   virtual ~CTransportable() = default;
-  virtual std::string GenInclude() const = 0;
+  virtual std::string GenInclude(bool body = true, int type = 0) const = 0;
+  virtual std::string GenHeaderBase() const = 0;
+  virtual std::string GenHeaderPayloadHandle() const = 0;
+  virtual std::string GenHeaderCommonHandle() const = 0;
+  virtual std::string GenHeaderConnectionHandle() const = 0;
+  virtual std::string GenHeaderPayloadBase() const = 0;
+  virtual std::string GenHeaderConnectionBase() const = 0;
+  virtual std::string GenBodyPayloadBase() const = 0;
+  virtual std::string GenBodyConnectionBase() const = 0;
+  virtual std::string GenBodyPeerInfoBase() const = 0;
+  virtual std::string GenProxyPrefix() const = 0;
+  virtual std::string GenStubPrefix() const = 0;
+  virtual std::string GenGroupPrefix() const = 0;
+  virtual std::string GenModulePrefix() const = 0;
+  virtual std::string GenErrorPrefix() const = 0;
+       virtual std::string GenServerExtra(bool body = true) const = 0;
+  virtual std::string GenClientExtra(bool body = true) const = 0;
+  virtual std::string GenGroupExtra(bool body = true) const = 0;
   virtual std::string GenClientSendAsync(std::string client,
       std::string payload, std::string size) const = 0;
   virtual std::string GenClientSend(std::string client, std::string data,
@@ -38,12 +55,12 @@ class CTransportable {
   virtual std::string GenClientFileSend(std::string path,
       std::string client) const = 0;
   virtual std::string GenGroupType() const = 0;
-  virtual std::string GenPayloadTransferStatusType() const = 0;
+  virtual std::string GenPayloadTransferStatusType(bool internal_type = false) const = 0;
   virtual std::string GenPeerInfoType() const = 0;
   virtual std::string GenPeerInfoDestroy(std::string peer) const = 0;
-  virtual std::string GenPayloadType() const = 0;
+  virtual std::string GenPayloadType(bool internal_type = false) const = 0;
   virtual std::string GenClientType() const = 0;
-  virtual std::string GenSecurityType() const = 0;
+  virtual std::string GenSecurityType(bool definition = true) const = 0;
   virtual std::string GenServerType() const = 0;
   virtual std::string GenClientTryConnect(std::string client,
       std::string peer) const = 0;
@@ -76,7 +93,6 @@ class CTransportable {
   virtual std::string GenPeerInfoClone(std::string src_peer,
       std::string dest_peer) const = 0;
   virtual std::string GenServerForeachConnectedPeerInfo(std::string name) const = 0;
-  virtual std::string GenServerSetOnDemandLaunchEnabled(std::string name) const = 0;
 };
 
 }  // namespace tidl
index 091313f2b6eb98a3edd06c96ee9f57dc61ae68f6..03124cb9869f7a62d400d49f4ae5c78a9e4ef42a 100644 (file)
@@ -22,9 +22,9 @@
 
 namespace tidl {
 
-CionPluginBase::CionPluginBase(std::shared_ptr<Document> doc)
+CionPluginBase::CionPluginBase(std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans)
     : Generator(std::move(doc)) {
-  transportable_.reset(new PluginLoader(""));
+  transportable_ = trans;
 }
 
 Transportable& CionPluginBase::GetTransportable() {
index 54a8008668ffed321e86886b0da288f3570be53e..045c84a04735b7e71c5ef0895409448dd4a2f443 100644 (file)
@@ -26,13 +26,13 @@ namespace tidl {
 
 class CionPluginBase : public Generator {
  public:
-  explicit CionPluginBase(std::shared_ptr<Document> doc);
+  explicit CionPluginBase(std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans);
   virtual ~CionPluginBase() = default;
 
   Transportable& GetTransportable();
 
  private:
-  std::unique_ptr<Transportable> transportable_;
+  std::shared_ptr<tidl::Transportable> transportable_;
 };
 
 }  // namespace tidl
index c9c3ec3aed9ffde2543d9b4c6f49cb60cce78681..b72fefeb45ecfee4f45a491a30b448bab735c742 100644 (file)
@@ -26,8 +26,8 @@ namespace {
 
 namespace tidl {
 
-CppCionGeneratorBase::CppCionGeneratorBase(std::shared_ptr<Document> doc)
-    : CionPluginBase(doc) {
+CppCionGeneratorBase::CppCionGeneratorBase(std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans)
+    : CionPluginBase(doc, trans) {
   type_map_ = {
       {"char", "char"}, {"int", "int"}, {"short", "short"},
       {"long", "long long"}, {"string", "std::string"}, {"bool", "bool"},
index c9f3daf2744a0ff08285736a60f6a4dd40460ffa..166de85329051aa6e36bdd5ad51a25461925a9aa 100644 (file)
@@ -29,7 +29,7 @@ namespace tidl {
 
 class CppCionGeneratorBase : public CionPluginBase {
  public:
-  explicit CppCionGeneratorBase(std::shared_ptr<Document> doc);
+  explicit CppCionGeneratorBase(std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans);
   virtual ~CppCionGeneratorBase() = default;
 
   void GenVersion(std::ofstream& stream);
index e497b1a49d045071e8f83b2f6043e2a35fb272e8..5b7140806cf251be541c4baaea8d5d589a2c7664 100644 (file)
@@ -22,8 +22,9 @@ namespace {
 
 namespace tidl {
 
-CppCionGroupBodyGen::CppCionGroupBodyGen(std::shared_ptr<Document> doc)
-    : CppCionGeneratorBase(doc) {}
+CppCionGroupBodyGen::CppCionGroupBodyGen(std::shared_ptr<Document> doc,
+    std::shared_ptr<tidl::Transportable> trans)
+    : CppCionGeneratorBase(doc, trans) {}
 
 void CppCionGroupBodyGen::OnInitGen(std::ofstream& stream) {
   std::string key(".cc");
index 2a49d7ad19b7169b17ef0895440a0cc4fd332a90..a1a5a8cf47548ea28ec1c635e1a4208ec7d32f78 100644 (file)
@@ -26,7 +26,8 @@ namespace tidl {
 
 class CppCionGroupBodyGen : public CppCionGeneratorBase {
  public:
-  explicit CppCionGroupBodyGen(std::shared_ptr<Document> doc);
+  explicit CppCionGroupBodyGen(std::shared_ptr<Document> doc,
+      std::shared_ptr<tidl::Transportable> trans);
   virtual ~CppCionGroupBodyGen() = default;
 
   void OnInitGen(std::ofstream& stream) override;
index 3f5d89451ee3d5adb44cfe2e5452817f03922c79..6cb9ff01b4dbd91fd02978701fced13cbf153713 100644 (file)
@@ -22,8 +22,8 @@ namespace {
 
 namespace tidl {
 
-CppCionGroupHeaderGen::CppCionGroupHeaderGen(std::shared_ptr<Document> doc)
-    : CppCionGeneratorBase(doc) {}
+CppCionGroupHeaderGen::CppCionGroupHeaderGen(std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans)
+    : CppCionGeneratorBase(doc, trans) {}
 
 void CppCionGroupHeaderGen::OnInitGen(std::ofstream& stream) {
   GenVersion(stream);
index 297f66679f81635768d9fb6ed695ca70612ea3c6..e9d14f0e9a7e8db0d04733042234192f4d4ba50a 100644 (file)
@@ -26,7 +26,8 @@ namespace tidl {
 
 class CppCionGroupHeaderGen : public CppCionGeneratorBase {
  public:
-  explicit CppCionGroupHeaderGen(std::shared_ptr<Document> doc);
+  explicit CppCionGroupHeaderGen(std::shared_ptr<Document> doc,
+    std::shared_ptr<tidl::Transportable> trans);
   virtual ~CppCionGroupHeaderGen() = default;
 
   void OnInitGen(std::ofstream& stream) override;
index e630eaff7d710736570ae1466774fabffae08b9f..2de06d2cc462ff17a9819a4bb1c9cbfe9f8acde6 100644 (file)
@@ -22,8 +22,8 @@ namespace {
 
 namespace tidl {
 
-CppCionProxyBodyGen::CppCionProxyBodyGen(std::shared_ptr<Document> doc)
-    : CppCionGeneratorBase(doc) {}
+CppCionProxyBodyGen::CppCionProxyBodyGen(std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans)
+    : CppCionGeneratorBase(doc, trans) {}
 
 void CppCionProxyBodyGen::OnInitGen(std::ofstream& stream) {
   std::string key(".cc");
index da42e1a7325ebe1d6051fe1bcd7834a34c3e0f59..64e6218aae2291f153430a228315b75de3d92478 100644 (file)
@@ -26,7 +26,8 @@ namespace tidl {
 
 class CppCionProxyBodyGen : public CppCionGeneratorBase {
  public:
-  explicit CppCionProxyBodyGen(std::shared_ptr<Document> doc);
+  explicit CppCionProxyBodyGen(std::shared_ptr<Document> doc,
+      std::shared_ptr<tidl::Transportable> trans);
   virtual ~CppCionProxyBodyGen() = default;
 
   void OnInitGen(std::ofstream& stream) override;
index d57b9c8e5493a535904f66c13a21175313583b3e..c23071fab768a5dd7c794783b39a879a6dc3305d 100644 (file)
@@ -22,8 +22,9 @@ namespace {
 
 namespace tidl {
 
-CppCionProxyHeaderGen::CppCionProxyHeaderGen(std::shared_ptr<Document> doc)
-    : CppCionGeneratorBase(doc) {}
+CppCionProxyHeaderGen::CppCionProxyHeaderGen(std::shared_ptr<Document> doc,
+    std::shared_ptr<tidl::Transportable> trans)
+    : CppCionGeneratorBase(doc, trans) {}
 
 void CppCionProxyHeaderGen::OnInitGen(std::ofstream& stream) {
   GenVersion(stream);
index c9eba7ca3241000e38d9422f9e34bb4949840338..11c5b921f5256910ae9a6ef6b75183bd117fccfb 100644 (file)
@@ -26,7 +26,8 @@ namespace tidl {
 
 class CppCionProxyHeaderGen : public CppCionGeneratorBase {
  public:
-  explicit CppCionProxyHeaderGen(std::shared_ptr<Document> doc);
+  explicit CppCionProxyHeaderGen(std::shared_ptr<Document> doc,
+      std::shared_ptr<tidl::Transportable> trans);
   virtual ~CppCionProxyHeaderGen() = default;
 
   void OnInitGen(std::ofstream& stream) override;
index 14a2250f6d7d1c5b76f2d0600b89e91c48abd03f..34c1b516eb215571eb532a0e3ff41248c865bfe4 100644 (file)
@@ -23,8 +23,8 @@ namespace {
 namespace tidl {
 
 CppCionStubBodyGen::CppCionStubBodyGen(std::shared_ptr<Document> doc,
-    std::shared_ptr<Options> options)
-    : CppCionGeneratorBase(doc), options_(options) {}
+    std::shared_ptr<Options> options, std::shared_ptr<tidl::Transportable> trans)
+    : CppCionGeneratorBase(doc, trans), options_(options) {}
 
 void CppCionStubBodyGen::OnInitGen(std::ofstream& stream) {
   std::string key(".cc");
index 747aa68bd1b111c16cae382bafe405bc46b516fb..3d3e129d8331136c6cb2fb83a0d0daa08738f5d3 100644 (file)
@@ -27,7 +27,8 @@ namespace tidl {
 
 class CppCionStubBodyGen : public CppCionGeneratorBase {
  public:
-  explicit CppCionStubBodyGen(std::shared_ptr<Document> doc, std::shared_ptr<Options> options);
+  explicit CppCionStubBodyGen(std::shared_ptr<Document> doc,
+      std::shared_ptr<Options> options, std::shared_ptr<tidl::Transportable> trans);
   virtual ~CppCionStubBodyGen() = default;
 
   void OnInitGen(std::ofstream& stream) override;
index e6353d10c4adf70c38f5f622010ea17842072a7c..fe17b74f14e77753c2f3f78e66d7fd58498cdd3c 100644 (file)
@@ -23,8 +23,8 @@ namespace {
 namespace tidl {
 
 CppCionStubHeaderGen::CppCionStubHeaderGen(std::shared_ptr<Document> doc,
-      std::shared_ptr<Options> options)
-    : CppCionGeneratorBase(doc), options_(options) {}
+      std::shared_ptr<Options> options, std::shared_ptr<tidl::Transportable> trans)
+    : CppCionGeneratorBase(doc, trans), options_(options) {}
 
 void CppCionStubHeaderGen::OnInitGen(std::ofstream& stream) {
   GenVersion(stream);
index 634217bfecc72e70848d35799ffacde51f5db5f4..6f63b823d76b7c0f526bfe82101eba2ca8367489 100644 (file)
@@ -28,7 +28,7 @@ namespace tidl {
 class CppCionStubHeaderGen : public CppCionGeneratorBase {
  public:
   explicit CppCionStubHeaderGen(std::shared_ptr<Document> doc,
-      std::shared_ptr<Options> options);
+      std::shared_ptr<Options> options, std::shared_ptr<tidl::Transportable> trans);
   virtual ~CppCionStubHeaderGen() = default;
 
   void OnInitGen(std::ofstream& stream) override;
index 8a7d9a37affab817c3202b73204fbd4043e20cb4..419f456911212ceb30fe3e73395c16e8b9de9e9f 100644 (file)
@@ -26,8 +26,9 @@ namespace {
 
 namespace tidl {
 
-CsCionGeneratorBase::CsCionGeneratorBase(std::shared_ptr<Document> doc)
-    : CionPluginBase(std::move(doc)) {
+CsCionGeneratorBase::CsCionGeneratorBase(std::shared_ptr<Document> doc,
+    std::shared_ptr<tidl::Transportable> trans)
+    : CionPluginBase(std::move(doc), trans) {
   type_map_ = {
       {"char", "byte"}, {"int", "int"}, {"short", "short"},
       {"long", "long"}, {"string", "string"}, {"bool", "bool"},
index ee847fec870c7163cc649d7f24aa14d7ef6b04ce..27def6336279caa9440b6fc55277e09453818fed 100644 (file)
@@ -29,7 +29,8 @@ namespace tidl {
 
 class CsCionGeneratorBase : public CionPluginBase {
  public:
-  explicit CsCionGeneratorBase(std::shared_ptr<Document> doc);
+  explicit CsCionGeneratorBase(std::shared_ptr<Document> doc,
+      std::shared_ptr<tidl::Transportable> trans);
   virtual ~CsCionGeneratorBase() = default;
 
   void GenVersion(std::ofstream& stream);
index 3aa49a94face998a3965b992abd245815851786e..1a0d7956adc4a7f3c9995648f924b39bf59365bd 100644 (file)
@@ -22,8 +22,9 @@ namespace {
 
 namespace tidl {
 
-CsCionGroupGen::CsCionGroupGen(std::shared_ptr<Document> doc)
-    : CsCionGeneratorBase(doc) {}
+CsCionGroupGen::CsCionGroupGen(std::shared_ptr<Document> doc,
+    std::shared_ptr<tidl::Transportable> trans)
+    : CsCionGeneratorBase(doc, trans) {}
 
 void CsCionGroupGen::OnInitGen(std::ofstream& stream) {
   GenVersion(stream);
index 61bb288de97162b58db983b17b85aa54401d3219..413888bbee3b8979477f0b5620610d4f1bb447a4 100644 (file)
@@ -26,7 +26,8 @@ namespace tidl {
 
 class CsCionGroupGen : public CsCionGeneratorBase {
  public:
-  explicit CsCionGroupGen(std::shared_ptr<Document> doc);
+  explicit CsCionGroupGen(std::shared_ptr<Document> doc,
+      std::shared_ptr<tidl::Transportable> trans);
   virtual ~CsCionGroupGen() = default;
 
   void OnInitGen(std::ofstream& stream) override;
index d3c69c405c81422e16dd780aa0b6cd570f341eae..7e7a421e0bda179d32fe94a97628cc8e1602694e 100644 (file)
@@ -22,8 +22,9 @@ namespace {
 
 namespace tidl {
 
-CsCionProxyGen::CsCionProxyGen(std::shared_ptr<Document> doc)
-    : CsCionGeneratorBase(doc) {}
+CsCionProxyGen::CsCionProxyGen(std::shared_ptr<Document> doc,
+    std::shared_ptr<tidl::Transportable> trans)
+    : CsCionGeneratorBase(doc, trans) {}
 
 void CsCionProxyGen::OnInitGen(std::ofstream& stream) {
   GenVersion(stream);
index df3eeec40e0522f4901bea1ea5ffd7cfb4fc921c..f2e4262fef0c2c6c7979c09cf0747f68c9b7f7de 100644 (file)
@@ -26,7 +26,8 @@ namespace tidl {
 
 class CsCionProxyGen : public CsCionGeneratorBase {
  public:
-  explicit CsCionProxyGen(std::shared_ptr<Document> doc);
+  explicit CsCionProxyGen(std::shared_ptr<Document> doc,
+      std::shared_ptr<tidl::Transportable> trans);
   virtual ~CsCionProxyGen() = default;
 
   void OnInitGen(std::ofstream& stream) override;
index b47f572d0b8dc15c70f3f37853d0d9ecb7f57157..b2b7ac64656f9305454fb23a34ec92d21ffdd156 100644 (file)
@@ -22,8 +22,9 @@ namespace {
 
 namespace tidl {
 
-CsCionStubGen::CsCionStubGen(std::shared_ptr<Document> doc)
-    : CsCionGeneratorBase(doc) {}
+CsCionStubGen::CsCionStubGen(std::shared_ptr<Document> doc,
+    std::shared_ptr<tidl::Transportable> trans)
+    : CsCionGeneratorBase(doc, trans) {}
 
 void CsCionStubGen::OnInitGen(std::ofstream& stream) {
   GenVersion(stream);
index eab7cb690f9a5ad48fba94887b257f3e875b88a4..20d3b85c26d83d6127f399975ccb5f784135d0cf 100644 (file)
@@ -26,7 +26,8 @@ namespace tidl {
 
 class CsCionStubGen : public CsCionGeneratorBase {
  public:
-  explicit CsCionStubGen(std::shared_ptr<Document> doc);
+  explicit CsCionStubGen(std::shared_ptr<Document> doc,
+      std::shared_ptr<tidl::Transportable> trans);
   virtual ~CsCionStubGen() = default;
 
   void OnInitGen(std::ofstream& stream) override;
index a858a97289a5567b4aebbac659fd33d8f309b528..081f90e036e3eabc13653609339931d4ed976129 100644 (file)
@@ -420,8 +420,56 @@ constexpr const char __PEER_INFO_CLONE[] =
 constexpr const char __SERVER_FOREACH_CONNECTED_PEER_INFO[] =
     "cion_server_foreach_connected_peer_info(__<NAME>.stub, callback, user_data);";
 
-constexpr const char __SERVER_SET_ONDEMAND_LAUNCH_ENABLED[] =
+constexpr const char __SERVER_HEADER_EXTRA[] =
 R"__c_cb(
+/**
+ * @brief Sets on-demand launch state.
+ * @details If the on-demand launch state is enabled, the server is launched on demand
+ *          when the request comes.
+ * @privilege http://tizen.org/privilege/d2d.remotelaunch
+
+ * @param[in] enabled The enable state
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #<ERROR_PREFIX>_ERROR_IO_ERROR IO error
+ */
+int <PREFIX>_<NAME>_set_ondemand_launch_enabled(bool enable);
+
+/**
+ * @brief Registers the set of the callback functions and the service_name.
+ * @details This function registers the set of the callback functions to handle stub events.
+ *          And, the <PREFIX>_server_listen() is called internally to handle events.
+
+ * @privilege %http://tizen.org/privilege/d2d.datasharing \n
+ *            %http://tizen.org/privilege/internet
+ * @param[in] service_name The name of service
+ * @param[in] display_name The display name of service
+ * @param[in] callback The set of callback functions to handle stub events
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_NOT_SUPPORTED Not supported
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #<ERROR_PREFIX>_ERROR_IO_ERROR IO error
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #<ERROR_PREFIX>_ERROR_OPERATION_FAILED Operation failed
+ * @retval #<ERROR_PREFIX>_ERROR_PERMISSION_DENIED Permission denied
+ * @see <PREFIX>_<NAME>_unregister()
+ * @see #<PREFIX>_<NAME>_callback_s
+ */
+int <PREFIX>_<NAME>_register(const char *service_name, const char *display_name, <PREFIX>_<NAME>_callback_s *callback, void *user_data);
+)__c_cb";
+
+constexpr const char __SERVER_BODY_EXTRA[] =
+R"__c_cb(
+int <PREFIX>_<NAME>_set_ondemand_launch_enabled(bool enable)
+{
   int ret;
 
   ret = cion_server_set_on_demand_launch_enabled(__<NAME>.stub, enable);
@@ -429,16 +477,159 @@ R"__c_cb(
     _E("Failed to set ondemand launch enable. error(%d)", ret);
 
   return ret;
+}
+
+int <PREFIX>_<NAME>_register(const char *service_name, const char *display_name, <PREFIX>_<NAME>_callback_s *callback, void *user_data)
+)__c_cb";
+
+constexpr const char __CLIENT_HEADER_EXTRA[] =
+R"__c_cb(
+/**
+ * @brief Creates a <PREFIX>_<NAME> handle.
+ * @remarks The @a h handle should be released using
+ *          the <PREFIX>_<NAME>_destroy() if it's no longer needed.
+ * @privilege %http://tizen.org/privilege/d2d.datasharing \n
+ *            %http://tizen.org/privilege/internet
+ * @param[in] service_name The name of service
+ * @param[in] callback The set of callback functions to handle proxy events
+ * @param[in] user_data The user data to be passed to the callback function
+ * @param[out] h The <PREFIX>_<NAME> handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #<ERROR_PREFIX>_ERROR_PERMISSION_DENIED Permission denied
+ * @see <PREFIX>_<NAME>_destroy()
+ * @see #<PREFIX>_<NAME>_callback_s
+ */
+int <PREFIX>_<NAME>_create(const char *service_name, <PREFIX>_<NAME>_callback_s *callback, void *user_data, <PREFIX>_<NAME>_h *h);
+
+)__c_cb";
+
+constexpr const char __CLIENT_BODY_EXTRA[] =
+R"__c_cb(
+int <PREFIX>_<NAME>_create(const char *service_name, <PREFIX>_<NAME>_callback_s *callback, void *user_data, <PREFIX>_<NAME>_h *h)
+)__c_cb";
+
+constexpr const char __GROUP_HEADER_EXTRA[] =
+R"__c_cb(
+/**
+ * @brief Creates a <PREFIX>_<NAME> handle.
+ * @remarks The @a h handle should be released using
+ *          the <PREFIX>_<NAME>_destroy() if it's no longer needed.
+ *
+ * @privilege %http://tizen.org/privilege/d2d.datasharing
+ *            %http://tizen.org/privilege/internet
+ *
+ * @param[in] topic_name topic_name The name of topic
+ * @param[in] callback The set of callback functions to handle events
+ * @param[in] user_data The user data to be passed to the callback function
+ * @param[out] h The <PREFIX>_<NAME> handle
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #<ERROR_PREFIX>_ERROR_NONE Successful
+ * @retval #<ERROR_PREFIX>_ERROR_NOT_SUPPORTED Not supported
+ * @retval #<ERROR_PREFIX>_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #<ERROR_PREFIX>_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #<ERROR_PREFIX>_ERROR_PERMISSION_DENIED Permission denied
+
+ * @see <PREFIX>_<NAME>_destroy()
+ * @see #<PREFIX>_<NAME>_callback_s
+ */
+int <PREFIX>_<NAME>_create(const char *topic_name, <PREFIX>_<NAME>_callback_s *callback, void *user_data, <PREFIX>_<NAME>_h *h);
+)__c_cb";
+
+constexpr const char __GROUP_BODY_EXTRA[] =
+R"__c_cb(
+int <PREFIX>_<NAME>_create(const char *topic_name, <PREFIX>_<NAME>_callback_s *callback, void *user_data, <PREFIX>_<NAME>_h *h)
 )__c_cb";
 
 }  // namespace
 
 namespace tidl {
 
-std::string DefaultCTransportable::GenInclude() const {
+std::string DefaultCTransportable::GenInclude(bool body, int type) const {
   return "#include <cion.h>";
 }
 
+std::string DefaultCTransportable::GenHeaderBase() const {
+  return "";
+}
+
+std::string DefaultCTransportable::GenHeaderPayloadHandle() const {
+  return "";
+}
+
+std::string DefaultCTransportable::GenHeaderCommonHandle() const {
+  return "";
+}
+
+std::string DefaultCTransportable::GenHeaderConnectionHandle() const {
+  return "";
+}
+
+std::string DefaultCTransportable::GenHeaderPayloadBase() const {
+  return "";
+}
+
+std::string DefaultCTransportable::GenHeaderConnectionBase() const {
+  return "";
+}
+
+std::string DefaultCTransportable::GenBodyPayloadBase() const {
+  return "";
+}
+
+std::string DefaultCTransportable::GenBodyConnectionBase() const {
+  return "";
+}
+
+std::string DefaultCTransportable::GenBodyPeerInfoBase() const {
+  return "";
+}
+
+std::string DefaultCTransportable::GenProxyPrefix() const {
+  return "cion_proxy";
+}
+
+std::string DefaultCTransportable::GenStubPrefix() const {
+  return "cion_stub";
+}
+
+std::string DefaultCTransportable::GenGroupPrefix() const {
+  return "cion_group";
+}
+
+std::string DefaultCTransportable::GenModulePrefix() const {
+  return "cion";
+}
+
+std::string DefaultCTransportable::GenErrorPrefix() const {
+  return "CION";
+}
+
+std::string DefaultCTransportable::GenServerExtra(bool body) const {
+  if (body)
+    return __SERVER_BODY_EXTRA;
+  else
+    return __SERVER_HEADER_EXTRA;
+}
+
+std::string DefaultCTransportable::GenClientExtra(bool body) const {
+  if (body)
+    return __CLIENT_BODY_EXTRA;
+  else
+    return __CLIENT_HEADER_EXTRA;
+}
+
+std::string DefaultCTransportable::GenGroupExtra(bool body) const {
+  if (body)
+    return __GROUP_BODY_EXTRA;
+  else
+    return __GROUP_HEADER_EXTRA;
+}
+
 std::string DefaultCTransportable::GenClientSendAsync(std::string client,
     std::string payload, std::string size) const {
   return std::string(ReplaceAll(__CLIENT_SEND_ASYNC, {
@@ -487,7 +678,7 @@ std::string DefaultCTransportable::GenGroupType() const {
   return "cion_group_h";
 }
 
-std::string DefaultCTransportable::GenPayloadTransferStatusType() const {
+std::string DefaultCTransportable::GenPayloadTransferStatusType(bool internal_type) const {
   return "cion_payload_transfer_status_e";
 }
 
@@ -500,7 +691,7 @@ std::string DefaultCTransportable::GenPeerInfoDestroy(std::string peer) const {
       { "<PEER>", peer } }));
 }
 
-std::string DefaultCTransportable::GenPayloadType() const {
+std::string DefaultCTransportable::GenPayloadType(bool internal_type) const {
   return "cion_payload_h";
 }
 
@@ -508,8 +699,11 @@ std::string DefaultCTransportable::GenClientType() const {
   return "cion_client_h";
 }
 
-std::string DefaultCTransportable::GenSecurityType() const {
-  return "cion_security_h";
+std::string DefaultCTransportable::GenSecurityType(bool definition) const {
+  if (definition)
+    return "cion_security_h security;";
+  else
+    return "cion_security_h";
 }
 
 std::string DefaultCTransportable::GenServerType() const {
@@ -649,9 +843,4 @@ std::string DefaultCTransportable::GenServerForeachConnectedPeerInfo(
       { "<NAME>", name } }));
 }
 
-std::string DefaultCTransportable::GenServerSetOnDemandLaunchEnabled(std::string name) const {
-  return std::string(ReplaceAll(__SERVER_SET_ONDEMAND_LAUNCH_ENABLED, {
-      { "<NAME>", name } }));
-}
-
 }  // namespace tidl
index 4c1983c15f3b3102787eff78cfdf19a6b86125d0..0fbc44505f31c8c60628fc70c75f4d52c7f991a4 100644 (file)
@@ -26,7 +26,24 @@ namespace tidl {
 class DefaultCTransportable : public CTransportable {
  public:
   virtual ~DefaultCTransportable() = default;
-  std::string GenInclude() const override;
+  std::string GenInclude(bool body = true, int type = 0) const override;
+  std::string GenHeaderBase() const override;
+  std::string GenHeaderPayloadHandle() const override;
+  std::string GenHeaderCommonHandle() const override;
+  std::string GenHeaderConnectionHandle() const override;
+  std::string GenHeaderPayloadBase() const override;
+  std::string GenHeaderConnectionBase() const override;
+  std::string GenBodyPayloadBase() const override;
+  std::string GenBodyConnectionBase() const override;
+  std::string GenBodyPeerInfoBase() const override;
+  std::string GenProxyPrefix() const override;
+  std::string GenStubPrefix() const override;
+  std::string GenGroupPrefix() const override;
+       std::string GenModulePrefix() const override;
+  std::string GenErrorPrefix() const override;
+       std::string GenServerExtra(bool body = true) const override;
+  std::string GenClientExtra(bool body = true) const override;
+  std::string GenGroupExtra(bool body = true) const override;
   std::string GenClientSendAsync(std::string client,
       std::string payload, std::string size) const override;
   std::string GenClientSend(std::string client, std::string data,
@@ -39,12 +56,12 @@ class DefaultCTransportable : public CTransportable {
   std::string GenClientFileSend(std::string path,
       std::string client) const override;
   std::string GenGroupType() const override;
-  std::string GenPayloadTransferStatusType() const override;
+  std::string GenPayloadTransferStatusType(bool internal_type) const override;
   std::string GenPeerInfoType() const override;
   std::string GenPeerInfoDestroy(std::string peer) const override;
-  std::string GenPayloadType() const override;
+  std::string GenPayloadType(bool internal_type) const override;
   std::string GenClientType() const override;
-  std::string GenSecurityType() const override;
+  std::string GenSecurityType(bool definition = true) const override;
   std::string GenServerType() const override;
   std::string GenClientTryConnect(std::string client,
       std::string peer) const override;
@@ -77,7 +94,6 @@ class DefaultCTransportable : public CTransportable {
   std::string GenPeerInfoClone(std::string src_peer,
       std::string dest_peer) const override;
   std::string GenServerForeachConnectedPeerInfo(std::string name) const override;
-  std::string GenServerSetOnDemandLaunchEnabled(std::string name) const override;
 };
 
 }  // namespace tidl
index ba90ca60a0cb653c1386fbd6b2d092e23627f722..9c326328e48d2853bd1bfad8bfc1f89c17dc21ba 100644 (file)
@@ -26,7 +26,8 @@
 namespace tidl {
 
 JavaCionCommonGen::JavaCionCommonGen(
-    std::shared_ptr<Document> doc) : JavaCionGeneratorBase(doc) {
+    std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans)
+    : JavaCionGeneratorBase(doc, trans) {
 }
 
 void JavaCionCommonGen::OnInitGen(std::ofstream& stream) {
index 5e43a6ffc6bd2cbe18b99afe267b3bdc974fec58..cdf478dac5385b850db944ca111772c2ceac6015 100644 (file)
@@ -27,7 +27,7 @@ namespace tidl {
 
 class JavaCionCommonGen : public JavaCionGeneratorBase {
  public:
-  explicit JavaCionCommonGen(std::shared_ptr<Document> doc);
+  explicit JavaCionCommonGen(std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans);
   virtual ~JavaCionCommonGen() = default;
 
   void OnInitGen(std::ofstream& stream) override;
index 43f5aec5c4a6afae8699b2a48491eaeed162c428..d4739acd4bcef35a4a669c043cffbf0ff996d071 100644 (file)
@@ -29,8 +29,9 @@
 
 namespace tidl {
 
-JavaCionGeneratorBase::JavaCionGeneratorBase(std::shared_ptr<Document> doc)
-    : CionPluginBase(std::move(doc)) {
+JavaCionGeneratorBase::JavaCionGeneratorBase(
+    std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans)
+    : CionPluginBase(std::move(doc), trans) {
   type_map_ = {
       {"char", "byte"}, {"int", "int"}, {"short", "short"},
       {"long", "long"}, {"string", "String"}, {"bool", "boolean"},
index 0e7700b3a1331a4b12dc49b65dbbaa6dffa29494..73444b8c9efb4cbe2452aa9d86b4dcd6f2596771 100644 (file)
@@ -29,7 +29,7 @@ namespace tidl {
 
 class JavaCionGeneratorBase : public CionPluginBase {
  public:
-  explicit JavaCionGeneratorBase(std::shared_ptr<Document> doc);
+  explicit JavaCionGeneratorBase(std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans);
   virtual ~JavaCionGeneratorBase() = default;
   void GenMethodId(std::ofstream& stream,
     const Interface& iface,  bool is_group = false);
index 8901b11460c40afa0a0d3878279bf2e2615e521e..b132241d815b893ba734887f4a367013d69c41ab 100644 (file)
@@ -23,8 +23,9 @@ namespace {
 
 namespace tidl {
 
-JavaCionGroupGen::JavaCionGroupGen(std::shared_ptr<Document> doc)
-    : JavaCionGeneratorBase(doc) {}
+JavaCionGroupGen::JavaCionGroupGen(std::shared_ptr<Document> doc,
+    std::shared_ptr<tidl::Transportable> trans)
+    : JavaCionGeneratorBase(doc, trans) {}
 
 void JavaCionGroupGen::OnInitGen(std::ofstream& stream) {
   std::string fname = MakeDir(FileName, "/group");
index 831476e87d1a00deec9d1695c87f863364f53c2b..71dbc99f1230a623b47d44b30daf7e99c5591808 100644 (file)
@@ -26,7 +26,8 @@ namespace tidl {
 
 class JavaCionGroupGen : public JavaCionGeneratorBase {
  public:
-  explicit JavaCionGroupGen(std::shared_ptr<Document> doc);
+  explicit JavaCionGroupGen(std::shared_ptr<Document> doc,
+      std::shared_ptr<tidl::Transportable> trans);
   virtual ~JavaCionGroupGen() = default;
 
   void OnInitGen(std::ofstream& stream) override;
index 10626d7aaf875186327129c38150205f89a9ac73..0ab0ab164302cdbe56481e1cfb0afb493ed030c9 100644 (file)
@@ -26,7 +26,8 @@
 namespace tidl {
 
 JavaCionGroupRepoGen::JavaCionGroupRepoGen(
-    std::shared_ptr<Document> doc) : JavaCionGeneratorBase(doc) {
+    std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans)
+    : JavaCionGeneratorBase(doc, trans) {
 }
 
 void JavaCionGroupRepoGen::OnInitGen(std::ofstream& stream) {
index 5fb2665817b4157a900ff1c9bad1e16c4c9c70b4..4079e0551949c45b7fb48265f1e803a95991743b 100644 (file)
@@ -27,7 +27,8 @@ namespace tidl {
 
 class JavaCionGroupRepoGen : public JavaCionGeneratorBase {
  public:
-  explicit JavaCionGroupRepoGen(std::shared_ptr<Document> doc);
+  explicit JavaCionGroupRepoGen(std::shared_ptr<Document> doc,
+      std::shared_ptr<tidl::Transportable> trans);
   virtual ~JavaCionGroupRepoGen() = default;
 
   void OnInitGen(std::ofstream& stream) override;
index 6172e7b77c787173f77f4347dccbcb9282dcef89..cdf65b847a39303be4dc2ee346cb074c94061173 100644 (file)
@@ -23,8 +23,9 @@ namespace {
 
 namespace tidl {
 
-JavaCionProxyGen::JavaCionProxyGen(std::shared_ptr<Document> doc)
-    : JavaCionGeneratorBase(doc) {}
+JavaCionProxyGen::JavaCionProxyGen(std::shared_ptr<Document> doc,
+    std::shared_ptr<tidl::Transportable> trans)
+    : JavaCionGeneratorBase(doc, trans) {}
 
 void JavaCionProxyGen::OnInitGen(std::ofstream& stream) {
   std::string fname = MakeDir(FileName, "/client");
index 5d3f24d608940020d2443ea0441201c2ee6d3c35..238fd4ebd79f3cb588277eda6bfd2cd4584c82f0 100644 (file)
@@ -26,7 +26,8 @@ namespace tidl {
 
 class JavaCionProxyGen : public JavaCionGeneratorBase {
  public:
-  explicit JavaCionProxyGen(std::shared_ptr<Document> doc);
+  explicit JavaCionProxyGen(std::shared_ptr<Document> doc,
+      std::shared_ptr<tidl::Transportable> trans);
   virtual ~JavaCionProxyGen() = default;
 
   void OnInitGen(std::ofstream& stream) override;
index b74a3e87d50e920ccd236573e2f94a29b6beb931..4c04cfea35f5ab0403847e81e2d96d7b7525307e 100644 (file)
@@ -26,7 +26,8 @@
 namespace tidl {
 
 JavaCionProxyRepoGen::JavaCionProxyRepoGen(
-    std::shared_ptr<Document> doc) : JavaCionGeneratorBase(doc) {
+    std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans)
+    : JavaCionGeneratorBase(doc, trans) {
 }
 
 void JavaCionProxyRepoGen::OnInitGen(std::ofstream& stream) {
index fc9d69700f149f7fe28aa0c4ee71d0e42615244d..665935018ee1df5ba3b83d51fba1ad0c4a32368d 100644 (file)
@@ -27,7 +27,8 @@ namespace tidl {
 
 class JavaCionProxyRepoGen : public JavaCionGeneratorBase {
  public:
-  explicit JavaCionProxyRepoGen(std::shared_ptr<Document> doc);
+  explicit JavaCionProxyRepoGen(std::shared_ptr<Document> doc,
+      std::shared_ptr<tidl::Transportable> trans);
   virtual ~JavaCionProxyRepoGen() = default;
 
   void OnInitGen(std::ofstream& stream) override;
index 0ea22106686d753af7466d7d6cdbbca1ac246fff..e34b6c98fc02b4beec29c9410cb5507bad85c16f 100644 (file)
@@ -26,7 +26,8 @@
 namespace tidl {
 
 JavaCionStructureGen::JavaCionStructureGen(
-    std::shared_ptr<Document> doc) : JavaCionGeneratorBase(doc) {
+    std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans)
+    : JavaCionGeneratorBase(doc, trans) {
 }
 
 void JavaCionStructureGen::OnInitGen(std::ofstream& stream) {
index 126414ba715ba753d38050d2016d8808ace72b7b..0902da1ec7d339e587920d1ccb08224394a01be1 100644 (file)
@@ -27,7 +27,7 @@ namespace tidl {
 
 class JavaCionStructureGen : public JavaCionGeneratorBase {
  public:
-  explicit JavaCionStructureGen(std::shared_ptr<Document> doc);
+  explicit JavaCionStructureGen(std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans);
   virtual ~JavaCionStructureGen() = default;
 
   void OnInitGen(std::ofstream& stream) override;
index 05129cfea5736e8f662313b6757b089dc2acdf70..74edda9652f1d293b283b39d20b24c7ae44a2d1d 100644 (file)
@@ -23,8 +23,8 @@ namespace {
 
 namespace tidl {
 
-JavaCionStubGen::JavaCionStubGen(std::shared_ptr<Document> doc)
-    : JavaCionGeneratorBase(doc) {}
+JavaCionStubGen::JavaCionStubGen(std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans)
+    : JavaCionGeneratorBase(doc, trans) {}
 
 void JavaCionStubGen::OnInitGen(std::ofstream& stream) {
   std::string fname = MakeDir(FileName, "/server");
index 2916bcf1cff3f7586e6269b0c46e98d3f9a1297b..2526f1b346dd029c97a280c698a507998b81f443 100644 (file)
@@ -26,7 +26,7 @@ namespace tidl {
 
 class JavaCionStubGen : public JavaCionGeneratorBase {
  public:
-  explicit JavaCionStubGen(std::shared_ptr<Document> doc);
+  explicit JavaCionStubGen(std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans);
   virtual ~JavaCionStubGen() = default;
 
   void OnInitGen(std::ofstream& stream) override;
index 513e1e96592658293e89f1ff2eff695720b2c888..3c855b5b744ccf21484627c545793394e6cba22c 100644 (file)
@@ -26,7 +26,8 @@
 namespace tidl {
 
 JavaCionStubRepoGen::JavaCionStubRepoGen(
-    std::shared_ptr<Document> doc) : JavaCionGeneratorBase(doc) {
+    std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans)
+    : JavaCionGeneratorBase(doc, trans) {
 }
 
 void JavaCionStubRepoGen::OnInitGen(std::ofstream& stream) {
index 2e4e6e959e7475c5f25acdeef73f3bc8799fe8cd..d37cb40980cfe0d398285041809b86cc912d87e3 100644 (file)
@@ -27,7 +27,7 @@ namespace tidl {
 
 class JavaCionStubRepoGen : public JavaCionGeneratorBase {
  public:
-  explicit JavaCionStubRepoGen(std::shared_ptr<Document> doc);
+  explicit JavaCionStubRepoGen(std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans);
   virtual ~JavaCionStubRepoGen() = default;
 
   void OnInitGen(std::ofstream& stream) override;
index b547fcc2e502aa14144e89d1184b64e9969397e2..078a2688d4ae4c86080b0666fa28c42c6bfb1a7a 100644 (file)
@@ -26,7 +26,8 @@
 namespace tidl {
 
 JavaCionUtilityGen::JavaCionUtilityGen(
-    std::shared_ptr<Document> doc) : JavaCionGeneratorBase(doc) {
+    std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans)
+    : JavaCionGeneratorBase(doc, trans) {
 }
 
 void JavaCionUtilityGen::OnInitGen(std::ofstream& stream) {
index 9f487a03facae97b8b22334d4ba1451bbe2111e0..bee4c12e740adfee573311401ff8ddc29012d8c5 100644 (file)
@@ -29,7 +29,7 @@ namespace tidl {
 
 class JavaCionUtilityGen : public JavaCionGeneratorBase {
  public:
-  explicit JavaCionUtilityGen(std::shared_ptr<Document> doc);
+  explicit JavaCionUtilityGen(std::shared_ptr<Document> doc, std::shared_ptr<tidl::Transportable> trans);
   virtual ~JavaCionUtilityGen() = default;
 
   void OnInitGen(std::ofstream& stream) override;
index 4e4228fdb75b22484bddf74866dfe82c22744336..ba6d0988ab605fccb27090f951ef609d8671f771 100644 (file)
 #include "idlc/gen_cion/cpp_cion_stub_body_gen.h"
 #include "idlc/gen_cion/cpp_cion_group_header_gen.h"
 #include "idlc/gen_cion/cpp_cion_group_body_gen.h"
+#include "idlc/gen_cion/plugin_loader.h"
+#include "idlc/gen_aitt_plugin/aitt_plugin_internal_header_gen.h"
+#include "idlc/gen_aitt_plugin/aitt_plugin_internal_body_gen.h"
+#include "idlc/gen_aitt_plugin/aitt_plugin_c_transportable.h"
+#include "idlc/gen_aitt_plugin/aitt_plugin_loader.h"
+
 #include "idlc/options.h"
 
 
 void GenerateStubCodes(std::shared_ptr<tidl::Options> options,
     tidl::Parser& ps) {
   if (options->IsCion()) {
+    auto trans = std::shared_ptr<tidl::Transportable>(new tidl::PluginLoader(""));
     switch (options->GetLanguage()) {
     case tidl::Options::LANGUAGE_TYPE_C:
     {
-      tidl::CCionStubHeaderGen stub_header(ps.GetDoc());
+      tidl::CCionStubHeaderGen stub_header(ps.GetDoc(), trans);
       stub_header.EnableNamespace(options->HasNamespace());
       stub_header.SetType(static_cast<int>(options->GetType()));
       stub_header.Run(options->GetOutput() + ".h");
-      tidl::CCionStubBodyGen stub_body(ps.GetDoc(), options);
+      tidl::CCionStubBodyGen stub_body(ps.GetDoc(), options, trans);
       stub_body.EnableNamespace(options->HasNamespace());
       stub_body.SetType(static_cast<int>(options->GetType()));
       stub_body.Run(options->GetOutput() + ".c");
@@ -82,33 +89,33 @@ void GenerateStubCodes(std::shared_ptr<tidl::Options> options,
     }
     case tidl::Options::LANGUAGE_TYPE_CPP:
     {
-      tidl::CppCionStubHeaderGen stub_header(ps.GetDoc(), options);
+      tidl::CppCionStubHeaderGen stub_header(ps.GetDoc(), options, trans);
       stub_header.Run(options->GetOutput() + ".h");
-      tidl::CppCionStubBodyGen stub_body(ps.GetDoc(), options);
+      tidl::CppCionStubBodyGen stub_body(ps.GetDoc(), options, trans);
       stub_body.Run(options->GetOutput() + ".cc");
       break;
     }
     case tidl::Options::LANGUAGE_TYPE_CSHARP:
     {
-       tidl::CsCionStubGen stub(ps.GetDoc());
+       tidl::CsCionStubGen stub(ps.GetDoc(), trans);
        stub.Run(options->GetOutput() + ".cs");
        break;
     }
     case tidl::Options::LANGUAGE_TYPE_JAVA:
     {
-      tidl::JavaCionStubRepoGen repo(ps.GetDoc());
+      tidl::JavaCionStubRepoGen repo(ps.GetDoc(), trans);
       repo.Run(options->GetOutput(), true);
 
-      tidl::JavaCionStubGen view_model(ps.GetDoc());
+      tidl::JavaCionStubGen view_model(ps.GetDoc(), trans);
       view_model.Run(options->GetOutput(), true);
 
-      tidl::JavaCionUtilityGen utilities(ps.GetDoc());
+      tidl::JavaCionUtilityGen utilities(ps.GetDoc(), trans);
       utilities.Run(options->GetOutput(), true);
 
-      tidl::JavaCionStructureGen structures(ps.GetDoc());
+      tidl::JavaCionStructureGen structures(ps.GetDoc(), trans);
       structures.Run(options->GetOutput(), true);
 
-      tidl::JavaCionCommonGen cgen(ps.GetDoc());
+      tidl::JavaCionCommonGen cgen(ps.GetDoc(), trans);
       cgen.Run(options->GetOutput(), true);
       break;
     }
@@ -117,13 +124,48 @@ void GenerateStubCodes(std::shared_ptr<tidl::Options> options,
       break;
     }
   } else if (options->IsAitt()) {
+    auto trans = std::shared_ptr<tidl::Transportable>(new tidl::AIttPluginLoader(""));
     switch (options->GetLanguage()) {
-      case tidl::Options::LANGUAGE_TYPE_C:
-      case tidl::Options::LANGUAGE_TYPE_CPP:
-      case tidl::Options::LANGUAGE_TYPE_CSHARP:
-      case tidl::Options::LANGUAGE_TYPE_JAVA:
-      default:
-        break;
+    case tidl::Options::LANGUAGE_TYPE_C:
+    {
+      tidl::AittPluginInternalHeaderGen internal_header(ps.GetDoc(), trans);
+      internal_header.SetType(static_cast<int>(options->GetType()));
+      internal_header.Run("aitt_plugin_stub_internal.h");
+
+      tidl::AittPluginInternalBodyGen internal_body(ps.GetDoc(), trans);
+      internal_body.EnableNamespace(options->HasNamespace());
+      internal_body.SetType(static_cast<int>(options->GetType()));
+      internal_body.Run("aitt_plugin_stub_internal.c");
+
+      tidl::CCionStubHeaderGen stub_header(ps.GetDoc(), trans);
+      stub_header.EnableNamespace(options->HasNamespace());
+      stub_header.SetType(static_cast<int>(options->GetType()));
+      stub_header.EnableGeneratedAPI(true);
+      stub_header.Run(options->GetOutput() + ".h");
+
+      tidl::CCionStubBodyGen stub_body(ps.GetDoc(), options, trans);
+      stub_body.EnableNamespace(options->HasNamespace());
+      stub_body.SetType(static_cast<int>(options->GetType()));
+      stub_body.EnableGeneratedAPI(true);
+      stub_body.Run(options->GetOutput() + ".c");
+
+      break;
+    }
+    case tidl::Options::LANGUAGE_TYPE_CPP:
+    {
+      break;
+    }
+    case tidl::Options::LANGUAGE_TYPE_CSHARP:
+    {
+       break;
+    }
+    case tidl::Options::LANGUAGE_TYPE_JAVA:
+    {
+      break;
+    }
+
+    default:
+      break;
     }
   } else {
     switch (options->GetLanguage()) {
@@ -167,14 +209,15 @@ void GenerateStubCodes(std::shared_ptr<tidl::Options> options,
 void GenerateProxyCodes(std::shared_ptr<tidl::Options> options,
     tidl::Parser& ps) {
   if (options->IsCion()) {
+    auto trans = std::shared_ptr<tidl::Transportable>(new tidl::PluginLoader(""));
     switch (options->GetLanguage()) {
     case tidl::Options::LANGUAGE_TYPE_C:
     {
-      tidl::CCionProxyHeaderGen proxy_header(ps.GetDoc());
+      tidl::CCionProxyHeaderGen proxy_header(ps.GetDoc(), trans);
       proxy_header.EnableNamespace(options->HasNamespace());
       proxy_header.SetType(static_cast<int>(options->GetType()));
       proxy_header.Run(options->GetOutput() + ".h");
-      tidl::CCionProxyBodyGen proxy_body(ps.GetDoc(), options);
+      tidl::CCionProxyBodyGen proxy_body(ps.GetDoc(), options, trans);
       proxy_body.EnableNamespace(options->HasNamespace());
       proxy_body.SetType(static_cast<int>(options->GetType()));
       proxy_body.Run(options->GetOutput() + ".c");
@@ -182,34 +225,34 @@ void GenerateProxyCodes(std::shared_ptr<tidl::Options> options,
     }
     case tidl::Options::LANGUAGE_TYPE_CPP:
     {
-      tidl::CppCionProxyHeaderGen proxy_header(ps.GetDoc());
+      tidl::CppCionProxyHeaderGen proxy_header(ps.GetDoc(), trans);
       proxy_header.Run(options->GetOutput() + ".h");
-      tidl::CppCionProxyBodyGen proxy_body(ps.GetDoc());
+      tidl::CppCionProxyBodyGen proxy_body(ps.GetDoc(), trans);
       proxy_body.Run(options->GetOutput() + ".cc");
       break;
     }
       break;
     case tidl::Options::LANGUAGE_TYPE_CSHARP:
     {
-      tidl::CsCionProxyGen proxy(ps.GetDoc());
+      tidl::CsCionProxyGen proxy(ps.GetDoc(), trans);
       proxy.Run(options->GetOutput() + ".cs");
       break;
     }
     case tidl::Options::LANGUAGE_TYPE_JAVA:
     {
-      tidl::JavaCionProxyRepoGen base_files(ps.GetDoc());
+      tidl::JavaCionProxyRepoGen base_files(ps.GetDoc(), trans);
       base_files.Run(options->GetOutput(), true);
 
-      tidl::JavaCionProxyGen view_model(ps.GetDoc());
+      tidl::JavaCionProxyGen view_model(ps.GetDoc(), trans);
       view_model.Run(options->GetOutput(), true);
 
-      tidl::JavaCionUtilityGen utilities(ps.GetDoc());
+      tidl::JavaCionUtilityGen utilities(ps.GetDoc(), trans);
       utilities.Run(options->GetOutput(), true);
 
-      tidl::JavaCionStructureGen structures(ps.GetDoc());
+      tidl::JavaCionStructureGen structures(ps.GetDoc(), trans);
       structures.Run(options->GetOutput(), true);
 
-      tidl::JavaCionCommonGen cgen(ps.GetDoc());
+      tidl::JavaCionCommonGen cgen(ps.GetDoc(), trans);
       cgen.Run(options->GetOutput(), true);
       break;
     }
@@ -218,13 +261,47 @@ void GenerateProxyCodes(std::shared_ptr<tidl::Options> options,
       break;
     }
   } else if (options->IsAitt()) {
+    auto trans = std::shared_ptr<tidl::Transportable>(new tidl::AIttPluginLoader(""));
     switch (options->GetLanguage()) {
-      case tidl::Options::LANGUAGE_TYPE_C:
-      case tidl::Options::LANGUAGE_TYPE_CPP:
-      case tidl::Options::LANGUAGE_TYPE_CSHARP:
-      case tidl::Options::LANGUAGE_TYPE_JAVA:
-      default:
-        break;
+    case tidl::Options::LANGUAGE_TYPE_C:
+    {
+      tidl::AittPluginInternalHeaderGen internal_header(ps.GetDoc(), trans);
+      internal_header.SetType(static_cast<int>(options->GetType()));
+      internal_header.Run("aitt_plugin_proxy_internal.h");
+
+      tidl::AittPluginInternalBodyGen internal_body(ps.GetDoc(), trans);
+      internal_body.EnableNamespace(options->HasNamespace());
+      internal_body.SetType(static_cast<int>(options->GetType()));
+      internal_body.Run("aitt_plugin_proxy_internal.c");
+
+      tidl::CCionProxyHeaderGen proxy_header(ps.GetDoc(), trans);
+      proxy_header.EnableNamespace(options->HasNamespace());
+      proxy_header.SetType(static_cast<int>(options->GetType()));
+      proxy_header.EnableGeneratedAPI(true);
+      proxy_header.Run(options->GetOutput() + ".h");
+
+      tidl::CCionProxyBodyGen proxy_body(ps.GetDoc(), options, trans);
+      proxy_body.EnableNamespace(options->HasNamespace());
+      proxy_body.SetType(static_cast<int>(options->GetType()));
+      proxy_body.EnableGeneratedAPI(true);
+      proxy_body.Run(options->GetOutput() + ".c");
+      break;
+    }
+    case tidl::Options::LANGUAGE_TYPE_CPP:
+    {
+      break;
+    }
+    case tidl::Options::LANGUAGE_TYPE_CSHARP:
+    {
+       break;
+    }
+    case tidl::Options::LANGUAGE_TYPE_JAVA:
+    {
+      break;
+    }
+
+    default:
+      break;
     }
   } else {
     switch (options->GetLanguage()) {
@@ -268,16 +345,16 @@ void GenerateProxyCodes(std::shared_ptr<tidl::Options> options,
 void GenerateGroupCodes(std::shared_ptr<tidl::Options> options,
     tidl::Parser& ps) {
   if (options->IsCion()) {
+    auto trans = std::shared_ptr<tidl::Transportable>(new tidl::PluginLoader(""));
     switch (options->GetLanguage()) {
     case tidl::Options::LANGUAGE_TYPE_C:
     {
-
-      tidl::CCionGroupHeaderGen group_header(ps.GetDoc());
+      tidl::CCionGroupHeaderGen group_header(ps.GetDoc(), trans);
       group_header.EnableNamespace(options->HasNamespace());
       group_header.SetType(static_cast<int>(options->GetType()));
       group_header.Run(options->GetOutput() + ".h");
 
-      tidl::CCionGroupBodyGen group_body(ps.GetDoc(), options);
+      tidl::CCionGroupBodyGen group_body(ps.GetDoc(), options, trans);
       group_body.EnableNamespace(options->HasNamespace());
       group_body.SetType(static_cast<int>(options->GetType()));
       group_body.Run(options->GetOutput() + ".c");
@@ -285,36 +362,79 @@ void GenerateGroupCodes(std::shared_ptr<tidl::Options> options,
     }
     case tidl::Options::LANGUAGE_TYPE_CPP:
     {
-      tidl::CppCionGroupHeaderGen group_header(ps.GetDoc());
+      tidl::CppCionGroupHeaderGen group_header(ps.GetDoc(), trans);
       group_header.Run(options->GetOutput() + ".h");
-      tidl::CppCionGroupBodyGen group_body(ps.GetDoc());
+      tidl::CppCionGroupBodyGen group_body(ps.GetDoc(), trans);
       group_body.Run(options->GetOutput() + ".cc");
       break;
     }
     case tidl::Options::LANGUAGE_TYPE_CSHARP:
     {
-      tidl::CsCionGroupGen group(ps.GetDoc());
+      tidl::CsCionGroupGen group(ps.GetDoc(), trans);
       group.Run(options->GetOutput() + ".cs");
       break;
     }
     case tidl::Options::LANGUAGE_TYPE_JAVA:
     {
-      tidl::JavaCionGroupRepoGen repo(ps.GetDoc());
+      tidl::JavaCionGroupRepoGen repo(ps.GetDoc(), trans);
       repo.Run(options->GetOutput(), true);
 
-      tidl::JavaCionGroupGen view_model(ps.GetDoc());
+      tidl::JavaCionGroupGen view_model(ps.GetDoc(), trans);
       view_model.Run(options->GetOutput(), true);
 
-      tidl::JavaCionUtilityGen utilities(ps.GetDoc());
+      tidl::JavaCionUtilityGen utilities(ps.GetDoc(), trans);
       utilities.Run(options->GetOutput(), true);
 
-      tidl::JavaCionStructureGen structures(ps.GetDoc());
+      tidl::JavaCionStructureGen structures(ps.GetDoc(), trans);
       structures.Run(options->GetOutput(), true);
 
-      tidl::JavaCionCommonGen cgen(ps.GetDoc());
+      tidl::JavaCionCommonGen cgen(ps.GetDoc(), trans);
       cgen.Run(options->GetOutput(), true);
       break;
     }
+    default:
+      break;
+    }
+ } else if (options->IsAitt()) {
+    auto trans = std::shared_ptr<tidl::Transportable>(new tidl::AIttPluginLoader(""));
+    switch (options->GetLanguage()) {
+    case tidl::Options::LANGUAGE_TYPE_C:
+    {
+      tidl::AittPluginInternalHeaderGen internal_header(ps.GetDoc(), trans);
+      internal_header.SetType(static_cast<int>(options->GetType()));
+      internal_header.Run("aitt_plugin_group_internal.h");
+
+      tidl::AittPluginInternalBodyGen internal_body(ps.GetDoc(), trans);
+      internal_body.EnableNamespace(options->HasNamespace());
+      internal_body.SetType(static_cast<int>(options->GetType()));
+      internal_body.Run("aitt_plugin_group_internal.c");
+
+      tidl::CCionGroupHeaderGen group_header(ps.GetDoc(), trans);
+      group_header.EnableNamespace(options->HasNamespace());
+      group_header.SetType(static_cast<int>(options->GetType()));
+      group_header.EnableGeneratedAPI(true);
+      group_header.Run(options->GetOutput() + ".h");
+
+      tidl::CCionGroupBodyGen group_body(ps.GetDoc(), options, trans);
+      group_body.EnableNamespace(options->HasNamespace());
+      group_body.SetType(static_cast<int>(options->GetType()));
+      group_body.EnableGeneratedAPI(true);
+      group_body.Run(options->GetOutput() + ".c");
+      break;
+    }
+    case tidl::Options::LANGUAGE_TYPE_CPP:
+    {
+      break;
+    }
+    case tidl::Options::LANGUAGE_TYPE_CSHARP:
+    {
+       break;
+    }
+    case tidl::Options::LANGUAGE_TYPE_JAVA:
+    {
+      break;
+    }
+
     default:
       break;
     }
index 90386b485df6a4cb985fd1d05d8eda5f88a1c34f..ed2dd0d40c1a438f2797f2585151748162d06498 100644 (file)
@@ -23,6 +23,8 @@ SET(CMAKE_EXE_LINKER_FLAGS "-pie -Wl,--as-needed")
 AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} TIDL_BUILD_TESTS_SRCS)
 
 SET(TIDL_GEN_SRCS
+  BufferAittPluginProxyC.c
+  BufferAittPluginStubC.c
   BufferCionProxy.cc
   BufferCionProxyC.c
   BufferCionStub.cc
@@ -31,6 +33,8 @@ SET(TIDL_GEN_SRCS
   BufferProxyC.c
   BufferStub.cc
   BufferStubC.c
+  DataPortAittPluginProxyC.c
+  DataPortAittPluginStubC.c
   DataPortCionProxy.cc
   DataPortCionProxyC.c
   DataPortCionStub.cc
@@ -39,6 +43,8 @@ SET(TIDL_GEN_SRCS
   DataPortProxyC.c
   DataPortStub.cc
   DataPortStubC.c
+  ExCionAittPluginProxyC.c
+  ExCionAittPluginStubC.c
   ExCionCionProxy.cc
   ExCionCionProxyC.c
   ExCionCionStub.cc
@@ -47,6 +53,8 @@ SET(TIDL_GEN_SRCS
   ExProxyC.c
   ExStub.cc
   ExStubC.c
+  FooAittPluginProxyC.c
+  FooAittPluginStubC.c
   FooCionProxy.cc
   FooCionProxyC.c
   FooCionStub.cc
@@ -55,6 +63,8 @@ SET(TIDL_GEN_SRCS
   FooProxyC.c
   FooStub.cc
   FooStubC.c
+  MessageAittPluginProxyC.c
+  MessageAittPluginStubC.c
   MessageCionProxy.cc
   MessageCionProxyC.c
   MessageCionStub.cc
@@ -62,6 +72,7 @@ SET(TIDL_GEN_SRCS
   MessageProxy.cc
   MessageProxyC.c
   MessageStub.cc
+  FooPubsubAittPluginGroupC.c
   FooPubsubGroup.cc
   FooPubsubGroupC.c
   FooPubsubCionGroup.cc
index dd1e3045c094bb68b71fa27333b8c6019802d4a2..f409fd4d66880212834f2a981b136a490fc7ad35 100755 (executable)
@@ -79,6 +79,28 @@ GenerateTIDL() {
     OUTPUT="${FILES_FOR_GROUP[index]}CionGroupC"
     ${TIDLC} -b -c -n -g -l C -i ${SCRIPT_DIR}/tidl/${INPUT} -o ${TARGET_DIR}/${OUTPUT}
   done
+
+  for index in ${!FILES_CION[*]}; do
+    echo "Generate ${FILES_CION[index]}"
+
+    INPUT="${FILES_CION[index]}.tidl"
+
+    OUTPUT="${FILES_CION[index]}AittPluginProxyC"
+
+    ${TIDLC} -b -p -n -a -l C -i ${SCRIPT_DIR}/tidl/${INPUT} -o ${TARGET_DIR}/${OUTPUT}
+
+    OUTPUT="${FILES_CION[index]}AittPluginStubC"
+    ${TIDLC} -b -s -n -a -l C -i ${SCRIPT_DIR}/tidl/${INPUT} -o ${TARGET_DIR}/${OUTPUT}
+  done
+
+  for index in ${!FILES_FOR_GROUP[*]}; do
+    echo "Generate ${FILES_FOR_GROUP[index]}"
+
+    INPUT="${FILES_FOR_GROUP[index]}.tidl"
+
+    OUTPUT="${FILES_FOR_GROUP[index]}AittPluginGroupC"
+    ${TIDLC} -b -a -n -g -l C -i ${SCRIPT_DIR}/tidl/${INPUT} -o ${TARGET_DIR}/${OUTPUT}
+  done
 }
 
 echo "############ Generate codes using TIDLC ############"