From b04b5b57e92af2e036ffb65e2dd7cbba4b6c3c6a Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 11 Nov 2014 23:30:54 +0100 Subject: Remove the remaining uses of Returned Change-Id: I493b75365d3c6fbf6965986d73e7aa0b659ded67 Reviewed-by: Lars Knoll --- src/qml/jsapi/qjsvalue.cpp | 9 ++-- src/qml/jsruntime/qv4arraydata_p.h | 2 - src/qml/jsruntime/qv4context.cpp | 4 +- src/qml/jsruntime/qv4context_p.h | 2 +- src/qml/jsruntime/qv4global_p.h | 4 -- src/qml/jsruntime/qv4managed_p.h | 6 --- src/qml/jsruntime/qv4mm.cpp | 8 +-- src/qml/jsruntime/qv4persistent_p.h | 8 --- src/qml/jsruntime/qv4scopedvalue_p.h | 95 ------------------------------------ src/qml/jsruntime/qv4value_p.h | 33 ------------- 10 files changed, 13 insertions(+), 158 deletions(-) (limited to 'src') 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 *o = d->value.as(); - if (!o) + if (!d->engine) + return 0; + QV4::Scope scope(d->engine); + QV4::Scoped 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 \ - QV4::Returned *asReturned() { return QV4::Returned::create(this); } \ V4_MANAGED_SIZE_TEST \ const QV4::Heap::Data *d() const { return &static_cast(Managed::data); } \ QV4::Heap::Data *d() { return &static_cast(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 *ExecutionContext::newCallContext(FunctionObject *function, CallData *callData) +Heap::CallContext *ExecutionContext::newCallContext(FunctionObject *function, CallData *callData) { Q_ASSERT(function->function()); @@ -78,7 +78,7 @@ Returned *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::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 *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 ScopedObject; typedef Scoped ScopedArrayObject; typedef Scoped ScopedFunctionObject; typedef Scoped ScopedContext; -template struct Returned; -typedef Returned ReturnedString; -typedef Returned ReturnedObject; -typedef Returned 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 \ - QV4::Returned<_T> *asReturned() { return QV4::Returned<_T>::create(this); } \ V4_MANAGED_SIZE_TEST \ const QV4::Heap::DataClass *d() const { return &static_cast(Managed::data); } \ QV4::Heap::DataClass *d() { return &static_cast(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 \ - QV4::Returned<_T> *asReturned() { return QV4::Returned<_T>::create(this); } \ V4_MANAGED_SIZE_TEST \ const Data *d() const { return &static_cast(Managed::data); } \ Data *d() { return &static_cast(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 \ - QV4::Returned<_T> *asReturned() { return QV4::Returned<_T>::create(this); } \ V4_MANAGED_SIZE_TEST \ const QV4::Heap::DataClass *d() const { return &static_cast(Managed::data); } \ QV4::Heap::DataClass *d() { return &static_cast(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 = weak->value.as(); + QObjectWrapper *qobjectWrapper = weak->value.managed()->as(); 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 - PersistentValue(Returned *obj); PersistentValue &operator=(const ValueRef other); PersistentValue &operator=(const ScopedValue &other); PersistentValue &operator =(ReturnedValue other); - template - PersistentValue &operator=(Returned *obj); PersistentValue &operator=(Heap::Base *obj); ~PersistentValue(); @@ -120,13 +116,9 @@ public: WeakValue(const ValueRef val); WeakValue(const WeakValue &other); WeakValue(ReturnedValue val); - template - WeakValue(Returned *obj); WeakValue &operator=(const WeakValue &other); WeakValue &operator=(const ValueRef other); WeakValue &operator =(const ReturnedValue &other); - template - WeakValue &operator=(Returned *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 - ScopedValue(const Scope &scope, Returned *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 - ScopedValue &operator=(Returned *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 - Scoped(const Scope &scope, Returned *x) - { - ptr = scope.engine->jsStackTop++; - setPointer(Returned::getPointer(x)); -#ifndef QT_NO_DEBUG - ++scope.size; -#endif - } - - template - Scoped(const Scope &scope, Returned *x, _Cast) - { - ptr = scope.engine->jsStackTop++; - setPointer(managed_cast(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 - Scoped &operator=(Returned *x) { - setPointer(Returned::getPointer(x)); - return *this; - } - operator T *() { return static_cast(ptr->managed()); } @@ -392,8 +350,6 @@ struct Scoped #endif } - Returned *asReturned() const { return Returned::create(static_cast(ptr->heapObject())); } - Value *ptr; }; @@ -458,13 +414,6 @@ inline Scoped &Scoped::operator=(const ValueRef &v) return *this; } -template -inline Value &Value::operator=(Returned *t) -{ - val = t->getPointer()->asReturnedValue(); - return *this; -} - inline Value &Value::operator =(const ScopedValue &v) { val = v.ptr->val; @@ -484,12 +433,6 @@ inline Value &Value::operator=(const ValueRef v) return *this; } -template -inline Returned *Value::as() -{ - return Returned::create(value_cast(*this)); -} - template inline TypedValue &TypedValue::operator =(T *t) { @@ -510,13 +453,6 @@ inline TypedValue &TypedValue::operator =(const Scoped &v) return *this; } -template -inline TypedValue &TypedValue::operator=(Returned *t) -{ - val = t->getPointer()->asReturnedValue(); - return *this; -} - //template //inline TypedValue &TypedValue::operator =(const ManagedRef &v) //{ @@ -531,47 +467,16 @@ inline TypedValue &TypedValue::operator=(const TypedValue &t) return *this; } -template -inline Returned * TypedValue::ret() const -{ - return Returned::create(static_cast(heapObject())); -} - inline Primitive::operator ValueRef() { return ValueRef(this); } - -template -PersistentValue::PersistentValue(Returned *obj) - : d(new PersistentValuePrivate(QV4::Value::fromManaged(obj->getPointer()))) -{ -} - -template -inline PersistentValue &PersistentValue::operator=(Returned *obj) -{ - return operator=(QV4::Value::fromManaged(obj->getPointer()).asReturnedValue()); -} - inline PersistentValue &PersistentValue::operator=(const ScopedValue &other) { return operator=(other.asReturnedValue()); } -template -inline WeakValue::WeakValue(Returned *obj) - : d(new PersistentValuePrivate(QV4::Value::fromManaged(obj->getPointer()), /*engine*/0, /*weak*/true)) -{ -} - -template -inline WeakValue &WeakValue::operator=(Returned *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 -struct Returned : private Heap::Base -{ - static Returned *create(T *t) { Q_ASSERT((void *)&t->data == (void *)t); return static_cast *>(static_cast(t ? &t->data : 0)); } - static Returned *create(typename T::Data *t) { return static_cast *>(static_cast(t)); } - T *getPointer() { return reinterpret_cast(this); } - template - static T *getPointer(Returned *x) { return x->getPointer(); } - template - Returned *as() { return Returned::create(Returned::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 - Value &operator=(Returned *t); - template 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 - inline Returned *as(); }; inline Managed *Value::asManaged() const @@ -471,7 +453,6 @@ struct TypedValue : public Value TypedValue &operator =(T *t); TypedValue &operator =(const Scoped &v); // TypedValue &operator =(const ManagedRef &v); - TypedValue &operator =(Returned *t); TypedValue &operator =(const TypedValue &t); @@ -481,7 +462,6 @@ struct TypedValue : public Value T *operator->() { return static_cast(managed()); } const T *operator->() const { return static_cast(managed()); } T *getPointer() const { return static_cast(managed()); } - Returned *ret() const; void mark(ExecutionEngine *e) { if (managed()) managed()->mark(e); } }; @@ -520,11 +500,6 @@ struct Encode { val = v; } - template - Encode(Returned *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 - ValueRef &operator=(Returned *v) { - ptr->val = v->asReturnedValue(); - return *this; - } operator const Value *() const { return ptr; @@ -607,9 +577,6 @@ T *value_cast(const Value &v) template ReturnedValue value_convert(ExecutionEngine *e, const Value &v); -template -ReturnedValue Returned::asReturnedValue() { return Value::fromHeapObject(this).asReturnedValue(); } - } QT_END_NAMESPACE -- cgit v1.2.3