These are not needed anymore with the most recent portings away from v8.
Implemented Object::__hasProperty__ by means of query/queryIndexed.
Change-Id: Id02057a34c44a8c4e71912a5b5379740f09ef05d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Value (*getIndexed)(Managed *, ExecutionContext *ctx, uint index, bool *hasProperty);
void (*put)(Managed *, ExecutionContext *ctx, String *name, const Value &value);
void (*putIndexed)(Managed *, ExecutionContext *ctx, uint index, const Value &value);
- PropertyAttributes (*query)(Managed *, ExecutionContext *ctx, String *name);
- PropertyAttributes (*queryIndexed)(Managed *, ExecutionContext *ctx, uint index);
+ PropertyAttributes (*query)(const Managed *, String *name);
+ PropertyAttributes (*queryIndexed)(const Managed *, uint index);
bool (*deleteProperty)(Managed *m, ExecutionContext *ctx, String *name);
bool (*deleteIndexedProperty)(Managed *m, ExecutionContext *ctx, uint index);
void (*getLookup)(Managed *m, ExecutionContext *ctx, Lookup *l, Value *result);
{ vtbl->put(this, ctx, name, value); }
void putIndexed(ExecutionContext *ctx, uint index, const Value &value)
{ vtbl->putIndexed(this, ctx, index, value); }
+ PropertyAttributes query(String *name) const
+ { return vtbl->query(this, name); }
+ PropertyAttributes queryIndexed(uint index) const
+ { return vtbl->queryIndexed(this, index); }
+
bool deleteProperty(ExecutionContext *ctx, String *name)
{ return vtbl->deleteProperty(this, ctx, name); }
bool deleteIndexedProperty(ExecutionContext *ctx, uint index)
, memberDataAlloc(InlinePropertySize), memberData(inlineProperties)
, arrayOffset(0), arrayDataLen(0), arrayAlloc(0), arrayAttributes(0), arrayData(0), sparseArray(0)
, externalResource(0)
- , dynamicPropertyEnumerator(0)
- , dynamicPropertyQuery(0)
{
vtbl = &static_vtbl;
type = Type_Object;
, memberDataAlloc(InlinePropertySize), memberData(inlineProperties)
, arrayOffset(0), arrayDataLen(0), arrayAlloc(0), arrayAttributes(0), arrayData(0), sparseArray(0)
, externalResource(0)
- , dynamicPropertyEnumerator(0)
- , dynamicPropertyQuery(0)
{
vtbl = &static_vtbl;
type = Type_Object;
, memberDataAlloc(InlinePropertySize), memberData(inlineProperties)
, arrayOffset(0), arrayDataLen(0), arrayAlloc(0), arrayAttributes(0), arrayData(0), sparseArray(0)
, externalResource(0)
- , dynamicPropertyEnumerator(0)
- , dynamicPropertyQuery(0)
{
vtbl = &static_vtbl;
type = Type_Object;
{
if (__getPropertyDescriptor__(name))
return true;
-
- if (dynamicPropertyQuery && !dynamicPropertyQuery(this, name).isEmpty())
- return true;
-
- return false;
+ return !query(name).isEmpty();
}
Value Object::get(Managed *m, ExecutionContext *ctx, String *name, bool *hasProperty)
static_cast<Object *>(m)->internalPutIndexed(ctx, index, value);
}
-PropertyAttributes Object::query(Managed *m, ExecutionContext *ctx, String *name)
+PropertyAttributes Object::query(const Managed *m, String *name)
{
uint idx = name->asArrayIndex();
if (idx != UINT_MAX)
- return queryIndexed(m, ctx, idx);
+ return queryIndexed(m, idx);
- const Object *o = static_cast<Object *>(m);
+ const Object *o = static_cast<const Object *>(m);
while (o) {
uint idx = o->internalClass->find(name);
if (idx < UINT_MAX)
return Attr_Invalid;
}
-PropertyAttributes Object::queryIndexed(Managed *m, ExecutionContext *ctx, uint index)
+PropertyAttributes Object::queryIndexed(const Managed *m, uint index)
{
- const Object *o = static_cast<Object *>(m);
+ const Object *o = static_cast<const Object *>(m);
while (o) {
uint pidx = o->propertyIndexFromArrayIndex(index);
if (pidx < UINT_MAX) {
Object::markObjects(that);
if (o->it.object)
o->it.object->mark();
- if (o->it.dynamicProperties)
- o->it.dynamicProperties->mark();
}
Property *arrayData;
SparseArray *sparseArray;
ExternalResource *externalResource;
- PropertyEnumeratorFunction dynamicPropertyEnumerator;
- PropertyQueryFunction dynamicPropertyQuery;
enum {
InlinePropertySize = 4
using Managed::getIndexed;
using Managed::put;
using Managed::putIndexed;
+ using Managed::query;
+ using Managed::queryIndexed;
using Managed::deleteProperty;
using Managed::deleteIndexedProperty;
using Managed::getLookup;
static Value getIndexed(Managed *m, ExecutionContext *ctx, uint index, bool *hasProperty);
static void put(Managed *m, ExecutionContext *ctx, String *name, const Value &value);
static void putIndexed(Managed *m, ExecutionContext *ctx, uint index, const Value &value);
- static PropertyAttributes query(Managed *m, ExecutionContext *ctx, String *name);
- static PropertyAttributes queryIndexed(Managed *m, ExecutionContext *ctx, uint index);
+ static PropertyAttributes query(const Managed *m, String *name);
+ static PropertyAttributes queryIndexed(const Managed *m, uint index);
static bool deleteProperty(Managed *m, ExecutionContext *ctx, String *name);
static bool deleteIndexedProperty(Managed *m, ExecutionContext *ctx, uint index);
static void getLookup(Managed *m, ExecutionContext *ctx, Lookup *l, Value *result);
, arrayIndex(0)
, memberIndex(0)
, flags(flags)
- , dynamicProperties(0)
- , dynamicPropertyIndex(0)
, wrappedListLength(0)
{
tmpDynamicProperty.value = Value::undefinedValue();
if (current) {
if (current->asStringObject())
this->flags |= CurrentIsString;
- if (current->dynamicPropertyEnumerator)
- dynamicProperties = current->dynamicPropertyEnumerator(current).asArrayObject();
if (current->isListType()) {
wrappedListLength = current->get(o->engine()->id_length).toUInt32();
}
while (arrayIndex < wrappedListLength) {
- PropertyAttributes a = current->vtbl->queryIndexed(current, current->engine()->current, arrayIndex);
+ PropertyAttributes a = current->queryIndexed(arrayIndex);
++arrayIndex;
if (!(flags & EnumerableOnly) || a.isEnumerable()) {
*index = arrayIndex - 1;
}
}
- if (dynamicProperties) {
- const int len = dynamicProperties->arrayLength();
- while (dynamicPropertyIndex < len) {
- bool exists = false;
- String *n = dynamicProperties->getIndexed(dynamicPropertyIndex).asString();
- ++dynamicPropertyIndex;
- if (!n)
- continue;
- PropertyAttributes a;
- if (current->dynamicPropertyQuery)
- a = current->dynamicPropertyQuery(current, n);
- if (!(flags & EnumerableOnly) || a.isEnumerable()) {
- *name = n;
- if (attrs)
- *attrs = a;
- tmpDynamicProperty.value = current->get(n);
- return &tmpDynamicProperty;
- }
- }
- dynamicProperties = 0;
- }
-
if (memberIndex == internalClass->size) {
if (flags & WithProtoChain)
current = current->prototype;
arrayIndex = 0;
memberIndex = 0;
- dynamicProperties = 0;
- if (current && current->dynamicPropertyEnumerator)
- dynamicProperties = current->dynamicPropertyEnumerator(current).asArrayObject();
- dynamicPropertyIndex = 0;
if (current && current->isListType()) {
wrappedListLength = current->get(current->engine()->id_length).toUInt32();
uint memberIndex;
uint flags;
- ArrayObject *dynamicProperties;
- uint dynamicPropertyIndex;
Property tmpDynamicProperty;
uint wrappedListLength;
{
}
-PropertyAttributes RegExp::query(Managed *m, ExecutionContext *ctx, String *name)
+PropertyAttributes RegExp::query(const Managed *m, String *name)
{
return Attr_Invalid;
}
-PropertyAttributes RegExp::queryIndexed(Managed *m, ExecutionContext *ctx, uint index)
+PropertyAttributes RegExp::queryIndexed(const Managed *m, uint index)
{
return Attr_Invalid;
}
static Value getIndexed(Managed *m, ExecutionContext *ctx, uint index, bool *hasProperty);
static void put(Managed *m, ExecutionContext *ctx, String *name, const Value &value);
static void putIndexed(Managed *m, ExecutionContext *ctx, uint index, const Value &value);
- static PropertyAttributes query(Managed *m, ExecutionContext *ctx, String *name);
- static PropertyAttributes queryIndexed(Managed *m, ExecutionContext *ctx, uint index);
+ static PropertyAttributes query(const Managed *m, String *name);
+ static PropertyAttributes queryIndexed(const Managed *m, uint index);
static bool deleteProperty(Managed *m, ExecutionContext *ctx, String *name);
static bool deleteIndexedProperty(Managed *m, ExecutionContext *ctx, uint index);
storeReference();
}
- QV4::PropertyAttributes containerQueryIndexed(QV4::ExecutionContext *ctx, uint index)
+ QV4::PropertyAttributes containerQueryIndexed(uint index) const
{
/* Qt containers have int (rather than uint) allowable indexes. */
if (index > INT_MAX) {
- generateWarning(ctx, QLatin1String("Index out of range during indexed query"));
+ generateWarning(engine()->current, QLatin1String("Index out of range during indexed query"));
return QV4::Attr_Invalid;
}
if (m_isReference) {
}
private:
- void loadReference()
+ void loadReference() const
{
Q_ASSERT(m_object);
Q_ASSERT(m_isReference);
QMetaObject::metacall(m_object, QMetaObject::WriteProperty, m_propertyIndex, a);
}
- Container m_container;
+ mutable Container m_container;
QQmlGuard<QObject> m_object;
int m_propertyIndex;
bool m_isReference;
{ return static_cast<QQmlSequence<Container> *>(that)->containerGetIndexed(ctx, index, hasProperty); }
static void putIndexed(Managed *that, QV4::ExecutionContext *ctx, uint index, const QV4::Value &value)
{ static_cast<QQmlSequence<Container> *>(that)->containerPutIndexed(ctx, index, value); }
- static QV4::PropertyAttributes queryIndexed(QV4::Managed *that, QV4::ExecutionContext *ctx, uint index)
- { return static_cast<QQmlSequence<Container> *>(that)->containerQueryIndexed(ctx, index); }
+ static QV4::PropertyAttributes queryIndexed(const QV4::Managed *that, uint index)
+ { return static_cast<const QQmlSequence<Container> *>(that)->containerQueryIndexed(index); }
static bool deleteIndexedProperty(QV4::Managed *that, QV4::ExecutionContext *ctx, uint index)
{ return static_cast<QQmlSequence<Container> *>(that)->containerDeleteIndexedProperty(ctx, index); }
static bool isEqualTo(Managed *that, Managed *other)
o->putIndexed(ctx, index, value);
}
-PropertyAttributes String::query(Managed *m, ExecutionContext *ctx, String *name)
+PropertyAttributes String::query(const Managed *m, String *name)
{
+ uint idx = name->asArrayIndex();
+ if (idx != UINT_MAX)
+ return queryIndexed(m, idx);
return Attr_Invalid;
}
-PropertyAttributes String::queryIndexed(Managed *m, ExecutionContext *ctx, uint index)
+PropertyAttributes String::queryIndexed(const Managed *m, uint index)
{
- String *that = static_cast<String *>(m);
+ const String *that = static_cast<const String *>(m);
return (index < that->_text.length()) ? Attr_NotConfigurable|Attr_NotWritable : Attr_Invalid;
}
static Value getIndexed(Managed *m, ExecutionContext *ctx, uint index, bool *hasProperty);
static void put(Managed *m, ExecutionContext *ctx, String *name, const Value &value);
static void putIndexed(Managed *m, ExecutionContext *ctx, uint index, const Value &value);
- static PropertyAttributes query(Managed *m, ExecutionContext *ctx, String *name);
- static PropertyAttributes queryIndexed(Managed *m, ExecutionContext *ctx, uint index);
+ static PropertyAttributes query(const Managed *m, String *name);
+ static PropertyAttributes queryIndexed(const Managed *m, uint index);
static bool deleteProperty(Managed *m, ExecutionContext *ctx, String *name);
static bool deleteIndexedProperty(Managed *m, ExecutionContext *ctx, uint index);
m_template = tmpl;
if (!m_template)
m_template = ObjectTemplate::New().get();
- else {
- if (m_template->m_fallbackPropertyEnumerator)
- this->dynamicPropertyEnumerator = enumerateDynamicProperties;
- if (m_template->m_fallbackPropertyQuery)
- this->dynamicPropertyQuery = queryDynamicProperty;
-
- }
foreach (const ObjectTemplate::Accessor &acc, m_template->m_accessors) {
PropertyAttributes attrs = Attr_Accessor;
}
}
- static QV4::Value enumerateDynamicProperties(QV4::Object *object)
- {
- V4V8Object<BaseClass> *that = static_cast<V4V8Object<BaseClass> *>(object);
- return that->m_template->m_fallbackPropertyEnumerator(that->namedAccessorInfo())->v4Value();
- }
-
- static QV4::PropertyAttributes queryDynamicProperty(const QV4::Object *object, QV4::String *string)
- {
- const V4V8Object<BaseClass> *that = static_cast<const V4V8Object<BaseClass> *>(object);
- Handle<Value> result = that->m_template->m_fallbackPropertyQuery(String::New(string), that->namedAccessorInfo());
- if (result.IsEmpty())
- return QV4::PropertyAttributes();
- return propertyAttributesToFlags(result);
- }
-
QExplicitlySharedDataPointer<ObjectTemplate> m_template;
protected:
return flags;
}
- static PropertyAttributes query(QV4::Managed *m, ExecutionContext *ctx, QV4::String *name)
+ static PropertyAttributes query(const QV4::Managed *m, QV4::String *name)
{
- V4V8Object *that = static_cast<V4V8Object*>(m);
+ const V4V8Object *that = static_cast<const V4V8Object*>(m);
if (that->m_template->m_namedPropertyQuery) {
Handle<Value> result = that->m_template->m_namedPropertyQuery(String::New(name), that->namedAccessorInfo());
if (!result.IsEmpty())
return propertyAttributesToFlags(result);
}
- PropertyAttributes flags = BaseClass::query(m, ctx, name);
+ PropertyAttributes flags = BaseClass::query(m, name);
if (flags.type() == PropertyAttributes::Generic && that->m_template->m_fallbackPropertySetter) {
Handle<Value> result = that->m_template->m_fallbackPropertyQuery(String::New(name), that->fallbackAccessorInfo());
if (!result.IsEmpty())
return flags;
}
- static PropertyAttributes queryIndexed(QV4::Managed *m, ExecutionContext *ctx, uint index)
+ static PropertyAttributes queryIndexed(const QV4::Managed *m, uint index)
{
- V4V8Object *that = static_cast<V4V8Object*>(m);
+ const V4V8Object *that = static_cast<const V4V8Object*>(m);
if (that->m_template->m_indexedPropertyQuery) {
Handle<Value> result = that->m_template->m_indexedPropertyQuery(index, that->indexedAccessorInfo());
if (!result.IsEmpty())
return propertyAttributesToFlags(result);
}
- return BaseClass::queryIndexed(m, ctx, index);
+ return BaseClass::queryIndexed(m, index);
}
static bool deleteProperty(QV4::Managed *m, ExecutionContext *ctx, QV4::String *name)
m_fallbackPropertyQuery = query;
m_fallbackPropertyDeleter = deleter;
m_fallbackPropertyEnumerator = enumerator;
+ assert(!enumerator);
m_fallbackPropertyData = data->v4Value();
}