type, int qmlTypeId) {
+ io.qt.core.QObject object = singletonInstance(QtJambi_LibraryUtilities.internal.nativeId(this), qmlTypeId).toQObject();
+ if(object!=null)
+ return object.qt_metacast(type);
+ return null;
+ }
+
+ /**
+ * See QQmlEngine::singletonInstance(int qmlTypeId)
+ */
+ @io.qt.QtUninvokable
+ public final QJSValue singletonInstance(int qmlTypeId) {
+ return singletonInstance(QtJambi_LibraryUtilities.internal.nativeId(this), qmlTypeId);
+ }
+
+ @io.qt.QtUninvokable
+ private static native QJSValue singletonInstance(long __this__nativeId, int qmlTypeId);
+
+}// class
+
class QQmlExpression__{
public static class ValueIsUndefined extends RuntimeException{
private static final long serialVersionUID = 7719401165632826435L;
diff --git a/generator/typesystem/java/typesystem_webenginequick-java.java b/generator/typesystem/java/typesystem_webenginequick-java.java
new file mode 100644
index 00000000..1c3a94bb
--- /dev/null
+++ b/generator/typesystem/java/typesystem_webenginequick-java.java
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2009-2022 Dr. Peter Droste, Omix Visualization GmbH & Co. KG. All rights reserved.
+**
+** This file is part of Qt Jambi.
+**
+** ** $BEGIN_LICENSE$
+**
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** $END_LICENSE$
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
+
+class QtWebEngineQuick___{
+ /**
+ * Allows accessing the QWebEngineSettings inside of a QQuickWebEngineSettings (internal type).
+ * @param quickWebEngineSettings QQuickWebEngineSettings object
+ * @return QWebEngineSettings
+ */
+ @SuppressWarnings("exports")
+ public static native io.qt.webengine.core.QWebEngineSettings toWebEngineSettings(io.qt.core.QObject quickWebEngineSettings);
+
+ /**
+ * Allows accessing the QWebEngineScriptCollection inside of a QQuickWebEngineScriptCollection (internal type).
+ * @param quickWebEngineScriptCollection QQuickWebEngineScriptCollection object
+ * @return QWebEngineScriptCollection
+ */
+ @SuppressWarnings("exports")
+ public static native io.qt.webengine.core.QWebEngineScriptCollection toWebEngineScriptCollection(io.qt.core.QObject quickWebEngineScriptCollection);
+}// class
+
+
diff --git a/generator/typesystem/typedatabase.cpp b/generator/typesystem/typedatabase.cpp
index aa71ed6a..eb029057 100644
--- a/generator/typesystem/typedatabase.cpp
+++ b/generator/typesystem/typedatabase.cpp
@@ -85,7 +85,9 @@ TypeDatabase::TypeDatabase() :
m_suppressWarnings(true),
m_includeEclipseWarnings(false),
m_pixmapType(nullptr),
- m_bitmapType(nullptr) {
+ m_bitmapType(nullptr),
+ m_qstringType(nullptr),
+ m_qcharType(nullptr){
}
TypeDatabase *TypeDatabase::instance() {
@@ -208,8 +210,10 @@ NamespaceTypeEntry *TypeDatabase::findNamespaceType(const QString &name) {
void TypeDatabase::addType(TypeEntry *e) {
if(e->qualifiedCppName()=="QString" && !e->isQString()){
m_entries["QtJambiString"].append(e);
+ m_qstringType = dynamic_cast(e);
}else if(e->qualifiedCppName()=="QChar" && !e->isChar()){
m_entries["QtJambiChar"].append(e);
+ m_qcharType = dynamic_cast(e);
}else{
m_entries[e->qualifiedCppName()].append(e);
}
@@ -222,10 +226,10 @@ void TypeDatabase::addType(TypeEntry *e) {
}
}
if(!m_pixmapType && e->qualifiedCppName()==QLatin1String("QPixmap")){
- m_pixmapType = e;
+ m_pixmapType = dynamic_cast(e);
}
if(!m_bitmapType && e->qualifiedCppName()==QLatin1String("QBitmap")){
- m_bitmapType = e;
+ m_bitmapType = dynamic_cast(e);
}
}
diff --git a/generator/typesystem/typedatabase.h b/generator/typesystem/typedatabase.h
index 938ca013..9a969e67 100644
--- a/generator/typesystem/typedatabase.h
+++ b/generator/typesystem/typedatabase.h
@@ -156,6 +156,14 @@ class TypeDatabase {
inline uint qtVersion() const {return m_qtVersion;}
+ ComplexTypeEntry * qstringType() const{
+ return m_qstringType;
+ }
+
+ ComplexTypeEntry * qcharType() const{
+ return m_qcharType;
+ }
+
private:
uint m_qtVersion;
uint m_suppressWarnings :
@@ -178,8 +186,10 @@ class TypeDatabase {
DefinedPtr m_defined;
QMap m_typeSystemsByQtLibrary;
- const TypeEntry * m_pixmapType;
- const TypeEntry * m_bitmapType;
+ ComplexTypeEntry * m_pixmapType;
+ ComplexTypeEntry * m_bitmapType;
+ ComplexTypeEntry * m_qstringType;
+ ComplexTypeEntry * m_qcharType;
};
#endif
diff --git a/generator/typesystem/typeentry.cpp b/generator/typesystem/typeentry.cpp
index 6e7eb00f..df4b9ffd 100644
--- a/generator/typesystem/typeentry.cpp
+++ b/generator/typesystem/typeentry.cpp
@@ -203,10 +203,10 @@ QString EnumTypeEntry::javaPackage() const {
}else{
m_qualifier_type = TypeDatabase::instance()->findType(m_javaScope);
}
- if(m_qualifier_type && m_qualifier_type->isQString())
- m_qualifier_type = TypeDatabase::instance()->findType("QtJambiString");
- else if(m_qualifier_type && m_qualifier_type->isChar())
- m_qualifier_type = TypeDatabase::instance()->findType("QtJambiChar");
+ if(m_qualifier_type && m_qualifier_type->isQString() && TypeDatabase::instance()->qstringType())
+ m_qualifier_type = TypeDatabase::instance()->qstringType();
+ else if(m_qualifier_type && m_qualifier_type->isChar() && TypeDatabase::instance()->qcharType())
+ m_qualifier_type = TypeDatabase::instance()->qcharType();
}
if (m_qualifier_type){
if(m_qualifier_type->isVariant())
diff --git a/generator/typesystem/xml/typesystem_core-common.xml b/generator/typesystem/xml/typesystem_core-common.xml
index cc861fc1..5f39f511 100644
--- a/generator/typesystem/xml/typesystem_core-common.xml
+++ b/generator/typesystem/xml/typesystem_core-common.xml
@@ -50,8 +50,6 @@
<li>QtGui - Base classes for graphical user interface (GUI) components. Includes OpenGL.</li>
<li>QtWidgets - Classes to extend Qt GUI with C++ widgets.</li>
</ul>
-
-
@@ -289,6 +287,7 @@
+
@@ -2730,11 +2729,9 @@
-
-
@@ -2966,7 +2963,8 @@
-
+
+
@@ -3438,7 +3436,6 @@
-
@@ -3725,8 +3722,10 @@
+
+
diff --git a/generator/typesystem/xml/typesystem_core-java.xml b/generator/typesystem/xml/typesystem_core-java.xml
index f02f55d4..15cda810 100644
--- a/generator/typesystem/xml/typesystem_core-java.xml
+++ b/generator/typesystem/xml/typesystem_core-java.xml
@@ -3116,7 +3116,7 @@ if(!useQGuiApplicationExec){
-
+
@@ -3219,11 +3219,27 @@ if(!useQGuiApplicationExec){
+
+
+
+
+ Q_UNUSED(__qt_return_value)
+ %out = qtjambi_to_stringobject(%env, __qt_%1);
+
+
+
+
+
+ QString %out;
+
+
+
+
- Q_UNUSED(__qt_return_value)
+ Q_UNUSED(__qt_return_value)
%out = qtjambi_from_qstring(%env, __qt_%1);
@@ -3233,10 +3249,23 @@ if(!useQGuiApplicationExec){
QString %out;
+
+
+
+
+
+
+
+
+
+
+ QString %out = qtjambi_to_qstring(%env, %1);
+
+
@@ -4057,7 +4086,20 @@ if(!useQGuiApplicationExec){
-
+
+
+ qsizetype* %out;
+ if constexpr(sizeof(int)==sizeof(qsizetype)){
+ %out = qtjambi_array_cast<qsizetype*>(%env, %scope, %in, 1);
+ }else{
+ if(int* tmp = qtjambi_array_cast<int*>(%env, %scope, %in, 1)){
+ %out = new qsizetype(*tmp);
+ %scope.addFinalAction([=]{*tmp = jint(*%out); delete %out;});
+ }else{
+ %out = nullptr;
+ }
+ }
+
@@ -4949,7 +4991,7 @@ if(!useQGuiApplicationExec){
-
+
@@ -5003,6 +5045,17 @@ if(!useQGuiApplicationExec){
+
+
+
+
+
+
+
+
+ QString %out = qtjambi_to_qstring(%env, %1);
+
+
@@ -5087,11 +5140,6 @@ if(!useQGuiApplicationExec){
-
-
-
-
-
diff --git a/generator/typesystem/xml/typesystem_gui-common.xml b/generator/typesystem/xml/typesystem_gui-common.xml
index 55daa67e..ba241606 100644
--- a/generator/typesystem/xml/typesystem_gui-common.xml
+++ b/generator/typesystem/xml/typesystem_gui-common.xml
@@ -270,6 +270,7 @@
+
diff --git a/generator/typesystem/xml/typesystem_gui-java.xml b/generator/typesystem/xml/typesystem_gui-java.xml
index c64f53fc..858dd6bc 100644
--- a/generator/typesystem/xml/typesystem_gui-java.xml
+++ b/generator/typesystem/xml/typesystem_gui-java.xml
@@ -5150,7 +5150,7 @@ __rcRedirections.remove(%1);
- jobject %out = %env->NewDirectByteBuffer(%in, __qt_this->size());
+ %out = %env->NewDirectByteBuffer(%in, __qt_this->size());
@@ -5158,7 +5158,7 @@ __rcRedirections.remove(%1);
- jobject %out = %env->NewDirectByteBuffer(%in, qMin(%2, __qt_this->size()-%1));
+ %out = %env->NewDirectByteBuffer(%in, qMin(%2, __qt_this->size()-%1));
@@ -5385,14 +5385,14 @@ __rcRedirections.remove(%1);
- jobject %out = qtjambi_from_qobject(%env, %in, "io/qt/widgets/QAction");
+ %out = qtjambi_from_qobject(%env, %in, "io/qt/widgets/QAction");
- jobject %out = qtjambi_from_qobject(%env, %in, "io/qt/widgets/QAction");
+ %out = qtjambi_from_qobject(%env, %in, "io/qt/widgets/QAction");
diff --git a/generator/typesystem/xml/typesystem_httpserver-common.xml b/generator/typesystem/xml/typesystem_httpserver-common.xml
index 00777292..1635ac89 100644
--- a/generator/typesystem/xml/typesystem_httpserver-common.xml
+++ b/generator/typesystem/xml/typesystem_httpserver-common.xml
@@ -46,6 +46,7 @@
+
@@ -59,17 +60,6 @@
-
-
-
-
-
-
-
-
-
-
-
@@ -84,11 +74,13 @@
+
-
+
-
+
diff --git a/generator/typesystem/xml/typesystem_httpserver-java.xml b/generator/typesystem/xml/typesystem_httpserver-java.xml
index 2ea7d22f..4a11926a 100644
--- a/generator/typesystem/xml/typesystem_httpserver-java.xml
+++ b/generator/typesystem/xml/typesystem_httpserver-java.xml
@@ -43,64 +43,6 @@
**
****************************************************************************-->
-
-
-template<> inline QHttpServerResponse qvariant_cast<QHttpServerResponse>(const QVariant &v)
-{
- QMetaType targetType = QMetaType::fromType<QHttpServerResponse>();
- if (v.d.type() == targetType)
- return QHttpServerResponse(const_cast<QHttpServerResponse&&>(v.d.get<QHttpServerResponse>()));
- QHttpServerResponse t(QHttpServerResponse::StatusCode::NotFound);
- QMetaType::convert(v.metaType(), v.constData(), targetType, &t);
- return t;
-}
-
-namespace QtJambiPrivate{
-template<>
-struct FutureVariantHandler<QHttpServerResponse>{
- static QVariant create(JNIEnv *env, const QHttpServerResponse& value){
- jobject _value = qtjambi_cast<jobject>(env, new QHttpServerResponse(std::move(const_cast<QHttpServerResponse&>(value))));
- qtjambi_set_java_ownership(env, _value);
- return QVariant::fromValue<JObjectWrapper>(JObjectWrapper(env, _value));
- }
- static void reportNativeResults(JNIEnv *env, const QSharedPointer<QFutureInterfaceBase>& sourceFuture, const QSharedPointer<QFutureInterfaceBase>& targetFuture, int beginIndex, int count){
- if(count==1){
- dynamic_cast<QFutureInterface<QVariant>*>(sourceFuture.get())->reportResult(create(env, targetFuture->resultStoreBase().resultAt(beginIndex).value<QHttpServerResponse>()), beginIndex);
- }else{
- QVector<QVariant> results(count);
- for(int i=0; i<count; ++i){
- results << create(env, targetFuture->resultStoreBase().resultAt(beginIndex).value<QHttpServerResponse>());
- }
- dynamic_cast<QFutureInterface<QVariant>*>(sourceFuture.get())->reportResults(results, count);
- }
- }
-
- static void reportJavaResults(JNIEnv *, const QSharedPointer<QFutureInterfaceBase>& sourceFuture, const QSharedPointer<QFutureInterfaceBase>&targetFuture, int beginIndex, int count){
- if(count==1){
- dynamic_cast<QFutureInterface<QHttpServerResponse>*>(targetFuture.get())->reportResult(sourceFuture->resultStoreBase().resultAt(beginIndex).value<QVariant>().value<QHttpServerResponse>(), beginIndex);
- }else{
- for(int i=0; i<count; ++i){
- dynamic_cast<QFutureInterface<QHttpServerResponse>*>(targetFuture.get())->reportResult(sourceFuture->resultStoreBase().resultAt(i).value<QVariant>().value<QHttpServerResponse>(), i);
- }
- }
- }
-};
-}
-
-
-
-
-
-
-
-
-
-
- QFuture<QHttpServerResponse> %out = qtjambi_cast<QFuture<QHttpServerResponse>>(%env, %in);
-
-
-
-
@@ -118,6 +60,26 @@ struct FutureVariantHandler<QHttpServerResponse>{
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -137,37 +99,6 @@ struct FutureVariantHandler<QHttpServerResponse>{
-
-
-
-
- QHash<QMetaType,QString> converters;
- for(std::pair<QMetaType,QLatin1StringView> m : %in.asKeyValueRange()){
- converters[m.first] = m.second;
- }
- %out = qtjambi_cast<jobject>(%env, converters);
-
-
-
-
-
-
-
- QByteArray* data = qtjambi_cast<QByteArray*>(%env, %in);
- QLatin1StringView %out = QLatin1StringView(data->data());
-
-
-
-
-
- converters.remove(metaType.id());
-
-
-
-
- converters.clear();
-
-
@@ -219,11 +150,6 @@ struct FutureVariantHandler<QHttpServerResponse>{
-
-
-
-
-
diff --git a/generator/typesystem/xml/typesystem_qml-common.xml b/generator/typesystem/xml/typesystem_qml-common.xml
index 829c752c..1fab8370 100644
--- a/generator/typesystem/xml/typesystem_qml-common.xml
+++ b/generator/typesystem/xml/typesystem_qml-common.xml
@@ -48,13 +48,11 @@
-
-
@@ -228,6 +226,7 @@
+
diff --git a/generator/typesystem/xml/typesystem_qml-java.xml b/generator/typesystem/xml/typesystem_qml-java.xml
index 54883cba..4ff4ac98 100644
--- a/generator/typesystem/xml/typesystem_qml-java.xml
+++ b/generator/typesystem/xml/typesystem_qml-java.xml
@@ -205,6 +205,17 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/generator/typesystem/xml/typesystem_quick-common.xml b/generator/typesystem/xml/typesystem_quick-common.xml
index 86930a58..8a5bd20a 100644
--- a/generator/typesystem/xml/typesystem_quick-common.xml
+++ b/generator/typesystem/xml/typesystem_quick-common.xml
@@ -77,6 +77,9 @@
+
+
+
@@ -142,6 +145,8 @@
+
+
@@ -747,12 +752,5 @@
-
-
-
-
-
-
-
diff --git a/generator/typesystem/xml/typesystem_quick-java.xml b/generator/typesystem/xml/typesystem_quick-java.xml
index 6b1846f2..6867014d 100644
--- a/generator/typesystem/xml/typesystem_quick-java.xml
+++ b/generator/typesystem/xml/typesystem_quick-java.xml
@@ -651,6 +651,9 @@
+
+
+
diff --git a/generator/typesystem/xml/typesystem_test-java.xml b/generator/typesystem/xml/typesystem_test-java.xml
index f1a91265..bcafeb94 100644
--- a/generator/typesystem/xml/typesystem_test-java.xml
+++ b/generator/typesystem/xml/typesystem_test-java.xml
@@ -376,6 +376,12 @@
%out = qtjambi_cast<jobject>(%env, variant_%in);
+#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
+ if(!QMetaType(%2).iface()->copyCtr
+ || (!%in && !QMetaType(%2).iface()->defaultCtr)){
+ JavaException::raiseUnsupportedOperationException(%env, qPrintable(QString("Unable to create result of type %1.").arg(QLatin1String(QMetaType::typeName(%2)))) QTJAMBI_STACKTRACEINFO );
+ }
+#endif
QVariant variant_%in(QMetaType(%2), %in);
%out = qtjambi_cast<jobject>(%env, variant_%in);
@@ -392,6 +398,12 @@
%out = qtjambi_cast<jobject>(%env, variant_%in);
+#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
+ if(!QMetaType(%2).iface()->copyCtr
+ || (!%in && !QMetaType(%2).iface()->defaultCtr)){
+ JavaException::raiseUnsupportedOperationException(%env, qPrintable(QString("Unable to create result of type %1.").arg(QLatin1String(QMetaType::typeName(%2)))) QTJAMBI_STACKTRACEINFO );
+ }
+#endif
QVariant variant_%in(QMetaType(%2), %in);
%out = qtjambi_cast<jobject>(%env, variant_%in);
@@ -408,6 +420,12 @@
%out = qtjambi_cast<jobject>(%env, variant_%in);
+#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
+ if(!QMetaType(%2).iface()->copyCtr
+ || (!%in && !QMetaType(%2).iface()->defaultCtr)){
+ JavaException::raiseUnsupportedOperationException(%env, qPrintable(QString("Unable to create result of type %1.").arg(QLatin1String(QMetaType::typeName(%2)))) QTJAMBI_STACKTRACEINFO );
+ }
+#endif
QVariant variant_%in(QMetaType(%2), %in);
%out = qtjambi_cast<jobject>(%env, variant_%in);
diff --git a/generator/typesystem/xml/typesystem_webengine-common.xml b/generator/typesystem/xml/typesystem_webengine-common.xml
index 7338ab10..82f0678d 100644
--- a/generator/typesystem/xml/typesystem_webengine-common.xml
+++ b/generator/typesystem/xml/typesystem_webengine-common.xml
@@ -72,6 +72,8 @@
+
+
diff --git a/generator/typesystem/xml/typesystem_webengine-java.xml b/generator/typesystem/xml/typesystem_webengine-java.xml
index 67178b3d..71507872 100644
--- a/generator/typesystem/xml/typesystem_webengine-java.xml
+++ b/generator/typesystem/xml/typesystem_webengine-java.xml
@@ -43,4 +43,32 @@
**
****************************************************************************-->
+
+
+
+
+
+ Q_UNUSED(in)
+ JavaException::raiseIllegalAccessException(%env, "Calling signal downloadRequested from Java not allowed." QTJAMBI_STACKTRACEINFO );
+ QQuickWebEngineDownloadItem* %out{nullptr};
+
+
+ %out = qtjambi_cast<jobject>(%env, reinterpret_cast<QObject*>(%in));
+
+
+
+
+
+
+
+ Q_UNUSED(in)
+ JavaException::raiseIllegalAccessException(%env, "Calling signal downloadFinished from Java not allowed." QTJAMBI_STACKTRACEINFO );
+ QQuickWebEngineDownloadItem* %out{nullptr};
+
+
+ %out = qtjambi_cast<jobject>(%env, reinterpret_cast<QObject*>(%in));
+
+
+
+
diff --git a/generator/typesystem/xml/typesystem_webenginecore-common.xml b/generator/typesystem/xml/typesystem_webenginecore-common.xml
index beaca4d3..d0975321 100644
--- a/generator/typesystem/xml/typesystem_webenginecore-common.xml
+++ b/generator/typesystem/xml/typesystem_webenginecore-common.xml
@@ -139,6 +139,7 @@
+
diff --git a/generator/typesystem/xml/typesystem_webenginequick-common.xml b/generator/typesystem/xml/typesystem_webenginequick-common.xml
index 53cb0b41..a25ca07f 100644
--- a/generator/typesystem/xml/typesystem_webenginequick-common.xml
+++ b/generator/typesystem/xml/typesystem_webenginequick-common.xml
@@ -66,6 +66,8 @@
+
+
diff --git a/generator/typesystem/xml/typesystem_webenginequick-java.xml b/generator/typesystem/xml/typesystem_webenginequick-java.xml
index 78f67e53..70b15c8b 100644
--- a/generator/typesystem/xml/typesystem_webenginequick-java.xml
+++ b/generator/typesystem/xml/typesystem_webenginequick-java.xml
@@ -43,4 +43,40 @@
**
****************************************************************************-->
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Q_UNUSED(in)
+ JavaException::raiseIllegalAccessException(%env, "Calling signal downloadRequested from Java not allowed." QTJAMBI_STACKTRACEINFO );
+ QQuickWebEngineDownloadRequest* %out{nullptr};
+
+
+ %out = qtjambi_cast<jobject>(%env, reinterpret_cast<QWebEngineDownloadRequest*>(%in));
+
+
+
+
+
+
+
+ Q_UNUSED(in)
+ JavaException::raiseIllegalAccessException(%env, "Calling signal downloadFinished from Java not allowed." QTJAMBI_STACKTRACEINFO );
+ QQuickWebEngineDownloadRequest* %out{nullptr};
+
+
+ %out = qtjambi_cast<jobject>(%env, reinterpret_cast<QWebEngineDownloadRequest*>(%in));
+
+
+
+
diff --git a/releases.properties b/releases.properties
index 360eadff..55411040 100644
--- a/releases.properties
+++ b/releases.properties
@@ -1,6 +1,6 @@
-5.15=8
+5.15=9
6.0=1
6.1=1
-6.2=6
-6.3=3
+6.2=7
+6.3=4
6.4=0
\ No newline at end of file
diff --git a/src/cpp/qtjambi/qnativepointer.cpp b/src/cpp/qtjambi/qnativepointer.cpp
index 0150556b..25c72c31 100644
--- a/src/cpp/qtjambi/qnativepointer.cpp
+++ b/src/cpp/qtjambi/qnativepointer.cpp
@@ -28,11 +28,6 @@
****************************************************************************/
#include
-#if QT_VERSION >= QT_VERSION_CHECK(6,4,0)
-# define QT_CORE_INLINE_SINCE(major, minor) inline
-# define QT_CORE_INLINE_IMPL_SINCE(major, minor) 1
-#endif
-
QT_WARNING_DISABLE_DEPRECATED
#include "qtjambi_core.h"
diff --git a/src/cpp/qtjambi/qtjambi_containers.cpp b/src/cpp/qtjambi/qtjambi_containers.cpp
index 52634999..dd418d7e 100644
--- a/src/cpp/qtjambi/qtjambi_containers.cpp
+++ b/src/cpp/qtjambi/qtjambi_containers.cpp
@@ -30,10 +30,6 @@
#include
#include
QT_WARNING_DISABLE_DEPRECATED
-#if QT_VERSION >= QT_VERSION_CHECK(6,4,0)
-# define QT_CORE_INLINE_SINCE(major, minor) inline
-# define QT_CORE_INLINE_IMPL_SINCE(major, minor) 1
-#endif
#include
diff --git a/src/cpp/qtjambi/qtjambi_core.cpp b/src/cpp/qtjambi/qtjambi_core.cpp
index f3d1e9a1..e54abbbe 100644
--- a/src/cpp/qtjambi/qtjambi_core.cpp
+++ b/src/cpp/qtjambi/qtjambi_core.cpp
@@ -37,10 +37,6 @@
#include
QT_WARNING_DISABLE_DEPRECATED
-#if QT_VERSION >= QT_VERSION_CHECK(6,4,0)
-# define QT_CORE_INLINE_SINCE(major, minor) inline
-# define QT_CORE_INLINE_IMPL_SINCE(major, minor) 1
-#endif
#include
@@ -489,6 +485,22 @@ jobject qtjambi_from_qvariant(JNIEnv *env, const QVariant &qt_variant)
return Java::Runtime::Long::valueOf(env, qt_variant.toLongLong());
case QMetaType::Bool:
return Java::Runtime::Boolean::valueOf(env, qt_variant.toBool());
+ case QMetaType::QStringList:
+ return qtjambi_cast(env, qt_variant.value());
+ case QMetaType::QByteArrayList:
+ return qtjambi_cast(env, qt_variant.value());
+ case QMetaType::QVariantMap:
+ return qtjambi_cast(env, qt_variant.value());
+ case QMetaType::QVariantHash:
+ return qtjambi_cast(env, qt_variant.value());
+ case QMetaType::QVariantList:
+ return qtjambi_cast(env, qt_variant.value());
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ case QMetaType::QVariantPair:
+ return qtjambi_cast(env, qt_variant.value());
+#endif
+ case QMetaType::QObjectStar:
+ return qtjambi_cast(env, qt_variant.value());
default:
break;
}
@@ -6842,51 +6854,46 @@ bool qtjambi_thread_affine_event_notify(void **data)
if(QObject *receiver = reinterpret_cast(data[0])){
QEvent *event = reinterpret_cast(data[1]);
{
- QThread *currentThread = QThread::currentThread();
- QThread *thr(nullptr);
if(const QObjectPrivate* p = QObjectPrivate::get(receiver)){
-#if QT_VERSION < QT_VERSION_CHECK(5,15,0)
- if(p->threadData)
- thr = p->threadData->thread;
-#else
- if(QThreadData* threadData = p->threadData.loadAcquire())
- thr = threadData->thread.loadAcquire();
-#endif
- }
- if(thr && currentThread != thr){
- QMetaEnum enm = QMetaEnum::fromType();
- QString eventDescr;
- if(enm.isValid()){
- eventDescr = QLatin1String(enm.valueToKeys(event->type()));
- }else{
- eventDescr = QString::number(int(event->type()));
- }
- if(QCoreApplicationPrivate::is_app_closing)
- return false;
- if (JNIEnv *env = qtjambi_current_environment()){
- QTJAMBI_JNI_LOCAL_FRAME(env, 200)
- QtJambiExceptionHandler __exceptionHandler;
- try{
- if (QSharedPointer link = QtJambiLink::findLinkForQObject(receiver)) {
- JavaException::raiseQThreadAffinityException(env, qPrintable(QString::asprintf("Cannot send events to objects owned by a different thread (event type: %ls). "
- "Current thread 0x%p. Receiver '%ls' (of type '%s') was created in thread 0x%p",
- qUtf16Printable(eventDescr),
- currentThread, qUtf16Printable(receiver->objectName()),
- receiver->metaObject()->className(), thr)) QTJAMBI_STACKTRACEINFO ,
- link->getJavaObjectLocalRef(env),
- nullptr, nullptr);
- }else{
- JavaException::raiseQThreadAffinityException(env, qPrintable(QString::asprintf("Cannot send events to objects owned by a different thread (event type: %ls). "
- "Current thread 0x%p. Receiver '%ls' (of type '%s') was created in thread 0x%p",
- qUtf16Printable(eventDescr),
- currentThread, qUtf16Printable(receiver->objectName()),
- receiver->metaObject()->className(), thr)) QTJAMBI_STACKTRACEINFO ,
- nullptr, nullptr, nullptr);
+ QThreadData *thr = p->threadData;
+ QScopedScopeLevelCounter scopeLevelCounter(thr);
+ QThreadData *currentThread = QThreadData::get2(QThread::currentThread());
+ QScopedScopeLevelCounter cscopeLevelCounter(currentThread);
+ if(thr && thr->threadId!=nullptr && currentThread != thr){
+ QMetaEnum enm = QMetaEnum::fromType();
+ QString eventDescr;
+ if(enm.isValid()){
+ eventDescr = QLatin1String(enm.valueToKeys(event->type()));
+ }else{
+ eventDescr = QString::number(int(event->type()));
+ }
+ if(QCoreApplicationPrivate::is_app_closing)
+ return false;
+ if (JNIEnv *env = qtjambi_current_environment()){
+ QTJAMBI_JNI_LOCAL_FRAME(env, 200)
+ QtJambiExceptionHandler __exceptionHandler;
+ try{
+ if (QSharedPointer link = QtJambiLink::findLinkForQObject(receiver)) {
+ JavaException::raiseQThreadAffinityException(env, qPrintable(QString::asprintf("Cannot send events to objects owned by a different thread (event type: %ls). "
+ "Current thread 0x%p. Receiver '%ls' (of type '%s') was created in thread 0x%p",
+ qUtf16Printable(eventDescr),
+ currentThread, qUtf16Printable(receiver->objectName()),
+ receiver->metaObject()->className(), thr)) QTJAMBI_STACKTRACEINFO ,
+ link->getJavaObjectLocalRef(env),
+ nullptr, nullptr);
+ }else{
+ JavaException::raiseQThreadAffinityException(env, qPrintable(QString::asprintf("Cannot send events to objects owned by a different thread (event type: %ls). "
+ "Current thread 0x%p. Receiver '%ls' (of type '%s') was created in thread 0x%p",
+ qUtf16Printable(eventDescr),
+ currentThread, qUtf16Printable(receiver->objectName()),
+ receiver->metaObject()->className(), thr)) QTJAMBI_STACKTRACEINFO ,
+ nullptr, nullptr, nullptr);
+ }
+ }catch(const JavaException& exn){
+ __exceptionHandler.handle(nullptr, exn, "QCoreApplication::sendEvent");
}
- }catch(const JavaException& exn){
- __exceptionHandler.handle(nullptr, exn, "QCoreApplication::sendEvent");
+ return true;
}
- return true;
}
}
}
diff --git a/src/cpp/qtjambi/qtjambi_functions.cpp b/src/cpp/qtjambi/qtjambi_functions.cpp
index 3bfec74e..c341d7ad 100644
--- a/src/cpp/qtjambi/qtjambi_functions.cpp
+++ b/src/cpp/qtjambi/qtjambi_functions.cpp
@@ -36,10 +36,11 @@
****************************************************************************/
#include
+
#if QT_VERSION >= QT_VERSION_CHECK(6,4,0)
-# define QT_CORE_INLINE_SINCE(major, minor) inline
-# define QT_CORE_INLINE_IMPL_SINCE(major, minor) 1
+#include
#endif
+
#include "qtjambi_functionpointer.h"
QT_WARNING_DISABLE_DEPRECATED
@@ -223,9 +224,11 @@ QTJAMBI_FUNCTION_PREFIX(Java_io_qt_internal_QtJambiSignals_signalInfo)
QByteArray signalName = qtjambi_cast(env, Java::Runtime::Field::getName(env, field)).toUtf8();
const QMetaObject* containingObjectClass = object->metaObject();
QMap matchingSignals;
- for(int i=0, length = containingObjectClass->methodCount(); imethodOffset(), length = containingObjectClass->methodCount(); imethod(i);
- if(method.methodType()==QMetaMethod::Signal && signalName==method.name()){
+ if(method.methodType()==QMetaMethod::Signal
+ && signalName==method.name()
+ && !matchingSignals.contains(method.methodSignature())){
matchingSignals[method.methodSignature()] = method;
}
}
@@ -288,37 +291,6 @@ QTJAMBI_FUNCTION_PREFIX(Java_io_qt_internal_QtJambiInternal_isObjectWrapperType)
|| metaTypeId == registeredMetaTypeID(typeid(JIteratorWrapper));
}
-#if QT_VERSION >= QT_VERSION_CHECK(6,4,0)
-struct QObjectPrivate::ConnectionData
-{
- // the id below is used to avoid activating new connections. When the object gets
- // deleted it's set to 0, so that signal emission stops
- QAtomicInteger currentConnectionId;
- QAtomicInt ref;
- QAtomicPointer signalVector;
- Connection *senders = nullptr;
- Sender *currentSender = nullptr; // object currently activating the object
- QAtomicPointer orphaned;
-};
-
-struct QObjectPrivate::Sender
-{
- Sender(QObject *receiver, QObject *sender, int signal)
- : receiver(receiver), sender(sender), signal(signal)
- {
- if (receiver) {
- ConnectionData *cd = receiver->d_func()->connections.loadRelaxed();
- previous = cd->currentSender;
- cd->currentSender = this;
- }
- }
- Sender *previous;
- QObject *receiver;
- QObject *sender;
- int signal;
-};
-#endif
-
extern "C" Q_DECL_EXPORT jlong JNICALL
QTJAMBI_FUNCTION_PREFIX(Java_io_qt_internal_QtJambiSignals_00024CurrentSenderSetter_setQObjectSender)
(JNIEnv * env, jobject, QtJambiNativeID r, QtJambiNativeID s)
@@ -1698,6 +1670,11 @@ QTJAMBI_FUNCTION_PREFIX(Java_io_qt_internal_QtJambiInternal__1_1qt_1createMetaTy
}
if(copy){
if(QSharedPointer link = QtJambiLink::findLinkForJavaInterface(env, copy)){
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
+ if(!QMetaType(id).iface()->copyCtr){
+ JavaException::raiseUnsupportedOperationException(env, qPrintable(QString("Unable to create value of meta type %1 due to missing copy constructor.").arg(QLatin1String(QMetaType::typeName(id)))) QTJAMBI_STACKTRACEINFO );
+ }
+#endif
QVariant variant(QTJAMBI_METATYPE(id), link->pointer());
return qtjambi_from_qvariant(env, variant);
}else{
@@ -1715,6 +1692,11 @@ QTJAMBI_FUNCTION_PREFIX(Java_io_qt_internal_QtJambiInternal__1_1qt_1createMetaTy
}
}
}
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
+ if(!QMetaType(id).iface()->defaultCtr){
+ JavaException::raiseUnsupportedOperationException(env, qPrintable(QString("Unable to create value of meta type %1 due to missing default constructor.").arg(QLatin1String(QMetaType::typeName(id)))) QTJAMBI_STACKTRACEINFO );
+ }
+#endif
QVariant variant(QTJAMBI_METATYPE(id), nullptr);
return qtjambi_from_qvariant(env, variant);
}catch(const JavaException& exn){
@@ -2194,17 +2176,19 @@ QTJAMBI_FUNCTION_PREFIX(Java_io_qt_internal_QtJambiInternal_monitorExit)
}
extern "C" Q_DECL_EXPORT jobject JNICALL
-QTJAMBI_FUNCTION_PREFIX(Java_io_qt_internal_QtJambiInternal_getListOfExtraSignal)
- (JNIEnv *env, jclass, QtJambiNativeID sender__id)
+QTJAMBI_FUNCTION_PREFIX(Java_io_qt_internal_QtJambiInternal_getExtraSignal)
+ (JNIEnv *env, jclass, QtJambiNativeID sender__id, QtJambiNativeID method__id)
{
try{
if(QSharedPointer sender = QtJambiLink::fromNativeId(sender__id)){
- if(sender->isSharedPointer()){
- QSharedPointerToQObjectLink* slink = static_cast(sender.data());
- return slink->getListOfExtraSignal(env);
- }else{
- PointerToQObjectLink* plink = static_cast(sender.data());
- return plink->getListOfExtraSignal(env);
+ if(const QMetaMethod *method = qtjambi_object_from_nativeId(method__id)){
+ if(sender->isSharedPointer()){
+ QSharedPointerToQObjectLink* slink = static_cast(sender.data());
+ return slink->getExtraSignal(env, *method);
+ }else{
+ PointerToQObjectLink* plink = static_cast(sender.data());
+ return plink->getExtraSignal(env, *method);
+ }
}
}
}catch(const JavaException& exn){
@@ -2571,20 +2555,28 @@ qint64 QJarEntryEngine::size() const{
}
qint64 QJarEntryEngine::read(char *data, qint64 maxlen) {
+ qint64 readBytes = 0;
if(m_stream){
if(JNIEnv* env = qtjambi_current_environment()){
QTJAMBI_JNI_LOCAL_FRAME(env, 600)
try{
- QtJambiScope __qtjambi_scope;
- jbyteArray _data = qtjambi_array_cast(env, __qtjambi_scope, data, jsize(qMin(qint64(INT_MAX), maxlen)));
- return Java::Runtime::InputStream::read(env, m_stream.object(), _data);
+ while(readBytes(env, __qtjambi_scope, data+readBytes, jsize(qMin(qint64(INT_MAX), maxlen-readBytes)));
+ jint r = Java::Runtime::InputStream::read(env, m_stream.object(), _data);
+ if(r<=0)
+ break;
+ readBytes += r;
+ }
}catch(const JavaException& exn){
exn.report(env);
- return 0;
}
}
}
- return 0;
+ if(readBytes==0)
+ return -1;
+ m_pos += readBytes;
+ return readBytes;
}
bool QJarEntryEngine::reset() {
@@ -2607,7 +2599,24 @@ bool QJarEntryEngine::reopen() {
bool QJarEntryEngine::seek(qint64 offset) {
if(offset < 0)
return false;
+ if(m_pos < offset) {
+ if(JNIEnv* env = qtjambi_current_environment()){
+ QTJAMBI_JNI_LOCAL_FRAME(env, 600)
+ while (m_pos < offset) {
+ qint64 skipBytesRemaining = qMin(offset - m_pos, qint64(std::numeric_limits::max));
+
+ // InputStream#skip(long) may not skip all the requested bytes in a single invocation
+ qint64 skipBytesActual = Java::Runtime::InputStream::skip(env, m_stream.object(), skipBytesRemaining);
+ if(skipBytesActual > 0)
+ m_pos += skipBytesActual; // The actual number of bytes skipped
+ else
+ break;
+ }
+ }
+ }
+ if(m_pos == offset)
+ return true;
if (!open(m_openMode)) // open() will automatically force a close()
return false;
if (offset < m_pos) {
@@ -2615,21 +2624,23 @@ bool QJarEntryEngine::seek(qint64 offset) {
return false;
}
- if(JNIEnv* env = qtjambi_current_environment()){
- QTJAMBI_JNI_LOCAL_FRAME(env, 600)
- while (m_pos < offset) {
- qint64 skipBytesRemaining = qMin(offset - m_pos, qint64(std::numeric_limits::max));
-
- // InputStream#skip(long) may not skip all the requested bytes in a single invocation
- qint64 skipBytesActual = Java::Runtime::InputStream::skip(env, m_stream.object(), skipBytesRemaining);
- if(skipBytesActual > 0)
- m_pos += skipBytesActual; // The actual number of bytes skipped
- else
- return false;
- }
- return true;
+ if(m_pos < offset) {
+ if(JNIEnv* env = qtjambi_current_environment()){
+ QTJAMBI_JNI_LOCAL_FRAME(env, 600)
+ while (m_pos < offset) {
+ qint64 skipBytesRemaining = qMin(offset - m_pos, qint64(std::numeric_limits::max));
+
+ // InputStream#skip(long) may not skip all the requested bytes in a single invocation
+ qint64 skipBytesActual = Java::Runtime::InputStream::skip(env, m_stream.object(), skipBytesRemaining);
+ if(skipBytesActual > 0)
+ m_pos += skipBytesActual; // The actual number of bytes skipped
+ else
+ return false;
+ }
+ return true;
+ }else return false;
}
- return false;
+ return true;
}
#ifdef Q_OS_ANDROID
diff --git a/src/cpp/qtjambi/qtjambi_future.cpp b/src/cpp/qtjambi/qtjambi_future.cpp
index 72ab06f3..52830c8d 100644
--- a/src/cpp/qtjambi/qtjambi_future.cpp
+++ b/src/cpp/qtjambi/qtjambi_future.cpp
@@ -41,39 +41,6 @@ FutureCallOut::FutureCallOut(QSharedPointer&& sourceFuture
m_resultRetranslator(resultRetranslator),
m_reverseFutureCallOut(this) {}
-#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
-#define CREATE_CALLOUT_EVENT(X) QFutureCallOutEvent(X)
-#define CREATE_CALLOUT_EVENT3(X,Y,Z) QFutureCallOutEvent(X,Y,Z)
-#else
-struct FutureCallOutEvent : public QEvent{
- explicit FutureCallOutEvent(QFutureCallOutEvent::CallOutType callOutType, int index1 = -1)
- : QEvent(QEvent::FutureCallOut), callOutType(callOutType), index1(index1), index2(-1)
- { }
- FutureCallOutEvent(QFutureCallOutEvent::CallOutType callOutType, int index1, int index2)
- : QEvent(QEvent::FutureCallOut), callOutType(callOutType), index1(index1), index2(index2)
- { }
-
- FutureCallOutEvent(QFutureCallOutEvent::CallOutType callOutType, int index1, const QString &text)
- : QEvent(QEvent::FutureCallOut),
- callOutType(callOutType),
- index1(index1),
- index2(-1),
- text(text)
- { }
-
- static const QFutureCallOutEvent& convert(const FutureCallOutEvent& evt){
- return reinterpret_cast(evt);
- }
-
- QFutureCallOutEvent::CallOutType callOutType;
- int index1;
- int index2;
- QString text;
-};
-#define CREATE_CALLOUT_EVENT(X) FutureCallOutEvent::convert(FutureCallOutEvent(X))
-#define CREATE_CALLOUT_EVENT3(X,Y,Z) FutureCallOutEvent::convert(FutureCallOutEvent(X,Y,Z))
-#endif
-
void FutureCallOut::initialize()
{
Q_ASSERT(!m_sourceFuture.isNull());
@@ -93,7 +60,7 @@ void FutureCallOut::initialize()
const auto currentState = m_sourceFuture->d->state.loadRelaxed();
try{
if (currentState & QFutureInterfaceBase::Started) {
- postCallOutEvent(CREATE_CALLOUT_EVENT(QFutureCallOutEvent::Started));
+ postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Started));
#if QT_VERSION < QT_VERSION_CHECK(6, 3, 0)
postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::ProgressRange,
m_sourceFuture->d->m_progressMinimum,
@@ -103,14 +70,14 @@ void FutureCallOut::initialize()
m_sourceFuture->d->m_progressText));
#else
if(m_sourceFuture->d->m_progress){
- postCallOutEvent(CREATE_CALLOUT_EVENT3(QFutureCallOutEvent::ProgressRange,
+ postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::ProgressRange,
m_sourceFuture->d->m_progress->minimum,
m_sourceFuture->d->m_progress->maximum));
- postCallOutEvent(CREATE_CALLOUT_EVENT3(QFutureCallOutEvent::Progress,
+ postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Progress,
m_sourceFuture->d->m_progressValue,
m_sourceFuture->d->m_progress->text));
}else{
- postCallOutEvent(CREATE_CALLOUT_EVENT3(QFutureCallOutEvent::Progress,
+ postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Progress,
m_sourceFuture->d->m_progressValue,
QString()));
}
@@ -136,7 +103,7 @@ void FutureCallOut::initialize()
while (it != m_sourceFuture->d->data.m_results.end()) {
const int begin = it.resultIndex();
const int end = begin + it.batchSize();
- postCallOutEvent(CREATE_CALLOUT_EVENT3(QFutureCallOutEvent::ResultsReady,
+ postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::ResultsReady,
begin,
end));
@@ -150,19 +117,19 @@ void FutureCallOut::initialize()
postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Paused));
#else
if (currentState & QFutureInterfaceBase::Suspended)
- postCallOutEvent(CREATE_CALLOUT_EVENT(QFutureCallOutEvent::Suspended));
+ postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Suspended));
else if (currentState & QFutureInterfaceBase::Suspending)
- postCallOutEvent(CREATE_CALLOUT_EVENT(QFutureCallOutEvent::Suspending));
+ postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Suspending));
#endif
if (currentState & QFutureInterfaceBase::Canceled)
- postCallOutEvent(CREATE_CALLOUT_EVENT(QFutureCallOutEvent::Canceled));
+ postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Canceled));
}catch(...){
delete this;
throw;
}
if (currentState & QFutureInterfaceBase::Finished){
- postCallOutEvent(CREATE_CALLOUT_EVENT(QFutureCallOutEvent::Finished));
+ postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Finished));
}else{
m_sourceFuture->d->outputConnections.append(this);
QMutexLocker locker2(&m_targetFuture->d->m_mutex);
diff --git a/src/cpp/qtjambi/qtjambi_plugin.cpp b/src/cpp/qtjambi/qtjambi_plugin.cpp
index 02833e28..f366a97b 100644
--- a/src/cpp/qtjambi/qtjambi_plugin.cpp
+++ b/src/cpp/qtjambi/qtjambi_plugin.cpp
@@ -1,8 +1,4 @@
#include
-#if QT_VERSION >= QT_VERSION_CHECK(6,4,0)
-# define QT_CORE_INLINE_SINCE(major, minor) inline
-# define QT_CORE_INLINE_IMPL_SINCE(major, minor) 1
-#endif
#include
#include
#include
diff --git a/src/cpp/qtjambi/qtjambi_registry.cpp b/src/cpp/qtjambi/qtjambi_registry.cpp
index ed044169..835356c7 100644
--- a/src/cpp/qtjambi/qtjambi_registry.cpp
+++ b/src/cpp/qtjambi/qtjambi_registry.cpp
@@ -110,6 +110,8 @@ Q_GLOBAL_STATIC(MetaObjectHash, gOriginalMetaObjectHash)
Q_GLOBAL_STATIC(MetaObjectHash, gHasCustomMetaObjectHash)
typedef QHash > SignalMetaInfoHash;
Q_GLOBAL_STATIC(SignalMetaInfoHash, gSignalMetaInfos)
+typedef QHash > ExtraSignalsOfMetaObjectHash;
+Q_GLOBAL_STATIC(ExtraSignalsOfMetaObjectHash, gExtraSignalsOfMetaObject)
typedef QHash TypeIdsByMetaObjectHash;
Q_GLOBAL_STATIC(TypeIdsByMetaObjectHash, gTypeIdsByMetaObject)
typedef QHash QMetaMethodRenamerByMetaObjectHash;
@@ -1694,6 +1696,44 @@ const QVector* signalMetaInfos(const QMetaObject* metaObje
}
}
+QList getExtraSignalsOfMetaObject(const QMetaObject* metaObject){
+ {
+ QReadLocker lock(gLock());
+ if(gExtraSignalsOfMetaObject->contains(metaObject))
+ return gExtraSignalsOfMetaObject->value(metaObject);
+ }
+ QList extraSignals;
+ QSet availableSignalInfos;
+ {
+ const QMetaObject* currentMetaObject = metaObject;
+ do{
+ if(const QVector* infos = signalMetaInfos(currentMetaObject)){
+ for(const SignalMetaInfo& info : *infos){
+ availableSignalInfos.insert(info.signal_method_index_provider());
+ }
+ }
+ currentMetaObject = currentMetaObject->superClass();
+ }while(currentMetaObject);
+ }
+ const int methodCount = metaObject->methodCount();
+ for(int i=0; imethod(i);
+ if(method.isValid()
+ && method.methodType()==QMetaMethod::Signal
+ && !availableSignalInfos.contains(method.methodIndex())
+ && !QtJambiMetaObject::isInstance(method.enclosingMetaObject())){
+ extraSignals << method;
+ }
+ }
+ {
+ QWriteLocker lock(gLock());
+ if(gExtraSignalsOfMetaObject->contains(metaObject))
+ return gExtraSignalsOfMetaObject->value(metaObject);
+ gExtraSignalsOfMetaObject->insert(metaObject, extraSignals);
+ }
+ return extraSignals;
+}
+
ParameterInfoProvider registeredParameterInfoProvider(const QMetaObject* metaObject)
{
QReadLocker locker(gLock());
@@ -2446,6 +2486,12 @@ void clear_registry_at_shutdown(JNIEnv * env){
if(!gFieldHash.isDestroyed())
gFieldHash->clear();
}
+ {
+ QWriteLocker locker(gLock());
+ Q_UNUSED(locker)
+ if(!gExtraSignalsOfMetaObject.isDestroyed())
+ gExtraSignalsOfMetaObject->clear();
+ }
if(env){
#ifdef QTJAMBI_LOG_CLASSNAMES
printf("DeleteGlobalRef of %i classes:\n", classIdHash.keys().size());
diff --git a/src/cpp/qtjambi/qtjambi_registry_p.h b/src/cpp/qtjambi/qtjambi_registry_p.h
index 8ad8919d..b410e4bf 100644
--- a/src/cpp/qtjambi/qtjambi_registry_p.h
+++ b/src/cpp/qtjambi/qtjambi_registry_p.h
@@ -80,6 +80,7 @@ const std::type_info* getTypeByMetaObject(const QMetaObject* metaObject);
int registeredMetaTypeID(const std::type_info& typeId);
int registeredInterfaceOffset(const std::type_info& qt_base, const std::type_info& qt_interface);
const QVector* signalMetaInfos(const QMetaObject* metaObject);
+QList getExtraSignalsOfMetaObject(const QMetaObject* metaObject);
ParameterInfoProvider registeredParameterInfoProvider(const QMetaObject* metaObject);
bool isValueOwner(const QMetaObject* metaObject);
const std::type_info* getTypeByMetaType(int metaType);
diff --git a/src/cpp/qtjambi/qtjambi_thread.cpp b/src/cpp/qtjambi/qtjambi_thread.cpp
index 54238840..440aed79 100644
--- a/src/cpp/qtjambi/qtjambi_thread.cpp
+++ b/src/cpp/qtjambi/qtjambi_thread.cpp
@@ -35,10 +35,6 @@
****************************************************************************/
#include
-#if QT_VERSION >= QT_VERSION_CHECK(6,4,0)
-# define QT_CORE_INLINE_SINCE(major, minor) inline
-# define QT_CORE_INLINE_IMPL_SINCE(major, minor) 1
-#endif
QT_WARNING_DISABLE_DEPRECATED
diff --git a/src/cpp/qtjambi/qtjambi_typeinfo.cpp b/src/cpp/qtjambi/qtjambi_typeinfo.cpp
index f6c938c8..3ca361d6 100644
--- a/src/cpp/qtjambi/qtjambi_typeinfo.cpp
+++ b/src/cpp/qtjambi/qtjambi_typeinfo.cpp
@@ -29,10 +29,6 @@
#include
QT_WARNING_DISABLE_DEPRECATED
-#if QT_VERSION >= QT_VERSION_CHECK(6,4,0)
-# define QT_CORE_INLINE_SINCE(major, minor) inline
-# define QT_CORE_INLINE_IMPL_SINCE(major, minor) 1
-#endif
#include
#include
diff --git a/src/cpp/qtjambi/qtjambilink.cpp b/src/cpp/qtjambi/qtjambilink.cpp
index e0619c79..db8400cd 100644
--- a/src/cpp/qtjambi/qtjambilink.cpp
+++ b/src/cpp/qtjambi/qtjambilink.cpp
@@ -36,10 +36,6 @@
****************************************************************************/
#include
-#if QT_VERSION >= QT_VERSION_CHECK(6,4,0)
-# define QT_CORE_INLINE_SINCE(major, minor) inline
-# define QT_CORE_INLINE_IMPL_SINCE(major, minor) 1
-#endif
QT_WARNING_DISABLE_DEPRECATED
#include "qtjambi_core.h"
@@ -429,44 +425,6 @@ jobject getNativeLink(JNIEnv *env, jobject java){
return nativeLink;
}
-QList extra_signals(const QMetaObject* metaObject){
- QList extraSignals;
- if (!QtJambiMetaObject::isInstance(metaObject)){
- const QMetaObject* knownMetaObject = metaObject;
- {
- const QVector *infos = nullptr;
- do{
- infos = signalMetaInfos(knownMetaObject);
- if(infos!=nullptr)
- break;
- knownMetaObject = knownMetaObject->superClass();
- }while(knownMetaObject);
- if(infos==nullptr){
- knownMetaObject = metaObject;
- }
- }
-
- if(knownMetaObject != metaObject){
- QSet knownMetaObjects;
- {
- const QMetaObject* parentMetaObject = knownMetaObject;
- do{
- knownMetaObjects.insert(parentMetaObject);
- parentMetaObject = parentMetaObject->superClass();
- }while(parentMetaObject);
- }
- const int methodCount = metaObject->methodCount();
- for(int i=0; imethod(i);
- if(method.isValid() && !knownMetaObjects.contains(method.enclosingMetaObject()) && method.methodType()==QMetaMethod::Signal){
- extraSignals << method;
- }
- }
- }
- }
- return extraSignals;
-}
-
const QSharedPointer& QtJambiLink::createLinkForQObject(JNIEnv *env, jobject javaObject, QObject *object, bool created_by_java, bool is_shell, const QMetaObject* superTypeForCustomMetaObject)
{
QTJAMBI_DEBUG_METHOD_PRINT("native", "QtJambiLink::createLinkForQObject(JNIEnv *env, jobject java, QObject *object, bool created_by_java, bool hasCustomMetaObject)")
@@ -487,17 +445,17 @@ const QSharedPointer& QtJambiLink::createLinkForQObject(JNIEnv *env
}
}else{
const QMetaObject* metaObject = object->metaObject();
- QList extraSignals = extra_signals(metaObject);
+ QList extraSignals = getExtraSignalsOfMetaObject(metaObject);
if(interfaceOffsets && !interfaceOffsets->offsets.isEmpty()){
if(extraSignals.isEmpty())
qtJambiLink = new PointerToQObjectInterfaceLink(env, nativeLink, javaObject, interfaceOffsets->offsets, interfaceOffsets->interfaces, interfaceOffsets->inheritedInterfaces, metaObject, object, created_by_java, false, is_shell, ocurredException);
else
- qtJambiLink = new PointerToQObjectInterfaceWithExtraSignalsLink(env, nativeLink, javaObject, interfaceOffsets->offsets, interfaceOffsets->interfaces, interfaceOffsets->inheritedInterfaces, metaObject, object, created_by_java, false, is_shell, extraSignals, ocurredException);
+ qtJambiLink = new PointerToQObjectInterfaceWithExtraSignalsLink(env, nativeLink, javaObject, interfaceOffsets->offsets, interfaceOffsets->interfaces, interfaceOffsets->inheritedInterfaces, metaObject, object, created_by_java, false, is_shell, ocurredException);
}else{
if(extraSignals.isEmpty())
qtJambiLink = new PointerToQObjectLink(env, nativeLink, javaObject, metaObject, object, created_by_java, false, is_shell, ocurredException);
else
- qtJambiLink = new PointerToQObjectWithExtraSignalsLink(env, nativeLink, javaObject, metaObject, object, created_by_java, false, is_shell, extraSignals, ocurredException);
+ qtJambiLink = new PointerToQObjectWithExtraSignalsLink(env, nativeLink, javaObject, metaObject, object, created_by_java, false, is_shell, ocurredException);
}
}
if(ocurredException.object()){
@@ -530,18 +488,18 @@ const QSharedPointer& QtJambiLink::createLinkForNewQObject(JNIEnv *
qtJambiLink = new PointerToPendingQObjectLink(env, nativeLink, javaObject, metaObject, object, created_by_java, isDeclarativeCall, is_shell, ocurredException);
}
}else{
- QList extraSignals = extra_signals(metaObject);
+ QList extraSignals = getExtraSignalsOfMetaObject(metaObject);
if(interfaceOffsets && !interfaceOffsets->offsets.isEmpty()){
if(extraSignals.isEmpty()){
qtJambiLink = new PointerToQObjectInterfaceLink(env, nativeLink, javaObject, interfaceOffsets->offsets, interfaceOffsets->interfaces, interfaceOffsets->inheritedInterfaces, metaObject, object, created_by_java, isDeclarativeCall, is_shell, ocurredException);
}else{
- qtJambiLink = new PointerToQObjectInterfaceWithExtraSignalsLink(env, nativeLink, javaObject, interfaceOffsets->offsets, interfaceOffsets->interfaces, interfaceOffsets->inheritedInterfaces, metaObject, object, created_by_java, isDeclarativeCall, is_shell, extraSignals, ocurredException);
+ qtJambiLink = new PointerToQObjectInterfaceWithExtraSignalsLink(env, nativeLink, javaObject, interfaceOffsets->offsets, interfaceOffsets->interfaces, interfaceOffsets->inheritedInterfaces, metaObject, object, created_by_java, isDeclarativeCall, is_shell, ocurredException);
}
}else{
if(extraSignals.isEmpty()){
qtJambiLink = new PointerToQObjectLink(env, nativeLink, javaObject, metaObject, object, created_by_java, isDeclarativeCall, is_shell, ocurredException);
}else{
- qtJambiLink = new PointerToQObjectWithExtraSignalsLink(env, nativeLink, javaObject, metaObject, object, created_by_java, isDeclarativeCall, is_shell, extraSignals, ocurredException);
+ qtJambiLink = new PointerToQObjectWithExtraSignalsLink(env, nativeLink, javaObject, metaObject, object, created_by_java, isDeclarativeCall, is_shell, ocurredException);
}
}
}
@@ -2462,11 +2420,10 @@ void DeletablePointerToObjectLink::deleteNativeObject(JNIEnv *env, bool forced)
// ### BEGIN ################### PointerToQObjectLink ###################### BEGIN ####
void qtjambi_resolve_signals(JNIEnv *env, jobject java_object, const QMetaObject* metaObject, JavaException& ocurredException);
-const QHash qtjambi_resolve_extra_signals(JNIEnv *env, jobject java_object, const QList& extraSignals, JavaException& ocurredException);
+JObjectWrapper qtjambi_resolve_extra_signal(JNIEnv *env, jobject java_object, const QMetaMethod& method);
-PointerToQObjectWithExtraSignalsLink::PointerToQObjectWithExtraSignalsLink(JNIEnv *env, jobject nativeLink, jobject jobj, const QMetaObject* metaObject, QObject *object, bool created_by_java, bool isDeclarativeCall, bool is_shell, const QList& extraSignals, JavaException& ocurredException)
- : PointerToQObjectLink(env, nativeLink, jobj, metaObject, object, created_by_java, isDeclarativeCall, is_shell, ocurredException),
- m_extraSignals(qtjambi_resolve_extra_signals(env, jobj, extraSignals, ocurredException))
+PointerToQObjectWithExtraSignalsLink::PointerToQObjectWithExtraSignalsLink(JNIEnv *env, jobject nativeLink, jobject jobj, const QMetaObject* metaObject, QObject *object, bool created_by_java, bool isDeclarativeCall, bool is_shell, JavaException& ocurredException)
+ : PointerToQObjectLink(env, nativeLink, jobj, metaObject, object, created_by_java, isDeclarativeCall, is_shell, ocurredException)
{
}
@@ -3006,11 +2963,11 @@ QSharedPointerToQObjectLink::QSharedPointerToQObjectLink(JNIEnv *env, jobject na
if(superTypeForCustomMetaObject){
m_pointerContainer = new PointerContainerWithPendingExtraSignals(env, local, superTypeForCustomMetaObject, this->getStrongPointer(), ptr_shared_pointer, isShell(), shared_pointer_deleter, pointerGetter, ocurredException);
}else{
- QList extraSignals = extra_signals(metaObject);
+ QList extraSignals = getExtraSignalsOfMetaObject(metaObject);
if(extraSignals.isEmpty())
m_pointerContainer = new PointerContainer(env, local, metaObject, this->getStrongPointer(), ptr_shared_pointer, isShell(), shared_pointer_deleter, pointerGetter, ocurredException);
else
- m_pointerContainer = new PointerContainerWithExtraSignals(env, local, metaObject, this->getStrongPointer(), ptr_shared_pointer, isShell(), shared_pointer_deleter, pointerGetter, extraSignals, ocurredException);
+ m_pointerContainer = new PointerContainerWithExtraSignals(env, local, metaObject, this->getStrongPointer(), ptr_shared_pointer, isShell(), shared_pointer_deleter, pointerGetter, ocurredException);
}
}
if(!ocurredException.object()){
@@ -3219,23 +3176,8 @@ bool QSharedPointerToObjectLink::isQObject() const {
return false;
}
-jobject PointerToQObjectLink::getListOfExtraSignal(JNIEnv * env) const{
- return qtjambi_arraylist_new(env, 0);
-}
-
-void PointerToPendingQObjectLink::resolveListOfExtraSignal(JNIEnv * env) const{
- JavaException ocurredException;
- if(jobject jobj = getJavaObjectLocalRef(env)){
- if(QObject* object = qobject()){
- m_metaObject = object->metaObject();
- QList extraSignals = extra_signals(m_metaObject);
- m_extraSignals = qtjambi_resolve_extra_signals(env, jobj, extraSignals, ocurredException);
- env->DeleteLocalRef(jobj);
- }
- }
- const_cast(this)->m_flags.setFlag(Flag::IsPendingObjectResolved);
- if(ocurredException.object())
- ocurredException.raise();
+jobject PointerToQObjectLink::getExtraSignal(JNIEnv*, const QMetaMethod&) const{
+ return nullptr;
}
PointerToPendingQObjectLink::PointerToPendingQObjectLink(JNIEnv *env, jobject nativeLink, jobject jobj, const QMetaObject* metaObject, QObject *ptr, bool created_by_java, bool isDeclarativeCall, bool is_shell, JavaException& ocurredException)
@@ -3277,19 +3219,25 @@ void PointerToPendingQObjectLink::init(JNIEnv* env){
}
}
-jobject PointerToPendingQObjectLink::getListOfExtraSignal(JNIEnv * env) const{
- if(!m_flags.testFlag(Flag::IsPendingObjectResolved)){
- resolveListOfExtraSignal(env);
- }else if(QObject* object = qobject()){
- if(m_metaObject != object->metaObject())
- resolveListOfExtraSignal(env);
- }
- jobject result = qtjambi_arraylist_new(env, 0);
- for(const QtJambiSignalInfo& info : m_extraSignals){
- if(info.signalObject())
- qtjambi_collection_add(env, result, env->NewLocalRef(info.signalObject()));
+jobject PointerToPendingQObjectLink::getExtraSignal(JNIEnv * env, const QMetaMethod& method) const{
+ if(QObject* object = qobject()){
+ QList extraSignals = getExtraSignalsOfMetaObject(object->metaObject());
+ if(extraSignals.contains(method)){
+ QReadLocker rlocker(QtJambiLinkUserData::lock());
+ if(!m_extraSignals.contains(method.methodIndex())){
+ rlocker.unlock();
+ JObjectWrapper signal = qtjambi_resolve_extra_signal(env, getJavaObjectLocalRef(env), method);
+ {
+ QWriteLocker wlocker(QtJambiLinkUserData::lock());
+ if(!m_extraSignals.contains(method.methodIndex()))
+ m_extraSignals[method.methodIndex()] = signal;
+ }
+ rlocker.relock();
+ }
+ return m_extraSignals.value(method.methodIndex()).object();
+ }
}
- return result;
+ return nullptr;
}
PointerToPendingQObjectInterfaceLink::PointerToPendingQObjectInterfaceLink(JNIEnv *env, jobject nativeLink, jobject jobj, const QMap& interfaceOffsets, const QSet& interfaces, const QMap>& inheritedInterfaces, const QMetaObject* metaObject, QObject *ptr, bool created_by_java, bool isDeclarativeCall, bool is_shell, JavaException& ocurredException)
@@ -3331,56 +3279,71 @@ void PointerToPendingQObjectInterfaceLink::init(JNIEnv* env){
}
}
-void PointerToPendingQObjectInterfaceLink::resolveListOfExtraSignal(JNIEnv * env) const{
- JavaException ocurredException;
- if(jobject jobj = getJavaObjectLocalRef(env)){
- if(QObject* object = qobject()){
- m_metaObject = object->metaObject();
- QList extraSignals = extra_signals(m_metaObject);
- m_extraSignals = qtjambi_resolve_extra_signals(env, jobj, extraSignals, ocurredException);
- env->DeleteLocalRef(jobj);
+jobject PointerToPendingQObjectInterfaceLink::getExtraSignal(JNIEnv * env, const QMetaMethod& method) const{
+ if(QObject* object = qobject()){
+ QList extraSignals = getExtraSignalsOfMetaObject(object->metaObject());
+ if(extraSignals.contains(method)){
+ QReadLocker rlocker(QtJambiLinkUserData::lock());
+ if(!m_extraSignals.contains(method.methodIndex())){
+ rlocker.unlock();
+ JObjectWrapper signal = qtjambi_resolve_extra_signal(env, getJavaObjectLocalRef(env), method);
+ {
+ QWriteLocker wlocker(QtJambiLinkUserData::lock());
+ if(!m_extraSignals.contains(method.methodIndex()))
+ m_extraSignals[method.methodIndex()] = signal;
+ }
+ rlocker.relock();
+ }
+ return m_extraSignals.value(method.methodIndex()).object();
}
}
- const_cast(this)->m_flags.setFlag(Flag::IsPendingObjectResolved);
- if(ocurredException.object())
- ocurredException.raise();
+ return nullptr;
}
-jobject PointerToPendingQObjectInterfaceLink::getListOfExtraSignal(JNIEnv * env) const{
- if(!m_flags.testFlag(Flag::IsPendingObjectResolved)){
- resolveListOfExtraSignal(env);
- }else if(QObject* object = qobject()){
- if(m_metaObject != object->metaObject())
- resolveListOfExtraSignal(env);
- }
- jobject result = qtjambi_arraylist_new(env, 0);
- for(const QtJambiSignalInfo& info : m_extraSignals){
- if(info.signalObject())
- qtjambi_collection_add(env, result, env->NewLocalRef(info.signalObject()));
- }
- return result;
-}
-
-jobject PointerToQObjectWithExtraSignalsLink::getListOfExtraSignal(JNIEnv * env) const{
- jobject result = qtjambi_arraylist_new(env, 0);
- for(const QtJambiSignalInfo& info : m_extraSignals){
- if(info.signalObject())
- qtjambi_collection_add(env, result, env->NewLocalRef(info.signalObject()));
+jobject PointerToQObjectWithExtraSignalsLink::getExtraSignal(JNIEnv * env, const QMetaMethod& method) const{
+ if(QObject* object = qobject()){
+ QList extraSignals = getExtraSignalsOfMetaObject(object->metaObject());
+ if(extraSignals.contains(method)){
+ QReadLocker rlocker(QtJambiLinkUserData::lock());
+ if(!m_extraSignals.contains(method.methodIndex())){
+ rlocker.unlock();
+ JObjectWrapper signal = qtjambi_resolve_extra_signal(env, getJavaObjectLocalRef(env), method);
+ {
+ QWriteLocker wlocker(QtJambiLinkUserData::lock());
+ if(!m_extraSignals.contains(method.methodIndex()))
+ m_extraSignals[method.methodIndex()] = signal;
+ }
+ rlocker.relock();
+ }
+ return m_extraSignals.value(method.methodIndex()).object();
+ }
}
- return result;
+ return nullptr;
}
-jobject PointerToQObjectInterfaceWithExtraSignalsLink::getListOfExtraSignal(JNIEnv * env) const{
- jobject result = qtjambi_arraylist_new(env, 0);
- for(const QtJambiSignalInfo& info : m_extraSignals){
- if(info.signalObject())
- qtjambi_collection_add(env, result, env->NewLocalRef(info.signalObject()));
+jobject PointerToQObjectInterfaceWithExtraSignalsLink::getExtraSignal(JNIEnv * env, const QMetaMethod& method) const{
+ if(QObject* object = qobject()){
+ QList extraSignals = getExtraSignalsOfMetaObject(object->metaObject());
+ if(extraSignals.contains(method)){
+ QReadLocker rlocker(QtJambiLinkUserData::lock());
+ if(!m_extraSignals.contains(method.methodIndex())){
+ rlocker.unlock();
+ JObjectWrapper signal = qtjambi_resolve_extra_signal(env, getJavaObjectLocalRef(env), method);
+ {
+ QWriteLocker wlocker(QtJambiLinkUserData::lock());
+ if(!m_extraSignals.contains(method.methodIndex()))
+ m_extraSignals[method.methodIndex()] = signal;
+ }
+ rlocker.relock();
+ }
+ return m_extraSignals.value(method.methodIndex()).object();
+ }
}
- return result;
+ return nullptr;
}
-jobject PointerContainer::getListOfExtraSignal(JNIEnv * env, const QSharedPointerToQObjectLink*) const{
- return qtjambi_arraylist_new(env, 0);
+jobject PointerContainer::getExtraSignal(JNIEnv *, const QSharedPointerToQObjectLink*, const QMetaMethod&) const{
+ return nullptr;
}
QString PointerToObjectLink::describe() const{
@@ -3437,8 +3400,8 @@ QString QSharedPointerToObjectLink::describe() const{
return strg;
}
-jobject QSharedPointerToQObjectLink::getListOfExtraSignal(JNIEnv * env) const{
- return m_pointerContainer->getListOfExtraSignal(env, this);
+jobject QSharedPointerToQObjectLink::getExtraSignal(JNIEnv * env, const QMetaMethod& method) const{
+ return m_pointerContainer->getExtraSignal(env, this, method);
}
void QSharedPointerToQObjectLink::removeInterface(const std::type_info&){
@@ -3466,20 +3429,30 @@ QString QSharedPointerToQObjectLink::describe() const{
// ### END ################# QSharedPointerToQObjectLink ################### END ###
-PointerContainerWithExtraSignals::PointerContainerWithExtraSignals(JNIEnv* env, jobject jobj, const QMetaObject* metaObject, const QSharedPointer& link, void* ptr_shared_pointer, bool isShell, PointerDeleter shared_pointer_deleter, PointerQObjectGetterFunction pointerGetter, const QList& extraSignals, JavaException& ocurredException)
- : PointerContainer(env, jobj, metaObject, link, ptr_shared_pointer, isShell, shared_pointer_deleter, pointerGetter, ocurredException),
- m_extraSignals(qtjambi_resolve_extra_signals(env, jobj, extraSignals, ocurredException))
+PointerContainerWithExtraSignals::PointerContainerWithExtraSignals(JNIEnv* env, jobject jobj, const QMetaObject* metaObject, const QSharedPointer& link, void* ptr_shared_pointer, bool isShell, PointerDeleter shared_pointer_deleter, PointerQObjectGetterFunction pointerGetter, JavaException& ocurredException)
+ : PointerContainer(env, jobj, metaObject, link, ptr_shared_pointer, isShell, shared_pointer_deleter, pointerGetter, ocurredException)
{
-
}
-jobject PointerContainerWithExtraSignals::getListOfExtraSignal(JNIEnv * env, const QSharedPointerToQObjectLink*) const{
- jobject result = qtjambi_arraylist_new(env, 0);
- for(const QtJambiSignalInfo& info : m_extraSignals){
- if(info.signalObject())
- qtjambi_collection_add(env, result, env->NewLocalRef(info.signalObject()));
+jobject PointerContainerWithExtraSignals::getExtraSignal(JNIEnv * env, const QSharedPointerToQObjectLink* link, const QMetaMethod& method) const{
+ if(QObject* object = qobject()){
+ QList extraSignals = getExtraSignalsOfMetaObject(object->metaObject());
+ if(extraSignals.contains(method)){
+ QReadLocker rlocker(QtJambiLinkUserData::lock());
+ if(!m_extraSignals.contains(method.methodIndex())){
+ rlocker.unlock();
+ JObjectWrapper signal = qtjambi_resolve_extra_signal(env, link->getJavaObjectLocalRef(env), method);
+ {
+ QWriteLocker wlocker(QtJambiLinkUserData::lock());
+ if(!m_extraSignals.contains(method.methodIndex()))
+ m_extraSignals[method.methodIndex()] = signal;
+ }
+ rlocker.relock();
+ }
+ return m_extraSignals.value(method.methodIndex()).object();
+ }
}
- return result;
+ return nullptr;
}
PointerContainerWithPendingExtraSignals::PointerContainerWithPendingExtraSignals(JNIEnv* env, jobject jobj, const QMetaObject* metaObject, const QSharedPointer& link, void* ptr_shared_pointer, bool isShell, PointerDeleter shared_pointer_deleter, PointerQObjectGetterFunction pointerGetter, JavaException& ocurredException)
@@ -3490,34 +3463,25 @@ PointerContainerWithPendingExtraSignals::PointerContainerWithPendingExtraSignals
}
-void PointerContainerWithPendingExtraSignals::resolveListOfExtraSignal(JNIEnv * env, const QSharedPointerToQObjectLink* link) const {
- JavaException ocurredException;
- if(jobject jobj = link->getJavaObjectLocalRef(env)){
- if(QObject* object = qobject()){
- m_metaObject = object->metaObject();
- QList extraSignals = extra_signals(m_metaObject);
- m_extraSignals = qtjambi_resolve_extra_signals(env, jobj, extraSignals, ocurredException);
- env->DeleteLocalRef(jobj);
+jobject PointerContainerWithPendingExtraSignals::getExtraSignal(JNIEnv * env, const QSharedPointerToQObjectLink* link, const QMetaMethod& method) const{
+ if(QObject* object = qobject()){
+ QList extraSignals = getExtraSignalsOfMetaObject(object->metaObject());
+ if(extraSignals.contains(method)){
+ QReadLocker rlocker(QtJambiLinkUserData::lock());
+ if(!m_extraSignals.contains(method.methodIndex())){
+ rlocker.unlock();
+ JObjectWrapper signal = qtjambi_resolve_extra_signal(env, link->getJavaObjectLocalRef(env), method);
+ {
+ QWriteLocker wlocker(QtJambiLinkUserData::lock());
+ if(!m_extraSignals.contains(method.methodIndex()))
+ m_extraSignals[method.methodIndex()] = signal;
+ }
+ rlocker.relock();
+ }
+ return m_extraSignals.value(method.methodIndex()).object();
}
}
- const_cast(link)->m_flags.setFlag(QtJambiLink::Flag::IsPendingObjectResolved);
- if(ocurredException.object())
- ocurredException.raise();
-}
-
-jobject PointerContainerWithPendingExtraSignals::getListOfExtraSignal(JNIEnv * env, const QSharedPointerToQObjectLink* link) const{
- if(!link->m_flags.testFlag(QtJambiLink::Flag::IsPendingObjectResolved)){
- resolveListOfExtraSignal(env, link);
- }else if(QObject* object = qobject()){
- if(m_metaObject != object->metaObject())
- resolveListOfExtraSignal(env, link);
- }
- jobject result = qtjambi_arraylist_new(env, 0);
- for(const QtJambiSignalInfo& info : m_extraSignals){
- if(info.signalObject())
- qtjambi_collection_add(env, result, env->NewLocalRef(info.signalObject()));
- }
- return result;
+ return nullptr;
}
@@ -3567,9 +3531,8 @@ void* PointerContainer::getSharedPointer() const{
return m_ptr_shared_pointer;
}
-PointerToQObjectInterfaceWithExtraSignalsLink::PointerToQObjectInterfaceWithExtraSignalsLink(JNIEnv *env, jobject nativeLink, jobject jobj, const QMap& interfaceOffsets, const QSet& interfaces, const QMap>& inheritedInterfaces, const QMetaObject* metaObject, QObject *ptr, bool created_by_java, bool isDeclarativeCall, bool is_shell, const QList& extraSignals, JavaException& ocurredException)
- : PointerToQObjectInterfaceLink(env, nativeLink, jobj, interfaceOffsets, interfaces, inheritedInterfaces, metaObject, ptr, created_by_java, isDeclarativeCall, is_shell, ocurredException),
- m_extraSignals(qtjambi_resolve_extra_signals(env, jobj, extraSignals, ocurredException))
+PointerToQObjectInterfaceWithExtraSignalsLink::PointerToQObjectInterfaceWithExtraSignalsLink(JNIEnv *env, jobject nativeLink, jobject jobj, const QMap& interfaceOffsets, const QSet& interfaces, const QMap>& inheritedInterfaces, const QMetaObject* metaObject, QObject *ptr, bool created_by_java, bool isDeclarativeCall, bool is_shell, JavaException& ocurredException)
+ : PointerToQObjectInterfaceLink(env, nativeLink, jobj, interfaceOffsets, interfaces, inheritedInterfaces, metaObject, ptr, created_by_java, isDeclarativeCall, is_shell, ocurredException)
{
}
@@ -3756,31 +3719,6 @@ QObject* PointerContainer::qobject() const{
return m_ptr_shared_pointer && m_shared_pointer_getter ? m_shared_pointer_getter(m_ptr_shared_pointer) : nullptr;
}
-QtJambiSignalInfo::QtJambiSignalInfo(const QtJambiSignalInfo & info):
- m_signalObject(info.m_signalObject)
-{}
-
-QtJambiSignalInfo::QtJambiSignalInfo(QtJambiSignalInfo && info):
- m_signalObject(info.m_signalObject)
-{}
-
-QtJambiSignalInfo::QtJambiSignalInfo(): m_signalObject()
-{}
-
-QtJambiSignalInfo::QtJambiSignalInfo(JNIEnv* env, jobject object, bool global)
- : m_signalObject(env, object, global)
-{}
-
-QtJambiSignalInfo & QtJambiSignalInfo::operator =(const QtJambiSignalInfo & info)
-{
- m_signalObject = info.m_signalObject;
- return *this;
-}
-
-jobject QtJambiSignalInfo::signalObject() const{
- return m_signalObject.object();
-}
-
void qtjambi_set_java_ownership_for_toplevel_object(JNIEnv *env, QObject* qobject)
{
if(qobject && !qobject->parent()){
@@ -4160,67 +4098,56 @@ void qtjambi_resolve_signals(JNIEnv *env, jobject java_object, const QMetaObject
}
}
-const QHash qtjambi_resolve_extra_signals(JNIEnv *env, jobject java_object, const QList& extraSignals, JavaException& ocurredException){
- QHash sinfos;
- if(!ocurredException.object()){
- try{
- sinfos.reserve(extraSignals.size());
- QSet convertedMetaObjects;
- for(QMetaMethod method : extraSignals){
- jobject signalObject = nullptr;
- switch(method.parameterCount()){
- case 0:
- signalObject = Java::QtJambi::QInstanceMemberSignals$Signal0::newInstance(env, java_object);
- break;
- case 1:
- signalObject = Java::QtJambi::QInstanceMemberSignals$Signal1::newInstance(env, java_object);
- break;
- case 2:
- signalObject = Java::QtJambi::QInstanceMemberSignals$Signal2::newInstance(env, java_object);
- break;
- case 3:
- signalObject = Java::QtJambi::QInstanceMemberSignals$Signal3::newInstance(env, java_object);
- break;
- case 4:
- signalObject = Java::QtJambi::QInstanceMemberSignals$Signal4::newInstance(env, java_object);
- break;
- case 5:
- signalObject = Java::QtJambi::QInstanceMemberSignals$Signal5::newInstance(env, java_object);
- break;
- case 6:
- signalObject = Java::QtJambi::QInstanceMemberSignals$Signal6::newInstance(env, java_object);
- break;
- case 7:
- signalObject = Java::QtJambi::QInstanceMemberSignals$Signal7::newInstance(env, java_object);
- break;
- case 8:
- signalObject = Java::QtJambi::QInstanceMemberSignals$Signal8::newInstance(env, java_object);
- break;
- case 9:
- signalObject = Java::QtJambi::QInstanceMemberSignals$Signal9::newInstance(env, java_object);
- break;
- default:
- break;
- }
- if(signalObject){
- {
- const QMetaObject* parentMetaObject = method.enclosingMetaObject();
- while(parentMetaObject && !convertedMetaObjects.contains(parentMetaObject)){
- qtjambi_cast(env, parentMetaObject);
- convertedMetaObjects.insert(parentMetaObject);
- parentMetaObject = parentMetaObject->superClass();
- }
- }
- jobject signalTypes = qtjambi_get_signal_types(env, nullptr, method);
- Java::QtJambi::QtJambiSignals$AbstractSignal::initializeSignal(env, signalObject, env->GetObjectClass(java_object), signalTypes, method.methodIndex(), jlong(method.enclosingMetaObject()));
- sinfos.insert(method.methodIndex(), QtJambiSignalInfo(env, signalObject, true));
- }else{
- sinfos.insert(method.methodIndex(), QtJambiSignalInfo());
- }
+JObjectWrapper qtjambi_resolve_extra_signal(JNIEnv *env, jobject java_object, const QMetaMethod& method){
+ QSet convertedMetaObjects;
+ jobject signalObject = nullptr;
+ switch(method.parameterCount()){
+ case 0:
+ signalObject = Java::QtJambi::QInstanceMemberSignals$Signal0::newInstance(env, java_object);
+ break;
+ case 1:
+ signalObject = Java::QtJambi::QInstanceMemberSignals$Signal1::newInstance(env, java_object);
+ break;
+ case 2:
+ signalObject = Java::QtJambi::QInstanceMemberSignals$Signal2::newInstance(env, java_object);
+ break;
+ case 3:
+ signalObject = Java::QtJambi::QInstanceMemberSignals$Signal3::newInstance(env, java_object);
+ break;
+ case 4:
+ signalObject = Java::QtJambi::QInstanceMemberSignals$Signal4::newInstance(env, java_object);
+ break;
+ case 5:
+ signalObject = Java::QtJambi::QInstanceMemberSignals$Signal5::newInstance(env, java_object);
+ break;
+ case 6:
+ signalObject = Java::QtJambi::QInstanceMemberSignals$Signal6::newInstance(env, java_object);
+ break;
+ case 7:
+ signalObject = Java::QtJambi::QInstanceMemberSignals$Signal7::newInstance(env, java_object);
+ break;
+ case 8:
+ signalObject = Java::QtJambi::QInstanceMemberSignals$Signal8::newInstance(env, java_object);
+ break;
+ case 9:
+ signalObject = Java::QtJambi::QInstanceMemberSignals$Signal9::newInstance(env, java_object);
+ break;
+ default:
+ break;
+ }
+ if(signalObject){
+ {
+ const QMetaObject* parentMetaObject = method.enclosingMetaObject();
+ while(parentMetaObject && !convertedMetaObjects.contains(parentMetaObject)){
+ qtjambi_cast(env, parentMetaObject);
+ convertedMetaObjects.insert(parentMetaObject);
+ parentMetaObject = parentMetaObject->superClass();
}
- }catch(const JavaException& exn){
- ocurredException.addSuppressed(env, exn);
}
+ jobject signalTypes = qtjambi_get_signal_types(env, nullptr, method);
+ Java::QtJambi::QtJambiSignals$AbstractSignal::initializeSignal(env, signalObject, env->GetObjectClass(java_object), signalTypes, method.methodIndex(), jlong(method.enclosingMetaObject()));
+ return JObjectWrapper(env, signalObject, true);
+ }else{
+ return JObjectWrapper();
}
- return sinfos;
}
diff --git a/src/cpp/qtjambi/qtjambilink_p.h b/src/cpp/qtjambi/qtjambilink_p.h
index a40e8a97..b29a20ed 100644
--- a/src/cpp/qtjambi/qtjambilink_p.h
+++ b/src/cpp/qtjambi/qtjambilink_p.h
@@ -110,20 +110,6 @@ class JObjectSynchronizer{
const bool monitor;
};
-class QtJambiSignalInfo
-{
-public:
- QtJambiSignalInfo(const QtJambiSignalInfo & info);
- QtJambiSignalInfo(QtJambiSignalInfo && info);
- QtJambiSignalInfo();
- QtJambiSignalInfo(JNIEnv* env, jobject object, bool global);
-
- QtJambiSignalInfo & operator =(const QtJambiSignalInfo & info);
- jobject signalObject() const;
-private:
- JObjectWrapper m_signalObject;
-};
-
typedef std::function PointerQObjectGetterFunction;
class QtJambiLink;
@@ -171,7 +157,7 @@ class PointerContainer : public QObject{
~PointerContainer() override;
void* getSharedPointer() const;
QObject *qobject() const;
- virtual jobject getListOfExtraSignal(JNIEnv * env, const QSharedPointerToQObjectLink* link) const;
+ virtual jobject getExtraSignal(JNIEnv * env, const QSharedPointerToQObjectLink* link, const QMetaMethod& method) const;
void setAsQObjectDeleted();
private:
void* m_ptr_shared_pointer;
@@ -183,21 +169,20 @@ class PointerContainer : public QObject{
class PointerContainerWithExtraSignals : public PointerContainer{
public:
- explicit PointerContainerWithExtraSignals(JNIEnv* env, jobject jobj, const QMetaObject* metaObject, const QSharedPointer& link, void* ptr_shared_pointer, bool isShell, PointerDeleter shared_pointer_deleter, PointerQObjectGetterFunction pointerGetter, const QList& extraSignals, JavaException& ocurredException);
+ explicit PointerContainerWithExtraSignals(JNIEnv* env, jobject jobj, const QMetaObject* metaObject, const QSharedPointer& link, void* ptr_shared_pointer, bool isShell, PointerDeleter shared_pointer_deleter, PointerQObjectGetterFunction pointerGetter, JavaException& ocurredException);
~PointerContainerWithExtraSignals() override = default;
- jobject getListOfExtraSignal(JNIEnv * env, const QSharedPointerToQObjectLink* link) const override;
+ jobject getExtraSignal(JNIEnv * env, const QSharedPointerToQObjectLink* link, const QMetaMethod& method) const override;
private:
- const QHash m_extraSignals;
+ mutable QHash m_extraSignals;
};
class PointerContainerWithPendingExtraSignals : public PointerContainer{
public:
explicit PointerContainerWithPendingExtraSignals(JNIEnv* env, jobject jobj, const QMetaObject* metaObject, const QSharedPointer& link, void* ptr_shared_pointer, bool isShell, PointerDeleter shared_pointer_deleter, PointerQObjectGetterFunction pointerGetter, JavaException& ocurredException);
~PointerContainerWithPendingExtraSignals() override = default;
- jobject getListOfExtraSignal(JNIEnv * env, const QSharedPointerToQObjectLink* link) const override;
+ jobject getExtraSignal(JNIEnv * env, const QSharedPointerToQObjectLink* link, const QMetaMethod& method) const override;
private:
- void resolveListOfExtraSignal(JNIEnv * env, const QSharedPointerToQObjectLink* link) const;
- mutable QHash m_extraSignals;
+ mutable QHash m_extraSignals;
mutable const QMetaObject* m_metaObject;
};
@@ -629,7 +614,7 @@ class PointerToQObjectLink : public QtJambiLink{
void onDispose(JNIEnv *env) override;
void onClean(JNIEnv *env) override;
void invalidate(JNIEnv *env) override;
- virtual jobject getListOfExtraSignal(JNIEnv * env) const;
+ virtual jobject getExtraSignal(JNIEnv * env, const QMetaMethod& method) const;
QString describe() const override;
void init(JNIEnv* env) override;
void removeInterface(const std::type_info&) override;
@@ -641,12 +626,12 @@ class PointerToQObjectLink : public QtJambiLink{
class PointerToQObjectWithExtraSignalsLink : public PointerToQObjectLink{
protected:
- PointerToQObjectWithExtraSignalsLink(JNIEnv *env, jobject nativeLink, jobject jobj, const QMetaObject* metaObject, QObject *ptr, bool created_by_java, bool isDeclarativeCall, bool is_shell, const QList& extraSignals, JavaException& ocurredException);
+ PointerToQObjectWithExtraSignalsLink(JNIEnv *env, jobject nativeLink, jobject jobj, const QMetaObject* metaObject, QObject *ptr, bool created_by_java, bool isDeclarativeCall, bool is_shell, JavaException& ocurredException);
public:
~PointerToQObjectWithExtraSignalsLink() override = default;
- jobject getListOfExtraSignal(JNIEnv * env) const override;
+ jobject getExtraSignal(JNIEnv * env, const QMetaMethod& method) const override;
private:
- QHash m_extraSignals;
+ mutable QHash m_extraSignals;
friend QtJambiLink;
};
@@ -655,11 +640,10 @@ class PointerToPendingQObjectLink : public PointerToQObjectLink{
PointerToPendingQObjectLink(JNIEnv *env, jobject nativeLink, jobject jobj, const QMetaObject* metaObject, QObject *ptr, bool created_by_java, bool isDeclarativeCall, bool is_shell, JavaException& ocurredException);
public:
~PointerToPendingQObjectLink() override = default;
- jobject getListOfExtraSignal(JNIEnv * env) const override;
+ jobject getExtraSignal(JNIEnv * env, const QMetaMethod& method) const override;
void init(JNIEnv* env) override;
private:
- void resolveListOfExtraSignal(JNIEnv * env) const;
- mutable QHash m_extraSignals;
+ mutable QHash m_extraSignals;
mutable const QMetaObject* m_metaObject;
friend QtJambiLink;
};
@@ -749,7 +733,7 @@ class QSharedPointerToQObjectLink : public QSharedPointerLink{
QString describe() const override;
void removeInterface(const std::type_info&) override;
bool isDeleteLater() const { return m_flags.testFlag(Flag::IsDeleteLater); }
- jobject getListOfExtraSignal(JNIEnv * env) const;
+ jobject getExtraSignal(JNIEnv * env, const QMetaMethod& method) const;
private:
void setDeleteLater(){ m_flags.setFlag(Flag::IsDeleteLater); }
PointerContainer* m_pointerContainer;
@@ -779,25 +763,24 @@ class PointerToPendingQObjectInterfaceLink : public PointerToQObjectInterfaceLin
PointerToPendingQObjectInterfaceLink(JNIEnv *env, jobject nativeLink, jobject jobj, const QMap& interfaceOffsets, const QSet& interfaces, const QMap>& inheritedInterfaces, const QMetaObject* metaObject, QObject *ptr, bool created_by_java, bool isDeclarativeCall, bool is_shell, JavaException& ocurredException);
public:
~PointerToPendingQObjectInterfaceLink() override = default;
- jobject getListOfExtraSignal(JNIEnv * env) const override;
+ jobject getExtraSignal(JNIEnv * env, const QMetaMethod& method) const override;
void init(JNIEnv* env) override;
private:
- void resolveListOfExtraSignal(JNIEnv * env) const;
- mutable QHash m_extraSignals;
+ mutable QHash m_extraSignals;
mutable const QMetaObject* m_metaObject;
friend QtJambiLink;
};
class PointerToQObjectInterfaceWithExtraSignalsLink : public PointerToQObjectInterfaceLink{
protected:
- PointerToQObjectInterfaceWithExtraSignalsLink(JNIEnv *env, jobject nativeLink, jobject jobj, const QMap& interfaceOffsets, const QSet& interfaces, const QMap>& inheritedInterfaces, const QMetaObject* metaObject, QObject *ptr, bool created_by_java, bool isDeclarativeCall, bool is_shell, const QList& extraSignals, JavaException& ocurredException);
+ PointerToQObjectInterfaceWithExtraSignalsLink(JNIEnv *env, jobject nativeLink, jobject jobj, const QMap& interfaceOffsets, const QSet& interfaces, const QMap>& inheritedInterfaces, const QMetaObject* metaObject, QObject *ptr, bool created_by_java, bool isDeclarativeCall, bool is_shell, JavaException& ocurredException);
public:
~PointerToQObjectInterfaceWithExtraSignalsLink() override = default;
- jobject getListOfExtraSignal(JNIEnv * env) const override;
+ jobject getExtraSignal(JNIEnv * env, const QMetaMethod& method) const override;
private:
friend QtJambiLink;
friend class PointerToQObjectInterfaceWithDetectedExtraSignalsLink;
- QHash m_extraSignals;
+ mutable QHash m_extraSignals;
};
class QSharedPointerToObjectInterfaceLink : public QSharedPointerToObjectLink{
diff --git a/src/cpp/qtjambi/qtjambimetaobject.cpp b/src/cpp/qtjambi/qtjambimetaobject.cpp
index 7963eb78..3896cc1b 100644
--- a/src/cpp/qtjambi/qtjambimetaobject.cpp
+++ b/src/cpp/qtjambi/qtjambimetaobject.cpp
@@ -1221,16 +1221,25 @@ void QtJambiMetaObject::registerQPropertyField(int index, jfieldID field){
#endif //QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
jclass QtJambiMetaObject::javaClass(JNIEnv * env, const QMetaObject* metaObject, bool exactOrNull){
- if(const QtJambiMetaObject* dynamicMetaObject = QtJambiMetaObject::cast(metaObject)){
+ if(!metaObject){
+ return nullptr;
+ }else if(const QtJambiMetaObject* dynamicMetaObject = QtJambiMetaObject::cast(metaObject)){
return jclass(env->NewLocalRef(dynamicMetaObject->javaClass()));
}else{
if(const std::type_info* typeId = getTypeByMetaObject(metaObject)){
jclass result = env->FindClass(getJavaName(*typeId));
qtjambi_throw_java_exception(env);
return result;
- }else if(exactOrNull){
+ }else if(const std::type_info* typeId = getTypeByQtName(metaObject->className())){
+ if(!registeredOriginalMetaObject(*typeId)){
+ jclass result = env->FindClass(getJavaName(*typeId));
+ qtjambi_throw_java_exception(env);
+ return result;
+ }
+ }
+ if(exactOrNull){
return nullptr;
- }else if(metaObject && metaObject->superClass()){
+ }else if(metaObject->superClass()){
return javaClass(env, metaObject->superClass(), exactOrNull);
}else{
return Java::QtJambi::QtGadget::getClass(env);
diff --git a/src/cpp/qtjambi/qtjambisignals.cpp b/src/cpp/qtjambi/qtjambisignals.cpp
index 46c3dd9c..c75d30a7 100644
--- a/src/cpp/qtjambi/qtjambisignals.cpp
+++ b/src/cpp/qtjambi/qtjambisignals.cpp
@@ -36,10 +36,11 @@
****************************************************************************/
#include
+
#if QT_VERSION >= QT_VERSION_CHECK(6,4,0)
-# define QT_CORE_INLINE_SINCE(major, minor) inline
-# define QT_CORE_INLINE_IMPL_SINCE(major, minor) 1
+#include
#endif
+
QT_WARNING_DISABLE_DEPRECATED
#include "qtjambi_core.h"
#include "qtjambi_repository_p.h"
@@ -426,48 +427,6 @@ QTJAMBI_FUNCTION_PREFIX(Java_io_qt_internal_QtJambiSignals_00024NativeConnection
return false;
}
-#if QT_VERSION >= QT_VERSION_CHECK(6,4,0)
-struct QObjectPrivate::ConnectionOrSignalVector
-{
- union {
- // linked list of orphaned connections that need cleaning up
- ConnectionOrSignalVector *nextInOrphanList;
- // linked list of connections connected to slots in this object
- Connection *next;
- };
-};
-
-struct QObjectPrivate::Connection : public ConnectionOrSignalVector
-{
- // linked list of connections connected to slots in this object, next is in base class
- Connection **prev;
- // linked list of connections connected to signals in this object
- QAtomicPointer nextConnectionList;
- Connection *prevConnectionList;
-
- QObject *sender;
- QAtomicPointer receiver;
- QAtomicPointer receiverThreadData;
- union {
- StaticMetaCallFunction callFunction;
- QtPrivate::QSlotObjectBase *slotObj;
- };
- QAtomicPointer argumentTypes;
- QAtomicInt ref_{2}; //ref_ is 2 for the use in the internal lists, and for the use in QMetaObject::Connection
- uint id = 0;
- ushort method_offset;
- ushort method_relative;
- signed int signal_index : 27; // In signal range (see QObjectPrivate::signalIndex())
- ushort connectionType : 2; // 0 == auto, 1 == direct, 2 == queued, 3 == blocking
- ushort isSlotObject : 1;
- ushort ownArgumentTypes : 1;
- ushort isSingleShot : 1;
- Connection() = delete;
- ~Connection() = delete;
- int method() const { Q_ASSERT(!isSlotObject); return method_offset + method_relative; }
-};
-#endif
-
QObject* connectionSender(const QMetaObject::Connection* connection){
if(connection && *connection){
void * ptr = reinterpret_cast(connection)->d_ptr;
diff --git a/src/cpp/qtjambi/qtjambitypemanager.cpp b/src/cpp/qtjambi/qtjambitypemanager.cpp
index f6e9a7ec..f9db1043 100644
--- a/src/cpp/qtjambi/qtjambitypemanager.cpp
+++ b/src/cpp/qtjambi/qtjambitypemanager.cpp
@@ -700,6 +700,14 @@ QString QtJambiTypeManager::getExternalTypeName(JNIEnv* environment, const QStri
case QMetaType::LongLong:
case QMetaType::ULongLong: return "long";
case QMetaType::Bool: return "boolean";
+ case QMetaType::QStringList: return "io/qt/core/QStringList";
+ case QMetaType::QByteArrayList: return "io/qt/core/QList";
+ case QMetaType::QVariantMap: return "io/qt/core/QMap";
+ case QMetaType::QVariantHash: return "io/qt/core/QHash";
+ case QMetaType::QVariantList: return "io/qt/core/QList";
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ case QMetaType::QVariantPair: return "io/qt/core/QPair";
+#endif
case QMetaType::VoidStar: return "io/qt/QNativePointer";
default:
break;
@@ -738,10 +746,42 @@ QString QtJambiTypeManager::getExternalTypeName(JNIEnv* environment, const QStri
return QLatin1String("java/lang/Enum");
else if (_internalTypeName=="JQFlagsWrapper")
return QLatin1String("io/qt/QFlags");
- else if (_internalTypeName.startsWith("QPair<") && _internalTypeName.endsWith(">"))
- return QLatin1String("io/qt/core/QPair");
- else if (_internalTypeName.startsWith("std::pair<") && _internalTypeName.endsWith(">"))
+ else if ((_internalTypeName.startsWith("std::pair<") || _internalTypeName.startsWith("QPair<")) && _internalTypeName.endsWith(">"))
return QLatin1String("io/qt/core/QPair");
+ else if (_internalTypeName.startsWith("QMap<") && _internalTypeName.endsWith(">"))
+ return QLatin1String("io/qt/core/QMap");
+ else if (_internalTypeName.startsWith("QMultiMap<") && _internalTypeName.endsWith(">"))
+ return QLatin1String("io/qt/core/QMultiMap");
+ else if (_internalTypeName.startsWith("QHash<") && _internalTypeName.endsWith(">"))
+ return QLatin1String("io/qt/core/QHash");
+ else if (_internalTypeName.startsWith("QMultiHash<") && _internalTypeName.endsWith(">"))
+ return QLatin1String("io/qt/core/QMultiHash");
+ else if (_internalTypeName.startsWith("QLinkedList<") && _internalTypeName.endsWith(">"))
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ return QLatin1String("java/util/LinkedList");
+#else
+ return QLatin1String("io/qt/core/QLinkedList");
+#endif
+ else if (_internalTypeName.startsWith("QList<") && _internalTypeName.endsWith(">"))
+ return QLatin1String("io/qt/core/QList");
+ else if (_internalTypeName.startsWith("QSet<") && _internalTypeName.endsWith(">"))
+ return QLatin1String("io/qt/core/QSet");
+ else if (_internalTypeName.startsWith("QQueue<") && _internalTypeName.endsWith(">"))
+ return QLatin1String("io/qt/core/QQueue");
+ else if (_internalTypeName.startsWith("QVector<") && _internalTypeName.endsWith(">"))
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ return QLatin1String("io/qt/core/QList");
+#else
+ return QLatin1String("io/qt/core/QVector");
+#endif
+ else if (_internalTypeName.startsWith("QStack<") && _internalTypeName.endsWith(">"))
+ return QLatin1String("io/qt/core/QStack");
+ else if (_internalTypeName.startsWith("std::vector<") && _internalTypeName.endsWith(">"))
+ return QLatin1String("java/util/ArrayList");
+ else if (_internalTypeName.startsWith("std::map<") && _internalTypeName.endsWith(">"))
+ return QLatin1String("java/util/HashMap");
+ else if (_internalTypeName.startsWith("std::set<") && _internalTypeName.endsWith(">"))
+ return QLatin1String("java/util/HashSet");
const std::type_info* typeId = metaType.isValid() ? getTypeByMetaType(metaType) : nullptr;
QString javaName;
if(typeId){
@@ -801,23 +841,28 @@ QString QtJambiTypeManager::getExternalTypeName(JNIEnv* environment, const QStri
if(metaType.isValid()
&& metaType.id()!=QMetaType::Nullptr
&& metaType.id()!=QMetaType::Void){
+ QByteArray name = registeredJavaClassForCustomMetaType(metaType);
+ if(!name.isEmpty()){
+ return QLatin1String(name);
+ }
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QVariant variant(metaType.id(), nullptr);
-#else
- QVariant variant(metaType, nullptr);
-#endif //QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if(variant.canConvert(QMetaType::QVariantList)){
javaName = "io/qt/core/QList";
+ }else if(variant.canConvert(QMetaType::QVariantMap)){
+ javaName = "io/qt/core/QMap";
}else if(variant.canConvert(QMetaType::QVariantHash)){
javaName = "io/qt/core/QHash";
- }else if(variant.canConvert(QMetaType::QVariantMap)){
+ }
+#else
+ if(QMetaType::canConvert(QMetaType(metaType), QMetaType(QMetaType::QVariantList))){
+ javaName = "io/qt/core/QList";
+ }else if(QMetaType::canConvert(QMetaType(metaType), QMetaType(QMetaType::QVariantMap))){
javaName = "io/qt/core/QMap";
- }else{
- QByteArray name = registeredJavaClassForCustomMetaType(metaType);
- if(!name.isEmpty()){
- return QLatin1String(name);
- }
+ }else if(QMetaType::canConvert(QMetaType(metaType), QMetaType(QMetaType::QVariantHash))){
+ javaName = "io/qt/core/QHash";
}
+#endif
}
}
if(!javaName.isEmpty() && pointerType==PointerType::initializer_list){
diff --git a/src/cpp/qtjambi_core/qtjambi_core_util.cpp b/src/cpp/qtjambi_core/qtjambi_core_util.cpp
index 913493e4..afd80fa9 100644
--- a/src/cpp/qtjambi_core/qtjambi_core_util.cpp
+++ b/src/cpp/qtjambi_core/qtjambi_core_util.cpp
@@ -1988,6 +1988,22 @@ QTJAMBI_FUNCTION_PREFIX(Java_io_qt_core_QMetaObject_propertyCount)
return _result;
}
+extern "C" Q_DECL_EXPORT jobject JNICALL
+QTJAMBI_FUNCTION_PREFIX(Java_io_qt_core_QMetaObject_propertyByIndex)
+ (JNIEnv *env, jobject, jlong metaObjectPointer, jint index)
+{
+ jobject _result{nullptr};
+ QTJAMBI_TRY{
+ if(metaObjectPointer){
+ const QMetaObject *metaObject = reinterpret_cast(metaObjectPointer);
+ _result = qtjambi_cast(env, metaObject->property(index));
+ }
+ }QTJAMBI_CATCH(const JavaException& exn){
+ exn.raiseInJava(env);
+ }QTJAMBI_TRY_END
+ return _result;
+}
+
extern "C" Q_DECL_EXPORT jobject JNICALL
QTJAMBI_FUNCTION_PREFIX(Java_io_qt_core_QMetaObject_property)
(JNIEnv *env, jobject, jlong metaObjectPointer, jobject name)
@@ -2335,6 +2351,26 @@ QTJAMBI_FUNCTION_PREFIX(Java_io_qt_core_QMetaObject_constructor)
return result;
}
+extern "C" Q_DECL_EXPORT jobject JNICALL
+QTJAMBI_FUNCTION_PREFIX(Java_io_qt_core_QMetaObject_constructorByIndex)
+ (JNIEnv * env, jobject, jlong metaObjectPointer, jint index)
+{
+ jobject result = nullptr;
+ QTJAMBI_TRY{
+ if(metaObjectPointer){
+ env->EnsureLocalCapacity(100);
+ const QMetaObject *metaObject = reinterpret_cast(metaObjectPointer);
+ QMetaMethod method = metaObject->constructor(index);
+ if(method.isValid() && method.methodType()==QMetaMethod::Constructor){
+ result = qtjambi_cast(env, method);
+ }
+ }
+ }QTJAMBI_CATCH(const JavaException& exn){
+ exn.raiseInJava(env);
+ }QTJAMBI_TRY_END
+ return result;
+}
+
extern "C" Q_DECL_EXPORT jint JNICALL
QTJAMBI_FUNCTION_PREFIX(Java_io_qt_core_QMetaObject_constructorCount)
(JNIEnv * env, jobject, jlong metaObjectPointer)
@@ -2391,6 +2427,23 @@ QTJAMBI_FUNCTION_PREFIX(Java_io_qt_core_QMetaObject_enumerator)
return result;
}
+extern "C" Q_DECL_EXPORT jobject JNICALL
+QTJAMBI_FUNCTION_PREFIX(Java_io_qt_core_QMetaObject_enumeratorByIndex)
+ (JNIEnv * env, jclass, jlong metaObjectPointer, jint index)
+{
+ jobject result = nullptr;
+ QTJAMBI_TRY{
+ if(metaObjectPointer){
+ const QMetaObject *metaObject = reinterpret_cast(metaObjectPointer);
+ QMetaEnum enumerator = metaObject->enumerator(index);
+ result = qtjambi_cast(env, enumerator);
+ }
+ }QTJAMBI_CATCH(const JavaException& exn){
+ exn.raiseInJava(env);
+ }QTJAMBI_TRY_END
+ return result;
+}
+
extern "C" Q_DECL_EXPORT void JNICALL
QTJAMBI_FUNCTION_PREFIX(Java_io_qt_core_QMetaObject_connectSlotsByName)
(JNIEnv * env, jclass, QtJambiNativeID native_id)
diff --git a/src/cpp/qtjambi_dbus/QDBusVariantReply.cpp b/src/cpp/qtjambi_dbus/QDBusVariantReply.cpp
index b4f37377..670c69bd 100644
--- a/src/cpp/qtjambi_dbus/QDBusVariantReply.cpp
+++ b/src/cpp/qtjambi_dbus/QDBusVariantReply.cpp
@@ -394,6 +394,12 @@ extern "C" Q_DECL_EXPORT void JNICALL QTJAMBI_FUNCTION_PREFIX(Java_io_qt_dbus_QD
|| metaTypeId==qMetaTypeId()){
JavaException::raiseIllegalArgumentException(__jni_env, qPrintable(QString("Unable to marhall/unmarshall type %1.").arg(qtjambi_class_name(__jni_env, classType))) QTJAMBI_STACKTRACEINFO );
}else{
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ if(!QMetaType(metaType).iface()->defaultCtr
+ || !QMetaType(metaType).iface()->copyCtr){
+ JavaException::raiseRuntimeException(__jni_env, qPrintable(QString("Meta type %1 does not provide default and copy constructor.").arg(QLatin1String(metaType.name()))) QTJAMBI_STACKTRACEINFO );
+ }
+#endif
JObjectWrapper _marshallFunction(__jni_env, marshallFunction);
mf = qtjambi_function_pointer<16,void(QDBusArgument &, const void *)>([metaTypeId,_marshallFunction](QDBusArgument &arg, const void *t) {
if(JNIEnv* env = qtjambi_current_environment()){
@@ -498,6 +504,11 @@ extern "C" Q_DECL_EXPORT jobject JNICALL QTJAMBI_FUNCTION_PREFIX(Java_io_qt_dbus
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
QVariant variant(metaType.id(), nullptr);
#else
+#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
+ if(!QMetaType(metaType).iface()->copyCtr || !QMetaType(metaType).iface()->defaultCtr){
+ JavaException::raiseUnsupportedOperationException(__jni_env, qPrintable(QString("Unable to extract value of type %1 from QDBusArgument.").arg(QLatin1String(metaType.name()))) QTJAMBI_STACKTRACEINFO );
+ }
+#endif
QVariant variant(metaType, nullptr);
#endif
if(QDBusMetaType::demarshall(*arg, metaType
diff --git a/src/cpp/qtjambi_httpserver/qtjambi_httpserver.cpp b/src/cpp/qtjambi_httpserver/qtjambi_httpserver.cpp
index ba3c156b..7a1390b9 100644
--- a/src/cpp/qtjambi_httpserver/qtjambi_httpserver.cpp
+++ b/src/cpp/qtjambi_httpserver/qtjambi_httpserver.cpp
@@ -9,7 +9,8 @@
#include
struct HttpServer : QAbstractHttpServer{
- inline void afterRequestImpl(QHttpServer::AfterRequestHandler afterRequestHandler)
+ inline void afterRequestImpl(std::function afterRequestHandler)
{
QHttpServerPrivate* d = reinterpret_cast(QObjectPrivate::get(this));
d->afterRequestHandlers.push_back(std::move(afterRequestHandler));
@@ -34,7 +35,7 @@ struct HttpServerRouterRule : QHttpServerRouterRule{
bool hasValidMethods() const{ return QHttpServerRouterRule::hasValidMethods(); }
bool createPathRegexp(std::initializer_list metaTypes,
- const QHash &converters){
+ const QHash &converters){
return QHttpServerRouterRule::createPathRegexp(metaTypes, converters);
}
};
diff --git a/src/cpp/qtjambi_qml/qmlregistry.cpp b/src/cpp/qtjambi_qml/qmlregistry.cpp
index d304c9ea..0744813d 100644
--- a/src/cpp/qtjambi_qml/qmlregistry.cpp
+++ b/src/cpp/qtjambi_qml/qmlregistry.cpp
@@ -1425,6 +1425,24 @@ extern "C" Q_DECL_EXPORT jint JNICALL Java_io_qt_qml_QtQml_qmlRegisterType__Lio_
return _result;
}
+/*
+ * Class: io_qt_qml_QtQml
+ * Method: qmlTypeId
+ * Signature: (Ljava/lang/String;IILjava/lang/String;)I
+ */
+extern "C" Q_DECL_EXPORT jint JNICALL Java_io_qt_qml_QtQml_qmlTypeId__Ljava_lang_String_2IILjava_lang_String_2
+ (JNIEnv * env, jclass, jstring uri, jint versionMajor, jint versionMinor, jstring qmlName){
+ env->EnsureLocalCapacity(300);
+ jint _result{-1};
+ QTJAMBI_TRY{
+ QString _qmlName = qtjambi_to_qstring(env, qmlName);
+ _result = qmlTypeId(qPrintable(qtjambi_to_qstring(env, uri)), int(versionMajor), int(versionMinor), _qmlName.isEmpty() ? nullptr : qPrintable(_qmlName));
+ }QTJAMBI_CATCH(const JavaException& exn){
+ exn.raiseInJava(env);
+ }QTJAMBI_TRY_END
+ return _result;
+}
+
/*
* Class: io_qt_qml_QtQml
* Method: qmlProtectModule
@@ -1888,3 +1906,230 @@ extern "C" Q_DECL_EXPORT void JNICALL QTJAMBI_FUNCTION_PREFIX(Java_io_qt_qml_QQm
#endif
}
+// QQmlEngine::singletonInstance(int)
+extern "C" Q_DECL_EXPORT jobject JNICALL QTJAMBI_FUNCTION_PREFIX(Java_io_qt_qml_QQmlEngine_singletonInstance__JI)
+(JNIEnv *__jni_env,
+ jclass,
+ QtJambiNativeID __this_nativeId, jint qmlTypeId)
+{
+ QTJAMBI_DEBUG_METHOD_PRINT("native", "QQmlEngine::singletonInstance(int)")
+ jobject result{nullptr};
+ QTJAMBI_TRY {
+ QQmlEngine *__qt_this = qtjambi_object_from_nativeId(__this_nativeId);
+ qtjambi_check_resource(__jni_env, __qt_this);
+ QJSValue value = __qt_this->singletonInstance(qmlTypeId);
+ result = qtjambi_cast(__jni_env, value);
+ }QTJAMBI_CATCH(const JavaException& exn){
+ exn.raiseInJava(__jni_env);
+ }QTJAMBI_TRY_END
+ return result;
+}
+
+// qjsEngine
+extern "C" Q_DECL_EXPORT jobject JNICALL QTJAMBI_FUNCTION_PREFIX(Java_io_qt_qml_QtQml_qjsEngine)
+(JNIEnv *__jni_env,
+ jclass,
+ QtJambiNativeID __object_nativeId)
+{
+ QTJAMBI_DEBUG_METHOD_PRINT("native", "qjsEngine")
+ jobject result{nullptr};
+ QTJAMBI_TRY {
+ QObject *object = qtjambi_object_from_nativeId(__object_nativeId);
+ result = qtjambi_cast(__jni_env, qjsEngine(object));
+ }QTJAMBI_CATCH(const JavaException& exn){
+ exn.raiseInJava(__jni_env);
+ }QTJAMBI_TRY_END
+ return result;
+}
+
+#if QT_VERSION >= QT_VERSION_CHECK(6,3,0)
+using ConvertVariant = bool(QJSEngine::*)(const QVariant &value, QMetaType metaType, void *ptr);
+template <>
+constexpr ConvertVariant qjsvalue_cast(const QJSValue &)
+{
+ return &QJSEngine::convertVariant;
+}
+// QJSEngine::fromVariant
+extern "C" Q_DECL_EXPORT jobject JNICALL QTJAMBI_FUNCTION_PREFIX(Java_io_qt_qml_QJSEngine_fromVariant)
+(JNIEnv *env,
+ jclass,
+ QtJambiNativeID __this_nativeId, jobject jVariant, QtJambiNativeID metaTypeId)
+{
+ QTJAMBI_DEBUG_METHOD_PRINT("native", "QJSEngine::fromVariant")
+ jobject result{nullptr};
+ QTJAMBI_TRY {
+ QJSEngine *__qt_this = qtjambi_object_from_nativeId(__this_nativeId);
+ qtjambi_check_resource(env, __qt_this);
+ QVariant value = qtjambi_to_qvariant(env, jVariant);
+ QMetaType targetType = qtjambi_object_from_nativeId_deref(env, metaTypeId);
+ if (value.metaType()==targetType){
+ result = jVariant;
+ }else{
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
+ if(!targetType.iface()->defaultCtr){
+ JavaException::raiseRuntimeException(env, qPrintable(QString("Unable to convert to meta type %1 due to missing default constructor.").arg(QLatin1String(targetType.name()))) QTJAMBI_STACKTRACEINFO );
+ }
+ if(!targetType.iface()->copyCtr){
+ JavaException::raiseRuntimeException(env, qPrintable(QString("Unable to convert to meta type %1 due to missing copy constructor.").arg(QLatin1String(targetType.name()))) QTJAMBI_STACKTRACEINFO );
+ }
+#endif
+ QVariant t(targetType, nullptr);
+ ConvertVariant convertVariant = qjsvalue_cast(QJSValue{});
+ if ((__qt_this->*convertVariant)(value, targetType, t.data())){
+ result = qtjambi_from_qvariant(env, t);
+ }else{
+ QMetaType::convert(value.metaType(), value.constData(), targetType, t.data());
+ result = qtjambi_from_qvariant(env, t);
+ }
+ }
+ }QTJAMBI_CATCH(const JavaException& exn){
+ exn.raiseInJava(env);
+ }QTJAMBI_TRY_END
+ return result;
+}
+#endif
+
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+using ConvertV2 = bool (*)(const QJSValue &value, QMetaType metaType, void *ptr);
+template <>
+constexpr ConvertV2 qjsvalue_cast(const QJSValue &)
+{
+ return &QJSEngine::convertV2;
+}
+// QJSEngine::fromScriptValue
+extern "C" Q_DECL_EXPORT jobject JNICALL QTJAMBI_FUNCTION_PREFIX(Java_io_qt_qml_QJSEngine_fromScriptValue)
+(JNIEnv *env,
+ jclass,
+ QtJambiNativeID __this_nativeId, QtJambiNativeID jmanaged, QtJambiNativeID metaTypeId)
+{
+ QTJAMBI_DEBUG_METHOD_PRINT("native", "QJSEngine::fromScriptValue")
+ jobject result{nullptr};
+ QTJAMBI_TRY {
+ QJSEngine *__qt_this = qtjambi_object_from_nativeId(__this_nativeId);
+ qtjambi_check_resource(env, __qt_this);
+ const QJSValue& value = qtjambi_object_from_nativeId_deref(env, jmanaged);
+ QMetaType targetType = qtjambi_object_from_nativeId_deref(env, metaTypeId);
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
+ if(!targetType.iface()->defaultCtr){
+ JavaException::raiseRuntimeException(env, qPrintable(QString("Unable to convert to meta type %1 due to missing default constructor.").arg(QLatin1String(targetType.name()))) QTJAMBI_STACKTRACEINFO );
+ }
+ if(!targetType.iface()->copyCtr){
+ JavaException::raiseRuntimeException(env, qPrintable(QString("Unable to convert to meta type %1 due to missing copy constructor.").arg(QLatin1String(targetType.name()))) QTJAMBI_STACKTRACEINFO );
+ }
+#endif
+ ConvertV2 convertV2 = qjsvalue_cast(QJSValue{});
+ QVariant t(targetType, nullptr);
+ if (convertV2(value, targetType, t.data())){
+ result = qtjambi_from_qvariant(env, t);
+ }else if (value.isVariant()){
+ t = value.toVariant();
+ t.convert(targetType);
+ result = qtjambi_from_qvariant(env, t);
+ }else{
+ result = qtjambi_from_qvariant(env, QVariant(targetType, nullptr));
+ }
+ }QTJAMBI_CATCH(const JavaException& exn){
+ exn.raiseInJava(env);
+ }QTJAMBI_TRY_END
+ return result;
+}
+
+using Create = QJSValue(QJSEngine::*)(QMetaType type, const void *ptr);
+template <>
+constexpr Create qjsvalue_cast(const QJSValue &)
+{
+ return &QJSEngine::create;
+}
+// QJSEngine::toScriptValue
+extern "C" Q_DECL_EXPORT jobject JNICALL QTJAMBI_FUNCTION_PREFIX(Java_io_qt_qml_QJSEngine_toScriptValue)
+(JNIEnv *env,
+ jclass,
+ QtJambiNativeID __this_nativeId, jobject object)
+{
+ QTJAMBI_DEBUG_METHOD_PRINT("native", "QJSEngine::toScriptValue")
+ jobject result{nullptr};
+ QTJAMBI_TRY {
+ QJSEngine *__qt_this = qtjambi_object_from_nativeId(__this_nativeId);
+ qtjambi_check_resource(env, __qt_this);
+ QVariant variant = qtjambi_to_qvariant(env, object);
+ Create create = qjsvalue_cast(QJSValue{});
+ QJSValue jsval = (__qt_this->*create)(variant.metaType(), variant.data());
+ result = qtjambi_cast(env, jsval);
+ }QTJAMBI_CATCH(const JavaException& exn){
+ exn.raiseInJava(env);
+ }QTJAMBI_TRY_END
+ return result;
+}
+#endif
+
+#if QT_VERSION >= QT_VERSION_CHECK(6, 1, 0)
+using ConvertManaged = bool(*)(const QJSManagedValue &value, QMetaType type, void *ptr);
+template <>
+constexpr ConvertManaged qjsvalue_cast(const QJSValue &)
+{
+ return &QJSEngine::convertManaged;
+}
+// QJSEngine::fromManagedValue
+extern "C" Q_DECL_EXPORT jobject JNICALL QTJAMBI_FUNCTION_PREFIX(Java_io_qt_qml_QJSEngine_fromManagedValue)
+(JNIEnv *env,
+ jclass,
+ QtJambiNativeID __this_nativeId, QtJambiNativeID jmanaged, QtJambiNativeID metaTypeId)
+{
+ QTJAMBI_DEBUG_METHOD_PRINT("native", "QJSEngine::fromManagedValue")
+ jobject result{nullptr};
+ QTJAMBI_TRY {
+ QJSEngine *__qt_this = qtjambi_object_from_nativeId(__this_nativeId);
+ qtjambi_check_resource(env, __qt_this);
+ const QJSManagedValue& value = qtjambi_object_from_nativeId_deref(env, jmanaged);
+ QMetaType targetType = qtjambi_object_from_nativeId_deref(env, metaTypeId);
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
+ if(!targetType.iface()->defaultCtr){
+ JavaException::raiseRuntimeException(env, qPrintable(QString("Unable to convert to meta type %1 due to missing default constructor.").arg(QLatin1String(targetType.name()))) QTJAMBI_STACKTRACEINFO );
+ }
+ if(!targetType.iface()->copyCtr){
+ JavaException::raiseRuntimeException(env, qPrintable(QString("Unable to convert to meta type %1 due to missing copy constructor.").arg(QLatin1String(targetType.name()))) QTJAMBI_STACKTRACEINFO );
+ }
+#endif
+ ConvertManaged convertManaged = qjsvalue_cast