aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4scopedvalue_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2014-01-25 22:13:44 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-31 11:13:48 +0100
commitcaa6e18da572a9fb6a548d2630f133e8bf4f1649 (patch)
treebebf73c391d72ada4e0ac0b8c2eb4bcd6a8ea420 /src/qml/jsruntime/qv4scopedvalue_p.h
parentbca28cb0d0dd922ee5d54e5d64d31b97ae5d0266 (diff)
Move ValueRef into qv4value_p.h
The ref class belongs logically together with the value. Change-Id: I40c0908715cbc8b2a5c51d2544cb06fcd8e25365 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4scopedvalue_p.h')
-rw-r--r--src/qml/jsruntime/qv4scopedvalue_p.h84
1 files changed, 23 insertions, 61 deletions
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;
+}
+
}