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
+6 -3
View File
@@ -47,7 +47,6 @@ IMPLEMENT_REFLECTION(Field) {
REFLECT(type);
}
REFLECT(name);
REFLECT_IF_READING name = canonical_name_form(name);
REFLECT(caption);
REFLECT(description);
REFLECT_N("icon", icon_filename);
@@ -63,8 +62,12 @@ IMPLEMENT_REFLECTION(Field) {
REFLECT(card_list_name);
REFLECT(sort_script);
REFLECT_N("card_list_alignment", card_list_align);
REFLECT_IF_READING if(caption.empty()) caption = name_to_caption(name);
REFLECT_IF_READING if(card_list_name.empty()) card_list_name = capitalize(caption);
}
void Field::after_reading(Version ver) {
name = canonical_name_form(name);
if(caption.empty()) caption = name_to_caption(name);
if(card_list_name.empty()) card_list_name = capitalize(caption);
}
template <>