aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlglobal.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/qml/qqmlglobal.cpp')
-rw-r--r--src/qml/qml/qqmlglobal.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlglobal.cpp b/src/qml/qml/qqmlglobal.cpp
index 90889c2ea4..aa899b2592 100644
--- a/src/qml/qml/qqmlglobal.cpp
+++ b/src/qml/qml/qqmlglobal.cpp
@@ -94,6 +94,17 @@ static void callConstructor(
}
template<typename Allocate>
+static void fromVerifiedType(
+ const QMetaObject *mo, int ctorIndex, void *sData, Allocate &&allocate)
+{
+ const QMetaMethod ctor = mo->constructor(ctorIndex);
+ Q_ASSERT_X(ctor.parameterCount() == 1, "fromVerifiedType",
+ "Value type constructor must take exactly one argument");
+ callConstructor(mo, ctorIndex, sData, allocate());
+}
+
+
+template<typename Allocate>
static bool fromMatchingType(
const QMetaObject *mo, const QV4::Value &s, Allocate &&allocate)
{
@@ -299,6 +310,16 @@ bool QQmlValueTypeProvider::createValueType(const QV4::Value &s, QMetaType metaT
return false;
}
+QVariant QQmlValueTypeProvider::constructValueType(
+ QMetaType resultMetaType, const QMetaObject *resultMetaObject,
+ int ctorIndex, void *ctorArg)
+{
+ QVariant result;
+ fromVerifiedType(resultMetaObject, ctorIndex, ctorArg,
+ [&]() { return createVariantData(resultMetaType, &result); });
+ return result;
+}
+
static QVariant fromJSValue(const QQmlType &type, const QJSValue &s, QMetaType metaType)
{
if (const auto valueTypeFunction = type.createValueTypeFunction()) {