summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunghoon Park <jh9216.park@samsung.com>2018-04-19 18:59:48 +0900
committerJunghoon Park <jh9216.park@samsung.com>2018-04-19 20:05:10 +0900
commit1ec627b406435f61829f91a709ccad89b31b7e88 (patch)
tree68258c1089e85dce98c1cd08fafa8022a94b5a09
parent673f1c62dd2108b881bbfb08d52743be1950e4d9 (diff)
downloadtidl-1ec627b406435f61829f91a709ccad89b31b7e88.tar.gz
tidl-1ec627b406435f61829f91a709ccad89b31b7e88.tar.bz2
tidl-1ec627b406435f61829f91a709ccad89b31b7e88.zip
Comply with google coding rule
Change-Id: Iaa1962cb72c12e0b4049dd51b573e70d0229980f Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
-rw-r--r--idlc/c_gen/c_body_gen_base.cc220
-rw-r--r--idlc/c_gen/c_body_gen_base.h4
-rw-r--r--idlc/c_gen/c_body_gen_base_cb.h5
-rw-r--r--idlc/c_gen/c_gen_base.cc21
-rw-r--r--idlc/c_gen/c_gen_base_cb.h5
-rw-r--r--idlc/c_gen/c_header_gen_base.cc21
-rw-r--r--idlc/c_gen/c_header_gen_base_cb.h5
-rw-r--r--idlc/c_gen/c_proxy_body_gen.cc130
-rw-r--r--idlc/c_gen/c_proxy_body_gen_cb.h5
-rw-r--r--idlc/c_gen/c_proxy_header_gen.cc18
-rw-r--r--idlc/c_gen/c_proxy_header_gen_cb.h5
-rw-r--r--idlc/c_gen/c_stub_body_gen.cc102
-rw-r--r--idlc/c_gen/c_stub_body_gen.h6
-rw-r--r--idlc/c_gen/c_stub_body_gen_cb.h5
-rw-r--r--idlc/c_gen/c_stub_header_gen.cc44
-rw-r--r--idlc/c_gen/c_stub_header_gen_cb.h5
-rw-r--r--idlc/cpp_gen/cpp_gen_base.cc47
-rw-r--r--idlc/cpp_gen/cpp_gen_base_cb.h5
-rw-r--r--idlc/cpp_gen/cpp_proxy_body_gen.cc11
-rw-r--r--idlc/cpp_gen/cpp_proxy_body_gen_cb.h5
-rw-r--r--idlc/cpp_gen/cpp_proxy_header_gen.cc5
-rw-r--r--idlc/cpp_gen/cpp_proxy_header_gen_cb.h5
-rw-r--r--idlc/cpp_gen/cpp_stub_body_gen.cc17
-rw-r--r--idlc/cpp_gen/cpp_stub_body_gen_cb.h5
-rw-r--r--idlc/cpp_gen/cpp_stub_header_gen.cc2
-rw-r--r--idlc/cpp_gen/cpp_stub_header_gen_cb.h5
-rw-r--r--idlc/cs_gen/cs_cb_copyright.h5
-rw-r--r--idlc/cs_gen/cs_cb_interop.h4
-rw-r--r--idlc/cs_gen/cs_cb_proxy_interop.h5
-rw-r--r--idlc/cs_gen/cs_cb_stub_interop.h5
-rw-r--r--idlc/cs_gen/cs_gen_base.cc39
-rw-r--r--idlc/cs_gen/cs_gen_base_cb.h5
-rw-r--r--idlc/cs_gen/cs_proxy_gen.cc16
-rw-r--r--idlc/cs_gen/cs_proxy_gen_cb.h5
-rw-r--r--idlc/cs_gen/cs_stub_gen.cc12
-rw-r--r--idlc/cs_gen/cs_stub_gen.h6
-rw-r--r--idlc/cs_gen/cs_stub_gen_cb.h5
-rw-r--r--idlc/declaration.h2
-rw-r--r--idlc/generator.h8
-rw-r--r--idlc/main.cc3
-rw-r--r--unit_tests/cs_gen/cs_proxy_gen_unittest.cc12
-rw-r--r--unit_tests/cs_gen/cs_stub_gen_unittest.cc15
-rw-r--r--unit_tests/generator_unittest.cc2
43 files changed, 445 insertions, 412 deletions
diff --git a/idlc/c_gen/c_body_gen_base.cc b/idlc/c_gen/c_body_gen_base.cc
index 71844f4..dcff508 100644
--- a/idlc/c_gen/c_body_gen_base.cc
+++ b/idlc/c_gen/c_body_gen_base.cc
@@ -97,9 +97,7 @@ void CBodyGeneratorBase::GenStructureDeclaration(std::ofstream& stream,
str += NLine(1) + "int " + i->GetID() + "_size;";
}
return str;
- }
- )
- );
+ }));
}
void CBodyGeneratorBase::GenStructureParcelSerializer(std::ofstream& stream,
@@ -113,9 +111,7 @@ void CBodyGeneratorBase::GenStructureParcelSerializer(std::ofstream& stream,
str += GetParcelWriteString(i->GetID(), i->GetType());
}
return str;
- }
- )
- );
+ }));
}
void CBodyGeneratorBase::GenStructureParcelDeserializer(std::ofstream& stream,
@@ -129,14 +125,13 @@ void CBodyGeneratorBase::GenStructureParcelDeserializer(std::ofstream& stream,
str += GetParcelReadString(i->GetID(), i->GetType());
}
return str;
- }
- )
- );
+ }));
}
void CBodyGeneratorBase::GenStructureConstructor(std::ofstream& stream,
const Structure& st) {
- stream << SmartIndent(ReplaceAll(CB_STRUCT_CTOR, "##", GetStructIdWithNamespace(st)));
+ stream << SmartIndent(ReplaceAll(CB_STRUCT_CTOR, "##",
+ GetStructIdWithNamespace(st)));
}
void CBodyGeneratorBase::GenStructureDestructor(std::ofstream& stream,
@@ -150,9 +145,7 @@ void CBodyGeneratorBase::GenStructureDestructor(std::ofstream& stream,
str += GetFinalizeString(i->GetID(), i->GetType());
}
return str;
- }
- )
- );
+ }));
}
void CBodyGeneratorBase::GenStructureSetter(std::ofstream& stream,
@@ -225,9 +218,7 @@ void CBodyGeneratorBase::GenStructureSetter(std::ofstream& stream,
str += NLine(1);
str += GetSetterString(i->GetID(), i->GetType());
return str;
- }
- )
- );
+ }));
}
}
@@ -283,9 +274,7 @@ void CBodyGeneratorBase::GenStructureGetter(std::ofstream& stream,
str += NLine(1);
str += GetGetterString(i->GetID(), i->GetType());
return str;
- }
- )
- );
+ }));
}
}
@@ -322,9 +311,7 @@ void CBodyGeneratorBase::GenStructureIterator(std::ofstream& stream,
str += NLine(1);
str += GetIteratorString(i->GetID(), i->GetType());
return str;
- }
- )
- );
+ }));
}
}
@@ -339,9 +326,7 @@ void CBodyGeneratorBase::GenStructureCloner(std::ofstream& stream,
str += GetClonerString(i->GetID(), i->GetType(), st);
}
return str;
- }
- )
- );
+ }));
}
std::string CBodyGeneratorBase::GetParcelTypeString(const BaseType& type,
@@ -389,8 +374,7 @@ std::string CBodyGeneratorBase::GetParcelWriteString(const std::string& id,
if (type.ToString() == "string")
return ReplaceAll(ternary_operation, "##", "h->" + id);
return "h->" + id;
- }
- );
+ });
if (type.ToString() == "list") {
str += GenTemplateString(CB_WRITE_LIST_BLOCK,
@@ -415,10 +399,8 @@ std::string CBodyGeneratorBase::GetParcelWriteString(const std::string& id,
if (type.GetMetaType()->ToString() == "string")
return ReplaceAll(ternary_operation, "##", "value");
return "*value";
- }
- );
- }
- );
+ });
+ });
} else if (type.ToString() == "array") {
str += GenTemplateString(CB_WRITE_ARRAY_BLOCK,
[&]()->std::string {
@@ -435,12 +417,11 @@ std::string CBodyGeneratorBase::GetParcelWriteString(const std::string& id,
type.GetMetaType()->ToString() == "array")
return "&h->" + id + "[i]->parcelable, h->" + id +"[i]";
if (type.GetMetaType()->ToString() == "string")
- return ReplaceAll(ternary_operation, "##", "h->" + id + "[i]");
+ return ReplaceAll(ternary_operation, "##", "h->" + id
+ + "[i]");
return "h->" + id + "[i]";
- }
- );
- }
- );
+ });
+ });
}
return str;
@@ -470,8 +451,7 @@ std::string CBodyGeneratorBase::GetParcelReadString(const std::string& id,
},
[&]()->std::string {
return "&len";
- }
- );
+ });
},
[&]()->std::string {
return GetParcelParamTypeString(*type.GetMetaType());
@@ -489,11 +469,11 @@ std::string CBodyGeneratorBase::GetParcelReadString(const std::string& id,
},
[&]()->std::string {
std::string ss;
- ss += "dlog_print(DLOG_ERROR, LOG_TAG, \"Failed to create handle\");" + NLine(1);
+ ss += "dlog_print(DLOG_ERROR, LOG_TAG," \
+ " \"Failed to create handle\");" + NLine(1);
ss += "return;";
return ss;
- }
- );
+ });
s += NLine(1);
s += GenTemplateString(parcel,
[&]()->std::string {
@@ -501,8 +481,7 @@ std::string CBodyGeneratorBase::GetParcelReadString(const std::string& id,
},
[&]()->std::string {
return "&value->parcelable, value";
- }
- );
+ });
} else if (type.GetMetaType()->ToString() == "string" ||
type.GetMetaType()->ToString() == "bundle") {
s += GenTemplateString(parcel,
@@ -511,8 +490,7 @@ std::string CBodyGeneratorBase::GetParcelReadString(const std::string& id,
},
[&]()->std::string {
return "&value";
- }
- );
+ });
} else {
s += "value = calloc(1, sizeof(*value));" + NLine(1);
s += GenTemplateString(CB_IF_STATEMENT_WITH_BRACES,
@@ -521,11 +499,11 @@ std::string CBodyGeneratorBase::GetParcelReadString(const std::string& id,
},
[&]()->std::string {
std::string ss;
- ss += "dlog_print(DLOG_ERROR, LOG_TAG, \"Out of memory\");" + NLine(1);
+ ss += "dlog_print(DLOG_ERROR, LOG_TAG," \
+ " \"Out of memory\");" + NLine(1);
ss += "return;";
return ss;
- }
- );
+ });
s += NLine(1);
s += GenTemplateString(parcel,
[&]()->std::string {
@@ -533,8 +511,7 @@ std::string CBodyGeneratorBase::GetParcelReadString(const std::string& id,
},
[&]()->std::string {
return "value";
- }
- );
+ });
}
return s;
@@ -544,8 +521,7 @@ std::string CBodyGeneratorBase::GetParcelReadString(const std::string& id,
},
[&]()->std::string {
return "h->" + id;
- }
- );
+ });
} else if (type.ToString() == "array") {
str += GenTemplateString(ReplaceAll(CB_READ_ARRAY_BLOCK, "##", id),
[&]()->std::string {
@@ -555,8 +531,7 @@ std::string CBodyGeneratorBase::GetParcelReadString(const std::string& id,
},
[&]()->std::string {
return "&h->" + id + "_size";
- }
- );
+ });
},
[&]()->std::string {
return GetReturnTypeString(*type.GetMetaType());
@@ -576,11 +551,11 @@ std::string CBodyGeneratorBase::GetParcelReadString(const std::string& id,
},
[&]()->std::string {
std::string ss;
- ss += "dlog_print(DLOG_ERROR, LOG_TAG, \"Failed to create handle\");" + NLine(1);
+ ss += "dlog_print(DLOG_ERROR, LOG_TAG," \
+ " \"Failed to create handle\");" + NLine(1);
ss += "return;";
return ss;
- }
- );
+ });
s += NLine(1);
s += GenTemplateString(parcel,
[&]()->std::string {
@@ -588,8 +563,7 @@ std::string CBodyGeneratorBase::GetParcelReadString(const std::string& id,
},
[&]()->std::string {
return "&value->parcelable, value";
- }
- );
+ });
} else {
s += GenTemplateString(parcel,
[&]()->std::string {
@@ -597,14 +571,12 @@ std::string CBodyGeneratorBase::GetParcelReadString(const std::string& id,
},
[&]()->std::string {
return "&value";
- }
- );
+ });
}
s += NLine(1);
s += GetSetterString("h->" + id + "[i]", "value");
return s;
- }
- );
+ });
} else {
str += GenTemplateString(parcel,
[&]()->std::string {
@@ -614,8 +586,7 @@ std::string CBodyGeneratorBase::GetParcelReadString(const std::string& id,
if (type.IsUserDefinedType())
return "&h->" + id + "h->" + id;
return "&h->" + id;
- }
- );
+ });
}
return str;
@@ -648,13 +619,11 @@ std::string CBodyGeneratorBase::GetFinalizeString(const std::string& id,
[&]()->std::string {
return GetDestructorString(*type.GetMetaType(),
"value", true) + NLine(1);
- }
- );
+ });
},
[&]()->std::string {
return "h->" + id;
- }
- );
+ });
} else if (type.ToString() == "array") {
if (!type.GetMetaType()->IsUserDefinedType() &&
type.GetMetaType()->ToString() != "list" &&
@@ -667,8 +636,7 @@ std::string CBodyGeneratorBase::GetFinalizeString(const std::string& id,
},
[&]()->std::string {
return "free(h->" + id + ");";
- }
- );
+ });
}
str += GenTemplateString(CB_FINALIZE_ARRAY_BLOCK,
[&]()->std::string {
@@ -682,13 +650,11 @@ std::string CBodyGeneratorBase::GetFinalizeString(const std::string& id,
[&]()->std::string {
return GetDestructorString(*type.GetMetaType(),
"h->" + id + "[i]", true) + NLine(1);
- }
- );
+ });
},
[&]()->std::string {
return "h->" + id;
- }
- );
+ });
} else {
str += GenTemplateString(CB_IF_STATEMENT,
[&]()->std::string {
@@ -696,8 +662,7 @@ std::string CBodyGeneratorBase::GetFinalizeString(const std::string& id,
},
[&]()->std::string {
return GetDestructorString(type, "h->" + id) + NLine(1);
- }
- );
+ });
}
return str;
@@ -720,8 +685,7 @@ std::string CBodyGeneratorBase::GetSetterString(const std::string& id,
s += GetDestructorString(type, "h->" + id) + NLine(1);
s += GetSetterString("h->" + id, "NULL");
return s;
- }
- );
+ });
str += NLine(1);
str += NLine(1);
@@ -732,11 +696,11 @@ std::string CBodyGeneratorBase::GetSetterString(const std::string& id,
},
[&]()->std::string {
std::string s;
- s += "dlog_print(DLOG_ERROR, LOG_TAG, \"Failed to duplicate data\");" + NLine(1);
+ s += "dlog_print(DLOG_ERROR, LOG_TAG," \
+ " \"Failed to duplicate data\");" + NLine(1);
s += "return -1;";
return s;
- }
- );
+ });
str += NLine(1);
} else if (type.ToString() == "list") {
if (type.GetMetaType()->IsUserDefinedType() ||
@@ -752,8 +716,7 @@ std::string CBodyGeneratorBase::GetSetterString(const std::string& id,
if (type.GetMetaType()->ToString() == "string")
return "g_list_append(h->" + id + ", strdup(" + id + "))";
return "g_list_append(h->" + id + ", " + id + ")";
- }
- );
+ });
} else {
str += GenTemplateString(CB_SETTER_LIST_BLOCK,
[&]()->std::string {
@@ -767,11 +730,11 @@ std::string CBodyGeneratorBase::GetSetterString(const std::string& id,
},
[&]()->std::string {
std::string s;
- s += "dlog_print(DLOG_ERROR, LOG_TAG, \"Out of memory\");" + NLine(1);
+ s += "dlog_print(DLOG_ERROR, LOG_TAG," \
+ " \"Out of memory\");" + NLine(1);
s += "return -1;";
return s;
- }
- );
+ });
s += NLine(1);
s += GetSetterString("*value", id);
return s;
@@ -781,8 +744,7 @@ std::string CBodyGeneratorBase::GetSetterString(const std::string& id,
},
[&]()->std::string {
return "h->" + id;
- }
- );
+ });
}
} else if (type.ToString() == "array") {
str += GetFinalizeString(id, type) + NLine(1);
@@ -792,8 +754,7 @@ std::string CBodyGeneratorBase::GetSetterString(const std::string& id,
[&]()->std::string {
return GetSetterString(*type.GetMetaType(),
"h->" + id + "[i]", id + "[i]");
- }
- );
+ });
} else {
str += GetSetterString(type, "h->" + id, id);
}
@@ -810,8 +771,7 @@ std::string CBodyGeneratorBase::GetGetterString(const std::string& id,
[&]()->std::string {
return GetSetterString(*type.GetMetaType(),
"(*" + id + ")[i]", "h->" + id + "[i]");
- }
- );
+ });
} else {
if (type.IsUserDefinedType() ||
type.ToString() == "string" ||
@@ -822,12 +782,11 @@ std::string CBodyGeneratorBase::GetGetterString(const std::string& id,
},
[&]()->std::string {
std::string s;
- s += "dlog_print(DLOG_ERROR, LOG_TAG, \"Invalid parameter: h->" + id +
- " is NULL\");" + NLine(1);
+ s += "dlog_print(DLOG_ERROR, LOG_TAG, \"Invalid parameter: h->"
+ + id + " is NULL\");" + NLine(1);
s += "return -1;";
return s;
- }
- );
+ });
str += NLine(1);
str += NLine(1);
}
@@ -847,11 +806,11 @@ std::string CBodyGeneratorBase::GetGetterString(const std::string& id,
},
[&]()->std::string {
std::string s;
- s += "dlog_print(DLOG_ERROR, LOG_TAG, \"Failed to duplicate " + id + "\");" + NLine(1);
+ s += "dlog_print(DLOG_ERROR, LOG_TAG, \"Failed to duplicate "
+ + id + "\");" + NLine(1);
s += "return -1;";
return s;
- }
- );
+ });
str += NLine(1);
}
}
@@ -878,8 +837,7 @@ std::string CBodyGeneratorBase::GetIteratorString(const std::string& id,
return "value";
return "*value";
- }
- );
+ });
return str;
}
@@ -905,17 +863,15 @@ std::string CBodyGeneratorBase::GetClonerString(const std::string& id,
},
[&]()->std::string {
std::string ss;
- ss += "dlog_print(DLOG_ERROR, LOG_TAG, \"Failed to duplicate h->" + id + "\");" +
- NLine(1);
- ss += "rpc_port_" + GetStructIdWithNamespace(st) + "_destroy(handle);" +
- NLine(1);
+ ss += "dlog_print(DLOG_ERROR, LOG_TAG," \
+ " \"Failed to duplicate h->" + id + "\");" + NLine(1);
+ ss += "rpc_port_" + GetStructIdWithNamespace(st)
+ + "_destroy(handle);" + NLine(1);
ss += "return -1;";
return ss;
- }
- );
+ });
return s;
- }
- );
+ });
str += NLine(1);
} else if (type.ToString() == "list") {
str += GenTemplateString(CB_CLONER_LIST_BLOCK,
@@ -946,14 +902,13 @@ std::string CBodyGeneratorBase::GetClonerString(const std::string& id,
},
[&]()->std::string {
std::string ss;
- ss += "dlog_print(DLOG_ERROR, LOG_TAG, \"Failed to duplicate value\");" +
- NLine(1);
- ss += "rpc_port_" + GetStructIdWithNamespace(st) + "_destroy(handle);" +
- NLine(1);
+ ss += "dlog_print(DLOG_ERROR, LOG_TAG," \
+ " \"Failed to duplicate value\");" + NLine(1);
+ ss += "rpc_port_" + GetStructIdWithNamespace(st)
+ + "_destroy(handle);" + NLine(1);
ss += "return -1;";
return ss;
- }
- );
+ });
} else {
s += "new_value = calloc(1, sizeof(*new_value));" + NLine(1);
s += GenTemplateString(CB_IF_STATEMENT_WITH_BRACES,
@@ -962,13 +917,13 @@ std::string CBodyGeneratorBase::GetClonerString(const std::string& id,
},
[&]()->std::string {
std::string tmp;
- tmp += "dlog_print(DLOG_ERROR, LOG_TAG, \"Out of memory\");" + NLine(1);
- tmp += "rpc_port_" + GetStructIdWithNamespace(st) + "_destroy(handle);" +
- NLine(1);
+ tmp += "dlog_print(DLOG_ERROR, LOG_TAG," \
+ " \"Out of memory\");" + NLine(1);
+ tmp += "rpc_port_" + GetStructIdWithNamespace(st)
+ + "_destroy(handle);" + NLine(1);
tmp += "return -1;";
return tmp;
- }
- );
+ });
s += NLine(1);
s += GetSetterString(*type.GetMetaType(),
"*new_value", "*value");
@@ -981,8 +936,7 @@ std::string CBodyGeneratorBase::GetClonerString(const std::string& id,
},
[&]()->std::string {
return "handle->" + id;
- }
- );
+ });
} else if (type.ToString() == "array") {
str += GenTemplateString(ReplaceAll(CB_CLONER_ARRAY_BLOCK, "##", id),
[&]()->std::string {
@@ -991,8 +945,7 @@ std::string CBodyGeneratorBase::GetClonerString(const std::string& id,
[&]()->std::string {
return GetSetterString(*type.GetMetaType(),
"handle->" + id + "[i]", "h->" + id + "[i]");
- }
- );
+ });
} else {
str += GetSetterString(type, "handle->" + id, "h->" + id);
}
@@ -1070,8 +1023,7 @@ void CBodyGeneratorBase::GenLogTag(std::ofstream& stream,
GenTemplate(CB_LOG_TAG, stream,
[&]()->std::string {
return log_tag;
- }
- );
+ });
}
void CBodyGeneratorBase::GenInterfaceEnumerations(std::ofstream& stream,
@@ -1116,13 +1068,10 @@ void CBodyGeneratorBase::GenInterfaceDelegateEnumeration(
},
[&]()->std::string {
return std::to_string(count++);
- }
- );
+ });
}
return str;
- }
- )
- );
+ }));
}
void CBodyGeneratorBase::GenInterfaceMethodEnumeration(
@@ -1148,13 +1097,10 @@ void CBodyGeneratorBase::GenInterfaceMethodEnumeration(
},
[&]()->std::string {
return i->GetID();
- }
- );
+ });
}
return str;
- }
- )
- );
+ }));
}
} // namespace tidl
diff --git a/idlc/c_gen/c_body_gen_base.h b/idlc/c_gen/c_body_gen_base.h
index 7b52e4a..3b8e77d 100644
--- a/idlc/c_gen/c_body_gen_base.h
+++ b/idlc/c_gen/c_body_gen_base.h
@@ -55,7 +55,8 @@ class CBodyGeneratorBase : public CGeneratorBase {
void GenStructure(std::ofstream& stream, const Structure& st);
void GenStructureDeclaration(std::ofstream& stream, const Structure& st);
void GenStructureParcelSerializer(std::ofstream& stream, const Structure& st);
- void GenStructureParcelDeserializer(std::ofstream& stream, const Structure& st);
+ void GenStructureParcelDeserializer(std::ofstream& stream,
+ const Structure& st);
void GenStructureConstructor(std::ofstream& stream, const Structure& st);
void GenStructureDestructor(std::ofstream& stream, const Structure& st);
void GenStructureSetter(std::ofstream& stream, const Structure& st);
@@ -77,6 +78,7 @@ class CBodyGeneratorBase : public CGeneratorBase {
const std::string& rvalue);
std::string GetSetterString(const std::string& lvalue,
const std::string& rvalue);
+
private:
std::map<std::string, std::string> parcel_type_map_;
};
diff --git a/idlc/c_gen/c_body_gen_base_cb.h b/idlc/c_gen/c_body_gen_base_cb.h
index 94b374c..d03cec1 100644
--- a/idlc/c_gen/c_body_gen_base_cb.h
+++ b/idlc/c_gen/c_body_gen_base_cb.h
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+#ifndef IDLC_C_GEN_C_BODY_GEN_BASE_CB_H_
+#define IDLC_C_GEN_C_BODY_GEN_BASE_CB_H_
+
const char CB_STRUCT_DECL[] =
R"__c_cb(
$$struct $$_s {
@@ -392,3 +395,5 @@ R"__c_cb(
#define LOG_TAG "$$"
)__c_cb";
+
+#endif // IDLC_C_GEN_C_BODY_GEN_BASE_CB_H_
diff --git a/idlc/c_gen/c_gen_base.cc b/idlc/c_gen/c_gen_base.cc
index 5468f04..69b6229 100644
--- a/idlc/c_gen/c_gen_base.cc
+++ b/idlc/c_gen/c_gen_base.cc
@@ -34,7 +34,7 @@ CGeneratorBase::CGeneratorBase(std::shared_ptr<Document> doc)
type_map_ = {
{"char", "char "}, {"int", "int "}, {"short", "short "},
{"long", "long long "}, {"bool", "bool "}, {"string", "char *"},
- {"list", "GList *"}, {"float","float "}, {"double", "double "},
+ {"list", "GList *"}, {"float", "float "}, {"double", "double "},
{"bundle", "bundle *"}, {"void", "void "}
};
}
@@ -69,11 +69,11 @@ std::string CGeneratorBase::ConvertTypeToString(
}
if (type.ToString() == "array") {
- if (direction == ParameterType::Direction::IN) {
- return GetReturnTypeString(*type.GetMetaType()) + "*";
- } else {
- return GetReturnTypeString(*type.GetMetaType()) + "**";
- }
+ if (direction == ParameterType::Direction::IN) {
+ return GetReturnTypeString(*type.GetMetaType()) + "*";
+ } else {
+ return GetReturnTypeString(*type.GetMetaType()) + "**";
+ }
}
if (type.ToString() == "string") {
@@ -240,8 +240,7 @@ std::string CGeneratorBase::SmartIndent(std::string lines) {
return result;
}
-std::string CGeneratorBase::Trim(const std::string& str)
-{
+std::string CGeneratorBase::Trim(const std::string& str) {
std::size_t first = str.find_first_not_of(" \t\r\n");
if (first == std::string::npos)
return str;
@@ -259,8 +258,7 @@ void CGeneratorBase::GenLicenseDescription(std::ofstream& stream) {
std::time_t t = std::time(NULL);
std::tm* local_time = std::localtime(&t);
return std::to_string(local_time->tm_year + 1900);
- }
- );
+ });
}
void CGeneratorBase::GenIncludeDefaultHeaders(std::ofstream& stream,
@@ -315,8 +313,7 @@ std::string CGeneratorBase::GetParamTypeString(
return type_map_[type.ToString()] + "*";
}
-std::string CGeneratorBase::GetErrorValue(const BaseType& type)
-{
+std::string CGeneratorBase::GetErrorValue(const BaseType& type) {
if (type.IsUserDefinedType() ||
type.ToString() == "list" ||
type.ToString() == "array" ||
diff --git a/idlc/c_gen/c_gen_base_cb.h b/idlc/c_gen/c_gen_base_cb.h
index 84f2081..dd51c2a 100644
--- a/idlc/c_gen/c_gen_base_cb.h
+++ b/idlc/c_gen/c_gen_base_cb.h
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+#ifndef IDLC_C_GEN_C_GEN_BASE_CB_H_
+#define IDLC_C_GEN_C_GEN_BASE_CB_H_
+
const char CB_COPYRIGHT[] =
R"__c_cb(/*
* Generated by tidlc $$.
@@ -50,3 +53,5 @@ R"__c_cb(
#include <rpc-port.h>
#include <rpc-port-parcel.h>
)__c_cb";
+
+#endif // IDLC_C_GEN_C_GEN_BASE_CB_H_
diff --git a/idlc/c_gen/c_header_gen_base.cc b/idlc/c_gen/c_header_gen_base.cc
index 8770870..8848fe4 100644
--- a/idlc/c_gen/c_header_gen_base.cc
+++ b/idlc/c_gen/c_header_gen_base.cc
@@ -88,8 +88,7 @@ void CHeaderGeneratorBase::GenStructureDeclaration(std::ofstream& stream,
},
[&]()->std::string {
return GetStructIdWithNamespace(st);
- }
- );
+ });
}
void CHeaderGeneratorBase::GenStructureConstructor(std::ofstream& stream,
@@ -100,8 +99,7 @@ void CHeaderGeneratorBase::GenStructureConstructor(std::ofstream& stream,
},
[&]()->std::string {
return GetStructIdWithNamespace(st);
- }
- );
+ });
}
void CHeaderGeneratorBase::GenStructureDestructor(std::ofstream& stream,
@@ -112,8 +110,7 @@ void CHeaderGeneratorBase::GenStructureDestructor(std::ofstream& stream,
},
[&]()->std::string {
return GetStructIdWithNamespace(st);
- }
- );
+ });
}
void CHeaderGeneratorBase::GenStructureSetter(std::ofstream& stream,
@@ -165,8 +162,7 @@ void CHeaderGeneratorBase::GenStructureSetter(std::ofstream& stream,
return str;
}
return i->GetID();
- }
- );
+ });
}
}
@@ -205,8 +201,7 @@ void CHeaderGeneratorBase::GenStructureGetter(std::ofstream& stream,
return str;
}
return i->GetID();
- }
- );
+ });
}
}
@@ -237,8 +232,7 @@ void CHeaderGeneratorBase::GenStructureIterator(std::ofstream& stream,
},
[&]()->std::string {
return i->GetID();
- }
- );
+ });
}
}
@@ -253,8 +247,7 @@ void CHeaderGeneratorBase::GenStructureCloner(std::ofstream& stream,
},
[&]()->std::string {
return GetStructIdWithNamespace(st);
- }
- );
+ });
}
} // namespace tidl
diff --git a/idlc/c_gen/c_header_gen_base_cb.h b/idlc/c_gen/c_header_gen_base_cb.h
index b18fe19..d8e8e37 100644
--- a/idlc/c_gen/c_header_gen_base_cb.h
+++ b/idlc/c_gen/c_header_gen_base_cb.h
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+#ifndef IDLC_C_GEN_C_HEADER_GEN_BASE_CB_H_
+#define IDLC_C_GEN_C_HEADER_GEN_BASE_CB_H_
+
const char CB_EXPLICIT_LINKAGE_OPEN[] =
R"__c_cb(
#ifdef __cplusplus
@@ -63,3 +66,5 @@ const char CB_STRUCT_CLONER[] =
R"__c_cb(
int rpc_port_$$_clone(rpc_port_$$_h h, rpc_port_$$_h *clone);
)__c_cb";
+
+#endif // IDLC_C_GEN_C_HEADER_GEN_BASE_CB_H_
diff --git a/idlc/c_gen/c_proxy_body_gen.cc b/idlc/c_gen/c_proxy_body_gen.cc
index 969405f..9a42a33 100644
--- a/idlc/c_gen/c_proxy_body_gen.cc
+++ b/idlc/c_gen/c_proxy_body_gen.cc
@@ -41,7 +41,8 @@ void CProxyBodyGen::OnFiniGen(std::ofstream& stream) {
void CProxyBodyGen::GenTypedefProxyDelegate(std::ofstream& stream) {
const char format[] =
- "typedef void (*proxy_delegate)(GList **list, rpc_port_parcel_h parcel, int seq_id, int id);\n";
+ "typedef void (*proxy_delegate)(GList **list, rpc_port_parcel_h parcel," \
+ " int seq_id, int id);\n";
stream << NLine(1);
stream << std::string(format);
}
@@ -76,7 +77,8 @@ void CProxyBodyGen::GenInterface(std::ofstream& stream, const Interface& inf) {
void CProxyBodyGen::GenInterfaceDeclaration(std::ofstream& stream,
const Interface& inf) {
- stream << SmartIndent(ReplaceAll(CB_INTERFACE_STRUCT, "##", GetInterfaceIdWithNamespace(inf)));
+ stream << SmartIndent(ReplaceAll(CB_INTERFACE_STRUCT, "##",
+ GetInterfaceIdWithNamespace(inf)));
}
void CProxyBodyGen::GenInterfaceDelegators(std::ofstream& stream,
@@ -126,9 +128,7 @@ void CProxyBodyGen::GenInterfaceDelegatorConstructor(
},
[&]()->std::string {
return decl.GetID();
- }
- )
- );
+ }));
}
void CProxyBodyGen::GenInterfaceDelegatorDisposer(
@@ -162,7 +162,7 @@ void CProxyBodyGen::GenInterfaceDelegatorInvoker(
}
if (cnt > 0)
str += NLine(1);
- for (auto& i: decl.GetParameters().GetParams()) {
+ for (auto& i : decl.GetParameters().GetParams()) {
if (i->GetParameterType().GetBaseType().IsUserDefinedType() ||
i->GetParameterType().GetBaseType().ToString() == "list" ||
i->GetParameterType().GetBaseType().ToString() == "array") {
@@ -176,19 +176,19 @@ void CProxyBodyGen::GenInterfaceDelegatorInvoker(
},
[&]()->std::string {
if (i->GetParameterType().GetBaseType().IsUserDefinedType() ||
- i->GetParameterType().GetBaseType().ToString() == "list" ||
+ i->GetParameterType().GetBaseType()
+ .ToString() == "list" ||
i->GetParameterType().GetBaseType().ToString() == "array")
return "&" + i->GetID() + "->parcelable, " + i->GetID();
return "&" + i->GetID();
- }
- );
+ });
}
return str;
},
[&]()->std::string {
std::string str;
str += "handle->callback(handle->user_data";
- for (auto& i: decl.GetParameters().GetParams()) {
+ for (auto& i : decl.GetParameters().GetParams()) {
str += ", ";
str += i->GetID();
}
@@ -197,14 +197,12 @@ void CProxyBodyGen::GenInterfaceDelegatorInvoker(
},
[&]()->std::string {
std::string str;
- for (auto& i: decl.GetParameters().GetParams()) {
+ for (auto& i : decl.GetParameters().GetParams()) {
str += GetDestructorString(i->GetParameterType().GetBaseType(),
i->GetID());
}
return str;
- }
- )
- );
+ }));
}
void CProxyBodyGen::GenInterfaceDelegatorTable(std::ofstream& stream,
@@ -225,9 +223,9 @@ void CProxyBodyGen::GenInterfaceDelegatorTable(std::ofstream& stream,
return GetInterfaceIdWithNamespace(inf) + "_DELEGATE_" + i->GetID();
},
[&]()->std::string {
- return "__" + GetInterfaceIdWithNamespace(inf) + "_delegate_" + i->GetID();
- }
- );
+ return "__" + GetInterfaceIdWithNamespace(inf) + "_delegate_"
+ + i->GetID();
+ });
cnt++;
}
@@ -241,9 +239,7 @@ void CProxyBodyGen::GenInterfaceDelegatorTable(std::ofstream& stream,
},
[&]()->std::string {
return str;
- }
- )
- );
+ }));
}
void CProxyBodyGen::GenInterfaceDelegatorHandler(std::ofstream& stream,
@@ -258,39 +254,44 @@ void CProxyBodyGen::GenInterfaceDelegatorHandler(std::ofstream& stream,
}
stream << SmartIndent(GenTemplateString(
- ReplaceAll(CB_PROCESS_RECEIVED_EVENT, "##", GetInterfaceIdWithNamespace(inf)),
- [&]()->std::string {
- if (cnt == 0)
- return str;
- return ReplaceAll(CB_PROCESS_RECEIVED_EVENT_IMPL, "##", GetInterfaceIdWithNamespace(inf));
- }
- )
- );
+ ReplaceAll(CB_PROCESS_RECEIVED_EVENT, "##",
+ GetInterfaceIdWithNamespace(inf)),
+ [&]()->std::string {
+ if (cnt == 0)
+ return str;
+ return ReplaceAll(CB_PROCESS_RECEIVED_EVENT_IMPL, "##",
+ GetInterfaceIdWithNamespace(inf));
+ }));
}
void CProxyBodyGen::GenInterfaceConsumeCommand(std::ofstream& stream,
const Interface& inf) {
- stream << SmartIndent(ReplaceAll(CB_CONSUME_COMMAND, "##", GetInterfaceIdWithNamespace(inf)));
+ stream << SmartIndent(ReplaceAll(CB_CONSUME_COMMAND, "##",
+ GetInterfaceIdWithNamespace(inf)));
}
void CProxyBodyGen::GenInterfaceOnConnectedEventCB(std::ofstream& stream,
const Interface& inf) {
- stream << SmartIndent(ReplaceAll(CB_ON_CONNECTED, "##", GetInterfaceIdWithNamespace(inf)));
+ stream << SmartIndent(ReplaceAll(CB_ON_CONNECTED, "##",
+ GetInterfaceIdWithNamespace(inf)));
}
void CProxyBodyGen::GenInterfaceOnDisconnectedEventCB(std::ofstream& stream,
const Interface& inf) {
- stream << SmartIndent(ReplaceAll(CB_ON_DISCONNECTED, "##", GetInterfaceIdWithNamespace(inf)));
+ stream << SmartIndent(ReplaceAll(CB_ON_DISCONNECTED, "##",
+ GetInterfaceIdWithNamespace(inf)));
}
void CProxyBodyGen::GenInterfaceOnRejectedEventCB(std::ofstream& stream,
const Interface& inf) {
- stream << SmartIndent(ReplaceAll(CB_ON_REJECTED, "##", GetInterfaceIdWithNamespace(inf)));
+ stream << SmartIndent(ReplaceAll(CB_ON_REJECTED, "##",
+ GetInterfaceIdWithNamespace(inf)));
}
void CProxyBodyGen::GenInterfaceOnReceivedEventCB(std::ofstream& stream,
const Interface& inf) {
- stream << SmartIndent(ReplaceAll(CB_ON_RECEIVED, "##", GetInterfaceIdWithNamespace(inf)));
+ stream << SmartIndent(ReplaceAll(CB_ON_RECEIVED, "##",
+ GetInterfaceIdWithNamespace(inf)));
}
void CProxyBodyGen::GenInterfaceMethods(std::ofstream& stream,
@@ -299,7 +300,8 @@ void CProxyBodyGen::GenInterfaceMethods(std::ofstream& stream,
if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
stream << SmartIndent(GenTemplateString(
- ReplaceAll(CB_INTERFACE_METHODS, "##", GetInterfaceIdWithNamespace(inf)),
+ ReplaceAll(CB_INTERFACE_METHODS, "##",
+ GetInterfaceIdWithNamespace(inf)),
[&]()->std::string {
return GetReturnTypeString(i->GetType());
},
@@ -330,7 +332,8 @@ void CProxyBodyGen::GenInterfaceMethods(std::ofstream& stream,
[&]()->std::string {
std::string str;
for (auto& p : i->GetParameters().GetParams()) {
- if (p->GetParameterType().GetDirection() == ParameterType::Direction::OUT ||
+ if (p->GetParameterType().GetDirection() ==
+ ParameterType::Direction::OUT ||
p->GetParameterType().GetBaseType().IsUserDefinedType() ||
p->GetParameterType().GetBaseType().ToString() == "list" ||
p->GetParameterType().GetBaseType().ToString() == "array" ||
@@ -357,30 +360,32 @@ void CProxyBodyGen::GenInterfaceMethods(std::ofstream& stream,
},
[&]()->std::string {
return GetMethodReadString(inf, *i);
- }
- )
- );
+ }));
}
}
void CProxyBodyGen::GenInterfaceConstructor(std::ofstream& stream,
const Interface& inf) {
- stream << SmartIndent(ReplaceAll(CB_INTERFACE_CTOR, "##", GetInterfaceIdWithNamespace(inf)));
+ stream << SmartIndent(ReplaceAll(CB_INTERFACE_CTOR, "##",
+ GetInterfaceIdWithNamespace(inf)));
}
void CProxyBodyGen::GenInterfaceDestructor(std::ofstream& stream,
const Interface& inf) {
- stream << SmartIndent(ReplaceAll(CB_INTERFACE_DTOR, "##", GetInterfaceIdWithNamespace(inf)));
+ stream << SmartIndent(ReplaceAll(CB_INTERFACE_DTOR, "##",
+ GetInterfaceIdWithNamespace(inf)));
}
void CProxyBodyGen::GenInterfaceConnect(std::ofstream& stream,
const Interface& inf) {
- stream << SmartIndent(ReplaceAll(CB_INTERFACE_CONNECT, "##", GetInterfaceIdWithNamespace(inf)));
+ stream << SmartIndent(ReplaceAll(CB_INTERFACE_CONNECT, "##",
+ GetInterfaceIdWithNamespace(inf)));
}
void CProxyBodyGen::GenInterfaceDisconnect(std::ofstream& stream,
const Interface& inf) {
- stream << SmartIndent(ReplaceAll(CB_INTERFACE_DISCONNECT, "##", GetInterfaceIdWithNamespace(inf)));
+ stream << SmartIndent(ReplaceAll(CB_INTERFACE_DISCONNECT, "##",
+ GetInterfaceIdWithNamespace(inf)));
}
std::string CProxyBodyGen::GetMethodWriteString(const Interface& inf,
@@ -393,11 +398,11 @@ std::string CProxyBodyGen::GetMethodWriteString(const Interface& inf,
continue;
if (IsDelegateType(inf, p->GetParameterType().GetBaseType())) {
str += GenTemplateString(ReplaceAll(CB_DELEGATE_BLOCK, "##",
- GetInterfaceIdWithNamespace(inf) + "_" + p->GetParameterType().GetBaseType().ToString()),
+ GetInterfaceIdWithNamespace(inf) + "_" + p->GetParameterType()
+ .GetBaseType().ToString()),
[&]()->std::string {
return p->GetID();
- }
- );
+ });
} else {
str += GenTemplateString(setter,
[&]()->std::string {
@@ -413,7 +418,8 @@ std::string CProxyBodyGen::GetMethodWriteString(const Interface& inf,
p->GetParameterType().GetBaseType().ToString() == "array") {
if (p->GetParameterType().GetDirection()
== ParameterType::Direction::REF)
- return "&(*" + p->GetID() + ")->parcelable, " + "*" + p->GetID();
+ return "&(*" + p->GetID() + ")->parcelable, " + "*"
+ + p->GetID();
else
return "&" + p->GetID() + "->parcelable, " + p->GetID();
} else if (p->GetParameterType().GetDirection()
@@ -421,12 +427,12 @@ std::string CProxyBodyGen::GetMethodWriteString(const Interface& inf,
if (p->GetParameterType().GetBaseType().ToString() == "string")
return ReplaceAll(ternary_operation, "##", "*" + p->GetID());
return "*" + p->GetID();
- } else if (p->GetParameterType().GetBaseType().ToString() == "string") {
+ } else if (p->GetParameterType().GetBaseType().ToString() ==
+ "string") {
return ReplaceAll(ternary_operation, "##", p->GetID());
}
return p->GetID();
- }
- );
+ });
}
}
return str;
@@ -442,7 +448,8 @@ std::string CProxyBodyGen::GetMethodReadString(const Interface& inf,
[&]()->std::string {
std::string s;
for (auto& p : decl.GetParameters().GetParams()) {
- if (p->GetParameterType().GetDirection() != ParameterType::Direction::OUT)
+ if (p->GetParameterType().GetDirection() !=
+ ParameterType::Direction::OUT)
continue;
s += GetReturnTypeString(p->GetParameterType().GetBaseType()) +
"out_" + p->GetID() + ";" + NLine(1);
@@ -455,7 +462,8 @@ std::string CProxyBodyGen::GetMethodReadString(const Interface& inf,
[&]()->std::string {
std::string s;
for (auto& p : decl.GetParameters().GetParams()) {
- if (p->GetParameterType().GetDirection() != ParameterType::Direction::OUT)
+ if (p->GetParameterType().GetDirection() !=
+ ParameterType::Direction::OUT)
continue;
if (p->GetParameterType().GetBaseType().IsUserDefinedType() ||
p->GetParameterType().GetBaseType().ToString() == "list" ||
@@ -472,13 +480,15 @@ std::string CProxyBodyGen::GetMethodReadString(const Interface& inf,
return "parcel_received";
},
[&]()->std::string {
- if (p->GetParameterType().GetBaseType().IsUserDefinedType() ||
- p->GetParameterType().GetBaseType().ToString() == "list" ||
- p->GetParameterType().GetBaseType().ToString() == "array")
- return "&out_" + p->GetID() + "->parcelable, out_" + p->GetID();
+ auto& t = p->GetParameterType().GetBaseType();
+ if (t.IsUserDefinedType() || t.ToString() == "list" ||
+ t.ToString() == "array") {
+ return "&out_" + p->GetID() + "->parcelable, out_"
+ + p->GetID();
+ }
+
return "&out_" + p->GetID();
- }
- );
+ });
s += "*" + p->GetID() + " = out_" + p->GetID() + ";" + NLine(1);
}
if (GetReturnTypeString(decl.GetType()) != "void ") {
@@ -500,12 +510,10 @@ std::string CProxyBodyGen::GetMethodReadString(const Interface& inf,
decl.GetType().ToString() == "array")
return "&ret->parcelable, ret";
return "&ret";
- }
- );
+ });
}
return s;
- }
- );
+ });
if (GetReturnTypeString(decl.GetType()) != "void ") {
str += NLine(1);
str += "return ret;";
diff --git a/idlc/c_gen/c_proxy_body_gen_cb.h b/idlc/c_gen/c_proxy_body_gen_cb.h
index 2474451..94c43e3 100644
--- a/idlc/c_gen/c_proxy_body_gen_cb.h
+++ b/idlc/c_gen/c_proxy_body_gen_cb.h
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+#ifndef IDLC_C_GEN_C_PROXY_BODY_GEN_CB_H_
+#define IDLC_C_GEN_C_PROXY_BODY_GEN_CB_H_
+
const char CB_INTERFACE_STRUCT[] =
R"__c_cb(
struct ##_s {
@@ -449,3 +452,5 @@ $$
} while (0);
g_rec_mutex_unlock(&h->mutex);
)__c_cb";
+
+#endif // IDLC_C_GEN_C_PROXY_BODY_GEN_CB_H_
diff --git a/idlc/c_gen/c_proxy_header_gen.cc b/idlc/c_gen/c_proxy_header_gen.cc
index c3edae1..abedb2f 100644
--- a/idlc/c_gen/c_proxy_header_gen.cc
+++ b/idlc/c_gen/c_proxy_header_gen.cc
@@ -97,8 +97,7 @@ void CProxyHeaderGen::GenInterfaceDelegator(std::ofstream& stream,
p->GetParameterType().GetBaseType()) + p->GetID();
}
return str;
- }
- );
+ });
stream << ReplaceAll(CB_DELEGATE_CTOR, "##", id + "_" + decl.GetID());
stream << GenTemplateString(
@@ -110,7 +109,8 @@ void CProxyHeaderGen::GenInterfaceDelegator(std::ofstream& stream,
void CProxyHeaderGen::GenInterfaceDeclaration(std::ofstream& stream,
const Interface& inf) {
- stream << SmartIndent(ReplaceAll(CB_INTERFACE_DECL, "##", GetInterfaceIdWithNamespace(inf)));
+ stream << SmartIndent(ReplaceAll(CB_INTERFACE_DECL, "##",
+ GetInterfaceIdWithNamespace(inf)));
}
void CProxyHeaderGen::GenInterfaceMethods(std::ofstream& stream,
@@ -119,7 +119,8 @@ void CProxyHeaderGen::GenInterfaceMethods(std::ofstream& stream,
if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
stream << GenTemplateString(
- ReplaceAll(CB_INTERFACE_METHODS, "##", GetInterfaceIdWithNamespace(inf)),
+ ReplaceAll(CB_INTERFACE_METHODS, "##",
+ GetInterfaceIdWithNamespace(inf)),
[&]()->std::string {
return GetReturnTypeString(i->GetType());
},
@@ -140,19 +141,20 @@ void CProxyHeaderGen::GenInterfaceMethods(std::ofstream& stream,
}
}
return str;
- }
- );
+ });
}
}
void CProxyHeaderGen::GenInterfaceConnect(std::ofstream& stream,
const Interface& inf) {
- stream << ReplaceAll(CB_INTERFACE_CONNECT, "##", GetInterfaceIdWithNamespace(inf));
+ stream << ReplaceAll(CB_INTERFACE_CONNECT, "##",
+ GetInterfaceIdWithNamespace(inf));
}
void CProxyHeaderGen::GenInterfaceDisconnect(std::ofstream& stream,
const Interface& inf) {
- stream << ReplaceAll(CB_INTERFACE_DISCONNECT, "##", GetInterfaceIdWithNamespace(inf));
+ stream << ReplaceAll(CB_INTERFACE_DISCONNECT, "##",
+ GetInterfaceIdWithNamespace(inf));
}
} // namespace tidl
diff --git a/idlc/c_gen/c_proxy_header_gen_cb.h b/idlc/c_gen/c_proxy_header_gen_cb.h
index b743b7f..631b808 100644
--- a/idlc/c_gen/c_proxy_header_gen_cb.h
+++ b/idlc/c_gen/c_proxy_header_gen_cb.h
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+#ifndef IDLC_C_GEN_C_PROXY_HEADER_GEN_CB_H_
+#define IDLC_C_GEN_C_PROXY_HEADER_GEN_CB_H_
+
const char CB_INTERFACE_DECL[] =
R"__c_cb(
typedef struct ##_s *rpc_port_proxy_##_h;
@@ -56,3 +59,5 @@ const char CB_DELEGATE_DISPOSER[] =
R"__c_cb(
int rpc_port_proxy_##_dispose(rpc_port_proxy_$$_h proxy, rpc_port_##_h delegate);
)__c_cb";
+
+#endif // IDLC_C_GEN_C_PROXY_HEADER_GEN_CB_H_
diff --git a/idlc/c_gen/c_stub_body_gen.cc b/idlc/c_gen/c_stub_body_gen.cc
index 79c30a2..d18b4db 100644
--- a/idlc/c_gen/c_stub_body_gen.cc
+++ b/idlc/c_gen/c_stub_body_gen.cc
@@ -81,9 +81,7 @@ void CStubBodyGen::GenInterfaceMethods(std::ofstream& stream,
},
[&]()->std::string {
return GetMethodString(inf, *i);
- }
- )
- );
+ }));
}
}
@@ -100,9 +98,9 @@ void CStubBodyGen::GenInterfaceMethodTable(std::ofstream& stream,
return GetInterfaceIdWithNamespace(inf) + "_METHOD_" + i->GetID();
},
[&]()->std::string {
- return "__" + GetInterfaceIdWithNamespace(inf) + "_method_" + i->GetID();
- }
- );
+ return "__" + GetInterfaceIdWithNamespace(inf) + "_method_"
+ + i->GetID();
+ });
cnt++;
}
@@ -116,42 +114,46 @@ void CStubBodyGen::GenInterfaceMethodTable(std::ofstream& stream,
},
[&]()->std::string {
return str;
- }
- )
- );
+ }));
}
void CStubBodyGen::GenInterfaceOnConnectedEventCB(std::ofstream& stream,
const Interface& inf) {
stream << SmartIndent(
- ReplaceAll(CB_INTERFACE_ON_CONNECTED, "##", GetInterfaceIdWithNamespace(inf)));
+ ReplaceAll(CB_INTERFACE_ON_CONNECTED, "##",
+ GetInterfaceIdWithNamespace(inf)));
}
void CStubBodyGen::GenInterfaceOnDisconnectedEventCB(std::ofstream& stream,
const Interface& inf) {
stream << SmartIndent(
- ReplaceAll(CB_INTERFACE_ON_DISCONNECTED, "##", GetInterfaceIdWithNamespace(inf)));
+ ReplaceAll(CB_INTERFACE_ON_DISCONNECTED, "##",
+ GetInterfaceIdWithNamespace(inf)));
}
void CStubBodyGen::GenInterfaceOnReceivedEventCB(std::ofstream& stream,
const Interface& inf) {
stream << SmartIndent(
- ReplaceAll(CB_INTERFACE_ON_RECEIVED, "##", GetInterfaceIdWithNamespace(inf)));
+ ReplaceAll(CB_INTERFACE_ON_RECEIVED, "##",
+ GetInterfaceIdWithNamespace(inf)));
}
void CStubBodyGen::GenInterfaceRegister(std::ofstream& stream,
const Interface& inf) {
- stream << SmartIndent(ReplaceAll(CB_INTERFACE_REGISTER, "##", GetInterfaceIdWithNamespace(inf)));
+ stream << SmartIndent(ReplaceAll(CB_INTERFACE_REGISTER, "##",
+ GetInterfaceIdWithNamespace(inf)));
}
void CStubBodyGen::GenInterfaceUnregister(std::ofstream& stream,
const Interface& inf) {
- stream << SmartIndent(ReplaceAll(CB_INTERFACE_UNREGISTER, "##", GetInterfaceIdWithNamespace(inf)));
+ stream << SmartIndent(ReplaceAll(CB_INTERFACE_UNREGISTER, "##",
+ GetInterfaceIdWithNamespace(inf)));
}
void CStubBodyGen::GenInterfaceGlobalVariables(std::ofstream& stream,
const Interface& inf) {
- stream << SmartIndent(ReplaceAll(CB_GLOBALS, "##", GetInterfaceIdWithNamespace(inf)));
+ stream << SmartIndent(ReplaceAll(CB_GLOBALS, "##",
+ GetInterfaceIdWithNamespace(inf)));
}
std::string CStubBodyGen::GetMethodString(const Interface& inf,
@@ -185,7 +187,7 @@ std::string CStubBodyGen::GetMethodString(const Interface& inf,
}
str += NLine(1);
- for (auto& i: decl.GetParameters().GetParams()) {
+ for (auto& i : decl.GetParameters().GetParams()) {
if (i->GetParameterType().GetDirection() != ParameterType::Direction::IN)
continue;
@@ -203,8 +205,7 @@ std::string CStubBodyGen::GetMethodString(const Interface& inf,
},
[&]()->std::string {
return i->GetID();
- }
- );
+ });
} else {
str += GetConstructorString(i->GetParameterType().GetBaseType(),
i->GetID());
@@ -225,8 +226,7 @@ std::string CStubBodyGen::GetMethodString(const Interface& inf,
i->GetParameterType().GetBaseType().ToString() == "array")
return "&" + i->GetID() + "->parcelable, " + i->GetID();
return "&" + i->GetID();
- }
- );
+ });
}
if (cnt > 0)
@@ -238,7 +238,7 @@ std::string CStubBodyGen::GetMethodString(const Interface& inf,
}
str += "context->callback." + decl.GetID() + "(context";
- for (auto& i: decl.GetParameters().GetParams()) {
+ for (auto& i : decl.GetParameters().GetParams()) {
str += ", ";
if (i->GetParameterType().GetDirection() != ParameterType::Direction::IN)
str += "&" + i->GetID();
@@ -253,8 +253,9 @@ std::string CStubBodyGen::GetMethodString(const Interface& inf,
},
[&]()->std::string {
std::string s;
- for (auto& i: decl.GetParameters().GetParams()) {
- if (i->GetParameterType().GetDirection() == ParameterType::Direction::IN)
+ for (auto& i : decl.GetParameters().GetParams()) {
+ if (i->GetParameterType().GetDirection() ==
+ ParameterType::Direction::IN)
continue;
s += GenTemplateString(setter,
[&]()->std::string {
@@ -265,15 +266,14 @@ std::string CStubBodyGen::GetMethodString(const Interface& inf,
return "result";
},
[&]()->std::string {
- if (i->GetParameterType().GetBaseType().IsUserDefinedType() ||
- i->GetParameterType().GetBaseType().ToString() == "list" ||
- i->GetParameterType().GetBaseType().ToString() == "array")
+ auto& t = i->GetParameterType().GetBaseType();
+ if (t.IsUserDefinedType() || t.ToString() == "list" ||
+ t.ToString() == "array")
return "&" + i->GetID() + "->parcelable, " + i->GetID();
- else if (i->GetParameterType().GetBaseType().ToString() == "string")
+ else if (t.ToString() == "string")
return ReplaceAll(ternary_operation, "##", i->GetID());
return i->GetID();
- }
- );
+ });
}
if (decl.GetType().ToString() != "void") {
s += GenTemplateString(setter,
@@ -291,15 +291,13 @@ std::string CStubBodyGen::GetMethodString(const Interface& inf,
else if (decl.GetType().ToString() == "string")
return ReplaceAll(ternary_operation, "##", "ret");
return "ret";
- }
- );
+ });
}
return s;
- }
- );
+ });
}
- for (auto& i: decl.GetParameters().GetParams()) {
+ for (auto& i : decl.GetParameters().GetParams()) {
str += NLine(1);
if (IsDelegateType(inf, i->GetParameterType().GetBaseType())) {
str += "rpc_port_" + GetInterfaceIdWithNamespace(inf) + "_" +
@@ -327,8 +325,7 @@ std::string CStubBodyGen::GetAddPrivilegeString(const std::string& id,
},
[&]()->std::string {
return attr.GetValue();
- }
- );
+ });
return str;
}
@@ -343,8 +340,7 @@ std::string CStubBodyGen::GetTrustedModeString(const std::string& id,
},
[&]()->std::string {
return attr.GetValue();
- }
- );
+ });
return str;
}
@@ -376,9 +372,7 @@ void CStubBodyGen::GenInterfaceDelegatorDeclaration(std::ofstream& stream,
stream << SmartIndent(GenTemplateString(CB_INTERFACE_DELEGATOR_DECL,
[&]()->std::string {
return id + "_" + decl.GetID();
- }
- )
- );
+ }));
}
void CStubBodyGen::GenInterfaceDelegatorConstructor(std::ofstream& stream,
@@ -391,9 +385,7 @@ void CStubBodyGen::GenInterfaceDelegatorConstructor(std::ofstream& stream,
},
[&]()->std::string {
return decl.GetID();
- }
- )
- );
+ }));
}
void CStubBodyGen::GenInterfaceDelegatorDestructor(std::ofstream& stream,
@@ -458,20 +450,17 @@ void CStubBodyGen::GenInterfaceDelegatorInvoker(std::ofstream& stream,
i->GetParameterType().GetBaseType(), true);
},
[&]()->std::string {
- if (i->GetParameterType().GetBaseType().IsUserDefinedType() ||
- i->GetParameterType().GetBaseType().ToString() == "list" ||
- i->GetParameterType().GetBaseType().ToString() == "array")
+ auto& t = i->GetParameterType().GetBaseType();
+ if (t.IsUserDefinedType() || t.ToString() == "list" ||
+ t.ToString() == "array")
return "&" + i->GetID() + "->parcelable, " + i->GetID();
- else if (i->GetParameterType().GetBaseType().ToString() == "string")
+ else if (t.ToString() == "string")
return ReplaceAll(ternary_operation, "##", i->GetID());
return i->GetID();
- }
- );
+ });
}
return str;
- }
- )
- );
+ }));
}
void CStubBodyGen::GenInterfaceDelegatorPortSetter(std::ofstream& stream,
@@ -558,7 +547,8 @@ void CStubBodyGen::GenInterfaceAddPrivileges(std::ofstream& stream,
std::string str;
for (auto& a : inf.GetAttributes().GetAttrs()) {
if (a->GetKey() == "privilege") {
- str += GetAddPrivilegeString(GetInterfaceIdWithNamespace(inf), *a);
+ str += GetAddPrivilegeString(
+ GetInterfaceIdWithNamespace(inf), *a);
str += NLine(1);
} else if (a->GetKey() == "trusted" && a->GetValue() == "true") {
str += GetTrustedModeString(GetInterfaceIdWithNamespace(inf), *a);
@@ -569,9 +559,7 @@ void CStubBodyGen::GenInterfaceAddPrivileges(std::ofstream& stream,
if (!str.empty())
str = SmartIndent("int r;\n\n") + str;
return str;
- }
- )
- );
+ }));
}
} // namespace tidl
diff --git a/idlc/c_gen/c_stub_body_gen.h b/idlc/c_gen/c_stub_body_gen.h
index 80356f7..76ac25d 100644
--- a/idlc/c_gen/c_stub_body_gen.h
+++ b/idlc/c_gen/c_stub_body_gen.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef IDLC_C_GEN_STUB_BODY_GEN_H_
-#define IDLC_C_GEN_STUB_BODY_GEN_H_
+#ifndef IDLC_C_GEN_C_STUB_BODY_GEN_H_
+#define IDLC_C_GEN_C_STUB_BODY_GEN_H_
#include <memory>
#include <string>
@@ -108,4 +108,4 @@ class CStubBodyGen : public CBodyGeneratorBase {
} // namespace tidl
-#endif // IDLC_C_GEN_STUB_BODY_GEN_H_
+#endif // IDLC_C_GEN_C_STUB_BODY_GEN_H_
diff --git a/idlc/c_gen/c_stub_body_gen_cb.h b/idlc/c_gen/c_stub_body_gen_cb.h
index e36ab8c..0a5fe0d 100644
--- a/idlc/c_gen/c_stub_body_gen_cb.h
+++ b/idlc/c_gen/c_stub_body_gen_cb.h
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+#ifndef IDLC_C_GEN_C_STUB_BODY_GEN_CB_H_
+#define IDLC_C_GEN_C_STUB_BODY_GEN_CB_H_
+
const char CB_INTERFACE_METHOD[] =
R"__c_cb(
static int __$$_method_$$(rpc_port_h port, rpc_port_parcel_h parcel, void *data)
@@ -557,3 +560,5 @@ if (r != 0) {
return r;
}
)__c_cb";
+
+#endif // IDLC_C_GEN_C_STUB_BODY_GEN_CB_H_
diff --git a/idlc/c_gen/c_stub_header_gen.cc b/idlc/c_gen/c_stub_header_gen.cc
index 5f56218..f8d9820 100644
--- a/idlc/c_gen/c_stub_header_gen.cc
+++ b/idlc/c_gen/c_stub_header_gen.cc
@@ -63,7 +63,7 @@ void CStubHeaderGen::GenInterfaceDeclaration(std::ofstream& stream,
CB_INTERFACE_DECL, "##", GetInterfaceIdWithNamespace(inf)),
[&]()->std::string {
std::string str;
- for (auto& i: inf.GetDeclarations().GetDecls()) {
+ for (auto& i : inf.GetDeclarations().GetDecls()) {
if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
str += NLine(1);
@@ -80,24 +80,23 @@ void CStubHeaderGen::GenInterfaceDeclaration(std::ofstream& stream,
[&]()->std::string {
std::string s;
for (auto& p : i->GetParameters().GetParams()) {
- if (IsDelegateType(inf, p->GetParameterType().GetBaseType())) {
- s += "rpc_port_" + GetInterfaceIdWithNamespace(inf) + "_" +
- p->GetParameterType().GetBaseType().ToString() + "_h " +
- p->GetID();
+ if (IsDelegateType(inf, p->GetParameterType()
+ .GetBaseType())) {
+ s += "rpc_port_" + GetInterfaceIdWithNamespace(inf)
+ + "_" + p->GetParameterType().GetBaseType().ToString()
+ + "_h " + p->GetID();
} else {
- s += GetParamTypeString(p->GetParameterType().GetDirection(),
- p->GetParameterType().GetBaseType()) + p->GetID();
+ s += GetParamTypeString(p->GetParameterType()
+ .GetDirection(), p->GetParameterType().GetBaseType())
+ + p->GetID();
}
s += ", ";
}
return s;
- }
- );
+ });
}
return str;
- }
- )
- );
+ }));
}
void CStubHeaderGen::GenInterfaceContext(std::ofstream& stream,
@@ -110,22 +109,26 @@ void CStubHeaderGen::GenInterfaceContext(std::ofstream& stream,
void CStubHeaderGen::GenInterfaceContextDeclaration(
std::ofstream& stream, const Interface& inf) {
- stream << ReplaceAll(CB_INTERFACE_CONTEXT_DECL, "##", GetInterfaceIdWithNamespace(inf));
+ stream << ReplaceAll(CB_INTERFACE_CONTEXT_DECL, "##",
+ GetInterfaceIdWithNamespace(inf));
}
void CStubHeaderGen::GenInterfaceContextTagSetter(
std::ofstream& stream, const Interface& inf) {
- stream << ReplaceAll(CB_INTERFACE_CONTEXT_SET_TAG, "##", GetInterfaceIdWithNamespace(inf));
+ stream << ReplaceAll(CB_INTERFACE_CONTEXT_SET_TAG, "##",
+ GetInterfaceIdWithNamespace(inf));
}
void CStubHeaderGen::GenInterfaceContextTagGetter(
std::ofstream& stream, const Interface& inf) {
- stream << ReplaceAll(CB_INTERFACE_CONTEXT_GET_TAG, "##", GetInterfaceIdWithNamespace(inf));
+ stream << ReplaceAll(CB_INTERFACE_CONTEXT_GET_TAG, "##",
+ GetInterfaceIdWithNamespace(inf));
}
void CStubHeaderGen::GenInterfaceContextSenderGetter(
std::ofstream& stream, const Interface& inf) {
- stream << ReplaceAll(CB_INTERFACE_CONTEXT_GET_SENDER, "##", GetInterfaceIdWithNamespace(inf));
+ stream << ReplaceAll(CB_INTERFACE_CONTEXT_GET_SENDER, "##",
+ GetInterfaceIdWithNamespace(inf));
}
void CStubHeaderGen::GenInterfaceDelegators(std::ofstream& stream,
@@ -176,18 +179,19 @@ void CStubHeaderGen::GenInterfaceDelegatorInvoker(
i->GetParameterType().GetBaseType()) + i->GetID();
}
return str;
- }
- );
+ });
}
void CStubHeaderGen::GenInterfaceRegister(std::ofstream& stream,
const Interface& inf) {
- stream << ReplaceAll(CB_INTERFACE_REGISTER, "##", GetInterfaceIdWithNamespace(inf));
+ stream << ReplaceAll(CB_INTERFACE_REGISTER, "##",
+ GetInterfaceIdWithNamespace(inf));
}
void CStubHeaderGen::GenInterfaceUnregister(std::ofstream& stream,
const Interface& inf) {
- stream << ReplaceAll(CB_INTERFACE_UNREGISTER, "##", GetInterfaceIdWithNamespace(inf));
+ stream << ReplaceAll(CB_INTERFACE_UNREGISTER, "##",
+ GetInterfaceIdWithNamespace(inf));
}
} // namespace tidl
diff --git a/idlc/c_gen/c_stub_header_gen_cb.h b/idlc/c_gen/c_stub_header_gen_cb.h
index 127cc5d..f16e733 100644
--- a/idlc/c_gen/c_stub_header_gen_cb.h
+++ b/idlc/c_gen/c_stub_header_gen_cb.h
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+#ifndef IDLC_C_GEN_C_STUB_HEADER_GEN_CB_H_
+#define IDLC_C_GEN_C_STUB_HEADER_GEN_CB_H_
+
const char CB_INTERFACE_DECL[] =
R"__c_cb(
typedef struct {
@@ -75,3 +78,5 @@ const char CB_INTERFACE_UNREGISTER[] =
R"__c_cb(
int rpc_port_stub_##_unregister(void);
)__c_cb";
+
+#endif // IDLC_C_GEN_C_STUB_HEADER_GEN_CB_H_
diff --git a/idlc/cpp_gen/cpp_gen_base.cc b/idlc/cpp_gen/cpp_gen_base.cc
index a259a3e..4c4210c 100644
--- a/idlc/cpp_gen/cpp_gen_base.cc
+++ b/idlc/cpp_gen/cpp_gen_base.cc
@@ -21,7 +21,7 @@
#include "idlc/cpp_gen/cpp_gen_base.h"
namespace {
-#include "cpp_gen_base_cb.h"
+#include "idlc/cpp_gen/cpp_gen_base_cb.h"
}
namespace tidl {
@@ -31,7 +31,7 @@ CppGeneratorBase::CppGeneratorBase(std::shared_ptr<Document> doc)
type_map_ = {
{"char", "char"}, {"int", "int"}, {"short", "short"},
{"long", "long long"}, {"string", "std::string"}, {"bool", "bool"},
- {"list", "std::list"}, {"float","float"}, {"double", "double"},
+ {"list", "std::list"}, {"float", "float"}, {"double", "double"},
{"bundle", "Bundle"}, {"void", "void"}, {"array", "std::vector"}
};
@@ -96,8 +96,7 @@ void CppGeneratorBase::GenStructureForHeader(std::ofstream& stream,
n++;
}
return str;
- }
- );
+ });
stream << NLine(1);
for (auto& i : st.GetElements().GetElms()) {
@@ -123,8 +122,7 @@ void CppGeneratorBase::GenStructureForHeader(std::ofstream& stream,
}
str += NLine(1);
return str;
- }
- );
+ });
}, false, false);
stream << ";" << NLine(1);
}
@@ -149,7 +147,7 @@ void CppGeneratorBase::GenSetter(std::ofstream& stream, const Element& ele) {
return ele.GetID();
},
[&]()->std::string {
- if(ele.GetType().IsUserDefinedType() ||
+ if (ele.GetType().IsUserDefinedType() ||
ele.GetType().GetMetaType() != nullptr ||
ele.GetType().ToString() == "string" ||
ele.GetType().ToString() == "bundle") {
@@ -157,8 +155,7 @@ void CppGeneratorBase::GenSetter(std::ofstream& stream, const Element& ele) {
}
return ele.GetID();
- }
- );
+ });
stream << NLine(1);
}
@@ -170,7 +167,7 @@ void CppGeneratorBase::GenGetter(std::ofstream& stream, const Element& ele) {
GenTemplate(AddIndent(TAB_SIZE, getter, true), stream,
[&]()->std::string {
- if(ele.GetType().IsUserDefinedType() ||
+ if (ele.GetType().IsUserDefinedType() ||
ele.GetType().GetMetaType() != nullptr ||
ele.GetType().ToString() == "string" ||
ele.GetType().ToString() == "bundle") {
@@ -184,8 +181,7 @@ void CppGeneratorBase::GenGetter(std::ofstream& stream, const Element& ele) {
},
[&]()->std::string {
return ele.GetID();
- }
- );
+ });
}
void CppGeneratorBase::GenStructuresForBody(std::ofstream& stream) {
@@ -198,7 +194,8 @@ void CppGeneratorBase::GenStructuresForBody(std::ofstream& stream) {
}
}
-void CppGeneratorBase::GenStructureForBody(std::ofstream& stream, const Structure& st) {
+void CppGeneratorBase::GenStructureForBody(std::ofstream& stream,
+ const Structure& st) {
std::vector<std::pair<std::string, std::string>> v;
const char ctor[] = "##::##() {}\n\n" \
"##::##($$)\n" \
@@ -216,7 +213,7 @@ void CppGeneratorBase::GenStructureForBody(std::ofstream& stream, const Structur
[&]()->std::string {
std::string str;
for (auto& i : v) {
- str += i.first + " " + i.second ;
+ str += i.first + " " + i.second;
if (i != v.back())
str += ", ";
@@ -232,8 +229,7 @@ void CppGeneratorBase::GenStructureForBody(std::ofstream& stream, const Structur
str += ", ";
}
return str;
- }
- );
+ });
stream << NLine(2);
}
@@ -307,8 +303,8 @@ void CppGeneratorBase::GenDeSerializer(std::ofstream& stream,
for (auto& i : st.GetElements().GetElms()) {
stream << AddIndent(TAB_SIZE,
ConvertTypeToDeserializer(i->GetType(), i->GetID(), "h"));
- stream << Tab(1) << "param.Set" << i->GetID() << "(std::move(" << i->GetID() << "));"
- << NLine(2);
+ stream << Tab(1) << "param.Set" << i->GetID() << "(std::move("
+ << i->GetID() << "));" << NLine(2);
}
stream << Tab(1) << "return h;" << NLine(1);
}, false);
@@ -549,7 +545,8 @@ std::string CppGeneratorBase::ConvertTypeToDeserializer(
if (make_new_type) {
ret += n + " ";
if (IsDelegateType(type)) {
- ret += id + "(new " + type.ToString() + "(port, std::weak_ptr<ServiceBase>(b)));\n";
+ ret += id + "(new " + type.ToString()
+ + "(port, std::weak_ptr<ServiceBase>(b)));\n";
} else {
ret += id + ";\n";
}
@@ -600,8 +597,7 @@ void CppGeneratorBase::GenBodyCallback(std::ofstream& stream,
ConvertTypeToSerializer(pt.GetBaseType(), i->GetID(), "p"));
}
return m;
- }
- );
+ });
} else {
GenTemplate(CB_CALLBACK_ON_RECEIVED_EVENT_METHOD, stream,
[&]()->std::string {
@@ -633,8 +629,7 @@ void CppGeneratorBase::GenBodyCallback(std::ofstream& stream,
ret += ");";
return ret;
- }
- );
+ });
}
}
@@ -643,7 +638,8 @@ void CppGeneratorBase::GenHeaderCallbacks(std::ofstream& stream,
bool is_proxy) {
stream << CB_CALLBACK_BASE_HEADER_FRONT;
if (is_proxy) {
- stream << Tab(1) << " virtual void OnReceivedEvent(rpc_port_parcel_h port) = 0;"
+ stream << Tab(1)
+ << " virtual void OnReceivedEvent(rpc_port_parcel_h port) = 0;"
<< NLine(1);
}
stream << CB_CALLBACK_BASE_HEADER_BACK;
@@ -695,8 +691,7 @@ void CppGeneratorBase::GenCopyright(std::ofstream& stream) {
std::time_t t = std::time(NULL);
std::tm* local_time = std::localtime(&t);
return std::to_string(local_time->tm_year + 1900);
- }
- );
+ });
}
} // namespace tidl
diff --git a/idlc/cpp_gen/cpp_gen_base_cb.h b/idlc/cpp_gen/cpp_gen_base_cb.h
index 582e9fa..e4ad06f 100644
--- a/idlc/cpp_gen/cpp_gen_base_cb.h
+++ b/idlc/cpp_gen/cpp_gen_base_cb.h
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+#ifndef IDLC_CPP_GEN_CPP_GEN_BASE_CB_H_
+#define IDLC_CPP_GEN_CPP_GEN_BASE_CB_H_
+
const char CB_BUNDLE[] = R"__cls_bundle(class Bundle final {
public:
Bundle() {
@@ -209,3 +212,5 @@ void $$::$$::OnReceivedEvent(rpc_port_parcel_h parcel) {
$$
}
)__cpp_cb";
+
+#endif // IDLC_CPP_GEN_CPP_GEN_BASE_CB_H_
diff --git a/idlc/cpp_gen/cpp_proxy_body_gen.cc b/idlc/cpp_gen/cpp_proxy_body_gen.cc
index 7a0c720..4c689a9 100644
--- a/idlc/cpp_gen/cpp_proxy_body_gen.cc
+++ b/idlc/cpp_gen/cpp_proxy_body_gen.cc
@@ -17,7 +17,7 @@
#include "idlc/cpp_gen/cpp_proxy_body_gen.h"
namespace {
-#include "cpp_proxy_body_gen_cb.h"
+#include "idlc/cpp_gen/cpp_proxy_body_gen_cb.h"
}
namespace tidl {
@@ -90,8 +90,7 @@ void CppProxyBodyGen::GenConstructor(std::ofstream& stream,
},
[&]()->std::string {
return iface.GetID();
- }
- );
+ });
}
void CppProxyBodyGen::GenDestructor(std::ofstream& stream,
@@ -102,8 +101,7 @@ void CppProxyBodyGen::GenDestructor(std::ofstream& stream,
},
[&]()->std::string {
return iface.GetID();
- }
- );
+ });
}
void CppProxyBodyGen::GenHelperMethods(std::ofstream& stream,
@@ -128,7 +126,8 @@ void CppProxyBodyGen::GenMethods(std::ofstream& stream,
}
}
-void CppProxyBodyGen::GenInvocation(std::ofstream& stream, const Declaration& decl) {
+void CppProxyBodyGen::GenInvocation(std::ofstream& stream,
+ const Declaration& decl) {
stream << CB_INVOCATION_PRE;
// Serialize
diff --git a/idlc/cpp_gen/cpp_proxy_body_gen_cb.h b/idlc/cpp_gen/cpp_proxy_body_gen_cb.h
index 78336e9..75c9ce5 100644
--- a/idlc/cpp_gen/cpp_proxy_body_gen_cb.h
+++ b/idlc/cpp_gen/cpp_proxy_body_gen_cb.h
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+#ifndef IDLC_CPP_GEN_CPP_PROXY_BODY_GEN_CB_H_
+#define IDLC_CPP_GEN_CPP_PROXY_BODY_GEN_CB_H_
+
const char CB_DTOR[] =
R"__cpp_cb(
$$::~$$() {
@@ -170,3 +173,5 @@ $$::$$(IEventListener* listener, const std::string& target_appid)
rpc_port_proxy_add_received_event_cb(proxy_, OnReceivedCB, this);
}
)__cpp_cb";
+
+#endif // IDLC_CPP_GEN_CPP_PROXY_BODY_GEN_CB_H_
diff --git a/idlc/cpp_gen/cpp_proxy_header_gen.cc b/idlc/cpp_gen/cpp_proxy_header_gen.cc
index ea3b50d..001e93b 100644
--- a/idlc/cpp_gen/cpp_proxy_header_gen.cc
+++ b/idlc/cpp_gen/cpp_proxy_header_gen.cc
@@ -17,7 +17,7 @@
#include "idlc/cpp_gen/cpp_proxy_header_gen.h"
namespace {
-#include "cpp_proxy_header_gen_cb.h"
+#include "idlc/cpp_gen/cpp_proxy_header_gen_cb.h"
}
namespace tidl {
@@ -75,8 +75,7 @@ void CppProxyHeaderGen::GenInterface(std::ofstream& stream,
},
[&]()->std::string {
return iface.GetID();
- }
- );
+ });
GenMethods(stream, iface);
stream << NLine(1) << " private:" << NLine(1);
GenMethodId(stream, iface);
diff --git a/idlc/cpp_gen/cpp_proxy_header_gen_cb.h b/idlc/cpp_gen/cpp_proxy_header_gen_cb.h
index c4e270e..82bb804 100644
--- a/idlc/cpp_gen/cpp_proxy_header_gen_cb.h
+++ b/idlc/cpp_gen/cpp_proxy_header_gen_cb.h
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+#ifndef IDLC_CPP_GEN_CPP_PROXY_HEADER_GEN_CB_H_
+#define IDLC_CPP_GEN_CPP_PROXY_HEADER_GEN_CB_H_
+
const char CB_EXCEPTIONS[] =
R"__cpp_cb(
class Exception {};
@@ -115,3 +118,5 @@ R"__cpp_cb(
#include <list>
)__cpp_cb";
+
+#endif // IDLC_CPP_GEN_CPP_PROXY_HEADER_GEN_CB_H_
diff --git a/idlc/cpp_gen/cpp_stub_body_gen.cc b/idlc/cpp_gen/cpp_stub_body_gen.cc
index 0f27964..7d4ca48 100644
--- a/idlc/cpp_gen/cpp_stub_body_gen.cc
+++ b/idlc/cpp_gen/cpp_stub_body_gen.cc
@@ -17,7 +17,7 @@
#include "idlc/cpp_gen/cpp_stub_body_gen.h"
namespace {
-#include "cpp_stub_body_gen_cb.h"
+#include "idlc/cpp_gen/cpp_stub_body_gen_cb.h"
}
namespace tidl {
@@ -85,8 +85,7 @@ void CppStubBodyGen::GenServiceBase(std::ofstream& stream,
GenTemplate(CB_CTOR_SERVICE_BASE, stream,
[&]()->std::string {
return iface.GetID();
- }
- );
+ });
stream << NLine(1);
}
@@ -121,12 +120,12 @@ void CppStubBodyGen::GenReceivedEvent(std::ofstream& stream,
},
[&]()->std::string {
return iface.GetID();
- }
- );
+ });
for (auto& i : iface.GetDeclarations().GetDecls()) {
if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
- stream << Tab(2) << "case static_cast<int>(MethodId::" << i->GetID() << "): ";
+ stream << Tab(2) << "case static_cast<int>(MethodId::"
+ << i->GetID() << "): ";
GenBrace(stream, TAB_SIZE * 2, [&]() {
GenInvocation(stream, *i);
stream << Tab(3) << "break;" << NLine(1);
@@ -136,7 +135,8 @@ void CppStubBodyGen::GenReceivedEvent(std::ofstream& stream,
stream << CB_ON_RECEIVED_CB_BACK << NLine(1);
}
-void CppStubBodyGen::GenInvocation(std::ofstream& stream, const Declaration& decl) {
+void CppStubBodyGen::GenInvocation(std::ofstream& stream,
+ const Declaration& decl) {
int cnt = 1;
// Deserialize
@@ -194,7 +194,8 @@ void CppStubBodyGen::GenInvocation(std::ofstream& stream, const Declaration& dec
return;
cnt = 0;
- m = "rpc_port_parcel_write_int32(result, static_cast<int>(MethodId::__Result));\n";
+ m = "rpc_port_parcel_write_int32(" \
+ "result, static_cast<int>(MethodId::__Result));\n";
for (auto& i : decl.GetParameters().GetParams()) {
auto& pt = i->GetParameterType();
cnt++;
diff --git a/idlc/cpp_gen/cpp_stub_body_gen_cb.h b/idlc/cpp_gen/cpp_stub_body_gen_cb.h
index 41f20ac..f656bc1 100644
--- a/idlc/cpp_gen/cpp_stub_body_gen_cb.h
+++ b/idlc/cpp_gen/cpp_stub_body_gen_cb.h
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+#ifndef IDLC_CPP_GEN_CPP_STUB_BODY_GEN_CB_H_
+#define IDLC_CPP_GEN_CPP_STUB_BODY_GEN_CB_H_
+
const char CB_CTOR_FRONT[] =
R"__cpp_cb(
##::##() {
@@ -113,3 +116,5 @@ R"__cpp_cb( default:
const char CB_CTOR_SERVICE_BASE[] =
R"__cpp_cb($$::ServiceBase::ServiceBase(std::string sender, std::string instance)
: sender_(std::move(sender)), instance_(std::move(instance)) {})__cpp_cb";
+
+#endif // IDLC_CPP_GEN_CPP_STUB_BODY_GEN_CB_H_
diff --git a/idlc/cpp_gen/cpp_stub_header_gen.cc b/idlc/cpp_gen/cpp_stub_header_gen.cc
index 503d566..f451631 100644
--- a/idlc/cpp_gen/cpp_stub_header_gen.cc
+++ b/idlc/cpp_gen/cpp_stub_header_gen.cc
@@ -17,7 +17,7 @@
#include "idlc/cpp_gen/cpp_stub_header_gen.h"
namespace {
-#include "cpp_stub_header_gen_cb.h"
+#include "idlc/cpp_gen/cpp_stub_header_gen_cb.h"
}
namespace tidl {
diff --git a/idlc/cpp_gen/cpp_stub_header_gen_cb.h b/idlc/cpp_gen/cpp_stub_header_gen_cb.h
index 21abaf3..4e65ec3 100644
--- a/idlc/cpp_gen/cpp_stub_header_gen_cb.h
+++ b/idlc/cpp_gen/cpp_stub_header_gen_cb.h
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+#ifndef IDLC_CPP_GEN_CPP_STUB_HEADER_GEN_CB_H_
+#define IDLC_CPP_GEN_CPP_STUB_HEADER_GEN_CB_H_
+
const char CB_EXCEPTIONS[] =
R"__cpp_cb(
class Exception {};
@@ -122,3 +125,5 @@ R"__cpp_cb(
#include <list>
)__cpp_cb";
+
+#endif // IDLC_CPP_GEN_CPP_STUB_HEADER_GEN_CB_H_
diff --git a/idlc/cs_gen/cs_cb_copyright.h b/idlc/cs_gen/cs_cb_copyright.h
index ece17d6..7982f9a 100644
--- a/idlc/cs_gen/cs_cb_copyright.h
+++ b/idlc/cs_gen/cs_cb_copyright.h
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+#ifndef IDLC_CS_GEN_CS_CB_COPYRIGHT_H_
+#define IDLC_CS_GEN_CS_CB_COPYRIGHT_H_
+
const char cs_cb_copyright[] =
R"__cs_cb(/*
* Generated by tidlc $$.
@@ -33,3 +36,5 @@ R"__cs_cb(/*
* limitations under the License.
*/
)__cs_cb";
+
+#endif // IDLC_CS_GEN_CS_CB_COPYRIGHT_H_
diff --git a/idlc/cs_gen/cs_cb_interop.h b/idlc/cs_gen/cs_cb_interop.h
index c606b97..249400b 100644
--- a/idlc/cs_gen/cs_cb_interop.h
+++ b/idlc/cs_gen/cs_cb_interop.h
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+#ifndef IDLC_CS_GEN_CS_CB_INTEROP_H_
+#define IDLC_CS_GEN_CS_CB_INTEROP_H_
+
const char cs_cb_interop[] =
R"__cs_cb(
internal static partial class Interop
@@ -137,3 +140,4 @@ $$
}
)__cs_cb";
+#endif // IDLC_CS_GEN_CS_CB_INTEROP_H_
diff --git a/idlc/cs_gen/cs_cb_proxy_interop.h b/idlc/cs_gen/cs_cb_proxy_interop.h
index b49475d..10191f5 100644
--- a/idlc/cs_gen/cs_cb_proxy_interop.h
+++ b/idlc/cs_gen/cs_cb_proxy_interop.h
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+#ifndef IDLC_CS_GEN_CS_CB_PROXY_INTEROP_H_
+#define IDLC_CS_GEN_CS_CB_PROXY_INTEROP_H_
+
const char cs_cb_proxy_interop[] =
R"__cs_cb(
internal static partial class Proxy
@@ -63,3 +66,5 @@ R"__cs_cb(
internal static extern ErrorCode AddReceivedEventCb(IntPtr handle, ReceivedEventCallback cb, IntPtr data);
}
)__cs_cb";
+
+#endif // IDLC_CS_GEN_CS_CB_PROXY_INTEROP_H_
diff --git a/idlc/cs_gen/cs_cb_stub_interop.h b/idlc/cs_gen/cs_cb_stub_interop.h
index f085b24..3d5294a 100644
--- a/idlc/cs_gen/cs_cb_stub_interop.h
+++ b/idlc/cs_gen/cs_cb_stub_interop.h
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+#ifndef IDLC_CS_GEN_CS_CB_STUB_INTEROP_H_
+#define IDLC_CS_GEN_CS_CB_STUB_INTEROP_H_
+
const char cs_cb_stub_interop[] =
R"__cs_cb(
internal static partial class Stub
@@ -63,3 +66,5 @@ R"__cs_cb(
internal static extern ErrorCode SetTrusted(IntPtr handle, bool trusted);
}
)__cs_cb";
+
+#endif // IDLC_CS_GEN_CS_CB_STUB_INTEROP_H_
diff --git a/idlc/cs_gen/cs_gen_base.cc b/idlc/cs_gen/cs_gen_base.cc
index 982a252..09b01eb 100644
--- a/idlc/cs_gen/cs_gen_base.cc
+++ b/idlc/cs_gen/cs_gen_base.cc
@@ -31,7 +31,7 @@ CsGeneratorBase::CsGeneratorBase(std::shared_ptr<Document> doc)
type_map_ = {
{"char", "byte"}, {"int", "int"}, {"short", "short"},
{"long", "long"}, {"string", "string"}, {"bool", "bool"},
- {"list", "LinkedList"}, {"array", "List"}, {"float","float"},
+ {"list", "LinkedList"}, {"array", "List"}, {"float", "float"},
{"double", "double"}, {"bundle", "Bundle"}, {"void", "void"}
};
@@ -74,8 +74,7 @@ void CsGeneratorBase::GenStructure(std::ofstream& stream, const Structure& st) {
},
[&]()->std::string {
return i->GetID();
- }
- );
+ });
if (i->GetType().ToString() == "bundle") {
v.push_back(i->GetID() + " = " + "new Bundle()");
}
@@ -91,12 +90,12 @@ void CsGeneratorBase::GenStructure(std::ofstream& stream, const Structure& st) {
str += " " + i + ";\n";
}
return str;
- }
- );
+ });
});
}
-void CsGeneratorBase::GenSerializer(std::ofstream& stream, const Structure& st) {
+void CsGeneratorBase::GenSerializer(std::ofstream& stream,
+ const Structure& st) {
stream << NLine(1) << Tab(3) << "private static void Serialize(IntPtr h, "
<< st.GetID() << " param)" << NLine(1);
GenBrace(stream, TAB_SIZE * 3, [&]() {
@@ -146,7 +145,6 @@ void CsGeneratorBase::GenSerializer(std::ofstream& stream, const Structure& st)
stream << Tab(4) << "Deserialize(h, param." << i->GetID()
<< ");" << NLine(1);
}
-
}
});
}
@@ -167,7 +165,8 @@ void CsGeneratorBase::AddSerializerList(const BaseType& type) {
}
}
-void CsGeneratorBase::GenListSerializer(std::ofstream& stream, const BaseType& type) {
+void CsGeneratorBase::GenListSerializer(std::ofstream& stream,
+ const BaseType& type) {
stream << NLine(1) << Tab(3) << "private static void Serialize(IntPtr h, "
<< ConvertTypeToString(type) << " param)" << NLine(1);
GenBrace(stream, TAB_SIZE * 3, [&]() {
@@ -344,18 +343,19 @@ std::string CsGeneratorBase::NLine(int cnt) {
return t;
}
-void CsGeneratorBase::GenWriteBundle(std::ofstream& stream, const std::string& id) {
+void CsGeneratorBase::GenWriteBundle(std::ofstream& stream,
+ const std::string& id) {
GenTemplate(CB_WRITE_BUNDLE, stream,
[&]()->std::string {
return id;
},
[&]()->std::string {
return id;
- }
- );
+ });
}
-void CsGeneratorBase::GenMethodId(std::ofstream& stream, const Interface& iface) {
+void CsGeneratorBase::GenMethodId(std::ofstream& stream,
+ const Interface& iface) {
stream << Tab(3) << "private enum MethodId : int" << NLine(1);
GenBrace(stream, TAB_SIZE * 3, [&]() {
int cnt = 2;
@@ -370,7 +370,8 @@ void CsGeneratorBase::GenMethodId(std::ofstream& stream, const Interface& iface)
});
}
-void CsGeneratorBase::GenDelegateId(std::ofstream& stream, const Interface& iface) {
+void CsGeneratorBase::GenDelegateId(std::ofstream& stream,
+ const Interface& iface) {
stream << Tab(3) << "private enum DelegateId : int" << NLine(1);
GenBrace(stream, TAB_SIZE * 3, [&]() {
int cnt = 1;
@@ -395,7 +396,8 @@ void CsGeneratorBase::GenDeclaration(std::ofstream& stream,
stream << ")";
}
-void CsGeneratorBase::GenParameters(std::ofstream& stream, const Parameters& ps) {
+void CsGeneratorBase::GenParameters(std::ofstream& stream,
+ const Parameters& ps) {
stream << GetParameters(ps);
}
@@ -446,8 +448,7 @@ void CsGeneratorBase::GenCallback(std::ofstream& stream,
},
[&]()->std::string {
return decl.GetID();
- }
- );
+ });
stream << NLine(1);
if (is_proxy) {
@@ -508,8 +509,7 @@ void CsGeneratorBase::GenInvokeMethod(std::ofstream& stream,
m += ConvertTypeToSerializer(pt.GetBaseType(), i->GetID(), "p", id);
}
return AddIndent(TAB_SIZE * 5, m);
- }
- );
+ });
}
void CsGeneratorBase::GenCopyright(std::ofstream& stream) {
@@ -521,8 +521,7 @@ void CsGeneratorBase::GenCopyright(std::ofstream& stream) {
std::time_t t = std::time(NULL);
std::tm* local_time = std::localtime(&t);
return std::to_string(local_time->tm_year + 1900);
- }
- );
+ });
stream << NLine(1);
}
} // namespace tidl
diff --git a/idlc/cs_gen/cs_gen_base_cb.h b/idlc/cs_gen/cs_gen_base_cb.h
index 83fab1b..d80bd7e 100644
--- a/idlc/cs_gen/cs_gen_base_cb.h
+++ b/idlc/cs_gen/cs_gen_base_cb.h
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+#ifndef IDLC_CS_GEN_CS_GEN_BASE_CB_H_
+#define IDLC_CS_GEN_CS_GEN_BASE_CB_H_
+
const char CB_EXCEPTIONS[] =
R"__cs_cb( public class InvalidIOException : InvalidOperationException {}
public class InvalidIDException : InvalidOperationException {}
@@ -134,3 +137,5 @@ R"__cs_cb(
Interop.LibRPCPort.Parcel.WriteBundle(h, new Bundle().SafeBundleHandle.DangerousGetHandle());
}
)__cs_cb";
+
+#endif // IDLC_CS_GEN_CS_GEN_BASE_CB_H_
diff --git a/idlc/cs_gen/cs_proxy_gen.cc b/idlc/cs_gen/cs_proxy_gen.cc
index 2e98940..9b127a5 100644
--- a/idlc/cs_gen/cs_proxy_gen.cc
+++ b/idlc/cs_gen/cs_proxy_gen.cc
@@ -63,8 +63,7 @@ void CsProxyGen::GenInterop(std::ofstream& stream) {
GenTemplate(AddIndent(TAB_SIZE, ::cs_cb_interop), stream,
[&]()->std::string {
return AddIndent(TAB_SIZE, ::cs_cb_proxy_interop);
- }
- );
+ });
});
});
stream << NLine(1);
@@ -81,7 +80,6 @@ void CsProxyGen::GenInterfaces(std::ofstream& stream) {
}
void CsProxyGen::GenInterface(std::ofstream& stream, const Interface& iface) {
-
stream << Tab(2) << "public class " << iface.GetID()
<< " : IDisposable" << NLine(1);
GenBrace(stream, TAB_SIZE * 2, [&]() {
@@ -106,16 +104,15 @@ void CsProxyGen::GenCtor(std::ofstream& stream, const Interface& iface) {
GenTemplate(AddIndent(TAB_SIZE * 3, m), stream,
[&]()->std::string {
return iface.GetID();
- }
- );
+ });
}
-void CsProxyGen::GenConnectMethod(std::ofstream& stream, const Interface& iface) {
+void CsProxyGen::GenConnectMethod(std::ofstream& stream,
+ const Interface& iface) {
GenTemplate(CB_CONNECT_METHOD, stream,
[&]()->std::string {
return iface.GetID();
- }
- );
+ });
stream << NLine(1);
}
@@ -217,8 +214,7 @@ void CsProxyGen::GenDisposable(std::ofstream& stream, const Interface& iface) {
GenTemplate(CB_DISPOSABLE, stream,
[&]()->std::string {
return iface.GetID();
- }
- );
+ });
}
} // namespace tidl
diff --git a/idlc/cs_gen/cs_proxy_gen_cb.h b/idlc/cs_gen/cs_proxy_gen_cb.h
index f9c420e..35fade0 100644
--- a/idlc/cs_gen/cs_proxy_gen_cb.h
+++ b/idlc/cs_gen/cs_proxy_gen_cb.h
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+#ifndef IDLC_CS_GEN_CS_PROXY_GEN_CB_H_
+#define IDLC_CS_GEN_CS_PROXY_GEN_CB_H_
+
const char CB_DATA_MEMBERS[] =
R"__cs_cb( public event EventHandler Connected;
public event EventHandler Disconnected;
@@ -213,3 +216,5 @@ const char CB_INVOCATION_MID[] =
R"__cs_cb( // Send
Interop.LibRPCPort.Parcel.Send(p, _port);
)__cs_cb";
+
+#endif // IDLC_CS_GEN_CS_PROXY_GEN_CB_H_
diff --git a/idlc/cs_gen/cs_stub_gen.cc b/idlc/cs_gen/cs_stub_gen.cc
index 43de07f..3f378c1 100644
--- a/idlc/cs_gen/cs_stub_gen.cc
+++ b/idlc/cs_gen/cs_stub_gen.cc
@@ -47,8 +47,7 @@ void CsStubGen::GenInterop(std::ofstream& stream) {
GenTemplate(AddIndent(TAB_SIZE, ::cs_cb_interop), stream,
[&]()->std::string {
return AddIndent(TAB_SIZE, ::cs_cb_stub_interop);
- }
- );
+ });
});
});
stream << NLine(1);
@@ -119,7 +118,8 @@ void CsStubGen::GenDeclarations(std::ofstream& stream,
}
}
-void CsStubGen::GenReceivedEvent(std::ofstream& stream, const Interface& iface) {
+void CsStubGen::GenReceivedEvent(std::ofstream& stream,
+ const Interface& iface) {
stream << CB_ON_RECEIVED_EVENT_FRONT;
for (auto& i : iface.GetDeclarations().GetDecls()) {
if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
@@ -218,8 +218,7 @@ void CsStubGen::GenCtor(std::ofstream& stream, const Interface& iface) {
},
[&]()->std::string {
return iface.GetID();
- }
- );
+ });
for (auto& i : iface.GetAttributes().GetAttrs()) {
if (i->GetKey() == "privilege") {
@@ -241,8 +240,7 @@ void CsStubGen::GenDisposable(std::ofstream& stream, const Interface& iface) {
GenTemplate(CB_DISPOSABLE, stream,
[&]()->std::string {
return iface.GetID();
- }
- );
+ });
}
} // namespace tidl
diff --git a/idlc/cs_gen/cs_stub_gen.h b/idlc/cs_gen/cs_stub_gen.h
index 897241a..072a597 100644
--- a/idlc/cs_gen/cs_stub_gen.h
+++ b/idlc/cs_gen/cs_stub_gen.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef IDLC_CS_GEN_STUB_GEN_H_
-#define IDLC_CS_GEN_STUB_GEN_H_
+#ifndef IDLC_CS_GEN_CS_STUB_GEN_H_
+#define IDLC_CS_GEN_CS_STUB_GEN_H_
#include <memory>
#include <string>
@@ -50,4 +50,4 @@ class CsStubGen : public CsGeneratorBase {
} // namespace tidl
-#endif // IDLC_CS_GEN_STUB_GEN_H_
+#endif // IDLC_CS_GEN_CS_STUB_GEN_H_
diff --git a/idlc/cs_gen/cs_stub_gen_cb.h b/idlc/cs_gen/cs_stub_gen_cb.h
index 36c7651..fe64861 100644
--- a/idlc/cs_gen/cs_stub_gen_cb.h
+++ b/idlc/cs_gen/cs_stub_gen_cb.h
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+#ifndef IDLC_CS_GEN_CS_STUB_GEN_CB_H_
+#define IDLC_CS_GEN_CS_STUB_GEN_CB_H_
+
const char CB_DATA_MEMBERS[] =
R"__cs_cb( private IntPtr _stub;
private List<ServiceBase> _services = new List<ServiceBase>();
@@ -214,3 +217,5 @@ R"__cs_cb(
}
#endregion
)__cs_cb";
+
+#endif // IDLC_CS_GEN_CS_STUB_GEN_CB_H_
diff --git a/idlc/declaration.h b/idlc/declaration.h
index 6aa09e8..9f9e17e 100644
--- a/idlc/declaration.h
+++ b/idlc/declaration.h
@@ -36,7 +36,7 @@ class Declaration {
Declaration(std::string id, BaseType* ret_type, Parameters* params,
std::string comments, unsigned line,
- MethodType mtype = MethodType::SYNC);
+ MethodType mtype = MethodType::SYNC);
const std::string& GetID() const;
const BaseType& GetType() const;
diff --git a/idlc/generator.h b/idlc/generator.h
index 6062c44..ed6b4ee 100644
--- a/idlc/generator.h
+++ b/idlc/generator.h
@@ -21,6 +21,7 @@
#include <fstream>
#include <iostream>
#include <memory>
+#include <utility>
#include "idlc/document.h"
#include "idlc/parameter.h"
@@ -50,7 +51,8 @@ class Generator {
}
template<typename T, typename ...ARGS>
- void GenTemplate(std::string templ, std::ofstream& stream, T cb, ARGS... args) {
+ void GenTemplate(std::string templ, std::ofstream& stream,
+ T cb, ARGS... args) {
size_t f = templ.find("$$");
templ.replace(f, std::string("$$").length(), cb());
GenTemplate(std::move(templ), stream, args...);
@@ -81,12 +83,12 @@ class Generator {
void GenBrace(std::ofstream& stream, int indent, T cb,
bool start_indent = true, bool ended_new_line = true) {
if (start_indent) {
- for(int i = 0; i < indent; i++)
+ for (int i = 0; i < indent; i++)
stream << " ";
}
stream << "{" << std::endl;
cb();
- for(int i = 0; i < indent; i++)
+ for (int i = 0; i < indent; i++)
stream << " ";
stream << "}";
if (ended_new_line)
diff --git a/idlc/main.cc b/idlc/main.cc
index ffdaf5e..89609d5 100644
--- a/idlc/main.cc
+++ b/idlc/main.cc
@@ -101,7 +101,8 @@ std::unique_ptr<Options> Options::Parse(int argc, char** argv) {
{ "output", 'o', 0, G_OPTION_ARG_STRING, &opt[OPT_OUTPUT],
"The generated interface file.", "OUTPUT" },
{ "namespace", 'n', 0, G_OPTION_ARG_NONE, &opt[OPT_NAMESPACE],
- "Add the prefix in the funtion name as output file name (C language only).",
+ "Add the prefix in the funtion name as output file name " \
+ "(C language only).",
NULL },
{ NULL }
};
diff --git a/unit_tests/cs_gen/cs_proxy_gen_unittest.cc b/unit_tests/cs_gen/cs_proxy_gen_unittest.cc
index 22bc86f..f989f58 100644
--- a/unit_tests/cs_gen/cs_proxy_gen_unittest.cc
+++ b/unit_tests/cs_gen/cs_proxy_gen_unittest.cc
@@ -60,9 +60,13 @@ TEST_F(CsProxyGenTest, CsProxyGen_Run) {
gen.Run("test.cs");
ASSERT_TRUE(FindStringFromFile("test.cs", "namespace RPCPort"));
- ASSERT_TRUE(FindStringFromFile("test.cs", " internal static partial class Proxy"));
- ASSERT_TRUE(FindStringFromFile("test.cs", " public sealed class Student"));
- ASSERT_TRUE(FindStringFromFile("test.cs", " public string name { get; set; }"));
+ ASSERT_TRUE(FindStringFromFile("test.cs",
+ " internal static partial class Proxy"));
+ ASSERT_TRUE(FindStringFromFile("test.cs",
+ " public sealed class Student"));
+ ASSERT_TRUE(FindStringFromFile("test.cs",
+ " public string name { get; set; }"));
ASSERT_TRUE(FindStringFromFile("test.cs", " public sealed class Class"));
- ASSERT_TRUE(FindStringFromFile("test.cs", " public LinkedList<Student> students { get; set; }"));
+ ASSERT_TRUE(FindStringFromFile("test.cs",
+ " public LinkedList<Student> students { get; set; }"));
}
diff --git a/unit_tests/cs_gen/cs_stub_gen_unittest.cc b/unit_tests/cs_gen/cs_stub_gen_unittest.cc
index cd6dad5..8b84032 100644
--- a/unit_tests/cs_gen/cs_stub_gen_unittest.cc
+++ b/unit_tests/cs_gen/cs_stub_gen_unittest.cc
@@ -60,9 +60,14 @@ TEST_F(CsStubGenTest, CsStubGen_Run) {
gen.Run("test_stub.cs");
ASSERT_TRUE(FindStringFromFile("test_stub.cs", "namespace RPCPort"));
- ASSERT_TRUE(FindStringFromFile("test_stub.cs", " internal static partial class Stub"));
- ASSERT_TRUE(FindStringFromFile("test_stub.cs", " public sealed class Student"));
- ASSERT_TRUE(FindStringFromFile("test_stub.cs", " public string name { get; set; }"));
- ASSERT_TRUE(FindStringFromFile("test_stub.cs", " public sealed class Class"));
- ASSERT_TRUE(FindStringFromFile("test_stub.cs", " public LinkedList<Student> students { get; set; }"));
+ ASSERT_TRUE(FindStringFromFile("test_stub.cs",
+ " internal static partial class Stub"));
+ ASSERT_TRUE(FindStringFromFile("test_stub.cs",
+ " public sealed class Student"));
+ ASSERT_TRUE(FindStringFromFile("test_stub.cs",
+ " public string name { get; set; }"));
+ ASSERT_TRUE(FindStringFromFile("test_stub.cs",
+ " public sealed class Class"));
+ ASSERT_TRUE(FindStringFromFile("test_stub.cs",
+ " public LinkedList<Student> students { get; set; }"));
}
diff --git a/unit_tests/generator_unittest.cc b/unit_tests/generator_unittest.cc
index b87ed3d..dd15a1c 100644
--- a/unit_tests/generator_unittest.cc
+++ b/unit_tests/generator_unittest.cc
@@ -65,5 +65,5 @@ TEST_F(GeneratorTest, Generator_Constructor) {
TEST_F(GeneratorTest, Generator_Run) {
EXPECT_NE(gen, nullptr);
gen->Run("test.out");
- EXPECT_TRUE(gen->GetCount() == 2);
+ EXPECT_EQ(gen->GetCount(), 2);
}