From 7d1b3c5df2eab1d42179332d467d5756aefed587 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Wed, 14 Jan 2015 02:44:09 +0100 Subject: Implemented attaching Methods and Property information to Types (this will later allow script engines to access these methods). --- src/core/common/Property.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/core/common/Property.cpp') diff --git a/src/core/common/Property.cpp b/src/core/common/Property.cpp index ea40182..8248058 100644 --- a/src/core/common/Property.cpp +++ b/src/core/common/Property.cpp @@ -41,8 +41,10 @@ void GetterFunction::validateArguments(Variant::arrayType &args) const void GetterFunction::validateResult(Variant &res) const { ExceptionLogger logger; - VariantConverter::convert(res, propertyType->type, propertyType->innerType, - logger); + if (propertyType != nullptr) { + VariantConverter::convert(res, propertyType->type, + propertyType->innerType, logger); + } } Variant GetterFunction::get(void *obj) @@ -66,8 +68,10 @@ void SetterFunction::validateArguments(Variant::arrayType &args) const // Convert the one argument to the requested type, throw an exception if // this fails. ExceptionLogger logger; - VariantConverter::convert(args[0], propertyType->type, - propertyType->innerType, logger); + if (propertyType != nullptr) { + VariantConverter::convert(args[0], propertyType->type, + propertyType->innerType, logger); + } } void SetterFunction::set(const Variant &value, void *obj) @@ -78,9 +82,9 @@ void SetterFunction::set(const Variant &value, void *obj) /* Class PropertyDescriptor */ PropertyDescriptor::PropertyDescriptor(const PropertyType &type, - std::unique_ptr getter, - std::unique_ptr setter) - : type(type), getter(std::move(getter)), setter(std::move(setter)) + std::shared_ptr getter, + std::shared_ptr setter) + : type(std::make_shared(type)), getter(getter), setter(setter) { if (!this->getter->isValid()) { throw PropertyException( @@ -89,8 +93,8 @@ PropertyDescriptor::PropertyDescriptor(const PropertyType &type, } // Assign the property type reference to the getter and setter - this->getter->propertyType = &this->type; - this->setter->propertyType = &this->type; + this->getter->propertyType = this->type; + this->setter->propertyType = this->type; } } -- cgit v1.2.3