ExecutionEngine *v4engine = QV8Engine::getV4(v8engine);
Scope scope(v4engine);
Scoped<Object> o(scope, v4engine->newObject());
+ ScopedString name(scope);
+ ScopedValue value(scope);
for (int ii = 0; ii < d->roleObjects.count(); ++ii) {
- ScopedString name(scope, v4engine->newIdentifier(d->roleObjects[ii]->name()));
- Property *p = o->insertMember(name, PropertyAttributes());
- p->value = v8engine->fromVariant(d->data.value(ii).value(index));
+ name = v4engine->newIdentifier(d->roleObjects[ii]->name());
+ value = v8engine->fromVariant(d->data.value(ii).value(index));
+ o->insertMember(name, value);
}
return QQmlV4Handle(o);
if (scope->strictMode) {
Property pd = Property::fromAccessor(v4->thrower, v4->thrower);
- *insertMember(scope->engine->id_caller, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable) = pd;
- *insertMember(scope->engine->id_arguments, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable) = pd;
+ insertMember(scope->engine->id_caller, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
+ insertMember(scope->engine->id_arguments, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
}
}
if (scope->strictMode) {
Property pd = Property::fromAccessor(v4->thrower, v4->thrower);
- *insertMember(scope->engine->id_caller, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable) = pd;
- *insertMember(scope->engine->id_arguments, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable) = pd;
+ insertMember(scope->engine->id_caller, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
+ insertMember(scope->engine->id_arguments, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
}
}
ExecutionEngine *v4 = scope->engine;
Property pd = Property::fromAccessor(v4->thrower, v4->thrower);
- *insertMember(scope->engine->id_arguments, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable) = pd;
- *insertMember(scope->engine->id_caller, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable) = pd;
+ insertMember(scope->engine->id_arguments, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
+ insertMember(scope->engine->id_caller, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
}
void BoundFunction::destroy(Managed *that)
if (idx < UINT_MAX) {
o->putIndexed(idx, val);
} else {
- Property *p = o->insertMember(s, Attr_Data);
- p->value = val.asReturnedValue();
+ o->insertMember(s, val);
}
END;
engine()->currentContext()->throwTypeError();
}
-void Object::defineDefaultProperty(const StringRef name, ValueRef value)
-{
- Property *pd = insertMember(name, Attr_Data|Attr_NotEnumerable);
- pd->value = *value;
-}
-
void Object::defineDefaultProperty(const QString &name, ValueRef value)
{
ExecutionEngine *e = engine();
void Object::defineAccessorProperty(const StringRef name, ReturnedValue (*getter)(CallContext *), ReturnedValue (*setter)(CallContext *))
{
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)->getPointer());
- if (setter)
- p->setSetter(v4->newBuiltinFunction(v4->rootContext, name, setter)->getPointer());
+ Property p;
+ p.setGetter(getter ? v4->newBuiltinFunction(v4->rootContext, name, getter)->getPointer() : 0);
+ p.setSetter(setter ? v4->newBuiltinFunction(v4->rootContext, name, setter)->getPointer() : 0);
+ insertMember(name, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
}
void Object::defineReadonlyProperty(const QString &name, ValueRef value)
void Object::defineReadonlyProperty(const StringRef name, ValueRef value)
{
- Property *pd = insertMember(name, Attr_ReadOnly);
- pd->value = *value;
+ insertMember(name, value, Attr_ReadOnly);
}
void Object::markObjects(Managed *that, ExecutionEngine *e)
}
}
-Property *Object::insertMember(const StringRef s, PropertyAttributes attributes)
+void Object::insertMember(const StringRef s, const Property &p, PropertyAttributes attributes)
{
uint idx;
internalClass = internalClass->addMember(s.getPointer(), attributes, &idx);
ensureMemberIndex(idx);
- return memberData + idx;
+ memberData[idx] = p;
}
// Section 8.12.1
return;
}
- {
- Property *p = insertMember(name, Attr_Data);
- p->value = *value;
- return;
- }
+ insertMember(name, value);
+ return;
reject:
if (engine()->currentContext()->strictMode) {
if (!extensible)
goto reject;
// clause 4
- Property *pd = insertMember(name, attrs);
- *pd = p;
- pd->fullyPopulated(&attrs);
+ Property pd = p;
+ pd.fullyPopulated(&attrs);
+ insertMember(name, pd, attrs);
return true;
}
void putValue(Property *pd, PropertyAttributes attrs, const ValueRef value);
/* The spec default: Writable: true, Enumerable: false, Configurable: true */
- void defineDefaultProperty(const StringRef name, ValueRef value);
+ void defineDefaultProperty(const StringRef name, ValueRef value) {
+ insertMember(name, value, Attr_Data|Attr_NotEnumerable);
+ }
void defineDefaultProperty(const QString &name, ValueRef value);
void defineDefaultProperty(const QString &name, ReturnedValue (*code)(CallContext *), int argumentCount = 0);
void defineDefaultProperty(const StringRef name, ReturnedValue (*code)(CallContext *), int argumentCount = 0);
void defineReadonlyProperty(const QString &name, ValueRef value);
void defineReadonlyProperty(const StringRef name, ValueRef value);
- Property *insertMember(const StringRef s, PropertyAttributes attributes);
+ void insertMember(const StringRef s, const ValueRef v, PropertyAttributes attributes = Attr_Data) {
+ insertMember(s, Property::fromValue(*v), attributes);
+ }
+ void insertMember(const StringRef s, const Property &p, PropertyAttributes attributes);
inline ExecutionEngine *engine() const { return internalClass->engine; }
defineDefaultProperty(QStringLiteral("__defineSetter__"), method_defineSetter, 2);
Scoped<String> id_proto(scope, v4->id___proto__);
- Property *p = insertMember(StringRef(v4->id___proto__), Attr_Accessor|Attr_NotEnumerable);
- p->setGetter(v4->newBuiltinFunction(v4->rootContext, id_proto, method_get_proto)->getPointer());
- p->setSetter(v4->newBuiltinFunction(v4->rootContext, id_proto, method_set_proto)->getPointer());
+ Property p = Property::fromAccessor(v4->newBuiltinFunction(v4->rootContext, id_proto, method_get_proto)->getPointer(),
+ v4->newBuiltinFunction(v4->rootContext, id_proto, method_set_proto)->getPointer());
+ insertMember(StringRef(v4->id___proto__), p, Attr_Accessor|Attr_NotEnumerable);
}
ReturnedValue ObjectPrototype::method_getPrototypeOf(CallContext *ctx)
ScopedObject protectThis(scope, this);
ScopedString lastIndex(scope, engine->newIdentifier(QStringLiteral("lastIndex")));
- Property *lastIndexProperty = insertMember(lastIndex, Attr_NotEnumerable|Attr_NotConfigurable);
- lastIndexProperty->value = Primitive::fromInt32(0);
+ ScopedValue v(scope, Primitive::fromInt32(0));
+ insertMember(lastIndex, v, Attr_NotEnumerable|Attr_NotConfigurable);
if (!this->value)
return;
p.replace('/', QLatin1String("\\/"));
}
- ScopedValue v(scope);
defineReadonlyProperty(QStringLiteral("source"), (v = engine->newString(p)));
defineReadonlyProperty(QStringLiteral("global"), Primitive::fromBoolean(global));
defineReadonlyProperty(QStringLiteral("ignoreCase"), Primitive::fromBoolean(this->value->ignoreCase()));
if (idx != UINT_MAX) {
o->arraySet(idx, val);
} else {
- Property *pd = o->insertMember(name, Attr_Data);
- pd->value = val ? *val : Primitive::undefinedValue();
+ ScopedValue v(scope, val ? *val : Primitive::undefinedValue());
+ o->insertMember(name, v);
}
}
Q_ASSERT(!!o);
uint idx = name->asArrayIndex();
+ Property pd;
+ pd.setGetter(getter ? getter->asFunctionObject() : 0);
+ pd.setSetter(setter ? setter->asFunctionObject() : 0);
if (idx != UINT_MAX) {
- Property pd;
- pd.setGetter(getter ? getter->asFunctionObject() : 0);
- pd.setSetter(setter ? setter->asFunctionObject() : 0);
o->arraySet(idx, pd, Attr_Accessor);
} else {
- Property *pd = o->insertMember(name, Attr_Accessor);
- pd->setGetter(getter ? getter->asFunctionObject() : 0);
- pd->setSetter(setter ? setter->asFunctionObject() : 0);
+ o->insertMember(name, pd, Attr_Accessor);
}
}
QV4::Scoped<QV4::Object> o(scope, m_v4Engine->newObject());
QVariantMap::const_iterator it;
QV4::ScopedString s(scope);
+ QV4::ScopedValue v(scope);
for (it = vmap.constBegin(); it != vmap.constEnd(); ++it) {
s = m_v4Engine->newIdentifier(it.key());
- QV4::Property *p = o->insertMember(s, QV4::Attr_Data);
- p->value = variantToJS(it.value());
+ v = variantToJS(it.value());
+ o->insertMember(s, v);
}
return o.asReturnedValue();
}
proto->defineAccessorProperty(QStringLiteral("model"), QQmlDelegateModelItem::get_model, 0);
proto->defineAccessorProperty(QStringLiteral("groups"), QQmlDelegateModelItem::get_groups, QQmlDelegateModelItem::set_groups);
QV4::ScopedString s(scope);
+ QV4::Property p;
+
s = v4->newString(QStringLiteral("isUnresolved"));
- QV4::Property *p = proto->insertMember(s, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
- p->setGetter(new (v4->memoryManager) DelegateModelGroupFunction(v4->rootContext, 30, QQmlDelegateModelItem::get_member));
+ p.setGetter(new (v4->memoryManager) DelegateModelGroupFunction(v4->rootContext, 30, QQmlDelegateModelItem::get_member));
+ p.setSetter(0);
+ proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
+
s = v4->newString(QStringLiteral("inItems"));
- p = proto->insertMember(s, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
- p->setGetter(new (v4->memoryManager) DelegateModelGroupFunction(v4->rootContext, QQmlListCompositor::Default, QQmlDelegateModelItem::get_member));
- p->setSetter(new (v4->memoryManager) DelegateModelGroupFunction(v4->rootContext, QQmlListCompositor::Default, QQmlDelegateModelItem::set_member));
+ p.setGetter(new (v4->memoryManager) DelegateModelGroupFunction(v4->rootContext, QQmlListCompositor::Default, QQmlDelegateModelItem::get_member));
+ p.setSetter(new (v4->memoryManager) DelegateModelGroupFunction(v4->rootContext, QQmlListCompositor::Default, QQmlDelegateModelItem::set_member));
+ proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
+
s = v4->newString(QStringLiteral("inPersistedItems"));
- p = proto->insertMember(s, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
- p->setGetter(new (v4->memoryManager) DelegateModelGroupFunction(v4->rootContext, QQmlListCompositor::Persisted, QQmlDelegateModelItem::get_member));
- p->setSetter(new (v4->memoryManager) DelegateModelGroupFunction(v4->rootContext, QQmlListCompositor::Persisted, QQmlDelegateModelItem::set_member));
+ p.setGetter(new (v4->memoryManager) DelegateModelGroupFunction(v4->rootContext, QQmlListCompositor::Persisted, QQmlDelegateModelItem::get_member));
+ p.setSetter(new (v4->memoryManager) DelegateModelGroupFunction(v4->rootContext, QQmlListCompositor::Persisted, QQmlDelegateModelItem::set_member));
+ proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
+
s = v4->newString(QStringLiteral("itemsIndex"));
- p = proto->insertMember(s, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
- p->setGetter(new (v4->memoryManager) DelegateModelGroupFunction(v4->rootContext, QQmlListCompositor::Default, QQmlDelegateModelItem::get_index));
+ p.setGetter(new (v4->memoryManager) DelegateModelGroupFunction(v4->rootContext, QQmlListCompositor::Default, QQmlDelegateModelItem::get_index));
+ proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
+
s = v4->newString(QStringLiteral("persistedItemsIndex"));
- p = proto->insertMember(s, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
- p->setGetter(new (v4->memoryManager) DelegateModelGroupFunction(v4->rootContext, QQmlListCompositor::Persisted, QQmlDelegateModelItem::get_index));
+ p.setGetter(new (v4->memoryManager) DelegateModelGroupFunction(v4->rootContext, QQmlListCompositor::Persisted, QQmlDelegateModelItem::get_index));
+ p.setSetter(0);
+ proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
for (int i = 2; i < groupNames.count(); ++i) {
QString propertyName = QStringLiteral("in") + groupNames.at(i);
propertyName.replace(2, 1, propertyName.at(2).toUpper());
s = v4->newString(propertyName);
- p = proto->insertMember(s, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
- p->setGetter(new (v4->memoryManager) DelegateModelGroupFunction(v4->rootContext, i + 1, QQmlDelegateModelItem::get_member));
- p->setSetter(new (v4->memoryManager) DelegateModelGroupFunction(v4->rootContext, i + 1, QQmlDelegateModelItem::set_member));
+ p.setGetter(new (v4->memoryManager) DelegateModelGroupFunction(v4->rootContext, i + 1, QQmlDelegateModelItem::get_member));
+ p.setSetter(new (v4->memoryManager) DelegateModelGroupFunction(v4->rootContext, i + 1, QQmlDelegateModelItem::set_member));
+ proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
}
for (int i = 2; i < groupNames.count(); ++i) {
const QString propertyName = groupNames.at(i) + QStringLiteral("Index");
s = v4->newString(propertyName);
- p = proto->insertMember(s, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
- p->setGetter(new (v4->memoryManager) DelegateModelGroupFunction(v4->rootContext, i + 1, QQmlDelegateModelItem::get_index));
+ p.setGetter(new (v4->memoryManager) DelegateModelGroupFunction(v4->rootContext, i + 1, QQmlDelegateModelItem::get_index));
+ p.setSetter(0);
+ proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
}
modelItemProto = proto;
}
const QByteArray &propertyName = it.key();
QV4::ScopedString name(scope, v4->newString(QString::fromUtf8(propertyName)));
- QV4::Property *p = proto->insertMember(name, 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));
+ QV4::Property p;
+ 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));
+ proto->insertMember(name, p, QV4::Attr_Accessor|QV4::Attr_NotEnumerable|QV4::Attr_NotConfigurable);
}
prototype = proto;
}