diff options
Diffstat (limited to 'src/qml/jsapi/qjsengine.h')
| -rw-r--r-- | src/qml/jsapi/qjsengine.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/qml/jsapi/qjsengine.h b/src/qml/jsapi/qjsengine.h index dbeecb45ae..a16ac60603 100644 --- a/src/qml/jsapi/qjsengine.h +++ b/src/qml/jsapi/qjsengine.h @@ -145,6 +145,18 @@ public: } } + if constexpr (std::is_same_v<T, double>) { + if (sourceType == QMetaType::fromType<int>()) + return double(*static_cast<const int *>(value.constData())); + } + + if constexpr (std::is_same_v<T, int>) { + if (sourceType == QMetaType::fromType<double>()) { + return QJSNumberCoercion::toInteger( + *static_cast<const double *>(value.constData())); + } + } + if constexpr (std::is_same_v<QObject, std::remove_const_t<std::remove_pointer_t<T>>>) { if (sourceType.flags() & QMetaType::PointerToQObject) { return *static_cast<QObject *const *>(value.constData()); @@ -254,6 +266,16 @@ public: return from; } + if constexpr (std::is_same_v<To, double>) { + if constexpr (std::is_same_v<From, int>) + return double(from); + } + + if constexpr (std::is_same_v<To, int>) { + if constexpr (std::is_same_v<From, double>) + return QJSNumberCoercion::toInteger(from); + } + { const QMetaType sourceType = QMetaType::fromType<From>(); const QMetaType targetType = QMetaType::fromType<To>(); |
