summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-07-09 12:55:03 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-07-09 12:55:03 (GMT)
commit4599876c471cbd20f4ebe0272edfee93af84cdea (patch)
tree21a8dfb71d757c0cebab388baac720f3caf4390a /src
parent55507beaedf1ef277b84bf6b2dba6182b8c345c2 (diff)
downloadQt-4599876c471cbd20f4ebe0272edfee93af84cdea.zip
Qt-4599876c471cbd20f4ebe0272edfee93af84cdea.tar.gz
Qt-4599876c471cbd20f4ebe0272edfee93af84cdea.tar.bz2
make QObject property setter functions work
Diffstat (limited to 'src')
-rw-r--r--src/script/bridge/qscriptqobject.cpp43
1 files changed, 31 insertions, 12 deletions
diff --git a/src/script/bridge/qscriptqobject.cpp b/src/script/bridge/qscriptqobject.cpp
index 534e141..30c33e1 100644
--- a/src/script/bridge/qscriptqobject.cpp
+++ b/src/script/bridge/qscriptqobject.cpp
@@ -1037,7 +1037,6 @@ JSC::JSValue QtPropertyFunction::execute(JSC::ExecState *exec,
}
} else {
// set
- Q_ASSERT_X(false, Q_FUNC_INFO, "check me");
JSC::JSValue arg = args.at(0);
QVariant v;
if (prop.isEnumType() && arg.isString()
@@ -1251,23 +1250,43 @@ void QObjectWrapperObject::put(JSC::ExecState* exec, const JSC::Identifier& prop
index = meta->indexOfProperty(name);
if (index != -1) {
- if (GeneratePropertyFunctions) {
- // ### the setter should be called
- }
QMetaProperty prop = meta->property(index);
if (prop.isScriptable()) {
if (!(opt & QScriptEngine::ExcludeSuperClassProperties)
|| (index >= meta->propertyOffset())) {
- QVariant v;
- if (prop.isEnumType() && value.isString()
- && !eng->hasDemarshalFunction(prop.userType())) {
- // give QMetaProperty::write() a chance to convert from
- // string to enum value
- v = qtStringFromJSCUString(value.toString(exec));
+ if (GeneratePropertyFunctions) {
+ // ### ideally JSC would do this for us already, i.e. find out
+ // that the property is a setter and call the setter.
+ // Maybe QtPropertyFunction needs to inherit JSC::GetterSetter.
+ JSC::JSValue fun;
+ QHash<QByteArray, JSC::JSValue>::const_iterator it;
+ it = data->cachedMembers.constFind(name);
+ if (it != data->cachedMembers.constEnd()) {
+ fun = it.value();
+ } else {
+ fun = new (exec)QtPropertyFunction(
+ meta, index, &exec->globalData(),
+ exec->lexicalGlobalObject()->functionStructure(),
+ propertyName);
+ data->cachedMembers.insert(name, fun);
+ }
+ JSC::CallData callData;
+ JSC::CallType callType = fun.getCallData(callData);
+ JSC::JSValue argv[1] = { value };
+ JSC::ArgList args(argv, 1);
+ (void)JSC::call(exec, fun, callType, callData, this, args);
} else {
- v = eng->jscValueToVariant(value, prop.userType());
+ QVariant v;
+ if (prop.isEnumType() && value.isString()
+ && !eng->hasDemarshalFunction(prop.userType())) {
+ // give QMetaProperty::write() a chance to convert from
+ // string to enum value
+ v = qtStringFromJSCUString(value.toString(exec));
+ } else {
+ v = eng->jscValueToVariant(value, prop.userType());
+ }
+ (void)prop.write(qobject, v);
}
- (void)prop.write(qobject, v);
return;
}
}