aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/v8/qv8valuetypewrapper.cpp
diff options
context:
space:
mode:
authorChris Adams <christopher.adams@nokia.com>2012-07-16 16:32:49 +1000
committerQt by Nokia <qt-info@nokia.com>2012-08-09 07:58:06 +0200
commit42f9444e983b5257241c17242471ca63f208c3f6 (patch)
tree4847ae743a0e05b0ff9d3d4ab6003ea257a6c682 /src/qml/qml/v8/qv8valuetypewrapper.cpp
parentf09517bd9c907698a05ee92ccf158a06db3340b8 (diff)
Allow invokable functions of value-type classes to be called
Previously, invokable functions of value-type classes were returned as properties. This commit fixes that bug by allowing such functions to be invoked normally. It also improves copy-value type handling. This commit also ensures that QMatrix4x4 value types are constructed with qreal values as this is the storage type used internally. Change-Id: Iab0fe4c522ed53d60154e8a8d46dda925fb9f4de Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src/qml/qml/v8/qv8valuetypewrapper.cpp')
-rw-r--r--src/qml/qml/v8/qv8valuetypewrapper.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/qml/qml/v8/qv8valuetypewrapper.cpp b/src/qml/qml/v8/qv8valuetypewrapper.cpp
index cf6c530f5b..fe58546522 100644
--- a/src/qml/qml/v8/qv8valuetypewrapper.cpp
+++ b/src/qml/qml/v8/qv8valuetypewrapper.cpp
@@ -235,6 +235,9 @@ bool QV8ValueTypeWrapper::isEqual(QV8ObjectResource *r, const QVariant& value)
} else {
Q_ASSERT(resource->objectType == QV8ValueTypeResource::Copy);
QV8ValueTypeCopyResource *copy = static_cast<QV8ValueTypeCopyResource *>(resource);
+ resource->type->setValue(copy->value);
+ if (resource->type->isEqual(value))
+ return true;
return (value == copy->value);
}
}
@@ -260,11 +263,8 @@ v8::Handle<v8::Value> QV8ValueTypeWrapper::ToString(const v8::Arguments &args)
} else {
Q_ASSERT(resource->objectType == QV8ValueTypeResource::Copy);
QV8ValueTypeCopyResource *copy = static_cast<QV8ValueTypeCopyResource *>(resource);
- QString result = copy->value.toString();
- if (result.isEmpty() && !copy->value.canConvert(QVariant::String)) {
- result = QString::fromLatin1("QVariant(%0)").arg(QString::fromLatin1(copy->value.typeName()));
- }
- return resource->engine->toString(result);
+ resource->type->setValue(copy->value);
+ return resource->engine->toString(resource->type->toString());
}
} else {
return v8::Undefined();
@@ -317,6 +317,11 @@ v8::Handle<v8::Value> QV8ValueTypeWrapper::Getter(v8::Local<v8::String> property
if (!result)
return v8::Handle<v8::Value>();
+ if (result->isFunction()) {
+ // calling a Q_INVOKABLE function of a value type
+ return r->engine->qobjectWrapper()->getProperty(r->type, propertystring, QV8QObjectWrapper::IgnoreRevision);
+ }
+
#define VALUE_TYPE_LOAD(metatype, cpptype, constructor) \
if (result->propType == metatype) { \
cpptype v; \