From 4e11a7a9e8ba49474bfdbdb9f4c565ebd39de595 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 8 May 2014 08:29:53 +0200 Subject: Get rid of ManagedRef Change-Id: I6883fc5d8c5a13f1e61966c9f6e7bf0bedbfbc8a Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4global_p.h | 1 - src/qml/jsruntime/qv4managed_p.h | 63 ------------------------------------ src/qml/jsruntime/qv4persistent_p.h | 2 -- src/qml/jsruntime/qv4scopedvalue_p.h | 22 ------------- 4 files changed, 88 deletions(-) (limited to 'src/qml') diff --git a/src/qml/jsruntime/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h index b601f0a668..38d353c2e9 100644 --- a/src/qml/jsruntime/qv4global_p.h +++ b/src/qml/jsruntime/qv4global_p.h @@ -163,7 +163,6 @@ template struct Returned; typedef Returned ReturnedString; typedef Returned ReturnedObject; typedef Returned ReturnedFunctionObject; -struct ManagedRef; struct PersistentValuePrivate; class PersistentValue; diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h index 271fad7255..c70b717b0f 100644 --- a/src/qml/jsruntime/qv4managed_p.h +++ b/src/qml/jsruntime/qv4managed_p.h @@ -356,69 +356,6 @@ inline FunctionObject *managed_cast(Managed *m) return m->asFunctionObject(); } - -Value *extractValuePointer(const ScopedValue &); -template -Value *extractValuePointer(const Scoped &); - -#define DEFINE_REF_METHODS(Class, Base) \ - Class##Ref(const QV4::ScopedValue &v) \ - { QV4::Value *val = extractValuePointer(v); ptr = QV4::value_cast(*val) ? val : 0; } \ - Class##Ref(const QV4::Scoped &v) { ptr = extractValuePointer(v); } \ - Class##Ref(QV4::TypedValue &v) { ptr = &v; } \ - Class##Ref(QV4::Value &v) { ptr = QV4::value_cast(v) ? &v : 0; } \ - Class##Ref &operator=(Class *t) { \ - if (sizeof(void *) == 4) \ - ptr->tag = QV4::Value::Managed_Type; \ - ptr->m = t; \ - return *this; \ - } \ - Class##Ref &operator=(QV4::Returned *t) { \ - if (sizeof(void *) == 4) \ - ptr->tag = QV4::Value::Managed_Type; \ - ptr->m = t->getPointer(); \ - return *this; \ - } \ - operator const Class *() const { return ptr ? static_cast(ptr->managed()) : 0; } \ - const Class *operator->() const { return static_cast(ptr->managed()); } \ - operator Class *() { return ptr ? static_cast(ptr->managed()) : 0; } \ - Class *operator->() { return static_cast(ptr->managed()); } \ - Class *getPointer() const { return static_cast(ptr->managed()); } \ - operator QV4::Returned *() const { return ptr ? QV4::Returned::create(getPointer()) : 0; } \ - static Class##Ref null() { Class##Ref c; c.ptr = 0; return c; } \ -protected: \ - Class##Ref() {} \ -public: \ - -#define DEFINE_REF(Class, Base) \ -struct Class##Ref : public Base##Ref \ -{ DEFINE_REF_METHODS(Class, Base) } \ - - -struct ManagedRef { - // Important: Do NOT add a copy constructor to this class or any derived 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. - DEFINE_REF_METHODS(Managed, Managed); - - bool operator==(const ManagedRef &other) { - if (ptr == other.ptr) - return true; - return ptr && other.ptr && ptr->m == other.ptr->m; - } - bool operator!=(const ManagedRef &other) { - return !operator==(other); - } - bool operator!() const { return !ptr || !ptr->managed(); } - - bool isNull() const { return !ptr; } - ReturnedValue asReturnedValue() const { return ptr ? ptr->val : Primitive::undefinedValue().asReturnedValue(); } - -public: - Value *ptr; -}; - } diff --git a/src/qml/jsruntime/qv4persistent_p.h b/src/qml/jsruntime/qv4persistent_p.h index 21f37f3d96..7b0f80e06a 100644 --- a/src/qml/jsruntime/qv4persistent_p.h +++ b/src/qml/jsruntime/qv4persistent_p.h @@ -84,13 +84,11 @@ public: PersistentValue(ReturnedValue val); template PersistentValue(Returned *obj); - PersistentValue(const ManagedRef obj); PersistentValue &operator=(const ValueRef other); PersistentValue &operator=(const ScopedValue &other); PersistentValue &operator =(ReturnedValue other); template PersistentValue &operator=(Returned *obj); - PersistentValue &operator=(const ManagedRef obj); ~PersistentValue(); ReturnedValue value() const { diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h index 13a1f33610..fc339904e9 100644 --- a/src/qml/jsruntime/qv4scopedvalue_p.h +++ b/src/qml/jsruntime/qv4scopedvalue_p.h @@ -522,22 +522,12 @@ PersistentValue::PersistentValue(Returned *obj) { } -inline PersistentValue::PersistentValue(const ManagedRef obj) - : d(new PersistentValuePrivate(obj.asReturnedValue())) -{ -} - template inline PersistentValue &PersistentValue::operator=(Returned *obj) { return operator=(QV4::Value::fromManaged(obj->getPointer()).asReturnedValue()); } -inline PersistentValue &PersistentValue::operator=(const ManagedRef obj) -{ - return operator=(obj.asReturnedValue()); -} - inline PersistentValue &PersistentValue::operator=(const ScopedValue &other) { return operator=(other.asReturnedValue()); @@ -578,18 +568,6 @@ inline ValueRef &ValueRef::operator=(const ScopedValue &o) return *this; } - -inline Value *extractValuePointer(const ScopedValue &v) -{ - return v.ptr; -} - -template -Value *extractValuePointer(const Scoped &v) -{ - return v.ptr; -} - struct ScopedProperty { ScopedProperty(Scope &scope) -- cgit v1.2.3