From fe5869292055a3ff94cd90b8a9d2816d7b874fe3 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 8 May 2013 13:14:40 +0200 Subject: Add more convenient get/put API to QV4::Object We can retrieve the current context from the Object itself, so it's possible to offer a simplified get/put API that doesn't require a context argument. Clean up a circular include dependency between qv4engine and qv4object. Change-Id: I39a37d479ace1ffbfe8ac59b393cab8e4be07677 Reviewed-by: Simon Hausmann --- src/imports/localstorage/plugin.cpp | 1 + src/imports/xmllistmodel/qqmlxmllistmodel.cpp | 1 + src/qml/qml/v4/qv4engine_p.h | 1 - src/qml/qml/v4/qv4internalclass.cpp | 1 + src/qml/qml/v4/qv4object_p.h | 10 ++++++++++ src/qml/qml/v4/qv4value_p.h | 3 +++ src/qml/qml/v8/qjsvalueiterator.cpp | 1 + src/qml/qml/v8/qv4sqlerrors.cpp | 1 + src/quick/items/context2d/qquickcontext2d.cpp | 1 + 9 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp index 498e541a25..1797db3e0c 100644 --- a/src/imports/localstorage/plugin.cpp +++ b/src/imports/localstorage/plugin.cpp @@ -56,6 +56,7 @@ #include #include #include +#include #define V8THROW_SQL(error, desc) \ { \ diff --git a/src/imports/xmllistmodel/qqmlxmllistmodel.cpp b/src/imports/xmllistmodel/qqmlxmllistmodel.cpp index 668479f5ba..77c04bed61 100644 --- a/src/imports/xmllistmodel/qqmlxmllistmodel.cpp +++ b/src/imports/xmllistmodel/qqmlxmllistmodel.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include diff --git a/src/qml/qml/v4/qv4engine_p.h b/src/qml/qml/v4/qv4engine_p.h index daacebda1c..95b1a725a8 100644 --- a/src/qml/qml/v4/qv4engine_p.h +++ b/src/qml/qml/v4/qv4engine_p.h @@ -43,7 +43,6 @@ #include "qv4global_p.h" #include "qv4isel_p.h" -#include "qv4object_p.h" #include "qv4util_p.h" #include "qv4context_p.h" #include "qv4property_p.h" diff --git a/src/qml/qml/v4/qv4internalclass.cpp b/src/qml/qml/v4/qv4internalclass.cpp index 391e05f10a..6fbc3d43b1 100644 --- a/src/qml/qml/v4/qv4internalclass.cpp +++ b/src/qml/qml/v4/qv4internalclass.cpp @@ -43,6 +43,7 @@ #include #include #include +#include "qv4object_p.h" using namespace QV4; diff --git a/src/qml/qml/v4/qv4object_p.h b/src/qml/qml/v4/qv4object_p.h index e1cf57c513..17f187aa13 100644 --- a/src/qml/qml/v4/qv4object_p.h +++ b/src/qml/qml/v4/qv4object_p.h @@ -177,6 +177,8 @@ struct Q_QML_EXPORT Object: Managed { Property *insertMember(String *s, PropertyAttributes attributes); + inline ExecutionEngine *engine() const { return internalClass->engine; } + // Array handling uint allocArrayValue() { @@ -323,6 +325,14 @@ public: void arrayReserve(uint n); void ensureArrayAttributes(); + inline Value get(String *name) + { return vtbl->get(this, engine()->current, name, 0); } + inline Value getIndexed(uint idx) + { return vtbl->getIndexed(this, engine()->current, idx, 0); } + inline void put(String *name, const Value &v) + { vtbl->put(this, engine()->current, name, v); } + inline void putIndexed(uint idx, const Value &v) + { vtbl->putIndexed(this, engine()->current, idx, v); } using Managed::get; using Managed::getIndexed; using Managed::put; diff --git a/src/qml/qml/v4/qv4value_p.h b/src/qml/qml/v4/qv4value_p.h index 3cc651d655..bb4ea55534 100644 --- a/src/qml/qml/v4/qv4value_p.h +++ b/src/qml/qml/v4/qv4value_p.h @@ -585,6 +585,9 @@ public: operator Value() const { return value(); } bool isEmpty() const { return !d; } + void clear() { + *this = PersistentValue(); + } private: PersistentValuePrivate *d; diff --git a/src/qml/qml/v8/qjsvalueiterator.cpp b/src/qml/qml/v8/qjsvalueiterator.cpp index a547918a09..555cbf0215 100644 --- a/src/qml/qml/v8/qjsvalueiterator.cpp +++ b/src/qml/qml/v8/qjsvalueiterator.cpp @@ -43,6 +43,7 @@ #include "qjsvalueiterator_p.h" #include "qjsvalue_p.h" #include "private/qv4string_p.h" +#include "private/qv4object_p.h" QT_BEGIN_NAMESPACE diff --git a/src/qml/qml/v8/qv4sqlerrors.cpp b/src/qml/qml/v8/qv4sqlerrors.cpp index 246a6f6026..bd5a9fdc83 100644 --- a/src/qml/qml/v8/qv4sqlerrors.cpp +++ b/src/qml/qml/v8/qv4sqlerrors.cpp @@ -41,6 +41,7 @@ #include "qv4sqlerrors_p.h" #include "private/qv4engine_p.h" +#include "private/qv4object_p.h" QT_BEGIN_NAMESPACE diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp index 196394f253..78c0e2ebb5 100644 --- a/src/quick/items/context2d/qquickcontext2d.cpp +++ b/src/quick/items/context2d/qquickcontext2d.cpp @@ -61,6 +61,7 @@ #include #include #include +#include #include #include -- cgit v1.2.3