From 28e8cb97ed2813a6baac36f1795b3ba9c71892c2 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Tue, 4 Aug 2009 16:47:08 +0200 Subject: adapt to commit 014c4c63066fd3920594e6a58b02f314b5c88cdf --- src/script/api/qscriptengine.cpp | 13 +++++++------ src/script/api/qscriptvalue.cpp | 12 ++++++------ src/script/bridge/qscriptclassobject.cpp | 5 +++-- src/script/bridge/qscriptclassobject_p.h | 3 ++- src/script/bridge/qscriptobject.cpp | 12 +++++++----- src/script/bridge/qscriptobject_p.h | 6 ++++-- src/script/bridge/qscriptqobject.cpp | 10 ++++++---- src/script/bridge/qscriptqobject_p.h | 6 ++++-- tests/auto/qscriptvalue/tst_qscriptvalue.cpp | 14 ++++---------- 9 files changed, 43 insertions(+), 38 deletions(-) diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index bebb972..088cf77 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -365,7 +365,8 @@ public: virtual void put(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&); virtual bool deleteProperty(JSC::ExecState*, - const JSC::Identifier& propertyName); + const JSC::Identifier& propertyName, + bool checkDontDelete = true); virtual bool getPropertyAttributes(JSC::ExecState*, const JSC::Identifier&, unsigned&) const; virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&, bool includeNonEnumerable = false); @@ -400,8 +401,8 @@ public: JSC::JSValue value, JSC::PutPropertySlot& slot) { originalGlobalObject->JSC::JSGlobalObject::put(exec, propertyName, value, slot); } virtual bool deleteProperty(JSC::ExecState* exec, - const JSC::Identifier& propertyName) - { return originalGlobalObject->JSC::JSGlobalObject::deleteProperty(exec, propertyName); } + const JSC::Identifier& propertyName, bool checkDontDelete = true) + { return originalGlobalObject->JSC::JSGlobalObject::deleteProperty(exec, propertyName, checkDontDelete); } virtual bool getPropertyAttributes(JSC::ExecState* exec, const JSC::Identifier& propertyName, unsigned& attributes) const { return originalGlobalObject->JSC::JSGlobalObject::getPropertyAttributes(exec, propertyName, attributes); } @@ -727,11 +728,11 @@ void GlobalObject::put(JSC::ExecState* exec, const JSC::Identifier& propertyName } bool GlobalObject::deleteProperty(JSC::ExecState* exec, - const JSC::Identifier& propertyName) + const JSC::Identifier& propertyName, bool checkDontDelete) { if (customGlobalObject) - return customGlobalObject->deleteProperty(exec, propertyName); - return JSC::JSGlobalObject::deleteProperty(exec, propertyName); + return customGlobalObject->deleteProperty(exec, propertyName, checkDontDelete); + return JSC::JSGlobalObject::deleteProperty(exec, propertyName, checkDontDelete); } bool GlobalObject::getPropertyAttributes(JSC::ExecState* exec, const JSC::Identifier& propertyName, diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index 24ff050..ae1235e 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -1786,7 +1786,7 @@ void QScriptValue::setProperty(quint32 arrayIndex, const QScriptValue &value, JSC::ExecState *exec = eng_p->currentFrame; JSC::JSValue jscValue = eng_p->scriptValueToJSCValue(value); if (!jscValue) { - JSC::asObject(d->jscValue)->deleteProperty(exec, arrayIndex); + JSC::asObject(d->jscValue)->deleteProperty(exec, arrayIndex, /*checkDontDelete=*/false); } else { if ((flags & QScriptValue::PropertyGetter) || (flags & QScriptValue::PropertySetter)) { Q_ASSERT_X(false, Q_FUNC_INFO, "property getters and setters not implemented"); @@ -1870,15 +1870,15 @@ void QScriptValue::setProperty(const QScriptString &name, // deleting getter/setter if ((flags & QScriptValue::PropertyGetter) && (flags & QScriptValue::PropertySetter)) { // deleting both: just delete the property - thisObject->deleteProperty(exec, id); + thisObject->deleteProperty(exec, id, /*checkDontDelete=*/false); } else if (flags & QScriptValue::PropertyGetter) { // preserve setter, if there is one - thisObject->deleteProperty(exec, id); + thisObject->deleteProperty(exec, id, /*checkDontDelete=*/false); if (setter && setter.isObject()) thisObject->defineSetter(exec, id, JSC::asObject(setter)); } else { // flags & QScriptValue::PropertySetter // preserve getter, if there is one - thisObject->deleteProperty(exec, id); + thisObject->deleteProperty(exec, id, /*checkDontDelete=*/false); if (getter && getter.isObject()) thisObject->defineGetter(exec, id, JSC::asObject(getter)); } @@ -1908,10 +1908,10 @@ void QScriptValue::setProperty(const QScriptString &name, } if (!jscValue) { // ### check if it's a getter/setter property - thisObject->deleteProperty(exec, id); + thisObject->deleteProperty(exec, id, /*checkDontDelete=*/false); } else if (flags != QScriptValue::KeepExistingFlags) { if (thisObject->hasOwnProperty(exec, id)) - thisObject->deleteProperty(exec, id); // ### hmmm - can't we just update the attributes? + thisObject->deleteProperty(exec, id, /*checkDontDelete=*/false); // ### hmmm - can't we just update the attributes? unsigned attribs = 0; if (flags & QScriptValue::ReadOnly) attribs |= JSC::ReadOnly; diff --git a/src/script/bridge/qscriptclassobject.cpp b/src/script/bridge/qscriptclassobject.cpp index 4913e73..5232ca2 100644 --- a/src/script/bridge/qscriptclassobject.cpp +++ b/src/script/bridge/qscriptclassobject.cpp @@ -125,7 +125,8 @@ void ClassObjectDelegate::put(QScriptObject* object, JSC::ExecState *exec, } bool ClassObjectDelegate::deleteProperty(QScriptObject* object, JSC::ExecState *exec, - const JSC::Identifier &propertyName) + const JSC::Identifier &propertyName, + bool checkDontDelete) { // ### avoid duplication of put() QScriptEnginePrivate *engine = scriptEngineFromExec(exec); @@ -141,7 +142,7 @@ bool ClassObjectDelegate::deleteProperty(QScriptObject* object, JSC::ExecState * m_scriptClass->setProperty(scriptObject, scriptName, id, QScriptValue()); return true; } - return QScriptObjectDelegate::deleteProperty(object, exec, propertyName); + return QScriptObjectDelegate::deleteProperty(object, exec, propertyName, checkDontDelete); } bool ClassObjectDelegate::getPropertyAttributes(const QScriptObject* object, JSC::ExecState *exec, diff --git a/src/script/bridge/qscriptclassobject_p.h b/src/script/bridge/qscriptclassobject_p.h index 61ece04..39d281d 100644 --- a/src/script/bridge/qscriptclassobject_p.h +++ b/src/script/bridge/qscriptclassobject_p.h @@ -84,7 +84,8 @@ public: const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&); virtual bool deleteProperty(QScriptObject*, JSC::ExecState*, - const JSC::Identifier& propertyName); + const JSC::Identifier& propertyName, + bool checkDontDelete = true); virtual bool getPropertyAttributes(const QScriptObject*, JSC::ExecState*, const JSC::Identifier&, unsigned&) const; diff --git a/src/script/bridge/qscriptobject.cpp b/src/script/bridge/qscriptobject.cpp index 65c4754..e4d2168 100644 --- a/src/script/bridge/qscriptobject.cpp +++ b/src/script/bridge/qscriptobject.cpp @@ -117,11 +117,12 @@ void QScriptObject::put(JSC::ExecState* exec, const JSC::Identifier& propertyNam } bool QScriptObject::deleteProperty(JSC::ExecState* exec, - const JSC::Identifier& propertyName) + const JSC::Identifier& propertyName, + bool checkDontDelete) { if (!d || !d->delegate) - return JSC::JSObject::deleteProperty(exec, propertyName); - return d->delegate->deleteProperty(this, exec, propertyName); + return JSC::JSObject::deleteProperty(exec, propertyName, checkDontDelete); + return d->delegate->deleteProperty(this, exec, propertyName, checkDontDelete); } bool QScriptObject::getPropertyAttributes(JSC::ExecState* exec, const JSC::Identifier& propertyName, @@ -203,9 +204,10 @@ void QScriptObjectDelegate::put(QScriptObject* object, JSC::ExecState* exec, } bool QScriptObjectDelegate::deleteProperty(QScriptObject* object, JSC::ExecState* exec, - const JSC::Identifier& propertyName) + const JSC::Identifier& propertyName, + bool checkDontDelete) { - return object->JSC::JSObject::deleteProperty(exec, propertyName); + return object->JSC::JSObject::deleteProperty(exec, propertyName, checkDontDelete); } bool QScriptObjectDelegate::getPropertyAttributes(const QScriptObject* object, diff --git a/src/script/bridge/qscriptobject_p.h b/src/script/bridge/qscriptobject_p.h index 17e5e6b..b52e654 100644 --- a/src/script/bridge/qscriptobject_p.h +++ b/src/script/bridge/qscriptobject_p.h @@ -85,7 +85,8 @@ public: virtual void put(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&); virtual bool deleteProperty(JSC::ExecState*, - const JSC::Identifier& propertyName); + const JSC::Identifier& propertyName, + bool checkDontDelete = true); virtual bool getPropertyAttributes(JSC::ExecState*, const JSC::Identifier&, unsigned&) const; virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&, bool includeNonEnumerable = false); @@ -139,7 +140,8 @@ public: virtual void put(QScriptObject*, JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&); virtual bool deleteProperty(QScriptObject*, JSC::ExecState*, - const JSC::Identifier& propertyName); + const JSC::Identifier& propertyName, + bool checkDontDelete = true); virtual bool getPropertyAttributes(const QScriptObject*, JSC::ExecState*, const JSC::Identifier&, unsigned&) const; virtual void getPropertyNames(QScriptObject*, JSC::ExecState*, JSC::PropertyNameArray&, diff --git a/src/script/bridge/qscriptqobject.cpp b/src/script/bridge/qscriptqobject.cpp index 4e9b74b..324b149 100644 --- a/src/script/bridge/qscriptqobject.cpp +++ b/src/script/bridge/qscriptqobject.cpp @@ -1368,7 +1368,8 @@ void QObjectDelegate::put(QScriptObject *object, JSC::ExecState* exec, } bool QObjectDelegate::deleteProperty(QScriptObject *object, JSC::ExecState *exec, - const JSC::Identifier& propertyName) + const JSC::Identifier& propertyName, + bool checkDontDelete) { QByteArray name = qtStringFromJSCUString(propertyName.ustring()).toLatin1(); QObject *qobject = data->value; @@ -1407,7 +1408,7 @@ bool QObjectDelegate::deleteProperty(QScriptObject *object, JSC::ExecState *exec return true; } - return QScriptObjectDelegate::deleteProperty(object, exec, propertyName); + return QScriptObjectDelegate::deleteProperty(object, exec, propertyName, checkDontDelete); } bool QObjectDelegate::getPropertyAttributes(const QScriptObject *object, @@ -1723,7 +1724,8 @@ void QMetaObjectWrapperObject::put(JSC::ExecState* exec, const JSC::Identifier& } bool QMetaObjectWrapperObject::deleteProperty( - JSC::ExecState *exec, const JSC::Identifier& propertyName) + JSC::ExecState *exec, const JSC::Identifier& propertyName, + bool checkDontDelete) { if (propertyName == exec->propertyNames().prototype) return false; @@ -1738,7 +1740,7 @@ bool QMetaObjectWrapperObject::deleteProperty( } } } - return JSC::JSObject::deleteProperty(exec, propertyName); + return JSC::JSObject::deleteProperty(exec, propertyName, checkDontDelete); } bool QMetaObjectWrapperObject::getPropertyAttributes(JSC::ExecState *exec, diff --git a/src/script/bridge/qscriptqobject_p.h b/src/script/bridge/qscriptqobject_p.h index 14b426e..0af6632 100644 --- a/src/script/bridge/qscriptqobject_p.h +++ b/src/script/bridge/qscriptqobject_p.h @@ -102,7 +102,8 @@ public: const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&); virtual bool deleteProperty(QScriptObject*, JSC::ExecState*, - const JSC::Identifier& propertyName); + const JSC::Identifier& propertyName, + bool checkDontDelete = true); virtual bool getPropertyAttributes(const QScriptObject*, JSC::ExecState*, const JSC::Identifier&, unsigned&) const; @@ -291,7 +292,8 @@ public: virtual void put(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&); virtual bool deleteProperty(JSC::ExecState*, - const JSC::Identifier& propertyName); + const JSC::Identifier& propertyName, + bool checkDontDelete = true); virtual bool getPropertyAttributes(JSC::ExecState*, const JSC::Identifier&, unsigned&) const; virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&, diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp index 99f5770..2b48c30 100644 --- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp +++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp @@ -2031,6 +2031,10 @@ void tst_QScriptValue::getSetProperty() "} found"); QCOMPARE(ret.strictlyEquals(QScriptValue(&eng, true)), true); } + // should still be deletable from C++ + object.setProperty("undeletableProperty", QScriptValue()); + QVERIFY(!object.property("undeletableProperty").isValid()); + QCOMPARE(object.propertyFlags("undeletableProperty"), 0); // SkipInEnumeration object.setProperty("dontEnumProperty", num, QScriptValue::SkipInEnumeration); @@ -2071,7 +2075,6 @@ void tst_QScriptValue::getSetProperty() QCOMPARE(object.propertyFlags("flagProperty"), QScriptValue::ReadOnly | QScriptValue::Undeletable); object.setProperty("flagProperty", str, QScriptValue::UserRange); - QEXPECT_FAIL("", "User-range flags are not retained for normal properties (JSC discards them?)", Continue); QCOMPARE(object.propertyFlags("flagProperty"), QScriptValue::UserRange); // using interned strings @@ -2083,15 +2086,6 @@ void tst_QScriptValue::getSetProperty() object.setProperty(foo, num); QVERIFY(object.property(foo).strictlyEquals(num)); QVERIFY(object.property("foo").strictlyEquals(num)); - - // can't set length property of native function objects - { - QScriptValue fun = eng.newFunction(getterSetter, /*length=*/2); - for (int x = 0; x < 2; ++x) { - QVERIFY(fun.property("length").strictlyEquals(QScriptValue(&eng, 2))); - fun.setProperty("length", QScriptValue()); - } - } } void tst_QScriptValue::getSetPrototype() -- cgit v0.12