summaryrefslogtreecommitdiff
path: root/src/core/common/Property.cpp
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-01-14 02:44:09 +0100
committerAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-01-14 02:44:09 +0100
commit7d1b3c5df2eab1d42179332d467d5756aefed587 (patch)
tree6a44220ea0781a686d6c7b513ca914ba1ce6e919 /src/core/common/Property.cpp
parent92c1f8d9c933d13a8f038565587c83abae28711e (diff)
Implemented attaching Methods and Property information to Types (this will later allow script engines to access these methods).
Diffstat (limited to 'src/core/common/Property.cpp')
-rw-r--r--src/core/common/Property.cpp22
1 files changed, 13 insertions, 9 deletions
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<GetterFunction> getter,
- std::unique_ptr<SetterFunction> setter)
- : type(type), getter(std::move(getter)), setter(std::move(setter))
+ std::shared_ptr<GetterFunction> getter,
+ std::shared_ptr<SetterFunction> setter)
+ : type(std::make_shared<PropertyType>(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;
}
}