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
+9 -3
View File
@@ -74,6 +74,8 @@ class Field : public IntrusivePtrVirtualBase {
private:
DECLARE_REFLECTION_VIRTUAL();
virtual void after_reading(Version ver);
friend void after_reading(Field& s, Version ver);
};
template <>
@@ -82,6 +84,10 @@ inline void update_index(FieldP& f, size_t index) {
f->index = index;
}
inline void after_reading(Field& f, Version ver) {
f.after_reading(ver);
}
inline String type_name(const Field&) {
return _TYPE_("field");
}
@@ -258,7 +264,7 @@ inline String type_name(const Value&) {
// ----------------------------------------------------------------------------- : Utilities
#define DECLARE_FIELD_TYPE(Type) \
DECLARE_REFLECTION(); public: \
DECLARE_REFLECTION_OVERRIDE(); public: \
virtual ValueP newValue(const FieldP& thisP) const; \
virtual StyleP newStyle(const FieldP& thisP) const; \
virtual String typeName() const
@@ -284,14 +290,14 @@ inline String type_name(const Value&) {
}
#define DECLARE_STYLE_TYPE(Type) \
DECLARE_REFLECTION(); public: \
DECLARE_REFLECTION_OVERRIDE(); public: \
DECLARE_HAS_FIELD(Type) \
virtual StyleP clone() const; \
virtual ValueViewerP makeViewer(DataViewer& parent, const StyleP& thisP); \
virtual ValueViewerP makeEditor(DataEditor& parent, const StyleP& thisP)
#define DECLARE_VALUE_TYPE(Type,ValueType_) \
DECLARE_REFLECTION(); public: \
DECLARE_REFLECTION_OVERRIDE(); public: \
DECLARE_HAS_FIELD(Type) \
virtual ValueP clone() const; \
virtual String toString() const; \