if (GetChannelType() != ChannelType::TYPE_GROUP) {
AddParameterType(
std::make_shared<ParameterType>(
- new BaseType(iface.GetID() + "_remote_exception", "", true),
+ new BaseType("remote_exception", "", true),
ParameterType::Direction::OUT));
AddParameterType(
std::make_shared<ParameterType>(
- new BaseType(iface.GetID() + "_remote_exception", "", true),
+ new BaseType("remote_exception", "", true),
ParameterType::Direction::IN));
}
return code;
}
+void CBodyGeneratorBase::GenRemoteExceptionDefinition(std::ofstream& stream) {
+ ReplaceAll(CB_REMOTE_EXCEPTION_DEF)
+ .Change("<PREFIX>", GetHandlePrefix())
+ .Transform([&](std::string code) { return SmartIndent(code); })
+ .Out(stream);
+}
+
+void CBodyGeneratorBase::GenRemoteExceptionBase(std::ofstream& stream) {
+ ReplaceAll(CB_REMOTE_EXCEPTION_BASE)
+ .Change("<PREFIX>", GetHandlePrefix())
+ .Transform([&](std::string code) { return SmartIndent(code); })
+ .Out(stream);
+
+ ReplaceAll(IsProxy() ? CB_PROXY_REMOTE_EXCEPTION_BASE
+ : CB_STUB_REMOTE_EXCEPTION_BASE)
+ .Change("<PREFIX>", GetHandlePrefix())
+ .Transform([&](std::string code) { return SmartIndent(code); })
+ .Out(stream);
+}
+
} // namespace version2
} // namespace tidl
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);
}
)__c_cb";
+/**
+ * <PREFIX> The prefix of the interface.
+ */
+constexpr const char CB_REMOTE_EXCEPTION_DEF[] =
+R"__c_cb(
+typedef struct <PREFIX>_remote_exception_s {
+ rpc_port_parcelable_t parcelable;
+ int cause;
+ char *message;
+} <PREFIX>_remote_exception_t;
+
+static __thread <PREFIX>_remote_exception_h __<PREFIX>_remote_exception;
+
+int <PREFIX>_remote_exception_create(<PREFIX>_remote_exception_h *h);
+)__c_cb";
+
+/**
+ * <PREFIX> The prefix of the interface.
+ */
+constexpr const char CB_REMOTE_EXCEPTION_BASE[] =
+R"__c_cb(
+static void __<PREFIX>_remote_exception_to(rpc_port_parcel_h parcel, void *user_data)
+{
+ <PREFIX>_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 __<PREFIX>_remote_exception_from(rpc_port_parcel_h parcel, void *user_data)
+{
+ <PREFIX>_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 <PREFIX>_remote_exception_create(<PREFIX>_remote_exception_h *h)
+{
+ <PREFIX>_remote_exception_h exception;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ exception = calloc(1, sizeof(<PREFIX>_remote_exception_t));
+ if (exception == nullptr) {
+ _E("calloc() is failed");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ exception->parcelable.to = __<PREFIX>_remote_exception_to;
+ exception->parcelable.from = __<PREFIX>_remote_exception_from;
+
+ *h = exception;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int <PREFIX>_remote_exception_set_cause(<PREFIX>_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 <PREFIX>_remote_exception_set_message(<PREFIX>_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 <PREFIX>_remote_exception_get_cause(<PREFIX>_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 <PREFIX>_remote_exception_get_message(<PREFIX>_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 <PREFIX>_remote_exception_destroy(<PREFIX>_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";
+
+/**
+ * <PREFIX> The prefix of the proxy interface.
+ */
+constexpr const char CB_PROXY_REMOTE_EXCEPTION_BASE[] =
+R"__cpp_cb(
+int <PREFIX>_get_remote_exception(<PREFIX>_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 (__<PREFIX>_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", __<PREFIX>_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 <PREFIX>_remote_exception_throw(<PREFIX>_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 (__<PREFIX>_remote_exception != nullptr) {
+ <PREFIX>_remote_exception_destroy(__<PREFIX>_remote_exception);
+ __<PREFIX>_remote_exception = nullptr;
+ }
+
+ ret = rpc_port_unit_map_read_remote_exception(map, "clone", &__<PREFIX>_remote_exception);
+ rpc_port_unit_map_destroy(map);
+
+ return ret;
+}
+)__cpp_cb";
+
} // namespace version2
} // namespace tidl
/*
- * 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.
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("<PREFIX>", GetHandlePrefix())
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("<PREFIX>", GetHandlePrefix())
GenStructureBase(stream, st);
}
+void CHeaderGeneratorBase::GenRemoteExceptionHandle(std::ofstream& stream) {
+ ReplaceAll(CB_REMOTE_EXCEPTION_HANDLE)
+ .Change("<PREFIX>", GetHandlePrefix())
+ .Transform([&](std::string code) { return SmartIndent(code); })
+ .Out(stream);
+}
+
+void CHeaderGeneratorBase::GenRemoteException(std::ofstream& stream) {
+ ReplaceAll(CB_REMOTE_EXCEPTION_BASE)
+ .Change("<PREFIX>", GetHandlePrefix())
+ .Transform([&](std::string code) { return SmartIndent(code); })
+ .Out(stream);
+
+ ReplaceAll(IsProxy() ? CB_PROXY_REMOTE_EXCEPTION_BASE
+ : CB_STUB_REMOTE_EXCEPTION_BASE)
+ .Change("<PREFIX>", GetHandlePrefix())
+ .Transform([&](std::string code) { return SmartIndent(code); })
+ .Out(stream);
+}
+
} // namespace version2
} // namespace tidl
/*
- * 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.
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);
/*
- * 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.
int <PREFIX>_<NAME>_get_<ELEMENT_NAME>(<PREFIX>_<NAME>_h h, <PARAM_TYPE_OUT>value);
)__c_cb";
+/**
+ * <PREFIX> The prefix of the interface.
+ */
+constexpr const char CB_REMOTE_EXCEPTION_HANDLE[] =
+R"__c_cb(
+/**
+ * @breif The <PREFIX> remote exception handle.
+ */
+typedef struct <PREFIX>_remote_exception_s *<PREFIX>_remote_exception_h;
+)__c_cb";
+
+/**
+ * <PREFIX> The prefix of the interface.
+ */
+constexpr const char CB_REMOTE_EXCEPTION_BASE[] =
+R"__c_cb(
+/**
+ * @brief Creates the <PREFIX> remote exception handle.
+ *
+ * @remarks The @c h handle should be released if it's no longer needed.
+ * @param[out] h The <PREFIX> 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 <PREFIX>_remote_exception_destroy()
+ */
+int <PREFIX>_remote_exception_create(<PREFIX>_remote_exception_h *h);
+
+/**
+ * @brief Sets the cause of the exception.
+ *
+ * @param[in] h The <PREFIX> 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 <PREFIX>_remote_exception_set_cause(<PREFIX>_remote_exception_h h, int cause);
+
+/**
+ * @brief Sets the detail message of the exception.
+ *
+ * @param[in] h The <PREFIX> 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 <PREFIX>_remote_exception_set_message(<PREFIX>_remote_exception_h h, const char *message);
+
+/**
+ * @brief Gets the cause of the exception.
+ * @param[in] h The <PREFIX> 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 <PREFIX>_remote_exception_get_cause(<PREFIX>_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 <PREFIX> 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 <PREFIX>_remote_exception_get_message(<PREFIX>_remote_exception_h, char **message);
+
+/**
+ * @brief Destroys the remote exception handle.
+ * @param[in] h The <PREFIX> 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 <PREFIX>_remote_exception_destroy(<PREFIX>_remote_exception_h h);
+)__c_cb";
+
+/**
+ * <PREFIX> 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 <PREFIX>_remote_exception_destroy(), if it's no longer needed.
+ * @param[out] h The <PREFIX> 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 <PREFIX>_remote_exception_destroy();
+ */
+int <PREFIX>_get_remote_exception(<PREFIX>_remote_exception_h *h);
+)__cpp_cb";
+
+/**
+ * <PREFIX> 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 <PREFIX> 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 <PREFIX>_remote_exception_create()
+ * @see <PREFIX>_remote_exception_destroy()
+ */
+int <PREFIX>_remote_exception_throw(<PREFIX>_remote_exception_h h);
+)__c_cb";
+
} // namespace version2
} // namespace tidl
GenDelegateDefinition(stream);
GenInterfaceDelegateCallback(stream);
GenStructureDefinition(stream);
+ GenRemoteExceptionDefinition(stream);
GenInterfaceDefinition(stream);
GenUnitMapBase(stream);
GenDelegateBase(stream);
GenPrivateSharingListSet(stream);
GenStructure(stream);
+ GenRemoteExceptionBase(stream);
GenInterface(stream);
}
GenInterfaceDelegateDefinition(stream, iface, *decl);
}
- GenInterfaceRemoteExceptionDefinition(stream, iface);
GenInterfaceBaseDefinition(stream, iface);
}
}
.Out(stream);
}
-void CProxyBodyGenerator::GenInterfaceRemoteExceptionDefinition(
- std::ofstream& stream, const Interface& iface) {
- ReplaceAll(CB_INTERFACE_REMOTE_EXCEPTION_DEF)
- .Change("<PREFIX>", GetHandlePrefix())
- .Change("<NAME>", 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)
GenInterfaceDelegateTable(stream, iface);
GenInterfaceMethodEnumBase(stream, iface);
- GenInterfaceRemoteExceptionBase(stream, iface);
GenDelegateProcess(stream, iface);
GenInterfaceBase(stream, iface);
void CProxyBodyGenerator::GenMethodBase(std::ofstream& stream,
const Interface& iface, const Declaration& decl) {
ReplaceAll(CB_INTERFACE_METHOD_BASE)
- .Change("<RETURN_TYPE>", GetReturnTypeString(decl.GetType(), iface.GetID()))
+ .Change("<RETURN_TYPE>",
+ GetReturnTypeString(decl.GetType(), iface.GetID()))
.Change("<PREFIX>", GetHandlePrefix())
.Change("<NAME>", iface.GetID())
.Change("<METHOD_NAME>", decl.GetID())
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("<DELEGATE_REGISTER_EVENT>", event)
.Out(stream);
}
-void CProxyBodyGenerator::GenInterfaceRemoteExceptionBase(std::ofstream& stream,
- const Interface& iface) {
- ReplaceAll(CB_INTERFACE_REMOTE_EXCEPTION_BASE)
- .Change("<PREFIX>", GetHandlePrefix())
- .Change("<NAME>", 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() +
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);
rpc_port_unit_map_read_int(map, "[METHOD]", &cmd);
if (cmd == <UPPERCASE_PREFIX>_<UPPERCASE_NAME>_METHOD_RESULT_) {
- if (__<PREFIX>_<NAME>_remote_exception != nullptr)
- <PREFIX>_<NAME>_remote_exception_destroy(__<PREFIX>_<NAME>_remote_exception);
+ if (__<PREFIX>_remote_exception != nullptr)
+ <PREFIX>_remote_exception_destroy(__<PREFIX>_remote_exception);
- __<PREFIX>_<NAME>_remote_exception = nullptr;
- rpc_port_unit_map_read_<NAME>_remote_exception(map, "[REMOTE_EXCEPTION]", &__<PREFIX>_<NAME>_remote_exception);
+ __<PREFIX>_remote_exception = nullptr;
+ rpc_port_unit_map_read_remote_exception(map, "[REMOTE_EXCEPTION]", &__<PREFIX>_remote_exception);
*unit_map = map;
return;
h->delegates = g_list_append(h->delegates, <ARG>);
)__c_cb";
-/**
- * <PREFIX> The prefix of the interface.
- * <NAME> The name of the interface.
- */
-constexpr const char CB_INTERFACE_REMOTE_EXCEPTION_DEF[] =
-R"__c_cb(
-typedef struct <PREFIX>_<NAME>_remote_exception_s {
- rpc_port_parcelable_t parcelable;
- int cause;
- char *message;
-} <PREFIX>_<NAME>_remote_exception_t;
-
-static __thread <PREFIX>_<NAME>_remote_exception_h __<PREFIX>_<NAME>_remote_exception;
-
-static int <PREFIX>_<NAME>_remote_exception_create(<PREFIX>_<NAME>_remote_exception_h *h);
-)__c_cb";
-
-/**
- * <PREFIX> The prefix of the interface.
- * <NAME> The name of the interface.
- */
-constexpr const char CB_INTERFACE_REMOTE_EXCEPTION_BASE[] =
-R"__c_cb(
-static void __<PREFIX>_<NAME>_remote_exception_to(rpc_port_parcel_h parcel, void *user_data)
-{
- <PREFIX>_<NAME>_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 __<PREFIX>_<NAME>_remote_exception_from(rpc_port_parcel_h parcel, void *user_data)
-{
- <PREFIX>_<NAME>_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 <PREFIX>_<NAME>_remote_exception_create(<PREFIX>_<NAME>_remote_exception_h *h)
-{
- <PREFIX>_<NAME>_remote_exception_h exception;
-
- if (h == nullptr) {
- _E("Invalid parameter");
- return RPC_PORT_ERROR_INVALID_PARAMETER;
- }
-
- exception = calloc(1, sizeof(<PREFIX>_<NAME>_remote_exception_t));
- if (exception == nullptr) {
- _E("calloc() is failed");
- return RPC_PORT_ERROR_OUT_OF_MEMORY;
- }
-
- exception->parcelable.to = __<PREFIX>_<NAME>_remote_exception_to;
- exception->parcelable.from = __<PREFIX>_<NAME>_remote_exception_from;
-
- *h = exception;
-
- return RPC_PORT_ERROR_NONE;
-}
-
-int <PREFIX>_<NAME>_get_remote_exception(<PREFIX>_<NAME>_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 (__<PREFIX>_<NAME>_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_<NAME>_remote_exception(map, "clone", __<PREFIX>_<NAME>_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_<NAME>_remote_exception(map, "clone", h);
- rpc_port_unit_map_destroy(map);
-
- return RPC_PORT_ERROR_NONE;
-}
-
-int <PREFIX>_<NAME>_remote_exception_get_cause(<PREFIX>_<NAME>_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 <PREFIX>_<NAME>_remote_exception_get_message(<PREFIX>_<NAME>_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 <PREFIX>_<NAME>_remote_exception_destroy(<PREFIX>_<NAME>_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
GenExplicitLinkageOpen(stream);
GenEnums(stream);
GenStructureHandles(stream);
+ GenRemoteExceptionHandle(stream);
GenInterfaceHandles(stream);
GenStructures(stream);
+ GenRemoteException(stream);
GenInterfaces(stream);
}
auto& iface = static_cast<const Interface&>(*b);
GenInterfaceHandle(stream, iface);
- GenInterfaceRemoteExceptionHandle(stream, iface);
for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
.Out(stream);
}
-void CProxyHeaderGenerator::GenInterfaceRemoteExceptionHandle(
- std::ofstream& stream, const Interface& iface) {
- ReplaceAll(CB_INTERFACE_REMOTE_EXCEPTION_HANDLE)
- .Change("<PREFIX>", GetHandlePrefix())
- .Change("<NAME>", 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)
GenInterfaceDelegateBase(stream, iface, *d);
}
- GenInterfaceRemoteExceptionBase(stream, iface);
GenInterfaceBase(stream, iface);
for (const auto& d : iface.GetDeclarations()) {
.Out(stream);
}
-void CProxyHeaderGenerator::GenInterfaceRemoteExceptionBase(
- std::ofstream& stream, const Interface& iface) {
- ReplaceAll(CB_INTERFACE_REMOTE_EXCEPTION_BASE)
- .Change("<PREFIX>", GetHandlePrefix())
- .Change("<NAME>", iface.GetID())
- .Transform([&](std::string code) { return SmartIndent(code); })
- .Out(stream);
-}
-
std::string CProxyHeaderGenerator::GenDelegateParams(const Interface& iface,
const Declaration& decl) {
std::string params;
void CProxyHeaderGenerator::GenInterfaceMethodBase(std::ofstream& stream,
const Interface& iface, const Declaration& decl) {
ReplaceAll(CB_INTERFACE_METHOD_BASE)
- .Change("<RETURN_TYPE>", GetReturnTypeString(decl.GetType(), iface.GetID()))
+ .Change("<RETURN_TYPE>",
+ GetReturnTypeString(decl.GetType(), iface.GetID()))
.Change("<PREFIX>", GetHandlePrefix())
.Change("<NAME>", iface.GetID())
.Change("<METHOD_NAME>", decl.GetID())
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);
};
<RETURN_TYPE><PREFIX>_<NAME>_invoke_<METHOD_NAME>(<PREFIX>_<NAME>_h h<METHOD_PARAMS>);
)__c_cb";
-constexpr const char CB_INTERFACE_REMOTE_EXCEPTION_HANDLE[] =
-R"__c_cb(
-/**
- * @breif The <PREFIX> <NAME> remote exception handle.
- */
-typedef struct <PREFIX>_<NAME>_remote_exception_s *<PREFIX>_<NAME>_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 <PREFIX>_<NAME>_remote_exception_destroy(), if it's no longer needed.
- * @param[out] h The <PREFIX> <NAME> 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 <PREFIX>_<NAME>_remote_exception_destroy();
- */
-int <PREFIX>_<NAME>_get_remote_exception(<PREFIX>_<NAME>_remote_exception_h *h);
-
-/**
- * @brief Gets the cause of the exception.
- * @param[in] h The <PREFIX> <NAME> 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 <PREFIX>_<NAME>_remote_exception_get_cause(<PREFIX>_<NAME>_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 <PREFIX> <NAME> 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 <PREFIX>_<NAME>_remote_exception_get_message(<PREFIX>_<NAME>_remote_exception_h, char **message);
-
-/**
- * @brief Destroys the remote exception handle.
- * @param[in] h The <PREFIX> <NAME> 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 <PREFIX>_<NAME>_remote_exception_destroy(<PREFIX>_<NAME>_remote_exception_h h);
-)__c_cb";
-
} // namespace version2
} // namespace tidl
GenInterfaceMethodHandlerType(stream);
GenDelegateDefinition(stream);
GenStructureDefinition(stream);
+ GenRemoteExceptionDefinition(stream);
GenInterfaceDefs(stream);
GenPrivateSharingListSet(stream);
GenUnitMapBase(stream);
GenDelegateBase(stream);
GenStructure(stream);
+ GenRemoteExceptionBase(stream);
GenInterfaces(stream);
}
// @see #CB_INTERFACE_METHOD_ENUM
std::string CStubBodyGenerator::GenMethodEnums(const Interface& iface) {
- std::string method_enum(ReplaceAll(CB_INTERFACE_METHOD_ENUM, {
- { "<UPPERCASE_PREFIX>", GetHandlePrefix() },
- { "<UPPERCASE_NAME>", iface.GetID() },
- { "<UPPERCASE_METHOD_NAME>", "RESULT_" }
- }));
-
- std::string method_enums = RemoveLine(method_enum);
-
- method_enum = ReplaceAll(CB_INTERFACE_METHOD_ENUM, {
- { "<UPPERCASE_PREFIX>", GetHandlePrefix() },
- { "<UPPERCASE_NAME>", iface.GetID() },
- { "<UPPERCASE_METHOD_NAME>", "CALLBACK_" }
- });
-
- method_enums += RemoveLine(method_enum);
+ std::string method_enums;
+ method_enums += RemoveLine(
+ std::string(ReplaceAll(CB_INTERFACE_METHOD_ENUM)
+ .ChangeToUpper("<UPPERCASE_PREFIX>", GetHandlePrefix())
+ .ChangeToUpper("<UPPERCASE_NAME>", iface.GetID())
+ .ChangeToUpper("<UPPERCASE_METHOD_NAME>", "RESULT_")));
+ method_enums += RemoveLine(
+ std::string(ReplaceAll(CB_INTERFACE_METHOD_ENUM)
+ .ChangeToUpper("<UPPERCASE_PREFIX>", GetHandlePrefix())
+ .ChangeToUpper("<UPPERCASE_NAME>", iface.GetID())
+ .ChangeToUpper("<UPPERCASE_METHOD_NAME>", "CALLBACK_")));
for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
- method_enum = ReplaceAll(CB_INTERFACE_METHOD_ENUM, {
- { "<UPPERCASE_PREFIX>", GetHandlePrefix() },
- { "<UPPERCASE_NAME>", iface.GetID() },
- { "<UPPERCASE_METHOD_NAME>", d->GetID() }
- });
-
- method_enums += RemoveLine(method_enum);
+ method_enums += RemoveLine(
+ std::string(ReplaceAll(CB_INTERFACE_METHOD_ENUM)
+ .ChangeToUpper("<UPPERCASE_PREFIX>", GetHandlePrefix())
+ .ChangeToUpper("<UPPERCASE_NAME>", iface.GetID())
+ .ChangeToUpper("<UPPERCASE_METHOD_NAME>", 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, {
- { "<PREFIX>", GetHandlePrefix() },
- { "<NAME>", iface.GetID() },
- { "<METHOD_ENUMS>", GenMethodEnums(iface) }
- }));
-
- stream << SmartIndent(code);
+ const Interface& iface) {
+ ReplaceAll(CB_INTERFACE_METHOD_ENUM_BASE)
+ .Change("<PREFIX>", GetHandlePrefix())
+ .Change("<NAME>", iface.GetID())
+ .Change("<METHOD_ENUMS>", GenMethodEnums(iface))
+ .Transform([&](std::string code) { return SmartIndent(code); })
+ .Out(stream);
}
// @see #CB_INTERFACE_DELEGATE_ENUM
if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
- std::string method_enum(ReplaceAll(CB_INTERFACE_DELEGATE_ENUM, {
- { "<UPPERCASE_PREFIX>", GetHandlePrefix() },
- { "<UPPERCASE_NAME>", iface.GetID() },
- { "<UPPERCASE_DELEGATE_NAME>", d->GetID() },
- { "<NUMBER>", std::to_string(num++) }
- }));
-
- method_enums += RemoveLine(method_enum);
+ method_enums += RemoveLine(
+ std::string(ReplaceAll(CB_INTERFACE_DELEGATE_ENUM)
+ .ChangeToUpper("<UPPERCASE_PREFIX>", GetHandlePrefix())
+ .ChangeToUpper("<UPPERCASE_NAME>", iface.GetID())
+ .ChangeToUpper("<UPPERCASE_DELEGATE_NAME>", d->GetID())
+ .ChangeToUpper("<NUMBER>", 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, {
- { "<PREFIX>", GetHandlePrefix() },
- { "<NAME>", iface.GetID() },
- { "<DELEGATE_ENUMS>", delegate_enums }
- }));
-
- stream << SmartIndent(code);
+ ReplaceAll(CB_INTERFACE_DELEGATE_ENUM_BASE)
+ .Change("<PREFIX>", GetHandlePrefix())
+ .Change("<NAME>", iface.GetID())
+ .Change("<DELEGATE_ENUMS>", delegate_enums)
+ .Transform([&](std::string code) { return SmartIndent(code); })
+ .Out(stream);
}
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)
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, {
- { "<PREFIX>", GetHandlePrefix() },
- { "<NAME>", iface.GetID() },
- { "<DELEGATE_NAME>", decl.GetID() }
- }));
-
- stream << SmartIndent(code);
+ const Interface& iface,
+ const Declaration& decl) {
+ ReplaceAll(CB_INTERFACE_DELEGATE_DEF)
+ .Change("<PREFIX>", GetHandlePrefix())
+ .Change("<NAME>", iface.GetID())
+ .Change("<DELEGATE_NAME>", 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, {
- { "<PREFIX>", GetHandlePrefix() },
- { "<NAME>", iface.GetID() }
- }));
-
- stream << SmartIndent(code);
+void CStubBodyGenerator::GenInterfaceCallbackPortCheckDef(
+ std::ofstream& stream, const Interface& iface) {
+ ReplaceAll(CB_INTERFACE_CALLBACK_PORT_CHECK_DEF)
+ .Change("<PREFIX>", GetHandlePrefix())
+ .Change("<NAME>", 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, {
- { "<PREFIX>", GetHandlePrefix() },
- { "<NAME>", 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("<PREFIX>", GetHandlePrefix())
.Change("<NAME>", 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, {
- { "<PREFIX>", GetHandlePrefix() },
- { "<NAME>", iface.GetID() }
- }));
-
- stream << SmartIndent(code);
+ const Interface& iface) {
+ ReplaceAll(CB_INTERFACE_BASE_DEF)
+ .Change("<PREFIX>", GetHandlePrefix())
+ .Change("<NAME>", iface.GetID())
+ .Transform([&](std::string code) { return SmartIndent(code); })
+ .Out(stream);
}
void CStubBodyGenerator::GenInterfaces(std::ofstream& stream) {
GenInterfaceMethodPrivilegeCheckerTable(stream, iface);
GenInterfaceMethodTable(stream, iface);
GenInterfaceContextBase(stream, iface);
- GenInterfaceRemoteExceptionBase(stream, iface);
if (has_delegate)
GenInterfaceCallbackPortCheck(stream, iface);
.Out(stream);
}
-// @see #CB_INTERFACE_REMOTE_EXCEPTION_BASE
-void CStubBodyGenerator::GenInterfaceRemoteExceptionBase(
- std::ofstream& stream, const Interface& iface) {
- ReplaceAll(CB_INTERFACE_REMOTE_EXCEPTION_BASE)
- .Change("<PREFIX>", GetHandlePrefix())
- .Change("<NAME>", iface.GetID())
- .Transform([&](std::string code) { return SmartIndent(code); })
- .Out(stream);
-}
-
std::string CStubBodyGenerator::GenDelegateParams(const Interface& iface,
const Declaration& decl) {
std::string params;
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, {
- { "<PREFIX>", GetHandlePrefix() },
- { "<NAME>", iface.GetID() },
- { "<DELEGATE_NAME>", decl.GetID() },
- { "<DELEGATE_PARAMS>", GenDelegateParams(iface, decl) },
- { "<DELEGATE_PARAMS_CHECK>", GenDelegateParamsCheck(iface, decl) },
- { "<DELEGATE_ENUM_VALUE>", enum_value },
- { "<DELEGATE_UNIT_MAP_WRITE>", GenDelegateUnitMapWrite(iface, decl) },
- { "<UPPERCASE_PREFIX>", prefix },
- { "<UPPERCASE_NAME>", name }
- }));
-
- stream << SmartIndent(code);
+ ReplaceAll(CB_INTERFACE_DELEGATE_BASE)
+ .Change("<PREFIX>", GetHandlePrefix())
+ .Change("<NAME>", iface.GetID())
+ .Change("<DELEGATE_NAME>", decl.GetID())
+ .Change("<DELEGATE_PARAMS>", GenDelegateParams(iface, decl))
+ .Change("<DELEGATE_PARAMS_CHECK>", GenDelegateParamsCheck(iface, decl))
+ .ChangeToUpper("<DELEGATE_ENUM_VALUE>", enum_value)
+ .Change("<DELEGATE_UNIT_MAP_WRITE>", GenDelegateUnitMapWrite(iface, decl))
+ .ChangeToUpper("<UPPERCASE_PREFIX>", GetHandlePrefix())
+ .ChangeToUpper("<UPPERCASE_NAME>", 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;
// @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;
// @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,
- "<METHOD_NAME>", decl.GetID()));
- code = ReplaceAll(code, "<PREFIX>", GetHandlePrefix());
- code = ReplaceAll(code, "<NAME>", iface.GetID());
-
- if (decl.GetMethodType() == Declaration::MethodType::SYNC)
- code = ReplaceAll(code, "<RES_SET>", "res_ = ");
- else
- code = ReplaceAll(code, "<RES_SET>", "");
-
std::string args;
for (const auto& p : decl.GetParameters()) {
args += ", ";
args += p->GetID();
}
- code = ReplaceAll(code, "<METHOD_ARGS>", 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("<METHOD_NAME>", decl.GetID())
+ .Change("<PREFIX>", GetHandlePrefix())
+ .Change("<NAME>", iface.GetID())
+ .Change("<RES_SET>", res_set)
+ .Change("<METHOD_ARGS>", 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(
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, "<UPPERCASE_PREFIX>",
- prefix);
-
- std::string name = iface.GetID();
- std::transform(name.begin(), name.end(), name.begin(), ::toupper);
- code = ReplaceAll(code, "<UPPERCASE_NAME>", name);
+ code = ReplaceAll(CB_INTERFACE_METHOD_PARCEL_WRITE_PRE)
+ .ChangeToUpper("<UPPERCASE_PREFIX>", GetHandlePrefix())
+ .ChangeToUpper("<UPPERCASE_NAME>", 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_");
// @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,
- "<PREFIX>", GetHandlePrefix());
- free_code = ReplaceAll(free_code, "<NAME>",
- GetFullNameFromType(type, iface));
- free_code = ReplaceAll(free_code, "<ARG>", p->GetID());
+ if (type.IsStructureType() || type.IsDelegateType() ||
+ type.GetMetaType() != nullptr || type.GetKeyType() != nullptr) {
+ code += ReplaceAll(CB_INTERFACE_METHOD_USER_DEFINED_FREE)
+ .Change("<PREFIX>", GetHandlePrefix())
+ .Change("<NAME>", GetFullNameFromType(type, iface))
+ .Change("<ARG>", p->GetID());
} else if (type.ToString() == "bundle") {
- free_code = ReplaceAll(CB_INTERFACE_METHOD_BUNDLE_FREE,
- "<ARG>", p->GetID());
+ code += ReplaceAll(CB_INTERFACE_METHOD_BUNDLE_FREE)
+ .Change("<ARG>", p->GetID());
} else if (type.ToString() == "string" || type.ToString() == "file") {
- free_code = ReplaceAll(CB_INTERFACE_METHOD_STRING_FREE,
- "<ARG>", p->GetID());
- } else {
- free_code.clear();
+ code += ReplaceAll(CB_INTERFACE_METHOD_STRING_FREE)
+ .Change("<ARG>", 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,
- "<PREFIX>", GetHandlePrefix());
- free_code = ReplaceAll(free_code, "<NAME>",
- GetFullNameFromType(type, iface));
- free_code = ReplaceAll(free_code, "<ARG>", "res_");
+ if (type.IsStructureType() || type.IsDelegateType() ||
+ type.GetMetaType() != nullptr || type.GetKeyType() != nullptr) {
+ code += ReplaceAll(CB_INTERFACE_METHOD_USER_DEFINED_FREE)
+ .Change("<PREFIX>", GetHandlePrefix())
+ .Change("<NAME>", GetFullNameFromType(type, iface))
+ .Change("<ARG>", arg);
} else if (type.ToString() == "bundle") {
- free_code = ReplaceAll(CB_INTERFACE_METHOD_BUNDLE_FREE,
- "<ARG>", "res_");
+ code += ReplaceAll(CB_INTERFACE_METHOD_BUNDLE_FREE).Change("<ARG>", arg);
} else if (type.ToString() == "string" || type.ToString() == "file") {
- free_code = ReplaceAll(CB_INTERFACE_METHOD_STRING_FREE,
- "<ARG>", "res_");
- } else {
- free_code.clear();
+ code += ReplaceAll(CB_INTERFACE_METHOD_STRING_FREE).Change("<ARG>", arg);
}
-
- code += free_code;
}
return RemoveLine(code);
std::string sync =
(decl.GetMethodType() == Declaration::MethodType::SYNC) ?
"true" : "false";
- std::string code(ReplaceAll(CB_INTERFACE_METHOD_PRIVILEGE_CHECKER)
- .Change("<PRIVILEGES>", privileges)
- .Change("<SYNC_TRUE_OR_FALSE>", sync));
- return RemoveLine(code);
+ return RemoveLine(
+ std::string(ReplaceAll(CB_INTERFACE_METHOD_PRIVILEGE_CHECKER)
+ .Change("<PRIVILEGES>", privileges)
+ .Change("<SYNC_TRUE_OR_FALSE>", sync)));
}
// @see #CB_INTERFACE_METHOD_PRIVILEGE_CHECKER_BASE
}
// @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, {
- { "<PREFIX>", GetHandlePrefix() },
- { "<NAME>", iface.GetID() },
- { "<METHOD_NAME>", decl.GetID() },
- { "<METHOD_HANDLER_ARGS_DECL>", GenMethodHandlerArgsDecl(iface, decl) },
- { "<METHOD_UNIT_MAP_READ>",
- GenMethodUnitMapRead(iface, decl) },
- { "<METHOD_HANDLER_CALLBACK_INVOKE>",
- GenMethodHandlerCallbackInvoke(iface, decl) },
- { "<METHOD_UNIT_MAP_WRITE>",
- GenMethodUnitMapWrite(iface, decl) },
- { "<METHOD_HANDLER_ARGS_FREE>", 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("<PREFIX>", GetHandlePrefix())
+ .Change("<NAME>", iface.GetID())
+ .Change("<METHOD_NAME>", decl.GetID())
+ .Change("<METHOD_HANDLER_ARGS_DECL>",
+ GenMethodHandlerArgsDecl(iface, decl))
+ .Change("<METHOD_UNIT_MAP_READ>", GenMethodUnitMapRead(iface, decl))
+ .Change("<METHOD_HANDLER_CALLBACK_INVOKE>",
+ GenMethodHandlerCallbackInvoke(iface, decl))
+ .Change("<METHOD_UNIT_MAP_WRITE>", GenMethodUnitMapWrite(iface, decl))
+ .Change("<METHOD_HANDLER_ARGS_FREE>",
+ GenMethodHandlerArgsFree(iface, decl))
+ .Transform([&](std::string code) { return SmartIndent(code); })
+ .Out(stream);
}
// @ see #CB_INTERFACE_PRIVILEGE_CHECKER
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>", enum_value },
- { "<PREFIX>", GetHandlePrefix() },
- { "<NAME>", iface.GetID() },
- { "<METHOD_NAME>", d->GetID() }
- }));
-
- code += RemoveLine(method_handler);
+ code +=
+ RemoveLine(std::string(ReplaceAll(CB_INTERFACE_METHOD_HANDLER)
+ .ChangeToUpper("<ENUM_VALUE>", enum_value)
+ .Change("<PREFIX>", GetHandlePrefix())
+ .Change("<NAME>", iface.GetID())
+ .Change("<METHOD_NAME>", d->GetID())));
}
return code;
// @see #CB_INTERFACE_METHOD_TABLE
void CStubBodyGenerator::GenInterfaceMethodTable(std::ofstream& stream,
- const Interface& iface) {
- std::string code(ReplaceAll(CB_INTERFACE_METHOD_TABLE, {
- { "<NAME>", iface.GetID() },
- { "<METHOD_HANDLERS>", GenMethodHandlers(iface) }
- }));
-
- stream << SmartIndent(code);
+ const Interface& iface) {
+ ReplaceAll(CB_INTERFACE_METHOD_TABLE)
+ .Change("<NAME>", iface.GetID())
+ .Change("<METHOD_HANDLERS>", 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, {
- { "<PREFIX>", GetHandlePrefix() },
- { "<NAME>", iface.GetID() }
- }));
-
- stream << SmartIndent(code);
+ const Interface& iface) {
+ ReplaceAll(CB_INTERFACE_CALLBACK_PORT_CHECK)
+ .Change("<PREFIX>", GetHandlePrefix())
+ .Change("<NAME>", iface.GetID())
+ .Transform([&](std::string code) { return SmartIndent(code); })
+ .Out(stream);
}
// @see #CB_INTERFACE_PRIVILEGE_ADD
std::string code;
for (const auto& attr : iface.GetAttributes()) {
if (attr->GetKey() == "privilege") {
- std::string privilege_add(ReplaceAll(CB_INTERFACE_PRIVILEGE_ADD, {
- { "<NAME>", iface.GetID() },
- { "<PRIVILEGE>", attr->GetValue() }
- }));
-
- code += privilege_add;
+ code += ReplaceAll(CB_INTERFACE_PRIVILEGE_ADD)
+ .Change("<NAME>", iface.GetID())
+ .Change("<PRIVILEGE>", attr->GetValue());
} else if (attr->GetKey() == "trusted" && attr->GetValue() == "true") {
- std::string trusted_set(ReplaceAll(CB_INTERFACE_TRUSTED_SET,
- "<NAME>", iface.GetID()));
-
- code += trusted_set;
+ code += ReplaceAll(CB_INTERFACE_TRUSTED_SET)
+ .Change("<NAME>", iface.GetID());
}
}
// @see #CB_INTERFACE_BASE
void CStubBodyGenerator::GenInterfaceBase(std::ofstream& stream,
const Interface& iface) {
- std::string code(ReplaceAll(CB_INTERFACE_BASE, {
- { "<PREFIX>", GetHandlePrefix() },
- { "<PREFIX_REVERSE>", GetHandlePrefixReverse() },
- { "<NAME>", iface.GetID() },
- { "<ACCESS_CONTROL_SET>", GenAccessControlSet(iface) }
- }));
-
- stream << SmartIndent(code);
+ ReplaceAll(CB_INTERFACE_BASE)
+ .Change("<PREFIX>", GetHandlePrefix())
+ .Change("<PREFIX_REVERSE>", GetHandlePrefixReverse())
+ .Change("<NAME>", iface.GetID())
+ .Change("<ACCESS_CONTROL_SET>", GenAccessControlSet(iface))
+ .Transform([&](std::string code) { return SmartIndent(code); })
+ .Out(stream);
}
} // namespace version2
* 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 <memory>
#include <string>
class CStubBodyGenerator : public CBodyGeneratorBase {
public:
explicit CStubBodyGenerator(std::shared_ptr<Document> doc,
- std::shared_ptr<Options> options);
+ std::shared_ptr<Options> options);
virtual ~CStubBodyGenerator() = default;
void OnInitGen(std::ofstream& stream) override;
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);
} // namespace version2
} // namespace tidl
-#endif // IDLC_C_GEN_C_STUB_BODY_GENERATOR_HH_
+#endif // IDLC_GEN_VERSION2_C_STUB_BODY_GENERATOR_HH_
* 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(
R"__c_cb(
static void __<PREFIX>_<NAME>_throw_remote_exception(rpc_port_h port, rpc_port_parcel_h parcel, int cause, const char *message)
{
- <PREFIX>_<NAME>_remote_exception_h remote_exception = nullptr;
+ <PREFIX>_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;
rpc_port_unit_map_write_int(map, "[METHOD]", <UPPERCASE_PREFIX>_<UPPERCASE_NAME>_METHOD_RESULT_);
- <PREFIX>_<NAME>_remote_exception_create(&remote_exception);
- <PREFIX>_<NAME>_remote_exception_set_cause(remote_exception, cause);
- <PREFIX>_<NAME>_remote_exception_set_message(remote_exception, message);
- rpc_port_unit_map_write_<NAME>_remote_exception(map, "[REMOTE_EXCEPTION]", remote_exception);
- <PREFIX>_<NAME>_remote_exception_destroy(remote_exception);
+ <PREFIX>_remote_exception_create(&remote_exception);
+ <PREFIX>_remote_exception_set_cause(remote_exception, cause);
+ <PREFIX>_remote_exception_set_message(remote_exception, message);
+ rpc_port_unit_map_write_remote_exception(map, "[REMOTE_EXCEPTION]", remote_exception);
+ <PREFIX>_remote_exception_destroy(remote_exception);
if (rpc_port_parcel_create(&result_parcel) != RPC_PORT_ERROR_NONE) {
_E("Failed to create parcel handle");
*/
constexpr const char CB_INTERFACE_METHOD_CALLBACK_INVOKE[] =
R"__c_cb(
-if (__<PREFIX>_<NAME>_remote_exception != nullptr) {
- <PREFIX>_<NAME>_remote_exception_destroy(__<PREFIX>_<NAME>_remote_exception);
- __<PREFIX>_<NAME>_remote_exception = nullptr;
+if (__<PREFIX>_remote_exception != nullptr) {
+ <PREFIX>_remote_exception_destroy(__<PREFIX>_remote_exception);
+ __<PREFIX>_remote_exception = nullptr;
}
if (context_->callback.<METHOD_NAME>)
*/
constexpr const char CB_INTERFACE_METHOD_PARCEL_WRITE_POST[] =
R"__c_cb(
-if (__<PREFIX>_<NAME>_remote_exception != nullptr)
- rpc_port_unit_map_write_<NAME>_remote_exception(map_, "[REMOTE_EXCEPTION]", __<PREFIX>_<NAME>_remote_exception);
+if (__<PREFIX>_remote_exception != nullptr)
+ rpc_port_unit_map_write_remote_exception(map_, "[REMOTE_EXCEPTION]", __<PREFIX>_remote_exception);
if (context_->lem_cb.is_LEM) {
stub_result_.lem_ret = map_;
}
)__c_cb";
-/**
- * <PREFIX> The prefix of the interface.
- * <NAME> The name of the interface.
- */
-constexpr const char CB_INTERFACE_REMOTE_EXCEPTION_DEF[] =
-R"__c_cb(
-typedef struct <PREFIX>_<NAME>_remote_exception_s {
- rpc_port_parcelable_t parcelable;
- int cause;
- char *message;
-} <PREFIX>_<NAME>_remote_exception_t;
-
-static __thread <PREFIX>_<NAME>_remote_exception_h __<PREFIX>_<NAME>_remote_exception;
-)__c_cb";
-
-/**
- * <PREFIX> The prefix of the interface.
- * <NAME> The name of the interface.
- */
-constexpr const char CB_INTERFACE_REMOTE_EXCEPTION_BASE[] =
-R"__c_cb(
-static void __<PREFIX>_<NAME>_remote_exception_to(rpc_port_parcel_h parcel, void *user_data)
-{
- <PREFIX>_<NAME>_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 __<PREFIX>_<NAME>_remote_exception_from(rpc_port_parcel_h parcel, void *user_data)
-{
- <PREFIX>_<NAME>_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 <PREFIX>_<NAME>_remote_exception_create(<PREFIX>_<NAME>_remote_exception_h *h)
-{
- <PREFIX>_<NAME>_remote_exception_h exception;
-
- if (h == nullptr) {
- _E("Invalid parameter");
- return RPC_PORT_ERROR_INVALID_PARAMETER;
- }
-
- exception = calloc(1, sizeof(<PREFIX>_<NAME>_remote_exception_t));
- if (exception == nullptr) {
- _E("calloc() is failed");
- return RPC_PORT_ERROR_OUT_OF_MEMORY;
- }
-
- exception->parcelable.to = __<PREFIX>_<NAME>_remote_exception_to;
- exception->parcelable.from = __<PREFIX>_<NAME>_remote_exception_from;
-
- *h = exception;
-
- return RPC_PORT_ERROR_NONE;
-}
-
-int <PREFIX>_<NAME>_remote_exception_set_cause(<PREFIX>_<NAME>_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 <PREFIX>_<NAME>_remote_exception_set_message(<PREFIX>_<NAME>_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 <PREFIX>_<NAME>_remote_exception_throw(<PREFIX>_<NAME>_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_<NAME>_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 (__<PREFIX>_<NAME>_remote_exception != nullptr) {
- <PREFIX>_<NAME>_remote_exception_destroy(__<PREFIX>_<NAME>_remote_exception);
- __<PREFIX>_<NAME>_remote_exception = nullptr;
- }
-
- ret = rpc_port_unit_map_read_<NAME>_remote_exception(map, "clone", &__<PREFIX>_<NAME>_remote_exception);
- rpc_port_unit_map_destroy(map);
-
- return ret;
-}
-
-int <PREFIX>_<NAME>_remote_exception_destroy(<PREFIX>_<NAME>_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";
-
/**
* <PREFIX> The prefix of the interace.
* <NAME> The name of the interface.
[<ENUM_VALUE>] = __<PREFIX>_<NAME>_method_<METHOD_NAME>_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_
#include "idlc/gen/version2/c_stub_header_generator.hh"
-namespace {
#include "idlc/gen/version2/c_stub_header_generator_cb.hh"
-}
namespace tidl {
namespace version2 {
GenExplicitLinkageOpen(stream);
GenEnums(stream);
GenStructureHandles(stream);
+ GenRemoteExceptionHandle(stream);
GenInterfaceHandles(stream);
GenStructures(stream);
+ GenRemoteException(stream);
GenInterfaceCallbacks(stream);
GenInterfaces(stream);
}
auto& iface = static_cast<const Interface&>(*b);
GenInterfaceContextHandle(stream, iface);
- GenInterfaceRemoteExceptionHandle(stream, iface);
for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
// @see #CB_INTERFACE_CONTEXT_HANDLE
void CStubHeaderGenerator::GenInterfaceContextHandle(std::ofstream& stream,
- const Interface& iface) {
- std::string code(ReplaceAll(CB_INTERFACE_CONTEXT_HANDLE, {
- { "<PREFIX>", GetHandlePrefix() },
- { "<NAME>", 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("<PREFIX>", GetHandlePrefix())
.Change("<NAME>", iface.GetID())
.Transform([&](std::string code) { return SmartIndent(code); })
// @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, {
- { "<PREFIX>", GetHandlePrefix() },
- { "<NAME>", iface.GetID() },
- { "<DELEGATE_NAME>", decl.GetID() }
- }));
-
- stream << SmartIndent(code);
+ const Interface& iface,
+ const Declaration& decl) {
+ ReplaceAll(CB_INTERFACE_DELEGATE_HANDLE)
+ .Change("<PREFIX>", GetHandlePrefix())
+ .Change("<NAME>", iface.GetID())
+ .Change("<DELEGATE_NAME>", decl.GetID())
+ .Transform([&](std::string code) { return SmartIndent(code); })
+ .Out(stream);
}
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, {
- { "<PREFIX>", GetHandlePrefix() },
- { "<NAME>", iface.GetID() }
- }));
-
- stream << SmartIndent(code);
+ const Interface& iface) {
+ ReplaceAll(CB_INTERFACE_CALLBACK_BASE)
+ .Change("<PREFIX>", GetHandlePrefix())
+ .Change("<NAME>", 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 += ", ";
}
// @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, {
- { "<RETURN_TYPE>", GetReturnTypeString(decl.GetType(), iface.GetID()) },
- { "<PREFIX>", GetHandlePrefix() },
- { "<NAME>", iface.GetID() },
- { "<METHOD_NAME>", decl.GetID() },
- { "<METHOD_PARAMS>", 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("<RETURN_TYPE>",
+ GetReturnTypeString(decl.GetType(), iface.GetID()))
+ .Change("<PREFIX>", GetHandlePrefix())
+ .Change("<NAME>", iface.GetID())
+ .Change("<METHOD_NAME>", decl.GetID())
+ .Change("<METHOD_PARAMS>", GenMethodParams(iface, decl))
+ .Transform([&](std::string code) { return SmartIndent(code); })
+ .Out(stream);
}
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;
// @see #CB_INTERFACE_CONTEXT_BASE
void CStubHeaderGenerator::GenInterfaceContextBase(std::ofstream& stream,
- const Interface& iface) {
- std::string code(ReplaceAll(CB_INTERFACE_CONTEXT_BASE, {
- { "<PREFIX>", GetHandlePrefix() },
- { "<NAME>", 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("<PREFIX>", GetHandlePrefix())
.Change("<NAME>", iface.GetID())
.Transform([&](std::string code) { return SmartIndent(code); })
}
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;
// @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, {
- { "<PREFIX>", GetHandlePrefix() },
- { "<NAME>", iface.GetID() },
- { "<DELEGATE_NAME>", decl.GetID() },
- { "<DELEGATE_PARAMS>", GenDelegateParams(iface, decl) }
- }));
-
- stream << SmartIndent(code);
+ const Interface& iface,
+ const Declaration& decl) {
+ ReplaceAll(CB_INTERFACE_DELEGATE_BASE)
+ .Change("<PREFIX>", GetHandlePrefix())
+ .Change("<NAME>", iface.GetID())
+ .Change("<DELEGATE_NAME>", decl.GetID())
+ .Change("<DELEGATE_PARAMS>", 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, {
- { "<PREFIX>", GetHandlePrefix() },
- { "<NAME>", iface.GetID() },
- { "<METHOD_NAME>", 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("<PREFIX>", GetHandlePrefix())
+ .Change("<NAME>", iface.GetID())
+ .Change("<METHOD_NAME>", 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, {
- { "<PREFIX>", GetHandlePrefix() },
- { "<NAME>", iface.GetID() },
- { "<METHOD_CALLBACK_DECLS>", GenMethodCallbackDecls(iface) }
- }));
-
- stream << SmartIndent(code);
+ const Interface& iface) {
+ ReplaceAll(CB_INTERFACE_BASE)
+ .Change("<PREFIX>", GetHandlePrefix())
+ .Change("<NAME>", iface.GetID())
+ .Change("<METHOD_CALLBACK_DECLS>", GenMethodCallbackDecls(iface))
+ .Transform([&](std::string code) { return SmartIndent(code); })
+ .Out(stream);
}
} // namespace version2
* 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 <memory>
#include <string>
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);
};
} // namespace version2
} // namespace tidl
-#endif // IDLC_C_GEN_C_STUB_HEADER_GENERATOR_HH_
+#endif // IDLC_GEN_VERSION2_C_STUB_HEADER_GENERATOR_HH_
* 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 {
/**
* <PREFIX> The prefix of the interface.
<PREFIX>_<NAME>_<METHOD_NAME>_cb <METHOD_NAME>; /**< This callback function is invoked when the <METHOD_NAME> request is delivered. */
)__c_cb";
-/**
- * <PREFIX> The prefix of the interface.
- * <NAME> The name of the interface.
- */
-constexpr const char CB_INTERFACE_REMOTE_EXCEPTION_HANDLE[] =
-R"__c_cb(
-/**
- * @brief The <PREFIX> <NAME> remote exception handle.
- */
-typedef struct <PREFIX>_<NAME>_remote_exception_s *<PREFIX>_<NAME>_remote_exception_h;
-)__c_cb";
-
-/**
- * <PREFIX> The prefix of the interface.
- * <NAME> The name of the interface.
- */
-constexpr const char CB_INTERFACE_REMOTE_EXCEPTION_BASE[] =
-R"__c_cb(
-/**
- * @brief Creates the <PREFIX> <NAME> remote exception handle.
- *
- * @remarks The @c h handle should be released if it's no longer needed.
- * @param[out] h The <PREFIX> <NAME> 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 <PREFIX>_<NAME>_remote_exception_throw()
- * @see <PREFIX>_<NAME>_remote_exception_destroy()
- */
-int <PREFIX>_<NAME>_remote_exception_create(<PREFIX>_<NAME>_remote_exception_h *h);
-
-/**
- * @brief Sets the cause of the exception.
- *
- * @param[in] h The <PREFIX> <NAME> 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 <PREFIX>_<NAME>_remote_exception_set_cause(<PREFIX>_<NAME>_remote_exception_h h, int cause);
-
-/**
- * @brief Sets the detail message of the exception.
- *
- * @param[in] h The <PREFIX> <NAME> 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 <PREFIX>_<NAME>_remote_exception_set_message(<PREFIX>_<NAME>_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 <PREFIX> <NAME> 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 <PREFIX>_<NAME>_remote_exception_throw(<PREFIX>_<NAME>_remote_exception_h h);
-
-/**
- * @brief Destroys the <PREFIX> <NAME> remote exception handle.
- *
- * @param[in] h The <PREFIX> <NAME> 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 <PREFIX>_<NAME>_remote_exception_destroy(<PREFIX>_<NAME>_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_