Only consider public members
Otherwise the compiler would complain about accessibility anyways.
This commit is contained in:
parent
13dfac3991
commit
e29dcce40f
|
@ -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"
|
||||
|
|
|
@ -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";
|
||||
};
|
||||
|
||||
/*!
|
||||
|
|
Loading…
Reference in New Issue