{
if (__getPropertyDescriptor__(name))
return true;
- return !query(name).isEmpty();
+
+ const Object *o = this;
+ while (o) {
+ if (!o->query(name).isEmpty())
+ return true;
+ o = o->prototype;
+ }
+
+ return false;
+}
+
+bool Object::__hasProperty__(uint index) const
+{
+ if (__getPropertyDescriptor__(index))
+ return true;
+
+ const Object *o = this;
+ while (o) {
+ if (!o->queryIndexed(index).isEmpty())
+ return true;
+ o = o->prototype;
+ }
+
+ return false;
}
Value Object::get(Managed *m, String *name, bool *hasProperty)
return queryIndexed(m, idx);
const Object *o = static_cast<const Object *>(m);
- while (o) {
- uint idx = o->internalClass->find(name);
- if (idx < UINT_MAX)
- return o->internalClass->propertyData[idx];
+ idx = o->internalClass->find(name);
+ if (idx < UINT_MAX)
+ return o->internalClass->propertyData[idx];
- o = o->prototype;
- }
return Attr_Invalid;
}
PropertyAttributes Object::queryIndexed(const Managed *m, uint index)
{
const Object *o = static_cast<const Object *>(m);
- while (o) {
- uint pidx = o->propertyIndexFromArrayIndex(index);
- if (pidx < UINT_MAX) {
- if (o->arrayAttributes)
- return o->arrayAttributes[pidx];
+ uint pidx = o->propertyIndexFromArrayIndex(index);
+ if (pidx < UINT_MAX) {
+ if (o->arrayAttributes)
+ return o->arrayAttributes[pidx];
+ return Attr_Data;
+ }
+ if (o->isStringObject()) {
+ Property *p = static_cast<const StringObject *>(o)->getIndex(index);
+ if (p)
return Attr_Data;
- }
- if (o->isStringObject()) {
- Property *p = static_cast<const StringObject *>(o)->getIndex(index);
- if (p)
- return Attr_Data;
- }
- o = o->prototype;
}
return Attr_Invalid;
}
Property *__getPropertyDescriptor__(uint index, PropertyAttributes *attrs = 0) const;
bool __hasProperty__(String *name) const;
- bool __hasProperty__(uint index) const {
- return __getPropertyDescriptor__(index);
- }
+ bool __hasProperty__(uint index) const;
bool __defineOwnProperty__(ExecutionContext *ctx, Property *current, String *member, const Property &p, PropertyAttributes attrs);
bool __defineOwnProperty__(ExecutionContext *ctx, String *name, const Property &p, PropertyAttributes attrs);
String *P = ctx->argument(0).toString(ctx);
Object *O = ctx->thisObject.toObject(ctx);
bool r = O->__getOwnProperty__(P) != 0;
+ if (!r)
+ r = !O->query(P).isEmpty();
return Value::fromBoolean(r);
}
#include "qqmllistwrapper_p.h"
#include <private/qv8engine_p.h>
#include <private/qqmllist_p.h>
+#include <private/qv4objectproto_p.h>
#include <private/qv4functionobject_p.h>
v8(engine)
{
vtbl = &static_vtbl;
+ prototype = QV8Engine::getV4(engine)->objectPrototype;
}
QmlListWrapper::~QmlListWrapper()
if (idx != UINT_MAX)
return getIndexed(m, idx, hasProperty);
- return Value::undefinedValue();
+ return Object::get(m, name, hasProperty);
}
Value QmlListWrapper::getIndexed(Managed *m, uint index, bool *hasProperty)
}
// check for property.
- return QV4::QObjectWrapper::getQmlProperty(v4->current, context, qobjectSingleton, name, QV4::QObjectWrapper::IgnoreRevision);
+ return QV4::QObjectWrapper::getQmlProperty(v4->current, context, qobjectSingleton, name, QV4::QObjectWrapper::IgnoreRevision, hasProperty);
} else if (!siinfo->scriptApi(e).isUndefined()) {
QV4::ExecutionEngine *engine = QV8Engine::getV4(v8engine);
// NOTE: if used in a binding, changes will not trigger re-evaluation since non-NOTIFYable.
} else if (w->object) {
QObject *ao = qmlAttachedPropertiesObjectById(type->attachedPropertiesId(), object);
if (ao)
- return QV4::QObjectWrapper::getQmlProperty(v4->current, context, ao, name, QV4::QObjectWrapper::IgnoreRevision);
+ return QV4::QObjectWrapper::getQmlProperty(v4->current, context, ao, name, QV4::QObjectWrapper::IgnoreRevision, hasProperty);
// Fall through to base implementation
}
} else if (w->typeNamespace) {
Q_ASSERT(w->importNamespace);
- QQmlTypeNameCache::Result r = w->typeNamespace->query(name,
- w->importNamespace);
+ QQmlTypeNameCache::Result r = w->typeNamespace->query(name, w->importNamespace);
if (r.isValid()) {
QQmlContextData *context = v8engine->callingContext();
}
}
+PropertyAttributes QmlTypeWrapper::query(const Managed *m, String *name)
+{
+ // ### Implement more efficiently.
+ bool hasProperty = false;
+ const_cast<Managed*>(m)->get(name, &hasProperty);
+ return hasProperty ? Attr_Data : Attr_Invalid;
+}
+
void QmlTypeWrapper::destroy(Managed *that)
{
static_cast<QmlTypeWrapper *>(that)->~QmlTypeWrapper();
static Value get(Managed *m, String *name, bool *hasProperty);
static void put(Managed *m, String *name, const Value &value);
+ static PropertyAttributes query(const Managed *, String *name);
static void destroy(Managed *that);
private:
return false;
}
+PropertyAttributes QmlValueTypeWrapper::query(const Managed *m, String *name)
+{
+ const QmlValueTypeWrapper *r = m->as<const QmlValueTypeWrapper>();
+ QV4::ExecutionEngine *v4 = m->engine();
+ if (!r)
+ v4->current->throwTypeError();
+
+ QQmlPropertyData local;
+ QQmlPropertyData *result = 0;
+ {
+ QQmlData *ddata = QQmlData::get(r->type, false);
+ if (ddata && ddata->propertyCache)
+ result = ddata->propertyCache->property(name, 0, 0);
+ else
+ result = QQmlPropertyCache::property(r->v8->engine(), r->type, name, 0, local);
+ }
+ return result ? Attr_Data : Attr_Invalid;
+}
+
bool QmlValueTypeWrapper::isEqual(const QVariant& value)
{
if (objectType == QmlValueTypeWrapper::Reference) {
static void put(Managed *m, String *name, const Value &value);
static void destroy(Managed *that);
static bool isEqualTo(Managed *m, Managed *other);
+ static PropertyAttributes query(const Managed *, String *name);
static QV4::Value method_toString(SimpleCallContext *ctx);
QVERIFY(object != 0);
// test QObjects in QML
- QEXPECT_FAIL("", "hasOwnProperty is currently not properly supported for dynamic objects that re-implement get()", Abort);
QMetaObject::invokeMethod(object, "testHasOwnPropertySuccess");
QVERIFY(object->property("result").value<bool>() == true);
QMetaObject::invokeMethod(object, "testHasOwnPropertyFailure");