From a55cd22b67ebcf0c5afa3287ecc407878fb24219 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 10 Aug 2023 16:31:40 +0900 Subject: [PATCH] Modify C Generator related to Remote Exception feature This patch modifies the remote exception feature. The interface name is removed from the remote exception handle. Changes: - Remove the interface name from the remote exception handle - Adjust coding style Change-Id: Ib79e7c68031e395aeca24be112477b06e3af85c6 Signed-off-by: Hwankyu Jhun --- idlc/gen/version2/c_body_generator_base.cc | 24 +- idlc/gen/version2/c_body_generator_base.hh | 2 + idlc/gen/version2/c_body_generator_base_cb.hh | 233 +++++++++++++ idlc/gen/version2/c_header_generator_base.cc | 34 +- idlc/gen/version2/c_header_generator_base.hh | 4 +- idlc/gen/version2/c_header_generator_base_cb.hh | 137 +++++++- idlc/gen/version2/c_proxy_body_generator.cc | 28 +- idlc/gen/version2/c_proxy_body_generator.hh | 44 ++- idlc/gen/version2/c_proxy_body_generator_cb.hh | 169 +-------- idlc/gen/version2/c_proxy_header_generator.cc | 25 +- idlc/gen/version2/c_proxy_header_generator.hh | 12 +- idlc/gen/version2/c_proxy_header_generator_cb.hh | 59 ---- idlc/gen/version2/c_stub_body_generator.cc | 419 +++++++++-------------- idlc/gen/version2/c_stub_body_generator.hh | 57 ++- idlc/gen/version2/c_stub_body_generator_cb.hh | 195 ++--------- idlc/gen/version2/c_stub_header_generator.cc | 151 ++++---- idlc/gen/version2/c_stub_header_generator.hh | 19 +- idlc/gen/version2/c_stub_header_generator_cb.hh | 97 +----- 18 files changed, 758 insertions(+), 951 deletions(-) diff --git a/idlc/gen/version2/c_body_generator_base.cc b/idlc/gen/version2/c_body_generator_base.cc index a19a0f3..659b6e7 100644 --- a/idlc/gen/version2/c_body_generator_base.cc +++ b/idlc/gen/version2/c_body_generator_base.cc @@ -1288,11 +1288,11 @@ void CBodyGeneratorBase::GenParameterMap() { if (GetChannelType() != ChannelType::TYPE_GROUP) { AddParameterType( std::make_shared( - new BaseType(iface.GetID() + "_remote_exception", "", true), + new BaseType("remote_exception", "", true), ParameterType::Direction::OUT)); AddParameterType( std::make_shared( - new BaseType(iface.GetID() + "_remote_exception", "", true), + new BaseType("remote_exception", "", true), ParameterType::Direction::IN)); } @@ -1491,5 +1491,25 @@ std::string CBodyGeneratorBase::GenUnitMapRead( return code; } +void CBodyGeneratorBase::GenRemoteExceptionDefinition(std::ofstream& stream) { + ReplaceAll(CB_REMOTE_EXCEPTION_DEF) + .Change("", GetHandlePrefix()) + .Transform([&](std::string code) { return SmartIndent(code); }) + .Out(stream); +} + +void CBodyGeneratorBase::GenRemoteExceptionBase(std::ofstream& stream) { + ReplaceAll(CB_REMOTE_EXCEPTION_BASE) + .Change("", GetHandlePrefix()) + .Transform([&](std::string code) { return SmartIndent(code); }) + .Out(stream); + + ReplaceAll(IsProxy() ? CB_PROXY_REMOTE_EXCEPTION_BASE + : CB_STUB_REMOTE_EXCEPTION_BASE) + .Change("", GetHandlePrefix()) + .Transform([&](std::string code) { return SmartIndent(code); }) + .Out(stream); +} + } // namespace version2 } // namespace tidl diff --git a/idlc/gen/version2/c_body_generator_base.hh b/idlc/gen/version2/c_body_generator_base.hh index b2f4559..81ba198 100644 --- a/idlc/gen/version2/c_body_generator_base.hh +++ b/idlc/gen/version2/c_body_generator_base.hh @@ -40,6 +40,8 @@ class CBodyGeneratorBase : public tidl::CBodyGeneratorBase { void GenLemBaseDefinition(std::ofstream& stream); void GenIncludeLemHeaders(std::ofstream& stream); std::string GetHandlePrefixReverse(); + void GenRemoteExceptionDefinition(std::ofstream& stream); + void GenRemoteExceptionBase(std::ofstream& stream); private: void AddTypeName(const Structure& st); diff --git a/idlc/gen/version2/c_body_generator_base_cb.hh b/idlc/gen/version2/c_body_generator_base_cb.hh index 95ffe82..e530dfb 100644 --- a/idlc/gen/version2/c_body_generator_base_cb.hh +++ b/idlc/gen/version2/c_body_generator_base_cb.hh @@ -1051,6 +1051,239 @@ static int __rpc_port_set_private_sharing_list(rpc_port_h port, GList *list) } )__c_cb"; +/** + * The prefix of the interface. + */ +constexpr const char CB_REMOTE_EXCEPTION_DEF[] = +R"__c_cb( +typedef struct _remote_exception_s { + rpc_port_parcelable_t parcelable; + int cause; + char *message; +} _remote_exception_t; + +static __thread _remote_exception_h ___remote_exception; + +int _remote_exception_create(_remote_exception_h *h); +)__c_cb"; + +/** + * The prefix of the interface. + */ +constexpr const char CB_REMOTE_EXCEPTION_BASE[] = +R"__c_cb( +static void ___remote_exception_to(rpc_port_parcel_h parcel, void *user_data) +{ + _remote_exception_h h = user_data; + rpc_port_unit_map_h map; + + map = rpc_port_unit_map_create(); + if (map == nullptr) { + set_last_result(RPC_PORT_ERROR_OUT_OF_MEMORY); + return; + } + + rpc_port_unit_map_write_int(map, "cause", h->cause); + rpc_port_unit_map_write_string(map, "message", h->message); + rpc_port_parcel_write(parcel, &map->parcelable, map); + rpc_port_unit_map_destroy(map); + set_last_result(RPC_PORT_ERROR_NONE); +} + +static void ___remote_exception_from(rpc_port_parcel_h parcel, void *user_data) +{ + _remote_exception_h h = user_data; + rpc_port_unit_map_h map; + + map = rpc_port_unit_map_create(); + if (map == nullptr) { + set_last_result(RPC_PORT_ERROR_OUT_OF_MEMORY); + return; + } + + rpc_port_parcel_read(parcel, &map->parcelable, map); + rpc_port_unit_map_read_int(map, "cause", &h->cause); + rpc_port_unit_map_read_string(map, "message", &h->message); + rpc_port_unit_map_destroy(map); + set_last_result(RPC_PORT_ERROR_NONE); +} + +int _remote_exception_create(_remote_exception_h *h) +{ + _remote_exception_h exception; + + if (h == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + exception = calloc(1, sizeof(_remote_exception_t)); + if (exception == nullptr) { + _E("calloc() is failed"); + return RPC_PORT_ERROR_OUT_OF_MEMORY; + } + + exception->parcelable.to = ___remote_exception_to; + exception->parcelable.from = ___remote_exception_from; + + *h = exception; + + return RPC_PORT_ERROR_NONE; +} + +int _remote_exception_set_cause(_remote_exception_h h, int cause) +{ + if (h == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + h->cause = cause; + + return RPC_PORT_ERROR_NONE; +} + +int _remote_exception_set_message(_remote_exception_h h, const char *message) +{ + if (h == nullptr || message == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + if (h->message) + free(h->message); + + h->message = strdup(message); + if (h->message == nullptr) { + _E("strdup() is failed"); + return RPC_PORT_ERROR_OUT_OF_MEMORY; + } + + return RPC_PORT_ERROR_NONE; +} + +int _remote_exception_get_cause(_remote_exception_h h, int *cause) +{ + if (h == nullptr || cause == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + *cause = h->cause; + + return RPC_PORT_ERROR_NONE; +} + +int _remote_exception_get_message(_remote_exception_h h, char **message) +{ + if (h == nullptr || message == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + *message = strdup(h->message); + if (*message == nullptr) { + _E("strdup() is failed"); + return RPC_PORT_ERROR_OUT_OF_MEMORY; + } + + return RPC_PORT_ERROR_NONE; +} + +int _remote_exception_destroy(_remote_exception_h h) +{ + if (h == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + if (h->message) + free(h->message); + + free(h); + + return RPC_PORT_ERROR_NONE; +} +)__c_cb"; + +/** + * The prefix of the proxy interface. + */ +constexpr const char CB_PROXY_REMOTE_EXCEPTION_BASE[] = +R"__cpp_cb( +int _get_remote_exception(_remote_exception_h *h) +{ + rpc_port_unit_map_h map; + int ret; + + if (h == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + if (___remote_exception == nullptr) { + _W("There is no exceptions"); + *h = nullptr; + return RPC_PORT_ERROR_NONE; + } + + map = rpc_port_unit_map_create(); + if (map == nullptr) { + _E("Failed to create unit map"); + return RPC_PORT_ERROR_OUT_OF_MEMORY; + } + + ret = rpc_port_unit_map_write_remote_exception(map, "clone", ___remote_exception); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to write remote exception. error(%d)", ret); + rpc_port_unit_map_destroy(map); + return ret; + } + + ret = rpc_port_unit_map_read_remote_exception(map, "clone", h); + rpc_port_unit_map_destroy(map); + + return RPC_PORT_ERROR_NONE; +} +)__cpp_cb"; + +constexpr const char CB_STUB_REMOTE_EXCEPTION_BASE[] = +R"__cpp_cb( +int _remote_exception_throw(_remote_exception_h h) +{ + rpc_port_unit_map_h map; + int ret; + + if (h == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + map = rpc_port_unit_map_create(); + if (map == nullptr) { + _E("Failed to create unit map"); + return RPC_PORT_ERROR_OUT_OF_MEMORY; + } + + ret = rpc_port_unit_map_write_remote_exception(map, "clone", h); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to write remote exception. error(%d)", ret); + rpc_port_unit_map_destroy(map); + return ret; + } + + if (___remote_exception != nullptr) { + _remote_exception_destroy(___remote_exception); + ___remote_exception = nullptr; + } + + ret = rpc_port_unit_map_read_remote_exception(map, "clone", &___remote_exception); + rpc_port_unit_map_destroy(map); + + return ret; +} +)__cpp_cb"; + } // namespace version2 } // namespace tidl diff --git a/idlc/gen/version2/c_header_generator_base.cc b/idlc/gen/version2/c_header_generator_base.cc index 7a728fc..832441c 100644 --- a/idlc/gen/version2/c_header_generator_base.cc +++ b/idlc/gen/version2/c_header_generator_base.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 - 2023 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. @@ -135,8 +135,10 @@ void CHeaderGeneratorBase::GenStructureArrayBase(std::ofstream& stream, else id = st.GetID(); - auto param_type_in = GetParamTypeString(ParameterType::Direction::IN, type, id); - auto param_type_out = GetParamTypeString(ParameterType::Direction::OUT, type, id); + auto param_type_in = + GetParamTypeString(ParameterType::Direction::IN, type, id); + auto param_type_out = + GetParamTypeString(ParameterType::Direction::OUT, type, id); ReplaceAll(CB_STRUCTURE_ARRAY_BASE) .Change("", GetHandlePrefix()) @@ -223,8 +225,10 @@ void CHeaderGeneratorBase::GenStructureBase(std::ofstream& stream, for (const auto& e : GetElements(st)) { auto& type = e->GetType(); - auto param_type_in = GetParamTypeString(ParameterType::Direction::IN, type, st.GetID()); - auto param_type_out = GetParamTypeString(ParameterType::Direction::OUT, type, st.GetID()); + auto param_type_in = + GetParamTypeString(ParameterType::Direction::IN, type, st.GetID()); + auto param_type_out = + GetParamTypeString(ParameterType::Direction::OUT, type, st.GetID()); ReplaceAll(CB_STRUCTURE_BASE_SET_GET) .Change("", GetHandlePrefix()) @@ -251,5 +255,25 @@ void CHeaderGeneratorBase::GenStructure(std::ofstream& stream, GenStructureBase(stream, st); } +void CHeaderGeneratorBase::GenRemoteExceptionHandle(std::ofstream& stream) { + ReplaceAll(CB_REMOTE_EXCEPTION_HANDLE) + .Change("", GetHandlePrefix()) + .Transform([&](std::string code) { return SmartIndent(code); }) + .Out(stream); +} + +void CHeaderGeneratorBase::GenRemoteException(std::ofstream& stream) { + ReplaceAll(CB_REMOTE_EXCEPTION_BASE) + .Change("", GetHandlePrefix()) + .Transform([&](std::string code) { return SmartIndent(code); }) + .Out(stream); + + ReplaceAll(IsProxy() ? CB_PROXY_REMOTE_EXCEPTION_BASE + : CB_STUB_REMOTE_EXCEPTION_BASE) + .Change("", GetHandlePrefix()) + .Transform([&](std::string code) { return SmartIndent(code); }) + .Out(stream); +} + } // namespace version2 } // namespace tidl diff --git a/idlc/gen/version2/c_header_generator_base.hh b/idlc/gen/version2/c_header_generator_base.hh index def5c8a..d5171dd 100644 --- a/idlc/gen/version2/c_header_generator_base.hh +++ b/idlc/gen/version2/c_header_generator_base.hh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 - 2023 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. @@ -32,6 +32,8 @@ class CHeaderGeneratorBase : public tidl::CHeaderGeneratorBase { void GenStructureHandles(std::ofstream& stream) override; void GenStructures(std::ofstream& stream) override; void GenEnums(std::ofstream& stream); + void GenRemoteExceptionHandle(std::ofstream& stream); + void GenRemoteException(std::ofstream& stream); private: void GenStructureHandle(std::ofstream& stream, const Structure& st); diff --git a/idlc/gen/version2/c_header_generator_base_cb.hh b/idlc/gen/version2/c_header_generator_base_cb.hh index da8b7be..a6c5992 100644 --- a/idlc/gen/version2/c_header_generator_base_cb.hh +++ b/idlc/gen/version2/c_header_generator_base_cb.hh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 - 2023 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. @@ -139,6 +139,141 @@ int __set_(__h h, value int __get_(__h h, value); )__c_cb"; +/** + * The prefix of the interface. + */ +constexpr const char CB_REMOTE_EXCEPTION_HANDLE[] = +R"__c_cb( +/** + * @breif The remote exception handle. + */ +typedef struct _remote_exception_s *_remote_exception_h; +)__c_cb"; + +/** + * The prefix of the interface. + */ +constexpr const char CB_REMOTE_EXCEPTION_BASE[] = +R"__c_cb( +/** + * @brief Creates the remote exception handle. + * + * @remarks The @c h handle should be released if it's no longer needed. + * @param[out] h The remote exception handle. + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @see _remote_exception_destroy() + */ +int _remote_exception_create(_remote_exception_h *h); + +/** + * @brief Sets the cause of the exception. + * + * @param[in] h The remote exception handle + * @param[in] cause The cause of the exception + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int _remote_exception_set_cause(_remote_exception_h h, int cause); + +/** + * @brief Sets the detail message of the exception. + * + * @param[in] h The remote exception handle + * @param[in] message The detail message of the exception + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + */ +int _remote_exception_set_message(_remote_exception_h h, const char *message); + +/** + * @brief Gets the cause of the exception. + * @param[in] h The remote exception handle. + * @param[out] cause The cause + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int _remote_exception_get_cause(_remote_exception_h h, int *cause); + +/** + * @brief Gets the detail message of the exception. + * @remarks The @c message should be released if it's no longer needed. + * @param[in] h The remote exception handle. + * @param[out] message The detail message + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + */ +int _remote_exception_get_message(_remote_exception_h, char **message); + +/** + * @brief Destroys the remote exception handle. + * @param[in] h The remote exception handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int _remote_exception_destroy(_remote_exception_h h); +)__c_cb"; + +/** + * The prefix of the proxy interface. + */ +constexpr const char CB_PROXY_REMOTE_EXCEPTION_BASE[] = +R"__cpp_cb( +/** + * @brief Gets the remote exception handle. + * @details If the return value is nullptr, there is no exceptions. + * @remarks The handle should be released using _remote_exception_destroy(), if it's no longer needed. + * @param[out] h The remote exception handle. + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @see _remote_exception_destroy(); + */ +int _get_remote_exception(_remote_exception_h *h); +)__cpp_cb"; + +/** + * The prefix of the stub interface. + */ +constexpr const char CB_STUB_REMOTE_EXCEPTION_BASE[] = +R"__c_cb( +/** + * @brief Throws the exception to the client. + * @details This function throws the exception to the client in the callback function. + * While calling the registered callback function related the method call, this function should be called + * if you want to send the remote exception to the client. + * If this function is called outside of the registered callback function, it's meaningless. + * The callback function is not returned by calling this function. + * + * @param[in] h The remote exception handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @see _remote_exception_create() + * @see _remote_exception_destroy() + */ +int _remote_exception_throw(_remote_exception_h h); +)__c_cb"; + } // namespace version2 } // namespace tidl diff --git a/idlc/gen/version2/c_proxy_body_generator.cc b/idlc/gen/version2/c_proxy_body_generator.cc index 7f4f7fb..ad17342 100644 --- a/idlc/gen/version2/c_proxy_body_generator.cc +++ b/idlc/gen/version2/c_proxy_body_generator.cc @@ -44,11 +44,13 @@ void CProxyBodyGenerator::OnInitGen(std::ofstream& stream) { GenDelegateDefinition(stream); GenInterfaceDelegateCallback(stream); GenStructureDefinition(stream); + GenRemoteExceptionDefinition(stream); GenInterfaceDefinition(stream); GenUnitMapBase(stream); GenDelegateBase(stream); GenPrivateSharingListSet(stream); GenStructure(stream); + GenRemoteExceptionBase(stream); GenInterface(stream); } @@ -88,7 +90,6 @@ void CProxyBodyGenerator::GenInterfaceDefinition(std::ofstream& stream) { GenInterfaceDelegateDefinition(stream, iface, *decl); } - GenInterfaceRemoteExceptionDefinition(stream, iface); GenInterfaceBaseDefinition(stream, iface); } } @@ -103,15 +104,6 @@ void CProxyBodyGenerator::GenInterfaceDelegateDefinition(std::ofstream& stream, .Out(stream); } -void CProxyBodyGenerator::GenInterfaceRemoteExceptionDefinition( - std::ofstream& stream, const Interface& iface) { - ReplaceAll(CB_INTERFACE_REMOTE_EXCEPTION_DEF) - .Change("", GetHandlePrefix()) - .Change("", iface.GetID()) - .Transform([&](std::string code) { return SmartIndent(code); }) - .Out(stream); -} - void CProxyBodyGenerator::GenInterfaceBaseDefinition(std::ofstream& stream, const Interface& iface) { ReplaceAll(CB_INTERFACE_BASE_DEF) @@ -138,7 +130,6 @@ void CProxyBodyGenerator::GenInterface(std::ofstream& stream) { GenInterfaceDelegateTable(stream, iface); GenInterfaceMethodEnumBase(stream, iface); - GenInterfaceRemoteExceptionBase(stream, iface); GenDelegateProcess(stream, iface); GenInterfaceBase(stream, iface); @@ -363,7 +354,8 @@ std::string CProxyBodyGenerator::GenMethodUnitMapRead(const Interface& iface, void CProxyBodyGenerator::GenMethodBase(std::ofstream& stream, const Interface& iface, const Declaration& decl) { ReplaceAll(CB_INTERFACE_METHOD_BASE) - .Change("", GetReturnTypeString(decl.GetType(), iface.GetID())) + .Change("", + GetReturnTypeString(decl.GetType(), iface.GetID())) .Change("", GetHandlePrefix()) .Change("", iface.GetID()) .Change("", decl.GetID()) @@ -396,7 +388,8 @@ void CProxyBodyGenerator::GenInterfaceBase(std::ofstream& stream, std::string prefix = GetHandlePrefix(); std::string name = iface.GetID(); std::string event = HasDelegate() ? CB_INTERFACE_DELEGATE_REGISTER_EVENT : ""; - std::string callback = HasDelegate() ? CB_INTERFACE_DELEGATE_LEM_RECEIVE_CALLBACK : ""; + std::string callback = + HasDelegate() ? CB_INTERFACE_DELEGATE_LEM_RECEIVE_CALLBACK : ""; ReplaceAll(CB_INTERFACE_BASE) .Change("", event) @@ -410,15 +403,6 @@ void CProxyBodyGenerator::GenInterfaceBase(std::ofstream& stream, .Out(stream); } -void CProxyBodyGenerator::GenInterfaceRemoteExceptionBase(std::ofstream& stream, - const Interface& iface) { - ReplaceAll(CB_INTERFACE_REMOTE_EXCEPTION_BASE) - .Change("", GetHandlePrefix()) - .Change("", iface.GetID()) - .Transform([&](std::string code) { return SmartIndent(code); }) - .Out(stream); -} - void CProxyBodyGenerator::GenInterfaceMethodEnumBase(std::ofstream& stream, const Interface& iface) { std::string enums = GetHandlePrefix() + "_" + iface.GetID() + diff --git a/idlc/gen/version2/c_proxy_body_generator.hh b/idlc/gen/version2/c_proxy_body_generator.hh index 806ef3e..98e5443 100644 --- a/idlc/gen/version2/c_proxy_body_generator.hh +++ b/idlc/gen/version2/c_proxy_body_generator.hh @@ -39,51 +39,49 @@ class CProxyBodyGenerator : public CBodyGeneratorBase { void GenInterfaceDelegateCallback(std::ofstream& stream); void GenInterfaceDefinition(std::ofstream& stream); void GenInterfaceDelegateDefinition(std::ofstream& stream, - const Interface& iface, const Declaration& decl); - void GenInterfaceRemoteExceptionDefinition(std::ofstream& stream, - const Interface& iface); + const Interface& iface, + const Declaration& decl); void GenInterfaceBaseDefinition(std::ofstream& stream, - const Interface& iface); + const Interface& iface); void GenInterface(std::ofstream& stream); std::string GenMethodParams(const Interface& iface, const Declaration& decl); std::string GenMethodArgs(const Interface& iface, const Declaration& decl); std::string GenMethodParamsCheck(const Interface& iface, - const Declaration& decl); + const Declaration& decl); std::string GenMethodUnitMapWrite(const Interface& iface, - const Declaration& decl); + const Declaration& decl); std::string GenMethodDelegateAppend(const Interface& iface, - const Declaration& decl); + const Declaration& decl); void GenMethodAsyncBase(std::ofstream& stream, const Interface& iface, - const Declaration& decl); + const Declaration& decl); std::string GenMethodUnitMapReadBase(const Interface& iface, - const BaseType& type, const std::string& arg_name, - const std::string& arg); + const BaseType& type, + const std::string& arg_name, + const std::string& arg); std::string GenMethodUnitMapRead(const Interface& iface, - const Declaration& decl); - std::string GenMethodRefFree(const Interface& iface, - const BaseType& type, const std::string& arg); + const Declaration& decl); + std::string GenMethodRefFree(const Interface& iface, const BaseType& type, + const std::string& arg); void GenMethodBase(std::ofstream& stream, const Interface& iface, - const Declaration& decl); + const Declaration& decl); void GenInterfaceMethodBase(std::ofstream& stream, const Interface& iface, - const Declaration& decl); + const Declaration& decl); void GenInterfaceBase(std::ofstream& stream, const Interface& iface); - void GenInterfaceRemoteExceptionBase(std::ofstream& stream, - const Interface& iface); void GenInterfaceMethodEnumBase(std::ofstream& stream, - const Interface& iface); + const Interface& iface); void GenInterfaceDelegateTable(std::ofstream& stream, const Interface& iface); void GenInterfaceDelegateBase(std::ofstream& stream, const Interface& iface, - const Declaration& decl); + const Declaration& decl); void GenDelegateProcess(std::ofstream& stream, const Interface& iface); std::string GenDelegateCallbackArgs(const Declaration& decl); std::string GenDelegateUnitMapRead(const Interface& iface, - const Declaration& decl); + const Declaration& decl); std::string GenDelegateArgsDecl(const Interface& iface, - const Declaration& decl); + const Declaration& decl); std::string GenDelegateArgsFree(const Interface& iface, - const Declaration& decl, bool* has_free); + const Declaration& decl, bool* has_free); void GenInterfaceDelegateEnumBase(std::ofstream& stream, - const Interface& iface); + const Interface& iface); void GenDelegateDefinition(std::ofstream& stream); void GenDelegateBase(std::ofstream& stream); void GenLemDefinition(std::ofstream& stream); diff --git a/idlc/gen/version2/c_proxy_body_generator_cb.hh b/idlc/gen/version2/c_proxy_body_generator_cb.hh index 09b194a..94e71ff 100644 --- a/idlc/gen/version2/c_proxy_body_generator_cb.hh +++ b/idlc/gen/version2/c_proxy_body_generator_cb.hh @@ -733,11 +733,11 @@ static void ____consume_command(rpc_port_h port, int seq_num, rpc_ rpc_port_unit_map_read_int(map, "[METHOD]", &cmd); if (cmd == __METHOD_RESULT_) { - if (____remote_exception != nullptr) - __remote_exception_destroy(____remote_exception); + if (___remote_exception != nullptr) + _remote_exception_destroy(___remote_exception); - ____remote_exception = nullptr; - rpc_port_unit_map_read__remote_exception(map, "[REMOTE_EXCEPTION]", &____remote_exception); + ___remote_exception = nullptr; + rpc_port_unit_map_read_remote_exception(map, "[REMOTE_EXCEPTION]", &___remote_exception); *unit_map = map; return; @@ -1373,167 +1373,6 @@ R"__c_cb( h->delegates = g_list_append(h->delegates, ); )__c_cb"; -/** - * The prefix of the interface. - * The name of the interface. - */ -constexpr const char CB_INTERFACE_REMOTE_EXCEPTION_DEF[] = -R"__c_cb( -typedef struct __remote_exception_s { - rpc_port_parcelable_t parcelable; - int cause; - char *message; -} __remote_exception_t; - -static __thread __remote_exception_h ____remote_exception; - -static int __remote_exception_create(__remote_exception_h *h); -)__c_cb"; - -/** - * The prefix of the interface. - * The name of the interface. - */ -constexpr const char CB_INTERFACE_REMOTE_EXCEPTION_BASE[] = -R"__c_cb( -static void ____remote_exception_to(rpc_port_parcel_h parcel, void *user_data) -{ - __remote_exception_h h = user_data; - rpc_port_unit_map_h map; - - map = rpc_port_unit_map_create(); - if (map == nullptr) { - set_last_result(RPC_PORT_ERROR_OUT_OF_MEMORY); - return; - } - - rpc_port_unit_map_write_int(map, "cause", h->cause); - rpc_port_unit_map_write_string(map, "message", h->message); - rpc_port_parcel_write(parcel, &map->parcelable, map); - rpc_port_unit_map_destroy(map); - set_last_result(RPC_PORT_ERROR_NONE); -} - -static void ____remote_exception_from(rpc_port_parcel_h parcel, void *user_data) -{ - __remote_exception_h h = user_data; - rpc_port_unit_map_h map; - - map = rpc_port_unit_map_create(); - if (map == nullptr) { - set_last_result(RPC_PORT_ERROR_OUT_OF_MEMORY); - return; - } - - rpc_port_parcel_read(parcel, &map->parcelable, map); - rpc_port_unit_map_read_int(map, "cause", &h->cause); - rpc_port_unit_map_read_string(map, "message", &h->message); - rpc_port_unit_map_destroy(map); - set_last_result(RPC_PORT_ERROR_NONE); -} - -static int __remote_exception_create(__remote_exception_h *h) -{ - __remote_exception_h exception; - - if (h == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - exception = calloc(1, sizeof(__remote_exception_t)); - if (exception == nullptr) { - _E("calloc() is failed"); - return RPC_PORT_ERROR_OUT_OF_MEMORY; - } - - exception->parcelable.to = ____remote_exception_to; - exception->parcelable.from = ____remote_exception_from; - - *h = exception; - - return RPC_PORT_ERROR_NONE; -} - -int __get_remote_exception(__remote_exception_h *h) -{ - rpc_port_unit_map_h map; - int ret; - - if (h == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - if (____remote_exception == nullptr) { - _W("There is no exceptions"); - *h = nullptr; - return RPC_PORT_ERROR_NONE; - } - - map = rpc_port_unit_map_create(); - if (map == nullptr) { - _E("Failed to create unit map"); - return RPC_PORT_ERROR_OUT_OF_MEMORY; - } - - ret = rpc_port_unit_map_write__remote_exception(map, "clone", ____remote_exception); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to write remote exception. error(%d)", ret); - rpc_port_unit_map_destroy(map); - return ret; - } - - ret = rpc_port_unit_map_read__remote_exception(map, "clone", h); - rpc_port_unit_map_destroy(map); - - return RPC_PORT_ERROR_NONE; -} - -int __remote_exception_get_cause(__remote_exception_h h, int *cause) -{ - if (h == nullptr || cause == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - *cause = h->cause; - - return RPC_PORT_ERROR_NONE; -} - -int __remote_exception_get_message(__remote_exception_h h, char **message) -{ - if (h == nullptr || message == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - *message = strdup(h->message); - if (*message == nullptr) { - _E("strdup() is failed"); - return RPC_PORT_ERROR_OUT_OF_MEMORY; - } - - return RPC_PORT_ERROR_NONE; -} - -int __remote_exception_destroy(__remote_exception_h h) -{ - if (h == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - if (h->message) - free(h->message); - - free(h); - - return RPC_PORT_ERROR_NONE; -} -)__c_cb"; - } // namespace version2 } // namespace tidl diff --git a/idlc/gen/version2/c_proxy_header_generator.cc b/idlc/gen/version2/c_proxy_header_generator.cc index 8841359..e188e79 100644 --- a/idlc/gen/version2/c_proxy_header_generator.cc +++ b/idlc/gen/version2/c_proxy_header_generator.cc @@ -32,8 +32,10 @@ void CProxyHeaderGenerator::OnInitGen(std::ofstream& stream) { GenExplicitLinkageOpen(stream); GenEnums(stream); GenStructureHandles(stream); + GenRemoteExceptionHandle(stream); GenInterfaceHandles(stream); GenStructures(stream); + GenRemoteException(stream); GenInterfaces(stream); } @@ -48,7 +50,6 @@ void CProxyHeaderGenerator::GenInterfaceHandles(std::ofstream& stream) { auto& iface = static_cast(*b); GenInterfaceHandle(stream, iface); - GenInterfaceRemoteExceptionHandle(stream, iface); for (const auto& d : iface.GetDeclarations()) { if (d->GetMethodType() != Declaration::MethodType::DELEGATE) continue; @@ -67,15 +68,6 @@ void CProxyHeaderGenerator::GenInterfaceHandle(std::ofstream& stream, .Out(stream); } -void CProxyHeaderGenerator::GenInterfaceRemoteExceptionHandle( - std::ofstream& stream, const Interface& iface) { - ReplaceAll(CB_INTERFACE_REMOTE_EXCEPTION_HANDLE) - .Change("", GetHandlePrefix()) - .Change("", iface.GetID()) - .Transform([&](std::string code) { return SmartIndent(code); }) - .Out(stream); -} - void CProxyHeaderGenerator::GenInterfaceDelegateHandle(std::ofstream& stream, const Interface& iface, const Declaration& decl) { ReplaceAll(CB_INTERFACE_DELEGATE_HANDLE) @@ -105,7 +97,6 @@ void CProxyHeaderGenerator::GenInterface(std::ofstream& stream, GenInterfaceDelegateBase(stream, iface, *d); } - GenInterfaceRemoteExceptionBase(stream, iface); GenInterfaceBase(stream, iface); for (const auto& d : iface.GetDeclarations()) { @@ -125,15 +116,6 @@ void CProxyHeaderGenerator::GenInterfaceBase(std::ofstream& stream, .Out(stream); } -void CProxyHeaderGenerator::GenInterfaceRemoteExceptionBase( - std::ofstream& stream, const Interface& iface) { - ReplaceAll(CB_INTERFACE_REMOTE_EXCEPTION_BASE) - .Change("", GetHandlePrefix()) - .Change("", iface.GetID()) - .Transform([&](std::string code) { return SmartIndent(code); }) - .Out(stream); -} - std::string CProxyHeaderGenerator::GenDelegateParams(const Interface& iface, const Declaration& decl) { std::string params; @@ -176,7 +158,8 @@ std::string CProxyHeaderGenerator::GenMethodParams(const Interface& iface, void CProxyHeaderGenerator::GenInterfaceMethodBase(std::ofstream& stream, const Interface& iface, const Declaration& decl) { ReplaceAll(CB_INTERFACE_METHOD_BASE) - .Change("", GetReturnTypeString(decl.GetType(), iface.GetID())) + .Change("", + GetReturnTypeString(decl.GetType(), iface.GetID())) .Change("", GetHandlePrefix()) .Change("", iface.GetID()) .Change("", decl.GetID()) diff --git a/idlc/gen/version2/c_proxy_header_generator.hh b/idlc/gen/version2/c_proxy_header_generator.hh index d7cb19f..468eed6 100644 --- a/idlc/gen/version2/c_proxy_header_generator.hh +++ b/idlc/gen/version2/c_proxy_header_generator.hh @@ -36,22 +36,18 @@ class CProxyHeaderGenerator : public CHeaderGeneratorBase { private: void GenInterfaceHandles(std::ofstream& stream); void GenInterfaceHandle(std::ofstream& stream, const Interface& iface); - void GenInterfaceRemoteExceptionHandle(std::ofstream& stream, - const Interface& iface); void GenInterfaceDelegateHandle(std::ofstream& stream, const Interface& iface, - const Declaration& decl); + const Declaration& decl); void GenInterfaces(std::ofstream& stream); void GenInterface(std::ofstream& stream, const Interface& iface); - void GenInterfaceRemoteExceptionBase(std::ofstream& stream, - const Interface& iface); void GenInterfaceDelegateBase(std::ofstream& stream, const Interface& iface, - const Declaration& decl); + const Declaration& decl); void GenInterfaceBase(std::ofstream& stream, const Interface& iface); void GenInterfaceMethodBase(std::ofstream& stream, const Interface& ifaceo, - const Declaration& decl); + const Declaration& decl); std::string GenDelegateParams(const Interface& iface, - const Declaration& decl); + const Declaration& decl); std::string GenMethodParams(const Interface& iface, const Declaration& decl); }; diff --git a/idlc/gen/version2/c_proxy_header_generator_cb.hh b/idlc/gen/version2/c_proxy_header_generator_cb.hh index ceec0ff..a7e66ea 100644 --- a/idlc/gen/version2/c_proxy_header_generator_cb.hh +++ b/idlc/gen/version2/c_proxy_header_generator_cb.hh @@ -340,65 +340,6 @@ R"__c_cb( __invoke_(__h h); )__c_cb"; -constexpr const char CB_INTERFACE_REMOTE_EXCEPTION_HANDLE[] = -R"__c_cb( -/** - * @breif The remote exception handle. - */ -typedef struct __remote_exception_s *__remote_exception_h; -)__c_cb"; - -constexpr const char CB_INTERFACE_REMOTE_EXCEPTION_BASE[] = -R"__c_cb( -/** - * @brief Gets the remote exception handle. - * @details If the return value is nullptr, there is no exceptions. - * @remarks The handle should be released using __remote_exception_destroy(), if it's no longer needed. - * @param[out] h The remote exception handle. - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @see __remote_exception_destroy(); - */ -int __get_remote_exception(__remote_exception_h *h); - -/** - * @brief Gets the cause of the exception. - * @param[in] h The remote exception handle. - * @param[out] cause The cause - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - */ -int __remote_exception_get_cause(__remote_exception_h h, int *cause); - -/** - * @brief Gets the detail message of the exception. - * @remarks The @c message should be released if it's no longer needed. - * @param[in] h The remote exception handle. - * @param[out] message The detail message - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - */ -int __remote_exception_get_message(__remote_exception_h, char **message); - -/** - * @brief Destroys the remote exception handle. - * @param[in] h The remote exception handle - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - */ -int __remote_exception_destroy(__remote_exception_h h); -)__c_cb"; - } // namespace version2 } // namespace tidl diff --git a/idlc/gen/version2/c_stub_body_generator.cc b/idlc/gen/version2/c_stub_body_generator.cc index d8c9e5a..f526afa 100644 --- a/idlc/gen/version2/c_stub_body_generator.cc +++ b/idlc/gen/version2/c_stub_body_generator.cc @@ -45,11 +45,13 @@ void CStubBodyGenerator::OnInitGen(std::ofstream& stream) { GenInterfaceMethodHandlerType(stream); GenDelegateDefinition(stream); GenStructureDefinition(stream); + GenRemoteExceptionDefinition(stream); GenInterfaceDefs(stream); GenPrivateSharingListSet(stream); GenUnitMapBase(stream); GenDelegateBase(stream); GenStructure(stream); + GenRemoteExceptionBase(stream); GenInterfaces(stream); } @@ -107,50 +109,41 @@ void CStubBodyGenerator::GenInterfaceEnum(std::ofstream& stream, // @see #CB_INTERFACE_METHOD_ENUM std::string CStubBodyGenerator::GenMethodEnums(const Interface& iface) { - std::string method_enum(ReplaceAll(CB_INTERFACE_METHOD_ENUM, { - { "", GetHandlePrefix() }, - { "", iface.GetID() }, - { "", "RESULT_" } - })); - - std::string method_enums = RemoveLine(method_enum); - - method_enum = ReplaceAll(CB_INTERFACE_METHOD_ENUM, { - { "", GetHandlePrefix() }, - { "", iface.GetID() }, - { "", "CALLBACK_" } - }); - - method_enums += RemoveLine(method_enum); + std::string method_enums; + method_enums += RemoveLine( + std::string(ReplaceAll(CB_INTERFACE_METHOD_ENUM) + .ChangeToUpper("", GetHandlePrefix()) + .ChangeToUpper("", iface.GetID()) + .ChangeToUpper("", "RESULT_"))); + method_enums += RemoveLine( + std::string(ReplaceAll(CB_INTERFACE_METHOD_ENUM) + .ChangeToUpper("", GetHandlePrefix()) + .ChangeToUpper("", iface.GetID()) + .ChangeToUpper("", "CALLBACK_"))); for (const auto& d : iface.GetDeclarations()) { if (d->GetMethodType() == Declaration::MethodType::DELEGATE) continue; - method_enum = ReplaceAll(CB_INTERFACE_METHOD_ENUM, { - { "", GetHandlePrefix() }, - { "", iface.GetID() }, - { "", d->GetID() } - }); - - method_enums += RemoveLine(method_enum); + method_enums += RemoveLine( + std::string(ReplaceAll(CB_INTERFACE_METHOD_ENUM) + .ChangeToUpper("", GetHandlePrefix()) + .ChangeToUpper("", iface.GetID()) + .ChangeToUpper("", d->GetID()))); } - std::transform(method_enums.begin(), method_enums.end(), method_enums.begin(), - ::toupper); return method_enums; } // @see #CB_INTERFACE_METHOD_ENUM_BASE void CStubBodyGenerator::GenInterfaceMethodEnumBase(std::ofstream& stream, - const Interface& iface) { - std::string code(ReplaceAll(CB_INTERFACE_METHOD_ENUM_BASE, { - { "", GetHandlePrefix() }, - { "", iface.GetID() }, - { "", GenMethodEnums(iface) } - })); - - stream << SmartIndent(code); + const Interface& iface) { + ReplaceAll(CB_INTERFACE_METHOD_ENUM_BASE) + .Change("", GetHandlePrefix()) + .Change("", iface.GetID()) + .Change("", GenMethodEnums(iface)) + .Transform([&](std::string code) { return SmartIndent(code); }) + .Out(stream); } // @see #CB_INTERFACE_DELEGATE_ENUM @@ -161,35 +154,30 @@ std::string CStubBodyGenerator::GenDelegateEnums(const Interface& iface) { if (d->GetMethodType() != Declaration::MethodType::DELEGATE) continue; - std::string method_enum(ReplaceAll(CB_INTERFACE_DELEGATE_ENUM, { - { "", GetHandlePrefix() }, - { "", iface.GetID() }, - { "", d->GetID() }, - { "", std::to_string(num++) } - })); - - method_enums += RemoveLine(method_enum); + method_enums += RemoveLine( + std::string(ReplaceAll(CB_INTERFACE_DELEGATE_ENUM) + .ChangeToUpper("", GetHandlePrefix()) + .ChangeToUpper("", iface.GetID()) + .ChangeToUpper("", d->GetID()) + .ChangeToUpper("", std::to_string(num++)))); } - std::transform(method_enums.begin(), method_enums.end(), method_enums.begin(), - ::toupper); return method_enums; } // @see #CB_INTERFACE_DELEGATE_ENUM_BASE void CStubBodyGenerator::GenInterfaceDelegateEnumBase(std::ofstream& stream, - const Interface& iface) { + const Interface& iface) { std::string delegate_enums = GenDelegateEnums(iface); if (delegate_enums.empty()) return; - std::string code(ReplaceAll(CB_INTERFACE_DELEGATE_ENUM_BASE, { - { "", GetHandlePrefix() }, - { "", iface.GetID() }, - { "", delegate_enums } - })); - - stream << SmartIndent(code); + ReplaceAll(CB_INTERFACE_DELEGATE_ENUM_BASE) + .Change("", GetHandlePrefix()) + .Change("", iface.GetID()) + .Change("", delegate_enums) + .Transform([&](std::string code) { return SmartIndent(code); }) + .Out(stream); } void CStubBodyGenerator::GenInterfaceDefs(std::ofstream& stream) { @@ -203,7 +191,7 @@ void CStubBodyGenerator::GenInterfaceDefs(std::ofstream& stream) { } void CStubBodyGenerator::GenInterfaceDef(std::ofstream& stream, - const Interface& iface) { + const Interface& iface) { bool has_delegate = false; for (const auto& d : iface.GetDeclarations()) { if (d->GetMethodType() != Declaration::MethodType::DELEGATE) @@ -217,63 +205,50 @@ void CStubBodyGenerator::GenInterfaceDef(std::ofstream& stream, GenInterfaceCallbackPortCheckDef(stream, iface); GenInterfaceContextDef(stream, iface); - GenInterfaceRemoteExceptionDefinition(stream, iface); GenInterfaceBaseDef(stream, iface); } // @see #CB_INTERFACE_DELEGATE_DEF void CStubBodyGenerator::GenInterfaceDelegateDef(std::ofstream& stream, - const Interface& iface, const Declaration& decl) { - std::string code(ReplaceAll(CB_INTERFACE_DELEGATE_DEF, { - { "", GetHandlePrefix() }, - { "", iface.GetID() }, - { "", decl.GetID() } - })); - - stream << SmartIndent(code); + const Interface& iface, + const Declaration& decl) { + ReplaceAll(CB_INTERFACE_DELEGATE_DEF) + .Change("", GetHandlePrefix()) + .Change("", iface.GetID()) + .Change("", decl.GetID()) + .Transform([&](std::string code) { return SmartIndent(code); }) + .Out(stream); } // @see #CB_INTERFACE_CALLBACK_PORT_CHECK_DEF -void CStubBodyGenerator::GenInterfaceCallbackPortCheckDef(std::ofstream& stream, - const Interface& iface) { - std::string code(ReplaceAll(CB_INTERFACE_CALLBACK_PORT_CHECK_DEF, { - { "", GetHandlePrefix() }, - { "", iface.GetID() } - })); - - stream << SmartIndent(code); +void CStubBodyGenerator::GenInterfaceCallbackPortCheckDef( + std::ofstream& stream, const Interface& iface) { + ReplaceAll(CB_INTERFACE_CALLBACK_PORT_CHECK_DEF) + .Change("", GetHandlePrefix()) + .Change("", iface.GetID()) + .Transform([&](std::string code) { return SmartIndent(code); }) + .Out(stream); } // @see #CB_INTERFACE_CONTEXT_DEF void CStubBodyGenerator::GenInterfaceContextDef(std::ofstream& stream, - const Interface& iface) { - std::string code(ReplaceAll(CB_INTERFACE_CONTEXT_DEF, { - { "", GetHandlePrefix() }, - { "", iface.GetID() } - })); - - stream << SmartIndent(code); -} - -// @see #CB_INTERFACE_REMOTE_EXCEPTION_DEF -void CStubBodyGenerator::GenInterfaceRemoteExceptionDefinition( - std::ofstream& stream, const Interface& iface) { - ReplaceAll(CB_INTERFACE_REMOTE_EXCEPTION_DEF) + const Interface& iface) { + ReplaceAll(CB_INTERFACE_CONTEXT_DEF) .Change("", GetHandlePrefix()) .Change("", iface.GetID()) .Transform([&](std::string code) { return SmartIndent(code); }) .Out(stream); } + // @see #CB_INTERFACE_BASE_DEF void CStubBodyGenerator::GenInterfaceBaseDef(std::ofstream& stream, - const Interface& iface) { - std::string code(ReplaceAll(CB_INTERFACE_BASE_DEF, { - { "", GetHandlePrefix() }, - { "", iface.GetID() } - })); - - stream << SmartIndent(code); + const Interface& iface) { + ReplaceAll(CB_INTERFACE_BASE_DEF) + .Change("", GetHandlePrefix()) + .Change("", iface.GetID()) + .Transform([&](std::string code) { return SmartIndent(code); }) + .Out(stream); } void CStubBodyGenerator::GenInterfaces(std::ofstream& stream) { @@ -308,7 +283,6 @@ void CStubBodyGenerator::GenInterface(std::ofstream& stream, GenInterfaceMethodPrivilegeCheckerTable(stream, iface); GenInterfaceMethodTable(stream, iface); GenInterfaceContextBase(stream, iface); - GenInterfaceRemoteExceptionBase(stream, iface); if (has_delegate) GenInterfaceCallbackPortCheck(stream, iface); @@ -328,16 +302,6 @@ void CStubBodyGenerator::GenInterfaceContextBase(std::ofstream& stream, .Out(stream); } -// @see #CB_INTERFACE_REMOTE_EXCEPTION_BASE -void CStubBodyGenerator::GenInterfaceRemoteExceptionBase( - std::ofstream& stream, const Interface& iface) { - ReplaceAll(CB_INTERFACE_REMOTE_EXCEPTION_BASE) - .Change("", GetHandlePrefix()) - .Change("", iface.GetID()) - .Transform([&](std::string code) { return SmartIndent(code); }) - .Out(stream); -} - std::string CStubBodyGenerator::GenDelegateParams(const Interface& iface, const Declaration& decl) { std::string params; @@ -376,48 +340,39 @@ void CStubBodyGenerator::GenInterfaceDelegateBase(std::ofstream& stream, const Interface& iface, const Declaration& decl) { std::string enum_value = GetHandlePrefix() + "_" + iface.GetID() + "_DELEGATE_" + decl.GetID(); - std::transform(enum_value.begin(), enum_value.end(), enum_value.begin(), - ::toupper); - - std::string prefix = GetHandlePrefix(); - std::transform(prefix.begin(), prefix.end(), prefix.begin(), ::toupper); - - std::string name = iface.GetID(); - std::transform(name.begin(), name.end(), name.begin(), ::toupper); - - std::string code(ReplaceAll(CB_INTERFACE_DELEGATE_BASE, { - { "", GetHandlePrefix() }, - { "", iface.GetID() }, - { "", decl.GetID() }, - { "", GenDelegateParams(iface, decl) }, - { "", GenDelegateParamsCheck(iface, decl) }, - { "", enum_value }, - { "", GenDelegateUnitMapWrite(iface, decl) }, - { "", prefix }, - { "", name } - })); - - stream << SmartIndent(code); + ReplaceAll(CB_INTERFACE_DELEGATE_BASE) + .Change("", GetHandlePrefix()) + .Change("", iface.GetID()) + .Change("", decl.GetID()) + .Change("", GenDelegateParams(iface, decl)) + .Change("", GenDelegateParamsCheck(iface, decl)) + .ChangeToUpper("", enum_value) + .Change("", GenDelegateUnitMapWrite(iface, decl)) + .ChangeToUpper("", GetHandlePrefix()) + .ChangeToUpper("", iface.GetID()) + .Transform([&](std::string code) { return SmartIndent(code); }) + .Out(stream); } -std::string CStubBodyGenerator::GenMethodHandlerArgsDecl(const Interface& iface, - const Declaration& decl) { +std::string CStubBodyGenerator::GenMethodHandlerArgsDecl( + const Interface& iface, const Declaration& decl) { std::string args_decl; for (const auto& p : decl.GetParameters()) { auto& param_type = p->GetParameterType(); auto& type = param_type.GetBaseType(); - if (type.GetUserDefinedType() == BaseType::UserType::ENUM) + if (type.IsEnumType()) { args_decl += GetArgTypeString(type, iface) + p->GetID() + ";" + NLine(1); - else + } else { args_decl += GetArgTypeString(type, iface) + p->GetID() + " = " + - GetErrorValue(type) + ";" + NLine(1); + GetErrorValue(type) + ";" + NLine(1); + } } if (decl.GetMethodType() == Declaration::MethodType::SYNC) { args_decl += "rpc_port_parcel_h parcel_;" + NLine(1); args_decl += "rpc_port_unit_map_h map_;" + NLine(1); - args_decl += GetArgTypeString(decl.GetType(), iface) + "res_ = " + - GetErrorValue(decl.GetType()) + ";" + NLine(1); + args_decl += GetArgTypeString(decl.GetType(), iface) + + "res_ = " + GetErrorValue(decl.GetType()) + ";" + NLine(1); } return args_decl; @@ -429,7 +384,7 @@ std::string CStubBodyGenerator::GenMethodHandlerArgsDecl(const Interface& iface, // @see #CB_INTERFACE_METHOD_STRING_UNIT_MAP_READ // @see #CB_INTERFACE_METHOD_BASE_UNIT_MAP_READ std::string CStubBodyGenerator::GenMethodUnitMapRead(const Interface& iface, - const Declaration& decl) { + const Declaration& decl) { std::string code; for (const auto& p : decl.GetParameters()) { std::string parcel_read_code; @@ -480,16 +435,6 @@ std::string CStubBodyGenerator::GenMethodUnitMapRead(const Interface& iface, // @see #CB_INTERFACE_METHOD_CALLBACK_INVOKE std::string CStubBodyGenerator::GenMethodHandlerCallbackInvoke( const Interface& iface, const Declaration& decl) { - std::string code(ReplaceAll(CB_INTERFACE_METHOD_CALLBACK_INVOKE, - "", decl.GetID())); - code = ReplaceAll(code, "", GetHandlePrefix()); - code = ReplaceAll(code, "", iface.GetID()); - - if (decl.GetMethodType() == Declaration::MethodType::SYNC) - code = ReplaceAll(code, "", "res_ = "); - else - code = ReplaceAll(code, "", ""); - std::string args; for (const auto& p : decl.GetParameters()) { args += ", "; @@ -499,14 +444,21 @@ std::string CStubBodyGenerator::GenMethodHandlerCallbackInvoke( args += p->GetID(); } - code = ReplaceAll(code, "", args); - return RemoveLine(code); + std::string res_set = + (decl.GetMethodType() == Declaration::MethodType::SYNC) ? "res_ = " : ""; + + return RemoveLine(std::string(ReplaceAll(CB_INTERFACE_METHOD_CALLBACK_INVOKE) + .Change("", decl.GetID()) + .Change("", GetHandlePrefix()) + .Change("", iface.GetID()) + .Change("", res_set) + .Change("", args))); } std::string CStubBodyGenerator::GenDelegateUnitMapWrite( const Interface& iface, const Declaration& decl) { - std::string parcel_write_code; + std::string parcel_write_code; for (const auto& p : decl.GetParameters()) { auto& param_type = p->GetParameterType(); parcel_write_code += GenMethodUnitMapWriteBase( @@ -572,22 +524,18 @@ std::string CStubBodyGenerator::GenMethodUnitMapWrite(const Interface& iface, if (decl.GetMethodType() != Declaration::MethodType::SYNC) return code; - std::string prefix = GetHandlePrefix(); - std::transform(prefix.begin(), prefix.end(), prefix.begin(), ::toupper); - code = ReplaceAll(CB_INTERFACE_METHOD_PARCEL_WRITE_PRE, "", - prefix); - - std::string name = iface.GetID(); - std::transform(name.begin(), name.end(), name.begin(), ::toupper); - code = ReplaceAll(code, "", name); + code = ReplaceAll(CB_INTERFACE_METHOD_PARCEL_WRITE_PRE) + .ChangeToUpper("", GetHandlePrefix()) + .ChangeToUpper("", iface.GetID()); std::string parcel_write_code; for (const auto& p : decl.GetParameters()) { auto& param_type = p->GetParameterType(); if (param_type.GetDirection() == ParameterType::Direction::IN) continue; - code += GenMethodUnitMapWriteBase( - iface, param_type.GetBaseType(), p->GetID(), p->GetID()); + + code += GenMethodUnitMapWriteBase(iface, param_type.GetBaseType(), + p->GetID(), p->GetID()); } code += GenMethodUnitMapWriteBase(iface, decl.GetType(), "[RESULT]", "res_"); @@ -604,55 +552,39 @@ std::string CStubBodyGenerator::GenMethodUnitMapWrite(const Interface& iface, // @see #CB_INTERFACE_METHOD_STRING_FREE std::string CStubBodyGenerator::GenMethodHandlerArgsFree(const Interface& iface, const Declaration& decl) { - std::string free_code; std::string code; for (const auto& p : decl.GetParameters()) { auto& param_type = p->GetParameterType(); auto& type = param_type.GetBaseType(); - if (type.GetUserDefinedType() == BaseType::UserType::STRUCTURE || - type.GetUserDefinedType() == BaseType::UserType::DELEGATE || - type.GetMetaType() != nullptr || - type.GetKeyType() != nullptr) { - free_code = ReplaceAll(CB_INTERFACE_METHOD_USER_DEFINED_FREE, - "", GetHandlePrefix()); - free_code = ReplaceAll(free_code, "", - GetFullNameFromType(type, iface)); - free_code = ReplaceAll(free_code, "", p->GetID()); + if (type.IsStructureType() || type.IsDelegateType() || + type.GetMetaType() != nullptr || type.GetKeyType() != nullptr) { + code += ReplaceAll(CB_INTERFACE_METHOD_USER_DEFINED_FREE) + .Change("", GetHandlePrefix()) + .Change("", GetFullNameFromType(type, iface)) + .Change("", p->GetID()); } else if (type.ToString() == "bundle") { - free_code = ReplaceAll(CB_INTERFACE_METHOD_BUNDLE_FREE, - "", p->GetID()); + code += ReplaceAll(CB_INTERFACE_METHOD_BUNDLE_FREE) + .Change("", p->GetID()); } else if (type.ToString() == "string" || type.ToString() == "file") { - free_code = ReplaceAll(CB_INTERFACE_METHOD_STRING_FREE, - "", p->GetID()); - } else { - free_code.clear(); + code += ReplaceAll(CB_INTERFACE_METHOD_STRING_FREE) + .Change("", p->GetID()); } - - code += free_code; } if (decl.GetMethodType() == Declaration::MethodType::SYNC) { + std::string arg = "res_"; auto& type = decl.GetType(); - if (type.GetUserDefinedType() == BaseType::UserType::STRUCTURE || - type.GetUserDefinedType() == BaseType::UserType::DELEGATE || - type.GetMetaType() != nullptr || - type.GetKeyType() != nullptr) { - free_code = ReplaceAll(CB_INTERFACE_METHOD_USER_DEFINED_FREE, - "", GetHandlePrefix()); - free_code = ReplaceAll(free_code, "", - GetFullNameFromType(type, iface)); - free_code = ReplaceAll(free_code, "", "res_"); + if (type.IsStructureType() || type.IsDelegateType() || + type.GetMetaType() != nullptr || type.GetKeyType() != nullptr) { + code += ReplaceAll(CB_INTERFACE_METHOD_USER_DEFINED_FREE) + .Change("", GetHandlePrefix()) + .Change("", GetFullNameFromType(type, iface)) + .Change("", arg); } else if (type.ToString() == "bundle") { - free_code = ReplaceAll(CB_INTERFACE_METHOD_BUNDLE_FREE, - "", "res_"); + code += ReplaceAll(CB_INTERFACE_METHOD_BUNDLE_FREE).Change("", arg); } else if (type.ToString() == "string" || type.ToString() == "file") { - free_code = ReplaceAll(CB_INTERFACE_METHOD_STRING_FREE, - "", "res_"); - } else { - free_code.clear(); + code += ReplaceAll(CB_INTERFACE_METHOD_STRING_FREE).Change("", arg); } - - code += free_code; } return RemoveLine(code); @@ -680,10 +612,10 @@ std::string CStubBodyGenerator::GenMethodPrivilegeChecker( std::string sync = (decl.GetMethodType() == Declaration::MethodType::SYNC) ? "true" : "false"; - std::string code(ReplaceAll(CB_INTERFACE_METHOD_PRIVILEGE_CHECKER) - .Change("", privileges) - .Change("", sync)); - return RemoveLine(code); + return RemoveLine( + std::string(ReplaceAll(CB_INTERFACE_METHOD_PRIVILEGE_CHECKER) + .Change("", privileges) + .Change("", sync))); } // @see #CB_INTERFACE_METHOD_PRIVILEGE_CHECKER_BASE @@ -699,23 +631,22 @@ void CStubBodyGenerator::GenInterfaceMethodPrivilegeCheckerBase( } // @see #CB_INTERFACE_METHOD_HANDLER_BASE -void CStubBodyGenerator::GenInterfaceMethodHandlerBase(std::ofstream& stream, - const Interface& iface, const Declaration& decl) { - std::string code(ReplaceAll(CB_INTERFACE_METHOD_HANDLER_BASE, { - { "", GetHandlePrefix() }, - { "", iface.GetID() }, - { "", decl.GetID() }, - { "", GenMethodHandlerArgsDecl(iface, decl) }, - { "", - GenMethodUnitMapRead(iface, decl) }, - { "", - GenMethodHandlerCallbackInvoke(iface, decl) }, - { "", - GenMethodUnitMapWrite(iface, decl) }, - { "", GenMethodHandlerArgsFree(iface, decl) } - })); - - stream << SmartIndent(code); +void CStubBodyGenerator::GenInterfaceMethodHandlerBase( + std::ofstream& stream, const Interface& iface, const Declaration& decl) { + ReplaceAll(CB_INTERFACE_METHOD_HANDLER_BASE) + .Change("", GetHandlePrefix()) + .Change("", iface.GetID()) + .Change("", decl.GetID()) + .Change("", + GenMethodHandlerArgsDecl(iface, decl)) + .Change("", GenMethodUnitMapRead(iface, decl)) + .Change("", + GenMethodHandlerCallbackInvoke(iface, decl)) + .Change("", GenMethodUnitMapWrite(iface, decl)) + .Change("", + GenMethodHandlerArgsFree(iface, decl)) + .Transform([&](std::string code) { return SmartIndent(code); }) + .Out(stream); } // @ see #CB_INTERFACE_PRIVILEGE_CHECKER @@ -758,16 +689,12 @@ std::string CStubBodyGenerator::GenMethodHandlers(const Interface& iface) { std::string enum_value = GetHandlePrefix() + "_" + iface.GetID() + "_METHOD_" + d->GetID(); - std::transform(enum_value.begin(), enum_value.end(), enum_value.begin(), - ::toupper); - std::string method_handler(ReplaceAll(CB_INTERFACE_METHOD_HANDLER, { - { "", enum_value }, - { "", GetHandlePrefix() }, - { "", iface.GetID() }, - { "", d->GetID() } - })); - - code += RemoveLine(method_handler); + code += + RemoveLine(std::string(ReplaceAll(CB_INTERFACE_METHOD_HANDLER) + .ChangeToUpper("", enum_value) + .Change("", GetHandlePrefix()) + .Change("", iface.GetID()) + .Change("", d->GetID()))); } return code; @@ -775,24 +702,22 @@ std::string CStubBodyGenerator::GenMethodHandlers(const Interface& iface) { // @see #CB_INTERFACE_METHOD_TABLE void CStubBodyGenerator::GenInterfaceMethodTable(std::ofstream& stream, - const Interface& iface) { - std::string code(ReplaceAll(CB_INTERFACE_METHOD_TABLE, { - { "", iface.GetID() }, - { "", GenMethodHandlers(iface) } - })); - - stream << SmartIndent(code); + const Interface& iface) { + ReplaceAll(CB_INTERFACE_METHOD_TABLE) + .Change("", iface.GetID()) + .Change("", GenMethodHandlers(iface)) + .Transform([&](std::string code) { return SmartIndent(code); }) + .Out(stream); } // @see #CB_INTERFACE_CALLBACK_PORT_CHECK void CStubBodyGenerator::GenInterfaceCallbackPortCheck(std::ofstream& stream, - const Interface& iface) { - std::string code(ReplaceAll(CB_INTERFACE_CALLBACK_PORT_CHECK, { - { "", GetHandlePrefix() }, - { "", iface.GetID() } - })); - - stream << SmartIndent(code); + const Interface& iface) { + ReplaceAll(CB_INTERFACE_CALLBACK_PORT_CHECK) + .Change("", GetHandlePrefix()) + .Change("", iface.GetID()) + .Transform([&](std::string code) { return SmartIndent(code); }) + .Out(stream); } // @see #CB_INTERFACE_PRIVILEGE_ADD @@ -801,17 +726,12 @@ std::string CStubBodyGenerator::GenAccessControlSet(const Interface& iface) { std::string code; for (const auto& attr : iface.GetAttributes()) { if (attr->GetKey() == "privilege") { - std::string privilege_add(ReplaceAll(CB_INTERFACE_PRIVILEGE_ADD, { - { "", iface.GetID() }, - { "", attr->GetValue() } - })); - - code += privilege_add; + code += ReplaceAll(CB_INTERFACE_PRIVILEGE_ADD) + .Change("", iface.GetID()) + .Change("", attr->GetValue()); } else if (attr->GetKey() == "trusted" && attr->GetValue() == "true") { - std::string trusted_set(ReplaceAll(CB_INTERFACE_TRUSTED_SET, - "", iface.GetID())); - - code += trusted_set; + code += ReplaceAll(CB_INTERFACE_TRUSTED_SET) + .Change("", iface.GetID()); } } @@ -821,14 +741,13 @@ std::string CStubBodyGenerator::GenAccessControlSet(const Interface& iface) { // @see #CB_INTERFACE_BASE void CStubBodyGenerator::GenInterfaceBase(std::ofstream& stream, const Interface& iface) { - std::string code(ReplaceAll(CB_INTERFACE_BASE, { - { "", GetHandlePrefix() }, - { "", GetHandlePrefixReverse() }, - { "", iface.GetID() }, - { "", GenAccessControlSet(iface) } - })); - - stream << SmartIndent(code); + ReplaceAll(CB_INTERFACE_BASE) + .Change("", GetHandlePrefix()) + .Change("", GetHandlePrefixReverse()) + .Change("", iface.GetID()) + .Change("", GenAccessControlSet(iface)) + .Transform([&](std::string code) { return SmartIndent(code); }) + .Out(stream); } } // namespace version2 diff --git a/idlc/gen/version2/c_stub_body_generator.hh b/idlc/gen/version2/c_stub_body_generator.hh index 91bd231..befeb84 100644 --- a/idlc/gen/version2/c_stub_body_generator.hh +++ b/idlc/gen/version2/c_stub_body_generator.hh @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef IDLC_C_GEN_C_STUB_BODY_GENERATOR_HH_ -#define IDLC_C_GEN_C_STUB_BODY_GENERATOR_HH_ +#ifndef IDLC_GEN_VERSION2_C_STUB_BODY_GENERATOR_HH_ +#define IDLC_GEN_VERSION2_C_STUB_BODY_GENERATOR_HH_ #include #include @@ -29,7 +29,7 @@ namespace version2 { class CStubBodyGenerator : public CBodyGeneratorBase { public: explicit CStubBodyGenerator(std::shared_ptr doc, - std::shared_ptr options); + std::shared_ptr options); virtual ~CStubBodyGenerator() = default; void OnInitGen(std::ofstream& stream) override; @@ -42,64 +42,63 @@ class CStubBodyGenerator : public CBodyGeneratorBase { void GenInterfaceEnums(std::ofstream& stream); void GenInterfaceEnum(std::ofstream& stream, const Interface& iface); void GenInterfaceMethodEnumBase(std::ofstream& stream, - const Interface& iface); + const Interface& iface); void GenInterfaceDelegateEnumBase(std::ofstream& stream, - const Interface& iface); + const Interface& iface); void GenInterfaceDefs(std::ofstream& stream); void GenInterfaceDef(std::ofstream& stream, const Interface& iface); void GenInterfaceContextDef(std::ofstream& stream, const Interface& iface); - void GenInterfaceRemoteExceptionDefinition(std::ofstream& stream, - const Interface& iface); void GenInterfaceDelegateDef(std::ofstream& stream, const Interface& iface, - const Declaration& decl); + const Declaration& decl); void GenInterfaceCallbackPortCheckDef(std::ofstream& stream, - const Interface& iface); + const Interface& iface); void GenInterfaceBaseDef(std::ofstream& stream, const Interface& iface); void GenInterfaces(std::ofstream& stream); void GenInterface(std::ofstream& stream, const Interface& iface); void GenInterfaceContextBase(std::ofstream& stream, const Interface& iface); - void GenInterfaceRemoteExceptionBase(std::ofstream& stream, - const Interface& iface); void GenInterfaceDelegateBase(std::ofstream& stream, const Interface& iface, - const Declaration& decl); + const Declaration& decl); void GenInterfaceMethodPrivilegeCheckerBase(std::ofstream& stream, - const Interface& iface, const Declaration& decl); + const Interface& iface, + const Declaration& decl); void GenInterfaceMethodPrivilegeCheckerTable(std::ofstream& stream, - const Interface& iface); + const Interface& iface); void GenInterfaceMethodHandlerBase(std::ofstream& stream, - const Interface& iface, const Declaration& decl); + const Interface& iface, + const Declaration& decl); void GenInterfaceMethodTable(std::ofstream& stream, const Interface& iface); void GenInterfaceCallbackPortCheck(std::ofstream& stream, - const Interface& iface); + const Interface& iface); void GenInterfaceBase(std::ofstream& stream, const Interface& iface); std::string GenMethodEnums(const Interface& iface); std::string GenDelegateEnums(const Interface& iface); std::string GenDelegateParams(const Interface& iface, - const Declaration& decl); + const Declaration& decl); std::string GenDelegateParamsCheck(const Interface& iface, - const Declaration& decl); + const Declaration& decl); std::string GenPrivileges(const Declaration& decl); std::string GenMethodPrivilegeChecker(const Declaration& decl); std::string GenPrivilegeCheckers(const Interface& iface); std::string GenMethodHandlerArgsDecl(const Interface& iface, - const Declaration& decl); + const Declaration& decl); std::string GenMethodUnitMapRead(const Interface& iface, - const Declaration& decl); + const Declaration& decl); std::string GenMethodHandlerCallbackInvoke(const Interface& iface, - const Declaration& decl); - std::string GenMethodUnitMapWriteBase( - const Interface& iface, const BaseType& type, - const std::string& arg_name, const std::string& arg); + const Declaration& decl); + std::string GenMethodUnitMapWriteBase(const Interface& iface, + const BaseType& type, + const std::string& arg_name, + const std::string& arg); std::string GenMethodUnitMapWrite(const Interface& iface, - const Declaration& decl); - std::string GenDelegateUnitMapWrite( - const Interface& iface, const Declaration& decl); + const Declaration& decl); + std::string GenDelegateUnitMapWrite(const Interface& iface, + const Declaration& decl); std::string GenMethodHandlerArgsFree(const Interface& iface, - const Declaration& decl); + const Declaration& decl); std::string GenMethodHandlers(const Interface& iface); std::string GenAccessControlSet(const Interface& iface); void GenDelegateDefinition(std::ofstream& stream); @@ -113,4 +112,4 @@ class CStubBodyGenerator : public CBodyGeneratorBase { } // namespace version2 } // namespace tidl -#endif // IDLC_C_GEN_C_STUB_BODY_GENERATOR_HH_ +#endif // IDLC_GEN_VERSION2_C_STUB_BODY_GENERATOR_HH_ diff --git a/idlc/gen/version2/c_stub_body_generator_cb.hh b/idlc/gen/version2/c_stub_body_generator_cb.hh index d663076..a43d682 100644 --- a/idlc/gen/version2/c_stub_body_generator_cb.hh +++ b/idlc/gen/version2/c_stub_body_generator_cb.hh @@ -14,8 +14,11 @@ * limitations under the License. */ -#ifndef IDLC_C_GEN_C_STUB_BODY_GENERATOR_CB_H_ -#define IDLC_C_GEN_C_STUB_BODY_GENERATOR_CB_H_ +#ifndef IDLC_GEN_VERSION2_C_STUB_BODY_GENERATOR_CB_HH_ +#define IDLC_GEN_VERSION2_C_STUB_BODY_GENERATOR_CB_HH_ + +namespace tidl { +namespace version2 { constexpr const char CB_PRIVATE_HEADERS[] = R"__c_cb( @@ -243,7 +246,7 @@ constexpr const char CB_INTERFACE_CONTEXT_BASE[] = R"__c_cb( static void ____throw_remote_exception(rpc_port_h port, rpc_port_parcel_h parcel, int cause, const char *message) { - __remote_exception_h remote_exception = nullptr; + _remote_exception_h remote_exception = nullptr; rpc_port_parcel_h result_parcel = nullptr; rpc_port_parcel_header_h header = nullptr; rpc_port_unit_map_h map; @@ -257,11 +260,11 @@ static void ____throw_remote_exception(rpc_port_h port, rpc_port_p rpc_port_unit_map_write_int(map, "[METHOD]", __METHOD_RESULT_); - __remote_exception_create(&remote_exception); - __remote_exception_set_cause(remote_exception, cause); - __remote_exception_set_message(remote_exception, message); - rpc_port_unit_map_write__remote_exception(map, "[REMOTE_EXCEPTION]", remote_exception); - __remote_exception_destroy(remote_exception); + _remote_exception_create(&remote_exception); + _remote_exception_set_cause(remote_exception, cause); + _remote_exception_set_message(remote_exception, message); + rpc_port_unit_map_write_remote_exception(map, "[REMOTE_EXCEPTION]", remote_exception); + _remote_exception_destroy(remote_exception); if (rpc_port_parcel_create(&result_parcel) != RPC_PORT_ERROR_NONE) { _E("Failed to create parcel handle"); @@ -1276,9 +1279,9 @@ rpc_port_parcel_read_(parcel, &); */ constexpr const char CB_INTERFACE_METHOD_CALLBACK_INVOKE[] = R"__c_cb( -if (____remote_exception != nullptr) { - __remote_exception_destroy(____remote_exception); - ____remote_exception = nullptr; +if (___remote_exception != nullptr) { + _remote_exception_destroy(___remote_exception); + ___remote_exception = nullptr; } if (context_->callback.) @@ -1318,8 +1321,8 @@ rpc_port_unit_map_write_int(map_, "[METHOD]", ___remote_exception != nullptr) - rpc_port_unit_map_write__remote_exception(map_, "[REMOTE_EXCEPTION]", ____remote_exception); +if (___remote_exception != nullptr) + rpc_port_unit_map_write_remote_exception(map_, "[REMOTE_EXCEPTION]", ___remote_exception); if (context_->lem_cb.is_LEM) { stub_result_.lem_ret = map_; @@ -1725,167 +1728,6 @@ if (ret != RPC_PORT_ERROR_NONE) { )__c_cb"; /** - * The prefix of the interface. - * The name of the interface. - */ -constexpr const char CB_INTERFACE_REMOTE_EXCEPTION_DEF[] = -R"__c_cb( -typedef struct __remote_exception_s { - rpc_port_parcelable_t parcelable; - int cause; - char *message; -} __remote_exception_t; - -static __thread __remote_exception_h ____remote_exception; -)__c_cb"; - -/** - * The prefix of the interface. - * The name of the interface. - */ -constexpr const char CB_INTERFACE_REMOTE_EXCEPTION_BASE[] = -R"__c_cb( -static void ____remote_exception_to(rpc_port_parcel_h parcel, void *user_data) -{ - __remote_exception_h h = user_data; - rpc_port_unit_map_h map; - - map = rpc_port_unit_map_create(); - if (map == nullptr) { - set_last_result(RPC_PORT_ERROR_OUT_OF_MEMORY); - return; - } - - rpc_port_unit_map_write_int(map, "cause", h->cause); - rpc_port_unit_map_write_string(map, "message", h->message); - rpc_port_parcel_write(parcel, &map->parcelable, map); - rpc_port_unit_map_destroy(map); - set_last_result(RPC_PORT_ERROR_NONE); -} - -static void ____remote_exception_from(rpc_port_parcel_h parcel, void *user_data) -{ - __remote_exception_h h = user_data; - rpc_port_unit_map_h map; - - map = rpc_port_unit_map_create(); - if (map == nullptr) { - set_last_result(RPC_PORT_ERROR_OUT_OF_MEMORY); - return; - } - - rpc_port_parcel_read(parcel, &map->parcelable, map); - rpc_port_unit_map_read_int(map, "cause", &h->cause); - rpc_port_unit_map_read_string(map, "message", &h->message); - rpc_port_unit_map_destroy(map); - set_last_result(RPC_PORT_ERROR_NONE); -} - -int __remote_exception_create(__remote_exception_h *h) -{ - __remote_exception_h exception; - - if (h == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - exception = calloc(1, sizeof(__remote_exception_t)); - if (exception == nullptr) { - _E("calloc() is failed"); - return RPC_PORT_ERROR_OUT_OF_MEMORY; - } - - exception->parcelable.to = ____remote_exception_to; - exception->parcelable.from = ____remote_exception_from; - - *h = exception; - - return RPC_PORT_ERROR_NONE; -} - -int __remote_exception_set_cause(__remote_exception_h h, int cause) -{ - if (h == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - h->cause = cause; - - return RPC_PORT_ERROR_NONE; -} - -int __remote_exception_set_message(__remote_exception_h h, const char *message) -{ - if (h == nullptr || message == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - if (h->message) - free(h->message); - - h->message = strdup(message); - if (h->message == nullptr) { - _E("strdup() is failed"); - return RPC_PORT_ERROR_OUT_OF_MEMORY; - } - - return RPC_PORT_ERROR_NONE; -} - -int __remote_exception_throw(__remote_exception_h h) -{ - rpc_port_unit_map_h map; - int ret; - - if (h == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - map = rpc_port_unit_map_create(); - if (map == nullptr) { - _E("Failed to create unit map"); - return RPC_PORT_ERROR_OUT_OF_MEMORY; - } - - ret = rpc_port_unit_map_write__remote_exception(map, "clone", h); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to write remote exception. error(%d)", ret); - rpc_port_unit_map_destroy(map); - return ret; - } - - if (____remote_exception != nullptr) { - __remote_exception_destroy(____remote_exception); - ____remote_exception = nullptr; - } - - ret = rpc_port_unit_map_read__remote_exception(map, "clone", &____remote_exception); - rpc_port_unit_map_destroy(map); - - return ret; -} - -int __remote_exception_destroy(__remote_exception_h h) -{ - if (h == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - if (h->message) - free(h->message); - - free(h); - - return RPC_PORT_ERROR_NONE; -} -)__c_cb"; - -/** * The prefix of the interace. * The name of the interface. * The name of the method of the interface. @@ -1943,4 +1785,7 @@ R"__c_cb( [] = ____method__privilege_checker, )__c_cb"; -#endif // IDLC_C_GEN_C_STUB_BODY_GENERATOR_CB_H_ +} // namespace version2 +} // namespace tidl + +#endif // IDLC_GEN_VERSION2_C_STUB_BODY_GENERATOR_CB_HH_ diff --git a/idlc/gen/version2/c_stub_header_generator.cc b/idlc/gen/version2/c_stub_header_generator.cc index b912dd2..da089dc 100644 --- a/idlc/gen/version2/c_stub_header_generator.cc +++ b/idlc/gen/version2/c_stub_header_generator.cc @@ -16,9 +16,7 @@ #include "idlc/gen/version2/c_stub_header_generator.hh" -namespace { #include "idlc/gen/version2/c_stub_header_generator_cb.hh" -} namespace tidl { namespace version2 { @@ -33,8 +31,10 @@ void CStubHeaderGenerator::OnInitGen(std::ofstream& stream) { GenExplicitLinkageOpen(stream); GenEnums(stream); GenStructureHandles(stream); + GenRemoteExceptionHandle(stream); GenInterfaceHandles(stream); GenStructures(stream); + GenRemoteException(stream); GenInterfaceCallbacks(stream); GenInterfaces(stream); } @@ -50,7 +50,6 @@ void CStubHeaderGenerator::GenInterfaceHandles(std::ofstream& stream) { auto& iface = static_cast(*b); GenInterfaceContextHandle(stream, iface); - GenInterfaceRemoteExceptionHandle(stream, iface); for (const auto& d : iface.GetDeclarations()) { if (d->GetMethodType() != Declaration::MethodType::DELEGATE) continue; @@ -62,19 +61,8 @@ void CStubHeaderGenerator::GenInterfaceHandles(std::ofstream& stream) { // @see #CB_INTERFACE_CONTEXT_HANDLE void CStubHeaderGenerator::GenInterfaceContextHandle(std::ofstream& stream, - const Interface& iface) { - std::string code(ReplaceAll(CB_INTERFACE_CONTEXT_HANDLE, { - { "", GetHandlePrefix() }, - { "", iface.GetID() } - })); - - stream << SmartIndent(code); -} - -// @see #CB_INTERFACE_REMOTE_EXCEPTION_HANDLE -void CStubHeaderGenerator::GenInterfaceRemoteExceptionHandle( - std::ofstream& stream, const Interface& iface) { - ReplaceAll(CB_INTERFACE_REMOTE_EXCEPTION_HANDLE) + const Interface& iface) { + ReplaceAll(CB_INTERFACE_CONTEXT_HANDLE) .Change("", GetHandlePrefix()) .Change("", iface.GetID()) .Transform([&](std::string code) { return SmartIndent(code); }) @@ -83,14 +71,14 @@ void CStubHeaderGenerator::GenInterfaceRemoteExceptionHandle( // @see #CB_INTERFACE_DELEGATE_HANDLE void CStubHeaderGenerator::GenInterfaceDelegateHandle(std::ofstream& stream, - const Interface& iface, const Declaration& decl) { - std::string code(ReplaceAll(CB_INTERFACE_DELEGATE_HANDLE, { - { "", GetHandlePrefix() }, - { "", iface.GetID() }, - { "", decl.GetID() } - })); - - stream << SmartIndent(code); + const Interface& iface, + const Declaration& decl) { + ReplaceAll(CB_INTERFACE_DELEGATE_HANDLE) + .Change("", GetHandlePrefix()) + .Change("", iface.GetID()) + .Change("", decl.GetID()) + .Transform([&](std::string code) { return SmartIndent(code); }) + .Out(stream); } void CStubHeaderGenerator::GenInterfaceCallbacks(std::ofstream& stream) { @@ -111,17 +99,16 @@ void CStubHeaderGenerator::GenInterfaceCallbacks(std::ofstream& stream) { // @see #CB_INTERFACE_CALLBACK_BASE void CStubHeaderGenerator::GenInterfaceCallbackBase(std::ofstream& stream, - const Interface& iface) { - std::string code(ReplaceAll(CB_INTERFACE_CALLBACK_BASE, { - { "", GetHandlePrefix() }, - { "", iface.GetID() } - })); - - stream << SmartIndent(code); + const Interface& iface) { + ReplaceAll(CB_INTERFACE_CALLBACK_BASE) + .Change("", GetHandlePrefix()) + .Change("", iface.GetID()) + .Transform([&](std::string code) { return SmartIndent(code); }) + .Out(stream); } std::string CStubHeaderGenerator::GenMethodParams(const Interface& iface, - const Declaration& decl) { + const Declaration& decl) { std::string params; for (const auto& p : decl.GetParameters()) { params += ", "; @@ -135,17 +122,17 @@ std::string CStubHeaderGenerator::GenMethodParams(const Interface& iface, } // @see #CB_INTERFACE_METHOD_CALLBACK_BASE -void CStubHeaderGenerator::GenInterfaceMethodCallbackBase(std::ofstream& stream, - const Interface& iface, const Declaration& decl) { - std::string code(ReplaceAll(CB_INTERFACE_METHOD_CALLBACK_BASE, { - { "", GetReturnTypeString(decl.GetType(), iface.GetID()) }, - { "", GetHandlePrefix() }, - { "", iface.GetID() }, - { "", decl.GetID() }, - { "", GenMethodParams(iface, decl) } - })); - - stream << SmartIndent(code); +void CStubHeaderGenerator::GenInterfaceMethodCallbackBase( + std::ofstream& stream, const Interface& iface, const Declaration& decl) { + ReplaceAll(CB_INTERFACE_METHOD_CALLBACK_BASE) + .Change("", + GetReturnTypeString(decl.GetType(), iface.GetID())) + .Change("", GetHandlePrefix()) + .Change("", iface.GetID()) + .Change("", decl.GetID()) + .Change("", GenMethodParams(iface, decl)) + .Transform([&](std::string code) { return SmartIndent(code); }) + .Out(stream); } void CStubHeaderGenerator::GenInterfaces(std::ofstream& stream) { @@ -159,9 +146,8 @@ void CStubHeaderGenerator::GenInterfaces(std::ofstream& stream) { } void CStubHeaderGenerator::GenInterface(std::ofstream& stream, - const Interface& iface) { + const Interface& iface) { GenInterfaceContextBase(stream, iface); - GenInterfaceRemoteExceptionBase(stream, iface); for (const auto& d : iface.GetDeclarations()) { if (d->GetMethodType() != Declaration::MethodType::DELEGATE) continue; @@ -174,19 +160,8 @@ void CStubHeaderGenerator::GenInterface(std::ofstream& stream, // @see #CB_INTERFACE_CONTEXT_BASE void CStubHeaderGenerator::GenInterfaceContextBase(std::ofstream& stream, - const Interface& iface) { - std::string code(ReplaceAll(CB_INTERFACE_CONTEXT_BASE, { - { "", GetHandlePrefix() }, - { "", iface.GetID() } - })); - - stream << SmartIndent(code); -} - -// @see #CB_INTERFACE_REMOTE_EXCEPTION_BASE -void CStubHeaderGenerator::GenInterfaceRemoteExceptionBase( - std::ofstream& stream, const Interface& iface) { - ReplaceAll(CB_INTERFACE_REMOTE_EXCEPTION_BASE) + const Interface& iface) { + ReplaceAll(CB_INTERFACE_CONTEXT_BASE) .Change("", GetHandlePrefix()) .Change("", iface.GetID()) .Transform([&](std::string code) { return SmartIndent(code); }) @@ -194,14 +169,14 @@ void CStubHeaderGenerator::GenInterfaceRemoteExceptionBase( } std::string CStubHeaderGenerator::GenDelegateParams(const Interface& iface, - const Declaration& decl) { + const Declaration& decl) { std::string params; for (const auto& p : decl.GetParameters()) { params += ", "; auto& param_type = p->GetParameterType(); auto& type = param_type.GetBaseType(); - params += GetParamTypeString(param_type.GetDirection(), type, iface) + - p->GetID(); + params += + GetParamTypeString(param_type.GetDirection(), type, iface) + p->GetID(); } return params; @@ -209,48 +184,44 @@ std::string CStubHeaderGenerator::GenDelegateParams(const Interface& iface, // @see #CB_INTERFACE_DELEGATE_BASE void CStubHeaderGenerator::GenInterfaceDelegateBase(std::ofstream& stream, - const Interface& iface, const Declaration& decl) { - std::string code(ReplaceAll(CB_INTERFACE_DELEGATE_BASE, { - { "", GetHandlePrefix() }, - { "", iface.GetID() }, - { "", decl.GetID() }, - { "", GenDelegateParams(iface, decl) } - })); - - stream << SmartIndent(code); + const Interface& iface, + const Declaration& decl) { + ReplaceAll(CB_INTERFACE_DELEGATE_BASE) + .Change("", GetHandlePrefix()) + .Change("", iface.GetID()) + .Change("", decl.GetID()) + .Change("", GenDelegateParams(iface, decl)) + .Transform([&](std::string code) { return SmartIndent(code); }) + .Out(stream); } // @see #CB_INTERFACE_METHOD_CALLBACK_DECL -std::string CStubHeaderGenerator::GenMethodCallbackDecls(const Interface& iface) { - std::string method_callback_decls; +std::string CStubHeaderGenerator::GenMethodCallbackDecls( + const Interface& iface) { + std::string code; for (const auto& d : iface.GetDeclarations()) { if (d->GetMethodType() == Declaration::MethodType::DELEGATE) continue; - std::string method_callback_decl(ReplaceAll( - CB_INTERFACE_METHOD_CALLBACK_DECL, { - { "", GetHandlePrefix() }, - { "", iface.GetID() }, - { "", d->GetID() } - })); - - method_callback_decl = RemoveLine(method_callback_decl); - method_callback_decls += RemoveLine(method_callback_decl, 2); + std::string callback_code(ReplaceAll(CB_INTERFACE_METHOD_CALLBACK_DECL) + .Change("", GetHandlePrefix()) + .Change("", iface.GetID()) + .Change("", d->GetID())); + code += RemoveLine(callback_code, 3); } - return method_callback_decls; + return code; } // @see #CB_INTERFACE_BASE void CStubHeaderGenerator::GenInterfaceBase(std::ofstream& stream, - const Interface& iface) { - std::string code(ReplaceAll(CB_INTERFACE_BASE, { - { "", GetHandlePrefix() }, - { "", iface.GetID() }, - { "", GenMethodCallbackDecls(iface) } - })); - - stream << SmartIndent(code); + const Interface& iface) { + ReplaceAll(CB_INTERFACE_BASE) + .Change("", GetHandlePrefix()) + .Change("", iface.GetID()) + .Change("", GenMethodCallbackDecls(iface)) + .Transform([&](std::string code) { return SmartIndent(code); }) + .Out(stream); } } // namespace version2 diff --git a/idlc/gen/version2/c_stub_header_generator.hh b/idlc/gen/version2/c_stub_header_generator.hh index e464947..05b57c0 100644 --- a/idlc/gen/version2/c_stub_header_generator.hh +++ b/idlc/gen/version2/c_stub_header_generator.hh @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef IDLC_C_GEN_C_STUB_HEADER_GENERATOR_HH_ -#define IDLC_C_GEN_C_STUB_HEADER_GENERATOR_HH_ +#ifndef IDLC_GEN_VERSION2_C_STUB_HEADER_GENERATOR_HH_ +#define IDLC_GEN_VERSION2_C_STUB_HEADER_GENERATOR_HH_ #include #include @@ -36,28 +36,25 @@ class CStubHeaderGenerator : public CHeaderGeneratorBase { private: void GenInterfaceHandles(std::ofstream& stream); void GenInterfaceContextHandle(std::ofstream& stream, const Interface& iface); - void GenInterfaceRemoteExceptionHandle(std::ofstream& stream, - const Interface& iface); void GenInterfaceDelegateHandle(std::ofstream& stream, const Interface& iface, - const Declaration& decl); + const Declaration& decl); void GenInterfaceCallbacks(std::ofstream& stream); void GenInterfaceCallbackBase(std::ofstream& stream, const Interface& iface); void GenInterfaceMethodCallbackBase(std::ofstream& stream, - const Interface& iface, const Declaration& decl); + const Interface& iface, + const Declaration& decl); void GenInterfaces(std::ofstream& stream); void GenInterface(std::ofstream& stream, const Interface& iface); void GenInterfaceContextBase(std::ofstream& stream, const Interface& iface); - void GenInterfaceRemoteExceptionBase(std::ofstream& stream, - const Interface& iface); void GenInterfaceDelegateBase(std::ofstream& stream, const Interface& iface, - const Declaration& decl); + const Declaration& decl); void GenInterfaceBase(std::ofstream& stream, const Interface& iface); std::string GenDelegateParams(const Interface& iface, - const Declaration& decl); + const Declaration& decl); std::string GenMethodParams(const Interface& iface, const Declaration& decl); std::string GenMethodCallbackDecls(const Interface& iface); }; @@ -65,4 +62,4 @@ class CStubHeaderGenerator : public CHeaderGeneratorBase { } // namespace version2 } // namespace tidl -#endif // IDLC_C_GEN_C_STUB_HEADER_GENERATOR_HH_ +#endif // IDLC_GEN_VERSION2_C_STUB_HEADER_GENERATOR_HH_ diff --git a/idlc/gen/version2/c_stub_header_generator_cb.hh b/idlc/gen/version2/c_stub_header_generator_cb.hh index 1893c52..e98f2fc 100644 --- a/idlc/gen/version2/c_stub_header_generator_cb.hh +++ b/idlc/gen/version2/c_stub_header_generator_cb.hh @@ -14,8 +14,11 @@ * limitations under the License. */ -#ifndef IDLC_C_GEN_C_STUB_HEADER_GENERATOR_CB_H_ -#define IDLC_C_GEN_C_STUB_HEADER_GENERATOR_CB_H_ +#ifndef IDLC_GEN_VERSION2_C_STUB_HEADER_GENERATOR_CB_HH_ +#define IDLC_GEN_VERSION2_C_STUB_HEADER_GENERATOR_CB_HH_ + +namespace tidl { +namespace version2 { /** * The prefix of the interface. @@ -365,91 +368,7 @@ R"__c_cb( ___cb ; /**< This callback function is invoked when the request is delivered. */ )__c_cb"; -/** - * The prefix of the interface. - * The name of the interface. - */ -constexpr const char CB_INTERFACE_REMOTE_EXCEPTION_HANDLE[] = -R"__c_cb( -/** - * @brief The remote exception handle. - */ -typedef struct __remote_exception_s *__remote_exception_h; -)__c_cb"; - -/** - * The prefix of the interface. - * The name of the interface. - */ -constexpr const char CB_INTERFACE_REMOTE_EXCEPTION_BASE[] = -R"__c_cb( -/** - * @brief Creates the remote exception handle. - * - * @remarks The @c h handle should be released if it's no longer needed. - * @param[out] h The remote exception handle. - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @see __remote_exception_throw() - * @see __remote_exception_destroy() - */ -int __remote_exception_create(__remote_exception_h *h); - -/** - * @brief Sets the cause of the exception. - * - * @param[in] h The remote exception handle - * @param[in] cause The cause of the exception - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - */ -int __remote_exception_set_cause(__remote_exception_h h, int cause); - -/** - * @brief Sets the detail message of the exception. - * - * @param[in] h The remote exception handle - * @param[in] message The detail message of the exception - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - */ -int __remote_exception_set_message(__remote_exception_h h, const char *message); - -/** - * @brief Throws the exception to the client. - * @details This function throws the exception to the client in the callback function. - * While calling the registered callback function related the method call, this function should be called - * if you want to send the remote exception to the client. - * If this function is called outside of the registered callback function, it's meaningless. - * The callback function is not returned by calling this function. - * - * @param[in] h The remote exception handle - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - */ -int __remote_exception_throw(__remote_exception_h h); - -/** - * @brief Destroys the remote exception handle. - * - * @param[in] h The remote exception handle - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - */ -int __remote_exception_destroy(__remote_exception_h h); -)__c_cb"; +} // namespace version2 +} // namespace tidl -#endif // IDLC_C_GEN_C_STUB_HEADER_GENERATOR_CB_H_ +#endif // IDLC_GEN_VERSION2_C_STUB_HEADER_GENERATOR_CB_HH_ -- 2.7.4