The generated codes make build break issues.
Change-Id: I1e0b687efff38d967e15c50ad241b5d8a4b41c89
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
type.ToString() == "array") {
code = ReplaceAll(CB_STRUCTURE_ARRAY_USER_DEFINED_PARCEL_READ, "<PREFIX>",
GetHandlePrefix());
-
- std::string name;
- auto* meta_type = type.GetMetaType();
- if (meta_type == nullptr)
- name = type.ToString();
- else
- name = GetFullNameFromType(*meta_type);
-
- code = ReplaceAll(code, "<NAME>", name);
+ code = ReplaceAll(code, "<NAME>", GetFullNameFromType(type));
} else if (type.ToString() == "bundle") {
code = std::string(CB_STRUCTURE_ARRAY_BUNDLE_PARCEL_READ);
} else if (type.ToString() == "string" || type.ToString() == "file") {
type.ToString() == "array") {
code = ReplaceAll(CB_STRUCTURE_ARRAY_USER_DEFINED_FREE, "<PREFIX>",
GetHandlePrefix());
-
- std::string name;
- auto* meta_type = type.GetMetaType();
- if (meta_type == nullptr)
- name = type.ToString();
- else
- name = GetFullNameFromType(*meta_type);
-
- code = ReplaceAll(code, "<NAME>", name);
+ code = ReplaceAll(code, "<NAME>", GetFullNameFromType(type));
} else if (type.ToString() == "bundle") {
code = std::string(CB_STRUCTURE_ARRAY_BUNDLE_FREE);
} else if (type.ToString() == "string" || type.ToString() == "file") {
type.ToString() == "array") {
code = ReplaceAll(CB_STRUCTURE_LIST_USER_DEFINED_FREE, "<PREFIX>",
GetHandlePrefix());
-
- std::string name;
- auto* meta_type = type.GetMetaType();
- if (meta_type == nullptr)
- name = type.ToString();
- else
- name = GetFullNameFromType(*meta_type);
-
- code = ReplaceAll(code, "<NAME>", name);
+ code = ReplaceAll(code, "<NAME>", GetFullNameFromType(type));
} else if (type.ToString() == "bundle") {
code = std::string(CB_STRUCTURE_LIST_BUNDLE_FREE);
} else if (type.ToString() == "string" || type.ToString() == "flie") {
type.ToString() == "array") {
code = ReplaceAll(CB_STRUCTURE_LIST_USER_DEFINED_PARCEL_READ, "<PREFIX>",
GetHandlePrefix());
-
- std::string name;
- auto* meta_type = type.GetMetaType();
- if (meta_type == nullptr)
- name = type.ToString();
- else
- name = GetFullNameFromType(*meta_type);
-
- code = ReplaceAll(code, "<NAME>", name);
+ code = ReplaceAll(code, "<NAME>", GetFullNameFromType(type));
} else if (type.ToString() == "bundle") {
code = std::string(CB_STRUCTURE_LIST_BUNDLE_PARCEL_READ);
} else if (type.ToString() == "string" || type.ToString() == "file") {
type.ToString() == "array") {
code = ReplaceAll(CB_STRUCTURE_LIST_USER_DEFINED_ADD, "<PREFIX>",
GetHandlePrefix());
-
- std::string name;
- auto* meta_type = type.GetMetaType();
- if (meta_type == nullptr)
- name = type.ToString();
- else
- name = GetFullNameFromType(*meta_type);
-
- code = ReplaceAll(code, "<NAME>", name);
+ code = ReplaceAll(code, "<NAME>", GetFullNameFromType(type));
} else if (type.ToString() == "bundle") {
code = std::string(CB_STRUCTURE_LIST_BUNDLE_ADD);
} else if (type.ToString() == "string" || type.ToString() == "file") {
type.ToString() == "array") {
code = ReplaceAll(CB_STRUCTURE_BASE_USER_DEFINED_FREE, "<PREFIX>",
GetHandlePrefix());
-
- std::string name = GetFullNameFromType(type);
- code = ReplaceAll(code, "<NAME>", name);
+ code = ReplaceAll(code, "<NAME>", GetFullNameFromType(type));
code = ReplaceAll(code, "<ELEMENT_NAME>", elm->GetID());
} else if (type.ToString() == "bundle") {
code = ReplaceAll(CB_STRUCTURE_BASE_BUNDLE_FREE, "<ELEMENT_NAME>",
if (!HasNamespace())
return prefix;
- return prefix + "_" + GetFileNamespace() + "_";
+ return prefix + "_" + GetFileNamespace();
}
const std::map<std::string, std::unique_ptr<Structure>>&
// @see CB_INTERFACE_DELEGATE_BUNDLE_ARG_FREE
// @see CB_INTERFACE_DELEGATE_STRING_ARG_FREE
std::string CProxyBodyGen::GenDelegateArgsFree(const Interface& iface,
- const Declaration& decl) {
+ const Declaration& decl, bool& has_free) {
std::string code;
for (auto& p : decl.GetParameters().GetParams()) {
std::string param_free_code;
std::string name = GetFullNameFromType(type, iface);
param_free_code = ReplaceAll(param_free_code, "<NAME>", name);
param_free_code = ReplaceAll(param_free_code, "<ARG>", p->GetID());
+ has_free = true;
} else if (type.ToString() == "bundle") {
param_free_code = ReplaceAll(CB_INTERFACE_DELEGATE_BUNDLE_ARG_FREE,
"<ARG>", p->GetID());
+ has_free = true;
} else if (type.ToString() == "string" || type.ToString() == "file") {
param_free_code = ReplaceAll(CB_INTERFACE_DELEGATE_STRING_ARG_FREE,
"<ARG>", p->GetID());
+ has_free = true;
}
code += param_free_code;
GenDelegateArgsDecl(iface, decl));
code = ReplaceAll(code, "<DELEGATE_PARCEL_READ>",
GenDelegateParcelRead(iface, decl));
- code = ReplaceAll(code, "<DELEGATE_ARGS_FREE>",
- GenDelegateArgsFree(iface, decl));
+ bool has_free = false;
+ std::string delegate_args_free = GenDelegateArgsFree(iface, decl, has_free);
+ code = ReplaceAll(code, "<DELEGATE_ARGS_FREE>", delegate_args_free);
code = ReplaceAll(code, "<DELEGATE_CALLBACK_ARGS>",
GenDelegateCallbackArgs(decl));
+ code = ReplaceAll(code, "<GOTO_STATEMENT>",
+ has_free ? "out:" + NLine(1) : "");
stream << SmartIndent(code);
}
std::string GenDelegateParcelRead(const Interface& iface,
const Declaration& decl);
std::string GenDelegateArgsFree(const Interface& iface,
- const Declaration& decl);
+ const Declaration& decl, bool& has_free);
std::string GenDelegateCallbackArgs(const Declaration& decl);
std::string GenMethodAsyncBase(const Interface& iface,
* <DELEGATE_PARCEL_READ> The implementation to read the arguments from the parcel.
* <DELEGATE_ARGS_FREE> The implementation to release the allocated arguments.
* <DELEGATE_CALLBACK_ARGS> The arguments of the delegate callback.
+ * <GOTO_STATEMENT> The statement label.
*/
constexpr const char CB_INTERFACE_DELEGATE_BASE[] =
R"__c_cb(
}
}
-out:
+<GOTO_STATEMENT>
<DELEGATE_ARGS_FREE>
}
)__c_cb";
*/
constexpr const char CB_INTERFACE_DELEGATE_TABLE[] =
R"__c_cb(
-static <PREFIX>_delegate_cb __<PREFIX>_<NAME>_delegate_table[] = {
+static rpc_port_proxy_delegate_cb __<PREFIX>_<NAME>_delegate_table[] = {
<DELEGATE_HANDLERS>
};
)__c_cb";
// @see #CB_INTERFACE_METHOD_HANDLER_TYPE
void CStubBodyGen::GenInterfaceMethodHandlerType(std::ofstream& stream) {
- std::string code = ReplaceAll(CB_INTERFACE_METHOD_HANDLER_TYPE, "<PREFIX>",
- GetHandlePrefix());
-
- stream << SmartIndent(code);
+ stream << SmartIndent(CB_INTERFACE_METHOD_HANDLER_TYPE);
}
void CStubBodyGen::GenInterfaceEnums(std::ofstream& stream) {
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(CB_INTERFACE_METHOD_PARCEL_WRITE_PRE, "<UPPERCASE_NAME>",
- name);
+ code = ReplaceAll(code, "<UPPERCASE_NAME>", name);
std::string parcel_write_code;
for (auto& p : decl.GetParameters().GetParams()) {
#define TIDL_THREAD_ENABLE 1
)__c_cb";
-/**
- * <PREFIX> The prefix of the interface.
- */
constexpr const char CB_INTERFACE_METHOD_HANDLER_TYPE[] =
R"__c_cb(
-typedef int (*<PREFIX>_method_handler)(rpc_port_h port, rpc_port_parcel_h parcel, void *data);
+typedef int (*rpc_port_stub_method_handler)(rpc_port_h port, rpc_port_parcel_h parcel, void *data);
)__c_cb";
/**
)__c_cb";
/**
+ * <UPPERCASE_PREFIX> The uppercase prefix of the interface.
* <UPPERCASE_NAME> The uppercase name of the interface.
*/
constexpr const char CB_INTERFACE_METHOD_PARCEL_WRITE_PRE[] =
rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
rpc_port_parcel_header_set_seq_num(header_, seq_num_);
-rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_<UPPERCASE_NAME>_METHOD_RESULT_);
+rpc_port_parcel_write_int32(parcel_, <UPPERCASE_PREFIX>_<UPPERCASE_NAME>_METHOD_RESULT_);
)__c_cb";
constexpr const char CB_INTERFACE_METHOD_PARCEL_WRITE_POST[] =
return ret;
}
-int <PREFIX>_<NAME>_register(rpc_port_stub_<NAME>_callback_s *callback, void *user_data)
+int <PREFIX>_<NAME>_register(<PREFIX>_<NAME>_callback_s *callback, void *user_data)
{
int ret;