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
+4 -4
View File
@@ -97,8 +97,8 @@ void TextStyle::checkContentDependencies(Context& ctx, const Dependency& dep) co
alignment.initDependencies(ctx, dep);
}
template <typename T> void reflect_content(T& tag, const TextStyle& ts) {}
template <> void reflect_content(GetMember& tag, const TextStyle& ts) {
template <typename T> void reflect_content(T& handler, const TextStyle& ts) {}
template <> void reflect_content(GetMember& handler, const TextStyle& ts) {
REFLECT_N("content_width", ts.content_width);
REFLECT_N("content_height", ts.content_height);
REFLECT_N("content_lines", ts.content_lines);
@@ -127,7 +127,7 @@ IMPLEMENT_REFLECTION(TextStyle) {
REFLECT(line_height_line_max);
REFLECT(paragraph_height);
REFLECT(direction);
reflect_content(tag, *this);
reflect_content(handler, *this);
}
// ----------------------------------------------------------------------------- : TextValue
@@ -147,7 +147,7 @@ bool TextValue::update(Context& ctx) {
}
IMPLEMENT_REFLECTION_NAMELESS(TextValue) {
if (fieldP->save_value || tag.scripting() || tag.reading()) REFLECT_NAMELESS(value);
if (fieldP->save_value || !handler.isWriting) REFLECT_NAMELESS(value);
}
// ----------------------------------------------------------------------------- : FakeTextValue