aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmllistwrapper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/qml/qqmllistwrapper.cpp')
-rw-r--r--src/qml/qml/qqmllistwrapper.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/qml/qml/qqmllistwrapper.cpp b/src/qml/qml/qqmllistwrapper.cpp
index 8aa107dc17..43677e0d78 100644
--- a/src/qml/qml/qqmllistwrapper.cpp
+++ b/src/qml/qml/qqmllistwrapper.cpp
@@ -140,12 +140,13 @@ ReturnedValue QmlListWrapper::getIndexed(const Managed *m, uint index, bool *has
return Primitive::undefinedValue().asReturnedValue();
}
-void QmlListWrapper::put(Managed *m, String *name, const Value &value)
+bool QmlListWrapper::put(Managed *m, String *name, const Value &value)
{
// doesn't do anything. Should we throw?
Q_UNUSED(m);
Q_UNUSED(name);
Q_UNUSED(value);
+ return false;
}
void QmlListWrapper::advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attrs)
@@ -165,4 +166,29 @@ void QmlListWrapper::advanceIterator(Managed *m, ObjectIterator *it, Value *name
return QV4::Object::advanceIterator(m, it, name, index, p, attrs);
}
+void PropertyListPrototype::init(ExecutionEngine *)
+{
+ defineDefaultProperty(QStringLiteral("push"), method_push, 1);
+}
+
+void PropertyListPrototype::method_push(const BuiltinFunction *, Scope &scope, CallData *callData)
+{
+ ScopedObject instance(scope, callData->thisObject.toObject(scope.engine));
+ if (!instance)
+ RETURN_UNDEFINED();
+ QmlListWrapper *w = instance->as<QmlListWrapper>();
+ if (!w)
+ RETURN_UNDEFINED();
+ if (!w->d()->property().append)
+ THROW_GENERIC_ERROR("List doesn't define an Append function");
+
+ QV4::ScopedObject so(scope);
+ for (int i = 0; i < callData->argc; ++i)
+ {
+ so = callData->args[i].toObject(scope.engine);
+ if (QV4::QObjectWrapper *wrapper = so->as<QV4::QObjectWrapper>())
+ w->d()->property().append(&w->d()->property(), wrapper->object() );
+ }
+}
+
QT_END_NAMESPACE