QV4::Scope scope(v4);
QV4::Scoped<QV4::ForEachIteratorObject> it(scope, d_ptr->iterator.value());
it->d()->it.flags = QV4::ObjectIterator::NoFlags;
- QV4::String *nm = 0;
- it->d()->it.next(nm, &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes);
+ QV4::ScopedString nm(scope);
+ it->d()->it.next(nm.getRef(), &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes);
d_ptr->nextName = nm;
}
return false;
QV4::Scope scope(v4);
QV4::Scoped<QV4::ForEachIteratorObject> it(scope, d_ptr->iterator.value());
- QV4::String *nm = 0;
- it->d()->it.next(nm, &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes);
+ QV4::ScopedString nm(scope);
+ it->d()->it.next(nm.getRef(), &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes);
d_ptr->nextName = nm;
return !!d_ptr->currentName || d_ptr->currentIndex != UINT_MAX;
}
d_ptr->iterator = v4->newForEachIteratorObject(o)->asReturnedValue();
QV4::Scoped<QV4::ForEachIteratorObject> it(scope, d_ptr->iterator.value());
it->d()->it.flags = QV4::ObjectIterator::NoFlags;
- QV4::String *nm = 0;
- it->d()->it.next(nm, &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes);
+ QV4::ScopedString nm(scope);
+ it->d()->it.next(nm.getRef(), &d_ptr->nextIndex, &d_ptr->nextProperty, &d_ptr->nextAttributes);
d_ptr->nextName = nm;
return *this;
}
ReturnedValue (*getLookup)(Managed *m, Lookup *l);
void (*setLookup)(Managed *m, Lookup *l, const ValueRef v);
uint (*getLength)(const Managed *m);
- void (*advanceIterator)(Managed *m, ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attributes);
+ void (*advanceIterator)(Managed *m, ObjectIterator *it, Heap::String **name, uint *index, Property *p, PropertyAttributes *attributes);
};
#define DEFINE_MANAGED_VTABLE_INT(classname, parentVTable) \
l->setter = Lookup::setterGeneric;
}
-void Object::advanceIterator(Managed *m, ObjectIterator *it, String *&name, uint *index, Property *pd, PropertyAttributes *attrs)
+void Object::advanceIterator(Managed *m, ObjectIterator *it, Heap::String **name, uint *index, Property *pd, PropertyAttributes *attrs)
{
Object *o = static_cast<Object *>(m);
- name = (String *)0;
+ *name = 0;
*index = UINT_MAX;
if (o->arrayData()) {
PropertyAttributes a = o->internalClass()->propertyData[it->memberIndex];
++it->memberIndex;
if (!(it->flags & ObjectIterator::EnumerableOnly) || a.isEnumerable()) {
- // #### GC
- name = reinterpret_cast<QV4::String*>(m->engine()->newString(n->string));
+ *name = m->engine()->newString(n->string);
*attrs = a;
pd->copy(*p, a);
return;
{ return vtable()->getLookup(this, l); }
void setLookup(Lookup *l, const ValueRef v)
{ vtable()->setLookup(this, l, v); }
- void advanceIterator(ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attributes)
+ void advanceIterator(ObjectIterator *it, Heap::String **name, uint *index, Property *p, PropertyAttributes *attributes)
{ vtable()->advanceIterator(this, it, name, index, p, attributes); }
uint getLength() const { return vtable()->getLength(this); }
static bool deleteIndexedProperty(Managed *m, uint index);
static ReturnedValue getLookup(Managed *m, Lookup *l);
static void setLookup(Managed *m, Lookup *l, const ValueRef v);
- static void advanceIterator(Managed *m, ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attributes);
+ static void advanceIterator(Managed *m, ObjectIterator *it, Heap::String **name, uint *index, Property *p, PropertyAttributes *attributes);
static uint getLength(const Managed *m);
private:
}
}
-void ObjectIterator::next(String *&name, uint *index, Property *pd, PropertyAttributes *attrs)
+void ObjectIterator::next(Heap::String **name, uint *index, Property *pd, PropertyAttributes *attrs)
{
- name = (String *)0;
+ *name = 0;
*index = UINT_MAX;
if (!object->asObject()) {
}
Scope scope(engine);
ScopedObject o(scope);
+ ScopedString n(scope);
while (1) {
if (!current->asObject())
// check the property is not already defined earlier in the proto chain
if (current->asObject() != object->asObject()) {
o = object->asObject();
+ n = *name;
bool shadowed = false;
while (o != current->asObject()) {
- if ((!!name && o->hasOwnProperty(name)) ||
+ if ((!!n && o->hasOwnProperty(n)) ||
(*index != UINT_MAX && o->hasOwnProperty(*index))) {
shadowed = true;
break;
uint index;
Scope scope(object->engine());
ScopedString name(scope);
- String *n;
- next(n, &index, &p, &attrs);
- name = n;
+ next(name.getRef(), &index, &p, &attrs);
if (attrs.isEmpty())
return Encode::null();
uint index;
Scope scope(object->engine());
ScopedString name(scope);
- String *n;
- next(n, &index, &p, &attrs);
- name = n;
+ next(name.getRef(), &index, &p, &attrs);
if (attrs.isEmpty())
return Encode::null();
uint index;
Scope scope(object->engine());
ScopedString name(scope);
- String *n;
- next(n, &index, &p, &attrs);
- name = n;
+ next(name.getRef(), &index, &p, &attrs);
if (attrs.isEmpty())
return Encode::null();
ObjectIterator(ExecutionEngine *e, Value *scratch1, Value *scratch2, Object *o, uint flags);
ObjectIterator(Scope &scope, Object *o, uint flags);
void init(Object *o);
- void next(String *&name, uint *index, Property *pd, PropertyAttributes *attributes = 0);
+ void next(Heap::String **name, uint *index, Property *pd, PropertyAttributes *attributes = 0);
ReturnedValue nextPropertyName(ValueRef value);
ReturnedValue nextPropertyNameAsString(ValueRef value);
ReturnedValue nextPropertyNameAsString();
uint index;
PropertyAttributes attrs;
Property pd;
- String *nm;
- it.next(nm, &index, &pd, &attrs);
- name = nm;
+ it.next(name.getRef(), &index, &pd, &attrs);
if (attrs.isEmpty())
break;
Property n;
return QV4::Object::query(m, name);
}
-void QObjectWrapper::advanceIterator(Managed *m, ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attributes)
+void QObjectWrapper::advanceIterator(Managed *m, ObjectIterator *it, Heap::String **name, uint *index, Property *p, PropertyAttributes *attributes)
{
// Used to block access to QObject::destroyed() and QObject::deleteLater() from QML
static const int destroyedIdx1 = QObject::staticMetaObject.indexOfSignal("destroyed(QObject*)");
static const int destroyedIdx2 = QObject::staticMetaObject.indexOfSignal("destroyed()");
static const int deleteLaterIdx = QObject::staticMetaObject.indexOfSlot("deleteLater()");
- name = (String *)0;
+ *name = (Heap::String *)0;
*index = UINT_MAX;
QObjectWrapper *that = static_cast<QObjectWrapper*>(m);
// #### GC
Scope scope(that->engine());
ScopedString propName(scope, that->engine()->newString(QString::fromUtf8(mo->property(it->arrayIndex).name())));
- name = propName.getPointer();
+ *name = propName->d();
++it->arrayIndex;
*attributes = QV4::Attr_Data;
- p->value = that->get(name);
+ p->value = that->get(propName);
return;
}
const int methodCount = mo->methodCount();
// #### GC
Scope scope(that->engine());
ScopedString methodName(scope, that->engine()->newString(QString::fromUtf8(method.name())));
- name = methodName.getPointer();
+ *name = methodName->d();
*attributes = QV4::Attr_Data;
- p->value = that->get(name);
+ p->value = that->get(methodName);
return;
}
}
static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
static void put(Managed *m, String *name, const ValueRef value);
static PropertyAttributes query(const Managed *, String *name);
- static void advanceIterator(Managed *m, ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attributes);
+ static void advanceIterator(Managed *m, ObjectIterator *it, Heap::String **name, uint *index, Property *p, PropertyAttributes *attributes);
static void markObjects(Heap::Base *that, QV4::ExecutionEngine *e);
static void destroy(Heap::Base *that);
Scoped(const Scope &scope)
{
ptr = scope.engine->jsStackTop++;
+ ptr->m = 0;
+#if QT_POINTER_SIZE == 4
+ ptr->tag = QV4::Value::Managed_Type;
+#endif
#ifndef QT_NO_DEBUG
++scope.size;
#endif
T *getPointer() {
return static_cast<T *>(ptr->managed());
}
+ typename T::Data **getRef() {
+ return reinterpret_cast<typename T::Data **>(&ptr->m);
+ }
ReturnedValue asReturnedValue() const {
#if QT_POINTER_SIZE == 8
return (signedIdx < d()->container.count()) ? QV4::Attr_Data : QV4::Attr_Invalid;
}
- void containerAdvanceIterator(ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attrs)
+ void containerAdvanceIterator(ObjectIterator *it, Heap::String **name, uint *index, Property *p, PropertyAttributes *attrs)
{
- name = (String *)0;
+ *name = (Heap::String *)0;
*index = UINT_MAX;
if (d()->isReference) {
{ return static_cast<QQmlSequence<Container> *>(that)->containerDeleteIndexedProperty(index); }
static bool isEqualTo(Managed *that, Managed *other)
{ return static_cast<QQmlSequence<Container> *>(that)->containerIsEqualTo(other); }
- static void advanceIterator(Managed *that, ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attrs)
+ static void advanceIterator(Managed *that, ObjectIterator *it, Heap::String **name, uint *index, Property *p, PropertyAttributes *attrs)
{ return static_cast<QQmlSequence<Container> *>(that)->containerAdvanceIterator(it, name, index, p, attrs); }
};
return true;
}
-void StringObject::advanceIterator(Managed *m, ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attrs)
+void StringObject::advanceIterator(Managed *m, ObjectIterator *it, Heap::String **name, uint *index, Property *p, PropertyAttributes *attrs)
{
- name = (String *)0;
+ *name = (Heap::String *)0;
StringObject *s = static_cast<StringObject *>(m);
uint slen = s->d()->value.stringValue()->toQString().length();
if (it->arrayIndex <= slen) {
static bool deleteIndexedProperty(Managed *m, uint index);
protected:
- static void advanceIterator(Managed *m, ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attrs);
+ static void advanceIterator(Managed *m, ObjectIterator *it, Heap::String **name, uint *index, Property *p, PropertyAttributes *attrs);
static void markObjects(Heap::Base *that, ExecutionEngine *e);
};
Q_UNUSED(value);
}
-void QmlListWrapper::advanceIterator(Managed *m, ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attrs)
+void QmlListWrapper::advanceIterator(Managed *m, ObjectIterator *it, Heap::String **name, uint *index, Property *p, PropertyAttributes *attrs)
{
- name = (String *)0;
+ *name = (Heap::String *)0;
*index = UINT_MAX;
Q_ASSERT(m->as<QmlListWrapper>());
QmlListWrapper *w = static_cast<QmlListWrapper *>(m);
static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty);
static void put(Managed *m, String *name, const ValueRef value);
- static void advanceIterator(Managed *m, ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attributes);
+ static void advanceIterator(Managed *m, ObjectIterator *it, Heap::String **name, uint *index, Property *p, PropertyAttributes *attributes);
};
}