void CBodyGeneratorBase::GenStructure(std::ofstream& stream,
const Structure& st) {
GenStructureDeclaration(stream, st);
- GenStructureParcelTo(stream, st);
- GenStructureParcelFrom(stream, st);
+ GenStructureParcelSerializer(stream, st);
+ GenStructureParcelDeserializer(stream, st);
GenStructureConstructor(stream, st);
GenStructureDestructor(stream, st);
GenStructureCloner(stream, st);
);
}
-void CBodyGeneratorBase::GenStructureParcelTo(std::ofstream& stream,
+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" \
+ " rpc_port_##_h h = data;\n" \
"\n" \
" if (!parcel || !h) {\n" \
" LOGE(\"Invalid parameter\");\n" \
"}\n";
stream << NLine(1);
- stream << SmartIndent(GenTemplateString(block,
- [&]()->std::string {
- return st.GetID();
- },
- [&]()->std::string {
- return st.GetID();
- },
+ stream << SmartIndent(GenTemplateString(ReplaceAll(block, "##", st.GetID()),
[&]()->std::string {
std::string str;
for (auto& i : st.GetElements().GetElms()) {
);
}
-void CBodyGeneratorBase::GenStructureParcelFrom(std::ofstream& stream,
+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" \
+ " rpc_port_##_h h = data;\n" \
"\n"
" if (!parcel || !h) {\n" \
" LOGE(\"Invalid parameter\");\n" \
"}\n";
stream << NLine(1);
- stream << SmartIndent(GenTemplateString(block,
- [&]()->std::string {
- return st.GetID();
- },
- [&]()->std::string {
- return st.GetID();
- },
+ stream << SmartIndent(GenTemplateString(ReplaceAll(block, "##", st.GetID()),
[&]()->std::string {
std::string str;
for (auto& i : st.GetElements().GetElms()) {
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" \
" return -1;\n" \
" }\n" \
"\n" \
- " handle = calloc(1, sizeof(struct $$_s));\n" \
+ " handle = calloc(1, sizeof(struct ##_s));\n" \
" if (!handle) {\n" \
" LOGE(\"Out of memory\");\n" \
" return -1;\n" \
" }\n" \
"\n"
- " handle->parcelable.to = __$$_to;\n" \
- " handle->parcelable.from = __$$_from;\n" \
+ " handle->parcelable.to = __##_to;\n" \
+ " handle->parcelable.from = __##_from;\n" \
"\n"
" *h = handle;\n"
"\n"
"}\n";
stream << NLine(1);
- stream << SmartIndent(GenTemplateString(block,
- [&]()->std::string {
- return st.GetID();
- },
- [&]()->std::string {
- return st.GetID();
- },
- [&]()->std::string {
- return st.GetID();
- },
- [&]()->std::string {
- return st.GetID();
- },
- [&]()->std::string {
- return st.GetID();
- },
- [&]()->std::string {
- return st.GetID();
- }
- )
- );
+ stream << SmartIndent(ReplaceAll(block, "##", st.GetID()));
}
void CBodyGeneratorBase::GenStructureDestructor(std::ofstream& stream,
const Structure& st) {
const char block[] =
- "int rpc_port_destroy_$$(rpc_port_$$_h h)\n" \
+ "int rpc_port_destroy_##(rpc_port_##_h h)\n" \
"{\n" \
" if (!h) {\n" \
" LOGE(\"Invalid parameter\");\n" \
"}\n";
stream << NLine(1);
- stream << SmartIndent(GenTemplateString(block,
- [&]()->std::string {
- return st.GetID();
- },
- [&]()->std::string {
- return st.GetID();
- },
+ stream << SmartIndent(GenTemplateString(ReplaceAll(block, "##", st.GetID()),
[&]()->std::string {
std::string str;
for (auto& i : st.GetElements().GetElms()) {
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" \
+ " rpc_port_##_h handle = NULL;\n" \
"\n" \
" if (!h || !clone) {\n" \
" LOGE(\"Invalid parameter\");\n" \
" return -1;\n" \
" }\n" \
"\n" \
- " rpc_port_create_$$(&handle);\n" \
+ " rpc_port_create_##(&handle);\n" \
" if (!handle) {\n" \
- " LOGE(\"Failed to create $$ handle\");\n" \
+ " LOGE(\"Failed to create ## handle\");\n" \
" return -1;\n" \
" }\n" \
"$$" \
"}\n";
stream << NLine(1);
- stream << SmartIndent(GenTemplateString(block,
- [&]()->std::string {
- return st.GetID();
- },
- [&]()->std::string {
- return st.GetID();
- },
- [&]()->std::string {
- return st.GetID();
- },
- [&]()->std::string {
- return st.GetID();
- },
- [&]()->std::string {
- return st.GetID();
- },
- [&]()->std::string {
- return st.GetID();
- },
+ stream << SmartIndent(GenTemplateString(ReplaceAll(block, "##", st.GetID()),
[&]()->std::string {
std::string str;
for (auto& i : st.GetElements().GetElms()) {