diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-02-19 12:29:58 +0100 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-02-19 18:12:43 +0100 |
commit | 871d85a1deb070fa059c1280ab234523a99b565c (patch) | |
tree | 7daf992d82fb36d8877ac88dca4292f1b77b5a9b | |
parent | 0cf6e06a8e936d36774fbcf953ea65ad1f7f0b8d (diff) |
metaTypeToJS: use QMetaType instead of id
Task-number: QTBUG-82931
Change-Id: I7b663c5f774ef3edbb19d5f2ef53cfe623a8e4cf
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r-- | src/qml/jsapi/qjsengine.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsapi/qjsengine.h | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4jscall.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlvmemetaobject.cpp | 2 |
7 files changed, 11 insertions, 11 deletions
diff --git a/src/qml/jsapi/qjsengine.cpp b/src/qml/jsapi/qjsengine.cpp index 94b0628cd7..dbb35cdde8 100644 --- a/src/qml/jsapi/qjsengine.cpp +++ b/src/qml/jsapi/qjsengine.cpp @@ -731,7 +731,7 @@ QJSValue QJSEngine::globalObject() const QJSManagedValue QJSEngine::createManaged(QMetaType type, const void *ptr) { QJSManagedValue result(m_v4Engine); - *result.d = m_v4Engine->metaTypeToJS(type.id(), ptr); + *result.d = m_v4Engine->metaTypeToJS(type, ptr); return result; } @@ -739,7 +739,7 @@ QJSManagedValue QJSEngine::createManaged(QMetaType type, const void *ptr) * \internal * used by QJSEngine::toScriptValue */ -QJSValue QJSEngine::create(int type, const void *ptr) +QJSValue QJSEngine::create(QMetaType type, const void *ptr) { QV4::Scope scope(m_v4Engine); QV4::ScopedValue v(scope, scope.engine->metaTypeToJS(type, ptr)); diff --git a/src/qml/jsapi/qjsengine.h b/src/qml/jsapi/qjsengine.h index 783f602c12..05c94ab261 100644 --- a/src/qml/jsapi/qjsengine.h +++ b/src/qml/jsapi/qjsengine.h @@ -90,7 +90,7 @@ public: template <typename T> inline QJSValue toScriptValue(const T &value) { - return create(qMetaTypeId<T>(), &value); + return create(QMetaType::fromType<T>(), &value); } template <typename T> @@ -146,7 +146,7 @@ Q_SIGNALS: private: QJSManagedValue createManaged(QMetaType type, const void *ptr); - QJSValue create(int type, const void *ptr); + QJSValue create(QMetaType type, const void *ptr); static bool convertManaged(const QJSManagedValue &value, int type, void *ptr); static bool convertV2(const QJSValue &value, int type, void *ptr); diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 38a21f87b5..85cbca05b8 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -1508,7 +1508,7 @@ static QV4::ReturnedValue sequentialIterableToJS(QV4::ExecutionEngine *v4, const static QV4::ReturnedValue variantMapToJS(QV4::ExecutionEngine *v4, const QVariantMap &vmap); static QV4::ReturnedValue variantToJS(QV4::ExecutionEngine *v4, const QVariant &value) { - return v4->metaTypeToJS(value.userType(), value.constData()); + return v4->metaTypeToJS(value.metaType(), value.constData()); } @@ -1932,11 +1932,11 @@ static QV4::ReturnedValue variantMapToJS(QV4::ExecutionEngine *v4, const QVarian // Converts the meta-type defined by the given type and data to JS. // Returns the value if conversion succeeded, an empty handle otherwise. -QV4::ReturnedValue ExecutionEngine::metaTypeToJS(int type, const void *data) +QV4::ReturnedValue ExecutionEngine::metaTypeToJS(QMetaType type, const void *data) { Q_ASSERT(data != nullptr); - QVariant variant(QMetaType(type), data); + QVariant variant(type, data); if (QMetaType::Type(variant.userType()) == QMetaType::QVariant) { // unwrap it: this is tested in QJSEngine, and makes the most sense for // end-user code too. diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index 7fc2b1670b..d91f7bf4a3 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -665,7 +665,7 @@ public: QVariantMap variantMapFromJS(const QV4::Object *o); static bool metaTypeFromJS(const Value &value, int type, void *data); - QV4::ReturnedValue metaTypeToJS(int type, const void *data); + QV4::ReturnedValue metaTypeToJS(QMetaType type, const void *data); int maxJSStackSize() const; int maxGCStackSize() const; diff --git a/src/qml/jsruntime/qv4jscall.cpp b/src/qml/jsruntime/qv4jscall.cpp index 5ffdc40879..8cd656ae2e 100644 --- a/src/qml/jsruntime/qv4jscall.cpp +++ b/src/qml/jsruntime/qv4jscall.cpp @@ -54,7 +54,7 @@ void QV4::populateJSCallArguments(ExecutionEngine *v4, JSCallData &jsCall, { const int argCount = types ? types[0] : 0; for (int ii = 0; ii < argCount; ++ii) { - int type = types[ii + 1]; + auto type = QMetaType(types[ii + 1]); jsCall.args[ii] = v4->metaTypeToJS(type, args[ii + 1]); } } diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index 03c0ed7e89..f606f8152d 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -500,7 +500,7 @@ ReturnedValue VME::exec(CppStackFrame *frame, ExecutionEngine *engine) function->aotFunction->functionPtr(&aotContext, returnValue, argumentPtrs); if (returnValue) { - result = engine->metaTypeToJS(returnType.id(), returnValue); + result = engine->metaTypeToJS(returnType, returnValue); returnType.destruct(returnValue); } else { result = Encode::undefined(); diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp index 265169a4d8..417ac6b3b7 100644 --- a/src/qml/qml/qqmlvmemetaobject.cpp +++ b/src/qml/qml/qqmlvmemetaobject.cpp @@ -1004,7 +1004,7 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void * *jsCallData->thisObject = v4->global(); for (uint ii = 0; ii < parameterCount; ++ii) { - jsCallData->args[ii] = scope.engine->metaTypeToJS(arguments->arguments[ii + 1], a[ii + 1]); + jsCallData->args[ii] = scope.engine->metaTypeToJS(QMetaType(arguments->arguments[ii + 1]), a[ii + 1]); } const QMetaType returnType = methodData->propType(); |