Only consider public members

Otherwise the compiler would complain about accessibility
anyways.
This commit is contained in:
Martchus 2017-11-09 00:07:40 +01:00
parent 13dfac3991
commit e29dcce40f
2 changed files with 9 additions and 2 deletions

View File

@ -103,7 +103,9 @@ void JsonSerializationCodeGenerator::generate(ostream &os) const
}
os << " // push members\n";
for (const clang::FieldDecl *field : relevantClass.record->fields()) {
os << " push(reflectable." << field->getName() << ", \"" << field->getName() << "\", value, allocator);\n";
if (field->getAccess() == clang::AS_public) {
os << " push(reflectable." << field->getName() << ", \"" << field->getName() << "\", value, allocator);\n";
}
}
os << "}\n";
@ -126,7 +128,9 @@ void JsonSerializationCodeGenerator::generate(ostream &os) const
" }\n"
" // pull members\n";
for (const clang::FieldDecl *field : relevantClass.record->fields()) {
os << " pull(reflectable." << field->getName() << ", \"" << field->getName() << "\", value, errors);\n";
if (field->getAccess() == clang::AS_public) {
os << " pull(reflectable." << field->getName() << ", \"" << field->getName() << "\", value, errors);\n";
}
}
os << " // restore error context for previous record\n"
" if (errors) {\n"

View File

@ -23,6 +23,9 @@ struct TestStruct : public JsonSerializable<TestStruct> {
int someInt = 0;
string someString = "foo";
string yetAnotherString = "bar";
private:
string privateString = "not going to be serialized";
};
/*!