aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
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
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')
-rw-r--r--src/qml/jsruntime/qv4global_p.h4
-rw-r--r--src/qml/jsruntime/qv4scopedvalue_p.h84
-rw-r--r--src/qml/jsruntime/qv4value_p.h53
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)