aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/jsapi/qjsvalue.cpp9
-rw-r--r--src/qml/jsruntime/qv4arraydata_p.h2
-rw-r--r--src/qml/jsruntime/qv4context.cpp4
-rw-r--r--src/qml/jsruntime/qv4context_p.h2
-rw-r--r--src/qml/jsruntime/qv4global_p.h4
-rw-r--r--src/qml/jsruntime/qv4managed_p.h6
-rw-r--r--src/qml/jsruntime/qv4mm.cpp8
-rw-r--r--src/qml/jsruntime/qv4persistent_p.h8
-rw-r--r--src/qml/jsruntime/qv4scopedvalue_p.h95
-rw-r--r--src/qml/jsruntime/qv4value_p.h33
10 files changed, 13 insertions, 158 deletions
diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp
index 47a764e641..5f76ba2c52 100644
--- a/src/qml/jsapi/qjsvalue.cpp
+++ b/src/qml/jsapi/qjsvalue.cpp
@@ -1091,11 +1091,14 @@ bool QJSValue::hasOwnProperty(const QString &name) const
*/
QObject *QJSValue::toQObject() const
{
- Returned<QV4::QObjectWrapper> *o = d->value.as<QV4::QObjectWrapper>();
- if (!o)
+ if (!d->engine)
+ return 0;
+ QV4::Scope scope(d->engine);
+ QV4::Scoped<QV4::QObjectWrapper> wrapper(scope, d->value);
+ if (!wrapper)
return 0;
- return o->getPointer()->object();
+ return wrapper->object();
}
/*!
diff --git a/src/qml/jsruntime/qv4arraydata_p.h b/src/qml/jsruntime/qv4arraydata_p.h
index 9393780323..581f31a607 100644
--- a/src/qml/jsruntime/qv4arraydata_p.h
+++ b/src/qml/jsruntime/qv4arraydata_p.h
@@ -47,8 +47,6 @@ namespace QV4 {
Q_MANAGED_CHECK \
static const QV4::ArrayVTable static_vtbl; \
static inline const QV4::ManagedVTable *staticVTable() { return &static_vtbl.managedVTable; } \
- template <typename T> \
- QV4::Returned<T> *asReturned() { return QV4::Returned<T>::create(this); } \
V4_MANAGED_SIZE_TEST \
const QV4::Heap::Data *d() const { return &static_cast<const QV4::Heap::Data &>(Managed::data); } \
QV4::Heap::Data *d() { return &static_cast<QV4::Heap::Data &>(Managed::data); }
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp
index 603b76630c..d3901f460f 100644
--- a/src/qml/jsruntime/qv4context.cpp
+++ b/src/qml/jsruntime/qv4context.cpp
@@ -48,7 +48,7 @@ DEFINE_MANAGED_VTABLE(CallContext);
DEFINE_MANAGED_VTABLE(WithContext);
DEFINE_MANAGED_VTABLE(GlobalContext);
-Returned<CallContext> *ExecutionContext::newCallContext(FunctionObject *function, CallData *callData)
+Heap::CallContext *ExecutionContext::newCallContext(FunctionObject *function, CallData *callData)
{
Q_ASSERT(function->function());
@@ -78,7 +78,7 @@ Returned<CallContext> *ExecutionContext::newCallContext(FunctionObject *function
std::fill(c->callData->args + c->callData->argc, c->callData->args + compiledFunction->nFormals, Primitive::undefinedValue());
c->callData->argc = qMax((uint)callData->argc, compiledFunction->nFormals);
- return Returned<CallContext>::create(c);
+ return c;
}
Heap::WithContext *ExecutionContext::newWithContext(Object *with)
diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h
index 9b5c4b0d87..30b578e428 100644
--- a/src/qml/jsruntime/qv4context_p.h
+++ b/src/qml/jsruntime/qv4context_p.h
@@ -130,7 +130,7 @@ struct Q_QML_EXPORT ExecutionContext : public Managed
V4_MANAGED(ExecutionContext, Managed)
Q_MANAGED_TYPE(ExecutionContext)
- Returned<CallContext> *newCallContext(FunctionObject *f, CallData *callData);
+ Heap::CallContext *newCallContext(FunctionObject *f, CallData *callData);
Heap::WithContext *newWithContext(Object *with);
Heap::CatchContext *newCatchContext(String *exceptionVarName, const ValueRef exceptionValue);
Heap::CallContext *newQmlContext(FunctionObject *f, Object *qml);
diff --git a/src/qml/jsruntime/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h
index 1c2b8af6bb..6119bed3ec 100644
--- a/src/qml/jsruntime/qv4global_p.h
+++ b/src/qml/jsruntime/qv4global_p.h
@@ -191,10 +191,6 @@ typedef Scoped<Object> ScopedObject;
typedef Scoped<ArrayObject> ScopedArrayObject;
typedef Scoped<FunctionObject> ScopedFunctionObject;
typedef Scoped<ExecutionContext> ScopedContext;
-template<typename T> struct Returned;
-typedef Returned<String> ReturnedString;
-typedef Returned<Object> ReturnedObject;
-typedef Returned<FunctionObject> ReturnedFunctionObject;
struct PersistentValuePrivate;
class PersistentValue;
diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h
index 116be8678f..5b9668b1c1 100644
--- a/src/qml/jsruntime/qv4managed_p.h
+++ b/src/qml/jsruntime/qv4managed_p.h
@@ -64,8 +64,6 @@ inline void qYouForgotTheQ_MANAGED_Macro(T1, T2) {}
typedef superClass SuperClass; \
static const QV4::ManagedVTable static_vtbl; \
static inline const QV4::ManagedVTable *staticVTable() { return &static_vtbl; } \
- template <typename _T> \
- QV4::Returned<_T> *asReturned() { return QV4::Returned<_T>::create(this); } \
V4_MANAGED_SIZE_TEST \
const QV4::Heap::DataClass *d() const { return &static_cast<const QV4::Heap::DataClass &>(Managed::data); } \
QV4::Heap::DataClass *d() { return &static_cast<QV4::Heap::DataClass &>(Managed::data); }
@@ -76,8 +74,6 @@ inline void qYouForgotTheQ_MANAGED_Macro(T1, T2) {}
typedef superClass SuperClass; \
static const QV4::ObjectVTable static_vtbl; \
static inline const QV4::ManagedVTable *staticVTable() { return &static_vtbl.managedVTable; } \
- template <typename _T> \
- QV4::Returned<_T> *asReturned() { return QV4::Returned<_T>::create(this); } \
V4_MANAGED_SIZE_TEST \
const Data *d() const { return &static_cast<const Data &>(Managed::data); } \
Data *d() { return &static_cast<Data &>(Managed::data); }
@@ -89,8 +85,6 @@ inline void qYouForgotTheQ_MANAGED_Macro(T1, T2) {}
typedef superClass SuperClass; \
static const QV4::ObjectVTable static_vtbl; \
static inline const QV4::ManagedVTable *staticVTable() { return &static_vtbl.managedVTable; } \
- template <typename _T> \
- QV4::Returned<_T> *asReturned() { return QV4::Returned<_T>::create(this); } \
V4_MANAGED_SIZE_TEST \
const QV4::Heap::DataClass *d() const { return &static_cast<const QV4::Heap::DataClass &>(Managed::data); } \
QV4::Heap::DataClass *d() { return &static_cast<QV4::Heap::DataClass &>(Managed::data); }
diff --git a/src/qml/jsruntime/qv4mm.cpp b/src/qml/jsruntime/qv4mm.cpp
index 2e15c249ca..cfaa6044f5 100644
--- a/src/qml/jsruntime/qv4mm.cpp
+++ b/src/qml/jsruntime/qv4mm.cpp
@@ -301,12 +301,12 @@ void MemoryManager::mark()
// managed objects in the loop down there doesn't make then end up as leftovers
// on the stack and thus always get collected.
for (PersistentValuePrivate *weak = m_weakValues; weak; weak = weak->next) {
- if (!weak->refcount)
+ if (!weak->refcount || !weak->value.isManaged())
continue;
- Returned<QObjectWrapper> *qobjectWrapper = weak->value.as<QObjectWrapper>();
+ QObjectWrapper *qobjectWrapper = weak->value.managed()->as<QObjectWrapper>();
if (!qobjectWrapper)
continue;
- QObject *qobject = qobjectWrapper->getPointer()->object();
+ QObject *qobject = qobjectWrapper->object();
if (!qobject)
continue;
bool keepAlive = QQmlData::keepAliveDuringGarbageCollection(qobject);
@@ -321,7 +321,7 @@ void MemoryManager::mark()
}
if (keepAlive)
- qobjectWrapper->getPointer()->mark(m_d->engine);
+ qobjectWrapper->mark(m_d->engine);
if (m_d->engine->jsStackTop >= m_d->engine->jsStackLimit)
drainMarkStack(m_d->engine, markBase);
diff --git a/src/qml/jsruntime/qv4persistent_p.h b/src/qml/jsruntime/qv4persistent_p.h
index 43d1b6e374..9ccab914a7 100644
--- a/src/qml/jsruntime/qv4persistent_p.h
+++ b/src/qml/jsruntime/qv4persistent_p.h
@@ -74,13 +74,9 @@ public:
PersistentValue(const ValueRef val);
PersistentValue(ReturnedValue val);
- template<typename T>
- PersistentValue(Returned<T> *obj);
PersistentValue &operator=(const ValueRef other);
PersistentValue &operator=(const ScopedValue &other);
PersistentValue &operator =(ReturnedValue other);
- template<typename T>
- PersistentValue &operator=(Returned<T> *obj);
PersistentValue &operator=(Heap::Base *obj);
~PersistentValue();
@@ -120,13 +116,9 @@ public:
WeakValue(const ValueRef val);
WeakValue(const WeakValue &other);
WeakValue(ReturnedValue val);
- template<typename T>
- WeakValue(Returned<T> *obj);
WeakValue &operator=(const WeakValue &other);
WeakValue &operator=(const ValueRef other);
WeakValue &operator =(const ReturnedValue &other);
- template<typename T>
- WeakValue &operator=(Returned<T> *obj);
~WeakValue();
diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h
index 85ffd81da1..f5729348f1 100644
--- a/src/qml/jsruntime/qv4scopedvalue_p.h
+++ b/src/qml/jsruntime/qv4scopedvalue_p.h
@@ -140,16 +140,6 @@ struct ScopedValue
#endif
}
- template<typename T>
- ScopedValue(const Scope &scope, Returned<T> *t)
- {
- ptr = scope.engine->jsStackTop++;
- *ptr = t->getPointer() ? Value::fromManaged(t->getPointer()) : Primitive::undefinedValue();
-#ifndef QT_NO_DEBUG
- ++scope.size;
-#endif
- }
-
ScopedValue &operator=(const Value &v) {
*ptr = v;
return *this;
@@ -173,12 +163,6 @@ struct ScopedValue
return *this;
}
- template<typename T>
- ScopedValue &operator=(Returned<T> *t) {
- *ptr = t->getPointer() ? Value::fromManaged(t->getPointer()) : Primitive::undefinedValue();
- return *this;
- }
-
ScopedValue &operator=(const ScopedValue &other) {
*ptr = *other.ptr;
return *this;
@@ -287,26 +271,6 @@ struct Scoped
#endif
}
- template<typename X>
- Scoped(const Scope &scope, Returned<X> *x)
- {
- ptr = scope.engine->jsStackTop++;
- setPointer(Returned<T>::getPointer(x));
-#ifndef QT_NO_DEBUG
- ++scope.size;
-#endif
- }
-
- template<typename X>
- Scoped(const Scope &scope, Returned<X> *x, _Cast)
- {
- ptr = scope.engine->jsStackTop++;
- setPointer(managed_cast<T>(x->getPointer()));
-#ifndef QT_NO_DEBUG
- ++scope.size;
-#endif
- }
-
Scoped(const Scope &scope, const ReturnedValue &v)
{
ptr = scope.engine->jsStackTop++;
@@ -359,12 +323,6 @@ struct Scoped
return *this;
}
- template<typename X>
- Scoped<T> &operator=(Returned<X> *x) {
- setPointer(Returned<T>::getPointer(x));
- return *this;
- }
-
operator T *() {
return static_cast<T *>(ptr->managed());
}
@@ -392,8 +350,6 @@ struct Scoped
#endif
}
- Returned<T> *asReturned() const { return Returned<T>::create(static_cast<typename T::Data*>(ptr->heapObject())); }
-
Value *ptr;
};
@@ -458,13 +414,6 @@ inline Scoped<T> &Scoped<T>::operator=(const ValueRef &v)
return *this;
}
-template <typename T>
-inline Value &Value::operator=(Returned<T> *t)
-{
- val = t->getPointer()->asReturnedValue();
- return *this;
-}
-
inline Value &Value::operator =(const ScopedValue &v)
{
val = v.ptr->val;
@@ -485,12 +434,6 @@ inline Value &Value::operator=(const ValueRef v)
}
template<typename T>
-inline Returned<T> *Value::as()
-{
- return Returned<T>::create(value_cast<T>(*this));
-}
-
-template<typename T>
inline TypedValue<T> &TypedValue<T>::operator =(T *t)
{
m = t ? &t->data : 0;
@@ -510,13 +453,6 @@ inline TypedValue<T> &TypedValue<T>::operator =(const Scoped<T> &v)
return *this;
}
-template<typename T>
-inline TypedValue<T> &TypedValue<T>::operator=(Returned<T> *t)
-{
- val = t->getPointer()->asReturnedValue();
- return *this;
-}
-
//template<typename T>
//inline TypedValue<T> &TypedValue<T>::operator =(const ManagedRef<T> &v)
//{
@@ -531,47 +467,16 @@ inline TypedValue<T> &TypedValue<T>::operator=(const TypedValue<T> &t)
return *this;
}
-template<typename T>
-inline Returned<T> * TypedValue<T>::ret() const
-{
- return Returned<T>::create(static_cast<typename T::Data *>(heapObject()));
-}
-
inline Primitive::operator ValueRef()
{
return ValueRef(this);
}
-
-template<typename T>
-PersistentValue::PersistentValue(Returned<T> *obj)
- : d(new PersistentValuePrivate(QV4::Value::fromManaged(obj->getPointer())))
-{
-}
-
-template<typename T>
-inline PersistentValue &PersistentValue::operator=(Returned<T> *obj)
-{
- return operator=(QV4::Value::fromManaged(obj->getPointer()).asReturnedValue());
-}
-
inline PersistentValue &PersistentValue::operator=(const ScopedValue &other)
{
return operator=(other.asReturnedValue());
}
-template<typename T>
-inline WeakValue::WeakValue(Returned<T> *obj)
- : d(new PersistentValuePrivate(QV4::Value::fromManaged(obj->getPointer()), /*engine*/0, /*weak*/true))
-{
-}
-
-template<typename T>
-inline WeakValue &WeakValue::operator=(Returned<T> *obj)
-{
- return operator=(QV4::Value::fromManaged(obj->getPointer()).asReturnedValue());
-}
-
inline ValueRef::ValueRef(const ScopedValue &v)
: ptr(v.ptr)
{}
diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h
index a3b08ba865..71b712b3fd 100644
--- a/src/qml/jsruntime/qv4value_p.h
+++ b/src/qml/jsruntime/qv4value_p.h
@@ -83,20 +83,6 @@ struct Q_QML_EXPORT Base {
}
-template <typename T>
-struct Returned : private Heap::Base
-{
- static Returned<T> *create(T *t) { Q_ASSERT((void *)&t->data == (void *)t); return static_cast<Returned<T> *>(static_cast<Heap::Base*>(t ? &t->data : 0)); }
- static Returned<T> *create(typename T::Data *t) { return static_cast<Returned<T> *>(static_cast<Heap::Base*>(t)); }
- T *getPointer() { return reinterpret_cast<T *>(this); }
- template<typename X>
- static T *getPointer(Returned<X> *x) { return x->getPointer(); }
- template<typename X>
- Returned<X> *as() { return Returned<X>::create(Returned<X>::getPointer(this)); }
-
- inline ReturnedValue asReturnedValue();
-};
-
struct Q_QML_PRIVATE_EXPORT Value
{
/*
@@ -390,8 +376,6 @@ struct Q_QML_PRIVATE_EXPORT Value
Value &operator =(const ScopedValue &v);
Value &operator=(ReturnedValue v) { val = v; return *this; }
template<typename T>
- Value &operator=(Returned<T> *t);
- template<typename T>
Value &operator=(T *t) {
val = Value::fromManaged(t).val;
return *this;
@@ -408,8 +392,6 @@ struct Q_QML_PRIVATE_EXPORT Value
val = v.val;
return *this;
}
- template<typename T>
- inline Returned<T> *as();
};
inline Managed *Value::asManaged() const
@@ -471,7 +453,6 @@ struct TypedValue : public Value
TypedValue &operator =(T *t);
TypedValue &operator =(const Scoped<T> &v);
// TypedValue &operator =(const ManagedRef<T> &v);
- TypedValue &operator =(Returned<T> *t);
TypedValue &operator =(const TypedValue<T> &t);
@@ -481,7 +462,6 @@ struct TypedValue : public Value
T *operator->() { return static_cast<T *>(managed()); }
const T *operator->() const { return static_cast<T *>(managed()); }
T *getPointer() const { return static_cast<T *>(managed()); }
- Returned<T> *ret() const;
void mark(ExecutionEngine *e) { if (managed()) managed()->mark(e); }
};
@@ -520,11 +500,6 @@ struct Encode {
val = v;
}
- template<typename T>
- Encode(Returned<T> *t) {
- val = t->getPointer()->asReturnedValue();
- }
-
Encode(Heap::Base *o) {
Q_ASSERT(o);
val = Value::fromHeapObject(o).asReturnedValue();
@@ -556,11 +531,6 @@ struct ValueRef {
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;
@@ -607,9 +577,6 @@ T *value_cast(const Value &v)
template<typename T>
ReturnedValue value_convert(ExecutionEngine *e, const Value &v);
-template <typename T>
-ReturnedValue Returned<T>::asReturnedValue() { return Value::fromHeapObject(this).asReturnedValue(); }
-
}
QT_END_NAMESPACE