Cleaned up the reflection code a bit

* Renamed 'tag' variable to 'handler'
* Removed addAlias stuff, instead check for matching names with if statements
* Added after_reading function that is called by Reader after reading a complete object. This generalizes Packaged::validate, which is now also called via this mechanism.
* Removed some backwards compatibility with <0.3.0 for templates
This commit is contained in:
Twan van Laarhoven
2020-04-26 15:33:59 +02:00
parent 4bebd48786
commit 40d78edf0f
32 changed files with 248 additions and 281 deletions
+14 -14
View File
@@ -38,24 +38,24 @@ IMPLEMENT_REFLECTION(PackType) {
REFLECT(select);
REFLECT(filter);
REFLECT(items);
REFLECT_IF_READING {
if (select == SELECT_AUTO) {
if (filter) select = SELECT_NO_REPLACE;
else if (!items.empty()) select = SELECT_ALL;
}
if (indeterminate(summary)) {
if (filter) summary = true;
else if (!items.empty()) summary = false;
}
if (indeterminate(selectable)) {
if (filter) selectable = false;
else if (!items.empty()) selectable = true;
}
}
void after_reading(PackType& pt, Version) {
if (pt.select == SELECT_AUTO) {
if (pt.filter) pt.select = SELECT_NO_REPLACE;
else if (!pt.items.empty()) pt.select = SELECT_ALL;
}
if (indeterminate(pt.summary)) {
if (pt.filter) pt.summary = true;
else if (!pt.items.empty()) pt.summary = false;
}
if (indeterminate(pt.selectable)) {
if (pt.filter) pt.selectable = false;
else if (!pt.items.empty()) pt.selectable = true;
}
}
IMPLEMENT_REFLECTION(PackItem) {
if (!tag.isComplex()) {
REFLECT_IF_READING_SINGLE_VALUE {
REFLECT_NAMELESS(name);
} else {
REFLECT(name);