diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/XML.cpp | 2 | ||||
-rw-r--r-- | src/core/common/Argument.cpp | 76 | ||||
-rw-r--r-- | src/core/common/Argument.hpp | 18 | ||||
-rw-r--r-- | src/core/common/Property.hpp | 18 | ||||
-rw-r--r-- | src/core/common/Rtti.cpp | 14 | ||||
-rw-r--r-- | src/core/common/Rtti.hpp | 10 | ||||
-rw-r--r-- | src/core/common/Variant.cpp | 32 | ||||
-rw-r--r-- | src/core/common/Variant.hpp | 6 | ||||
-rw-r--r-- | src/core/common/VariantConverter.cpp | 48 | ||||
-rw-r--r-- | src/core/common/VariantConverter.hpp | 8 | ||||
-rw-r--r-- | src/core/managed/Managed.cpp | 8 | ||||
-rw-r--r-- | src/core/managed/Managed.hpp | 6 | ||||
-rw-r--r-- | src/core/managed/Manager.cpp | 14 | ||||
-rw-r--r-- | src/core/model/Document.cpp | 34 | ||||
-rw-r--r-- | src/core/model/Domain.cpp | 10 | ||||
-rw-r--r-- | src/core/model/Node.cpp | 93 | ||||
-rw-r--r-- | src/core/model/Node.hpp | 4 | ||||
-rw-r--r-- | src/core/model/Project.cpp | 2 | ||||
-rw-r--r-- | src/core/model/RootNode.cpp | 6 | ||||
-rw-r--r-- | src/core/model/Typesystem.cpp | 6 | ||||
-rw-r--r-- | src/core/parser/ParserScope.cpp | 20 | ||||
-rw-r--r-- | src/core/parser/ParserScope.hpp | 14 | ||||
-rw-r--r-- | src/core/resource/ResourceManager.cpp | 6 |
23 files changed, 253 insertions, 202 deletions
diff --git a/src/core/XML.cpp b/src/core/XML.cpp index 9ca808d..722c490 100644 --- a/src/core/XML.cpp +++ b/src/core/XML.cpp @@ -123,7 +123,7 @@ namespace RttiTypes RttiBuilder<xml::Element>("XMLElement") .parent(&XMLNode) .composedOf(&XMLNode) - .property("name", {RttiTypes::String, + .property("name", {&RttiTypes::String, {[](const xml::Element *obj) { return Variant::fromString(obj->name); }}}); diff --git a/src/core/common/Argument.cpp b/src/core/common/Argument.cpp index 385bae1..bfe74a4 100644 --- a/src/core/common/Argument.cpp +++ b/src/core/common/Argument.cpp @@ -27,161 +27,161 @@ namespace ousia { /* Class Argument */ -Argument::Argument(std::string name, const Rtti &type, const Rtti &innerType, +Argument::Argument(std::string name, const Rtti *type, const Rtti *innerType, Variant defaultValue, bool hasDefaultValue) : name(std::move(name)), - type(&type), - innerType(&innerType), + type(type), + innerType(innerType), defaultValue(std::move(defaultValue)), hasDefaultValue(hasDefaultValue) { } -Argument::Argument(std::string name, const Rtti &type, Variant defaultValue) - : Argument(std::move(name), type, RttiTypes::None, defaultValue, true) +Argument::Argument(std::string name, const Rtti *type, Variant defaultValue) + : Argument(std::move(name), type, &RttiTypes::None, defaultValue, true) { } -Argument::Argument(std::string name, const Rtti &type) - : Argument(std::move(name), type, RttiTypes::None, nullptr, false) +Argument::Argument(std::string name, const Rtti *type) + : Argument(std::move(name), type, &RttiTypes::None, nullptr, false) { } Argument Argument::Any(std::string name) { - return Argument{name, RttiTypes::None, RttiTypes::None, nullptr, false}; + return Argument{name, &RttiTypes::None, &RttiTypes::None, nullptr, false}; } Argument Argument::Any(std::string name, Variant defaultValue) { - return Argument{name, RttiTypes::None, RttiTypes::None, defaultValue, true}; + return Argument{name, &RttiTypes::None, &RttiTypes::None, defaultValue, true}; } Argument Argument::Bool(std::string name) { - return Argument{name, RttiTypes::Bool}; + return Argument{name, &RttiTypes::Bool}; } Argument Argument::Bool(std::string name, Variant::boolType defaultValue) { - return Argument{name, RttiTypes::Bool, defaultValue}; + return Argument{name, &RttiTypes::Bool, defaultValue}; } Argument Argument::Int(std::string name) { - return Argument{name, RttiTypes::Int}; + return Argument{name, &RttiTypes::Int}; } Argument Argument::Int(std::string name, Variant::intType defaultValue) { - return Argument{name, RttiTypes::Int, defaultValue}; + return Argument{name, &RttiTypes::Int, defaultValue}; } Argument Argument::Double(std::string name) { - return Argument{name, RttiTypes::Double}; + return Argument{name, &RttiTypes::Double}; } Argument Argument::Double(std::string name, Variant::doubleType defaultValue) { - return Argument{name, RttiTypes::Double, defaultValue}; + return Argument{name, &RttiTypes::Double, defaultValue}; } Argument Argument::String(std::string name) { - return Argument{name, RttiTypes::String}; + return Argument{name, &RttiTypes::String}; } Argument Argument::String(std::string name, const Variant::stringType &defaultValue) { - return Argument{name, RttiTypes::String, Variant::fromString(defaultValue)}; + return Argument{name, &RttiTypes::String, Variant::fromString(defaultValue)}; } -Argument Argument::Object(std::string name, const Rtti &type) +Argument Argument::Object(std::string name, const Rtti *type) { - return Argument(std::move(name), type, RttiTypes::None, + return Argument(std::move(name), type, &RttiTypes::None, Variant::fromObject(nullptr), false); } -Argument Argument::Object(std::string name, const Rtti &type, std::nullptr_t) +Argument Argument::Object(std::string name, const Rtti *type, std::nullptr_t) { - return Argument(std::move(name), type, RttiTypes::None, + return Argument(std::move(name), type, &RttiTypes::None, Variant::fromObject(nullptr), true); } Argument Argument::Function(std::string name) { - return Argument(std::move(name), RttiTypes::Function); + return Argument(std::move(name), &RttiTypes::Function); } Argument Argument::Function(std::string name, Variant::functionType defaultValue) { - return Argument(std::move(name), RttiTypes::Function, + return Argument(std::move(name), &RttiTypes::Function, Variant::fromFunction(defaultValue)); } Argument Argument::Array(std::string name) { - return Argument(std::move(name), RttiTypes::Array); + return Argument(std::move(name), &RttiTypes::Array); } Argument Argument::Array(std::string name, const Variant::arrayType &defaultValue) { - return Argument(std::move(name), RttiTypes::Array, defaultValue); + return Argument(std::move(name), &RttiTypes::Array, defaultValue); } -Argument Argument::Array(std::string name, const Rtti &innerType) +Argument Argument::Array(std::string name, const Rtti *innerType) { - return Argument(std::move(name), RttiTypes::Array, innerType, nullptr, + return Argument(std::move(name), &RttiTypes::Array, innerType, nullptr, false); } -Argument Argument::Array(std::string name, const Rtti &innerType, +Argument Argument::Array(std::string name, const Rtti *innerType, const Variant::arrayType &defaultValue) { - return Argument(std::move(name), RttiTypes::Array, innerType, defaultValue, + return Argument(std::move(name), &RttiTypes::Array, innerType, defaultValue, true); } Argument Argument::Map(std::string name) { - return Argument(std::move(name), RttiTypes::Map); + return Argument(std::move(name), &RttiTypes::Map); } Argument Argument::Map(std::string name, const Variant::mapType &defaultValue) { - return Argument(std::move(name), RttiTypes::Map, defaultValue); + return Argument(std::move(name), &RttiTypes::Map, defaultValue); } -Argument Argument::Map(std::string name, const Rtti &innerType) +Argument Argument::Map(std::string name, const Rtti *innerType) { - return Argument(std::move(name), RttiTypes::Map, innerType, nullptr, false); + return Argument(std::move(name), &RttiTypes::Map, innerType, nullptr, false); } -Argument Argument::Map(std::string name, const Rtti &innerType, +Argument Argument::Map(std::string name, const Rtti *innerType, const Variant::mapType &defaultValue) { - return Argument(std::move(name), RttiTypes::Map, innerType, defaultValue, + return Argument(std::move(name), &RttiTypes::Map, innerType, defaultValue, true); } Argument Argument::Cardinality(std::string name) { - return Argument{name, RttiTypes::Cardinality}; + return Argument{name, &RttiTypes::Cardinality}; } Argument Argument::Cardinality(std::string name, Variant::cardinalityType defaultValue) { - return Argument{name, RttiTypes::Cardinality, defaultValue}; + return Argument{name, &RttiTypes::Cardinality, defaultValue}; } bool Argument::validate(Variant &var, Logger &logger) const { - if (!VariantConverter::convert(var, *type, *innerType, logger, + if (!VariantConverter::convert(var, type, innerType, logger, VariantConverter::Mode::SAFE)) { if (hasDefaultValue) { var = defaultValue; diff --git a/src/core/common/Argument.hpp b/src/core/common/Argument.hpp index ea68e3c..679b4a5 100644 --- a/src/core/common/Argument.hpp +++ b/src/core/common/Argument.hpp @@ -93,7 +93,7 @@ private: * @param hasDefault indicates whether the defaultValue actually should be * used. */ - Argument(std::string name, const Rtti &type, const Rtti &innerType, + Argument(std::string name, const Rtti *type, const Rtti *innerType, Variant defaultValue, bool hasDefault); /** @@ -105,7 +105,7 @@ private: * expected. * @param defaultValue is the default value to be used. */ - Argument(std::string name, const Rtti &type, Variant defaultValue); + Argument(std::string name, const Rtti *type, Variant defaultValue); /** * Private constructor used to build an argument describing a primitive type @@ -115,7 +115,7 @@ private: * @param variantType is the variant type of the argument that is to be * expected. */ - Argument(std::string name, const Rtti &type); + Argument(std::string name, const Rtti *type); public: /** @@ -230,7 +230,7 @@ public: * "isa" function returns true for the given type are be accepted. * @return a new Argument instance. */ - static Argument Object(std::string name, const Rtti &type); + static Argument Object(std::string name, const Rtti *type); /** * Named constructor for an object argument with default value. The default @@ -246,7 +246,7 @@ public: * cannot be stored. * @return a new Argument instance. */ - static Argument Object(std::string name, const Rtti &type, + static Argument Object(std::string name, const Rtti *type, std::nullptr_t defaultValue); /** @@ -303,7 +303,7 @@ public: * forced to be of this type. * @return a new Argument instance. */ - static Argument Array(std::string name, const Rtti &innerType); + static Argument Array(std::string name, const Rtti *innerType); /** * Named constructor for an array argument of objects of the given RTTI @@ -317,7 +317,7 @@ public: * @param defaultValue is the default value to be used in case this argument * is not supplied. */ - static Argument Array(std::string name, const Rtti &innerType, + static Argument Array(std::string name, const Rtti *innerType, const Variant::arrayType &defaultValue); /** @@ -352,7 +352,7 @@ public: * to be of this type. * @return a new Argument instance. */ - static Argument Map(std::string name, const Rtti &innerType); + static Argument Map(std::string name, const Rtti *innerType); /** * Named constructor for a map argument with default value and a given inner @@ -366,7 +366,7 @@ public: * is not supplied. * @return a new Argument instance. */ - static Argument Map(std::string name, const Rtti &innerType, + static Argument Map(std::string name, const Rtti *innerType, const Variant::mapType &defaultValue); /** diff --git a/src/core/common/Property.hpp b/src/core/common/Property.hpp index 10db869..546061c 100644 --- a/src/core/common/Property.hpp +++ b/src/core/common/Property.hpp @@ -67,21 +67,21 @@ struct PropertyType { * Outer type, may be any Rtti instance. If set to RttiTypes::None, any * outer type is acceptable. */ - const Rtti &type; + const Rtti *type; /** * Describes the inner type of the property used when the outer type is a * container type such as RttiTypes::Array or RttiTypes::Map. If set to * RttiTypes::None any inner type is acceptable. */ - const Rtti &innerType; + const Rtti *innerType; /** * Creates a new instance of the PropertyType class with both inner and * outer type being set to RttiTypes::None and thus allowing any type to be * represented by this property. */ - PropertyType() : type(RttiTypes::None), innerType(RttiTypes::None){}; + PropertyType() : type(&RttiTypes::None), innerType(&RttiTypes::None){}; /** * Creates a new instance of the PropertyType class with the given outer @@ -91,8 +91,8 @@ struct PropertyType { * be any Rtti instances or RttiTypes::None, in which case all types are * allowed. */ - PropertyType(const Rtti &type) - : type(type), innerType(RttiTypes::None){}; + PropertyType(const Rtti *type) + : type(type), innerType(&RttiTypes::None){}; /** * Creates a new instance of the PropertyType class with the given outer and @@ -105,7 +105,7 @@ struct PropertyType { * relevant if the outer type is set to a basic container type, namely * RttiTypes::Array or RttiTypes::Map. */ - PropertyType(const Rtti &type, const Rtti &innerType) + PropertyType(const Rtti *type, const Rtti *innerType) : type(type), innerType(innerType){}; }; @@ -396,7 +396,7 @@ public: * * @return the PropertyType instance describing the type of this property. */ - const PropertyType &getType() const { return *type; } + const PropertyType *getType() const { return type.get(); } /** * Returns the value of the property for the given object. @@ -454,7 +454,7 @@ public: * @param setter is a Setter for writing the described property for objects * of type T. */ - Property(const Rtti &type, const Getter<T> &getter, + Property(const Rtti *type, const Getter<T> &getter, const Setter<T> &setter = Setter<T>{}) : PropertyDescriptor( PropertyType{type}, @@ -477,7 +477,7 @@ public: * @param setter is a Setter for writing the described property for objects * of type T. */ - Property(const Rtti &type, const Rtti &innerType, + Property(const Rtti *type, const Rtti *innerType, const Getter<T> &getter, const Setter<T> &setter = Setter<T>{}) : PropertyDescriptor( PropertyType{type, innerType}, diff --git a/src/core/common/Rtti.cpp b/src/core/common/Rtti.cpp index acc98a7..7c353d5 100644 --- a/src/core/common/Rtti.cpp +++ b/src/core/common/Rtti.cpp @@ -34,14 +34,14 @@ void RttiStore::store(const std::type_info &native, const Rtti *rtti) table().emplace(std::type_index{native}, rtti); } -const Rtti &RttiStore::lookup(const std::type_info &native) +const Rtti *RttiStore::lookup(const std::type_info &native) { const auto &tbl = table(); auto it = tbl.find(std::type_index{native}); if (it == tbl.end()) { - return RttiTypes::None; + return &RttiTypes::None; } else { - return *(it->second); + return it->second; } } @@ -120,10 +120,10 @@ void Rtti::initialize() const } } -bool Rtti::isa(const Rtti &other) const +bool Rtti::isa(const Rtti *other) const { initialize(); - return parents.count(&other) > 0; + return parents.count(other) > 0; } bool Rtti::isOneOf(const RttiSet &others) const @@ -158,10 +158,10 @@ RttiSet Rtti::setIntersection(const RttiSet &s1, const RttiSet &s2) return res; } -bool Rtti::composedOf(const Rtti &other) const +bool Rtti::composedOf(const Rtti *other) const { initialize(); - return compositeTypes.count(&other) > 0; + return compositeTypes.count(other) > 0; } const RttiMethodMap &Rtti::getMethods() const diff --git a/src/core/common/Rtti.hpp b/src/core/common/Rtti.hpp index f371494..de9f3f6 100644 --- a/src/core/common/Rtti.hpp +++ b/src/core/common/Rtti.hpp @@ -127,7 +127,7 @@ public: * Looks up the type information stored for the given native type * information. */ - static const Rtti &lookup(const std::type_info &native); + static const Rtti *lookup(const std::type_info &native); }; /** @@ -381,7 +381,7 @@ public: * @return true if this type (directly or indirectly) has the given other * type as parent or equals the other type. */ - bool isa(const Rtti &other) const; + bool isa(const Rtti *other) const; /** * Returns true if this Rtti instance is one of the given types. @@ -421,7 +421,7 @@ public: * @param other is the other type for which should be checked whether this * type is directly or indirectly composed of it. */ - bool composedOf(const Rtti &other) const; + bool composedOf(const Rtti *other) const; /** * Returns all methods that are registered for this type (and the parent @@ -489,7 +489,7 @@ public: * @tparam T is the C++ type for which the type information should be returned. */ template <typename T> -inline const Rtti &typeOf() +inline const Rtti *typeOf() { return RttiStore::lookup(typeid(T)); } @@ -505,7 +505,7 @@ inline const Rtti &typeOf() * returned. */ template <typename T> -inline const Rtti &typeOf(const T &obj) +inline const Rtti *typeOf(const T &obj) { return RttiStore::lookup(typeid(obj)); } diff --git a/src/core/common/Variant.cpp b/src/core/common/Variant.cpp index 0c7fceb..836fed3 100644 --- a/src/core/common/Variant.cpp +++ b/src/core/common/Variant.cpp @@ -148,12 +148,12 @@ Variant::arrayType Variant::toArray() const { ExceptionLogger logger; Variant res{*this}; - VariantConverter::toArray(res, RttiTypes::None, logger, + VariantConverter::toArray(res, &RttiTypes::None, logger, VariantConverter::Mode::ALL); return res.asArray(); } -Variant::arrayType Variant::toArray(const Rtti &innerType) const +Variant::arrayType Variant::toArray(const Rtti *innerType) const { ExceptionLogger logger; Variant res{*this}; @@ -166,12 +166,12 @@ Variant::mapType Variant::toMap() const { ExceptionLogger logger; Variant res{*this}; - VariantConverter::toMap(res, RttiTypes::None, logger, + VariantConverter::toMap(res, &RttiTypes::None, logger, VariantConverter::Mode::ALL); return res.asMap(); } -Variant::mapType Variant::toMap(const Rtti &innerType) const +Variant::mapType Variant::toMap(const Rtti *innerType) const { ExceptionLogger logger; Variant res{*this}; @@ -190,34 +190,34 @@ Variant::cardinalityType Variant::toCardinality() const /* Type management */ -const Rtti &Variant::getRtti() const +const Rtti *Variant::getRtti() const { switch (meta.getType()) { case VariantType::NULLPTR: - return RttiTypes::Nullptr; + return &RttiTypes::Nullptr; case VariantType::BOOL: - return RttiTypes::Bool; + return &RttiTypes::Bool; case VariantType::INT: - return RttiTypes::Int; + return &RttiTypes::Int; case VariantType::DOUBLE: - return RttiTypes::Double; + return &RttiTypes::Double; case VariantType::STRING: case VariantType::MAGIC: - return RttiTypes::String; + return &RttiTypes::String; case VariantType::ARRAY: - return RttiTypes::Array; + return &RttiTypes::Array; case VariantType::MAP: - return RttiTypes::Map; + return &RttiTypes::Map; case VariantType::CARDINALITY: - return RttiTypes::Cardinality; + return &RttiTypes::Cardinality; case VariantType::FUNCTION: - return RttiTypes::Function; + return &RttiTypes::Function; case VariantType::OBJECT: { Variant::objectType o = asObject(); - return (o == nullptr) ? RttiTypes::Nullptr : o->type(); + return (o == nullptr) ? &RttiTypes::Nullptr : o->type(); } } - return RttiTypes::None; + return &RttiTypes::None; } /* Output stream operators */ diff --git a/src/core/common/Variant.hpp b/src/core/common/Variant.hpp index 76f4506..6eae7e1 100644 --- a/src/core/common/Variant.hpp +++ b/src/core/common/Variant.hpp @@ -929,7 +929,7 @@ public: * to. * @return the value of the variant as array. */ - arrayType toArray(const Rtti &innerType) const; + arrayType toArray(const Rtti *innerType) const; /** * Returns the value of the Variant as map. @@ -946,7 +946,7 @@ public: * to. * @return the value of the variant as map. */ - mapType toMap(const Rtti &innerType) const; + mapType toMap(const Rtti *innerType) const; /** * Returns the value of the Variant as cardinality. @@ -1125,7 +1125,7 @@ public: * or RttiTypes::Function or -- in case an object is stored inside the * variant -- the Rtti of that object. */ - const Rtti &getRtti() const; + const Rtti *getRtti() const; /** * Returns the name of the given variant type as C-style string. diff --git a/src/core/common/VariantConverter.cpp b/src/core/common/VariantConverter.cpp index 29b4ef3..271fe75 100644 --- a/src/core/common/VariantConverter.cpp +++ b/src/core/common/VariantConverter.cpp @@ -305,7 +305,7 @@ bool VariantConverter::toString(Variant &var, Logger &logger, Mode mode) std::stringstream ss; ss << "<object " << obj.get(); if (obj.get() != nullptr) { - ss << " (" << obj->type().name << ")"; + ss << " (" << obj->type()->name << ")"; } ss << ">"; var = ss.str().c_str(); @@ -330,7 +330,7 @@ bool VariantConverter::toString(Variant &var, Logger &logger, Mode mode) return false; } -bool VariantConverter::toArray(Variant &var, const Rtti &innerType, +bool VariantConverter::toArray(Variant &var, const Rtti *innerType, Logger &logger, Mode mode) { // If unsafe conversions are allowed, encapsulate the given variant in an @@ -343,7 +343,7 @@ bool VariantConverter::toArray(Variant &var, const Rtti &innerType, if (var.isArray()) { // If no specific inner type is given, conversion is successful at this // point - if (&innerType == &RttiTypes::None) { + if (innerType == &RttiTypes::None) { return true; } @@ -351,7 +351,7 @@ bool VariantConverter::toArray(Variant &var, const Rtti &innerType, // failures to do so bool res = true; for (Variant &v : var.asArray()) { - res = convert(v, innerType, RttiTypes::None, logger, mode) & res; + res = convert(v, innerType, &RttiTypes::None, logger, mode) & res; } return res; } @@ -362,14 +362,14 @@ bool VariantConverter::toArray(Variant &var, const Rtti &innerType, return false; } -bool VariantConverter::toMap(Variant &var, const Rtti &innerType, +bool VariantConverter::toMap(Variant &var, const Rtti *innerType, Logger &logger, Mode mode) { // Make sure the variant is a map if (var.isMap()) { // If no specific inner type is given, conversion is successful at this // point - if (&innerType == &RttiTypes::None) { + if (innerType == &RttiTypes::None) { return true; } @@ -377,7 +377,7 @@ bool VariantConverter::toMap(Variant &var, const Rtti &innerType, // all failures to do so bool res = true; for (auto &e : var.asMap()) { - res = convert(e.second, innerType, RttiTypes::None, logger, mode) & + res = convert(e.second, innerType, &RttiTypes::None, logger, mode) & res; } return res; @@ -517,14 +517,14 @@ bool VariantConverter::toFunction(Variant &var, Logger &logger) return false; } -bool VariantConverter::convert(Variant &var, const Rtti &type, - const Rtti &innerType, Logger &logger, Mode mode) +bool VariantConverter::convert(Variant &var, const Rtti *type, + const Rtti *innerType, Logger &logger, Mode mode) { // Check for simple Variant types - if (&type == &RttiTypes::None) { + if (type == &RttiTypes::None) { return true; // Everything is fine if no specific type was // requested - } else if (&type == &RttiTypes::Nullptr) { + } else if (type == &RttiTypes::Nullptr) { // Make sure the variant is set to null if (!var.isNull()) { logger.error(msgUnexpectedType(var, VariantType::NULLPTR)); @@ -532,21 +532,21 @@ bool VariantConverter::convert(Variant &var, const Rtti &type, return false; } return true; - } else if (&type == &RttiTypes::Bool) { + } else if (type == &RttiTypes::Bool) { return toBool(var, logger, mode); - } else if (&type == &RttiTypes::Int) { + } else if (type == &RttiTypes::Int) { return toInt(var, logger, mode); - } else if (&type == &RttiTypes::Double) { + } else if (type == &RttiTypes::Double) { return toDouble(var, logger, mode); - } else if (&type == &RttiTypes::String) { + } else if (type == &RttiTypes::String) { return toString(var, logger, mode); - } else if (&type == &RttiTypes::Array) { + } else if (type == &RttiTypes::Array) { return toArray(var, innerType, logger, mode); - } else if (&type == &RttiTypes::Map) { + } else if (type == &RttiTypes::Map) { return toMap(var, innerType, logger, mode); - } else if (&type == &RttiTypes::Cardinality) { + } else if (type == &RttiTypes::Cardinality) { return toCardinality(var, logger, mode); - } else if (&type == &RttiTypes::Function) { + } else if (type == &RttiTypes::Function) { return toFunction(var, logger); } @@ -559,19 +559,19 @@ bool VariantConverter::convert(Variant &var, const Rtti &type, } // Make sure the object type is correct - if (!var.getRtti().isa(type)) { - logger.error(std::string("Expected object of type ") + type.name + - " but got object of type " + var.getRtti().name); + if (!var.getRtti()->isa(type)) { + logger.error(std::string("Expected object of type ") + type->name + + " but got object of type " + var.getRtti()->name); var.setObject(nullptr); return false; } return true; } -bool VariantConverter::convert(Variant &var, const Rtti &type, Logger &logger, +bool VariantConverter::convert(Variant &var, const Rtti *type, Logger &logger, Mode mode) { - return convert(var, type, RttiTypes::None, logger, mode); + return convert(var, type, &RttiTypes::None, logger, mode); } } diff --git a/src/core/common/VariantConverter.hpp b/src/core/common/VariantConverter.hpp index 92cc40a..26278eb 100644 --- a/src/core/common/VariantConverter.hpp +++ b/src/core/common/VariantConverter.hpp @@ -161,7 +161,7 @@ public: * @return true if the operation was successful, false otherwise. In any * case the input/output parameter "var" will have the requested type. */ - static bool toArray(Variant &var, const Rtti &innerType, Logger &logger, + static bool toArray(Variant &var, const Rtti *innerType, Logger &logger, Mode mode = Mode::SAFE); /** @@ -180,7 +180,7 @@ public: * @return true if the operation was successful, false otherwise. In any * case the input/output parameter "var" will have the requested type. */ - static bool toMap(Variant &var, const Rtti &innerType, Logger &logger, + static bool toMap(Variant &var, const Rtti *innerType, Logger &logger, Mode mode = Mode::SAFE); /** @@ -242,7 +242,7 @@ public: * @return true if the operation was successful, false otherwise. In any * case the input/output parameter "var" will have the requested type. */ - static bool convert(Variant &var, const Rtti &type, const Rtti &innerType, + static bool convert(Variant &var, const Rtti *type, const Rtti *innerType, Logger &logger, Mode mode = Mode::SAFE); /** @@ -261,7 +261,7 @@ public: * @return true if the operation was successful, false otherwise. In any * case the input/output parameter "var" will have the requested type. */ - static bool convert(Variant &var, const Rtti &type, Logger &logger, + static bool convert(Variant &var, const Rtti *type, Logger &logger, Mode mode = Mode::SAFE); }; } diff --git a/src/core/managed/Managed.cpp b/src/core/managed/Managed.cpp index b282427..64e287d 100644 --- a/src/core/managed/Managed.cpp +++ b/src/core/managed/Managed.cpp @@ -76,12 +76,12 @@ bool Managed::unregisterEvent(EventType type, EventHandler handler, bool Managed::triggerEvent(Event &ev) { return mgr.triggerEvent(this, ev); } -const Rtti &Managed::type() const { return typeOf(*this); } +const Rtti *Managed::type() const { return typeOf(*this); } -bool Managed::isa(const Rtti &t) const { return type().isa(t); } +bool Managed::isa(const Rtti *t) const { return type()->isa(t); } -bool Managed::composedOf(const Rtti &t) const +bool Managed::composedOf(const Rtti *t) const { - return type().composedOf(t); + return type()->composedOf(t); } } diff --git a/src/core/managed/Managed.hpp b/src/core/managed/Managed.hpp index 7c43527..4784e46 100644 --- a/src/core/managed/Managed.hpp +++ b/src/core/managed/Managed.hpp @@ -245,7 +245,7 @@ public: * @return a reference to the registered Rtti for this particular * Managed class. */ - const Rtti &type() const; + const Rtti *type() const; /** * Returns true if this Managed instance is of the type described by the @@ -255,7 +255,7 @@ public: * class is of the given type or one of the registered parent types is of * the given type. */ - bool isa(const Rtti &t) const; + bool isa(const Rtti *t) const; /** * Returns true if this Managed instance may contain instances of the type @@ -264,7 +264,7 @@ public: * @param true if the Rtti registered for this particular Managed class * may contain instance of the given type. */ - bool composedOf(const Rtti &t) const; + bool composedOf(const Rtti *t) const; }; /** diff --git a/src/core/managed/Manager.cpp b/src/core/managed/Manager.cpp index 2e0b882..ee4da5f 100644 --- a/src/core/managed/Manager.cpp +++ b/src/core/managed/Manager.cpp @@ -199,7 +199,7 @@ void Manager::deleteRef(Managed *tar, Managed *src, bool all) std::cerr << "\x1b[41;30mManager:\x1b[0m A managed object contains a rooted reference, " "this may cause memory leaks!" << std::endl; std::cerr << "\x1b[41;30mManager:\x1b[0m Referenced object is " << tar << " of type " - << tar->type().name << std::endl; + << tar->type()->name << std::endl; } #endif @@ -595,13 +595,13 @@ void Manager::exportGraphviz(const char *filename) : std::vector<EventHandlerDescriptor>{}; // Read type information and Node name (if available) - const Rtti &type = objectPtr->type(); - const std::string &typeName = type.name; + const Rtti *type = objectPtr->type(); + const std::string &typeName = type->name; // Fetch the name of the object if the object has a "name" property std::string name; - if (type.hasProperty("name")) { - name = type.getProperty("name")->get(objectPtr).toString(); + if (type->hasProperty("name")) { + name = type->getProperty("name")->get(objectPtr).toString(); } // Print the node @@ -662,7 +662,7 @@ void Manager::exportGraphviz(const char *filename) while (edgeCount > 0) { // Get the type of the target element uintptr_t pTar = reinterpret_cast<uintptr_t>(e.first); - const Rtti &typeTar = e.first->type(); + const Rtti *typeTar = e.first->type(); // Get some information about the edge std::string port = ""; @@ -679,7 +679,7 @@ void Manager::exportGraphviz(const char *filename) } } } - if (et == EdgeType::NORMAL && type.composedOf(typeTar)) { + if (et == EdgeType::NORMAL && type->composedOf(typeTar)) { et = EdgeType::AGGREGATE; } diff --git a/src/core/model/Document.cpp b/src/core/model/Document.cpp index b981c26..de73bb8 100644 --- a/src/core/model/Document.cpp +++ b/src/core/model/Document.cpp @@ -77,7 +77,7 @@ int DocumentEntity::getFieldDescriptorIndex( void DocumentEntity::invalidateSubInstance() { - if (subInst->isa(RttiTypes::StructuredEntity)) { + if (subInst->isa(&RttiTypes::StructuredEntity)) { subInst.cast<StructuredEntity>()->invalidate(); } else { subInst.cast<AnnotationEntity>()->invalidate(); @@ -107,7 +107,7 @@ void DocumentEntity::setDescriptor(Handle<Descriptor> d) descriptor = subInst->acquire(d); // get the effective field descriptors in the descriptor. NodeVector<FieldDescriptor> fieldDescs; - if (descriptor->isa(RttiTypes::StructuredClass)) { + if (descriptor->isa(&RttiTypes::StructuredClass)) { fieldDescs = descriptor.cast<StructuredClass>()->getEffectiveFieldDescriptors(); } else { @@ -149,7 +149,7 @@ bool DocumentEntity::doValidate(Logger &logger) const * overridden in the subclasses. */ NodeVector<FieldDescriptor> fieldDescs; - if (descriptor->isa(RttiTypes::StructuredClass)) { + if (descriptor->isa(&RttiTypes::StructuredClass)) { fieldDescs = descriptor.cast<StructuredClass>()->getEffectiveFieldDescriptors(); } else { @@ -181,7 +181,7 @@ bool DocumentEntity::doValidate(Logger &logger) const continue; } // if we are here we know that exactly one child exists. - if (!fields[f][0]->isa(RttiTypes::DocumentPrimitive)) { + if (!fields[f][0]->isa(&RttiTypes::DocumentPrimitive)) { logger.error(std::string("Primitive Field \"") + fieldDescs[f]->getName() + "\" has non primitive content!", @@ -243,11 +243,11 @@ bool DocumentEntity::doValidate(Logger &logger) const *child); valid = false; } - if (child->isa(RttiTypes::Anchor)) { + if (child->isa(&RttiTypes::Anchor)) { // Anchors are uninteresting and can be ignored. continue; } - if (child->isa(RttiTypes::DocumentPrimitive)) { + if (child->isa(&RttiTypes::DocumentPrimitive)) { logger.error(std::string("Non-primitive Field \"") + fieldDescs[f]->getName() + "\" had primitive content!", @@ -344,7 +344,7 @@ void DocumentEntity::addStructureNode(Handle<StructureNode> s, const int &i) if (par != subInst) { // if a previous parent existed, remove the StructureNode from it if (par != nullptr) { - if (par->isa(RttiTypes::StructuredEntity)) { + if (par->isa(&RttiTypes::StructuredEntity)) { par.cast<StructuredEntity>()->removeStructureNode(s); } else { par.cast<AnnotationEntity>()->removeStructureNode(s); @@ -464,9 +464,9 @@ bool StructureNode::doValidate(Logger &logger) const logger.error("The parent is not set!", *this); valid = false; } - if (!getParent()->isa(RttiTypes::StructuredEntity) && - !getParent()->isa(RttiTypes::AnnotationEntity) && - !getParent()->isa(RttiTypes::Document)) { + if (!getParent()->isa(&RttiTypes::StructuredEntity) && + !getParent()->isa(&RttiTypes::AnnotationEntity) && + !getParent()->isa(&RttiTypes::Document)) { logger.error("The parent does not have a valid type!", *this); valid = false; } @@ -477,9 +477,9 @@ StructureNode::StructureNode(Manager &mgr, std::string name, Handle<Node> parent, const std::string &fieldName) : Node(mgr, std::move(name), parent) { - if (parent->isa(RttiTypes::StructuredEntity)) { + if (parent->isa(&RttiTypes::StructuredEntity)) { parent.cast<StructuredEntity>()->addStructureNode(this, fieldName); - } else if (parent->isa(RttiTypes::AnnotationEntity)) { + } else if (parent->isa(&RttiTypes::AnnotationEntity)) { parent.cast<AnnotationEntity>()->addStructureNode(this, fieldName); } else { throw OusiaException("The proposed parent was no DocumentEntity!"); @@ -552,7 +552,7 @@ bool AnnotationEntity::doValidate(Logger &logger) const if (getParent() == nullptr) { logger.error("The parent is not set!", *this); valid = false; - } else if (!getParent()->isa(RttiTypes::Document)) { + } else if (!getParent()->isa(&RttiTypes::Document)) { logger.error("The parent is not a document!", *this); valid = false; } else { @@ -640,7 +640,7 @@ bool Document::doValidate(Logger &logger) const void Document::doReference(Handle<Node> node) { - if (node->isa(RttiTypes::Domain)) { + if (node->isa(&RttiTypes::Domain)) { referenceDomain(node.cast<Domain>()); } } @@ -706,12 +706,12 @@ Rooted<AnnotationEntity> Document::createChildAnnotation( bool Document::hasChild(Handle<StructureNode> s) const { Rooted<Managed> parent = s->getParent(); - if (parent->isa(RttiTypes::StructureNode)) { + if (parent->isa(&RttiTypes::StructureNode)) { return hasChild(parent.cast<StructureNode>()); - } else if (parent->isa(RttiTypes::AnnotationEntity)) { + } else if (parent->isa(&RttiTypes::AnnotationEntity)) { Handle<AnnotationEntity> a = parent.cast<AnnotationEntity>(); return this == a->getParent(); - } else if (parent->isa(RttiTypes::Document)) { + } else if (parent->isa(&RttiTypes::Document)) { return this == parent; } return false; diff --git a/src/core/model/Domain.cpp b/src/core/model/Domain.cpp index 7d5a76e..55f05b3 100644 --- a/src/core/model/Domain.cpp +++ b/src/core/model/Domain.cpp @@ -61,7 +61,7 @@ bool FieldDescriptor::doValidate(Logger &logger) const if (getParent() == nullptr) { logger.error("This field has no parent!", *this); valid = false; - } else if (!getParent()->isa(RttiTypes::Descriptor)) { + } else if (!getParent()->isa(&RttiTypes::Descriptor)) { logger.error("The parent of this field is not a descriptor!", *this); valid = false; } @@ -142,7 +142,7 @@ bool Descriptor::doValidate(Logger &logger) const if (getParent() == nullptr) { logger.error("This Descriptor has no parent!", *this); valid = false; - } else if (!getParent()->isa(RttiTypes::Domain)) { + } else if (!getParent()->isa(&RttiTypes::Domain)) { logger.error("The parent of this Descriptor is not a Domain!", *this); valid = false; } @@ -180,7 +180,7 @@ bool Descriptor::continuePath(Handle<StructuredClass> target, // use recursive depth-first search from the top to reach the given child // get the list of effective FieldDescriptors. NodeVector<FieldDescriptor> fields; - if (isa(RttiTypes::StructuredClass)) { + if (isa(&RttiTypes::StructuredClass)) { const StructuredClass *tis = static_cast<const StructuredClass *>(this); fields = tis->getEffectiveFieldDescriptors(); } else { @@ -212,7 +212,7 @@ bool Descriptor::continuePath(Handle<StructuredClass> target, } } - if (isa(RttiTypes::StructuredClass)) { + if (isa(&RttiTypes::StructuredClass)) { const StructuredClass *tis = static_cast<const StructuredClass *>(this); // if this is a StructuredClass we also can call the subclasses. for (auto &c : tis->getSubclasses()) { @@ -489,7 +489,7 @@ bool Domain::doValidate(Logger &logger) const void Domain::doReference(Handle<Node> node) { - if (node->isa(RttiTypes::Domain)) { + if (node->isa(&RttiTypes::Domain)) { referenceTypesystem(node.cast<Typesystem>()); } } diff --git a/src/core/model/Node.cpp b/src/core/model/Node.cpp index 65f093f..39ee2e4 100644 --- a/src/core/model/Node.cpp +++ b/src/core/model/Node.cpp @@ -62,7 +62,7 @@ public: /** * Type of the node that was requested for resolution. */ - const Rtti &type; + const Rtti *type; /** * Actual path (name pattern) that was requested for resolution. @@ -86,7 +86,7 @@ public: * @param path is a const reference to the actual path that should be * resolved. */ - SharedResolutionState(const Rtti &type, + SharedResolutionState(const Rtti *type, const std::vector<std::string> &path) : type(type), path(path) { @@ -182,35 +182,86 @@ public: /** * Returns true if the given type matches the type given in the query. * + * @param type is the type that should be checked. * @return true if the type matches, false otherwise. */ - bool typeMatches(const Rtti &type) { return type.isa(shared.type); } + bool typeMatches(const Rtti *type) { return type->isa(shared.type); } - bool canContainType(const Rtti &type) + /** + * Returns true if the given type can contain the node that is currently + * being resolved. + * + * @param type is the type that should be checked. + * @return true if the given type can contain the node that is currently + * begin resolved, false otherwise. + */ + bool canContainType(const Rtti *type) + { + return type->composedOf(shared.type); + } + + /** + * Returns true if the resolution process is still allowed to follow + * references. This is only the case if we are at the beginning of the + * resolution process and have not entered another start tree. + * + * @return true if references can still be followed, false if only composita + * may be examined. + */ + bool canFollowReferences() { - return type.composedOf(shared.type); + return idx == 0 && inStartTree && !foundCompositum; } + /** + * Returns true if we can still descend into new composita. This is only + * the case if we have not yet descended into another compositum beforehand. + * + * @return true if composita can be followed, false otherwise. + */ + bool canFollowComposita() { return idx == 0; } + + /** + * Returns the number of matching nodes that were found until now. + * + * @return the number of matching nodes. + */ + size_t resultCount() { return shared.result.size(); } + + /** + * Returns the name that is currently being search for (at the current path + * position). + * + * @return the current name. + */ const std::string ¤tName() { return shared.path[idx]; } + /** + * Returns a new ResolutionState instance where the path position is moved + * on by one element. + * + * @return a copy of the current ResolutionState instance with the path + * position being incremented by one. + */ ResolutionState advance() { return ResolutionState{shared, resolutionRoot, idx + 1, false}; } + /** + * Forks current ResolutionState instance with the resolution starting at + * the given node. This function is used when a reference is being followed. + * + * @param newResolutionRoot is the root node of the new subtree in which + * resolution takes place. + * @return a copy of this ResolutionState instance with the resolution root + * begin set to the new root instance and the path position being set to + * zero. + */ ResolutionState fork(Node *newResolutionRoot) { return ResolutionState{shared, newResolutionRoot, 0, false}; } - - bool canFollowReferences() - { - return idx == 0 && inStartTree && !foundCompositum; - } - - bool canFollowComposita() { return idx == 0; } - - size_t resultCount() { return shared.result.size(); } }; /* Class ResolutionResult */ @@ -329,7 +380,7 @@ bool Node::continueResolveReference(Handle<Node> h, ResolutionState &state) } std::vector<ResolutionResult> Node::resolve( - const Rtti &type, const std::vector<std::string> &path) + const Rtti *type, const std::vector<std::string> &path) { // Create the state variables SharedResolutionState sharedState(type, path); @@ -344,7 +395,7 @@ std::vector<ResolutionResult> Node::resolve( return sharedState.result; } -std::vector<ResolutionResult> Node::resolve(const Rtti &type, +std::vector<ResolutionResult> Node::resolve(const Rtti *type, const std::string &name) { // Place the name in a vector and call the corresponding resolve function @@ -359,7 +410,7 @@ bool Node::checkDuplicate(Handle<Node> elem, if (!names.emplace(name).second) { logger.error(std::string("Element with name \"") + name + std::string("\" defined multiple times in parent ") + - type().name + std::string(" \"") + + type()->name + std::string(" \"") + Utils::join(path(), ".") + std::string("\""), *elem); return false; @@ -398,7 +449,7 @@ bool Node::doValidate(Logger &logger) const { return true; } bool Node::validateName(Logger &logger) const { if (!Utils::isIdentifier(name)) { - logger.error(type().name + std::string(" name \"") + name + + logger.error(type()->name + std::string(" name \"") + name + std::string("\" is not a valid identifier"), this); return false; @@ -421,7 +472,7 @@ bool Node::validateIsAcyclic(const std::string &name, for (size_t i = 0; i < path.size(); i++) { auto node = path[i]; const std::string &name = node->getName(); - const std::string &typeName = node->type().name; + const std::string &typeName = node->type()->name; const std::string suffix = i == path.size() - 1 ? std::string{" (this node closes the cycle):"} @@ -517,14 +568,14 @@ void Node::setParent(Handle<Node> p) namespace RttiTypes { const Rtti Node = RttiBuilder<ousia::Node>("Node") - .property("name", {RttiTypes::String, + .property("name", {&RttiTypes::String, {[](const ousia::Node *obj) { return Variant::fromString(obj->getName()); }}, {[](const Variant &value, ousia::Node *obj) { obj->setName(value.asString()); }}}) - .property("parent", {Node, + .property("parent", {&Node, {[](const ousia::Node *obj) { return Variant::fromObject(obj->getParent()); }}}); diff --git a/src/core/model/Node.hpp b/src/core/model/Node.hpp index 61bf418..fe8db16 100644 --- a/src/core/model/Node.hpp +++ b/src/core/model/Node.hpp @@ -545,7 +545,7 @@ public: * @return a vector containing ResolutionResult structures which describe * the resolved elements. */ - std::vector<ResolutionResult> resolve(const Rtti &type, + std::vector<ResolutionResult> resolve(const Rtti *type, const std::vector<std::string> &path); /** @@ -557,7 +557,7 @@ public: * @return a vector containing ResolutionResult structures which describe * the resolved elements. */ - std::vector<ResolutionResult> resolve(const Rtti &type, + std::vector<ResolutionResult> resolve(const Rtti *type, const std::string &name); /** diff --git a/src/core/model/Project.cpp b/src/core/model/Project.cpp index 31530f3..f7dab8a 100644 --- a/src/core/model/Project.cpp +++ b/src/core/model/Project.cpp @@ -42,7 +42,7 @@ void Project::doResolve(ResolutionState &state){ } void Project::doReference(Handle<Node> node) { - if (node->isa(RttiTypes::Document)) { + if (node->isa(&RttiTypes::Document)) { referenceDocument(node.cast<Document>()); } } diff --git a/src/core/model/RootNode.cpp b/src/core/model/RootNode.cpp index 821c50c..642ec14 100644 --- a/src/core/model/RootNode.cpp +++ b/src/core/model/RootNode.cpp @@ -24,10 +24,10 @@ namespace ousia { void RootNode::reference(Handle<Node> node) { - if (!node->type().isOneOf(getReferenceTypes())) { + if (!node->type()->isOneOf(getReferenceTypes())) { throw OusiaException( - std::string("Node with type ") + node->type().name + - std::string(" cannot be referenced in a ") + type().name); + std::string("Node with type ") + node->type()->name + + std::string(" cannot be referenced in a ") + type()->name); } doReference(node); } diff --git a/src/core/model/Typesystem.cpp b/src/core/model/Typesystem.cpp index bd5e615..fb99f87 100644 --- a/src/core/model/Typesystem.cpp +++ b/src/core/model/Typesystem.cpp @@ -648,13 +648,13 @@ bool ArrayType::doCheckIsa(Handle<const Type> type) const Handle<const Type> t2{type}; // Unwrap the array types until only the innermost type is left - while (t1->isa(RttiTypes::ArrayType) && t2->isa(RttiTypes::ArrayType)) { + while (t1->isa(&RttiTypes::ArrayType) && t2->isa(&RttiTypes::ArrayType)) { t1 = t1.cast<const ArrayType>()->innerType; t2 = t2.cast<const ArrayType>()->innerType; } // Abort if only one of the to types is an array type - if (t1->isa(RttiTypes::ArrayType) || t2->isa(RttiTypes::ArrayType)) { + if (t1->isa(&RttiTypes::ArrayType) || t2->isa(&RttiTypes::ArrayType)) { return false; } @@ -725,7 +725,7 @@ bool Typesystem::doValidate(Logger &logger) const void Typesystem::doReference(Handle<Node> node) { - if (node->isa(RttiTypes::Typesystem)) { + if (node->isa(&RttiTypes::Typesystem)) { referenceTypesystem(node.cast<Typesystem>()); } } diff --git a/src/core/parser/ParserScope.cpp b/src/core/parser/ParserScope.cpp index b97dabd..9c0b729 100644 --- a/src/core/parser/ParserScope.cpp +++ b/src/core/parser/ParserScope.cpp @@ -33,7 +33,7 @@ ParserScopeBase::ParserScopeBase(const NodeVector<Node> &nodes) : nodes(nodes) { } -Rooted<Node> ParserScopeBase::resolve(const Rtti &type, +Rooted<Node> ParserScopeBase::resolve(const Rtti *type, const std::vector<std::string> &path, Logger &logger) { @@ -74,7 +74,7 @@ std::vector<Rtti const *> ParserScopeBase::getStackTypeSignature() const std::vector<Rtti const *> res; res.reserve(nodes.size()); for (size_t i = 0; i < nodes.size(); i++) { - res.push_back(&(nodes[i]->type())); + res.push_back(nodes[i]->type()); } return res; } @@ -86,7 +86,7 @@ Rooted<Node> ParserScopeBase::select(RttiSet types, int maxDepth) minDepth = static_cast<ssize_t>(nodes.size()) - (maxDepth + 1); } for (ssize_t i = nodes.size() - 1; i >= minDepth; i--) { - if (nodes[i]->type().isOneOf(types)) { + if (nodes[i]->type()->isOneOf(types)) { return nodes[i]; } } @@ -113,7 +113,7 @@ Rooted<Node> ParserScopeBase::selectOrThrow(RttiSet types, int maxDepth) DeferredResolution::DeferredResolution(const NodeVector<Node> &nodes, const std::vector<std::string> &path, - const Rtti &type, + const Rtti *type, ResolutionResultCallback resultCallback, Handle<Node> owner) : scope(nodes), @@ -179,7 +179,7 @@ bool ParserScope::checkUnwound(Logger &logger) const MessageMode::NO_CONTEXT); for (size_t i = topLevelDepth + 1; i < nodes.size(); i++) { logger.note(std::string("Element of interal type ") + - nodes[i]->type().name + + nodes[i]->type()->name + std::string(" defined here:"), *nodes[i]); } @@ -270,7 +270,7 @@ bool ParserScope::getFlag(ParserFlag flag) return false; } -bool ParserScope::resolve(const Rtti &type, +bool ParserScope::resolve(const Rtti *type, const std::vector<std::string> &path, Handle<Node> owner, Logger &logger, ResolutionImposterCallback imposterCallback, @@ -283,7 +283,7 @@ bool ParserScope::resolve(const Rtti &type, return true; } -bool ParserScope::resolve(const Rtti &type, +bool ParserScope::resolve(const Rtti *type, const std::vector<std::string> &path, Handle<Node> owner, Logger &logger, ResolutionResultCallback resultCallback) @@ -340,7 +340,7 @@ bool ParserScope::resolveType(const std::vector<std::string> &path, } // Requested type is not an array, call the usual resolve function - return resolve(RttiTypes::Type, path, owner, logger, resultCallback); + return resolve(&RttiTypes::Type, path, owner, logger, resultCallback); } bool ParserScope::resolveType(const std::string &name, Handle<Node> owner, @@ -359,7 +359,7 @@ bool ParserScope::resolveValue(Variant &data, Handle<Type> type, const Type *innerType) mutable -> Type::MagicCallbackResult { // Try to resolve the node Rooted<Constant> constant = - ParserScopeBase::resolve(RttiTypes::Constant, + ParserScopeBase::resolve(&RttiTypes::Constant, Utils::split(innerData.asMagic(), '.'), logger).cast<Constant>(); @@ -464,7 +464,7 @@ bool ParserScope::performDeferredResolution(Logger &logger) // succeed. for (auto &failed : deferred) { failed.fail(logger); - logger.error(std::string("Could not resolve ") + failed.type.name + + logger.error(std::string("Could not resolve ") + failed.type->name + std::string(" \"") + Utils::join(failed.path, ".") + std::string("\""), *failed.owner); diff --git a/src/core/parser/ParserScope.hpp b/src/core/parser/ParserScope.hpp index 1de1592..bd6a29f 100644 --- a/src/core/parser/ParserScope.hpp +++ b/src/core/parser/ParserScope.hpp @@ -103,7 +103,7 @@ public: * @return a reference at a resolved node or nullptr if no node could be * found. */ - Rooted<Node> resolve(const Rtti &type, const std::vector<std::string> &path, + Rooted<Node> resolve(const Rtti *type, const std::vector<std::string> &path, Logger &logger); /** @@ -167,7 +167,7 @@ public: template <class T> Rooted<T> select(int maxDepth = -1) { - return select(RttiSet{&typeOf<T>()}, maxDepth).cast<T>(); + return select(RttiSet{typeOf<T>()}, maxDepth).cast<T>(); } /** @@ -195,7 +195,7 @@ public: template <class T> Rooted<T> selectOrThrow(int maxDepth = -1) { - return selectOrThrow(RttiSet{&typeOf<T>()}, maxDepth).cast<T>(); + return selectOrThrow(RttiSet{typeOf<T>()}, maxDepth).cast<T>(); } }; @@ -227,7 +227,7 @@ public: /** * Reference at the type of the object that should be resolved. */ - const Rtti &type; + const Rtti *type; /** * Node for which the resolution is taking place. @@ -248,7 +248,7 @@ public: * @param owner is the node for which the resolution takes place. */ DeferredResolution(const NodeVector<Node> &nodes, - const std::vector<std::string> &path, const Rtti &type, + const std::vector<std::string> &path, const Rtti *type, ResolutionResultCallback resultCallback, Handle<Node> owner); @@ -482,7 +482,7 @@ public: * not mean, that the resolved object does not exist, as it may be resolved * later. */ - bool resolve(const Rtti &type, const std::vector<std::string> &path, + bool resolve(const Rtti *type, const std::vector<std::string> &path, Handle<Node> owner, Logger &logger, ResolutionImposterCallback imposterCallback, ResolutionResultCallback resultCallback); @@ -505,7 +505,7 @@ public: * mean, that the resolved object does not exist, as it may be resolved * later. */ - bool resolve(const Rtti &type, const std::vector<std::string> &path, + bool resolve(const Rtti *type, const std::vector<std::string> &path, Handle<Node> owner, Logger &logger, ResolutionResultCallback resultCallback); diff --git a/src/core/resource/ResourceManager.cpp b/src/core/resource/ResourceManager.cpp index 56c9583..74fd5ad 100644 --- a/src/core/resource/ResourceManager.cpp +++ b/src/core/resource/ResourceManager.cpp @@ -215,9 +215,9 @@ NodeVector<Node> ResourceManager::parse( // Make sure the parsed nodes fulfill the "supportedTypes" constraint, // remove nodes that do not the result for (auto it = parsedNodes.begin(); it != parsedNodes.end();) { - const Rtti &type = (*it)->type(); - if (!type.isOneOf(supportedTypes)) { - logger.error(std::string("Node of internal type ") + type.name + + const Rtti *type = (*it)->type(); + if (!type->isOneOf(supportedTypes)) { + logger.error(std::string("Node of internal type ") + type->name + std::string(" not supported here"), **it); it = parsedNodes.erase(it); |