aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@theqtcompany.com>2015-06-10 14:49:16 +0200
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-06-18 16:42:42 +0000
commitfe9b63780da81fa8e3746e519dda320d57436503 (patch)
tree42147e0198befd5265e80578f7b1799b2b2b2640 /src/qml
parentd4801fc76a0dff43abd3c4f46fb34553c8c5efd1 (diff)
Get rid of QQmlIdObjectsArray
The context wrapper can do this directly, and give access to the array by index. Simplifies code, and is one less object we need to allocate on the JS heap. Change-Id: I9d9d3a47920e97c42234a27aa66cd5ae3cc28085 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp4
-rw-r--r--src/qml/qml/qqmlcontextwrapper.cpp42
-rw-r--r--src/qml/qml/qqmlcontextwrapper_p.h18
3 files changed, 5 insertions, 59 deletions
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index 4026be75e4..6d7aeafb77 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -1335,9 +1335,7 @@ ReturnedValue Runtime::regexpLiteral(ExecutionEngine *engine, int id)
ReturnedValue Runtime::getQmlIdArray(NoThrowEngine *engine)
{
Q_ASSERT(engine->qmlContextObject());
- Scope scope(engine);
- Scoped<QmlContextWrapper> wrapper(scope, engine->qmlContextObject());
- return wrapper->idObjectsArray();
+ return engine->qmlContextObject()->asReturnedValue();
}
ReturnedValue Runtime::getQmlContextObject(NoThrowEngine *engine)
diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp
index d06c557dfe..3d704d0b4e 100644
--- a/src/qml/qml/qqmlcontextwrapper.cpp
+++ b/src/qml/qml/qqmlcontextwrapper.cpp
@@ -61,7 +61,6 @@ Heap::QmlContextWrapper::QmlContextWrapper(QV4::ExecutionEngine *engine, QQmlCon
, isNullWrapper(false)
, context(context)
, scopeObject(scopeObject)
- , idObjectsWrapper(Q_NULLPTR)
{
}
@@ -332,14 +331,6 @@ void QmlContextWrapper::put(Managed *m, String *name, const Value &value)
Object::put(m, name, value);
}
-void QmlContextWrapper::markObjects(Heap::Base *m, ExecutionEngine *engine)
-{
- QmlContextWrapper::Data *This = static_cast<QmlContextWrapper::Data *>(m);
- if (This->idObjectsWrapper)
- This->idObjectsWrapper->mark(engine);
- Object::markObjects(m, engine);
-}
-
void QmlContextWrapper::registerQmlDependencies(ExecutionEngine *engine, const CompiledData::Function *compiledFunction)
{
// Let the caller check and avoid the function call :)
@@ -383,15 +374,6 @@ void QmlContextWrapper::registerQmlDependencies(ExecutionEngine *engine, const C
}
-ReturnedValue QmlContextWrapper::idObjectsArray()
-{
- if (!d()->idObjectsWrapper) {
- ExecutionEngine *v4 = engine();
- d()->idObjectsWrapper = v4->memoryManager->alloc<QQmlIdObjectsArray>(v4, this);
- }
- return d()->idObjectsWrapper->asReturnedValue();
-}
-
ReturnedValue QmlContextWrapper::qmlSingletonWrapper(ExecutionEngine *v4, String *name)
{
if (!d()->context->imports)
@@ -413,20 +395,11 @@ ReturnedValue QmlContextWrapper::qmlSingletonWrapper(ExecutionEngine *v4, String
return QJSValuePrivate::convertedToValue(engine(), siinfo->scriptApi(e));
}
-DEFINE_OBJECT_VTABLE(QQmlIdObjectsArray);
-
-Heap::QQmlIdObjectsArray::QQmlIdObjectsArray(ExecutionEngine *engine, QV4::QmlContextWrapper *contextWrapper)
- : Heap::Object(engine)
- , contextWrapper(contextWrapper->d())
-{
-}
-
-ReturnedValue QQmlIdObjectsArray::getIndexed(const Managed *m, uint index, bool *hasProperty)
+ReturnedValue QmlContextWrapper::getIndexed(const Managed *m, uint index, bool *hasProperty)
{
- Scope scope(static_cast<const QV4::QQmlIdObjectsArray*>(m)->engine());
- Scoped<QQmlIdObjectsArray> This(scope, static_cast<const QV4::QQmlIdObjectsArray*>(m));
- Scoped<QmlContextWrapper> contextWrapper(scope, This->d()->contextWrapper);
- QQmlContextData *context = contextWrapper->getContext();
+ const QV4::QmlContextWrapper *This = static_cast<const QV4::QmlContextWrapper *>(m);
+ Scope scope(This->engine());
+ QQmlContextData *context = This->getContext();
if (!context) {
if (hasProperty)
*hasProperty = false;
@@ -448,11 +421,4 @@ ReturnedValue QQmlIdObjectsArray::getIndexed(const Managed *m, uint index, bool
return QObjectWrapper::wrap(This->engine(), context->idValues[index].data());
}
-void QQmlIdObjectsArray::markObjects(Heap::Base *that, ExecutionEngine *engine)
-{
- QQmlIdObjectsArray::Data *This = static_cast<QQmlIdObjectsArray::Data *>(that);
- This->contextWrapper->mark(engine);
- Object::markObjects(that, engine);
-}
-
QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlcontextwrapper_p.h b/src/qml/qml/qqmlcontextwrapper_p.h
index 9bd95efaa6..f689ee857a 100644
--- a/src/qml/qml/qqmlcontextwrapper_p.h
+++ b/src/qml/qml/qqmlcontextwrapper_p.h
@@ -65,8 +65,6 @@ struct QmlContextWrapper;
namespace Heap {
-struct QQmlIdObjectsArray;
-
struct QmlContextWrapper : Object {
QmlContextWrapper(ExecutionEngine *engine, QQmlContextData *context, QObject *scopeObject, bool ownsContext = false);
~QmlContextWrapper();
@@ -76,12 +74,6 @@ struct QmlContextWrapper : Object {
QQmlGuardedContextData context;
QPointer<QObject> scopeObject;
- QQmlIdObjectsArray *idObjectsWrapper;
-};
-
-struct QQmlIdObjectsArray : Object {
- QQmlIdObjectsArray(QV4::ExecutionEngine *engine, QV4::QmlContextWrapper *contextWrapper);
- Pointer<QmlContextWrapper> contextWrapper;
};
}
@@ -107,22 +99,12 @@ struct Q_QML_EXPORT QmlContextWrapper : Object
static ReturnedValue get(const Managed *m, String *name, bool *hasProperty);
static void put(Managed *m, String *name, const Value &value);
- static void markObjects(Heap::Base *m, ExecutionEngine *engine);
static void registerQmlDependencies(ExecutionEngine *context, const CompiledData::Function *compiledFunction);
- ReturnedValue idObjectsArray();
ReturnedValue qmlSingletonWrapper(ExecutionEngine *e, String *name);
-};
-
-struct QQmlIdObjectsArray : public Object
-{
- V4_OBJECT2(QQmlIdObjectsArray, Object)
-
static ReturnedValue getIndexed(const Managed *m, uint index, bool *hasProperty);
- static void markObjects(Heap::Base *that, ExecutionEngine *engine);
-
};
}