aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-09-17 22:33:48 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-22 01:06:20 +0200
commit2d781c4ca42f50643fa37200073a2fb2644b3806 (patch)
tree9554dbea266f6fbb7820db018e39624b6c0f1353 /src
parent21198a676128a52e892557bc434035bcd1ddfaac (diff)
Cleanup ExecutionEngine::newBuiltinFunction() usages
And change the return type to be GC safe Change-Id: I6d7513962370fea4072a3d8c6b2c6f2d1705992e Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/imports/localstorage/plugin.cpp14
-rw-r--r--src/qml/jsruntime/qv4argumentsobject.cpp6
-rw-r--r--src/qml/jsruntime/qv4engine.cpp4
-rw-r--r--src/qml/jsruntime/qv4engine_p.h2
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp23
-rw-r--r--src/qml/jsruntime/qv4object.cpp23
-rw-r--r--src/qml/jsruntime/qv4objectproto.cpp4
-rw-r--r--src/qml/qml/qqmlcomponent.cpp17
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions.cpp23
-rw-r--r--src/qml/types/qqmldelegatemodel.cpp9
-rw-r--r--src/qml/types/qquickworkerscript.cpp4
-rw-r--r--src/qml/util/qqmladaptormodel.cpp23
12 files changed, 60 insertions, 92 deletions
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp
index 900a5a09a3..c72e61cd99 100644
--- a/src/imports/localstorage/plugin.cpp
+++ b/src/imports/localstorage/plugin.cpp
@@ -448,9 +448,7 @@ QQmlSqlDatabaseData::QQmlSqlDatabaseData(QV8Engine *engine)
Scoped<Object> proto(scope, v4->newObject());
proto->defineDefaultProperty(v4, QStringLiteral("transaction"), qmlsqldatabase_transaction);
proto->defineDefaultProperty(v4, QStringLiteral("readTransaction"), qmlsqldatabase_read_transaction);
- Property *p = proto->insertMember(v4->newString(QStringLiteral("version")),
- Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
- p->setGetter(v4->newBuiltinFunction(v4->rootContext, v4->newString(QStringLiteral("version")), qmlsqldatabase_version));
+ proto->defineAccessorProperty(v4->newString(QStringLiteral("version")), qmlsqldatabase_version, 0);
proto->defineDefaultProperty(v4, QStringLiteral("changeVersion"), qmlsqldatabase_changeVersion);
databaseProto = proto;
}
@@ -463,13 +461,9 @@ QQmlSqlDatabaseData::QQmlSqlDatabaseData(QV8Engine *engine)
{
Scoped<Object> proto(scope, v4->newObject());
proto->defineDefaultProperty(v4, QStringLiteral("item"), qmlsqldatabase_rows_item);
- Property *p = proto->insertMember(v4->newString(QStringLiteral("length")),
- Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
- p->setGetter(v4->newBuiltinFunction(v4->rootContext, v4->newString(QStringLiteral("length")), qmlsqldatabase_rows_length));
- p = proto->insertMember(v4->newString(QStringLiteral("forwardOnly")),
- Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
- p->setGetter(v4->newBuiltinFunction(v4->rootContext, v4->newString(QStringLiteral("forwardOnly")), qmlsqldatabase_rows_forwardOnly));
- p->setSetter(v4->newBuiltinFunction(v4->rootContext, v4->newString(QStringLiteral("setForwardOnly")), qmlsqldatabase_rows_setForwardOnly));
+ proto->defineAccessorProperty(v4->newString(QStringLiteral("length")), qmlsqldatabase_rows_length, 0);
+ proto->defineAccessorProperty(v4->newString(QStringLiteral("forwardOnly")),
+ qmlsqldatabase_rows_forwardOnly, qmlsqldatabase_rows_setForwardOnly);
rowsProto = proto;
}
}
diff --git a/src/qml/jsruntime/qv4argumentsobject.cpp b/src/qml/jsruntime/qv4argumentsobject.cpp
index 62937921aa..5af2c07b1a 100644
--- a/src/qml/jsruntime/qv4argumentsobject.cpp
+++ b/src/qml/jsruntime/qv4argumentsobject.cpp
@@ -58,11 +58,13 @@ ArgumentsObject::ArgumentsObject(CallContext *context)
vtbl = &static_vtbl;
type = Type_ArgumentsObject;
+ Scope scope(context);
+
if (context->strictMode) {
internalClass = engine()->strictArgumentsObjectClass;
- FunctionObject *thrower = context->engine->newBuiltinFunction(context, 0, throwTypeError);
- Property pd = Property::fromAccessor(thrower, thrower);
+ Scoped<FunctionObject> thrower(scope, context->engine->newBuiltinFunction(context, 0, throwTypeError));
+ Property pd = Property::fromAccessor(thrower.getPointer(), thrower.getPointer());
assert(CalleePropertyIndex == internalClass->find(context->engine->id_callee));
assert(CallerPropertyIndex == internalClass->find(context->engine->id_caller));
memberData[CalleePropertyIndex] = pd;
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 5bde6b8e46..c9d3716469 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -344,10 +344,10 @@ ExecutionContext *ExecutionEngine::pushGlobalContext()
return current;
}
-FunctionObject *ExecutionEngine::newBuiltinFunction(ExecutionContext *scope, String *name, ReturnedValue (*code)(SimpleCallContext *))
+Returned<FunctionObject> *ExecutionEngine::newBuiltinFunction(ExecutionContext *scope, String *name, ReturnedValue (*code)(SimpleCallContext *))
{
BuiltinFunction *f = new (memoryManager) BuiltinFunction(scope, name, code);
- return f;
+ return f->asReturned<FunctionObject>();
}
Returned<BoundFunction> *ExecutionEngine::newBoundFunction(ExecutionContext *scope, FunctionObject *target, Value boundThis, const QVector<Value> &boundArgs)
diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h
index d00ef0ea35..f85fd1a6d7 100644
--- a/src/qml/jsruntime/qv4engine_p.h
+++ b/src/qml/jsruntime/qv4engine_p.h
@@ -261,7 +261,7 @@ struct Q_QML_EXPORT ExecutionEngine
void pushContext(SimpleCallContext *context);
ExecutionContext *popContext();
- FunctionObject *newBuiltinFunction(ExecutionContext *scope, String *name, ReturnedValue (*code)(SimpleCallContext *));
+ Returned<FunctionObject> *newBuiltinFunction(ExecutionContext *scope, String *name, ReturnedValue (*code)(SimpleCallContext *));
Returned<BoundFunction> *newBoundFunction(ExecutionContext *scope, FunctionObject *target, Value boundThis, const QVector<Value> &boundArgs);
Returned<Object> *newObject();
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index 011ea34b7d..aa94f93461 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -400,10 +400,11 @@ ScriptFunction::ScriptFunction(ExecutionContext *scope, Function *function)
varList = function->locals.constData();
if (scope->strictMode) {
- FunctionObject *thrower = scope->engine->newBuiltinFunction(scope, 0, throwTypeError);
- Property pd = Property::fromAccessor(thrower, thrower);
- __defineOwnProperty__(scope, QStringLiteral("caller"), pd, Attr_Accessor|Attr_NotEnumerable|Attr_NotConfigurable);
- __defineOwnProperty__(scope, QStringLiteral("arguments"), pd, Attr_Accessor|Attr_NotEnumerable|Attr_NotConfigurable);
+ Scope s(scope);
+ Scoped<FunctionObject> thrower(s, scope->engine->newBuiltinFunction(scope, 0, throwTypeError));
+ Property pd = Property::fromAccessor(thrower.getPointer(), thrower.getPointer());
+ *insertMember(scope->engine->id_caller, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable) = pd;
+ *insertMember(scope->engine->id_arguments, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable) = pd;
}
}
@@ -496,10 +497,11 @@ SimpleScriptFunction::SimpleScriptFunction(ExecutionContext *scope, Function *fu
varList = function->locals.constData();
if (scope->strictMode) {
- FunctionObject *thrower = scope->engine->newBuiltinFunction(scope, 0, throwTypeError);
- Property pd = Property::fromAccessor(thrower, thrower);
- __defineOwnProperty__(scope, QStringLiteral("caller"), pd, Attr_Accessor|Attr_NotEnumerable|Attr_NotConfigurable);
- __defineOwnProperty__(scope, QStringLiteral("arguments"), pd, Attr_Accessor|Attr_NotEnumerable|Attr_NotConfigurable);
+ Scope s(scope);
+ Scoped<FunctionObject> thrower(s, scope->engine->newBuiltinFunction(scope, 0, throwTypeError));
+ Property pd = Property::fromAccessor(thrower.getPointer(), thrower.getPointer());
+ *insertMember(scope->engine->id_caller, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable) = pd;
+ *insertMember(scope->engine->id_arguments, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable) = pd;
}
}
@@ -654,8 +656,9 @@ BoundFunction::BoundFunction(ExecutionContext *scope, FunctionObject *target, Va
len = 0;
defineReadonlyProperty(scope->engine->id_length, Value::fromInt32(len));
- FunctionObject *thrower = scope->engine->newBuiltinFunction(scope, 0, throwTypeError);
- Property pd = Property::fromAccessor(thrower, thrower);
+ Scope s(scope);
+ Scoped<FunctionObject> thrower(s, scope->engine->newBuiltinFunction(scope, 0, throwTypeError));
+ Property pd = Property::fromAccessor(thrower.getPointer(), thrower.getPointer());
*insertMember(scope->engine->id_arguments, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable) = pd;
*insertMember(scope->engine->id_caller, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable) = pd;
}
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp
index 4f7e2966f1..d55c3ad41f 100644
--- a/src/qml/jsruntime/qv4object.cpp
+++ b/src/qml/jsruntime/qv4object.cpp
@@ -234,26 +234,29 @@ void Object::defineDefaultProperty(ExecutionEngine *engine, const QString &name,
void Object::defineDefaultProperty(ExecutionContext *context, const QString &name, ReturnedValue (*code)(SimpleCallContext *), int argumentCount)
{
Q_UNUSED(argumentCount);
- String *s = context->engine->newIdentifier(name);
- FunctionObject* function = context->engine->newBuiltinFunction(context, s, code);
+ Scope scope(context);
+ Scoped<String> s(scope, context->engine->newIdentifier(name));
+ Scoped<FunctionObject> function(scope, context->engine->newBuiltinFunction(context, s.getPointer(), code));
function->defineReadonlyProperty(context->engine->id_length, Value::fromInt32(argumentCount));
- defineDefaultProperty(s, Value::fromObject(function));
+ defineDefaultProperty(s.getPointer(), function.asValue());
}
void Object::defineDefaultProperty(ExecutionEngine *engine, const QString &name, ReturnedValue (*code)(SimpleCallContext *), int argumentCount)
{
Q_UNUSED(argumentCount);
- String *s = engine->newIdentifier(name);
- FunctionObject* function = engine->newBuiltinFunction(engine->rootContext, s, code);
+ Scope scope(engine);
+ Scoped<String> s(scope, engine->newIdentifier(name));
+ Scoped<FunctionObject> function(scope, engine->newBuiltinFunction(engine->rootContext, s.getPointer(), code));
function->defineReadonlyProperty(engine->id_length, Value::fromInt32(argumentCount));
- defineDefaultProperty(s, Value::fromObject(function));
+ defineDefaultProperty(s.getPointer(), function.asValue());
}
void Object::defineAccessorProperty(ExecutionEngine *engine, const QString &name,
ReturnedValue (*getter)(SimpleCallContext *), ReturnedValue (*setter)(SimpleCallContext *))
{
- String *s = engine->newString(name);
- defineAccessorProperty(s, getter, setter);
+ Scope scope(engine);
+ Scoped<String> s(scope, engine->newIdentifier(name));
+ defineAccessorProperty(s.getPointer(), getter, setter);
}
void Object::defineAccessorProperty(String *name, ReturnedValue (*getter)(SimpleCallContext *), ReturnedValue (*setter)(SimpleCallContext *))
@@ -261,9 +264,9 @@ void Object::defineAccessorProperty(String *name, ReturnedValue (*getter)(Simple
ExecutionEngine *v4 = engine();
Property *p = insertMember(name, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
if (getter)
- p->setGetter(v4->newBuiltinFunction(v4->rootContext, name, getter));
+ p->setGetter(v4->newBuiltinFunction(v4->rootContext, name, getter)->getPointer());
if (setter)
- p->setSetter(v4->newBuiltinFunction(v4->rootContext, name, setter));
+ p->setSetter(v4->newBuiltinFunction(v4->rootContext, name, setter)->getPointer());
}
void Object::defineReadonlyProperty(ExecutionEngine *engine, const QString &name, Value value)
diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp
index 82215e4fc5..6282657556 100644
--- a/src/qml/jsruntime/qv4objectproto.cpp
+++ b/src/qml/jsruntime/qv4objectproto.cpp
@@ -131,8 +131,8 @@ void ObjectPrototype::init(ExecutionContext *ctx, const Value &ctor)
ExecutionEngine *v4 = ctx->engine;
Property *p = insertMember(v4->id___proto__, Attr_Accessor|Attr_NotEnumerable);
- p->setGetter(v4->newBuiltinFunction(v4->rootContext, v4->id___proto__, method_get_proto));
- p->setSetter(v4->newBuiltinFunction(v4->rootContext, v4->id___proto__, method_set_proto));
+ p->setGetter(v4->newBuiltinFunction(v4->rootContext, v4->id___proto__, method_get_proto)->getPointer());
+ p->setSetter(v4->newBuiltinFunction(v4->rootContext, v4->id___proto__, method_set_proto)->getPointer());
}
ReturnedValue ObjectPrototype::method_getPrototypeOf(SimpleCallContext *ctx)
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index 623efb54b2..095da5d906 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -1402,24 +1402,15 @@ void QQmlComponentPrivate::initializeObjectWithInitialProperties(const QV4::Valu
}
}
-#define V4FUNCTION(function, engine) engine->newBuiltinFunction(engine->rootContext, engine->id_undefined, function)
-
-
QQmlComponentExtension::QQmlComponentExtension(QV8Engine *engine)
{
QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine);
QV4::Scope scope(v4);
QV4::Scoped<QV4::Object> proto(scope, v4->newObject());
- QV4::Property *s = proto->insertMember(v4->newString(QStringLiteral("onStatusChanged")),
- QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
- s->setGetter(V4FUNCTION(QmlIncubatorObject::method_get_statusChanged, v4));
- s->setSetter(V4FUNCTION(QmlIncubatorObject::method_set_statusChanged, v4));
- s = proto->insertMember(v4->newString(QStringLiteral("status")),
- QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
- s->setGetter(V4FUNCTION(QmlIncubatorObject::method_get_status, v4));
- s = proto->insertMember(v4->newString(QStringLiteral("object")),
- QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
- s->setGetter(V4FUNCTION(QmlIncubatorObject::method_get_object, v4));
+ proto->defineAccessorProperty(v4->newString(QStringLiteral("onStatusChanged")),
+ QmlIncubatorObject::method_get_statusChanged, QmlIncubatorObject::method_set_statusChanged);
+ proto->defineAccessorProperty(v4->newString(QStringLiteral("status")), QmlIncubatorObject::method_get_status, 0);
+ proto->defineAccessorProperty(v4->newString(QStringLiteral("object")), QmlIncubatorObject::method_get_object, 0);
proto->defineDefaultProperty(v4, QStringLiteral("forceCompletion"), QmlIncubatorObject::method_forceCompletion);
incubationProto = proto;
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
index 40b5075ddd..bd10b7e719 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
@@ -92,6 +92,8 @@ QV4::QtObject::QtObject(ExecutionEngine *v4, QQmlEngine *qmlEngine)
{
vtbl = &static_vtbl;
+ Scope scope(v4);
+
// Set all the enums from the "Qt" namespace
const QMetaObject *qtMetaObject = StaticQtMetaObject::get();
for (int ii = 0; ii < qtMetaObject->enumeratorCount(); ++ii) {
@@ -141,25 +143,10 @@ QV4::QtObject::QtObject(ExecutionEngine *v4, QQmlEngine *qmlEngine)
defineDefaultProperty(v4, QStringLiteral("createComponent"), method_createComponent);
}
- {
- String *s = v4->newString(QStringLiteral("platform"));
- Property *p = insertMember(s, Attr_Accessor);
- FunctionObject* f = v4->newBuiltinFunction(v4->rootContext, s, method_get_platform);
- p->setGetter(f);
- }
- {
- String *s = v4->newString(QStringLiteral("application"));
- Property *p = insertMember(s, Attr_Accessor);
- FunctionObject* f = v4->newBuiltinFunction(v4->rootContext, s, method_get_application);
- p->setGetter(f);
- }
+ defineAccessorProperty(v4->newString(QStringLiteral("platform")), method_get_platform, 0);
+ defineAccessorProperty(v4->newString(QStringLiteral("application")), method_get_application, 0);
#ifndef QT_NO_IM
- {
- String *s = v4->newString(QStringLiteral("inputMethod"));
- Property *p = insertMember(s, Attr_Accessor);
- FunctionObject* f = v4->newBuiltinFunction(v4->rootContext, s, method_get_inputMethod);
- p->setGetter(f);
- }
+ defineAccessorProperty(v4->newString(QStringLiteral("inputMethod")), method_get_inputMethod, 0);
#endif
}
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp
index c0b0b59f1d..8faa1ec088 100644
--- a/src/qml/types/qqmldelegatemodel.cpp
+++ b/src/qml/types/qqmldelegatemodel.cpp
@@ -3239,12 +3239,9 @@ QQmlDelegateModelEngineData::QQmlDelegateModelEngineData(QV8Engine *e)
QV4::Scope scope(v4);
QV4::Scoped<QV4::Object> proto(scope, v4->newObject());
- QV4::Property *p = proto->insertMember(v4->newString(QStringLiteral("index")), QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
- p->setGetter(v4->newBuiltinFunction(v4->rootContext, v4->id_undefined, QQmlDelegateModelGroupChange::method_get_index));
- p = proto->insertMember(v4->newString(QStringLiteral("count")), QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
- p->setGetter(v4->newBuiltinFunction(v4->rootContext, v4->id_undefined, QQmlDelegateModelGroupChange::method_get_count));
- p = proto->insertMember(v4->newString(QStringLiteral("moveId")), QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
- p->setGetter(v4->newBuiltinFunction(v4->rootContext, v4->id_undefined, QQmlDelegateModelGroupChange::method_get_moveId));
+ proto->defineAccessorProperty(v4->newString(QStringLiteral("index")), QQmlDelegateModelGroupChange::method_get_index, 0);
+ proto->defineAccessorProperty(v4->newString(QStringLiteral("count")), QQmlDelegateModelGroupChange::method_get_count, 0);
+ proto->defineAccessorProperty(v4->newString(QStringLiteral("moveId")), QQmlDelegateModelGroupChange::method_get_moveId, 0);
changeProto = proto;
}
diff --git a/src/qml/types/qquickworkerscript.cpp b/src/qml/types/qquickworkerscript.cpp
index d80df760fa..284888b0b1 100644
--- a/src/qml/types/qquickworkerscript.cpp
+++ b/src/qml/types/qquickworkerscript.cpp
@@ -233,8 +233,8 @@ void QQuickWorkerScriptEnginePrivate::WorkerEngine::init()
QV4::Script createsendscript(m_v4Engine->rootContext, SEND_MESSAGE_CREATE_SCRIPT);
QV4::Scoped<QV4::FunctionObject> createsendconstructor(scope, createsendscript.run());
- QV4::Value function = QV4::Value::fromObject(m_v4Engine->newBuiltinFunction(m_v4Engine->rootContext, m_v4Engine->newString(QStringLiteral("sendMessage")),
- QQuickWorkerScriptEnginePrivate::method_sendMessage));
+ QV4::ScopedValue function(scope, m_v4Engine->newBuiltinFunction(m_v4Engine->rootContext, m_v4Engine->newString(QStringLiteral("sendMessage")),
+ QQuickWorkerScriptEnginePrivate::method_sendMessage));
QV4::ScopedCallData callData(scope, 1);
callData->args[0] = function;
callData->thisObject = global();
diff --git a/src/qml/util/qqmladaptormodel.cpp b/src/qml/util/qqmladaptormodel.cpp
index 6c12d7310f..1562ab1029 100644
--- a/src/qml/util/qqmladaptormodel.cpp
+++ b/src/qml/util/qqmladaptormodel.cpp
@@ -215,21 +215,16 @@ public:
QV4::ExecutionEngine *v4 = data->v4;
QV4::Scope scope(v4);
QV4::Scoped<QV4::Object> proto(scope, v4->newObject());
- QV4::Property *p = proto->insertMember(v4->newString(QStringLiteral("index")),
- QV4::Attr_Accessor|QV4::Attr_NotEnumerable|QV4::Attr_NotConfigurable);
- p->setGetter(v4->newBuiltinFunction(v4->rootContext, v4->id_undefined, get_index));
-
- p = proto->insertMember(v4->newString(QStringLiteral("hasModelChildren")),
- QV4::Attr_Accessor|QV4::Attr_NotEnumerable|QV4::Attr_NotConfigurable);
- p->setGetter(v4->newBuiltinFunction(v4->rootContext, v4->id_undefined, get_hasModelChildren));
+ proto->defineAccessorProperty(v4->newString(QStringLiteral("index")), get_index, 0);
+ proto->defineAccessorProperty(v4->newString(QStringLiteral("hasModelChildren")), get_hasModelChildren, 0);
typedef QHash<QByteArray, int>::const_iterator iterator;
for (iterator it = roleNames.constBegin(), end = roleNames.constEnd(); it != end; ++it) {
const int propertyId = propertyRoles.indexOf(it.value());
const QByteArray &propertyName = it.key();
- p = proto->insertMember(v4->newString(QString::fromUtf8(propertyName)),
- QV4::Attr_Accessor|QV4::Attr_NotEnumerable|QV4::Attr_NotConfigurable);
+ QV4::Property *p = proto->insertMember(v4->newString(QString::fromUtf8(propertyName)),
+ QV4::Attr_Accessor|QV4::Attr_NotEnumerable|QV4::Attr_NotConfigurable);
p->setGetter(new (v4->memoryManager) QV4::IndexedBuiltinFunction(v4->rootContext, propertyId, QQmlDMCachedModelData::get_property));
p->setSetter(new (v4->memoryManager) QV4::IndexedBuiltinFunction(v4->rootContext, propertyId, QQmlDMCachedModelData::set_property));
}
@@ -958,13 +953,9 @@ QQmlAdaptorModelEngineData::QQmlAdaptorModelEngineData(QV8Engine *e)
{
QV4::Scope scope(v4);
QV4::Scoped<QV4::Object> proto(scope, v4->newObject());
- QV4::Property *p = proto->insertMember(v4->newString(QStringLiteral("index")),
- QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
- p->setGetter(v4->newBuiltinFunction(v4->rootContext, v4->id_undefined, get_index));
- p = proto->insertMember(v4->newString(QStringLiteral("modelData")),
- QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
- p->setGetter(v4->newBuiltinFunction(v4->rootContext, v4->id_undefined, QQmlDMListAccessorData::get_modelData));
- p->setSetter(v4->newBuiltinFunction(v4->rootContext, v4->id_undefined, QQmlDMListAccessorData::set_modelData));
+ proto->defineAccessorProperty(v4->newString(QStringLiteral("index")), get_index, 0);
+ proto->defineAccessorProperty(v4->newString(QStringLiteral("modelData")),
+ QQmlDMListAccessorData::get_modelData, QQmlDMListAccessorData::set_modelData);
listItemProto = proto;
}