diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-08-10 09:24:09 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-08-10 09:24:09 (GMT) |
commit | 692f13f4980cf13acef3164bfe2d89721e09a406 (patch) | |
tree | 02cba1ecf94926f858aa2629e58ac89a4f8fcb2b /src | |
parent | a5cc9714deb37281d97f03f3eaf23ebd0be41f0f (diff) | |
download | Qt-692f13f4980cf13acef3164bfe2d89721e09a406.zip Qt-692f13f4980cf13acef3164bfe2d89721e09a406.tar.gz Qt-692f13f4980cf13acef3164bfe2d89721e09a406.tar.bz2 |
make property flags lookup work for properties in prototype chain
JSObject::getPropertyAttributes() does not follow the prototype
chain, so we have to do it.
Diffstat (limited to 'src')
-rw-r--r-- | src/script/api/qscriptvalue.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index d2569ae..9bf4ff2 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -1964,10 +1964,14 @@ QScriptValue::PropertyFlags QScriptValue::propertyFlags(const QScriptString &nam return 0; QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(d->engine); JSC::ExecState *exec = eng_p->currentFrame; + JSC::JSObject *object = JSC::asObject(d->jscValue); JSC::Identifier id = name.d_ptr->identifier; unsigned attribs = 0; - if (!JSC::asObject(d->jscValue)->getPropertyAttributes(exec, id, attribs)) + if (!object->getPropertyAttributes(exec, id, attribs)) { + if ((mode & QScriptValue::ResolvePrototype) && object->prototype()) + return eng_p->scriptValueFromJSCValue(object->prototype()).propertyFlags(name, mode); return 0; + } QScriptValue::PropertyFlags result = 0; if (attribs & JSC::ReadOnly) result |= QScriptValue::ReadOnly; @@ -1976,9 +1980,9 @@ QScriptValue::PropertyFlags QScriptValue::propertyFlags(const QScriptString &nam if (attribs & JSC::DontDelete) result |= QScriptValue::Undeletable; //We cannot rely on attribs JSC::Setter/Getter because they are not necesserly set by JSC (bug?) - if (attribs & JSC::Getter || !JSC::asObject(d->jscValue)->lookupGetter(exec, id).isUndefinedOrNull()) + if (attribs & JSC::Getter || !object->lookupGetter(exec, id).isUndefinedOrNull()) result |= QScriptValue::PropertyGetter; - if (attribs & JSC::Setter || !JSC::asObject(d->jscValue)->lookupSetter(exec, id).isUndefinedOrNull()) + if (attribs & JSC::Setter || !object->lookupSetter(exec, id).isUndefinedOrNull()) result |= QScriptValue::PropertySetter; if (attribs & QScript::QObjectMemberAttribute) result |= QScriptValue::QObjectMember; |