QV4::Scope scope(v4);
QV4::Scoped<QV4::ForEachIteratorObject> it(scope, d_ptr->iterator.value());
it->it.flags = QV4::ObjectIterator::NoFlags;
- it->it.next(d_ptr->nextName, &d_ptr->nextIndex, &d_ptr->nextAttributes);
+ it->it.next(d_ptr->nextName, &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes);
}
/*!
return false;
d_ptr->currentName = d_ptr->nextName;
d_ptr->currentIndex = d_ptr->nextIndex;
+ d_ptr->currentProperty = d_ptr->nextProperty;
d_ptr->currentAttributes = d_ptr->nextAttributes;
QV4::ExecutionEngine *v4 = d_ptr->iterator.engine();
return false;
QV4::Scope scope(v4);
QV4::Scoped<QV4::ForEachIteratorObject> it(scope, d_ptr->iterator.value());
- it->it.next(d_ptr->nextName, &d_ptr->nextIndex, &d_ptr->nextAttributes);
+ it->it.next(d_ptr->nextName, &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes);
return !!d_ptr->nextName || d_ptr->nextIndex != UINT_MAX;
}
*/
QJSValue QJSValueIterator::value() const
{
- if (!QJSValuePrivate::get(d_ptr->value)->value.isObject())
- return QJSValue();
-
QV4::ExecutionEngine *engine = d_ptr->iterator.engine();
if (!engine)
return QJSValue();
-
QV4::Scope scope(engine);
- QV4::Scoped<QV4::ForEachIteratorObject> it(scope, d_ptr->iterator.value());
- QV4::ScopedObject o(scope, it->it.object);
+ QV4::ScopedObject obj(scope, QJSValuePrivate::get(d_ptr->value)->value);
+ if (!obj)
+ return QJSValue();
QV4::ExecutionContext *ctx = engine->currentContext();
- QV4::ScopedValue v(scope);
- if (!!d_ptr->currentName) {
- QV4::ScopedString n(scope, d_ptr->currentName);
- v = o->get(n);
- } else if (d_ptr->currentIndex != UINT_MAX) {
- v = o->getIndexed(d_ptr->currentIndex);
- } else {
+ if (!d_ptr->currentName && d_ptr->currentIndex == UINT_MAX)
return QJSValue();
- }
+
+ QV4::ScopedValue v(scope, obj->getValue(obj, &d_ptr->currentProperty, d_ptr->currentAttributes));
if (scope.hasException()) {
ctx->catchException();
return QJSValue();
d_ptr->iterator = v4->newForEachIteratorObject(v4->currentContext(), o)->asReturnedValue();
QV4::Scoped<QV4::ForEachIteratorObject> it(scope, d_ptr->iterator.value());
it->it.flags = QV4::ObjectIterator::NoFlags;
- it->it.next(d_ptr->nextName, &d_ptr->nextIndex, &d_ptr->nextAttributes);
+ it->it.next(d_ptr->nextName, &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes);
return *this;
}
QJSValue value;
QV4::PersistentValue iterator;
+ QV4::Property currentProperty;
QV4::PropertyAttributes currentAttributes;
QV4::SafeString currentName;
uint currentIndex;
+ QV4::Property nextProperty;
QV4::PropertyAttributes nextAttributes;
QV4::SafeString nextName;
uint nextIndex;
}
}
-Property *ObjectIterator::next(StringRef name, uint *index, PropertyAttributes *attrs)
+void ObjectIterator::next(StringRef name, uint *index, Property *pd, PropertyAttributes *attrs)
{
name = (String *)0;
*index = UINT_MAX;
- if (!object)
- return 0;
+
+ if (!object) {
+ *attrs = PropertyAttributes();
+ return;
+ }
Property *p = 0;
while (1) {
if (pp != p)
continue;
}
- return p;
+ *pd = *p;
+ return;
}
if (flags & WithProtoChain)
arrayIndex = 0;
memberIndex = 0;
}
- return 0;
+ *attrs = PropertyAttributes();
}
ReturnedValue ObjectIterator::nextPropertyName(ValueRef value)
return Encode::null();
PropertyAttributes attrs;
+ Property p;
uint index;
Scope scope(object->engine());
ScopedString name(scope);
- Property *p = next(name, &index, &attrs);
- if (!p)
+ next(name, &index, &p, &attrs);
+ if (attrs.isEmpty())
return Encode::null();
- value = object->getValue(p, attrs);
+ value = object->getValue(&p, attrs);
if (!!name)
return name->asReturnedValue();
return Encode::null();
PropertyAttributes attrs;
+ Property p;
uint index;
Scope scope(object->engine());
ScopedString name(scope);
- Property *p = next(name, &index, &attrs);
- if (!p)
+ next(name, &index, &p, &attrs);
+ if (attrs.isEmpty())
return Encode::null();
- value = object->getValue(p, attrs);
+ value = object->getValue(&p, attrs);
if (!!name)
return name->asReturnedValue();
return Encode::null();
PropertyAttributes attrs;
+ Property p;
uint index;
Scope scope(object->engine());
ScopedString name(scope);
- Property *p = next(name, &index, &attrs);
- if (!p)
+ next(name, &index, &p, &attrs);
+ if (attrs.isEmpty())
return Encode::null();
if (!!name)
ObjectIterator(SafeObject *scratch1, SafeObject *scratch2, const ObjectRef o, uint flags);
ObjectIterator(Scope &scope, const ObjectRef o, uint flags);
- Property *next(StringRef name, uint *index, PropertyAttributes *attributes = 0);
+ void next(StringRef name, uint *index, Property *pd, PropertyAttributes *attributes = 0);
ReturnedValue nextPropertyName(ValueRef value);
ReturnedValue nextPropertyNameAsString(ValueRef value);
ReturnedValue nextPropertyNameAsString();
while (1) {
uint index;
PropertyAttributes attrs;
- Property *pd = it.next(name, &index, &attrs);
- if (!pd)
+ Property pd;
+ it.next(name, &index, &pd, &attrs);
+ if (attrs.isEmpty())
break;
Property n;
PropertyAttributes nattrs;
- val = o->getValue(pd, attrs);
+ val = o->getValue(&pd, attrs);
toPropertyDescriptor(ctx, val, &n, &nattrs);
if (scope.engine->hasException)
return Encode::undefined();