diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-07-09 11:55:31 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-07-09 11:57:24 (GMT) |
commit | d96bc6ba81465c5a82ca08ac68c2dac54a57700f (patch) | |
tree | 474b215e655a657cff6266d377afda1a2c4893d3 /src/script/bridge | |
parent | 5bf417cf836636aab1dcadffaa73f26966880dff (diff) | |
download | Qt-d96bc6ba81465c5a82ca08ac68c2dac54a57700f.zip Qt-d96bc6ba81465c5a82ca08ac68c2dac54a57700f.tar.gz Qt-d96bc6ba81465c5a82ca08ac68c2dac54a57700f.tar.bz2 |
make QObject property access use getter+setter functions
Setters don't work yet. But hey, the defaultprototypes
example finally works.
Diffstat (limited to 'src/script/bridge')
-rw-r--r-- | src/script/bridge/qscriptqobject.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/script/bridge/qscriptqobject.cpp b/src/script/bridge/qscriptqobject.cpp index b3a92b3..534e141 100644 --- a/src/script/bridge/qscriptqobject.cpp +++ b/src/script/bridge/qscriptqobject.cpp @@ -171,7 +171,7 @@ static QVariant variantFromValue(QScriptEnginePrivate *eng, return QVariant(); } -static const bool GeneratePropertyFunctions = false; +static const bool GeneratePropertyFunctions = true; static unsigned flagsForMetaProperty(const QMetaProperty &prop) { @@ -1120,16 +1120,19 @@ bool QObjectWrapperObject::getOwnPropertySlot(JSC::ExecState *exec, return false; } + const QMetaObject *meta = qobject->metaObject(); { QHash<QByteArray, JSC::JSValue>::const_iterator it = data->cachedMembers.constFind(name); if (it != data->cachedMembers.constEnd()) { - slot.setValue(it.value()); + if (GeneratePropertyFunctions && (meta->indexOfProperty(name) != -1)) + slot.setGetterSlot(JSC::asObject(it.value())); + else + slot.setValue(it.value()); return true; } } const QScriptEngine::QObjectWrapOptions &opt = data->options; - const QMetaObject *meta = qobject->metaObject(); QScriptEnginePrivate *eng = static_cast<QScript::GlobalObject*>(exec->lexicalGlobalObject())->engine; int index = -1; if (name.contains('(')) { @@ -1248,8 +1251,9 @@ void QObjectWrapperObject::put(JSC::ExecState* exec, const JSC::Identifier& prop index = meta->indexOfProperty(name); if (index != -1) { - if (GeneratePropertyFunctions) - qWarning("Booo, the property setter should be called..."); + if (GeneratePropertyFunctions) { + // ### the setter should be called + } QMetaProperty prop = meta->property(index); if (prop.isScriptable()) { if (!(opt & QScriptEngine::ExcludeSuperClassProperties) @@ -1302,16 +1306,18 @@ bool QObjectWrapperObject::deleteProperty(JSC::ExecState *exec, return false; } + const QMetaObject *meta = qobject->metaObject(); { QHash<QByteArray, JSC::JSValue>::iterator it = data->cachedMembers.find(name); if (it != data->cachedMembers.end()) { + if (GeneratePropertyFunctions && (meta->indexOfProperty(name) != -1)) + return false; data->cachedMembers.erase(it); return true; } } const QScriptEngine::QObjectWrapOptions &opt = data->options; - const QMetaObject *meta = qobject->metaObject(); int index = meta->indexOfProperty(name); if (index != -1) { QMetaProperty prop = meta->property(index); |