diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/array.h | 2 | ||||
-rw-r--r-- | include/class.h | 34 | ||||
-rw-r--r-- | include/classbase.h | 2 | ||||
-rw-r--r-- | include/object.h | 2 | ||||
-rw-r--r-- | include/value.h | 2 |
5 files changed, 29 insertions, 13 deletions
diff --git a/include/array.h b/include/array.h index 126cd58..925e902 100644 --- a/include/array.h +++ b/include/array.h @@ -79,7 +79,7 @@ public: * Change the internal type of the variable * @param Type */ - virtual Value &setType(Type type) override + virtual Value &setType(Type type) & override { // throw exception if things are going wrong if (type != Type::Array) throw FatalError("Changing type of a fixed array variable"); diff --git a/include/class.h b/include/class.h index e92dfc3..371595e 100644 --- a/include/class.h +++ b/include/class.h @@ -53,7 +53,7 @@ public: /** * Destructor */ - virtual ~Class() {} + virtual ~Class() = default; /** * Add a regular method to the class @@ -461,8 +461,12 @@ private: // cast to actual object T *obj = (T *)base; - // pass on - return Value(obj->__toString()).setType(Type::String); + // retrieve the casted value and convert it if necessary + auto result = obj->__toString(); + result.setType(Type::String); + + // return the converted result + return result; } /** @@ -475,8 +479,12 @@ private: // cast to actual object T *obj = (T *)base; - // pass on - return Value(obj->__toInteger()).setType(Type::Numeric); + // retrieve the casted value and convert it if necessary + auto result = obj->__toInteger(); + result.setType(Type::Numeric); + + // return the converted result + return result; } /** @@ -489,8 +497,12 @@ private: // cast to actual object T *obj = (T *)base; - // pass on - return Value(obj->__toFloat()).setType(Type::Float); + // retrieve the casted value and convert it if necessary + auto result = obj->__toFloat(); + result.setType(Type::Float); + + // return the converted result + return result; } /** @@ -503,8 +515,12 @@ private: // cast to actual object T *obj = (T *)base; - // pass on - return Value(obj->__toBool()).setType(Type::Bool); + // retrieve the casted value and convert it if necessary + auto result = obj->__toBool(); + result.setType(Type::Bool); + + // return the converted result + return result; } /** diff --git a/include/classbase.h b/include/classbase.h index 0db0c35..a9542d7 100644 --- a/include/classbase.h +++ b/include/classbase.h @@ -90,7 +90,7 @@ public: /** * Destructor */ - virtual ~ClassBase() {} + virtual ~ClassBase() = default; /** * Construct a new instance of the object, or to clone the object diff --git a/include/object.h b/include/object.h index 745b7c6..56d7e83 100644 --- a/include/object.h +++ b/include/object.h @@ -106,7 +106,7 @@ public: * Change the internal type of the variable * @param Type */ - virtual Value &setType(Type type) override + virtual Value &setType(Type type) & override { // throw exception if things are going wrong if (type != Type::Object) throw FatalError("Changing type of a fixed object variable"); diff --git a/include/value.h b/include/value.h index afd532d..cd32568 100644 --- a/include/value.h +++ b/include/value.h @@ -361,7 +361,7 @@ public: * Change the internal type of the variable * @param Type */ - virtual Value &setType(Type type); + virtual Value &setType(Type type) &; /** * Make a clone of the value with the same type |