diff options
-rw-r--r-- | src/qml/jsruntime/qv4global_p.h | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4scopedvalue_p.h | 84 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4value_p.h | 53 |
3 files changed, 80 insertions, 61 deletions
diff --git a/src/qml/jsruntime/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h index 1d465df0c0..0337e336b9 100644 --- a/src/qml/jsruntime/qv4global_p.h +++ b/src/qml/jsruntime/qv4global_p.h @@ -163,6 +163,10 @@ typedef Referenced<Object> ObjectRef; typedef Referenced<ArrayObject> ArrayObjectRef; typedef Referenced<FunctionObject> FunctionObjectRef; +struct PersistentValuePrivate; +class PersistentValue; +class WeakValue; + namespace Global { enum { diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h index 3b1f3d5e67..678b18c829 100644 --- a/src/qml/jsruntime/qv4scopedvalue_p.h +++ b/src/qml/jsruntime/qv4scopedvalue_p.h @@ -377,67 +377,6 @@ struct ScopedCallData { CallData *ptr; }; -struct ValueRef { - ValueRef(const ScopedValue &v) - : ptr(v.ptr) {} - template <typename T> - ValueRef(const Scoped<T> &v) - : ptr(v.ptr) {} - ValueRef(const PersistentValue &v) - : ptr(&v.d->value) {} - ValueRef(PersistentValuePrivate *p) - : ptr(&p->value) {} - ValueRef(Value &v) { ptr = &v; } - // Important: Do NOT add a copy constructor to this class - // adding a copy constructor actually changes the calling convention, ie. - // is not even binary compatible. Adding it would break assumptions made - // in the jit'ed code. - ValueRef &operator=(const ScopedValue &o) - { *ptr = *o.ptr; return *this; } - ValueRef &operator=(const ValueRef &o) - { *ptr = *o.ptr; return *this; } - ValueRef &operator=(const Value &v) - { *ptr = v; return *this; } - ValueRef &operator=(const ReturnedValue &v) { - ptr->val = v; - return *this; - } - template <typename T> - ValueRef &operator=(Returned<T> *v) { - ptr->val = v->asReturnedValue(); - return *this; - } - - operator const Value *() const { - return ptr; - } - const Value *operator->() const { - return ptr; - } - - operator Value *() { - return ptr; - } - Value *operator->() { - return ptr; - } - - static ValueRef fromRawValue(Value *v) { - return ValueRef(v); - } - static const ValueRef fromRawValue(const Value *v) { - return ValueRef(const_cast<Value *>(v)); - } - - ReturnedValue asReturnedValue() const { return ptr->val; } - - // ### get rid of this one! - ValueRef(Value *v) { ptr = reinterpret_cast<Value *>(v); } -private: - Value *ptr; -}; - - template<typename T> struct Referenced { // Important: Do NOT add a copy constructor to this class @@ -695,6 +634,29 @@ inline WeakValue &WeakValue::operator=(Returned<T> *obj) return operator=(QV4::Value::fromManaged(obj->getPointer()).asReturnedValue()); } +inline ValueRef::ValueRef(const ScopedValue &v) + : ptr(v.ptr) +{} + +template <typename T> +inline ValueRef::ValueRef(const Scoped<T> &v) + : ptr(v.ptr) +{} + +inline ValueRef::ValueRef(const PersistentValue &v) + : ptr(&v.d->value) +{} + +inline ValueRef::ValueRef(PersistentValuePrivate *p) + : ptr(&p->value) +{} + +inline ValueRef &ValueRef::operator=(const ScopedValue &o) +{ + *ptr = *o.ptr; + return *this; +} + } diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index 4b5d0de6f9..536057ef26 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -498,6 +498,59 @@ private: Encode(void *); }; +struct ValueRef { + ValueRef(const ScopedValue &v); + template <typename T> + ValueRef(const Scoped<T> &v); + ValueRef(const PersistentValue &v); + ValueRef(PersistentValuePrivate *p); + ValueRef(Value &v) { ptr = &v; } + // Important: Do NOT add a copy constructor to this class + // adding a copy constructor actually changes the calling convention, ie. + // is not even binary compatible. Adding it would break assumptions made + // in the jit'ed code. + ValueRef &operator=(const ScopedValue &o); + ValueRef &operator=(const Value &v) + { *ptr = v; return *this; } + ValueRef &operator=(const ReturnedValue &v) { + ptr->val = v; + return *this; + } + template <typename T> + ValueRef &operator=(Returned<T> *v) { + ptr->val = v->asReturnedValue(); + return *this; + } + + operator const Value *() const { + return ptr; + } + const Value *operator->() const { + return ptr; + } + + operator Value *() { + return ptr; + } + Value *operator->() { + return ptr; + } + + static ValueRef fromRawValue(Value *v) { + return ValueRef(v); + } + static const ValueRef fromRawValue(const Value *v) { + return ValueRef(const_cast<Value *>(v)); + } + + ReturnedValue asReturnedValue() const { return ptr->val; } + + // ### get rid of this one! + ValueRef(Value *v) { ptr = reinterpret_cast<Value *>(v); } +private: + Value *ptr; +}; + template<typename T> T *value_cast(const Value &v) |