aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-05-08 13:14:40 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2013-05-08 15:16:03 +0200
commitfe5869292055a3ff94cd90b8a9d2816d7b874fe3 (patch)
treedaea927c4fbc8faa92ad437ae321761eb2eb3431
parentf44e3f05650ce540aa2a0392ed547a900839befa (diff)
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 <simon.hausmann@digia.com>
-rw-r--r--src/imports/localstorage/plugin.cpp1
-rw-r--r--src/imports/xmllistmodel/qqmlxmllistmodel.cpp1
-rw-r--r--src/qml/qml/v4/qv4engine_p.h1
-rw-r--r--src/qml/qml/v4/qv4internalclass.cpp1
-rw-r--r--src/qml/qml/v4/qv4object_p.h10
-rw-r--r--src/qml/qml/v4/qv4value_p.h3
-rw-r--r--src/qml/qml/v8/qjsvalueiterator.cpp1
-rw-r--r--src/qml/qml/v8/qv4sqlerrors.cpp1
-rw-r--r--src/quick/items/context2d/qquickcontext2d.cpp1
9 files changed, 19 insertions, 1 deletions
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 <QtCore/qdir.h>
#include <private/qv4sqlerrors_p.h>
#include <private/qv4engine_p.h>
+#include <private/qv4object_p.h>
#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 <private/qv8engine_p.h>
#include <private/qv4value_p.h>
#include <private/qv4engine_p.h>
+#include <private/qv4object_p.h>
#include <QDebug>
#include <QStringList>
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 <qv4string_p.h>
#include <qv4engine_p.h>
#include <qv4identifier_p.h>
+#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 <qqmlengine.h>
#include <private/qv4domerrors_p.h>
#include <private/qv4engine_p.h>
+#include <private/qv4object_p.h>
#include <QtCore/qnumeric.h>
#include <private/qquickwindow_p.h>