diff options
Diffstat (limited to 'src/qml/jsruntime/qv4scopedvalue_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4scopedvalue_p.h | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h index 705e5301dc..d72d23bbe9 100644 --- a/src/qml/jsruntime/qv4scopedvalue_p.h +++ b/src/qml/jsruntime/qv4scopedvalue_p.h @@ -193,6 +193,9 @@ struct ScopedValue return ptr; } + operator Value *() { return ptr; } + operator const Value &() const { return *ptr; } + ReturnedValue asReturnedValue() const { return ptr->val; } Value *ptr; @@ -264,7 +267,14 @@ struct Scoped #endif } - Scoped(const Scope &scope, const ValueRef &v); + Scoped(const Scope &scope, const Value *v) + { + ptr = scope.engine->jsStackTop++; + setPointer(v ? value_cast<T>(*v) : 0); +#ifndef QT_NO_DEBUG + ++scope.size; +#endif + } Scoped(const Scope &scope, T *t) { @@ -326,8 +336,10 @@ struct Scoped setPointer(value_cast<T>(v)); return *this; } - - Scoped<T> &operator=(const ValueRef &v); + Scoped<T> &operator=(Value *v) { + setPointer(v ? value_cast<T>(*v) : 0); + return *this; + } Scoped<T> &operator=(const ReturnedValue &v) { setPointer(value_cast<T>(QV4::Value::fromReturnedValue(v))); @@ -347,6 +359,9 @@ struct Scoped operator T *() { return static_cast<T *>(ptr->managed()); } + operator const Value &() const { + return *ptr; + } T *operator->() { return ptr->cast<T>(); @@ -398,23 +413,6 @@ struct ScopedCallData { }; -template<typename T> -inline Scoped<T>::Scoped(const Scope &scope, const ValueRef &v) -{ - ptr = scope.engine->jsStackTop++; - setPointer(value_cast<T>(*v.operator ->())); -#ifndef QT_NO_DEBUG - ++scope.size; -#endif -} - -template<typename T> -inline Scoped<T> &Scoped<T>::operator=(const ValueRef &v) -{ - setPointer(value_cast<T>(*v.operator ->())); - return *this; -} - inline Value &Value::operator =(const ScopedValue &v) { val = v.ptr->val; @@ -428,12 +426,6 @@ inline Value &Value::operator=(const Scoped<T> &t) return *this; } -inline Value &Value::operator=(const ValueRef v) -{ - val = v.asReturnedValue(); - return *this; -} - template<typename T> inline TypedValue<T> &TypedValue<T>::operator =(T *t) { |