stream << NLine(1);
stream << st.GetComments();
-
stream << SmartIndent(GenTemplateString(block,
[&]()->std::string {
return st.GetID();
std::string str;
for (auto& i : st.GetElements().GetElms()) {
str += GetStringFromElementType(i->GetType()) +
- " " + i->GetID() + ";";
- str += NLine(1);
+ i->GetID() + ";" + NLine(1);
}
return str;
}
void CBodyGeneratorBase::GenStructureParcelSerializer(std::ofstream& stream,
const Structure& st) {
const char block[] =
- "static void __##_to(rpc_port_parcel_h parcel, void* data)\n" \
+ "static void __##_to(rpc_port_parcel_h parcel, void *data)\n" \
"{\n" \
" rpc_port_##_h h = data;\n" \
"\n" \
void CBodyGeneratorBase::GenStructureParcelDeserializer(std::ofstream& stream,
const Structure& st) {
const char block[] =
- "static void __##_from(rpc_port_parcel_h parcel, void* data)\n" \
+ "static void __##_from(rpc_port_parcel_h parcel, void *data)\n" \
"{\n" \
" rpc_port_##_h h = data;\n" \
"\n"
void CBodyGeneratorBase::GenStructureConstructor(std::ofstream& stream,
const Structure& st) {
const char block[] =
- "int rpc_port_create_##(rpc_port_##_h* h)\n" \
+ "int rpc_port_create_##(rpc_port_##_h *h)\n" \
"{\n" \
- " struct ##_s* handle;\n" \
+ " struct ##_s *handle;\n" \
"\n" \
" if (!h) {\n" \
" LOGE(\"Invalid parameter\");\n" \
void CBodyGeneratorBase::GenStructureSetter(std::ofstream& stream,
const Structure& st) {
const char block[] =
- "int rpc_port_$$_$$_$$(rpc_port_$$_h h, $$ $$)\n" \
+ "int rpc_port_$$_$$_$$(rpc_port_$$_h h, $$$$)\n" \
"{\n" \
" if ($$) {\n" \
" LOGE(\"Invalid parameter\");\n" \
void CBodyGeneratorBase::GenStructureGetter(std::ofstream& stream,
const Structure& st) {
const char block[] =
- "int rpc_port_get_$$_$$(rpc_port_$$_h h, $$ $$)\n" \
+ "int rpc_port_get_$$_$$(rpc_port_$$_h h, $$$$)\n" \
"{\n" \
" if (!h || $$) {\n" \
" LOGE(\"Invalid parameter\");\n" \
const Structure& st) {
const char block[] =
"int rpc_port_foreach_$$_$$(rpc_port_$$_h h, " \
- "void (*callback)($$ $$, void* user_data), void* user_data)\n" \
+ "void (*callback)($$$$, void *user_data), void *user_data)\n" \
"{\n" \
" if (!h || !callback) {\n" \
" LOGE(\"Invalid parameter\");\n" \
void CBodyGeneratorBase::GenStructureCloner(std::ofstream& stream,
const Structure& st) {
const char block[] =
- "int rpc_port_clone_##(rpc_port_##_h h, rpc_port_##_h* clone)\n" \
+ "int rpc_port_clone_##(rpc_port_##_h h, rpc_port_##_h *clone)\n" \
"{\n" \
" rpc_port_##_h handle = NULL;\n" \
"\n" \
std::string CBodyGeneratorBase::GetStringFromElementType(const BaseType& type) {
if (type.IsUserDefinedType())
- return "rpc_port_" + type.ToString() + "_h";
+ return "rpc_port_" + type.ToString() + "_h ";
if (type.ToString() == "list" ||
type.ToString() == "array")
- return "GList*";
+ return "GList *";
if (type.ToString() == "string")
- return "char*";
+ return "char *";
if (type.ToString() == "bundle")
- return "bundle*";
+ return "bundle *";
- return type.ToString();
+ return type.ToString() + " ";
}
std::string CBodyGeneratorBase::GetParcelWriteFunctionString(
const char parcel[] = "$$(parcel, $$);\n";
const char do_while[] =
"do {\n" \
- " GList* iter = $$;\n"
+ " GList *iter = $$;\n"
" while (iter) {\n" \
- " $$ value = iter->data;\n" \
+ " $$value = iter->data;\n" \
"\n" \
" iter = g_list_next(iter);\n" \
" if (!value) {\n" \
[&]()->std::string {
if (type.IsUserDefinedType())
return "&h->" + id + ", h->" + id;
- if (type.ToString() == "list")
+ if (type.ToString() == "list" ||
+ type.ToString() == "array")
return "g_list_length(h->" + id + ")";
return "h->" + id;
}
"\n" \
" $$" \
" for (int i = 0; i < len; i++) {\n" \
- " $$ value = NULL;\n" \
+ " $$value = NULL;\n" \
"\n" \
" $$" \
" $$ = g_list_append($$, value);\n" \
" $$";
const char do_while[] =
"do {\n" \
- " GList* iter = $$;\n" \
+ " GList *iter = $$;\n" \
" while (iter) {\n" \
- " $$ value = iter->data;\n" \
+ " $$value = iter->data;\n" \
" $$" \
" iter = g_list_next(iter);\n" \
" }\n" \
"}\n";
const char do_while[] =
"do {\n" \
- " $$ value;\n" \
+ " $$value;\n" \
"\n" \
" value = calloc(1, sizeof(*value));\n" \
" $$" \
std::string str;
const char iterator[] =
"do {\n" \
- " GList* iter = $$;\n" \
+ " GList *iter = $$;\n" \
" while (iter) {\n" \
- " $$ value = iter->data;\n" \
+ " $$value = iter->data;\n" \
"\n" \
" iter = g_list_next(iter);\n" \
" if (!value) {\n" \
"}\n";
const char do_while[] =
"do {\n" \
- " GList* iter = $$;\n" \
+ " GList *iter = $$;\n" \
" while (iter) {\n" \
- " $$ new_value;\n" \
- " $$ value = iter->data;\n" \
+ " $$new_value;\n" \
+ " $$value = iter->data;\n" \
"\n" \
" if (!value) {\n" \
" LOGE(\"Error: value is NULL\");\n" \
ParameterType::Direction direction, const BaseType& type) {
if (type.IsUserDefinedType()) {
if (direction == ParameterType::Direction::IN)
- return "rpc_port_" + type.ToString() + "_h";
+ return "rpc_port_" + type.ToString() + "_h ";
else
- return "rpc_port_" + type.ToString() + "_h" + "*";
+ return "rpc_port_" + type.ToString() + "_h *";
}
if (type.ToString() == "list" ||
type.ToString() == "array") {
if (direction == ParameterType::Direction::IN)
- return "GList*";
+ return "GList *";
else
- return "GList**";
+ return "GList **";
}
if (type.ToString() == "string") {
if (direction == ParameterType::Direction::IN)
- return "const char*";
+ return "const char *";
else
- return "char**";
+ return "char **";
}
if (type.ToString() == "bundle") {
if (direction == ParameterType::Direction::IN)
- return "bundle*";
+ return "bundle *";
else
- return "bundle**";
+ return "bundle **";
}
if (direction == ParameterType::Direction::IN)
- return type.ToString();
+ return type.ToString() + " ";
- return type.ToString() + "*";
+ return type.ToString() + " *";
}
std::string CGeneratorBase::GetFullNameFromType(const BaseType& type) {
std::string CGeneratorBase::GetParcelParamTypeString(const BaseType& type) {
if (type.IsUserDefinedType())
- return "rpc_port_" + type.ToString() + "_h";
+ return "rpc_port_" + type.ToString() + "_h ";
if (type.ToString() == "list" ||
type.ToString() == "array")
- return "rpc_port_" + GetFullNameFromType(type) + "_h";
+ return "rpc_port_" + GetFullNameFromType(type) + "_h ";
if (type.ToString() == "string")
- return "char*";
+ return "char *";
- return type.ToString() + "*";
+ return type.ToString() + " *";
}
std::string CGeneratorBase::GetReturnTypeString(const BaseType& type) {
if (type.IsUserDefinedType())
- return "rpc_port_" + type.ToString() + "_h";
+ return "rpc_port_" + type.ToString() + "_h ";
if (type.ToString() == "list" ||
type.ToString() == "array")
- return "rpc_port_" + GetFullNameFromType(type) + "_h";
+ return "rpc_port_" + GetFullNameFromType(type) + "_h ";
if (type.ToString() == "string")
- return "char*";
+ return "char *";
- return type.ToString();
+ return type.ToString() + " ";
}
void CGeneratorBase::AddStructureFromType(const BaseType& type) {
type.ToString() == "list" ||
type.ToString() == "array") {
if (direction == ParameterType::Direction::IN)
- return "rpc_port_" + type.ToString() + "_h";
+ return "rpc_port_" + type.ToString() + "_h ";
else
- return "rpc_port_" + type.ToString() + "_h" + "*";
+ return "rpc_port_" + type.ToString() + "_h *";
}
if (type.ToString() == "string") {
if (direction == ParameterType::Direction::IN)
- return "const char*";
+ return "const char *";
else
- return "char**";
+ return "char **";
}
if (type.ToString() == "bundle") {
if (direction == ParameterType::Direction::IN)
- return "bundle*";
+ return "bundle *";
else
- return "bundle**";
+ return "bundle **";
}
if (direction == ParameterType::Direction::IN)
- return type.ToString();
+ return type.ToString() + " ";
- return type.ToString() + "*";
+ return type.ToString() + " *";
+}
+
+std::string CGeneratorBase::GetErrorValue(const BaseType& type)
+{
+ if (type.IsUserDefinedType() ||
+ type.ToString() == "list" ||
+ type.ToString() == "array" ||
+ type.ToString() == "bundle" ||
+ type.ToString() == "string")
+ return "NULL";
+ if (type.ToString() == "bool")
+ return "false";
+ if (type.ToString() == "char")
+ return "0";
+ return "-1";
}
} // namespace tidl
std::string GetReturnTypeString(const BaseType& type);
std::string GetParamTypeString(ParameterType::Direction direction,
const BaseType& type);
+ std::string GetErrorValue(const BaseType& type);
bool TypeIsDelegator(const Interface& inf, const BaseType& type);
void AddStructureFromType(const BaseType& type);
const std::map<std::string, std::unique_ptr<Structure>>& GetStructures(void) {
void CHeaderGeneratorBase::GenStructureConstructor(std::ofstream& stream,
const Structure& st) {
- const char format[] = "int rpc_port_create_$$(rpc_port_$$_h* h);\n";
+ const char format[] = "int rpc_port_create_$$(rpc_port_$$_h *h);\n";
stream << NLine(1);
GenTemplate(format, stream,
void CHeaderGeneratorBase::GenStructureSetter(std::ofstream& stream,
const Structure& st) {
- const char format[] = "int rpc_port_$$_$$_$$(rpc_port_$$_h h, $$ $$);\n";
+ const char format[] = "int rpc_port_$$_$$_$$(rpc_port_$$_h h, $$$$);\n";
for (auto& i : st.GetElements().GetElms()) {
stream << NLine(1);
void CHeaderGeneratorBase::GenStructureGetter(std::ofstream& stream,
const Structure& st) {
- const char format[] = "int rpc_port_get_$$_$$(rpc_port_$$_h h, $$ $$);\n";
+ const char format[] = "int rpc_port_get_$$_$$(rpc_port_$$_h h, $$$$);\n";
for (auto& i : st.GetElements().GetElms()) {
if (i->GetType().ToString() == "list" ||
const Structure& st) {
const char format[] =
"int rpc_port_foreach_$$_$$(rpc_port_$$_h h, " \
- "void (*callback)($$ $$, void* user_data), void* user_data);\n";
+ "void (*callback)($$$$, void *user_data), void *user_data);\n";
for (auto& i : st.GetElements().GetElms()) {
if (i->GetType().ToString() != "list" &&
void CHeaderGeneratorBase::GenStructureCloner(std::ofstream& stream,
const Structure& st) {
const char format[] =
- "int rpc_port_clone_$$(rpc_port_$$_h h, rpc_port_$$_h* clone);\n";
+ "int rpc_port_clone_$$(rpc_port_$$_h h, rpc_port_$$_h *clone);\n";
stream << NLine(1);
GenTemplate(format, stream,
void CProxyBodyGen::GenTypedefProxyDelegate(std::ofstream& stream) {
const char format[] =
- "typedef void (*proxy_delegate)(GList* list, rpc_port_parcel_h parcel, int seq_id);\n";
+ "typedef void (*proxy_delegate)(GList *list, rpc_port_parcel_h parcel, int seq_id);\n";
stream << NLine(1);
stream << std::string(format);
}
const Interface& inf) {
const char block[] =
"struct ##_s {\n" \
- " char* stub_appid;\n" \
+ " char *stub_appid;\n" \
" rpc_port_proxy_h proxy;\n" \
" rpc_port_h port;\n" \
" rpc_port_proxy_##_callback_s callback;\n" \
- " void* user_data;\n" \
- " GList* delegates;\n" \
+ " void *user_data;\n" \
+ " GList *delegates;\n" \
"};\n";
stream << NLine(1);
stream << SmartIndent(ReplaceAll(block, "##", inf.GetID()));
void CProxyBodyGen::GenInterfaceDelegatorSerializer(
std::ofstream& stream, const std::string& id, const Declaration& decl) {
const char block[] =
- "static void __##_to(rpc_port_parcel_h parcel, void* data)\n" \
+ "static void __##_to(rpc_port_parcel_h parcel, void *data)\n" \
"{\n" \
- " struct ##_s* handle = data;\n" \
+ " struct ##_s *handle = data;\n" \
"\n" \
" if (!handle) {\n" \
" LOGE(\"Invalid parameter\");\n" \
void CProxyBodyGen::GenInterfaceDelegatorDeserializer(
std::ofstream& stream, const std::string& id, const Declaration& decl) {
const char block[] =
- "static void __##_from(rpc_port_parcel_h parcel, void* data)\n" \
+ "static void __##_from(rpc_port_parcel_h parcel, void *data)\n" \
"{\n" \
- " struct ##_s* handle = data;\n" \
+ " struct ##_s *handle = data;\n" \
"\n" \
" if (!handle) {\n" \
" LOGE(\"Invalid parameter\");\n" \
void CProxyBodyGen::GenInterfaceDelegatorConstructor(
std::ofstream& stream, const std::string& id, const Declaration& decl) {
const char block[] =
- "static struct ##_s* __create_##(## callback)\n" \
+ "static struct ##_s *__create_##(## callback)\n" \
"{\n" \
- " struct ##_s* handle;\n" \
+ " struct ##_s *handle;\n" \
" static int seq_num;\n" \
"\n" \
" handle = calloc(1, sizeof(struct ##_s));\n" \
"{\n" \
"$$" \
" do {\n" \
- " struct ##_s* handle;\n" \
- " GList* iter;\n" \
+ " struct ##_s *handle;\n" \
+ " GList *iter;\n" \
"\n" \
" iter = list;\n" \
" while (iter) {\n" \
for (auto& i : decl.GetParameters().GetParams()) {
str += GetParcelParamTypeString(
i->GetParameterType().GetBaseType()) +
- " " + i->GetID() + ";" + NLine(1);
+ i->GetID() + ";" + NLine(1);
cnt++;
}
if (cnt > 0)
void CProxyBodyGen::GenInterfaceOnConnectedEventCB(std::ofstream& stream,
const Interface& inf) {
const char block[] =
- "static void __##_on_connected(const char* endpoint, const char* port_name, rpc_port_h port, void* data)\n" \
+ "static void __##_on_connected(const char *endpoint, const char *port_name, rpc_port_h port, void *data)\n" \
"{\n" \
" rpc_port_proxy_##_h handle = data;\n" \
"\n" \
void CProxyBodyGen::GenInterfaceOnDisconnectedEventCB(std::ofstream& stream,
const Interface& inf) {
const char block[] =
- "static void __##_on_disconnected(const char* endpoint, const char* port_name, void* data)\n" \
+ "static void __##_on_disconnected(const char *endpoint, const char *port_name, void *data)\n" \
"{\n" \
" rpc_port_proxy_##_h handle = data;\n" \
"\n" \
void CProxyBodyGen::GenInterfaceOnRejectedEventCB(std::ofstream& stream,
const Interface& inf) {
const char block[] =
- "static void __##_on_rejected(const char* endpoint, const char* port_name, void* data)\n" \
+ "static void __##_on_rejected(const char *endpoint, const char *port_name, void *data)\n" \
"{\n" \
" rpc_port_proxy_##_h handle = data;\n" \
"\n" \
void CProxyBodyGen::GenInterfaceOnReceivedEventCB(std::ofstream& stream,
const Interface& inf) {
const char block[] =
- "static void __##_on_received(const char* endpoint, const char* port_name, void* data)\n" \
+ "static void __##_on_received(const char *endpoint, const char *port_name, void *data)\n" \
"{\n" \
" rpc_port_proxy_##_h handle = data;\n" \
" rpc_port_parcel_h parcel_received;\n" \
void CProxyBodyGen::GenInterfaceMethods(std::ofstream& stream,
const Interface& inf) {
const char block[] =
- "$$ rpc_port_proxy_##_invoke_$$(rpc_port_proxy_##_h h$$)\n" \
+ "$$rpc_port_proxy_##_invoke_$$(rpc_port_proxy_##_h h$$)\n" \
"{\n" \
" rpc_port_parcel_h parcel;\n" \
"$$" \
"}\n";
const char delegate_block[] =
"do {\n" \
- " struct ##_s* handle;\n" \
+ " struct ##_s *handle;\n" \
"\n" \
" handle = __create_##($$);\n" \
" if (!handle)\n" \
p->GetID();
} else {
str += ConvertTypeToString(p->GetParameterType().GetDirection(),
- p->GetParameterType().GetBaseType()) + " " + p->GetID();
+ p->GetParameterType().GetBaseType()) + p->GetID();
}
}
return str;
},
[&]()->std::string {
- if (GetReturnTypeString(i->GetType()) != "void")
- return GetReturnTypeString(i->GetType()) + " ret = 0;" + NLine(1);
+ if (GetReturnTypeString(i->GetType()) != "void ")
+ return GetReturnTypeString(i->GetType()) + "ret = " +
+ GetErrorValue(i->GetType()) + ";" + NLine(1);
return "";
},
[&]()->std::string {
return str;
},
[&]()->std::string {
- if (GetReturnTypeString(i->GetType()) != "void")
+ if (GetReturnTypeString(i->GetType()) != "void ")
return " ret";
return "";
},
[&]()->std::string {
- if (GetReturnTypeString(i->GetType()) != "void")
+ if (GetReturnTypeString(i->GetType()) != "void ")
return " ret";
return "";
},
}
);
}
- if (GetReturnTypeString(i->GetType()) != "void") {
+ if (GetReturnTypeString(i->GetType()) != "void ") {
if (i->GetType().IsUserDefinedType() ||
i->GetType().ToString() == "list" ||
i->GetType().ToString() == "array") {
return s;
}
);
- if (GetReturnTypeString(i->GetType()) != "void") {
+ if (GetReturnTypeString(i->GetType()) != "void ") {
str += NLine(1);
str += "return ret;" + NLine(1);;
}
void CProxyBodyGen::GenInterfaceConstructor(std::ofstream& stream,
const Interface& inf) {
const char block[] =
- "static struct ##_s* __create_##(const char* stub_appid, rpc_port_proxy_##_callback_s* callback, void* user_data)\n" \
+ "static struct ##_s *__create_##(const char *stub_appid, rpc_port_proxy_##_callback_s *callback, void *user_data)\n" \
"{\n" \
- " struct ##_s* handle;\n" \
+ " struct ##_s *handle;\n" \
"\n" \
" handle = calloc(1, sizeof(struct ##_s));\n" \
" if (!handle) {\n " \
void CProxyBodyGen::GenInterfaceDestructor(std::ofstream& stream,
const Interface& inf) {
const char block[] =
- "static void __destroy_##(struct ##_s* h)\n" \
+ "static void __destroy_##(struct ##_s *h)\n" \
"{\n" \
" if (!h)\n" \
" return;\n" \
void CProxyBodyGen::GenInterfaceConnect(std::ofstream& stream,
const Interface& inf) {
const char block[] =
- "int rpc_port_proxy_##_connect(const char* stub_appid, rpc_port_proxy_##_callback_s* callback, void* user_data, rpc_port_proxy_##_h* h)\n" \
+ "int rpc_port_proxy_##_connect(const char *stub_appid, rpc_port_proxy_##_callback_s *callback, void *user_data, rpc_port_proxy_##_h *h)\n" \
"{\n" \
- " struct ##_s* handle;\n" \
+ " struct ##_s *handle;\n" \
" int r;\n" \
"\n" \
" if (!stub_appid || !callback || !h) {\n" \
if (cnt != 1)
str += ", ";
str += ConvertTypeToString(p->GetParameterType().GetDirection(),
- p->GetParameterType().GetBaseType()) + " " + p->GetID();
+ p->GetParameterType().GetBaseType()) + p->GetID();
cnt++;
}
return str;
void CProxyHeaderGen::GenInterfaceDeclaration(std::ofstream& stream,
const Interface& inf) {
const char format[] =
- "typedef struct ##_s* rpc_port_proxy_##_h;\n" \
+ "typedef struct ##_s *rpc_port_proxy_##_h;\n" \
"\n" \
"typedef struct {\n" \
- " void (*connected)(rpc_port_proxy_##_h h, void* user_data);\n" \
- " void (*disconnected)(rpc_port_proxy_##_h h, void* user_data);\n" \
- " void (*rejected)(rpc_port_proxy_##_h h, void* user_data);\n" \
+ " void (*connected)(rpc_port_proxy_##_h h, void *user_data);\n" \
+ " void (*disconnected)(rpc_port_proxy_##_h h, void *user_data);\n" \
+ " void (*rejected)(rpc_port_proxy_##_h h, void *user_data);\n" \
"} rpc_port_proxy_##_callback_s;\n";
stream << NLine(1);
stream << SmartIndent(ReplaceAll(format, "##", inf.GetID()));
p->GetID();
} else {
str += ConvertTypeToString(p->GetParameterType().GetDirection(),
- p->GetParameterType().GetBaseType()) + " " + p->GetID();
+ p->GetParameterType().GetBaseType()) + p->GetID();
}
}
return str;
void CProxyHeaderGen::GenInterfaceConnect(std::ofstream& stream,
const Interface& inf) {
const char format[] =
- "int rpc_port_proxy_##_connect(const char* stub_appid, " \
- "rpc_port_proxy_##_callback_s* callback, void* user_data, " \
- "rpc_port_proxy_##_h* h);\n";
+ "int rpc_port_proxy_##_connect(const char *stub_appid, " \
+ "rpc_port_proxy_##_callback_s *callback, void *user_data, " \
+ "rpc_port_proxy_##_h *h);\n";
stream << NLine(1);
stream << ReplaceAll(format, "##", inf.GetID());
}
void CStubBodyGen::GenInterfaceMethods(std::ofstream& stream,
const Interface& inf) {
const char block[] =
- "static int __$$_method_$$(rpc_port_h port, rpc_port_parcel_h parcel, void* data)\n" \
+ "static int __$$_method_$$(rpc_port_h port, rpc_port_parcel_h parcel, void *data)\n" \
"{\n" \
" rpc_port_stub_$$_context_h context = data;\n" \
"$$" \
void CStubBodyGen::GenInterfaceOnConnectedEventCB(std::ofstream& stream,
const Interface& inf) {
const char block[] =
- "static void __##_on_connected(const char* sender, const char* instance, void* data)\n" \
+ "static void __##_on_connected(const char *sender, const char *instance, void *data)\n" \
"{\n" \
" rpc_port_stub_##_context_h context;\n" \
"\n" \
void CStubBodyGen::GenInterfaceOnDisconnectedEventCB(std::ofstream& stream,
const Interface& inf) {
const char block[] =
- "static void __##_on_disconnected(const char* sender, const char* instance, void* data)\n" \
+ "static void __##_on_disconnected(const char *sender, const char *instance, void *data)\n" \
"{\n" \
" rpc_port_stub_##_context_h context;\n" \
"\n" \
void CStubBodyGen::GenInterfaceOnReceivedEventCB(std::ofstream& stream,
const Interface& inf) {
const char block[] =
- "static int __##_on_received(const char* sender, const char* instance, rpc_port_h port, void* data)\n" \
+ "static int __##_on_received(const char *sender, const char *instance, rpc_port_h port, void *data)\n" \
"{\n" \
" rpc_port_stub_##_context_h context;\n" \
" rpc_port_parcel_h parcel;\n" \
void CStubBodyGen::GenInterfaceRegister(std::ofstream& stream,
const Interface& inf) {
const char block[] =
- "int rpc_port_stub_##_register(rpc_port_stub_##_callback_s* callback, void* user_data)\n" \
+ "int rpc_port_stub_##_register(rpc_port_stub_##_callback_s *callback, void *user_data)\n" \
"{\n" \
" int r;\n" \
"\n" \
const char format[] =
"static rpc_port_stub_h __##_stub;\n" \
"static rpc_port_stub_##_callback_s __##_callback;\n" \
- "static void* __##_user_data;\n" \
- "static GList* __##_contexts;\n";
+ "static void *__##_user_data;\n" \
+ "static GList *__##_contexts;\n";
stream << NLine(1);
stream << SmartIndent(ReplaceAll(format, "##", inf.GetID()));
int cnt = 0;
for (auto& i : decl.GetParameters().GetParams()) {
str += GetParcelParamTypeString(i->GetParameterType().GetBaseType()) +
- " " + i->GetID() + ";" + NLine(1);
+ i->GetID() + ";" + NLine(1);
if (i->GetParameterType().GetDirection() == ParameterType::Direction::IN)
cnt++;
}
const std::string& id,
const Declaration& decl) {
const char block[] =
- "int rpc_port_create_##(rpc_port_##_h* h)\n" \
+ "int rpc_port_create_##(rpc_port_##_h *h)\n" \
"{\n" \
- " struct ##_s* handle;\n" \
+ " struct ##_s *handle;\n" \
" static int seq_num;\n" \
"\n" \
" if (!h) {\n" \
const std::string& id,
const Declaration& decl) {
const char block[] =
- "static void __##_to(rpc_port_parcel_h parcel, void* data)\n" \
+ "static void __##_to(rpc_port_parcel_h parcel, void *data)\n" \
"{\n" \
" rpc_port_##_h handle = data;\n" \
"\n" \
const std::string& id,
const Declaration& decl) {
const char block[] =
- "static void __##_from(rpc_port_parcel_h parcel, void* data)\n" \
+ "static void __##_from(rpc_port_parcel_h parcel, void *data)\n" \
"{\n" \
" rpc_port_##_h handle = data;\n" \
"\n" \
const std::string& id,
const Declaration& decl) {
const char block[] =
- "int rpc_port_clone_##(rpc_port_##_h h, rpc_port_##_h* clone)\n" \
+ "int rpc_port_clone_##(rpc_port_##_h h, rpc_port_##_h *clone)\n" \
"{\n" \
" rpc_port_##_h handle;\n" \
"\n" \
for (auto& i : decl.GetParameters().GetParams()) {
str += ", ";
str += ConvertTypeToString(i->GetParameterType().GetDirection(),
- i->GetParameterType().GetBaseType()) + " " + i->GetID();
+ i->GetParameterType().GetBaseType()) + i->GetID();
}
return str;
},
const Interface& inf) {
const char block[] =
"struct ##_context_s {\n" \
- " char* sender;\n" \
- " char* instance;\n" \
+ " char *sender;\n" \
+ " char *instance;\n" \
" rpc_port_h port;\n" \
- " void* tag;\n" \
+ " void *tag;\n" \
" rpc_port_stub_##_callback_s callback;\n" \
- " void* user_data;\n" \
+ " void *user_data;\n" \
"};\n";
stream << NLine(1);
stream << SmartIndent(ReplaceAll(block, "##", inf.GetID()));
void CStubBodyGen::GenInterfaceContextConstructor(std::ofstream& stream,
const Interface& inf) {
const char block[] =
- "static struct ##_context_s* __create_##_context(const char* sender, const char* instance)\n" \
+ "static struct ##_context_s *__create_##_context(const char *sender, const char *instance)\n" \
"{\n" \
- " struct ##_context_s* handle;\n" \
+ " struct ##_context_s *handle;\n" \
"\n"
" handle = calloc(1, sizeof(struct ##_context_s));\n" \
" if (!handle) {\n" \
const char block[] =
"static void __destroy_##_context(gpointer data)\n" \
"{\n" \
- " struct ##_context_s* handle = data;\n" \
+ " struct ##_context_s *handle = data;\n" \
"\n" \
" if (!handle) {\n" \
" LOGE(\"Critical error!\");\n" \
void CStubBodyGen::GenInterfaceContextFinder(std::ofstream& stream,
const Interface& inf) {
const char block[] =
- "static struct ##_context_s* __find_##_context(const char* instance)\n" \
+ "static struct ##_context_s *__find_##_context(const char *instance)\n" \
"{\n" \
- " struct ##_context_s* handle;\n" \
- " GList* iter;\n" \
+ " struct ##_context_s *handle;\n" \
+ " GList *iter;\n" \
"\n" \
" iter = __##_contexts;\n" \
" while (iter) {\n" \
- " handle = (struct ##_context_s*)iter->data;\n" \
+ " handle = (struct ##_context_s *)iter->data;\n" \
" if (!strcmp(handle->instance, instance))\n" \
" return handle;\n" \
" iter = g_list_next(iter);\n" \
void CStubBodyGen::GenInterfaceContextTagSetter(std::ofstream& stream,
const Interface& inf) {
const char block[] =
- "int rpc_port_stub_##_context_set_tag(rpc_port_stub_##_context_h ctx, void* tag)\n" \
+ "int rpc_port_stub_##_context_set_tag(rpc_port_stub_##_context_h ctx, void *tag)\n" \
"{\n" \
" if (!ctx) {\n" \
" LOGE(\"Invalid parameter\");\n" \
void CStubBodyGen::GenInterfaceContextTagGetter(std::ofstream& stream,
const Interface& inf) {
const char block[] =
- "int rpc_port_stub_##_context_get_tag(rpc_port_stub_##_context_h ctx, void** tag)\n" \
+ "int rpc_port_stub_##_context_get_tag(rpc_port_stub_##_context_h ctx, void **tag)\n" \
"{\n" \
" if (!ctx || !tag) {\n" \
" LOGE(\"Invalid parameter\");\n" \
void CStubBodyGen::GenInterfaceContextSenderGetter(std::ofstream& stream,
const Interface& inf) {
const char block[] =
- "int rpc_port_stub_##_context_get_sender(rpc_port_stub_##_context_h ctx, char** sender)\n" \
+ "int rpc_port_stub_##_context_get_sender(rpc_port_stub_##_context_h ctx, char **sender)\n" \
"{\n" \
" if (!ctx || !sender) {\n" \
" LOGE(\"Invalid parameter\");\n" \
const char block[] =
"static bool __##_context_port_exist(rpc_port_h port)\n" \
"{\n" \
- " struct ##_context_s* handle;\n" \
- " GList* iter;\n" \
+ " struct ##_context_s *handle;\n" \
+ " GList *iter;\n" \
"\n" \
" iter = __##_contexts;\n" \
" while (iter) {\n" \
- " handle = (struct ##_context_s*)iter->data;\n" \
+ " handle = (struct ##_context_s *)iter->data;\n" \
" if (handle->port == port)\n" \
" return true;\n" \
" iter = g_list_next(iter);\n" \
void CStubBodyGen::GenTypedefStubMethod(std::ofstream& stream) {
const char format[] =
- "typedef int (*stub_method)(rpc_port_h, rpc_port_parcel_h, void* data);\n";
+ "typedef int (*stub_method)(rpc_port_h, rpc_port_parcel_h, void *data);\n";
stream << NLine(1);
stream << std::string(format);
const char callback[] = "$$ (*$$)(rpc_port_stub_Message_context_h context, $$void *user_data);\n";
const char block[] =
"typedef struct {\n" \
- " void (*create)(rpc_port_stub_##_context_h context, void* user_data);\n" \
- " void (*terminate)(rpc_port_stub_##_context_h context, void* user_data);\n" \
+ " void (*create)(rpc_port_stub_##_context_h context, void *user_data);\n" \
+ " void (*terminate)(rpc_port_stub_##_context_h context, void *user_data);\n" \
" $$" \
"} rpc_port_stub_##_callback_s;\n";
stream << NLine(1);
for (auto& p : i->GetParameters().GetParams()) {
if (TypeIsDelegator(inf, p->GetParameterType().GetBaseType())) {
s += GetParcelParamTypeString(p->GetParameterType().GetBaseType()) +
- " " + p->GetID();
+ p->GetID();
} else {
s += GetParamTypeString(p->GetParameterType().GetDirection(),
- p->GetParameterType().GetBaseType()) + " " + p->GetID();
+ p->GetParameterType().GetBaseType()) + p->GetID();
}
s += ", ";
}
void CStubHeaderGen::GenInterfaceContextTagSetter(
std::ofstream& stream, const Interface& inf) {
const char format[] =
- "int rpc_port_stub_##_context_set_tag(rpc_port_stub_##_context_h ctx, void* tag);\n";
+ "int rpc_port_stub_##_context_set_tag(rpc_port_stub_##_context_h ctx, void *tag);\n";
stream << NLine(1);
stream << ReplaceAll(format, "##", inf.GetID());
}
void CStubHeaderGen::GenInterfaceContextTagGetter(
std::ofstream& stream, const Interface& inf) {
const char format[] =
- "int rpc_port_stub_##_context_get_tag(rpc_port_stub_##_context_h ctx, void** tag);\n";
+ "int rpc_port_stub_##_context_get_tag(rpc_port_stub_##_context_h ctx, void **tag);\n";
stream << NLine(1);
stream << ReplaceAll(format, "##", inf.GetID());
}
void CStubHeaderGen::GenInterfaceContextSenderGetter(
std::ofstream& stream, const Interface& inf) {
const char format[] =
- "int rpc_port_stub_##_context_get_sender(rpc_port_stub_##_context_h ctx, char** sender);\n";
+ "int rpc_port_stub_##_context_get_sender(rpc_port_stub_##_context_h ctx, char **sender);\n";
stream << NLine(1);
stream << ReplaceAll(format, "##", inf.GetID());
}
void CStubHeaderGen::GenInterfaceDelegatorDeclaration(
std::ofstream& stream, const std::string& id, const Declaration& decl) {
- const char format[] = "typedef struct ##_s* rpc_port_##_h;\n";
+ const char format[] = "typedef struct ##_s *rpc_port_##_h;\n";
stream << NLine(1);
stream << ReplaceAll(format, "##", decl.GetID());
}
void CStubHeaderGen::GenInterfaceDelegatorCloner(
std::ofstream& stream, const std::string& id, const Declaration& decl) {
const char format[] =
- "int rpc_port_clone_##(rpc_port_##_h h, rpc_port_##_h* clone);\n";
+ "int rpc_port_clone_##(rpc_port_##_h h, rpc_port_##_h *clone);\n";
stream << NLine(1);
stream << ReplaceAll(format, "##", decl.GetID());
}
void CStubHeaderGen::GenInterfaceRegister(std::ofstream& stream,
const Interface& inf) {
const char format[] =
- "int rpc_port_stub_##_register(rpc_port_stub_##_callback_s* callback, void* user_data);\n";
+ "int rpc_port_stub_##_register(rpc_port_stub_##_callback_s *callback, void *user_data);\n";
stream << NLine(1);
stream << ReplaceAll(format, "##", inf.GetID());
}