diff options
68 files changed, 5366 insertions, 403 deletions
@@ -126,7 +126,7 @@ shellArgumentListToQMakeList() # Helper function for getQMakeConf. It parses include statements in # qmake.conf and prints out the expanded file -getQMakeConf1() +expandQMakeConf() { while read line; do case "$line" in include*) @@ -137,7 +137,7 @@ getQMakeConf1() echo "WARNING: Unable to find file $conf_file" >&2 continue fi - getQMakeConf1 "$conf_file" + expandQMakeConf "$conf_file" ;; *load\(device_config\)*) conf_file="$DEVICE_VARS_FILE" @@ -145,7 +145,7 @@ getQMakeConf1() echo "WARNING: Unable to find file $conf_file" >&2 continue fi - getQMakeConf1 "$conf_file" + expandQMakeConf "$conf_file" ;; *) echo "$line" @@ -153,7 +153,7 @@ getQMakeConf1() esac; done < "$1" } -getQMakeConf2() +extractQMakeVariables() { $AWK ' BEGIN { @@ -215,7 +215,7 @@ END { ' } -getQMakeConf3() +getSingleQMakeVariable() { echo "$2" | $AWK "/^($1)=/ { print substr(\$0, index(\$0, \"=\") + 1) }" } @@ -225,17 +225,17 @@ getQMakeConf3() getQMakeConf() { if [ -z "$specvals" ]; then - specvals=`getQMakeConf1 "$QMAKESPEC/qmake.conf" | getQMakeConf2` + specvals=`expandQMakeConf "$QMAKESPEC/qmake.conf" | extractQMakeVariables` fi - getQMakeConf3 "$1" "$specvals" + getSingleQMakeVariable "$1" "$specvals" } getXQMakeConf() { if [ -z "$xspecvals" ]; then - xspecvals=`getQMakeConf1 "$XQMAKESPEC/qmake.conf" | getQMakeConf2` + xspecvals=`expandQMakeConf "$XQMAKESPEC/qmake.conf" | extractQMakeVariables` fi - getQMakeConf3 "$1" "$xspecvals" + getSingleQMakeVariable "$1" "$xspecvals" } compilerSupportsFlag() @@ -4175,7 +4175,7 @@ if [ "${CFG_AVX}" = "auto" ]; then *g++*|*-clang*) # Some clang versions produce internal compiler errors compiling Qt AVX code case `$TEST_COMPILER --version` in - Apple\ clang\ version\ 2*|Apple\ clang\ version\ 3.0*) + Apple\ clang\ version\ [23]*) CFG_AVX=no if [ "$OPT_VERBOSE" = "yes" ]; then echo 'AVX support disabled for blacklisted clang compiler' diff --git a/mkspecs/common/gcc-base-ios.conf b/mkspecs/common/gcc-base-ios.conf deleted file mode 100644 index 2fd597e973..0000000000 --- a/mkspecs/common/gcc-base-ios.conf +++ /dev/null @@ -1,33 +0,0 @@ -# -# Base qmake configuration for GCC on iOS -# -# Before making changes to this file, please read the comment in -# gcc-base.conf, to make sure the change goes in the right place. -# -# To verify that your change has the desired effect on the final configuration -# you can use the manual test in tests/manual/mkspecs. -# - -include(gcc-base.conf) - -QMAKE_COMPILER_DEFINES += __APPLE__ __GNUC__=4 - -QMAKE_CFLAGS_DEBUG += -gdwarf-2 - -QMAKE_CXXFLAGS_DEBUG += -gdwarf-2 - -QMAKE_OBJECTIVE_CFLAGS = $$QMAKE_CFLAGS -QMAKE_OBJECTIVE_CFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -QMAKE_OBJECTIVE_CFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_OBJECTIVE_CFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_OBJECTIVE_CFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_OBJECTIVE_CFLAGS_HIDESYMS = $$QMAKE_CXXFLAGS_HIDESYMS - -QMAKE_LFLAGS += -headerpad_max_install_names -QMAKE_LFLAGS_SHLIB += -single_module -dynamiclib -QMAKE_LFLAGS_PLUGIN += $$QMAKE_LFLAGS_SHLIB -QMAKE_LFLAGS_INCREMENTAL += -undefined suppress -flat_namespace -QMAKE_LFLAGS_SONAME += -install_name$${LITERAL_WHITESPACE}@executable_path/ -QMAKE_LFLAGS_VERSION += -current_version$${LITERAL_WHITESPACE} -QMAKE_LFLAGS_COMPAT_VERSION += -compatibility_version$${LITERAL_WHITESPACE} - diff --git a/mkspecs/common/gcc-base-macx.conf b/mkspecs/common/gcc-base-mac.conf index 45fa248b66..cee129e774 100644 --- a/mkspecs/common/gcc-base-macx.conf +++ b/mkspecs/common/gcc-base-mac.conf @@ -1,5 +1,5 @@ # -# Base qmake configuration for GCC on Mac OS X +# Base qmake configuration for GCC on Mac OS X and iOS # # Before making changes to this file, please read the comment in # gcc-base.conf, to make sure the change goes in the right place. diff --git a/mkspecs/common/gcc-base.conf b/mkspecs/common/gcc-base.conf index 43ebc0ab3a..2676cd6f04 100644 --- a/mkspecs/common/gcc-base.conf +++ b/mkspecs/common/gcc-base.conf @@ -7,8 +7,7 @@ # # Platform-specific options shared by these compilers are put into: # -# - gcc-base-ios.conf -# - gcc-base-macx.conf +# - gcc-base-mac.conf # - gcc-base-unix.conf # # These base files are then combined with configurations for each compiler: @@ -20,7 +19,7 @@ # - clang.conf # # The combination happens in the top level mkspec, by including a platform- -# specific version of the base-file, for example gcc-base-macx.conf, and then +# specific version of the base-file, for example gcc-base-mac.conf, and then # a (possibly platform-specific) version of the actual compiler configuration, # for example g++-macx.conf. # diff --git a/mkspecs/common/ios.conf b/mkspecs/common/ios.conf index 5ff2f9b416..b7d2b84ec9 100644 --- a/mkspecs/common/ios.conf +++ b/mkspecs/common/ios.conf @@ -2,24 +2,7 @@ # qmake common configuration for iOS # -MAKEFILE_GENERATOR = UNIX -CONFIG += app_bundle reduce_exports incremental global_init_link_order lib_version_first plugin_no_soname sdk -QMAKE_INCREMENTAL_STYLE = sublib +QMAKE_PLATFORM += ios +QMAKE_MAC_SDK = iphoneos -# FIXME: Transform ios.conf to follow the same inheritance pattern as eg mac.conf and unix.conf -QMAKE_PLATFORM = ios $$QMAKE_PLATFORM - -# Not deploying to Mac OSX -QMAKE_MACOSX_DEPLOYMENT_TARGET = - -# But to iOS -QMAKE_IOS_DEPLOYMENT_TARGET = 4.3 - -# Add iOS common folder to include path -INCLUDEPATH += $$PWD/ios - -# iOS defines -DEFINES += DARWIN_NO_CARBON QT_NO_CORESERVICES QT_NO_PRINTER QT_NO_PRINTDIALOG - -# Universal target (iPhone and iPad) -QMAKE_IOS_TARGETED_DEVICE_FAMILY = 1,2 +include(mac.conf) diff --git a/mkspecs/common/mac.conf b/mkspecs/common/mac.conf index 5f5ed80e4d..5d7cb1a91b 100644 --- a/mkspecs/common/mac.conf +++ b/mkspecs/common/mac.conf @@ -1,34 +1,29 @@ # -# qmake configuration for common Mac OS X +# qmake configuration for common Mac OS (OSX and iOS) # -!load(device_config) { - error(Could not successfully load device configuration) -} -QMAKE_PLATFORM += macx mac +!load(device_config): error(Could not successfully load device configuration) -isEmpty(QMAKE_MAC_SDK): QMAKE_MAC_SDK = macosx +QMAKE_PLATFORM += mac -QMAKE_RESOURCE = /Developer/Tools/Rez - -QMAKE_EXTENSION_SHLIB = dylib - -QMAKE_LIBDIR = +QMAKE_RESOURCE = /Developer/Tools/Rez +QMAKE_EXTENSION_SHLIB = dylib +QMAKE_LIBDIR = # sdk.prf will prefix the proper SDK sysroot QMAKE_INCDIR_OPENGL = \ /System/Library/Frameworks/OpenGL.framework/Headers \ /System/Library/Frameworks/AGL.framework/Headers/ -QMAKE_FIX_RPATH = install_name_tool -id +QMAKE_FIX_RPATH = install_name_tool -id -QMAKE_LFLAGS_RPATH = +QMAKE_LFLAGS_RPATH = -QMAKE_LIBS_DYNLOAD = -QMAKE_LIBS_OPENGL = -framework OpenGL -framework AGL -QMAKE_LIBS_THREAD = +QMAKE_LIBS_DYNLOAD = +QMAKE_LIBS_OPENGL = -framework OpenGL -framework AGL +QMAKE_LIBS_THREAD = -QMAKE_AR = ar cq -QMAKE_RANLIB = ranlib -s +QMAKE_AR = ar cq +QMAKE_RANLIB = ranlib -s include(unix.conf) diff --git a/mkspecs/common/macx.conf b/mkspecs/common/macx.conf new file mode 100644 index 0000000000..eb39d1cf8d --- /dev/null +++ b/mkspecs/common/macx.conf @@ -0,0 +1,8 @@ +# +# qmake configuration for common Mac OS X +# + +QMAKE_PLATFORM += macx +QMAKE_MAC_SDK = macosx + +include(mac.conf) diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf index 428a3a4d43..9aef37472f 100644 --- a/mkspecs/features/create_cmake.prf +++ b/mkspecs/features/create_cmake.prf @@ -69,7 +69,7 @@ CMAKE_MKSPEC = $$[QMAKE_XSPEC] CMAKE_QT_STEM = Qt$$eval(QT.$${MODULE}.MAJOR_VERSION)$${CMAKE_MODULE_NAME}$${QT_LIBINFIX} -macx { +mac { !isEmpty(CMAKE_STATIC_TYPE) { CMAKE_LIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}_debug.a CMAKE_LIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.a diff --git a/mkspecs/features/qmltestcase.prf b/mkspecs/features/qmltestcase.prf index 71e70e06a4..335ba90009 100644 --- a/mkspecs/features/qmltestcase.prf +++ b/mkspecs/features/qmltestcase.prf @@ -2,7 +2,7 @@ CONFIG += testcase QT += qml qmltest -macx: CONFIG -= app_bundle +mac: CONFIG -= app_bundle # If the .pro file specified an IMPORTPATH, then add that to # the command-line when the test is run. diff --git a/mkspecs/features/resolve_target.prf b/mkspecs/features/resolve_target.prf index 8cd12b2a00..22d7722ce3 100644 --- a/mkspecs/features/resolve_target.prf +++ b/mkspecs/features/resolve_target.prf @@ -28,7 +28,7 @@ win32 { } else { contains(TEMPLATE, .*lib):LIBPREFIX = lib - macx { + mac { equals(TEMPLATE, lib) { lib_bundle { QMAKE_RESOLVED_TARGET = $${QMAKE_RESOLVED_TARGET}$${TARGET}.framework/$${TARGET} diff --git a/mkspecs/features/testcase.prf b/mkspecs/features/testcase.prf index faf4eeb124..15febe2dd5 100644 --- a/mkspecs/features/testcase.prf +++ b/mkspecs/features/testcase.prf @@ -32,7 +32,7 @@ contains(MUNGED_TARGET,.*/.*):check.commands = cd $(DESTDIR) && # Allow for a custom test runner script check.commands += $(TESTRUNNER) -macx { +mac { app_bundle: check.commands += ./$(QMAKE_TARGET).app/Contents/MacOS/$(QMAKE_TARGET) else: check.commands += ./$(QMAKE_TARGET) } diff --git a/mkspecs/macx-clang-32/qmake.conf b/mkspecs/macx-clang-32/qmake.conf index 01b4b419c7..6a0b65d641 100644 --- a/mkspecs/macx-clang-32/qmake.conf +++ b/mkspecs/macx-clang-32/qmake.conf @@ -6,8 +6,8 @@ MAKEFILE_GENERATOR = UNIX CONFIG += app_bundle incremental global_init_link_order lib_version_first plugin_no_soname QMAKE_INCREMENTAL_STYLE = sublib -include(../common/mac.conf) -include(../common/gcc-base-macx.conf) +include(../common/macx.conf) +include(../common/gcc-base-mac.conf) include(../common/clang.conf) include(../common/clang-mac.conf) diff --git a/mkspecs/macx-clang-libc++-32/qmake.conf b/mkspecs/macx-clang-libc++-32/qmake.conf index af8039d7c9..4ba249be22 100644 --- a/mkspecs/macx-clang-libc++-32/qmake.conf +++ b/mkspecs/macx-clang-libc++-32/qmake.conf @@ -6,8 +6,8 @@ MAKEFILE_GENERATOR = UNIX CONFIG += app_bundle incremental global_init_link_order lib_version_first plugin_no_soname QMAKE_INCREMENTAL_STYLE = sublib -include(../common/mac.conf) -include(../common/gcc-base-macx.conf) +include(../common/macx.conf) +include(../common/gcc-base-mac.conf) include(../common/clang.conf) include(../common/clang-mac.conf) diff --git a/mkspecs/macx-clang-libc++/qmake.conf b/mkspecs/macx-clang-libc++/qmake.conf index a2d032bf8c..a8858f0b73 100644 --- a/mkspecs/macx-clang-libc++/qmake.conf +++ b/mkspecs/macx-clang-libc++/qmake.conf @@ -6,8 +6,8 @@ MAKEFILE_GENERATOR = UNIX CONFIG += app_bundle incremental global_init_link_order lib_version_first plugin_no_soname QMAKE_INCREMENTAL_STYLE = sublib -include(../common/mac.conf) -include(../common/gcc-base-macx.conf) +include(../common/macx.conf) +include(../common/gcc-base-mac.conf) include(../common/clang.conf) include(../common/clang-mac.conf) diff --git a/mkspecs/macx-clang/qmake.conf b/mkspecs/macx-clang/qmake.conf index d56b7e6f5b..2a6a5a95bc 100644 --- a/mkspecs/macx-clang/qmake.conf +++ b/mkspecs/macx-clang/qmake.conf @@ -6,8 +6,8 @@ MAKEFILE_GENERATOR = UNIX CONFIG += app_bundle incremental global_init_link_order lib_version_first plugin_no_soname QMAKE_INCREMENTAL_STYLE = sublib -include(../common/mac.conf) -include(../common/gcc-base-macx.conf) +include(../common/macx.conf) +include(../common/gcc-base-mac.conf) include(../common/clang.conf) include(../common/clang-mac.conf) diff --git a/mkspecs/macx-g++-32/qmake.conf b/mkspecs/macx-g++-32/qmake.conf index d60c0dc411..aa3df18ec6 100644 --- a/mkspecs/macx-g++-32/qmake.conf +++ b/mkspecs/macx-g++-32/qmake.conf @@ -10,8 +10,8 @@ MAKEFILE_GENERATOR = UNIX CONFIG += app_bundle incremental global_init_link_order lib_version_first plugin_no_soname QMAKE_INCREMENTAL_STYLE = sublib -include(../common/mac.conf) -include(../common/gcc-base-macx.conf) +include(../common/macx.conf) +include(../common/gcc-base-mac.conf) include(../common/g++-macx.conf) QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6 diff --git a/mkspecs/macx-g++/qmake.conf b/mkspecs/macx-g++/qmake.conf index 2797d766b4..c7aa9752d1 100644 --- a/mkspecs/macx-g++/qmake.conf +++ b/mkspecs/macx-g++/qmake.conf @@ -10,8 +10,8 @@ MAKEFILE_GENERATOR = UNIX CONFIG += app_bundle incremental global_init_link_order lib_version_first plugin_no_soname QMAKE_INCREMENTAL_STYLE = sublib -include(../common/mac.conf) -include(../common/gcc-base-macx.conf) +include(../common/macx.conf) +include(../common/gcc-base-mac.conf) include(../common/g++-macx.conf) QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6 diff --git a/mkspecs/macx-g++40/qmake.conf b/mkspecs/macx-g++40/qmake.conf index c2013c7d9c..23aee379a9 100644 --- a/mkspecs/macx-g++40/qmake.conf +++ b/mkspecs/macx-g++40/qmake.conf @@ -10,8 +10,8 @@ MAKEFILE_GENERATOR = UNIX CONFIG += app_bundle incremental global_init_link_order lib_version_first plugin_no_soname QMAKE_INCREMENTAL_STYLE = sublib -include(../common/mac.conf) -include(../common/gcc-base-macx.conf) +include(../common/macx.conf) +include(../common/gcc-base-mac.conf) include(../common/g++-macx.conf) QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6 diff --git a/mkspecs/macx-g++42/qmake.conf b/mkspecs/macx-g++42/qmake.conf index e37b8e0acc..5c1df37027 100644 --- a/mkspecs/macx-g++42/qmake.conf +++ b/mkspecs/macx-g++42/qmake.conf @@ -10,8 +10,8 @@ MAKEFILE_GENERATOR = UNIX CONFIG += app_bundle incremental global_init_link_order lib_version_first plugin_no_soname QMAKE_INCREMENTAL_STYLE = sublib -include(../common/mac.conf) -include(../common/gcc-base-macx.conf) +include(../common/macx.conf) +include(../common/gcc-base-mac.conf) include(../common/g++-macx.conf) QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6 diff --git a/mkspecs/macx-icc/qmake.conf b/mkspecs/macx-icc/qmake.conf index 1aa252a0ed..b85f44d182 100644 --- a/mkspecs/macx-icc/qmake.conf +++ b/mkspecs/macx-icc/qmake.conf @@ -68,6 +68,6 @@ QMAKE_LFLAGS_COMPAT_VERSION = -compatibility_version$${LITERAL_WHITESPACE} QMAKE_CLEAN = -r $(OBJECTS_DIR)/ti_files -include(../common/mac.conf) +include(../common/macx.conf) load(qt_config) diff --git a/mkspecs/macx-llvm/qmake.conf b/mkspecs/macx-llvm/qmake.conf index 96e02dc913..daacd1f00e 100644 --- a/mkspecs/macx-llvm/qmake.conf +++ b/mkspecs/macx-llvm/qmake.conf @@ -10,8 +10,8 @@ MAKEFILE_GENERATOR = UNIX CONFIG += app_bundle incremental global_init_link_order lib_version_first plugin_no_soname QMAKE_INCREMENTAL_STYLE = sublib -include(../common/mac.conf) -include(../common/gcc-base-macx.conf) +include(../common/macx.conf) +include(../common/gcc-base-mac.conf) include(../common/llvm.conf) QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6 diff --git a/mkspecs/macx-xcode/qmake.conf b/mkspecs/macx-xcode/qmake.conf index 819986fd1c..e4ffba0531 100644 --- a/mkspecs/macx-xcode/qmake.conf +++ b/mkspecs/macx-xcode/qmake.conf @@ -7,8 +7,8 @@ MAKEFILE_GENERATOR = XCODE CONFIG += lib_version_first incremental plugin_no_soname app_bundle -include(../common/mac.conf) -include(../common/gcc-base-macx.conf) +include(../common/macx.conf) +include(../common/gcc-base-mac.conf) include(../common/g++-macx.conf) QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6 diff --git a/mkspecs/unsupported/macx-ios-clang/qmake.conf b/mkspecs/unsupported/macx-ios-clang/qmake.conf index 3cb68d495a..7805c079bb 100644 --- a/mkspecs/unsupported/macx-ios-clang/qmake.conf +++ b/mkspecs/unsupported/macx-ios-clang/qmake.conf @@ -2,24 +2,26 @@ # qmake configuration for macx-ios-clang # -!load(device_config): error("Could not successfully load device configuration.") +MAKEFILE_GENERATOR = UNIX +CONFIG += app_bundle reduce_exports incremental global_init_link_order lib_version_first plugin_no_soname sdk +QMAKE_INCREMENTAL_STYLE = sublib -isEmpty(QMAKE_MAC_SDK): QMAKE_MAC_SDK = iphoneos +QMAKE_MACOSX_DEPLOYMENT_TARGET = +QMAKE_IOS_DEPLOYMENT_TARGET = 4.3 -# iOS is considered a variant of MacOS by Apple. We follow this to -# keep things simple, e.g. by defining Q_OS_MAC _and_ Q_OS_IOS. -include(../../common/mac.conf) - -include(../../common/gcc-base-ios.conf) -include(../../common/xcode.conf) -include(../../common/clang.conf) -include(../../common/clang-mac.conf) +INCLUDEPATH += $$PWD/ios +DEFINES += DARWIN_NO_CARBON QT_NO_CORESERVICES QT_NO_PRINTER QT_NO_PRINTDIALOG +# Universal target (iPhone and iPad) +QMAKE_IOS_TARGETED_DEVICE_FAMILY = 1,2 -# Version check +include(../../common/xcode.conf) lessThan(QMAKE_XCODE_VERSION, "4.3"): error("This mkspec requires Xcode 4.3 or later") include(../../common/ios.conf) +include(../../common/gcc-base-mac.conf) +include(../../common/clang.conf) +include(../../common/clang-mac.conf) include(../../common/ios/clang.conf) include(../../common/ios/qmake.conf) diff --git a/mkspecs/unsupported/macx-ios-clang/qplatformdefs.h b/mkspecs/unsupported/macx-ios-clang/qplatformdefs.h index 5f80a17860..581ad0d485 100644 --- a/mkspecs/unsupported/macx-ios-clang/qplatformdefs.h +++ b/mkspecs/unsupported/macx-ios-clang/qplatformdefs.h @@ -39,4 +39,4 @@ ** ****************************************************************************/ -#include "../../common/ios/qplatformdefs.h" +#include "../../common/mac/qplatformdefs.h" diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index a4af8b8899..383d9c9c6e 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -157,6 +157,10 @@ # define Q_CC_CLANG # define Q_ASSUME_IMPL(expr) if (expr){} else __builtin_unreachable() # define Q_UNREACHABLE_IMPL() __builtin_unreachable() +# if !defined(__has_extension) +# /* Compatibility with older Clang versions */ +# define __has_extension __has_feature +# endif # else /* Plain GCC */ # if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index a52386def1..3f100593bb 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -117,12 +117,12 @@ win32 { io/qprocess_unix.cpp \ io/qfilesystemiterator_unix.cpp \ - !nacl:macx-*: { + !nacl:mac: { SOURCES += io/qfilesystemengine_mac.cpp SOURCES += io/qsettings_mac.cpp } - macx-*: { - !ios { + mac { + macx { SOURCES += io/qstandardpaths_mac.cpp } else { SOURCES += io/qstandardpaths_unix.cpp @@ -139,7 +139,7 @@ win32 { } !nacl { - freebsd-*|macx-*|darwin-*|openbsd-*:{ + freebsd-*|mac|darwin-*|openbsd-*:{ SOURCES += io/qfilesystemwatcher_kqueue.cpp HEADERS += io/qfilesystemwatcher_kqueue_p.h } diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 8409e7e479..3993cf5002 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -458,6 +458,9 @@ void QProcessPrivate::Channel::clear() the program you want to run as arguments to start(). Arguments are supplied as individual strings in a QStringList. + Alternatively, you can set the program to run with setProgram() + and setArguments(), and then call start() or open(). + For example, the following code snippet runs the analog clock example in the Fusion style on X11 platforms by passing strings containing "-style" and "fusion" as two items in the list of @@ -1946,6 +1949,58 @@ void QProcess::start(const QString &program, const QStringList &arguments, OpenM return; } + d->program = program; + d->arguments = arguments; + + open(mode); +} + +/*! + \since 5.1 + \overload + + Starts the program set by setProgram() with arguments set by setArguments(). + The OpenMode is set to \a mode. + + This method is a convenient alias to open(). + + \sa open(), setProgram(), setArguments() + */ +void QProcess::start(OpenMode mode) +{ + open(mode); +} + +/*! + Starts the program set by setProgram() in a new process, if none is already + running, passing the command line arguments set by setArguments(). The OpenMode + is set to \a mode. + + The QProcess object will immediately enter the Starting state. If the + process starts successfully, QProcess will emit started(); otherwise, + error() will be emitted. If the QProcess object is already running a + process, a warning may be printed at the console, the function will return false, + and the existing process will continue running. + + \note Processes are started asynchronously, which means the started() + and error() signals may be delayed. Call waitForStarted() to make + sure the process has started (or has failed to start) and those signals + have been emitted. In this regard, a true return value merly means the process + was correcty initialized, not that the program was actually started. + +*/ +bool QProcess::open(OpenMode mode) +{ + Q_D(QProcess); + if (d->processState != NotRunning) { + qWarning("QProcess::start: Process is already running"); + return false; + } + if (d->program.isEmpty()) { + qWarning("QProcess::start: program not set"); + return false; + } + #if defined QPROCESS_DEBUG qDebug() << "QProcess::start(" << program << ',' << arguments << ',' << mode << ')'; #endif @@ -1967,14 +2022,13 @@ void QProcess::start(const QString &program, const QStringList &arguments, OpenM d->stdoutChannel.closed = false; d->stderrChannel.closed = false; - d->program = program; - d->arguments = arguments; - d->exitCode = 0; d->exitStatus = NormalExit; d->processError = QProcess::UnknownError; d->errorString.clear(); d->startProcess(); + + return true; } @@ -2074,6 +2128,24 @@ QString QProcess::program() const } /*! + \since 5.1 + + Set the \a program to use when starting the process. + That function must be call before open() + + \sa start(), setArguments(), program() +*/ +void QProcess::setProgram(const QString &program) +{ + Q_D(QProcess); + if (d->processState != NotRunning) { + qWarning("QProcess::setProgram: Process is already running"); + return; + } + d->program = program; +} + +/*! Returns the command line arguments the process was last started with. \sa start() @@ -2085,6 +2157,24 @@ QStringList QProcess::arguments() const } /*! + \since 5.1 + + Set the \a arguments to pass to the called program when starting the process. + That function must be call before open() + + \sa start(), setProgram(), arguments() +*/ +void QProcess::setArguments(const QStringList &arguments) +{ + Q_D(QProcess); + if (d->processState != NotRunning) { + qWarning("QProcess::setProgram: Process is already running"); + return; + } + d->arguments = arguments; +} + +/*! Attempts to terminate the process. The process may not exit as a result of calling this function (it is given diff --git a/src/corelib/io/qprocess.h b/src/corelib/io/qprocess.h index e8ebadf101..29adf37f74 100644 --- a/src/corelib/io/qprocess.h +++ b/src/corelib/io/qprocess.h @@ -136,8 +136,14 @@ public: void start(const QString &program, const QStringList &arguments, OpenMode mode = ReadWrite); void start(const QString &command, OpenMode mode = ReadWrite); + void start(OpenMode mode = ReadWrite); + bool open(OpenMode mode = ReadWrite) Q_DECL_OVERRIDE; + QString program() const; + void setProgram(const QString &program); + QStringList arguments() const; + void setArguments(const QStringList & arguments); ProcessChannelMode readChannelMode() const; void setReadChannelMode(ProcessChannelMode mode); diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 1696aeb77b..46de52ec9f 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -300,13 +300,6 @@ struct QCoreApplicationData { #ifndef QT_NO_LIBRARY delete app_libpaths; #endif - - // cleanup the QAdoptedThread created for the main() thread - if (QCoreApplicationPrivate::theMainThread) { - QThreadData *data = QThreadData::get2(QCoreApplicationPrivate::theMainThread); - QCoreApplicationPrivate::theMainThread = 0; - data->deref(); // deletes the data and the adopted thread - } } #ifdef Q_OS_BLACKBERRY diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index bd8c6341c1..79199c97e0 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -76,6 +76,7 @@ QThreadData::~QThreadData() // the problem... if (this->thread == QCoreApplicationPrivate::theMainThread) { QCoreApplicationPrivate::theMainThread = 0; + QThreadData::clearCurrentThreadData(); } QThread *t = thread; diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h index 526633cafa..2cf988260f 100644 --- a/src/corelib/thread/qthread_p.h +++ b/src/corelib/thread/qthread_p.h @@ -223,6 +223,7 @@ public: ~QThreadData(); static QThreadData *current(); + static void clearCurrentThreadData(); static QThreadData *get2(QThread *thread) { Q_ASSERT_X(thread != 0, "QThread", "internal error"); return thread->d_func()->data; } diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index 8104cc8938..44ad8d3ac2 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -204,6 +204,11 @@ static void clear_thread_data() pthread_setspecific(current_thread_data_key, 0); } +void QThreadData::clearCurrentThreadData() +{ + clear_thread_data(); +} + QThreadData *QThreadData::current() { QThreadData *data = get_thread_data(); diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp index 8614330d6f..0cf903bb3a 100644 --- a/src/corelib/thread/qthread_win.cpp +++ b/src/corelib/thread/qthread_win.cpp @@ -96,6 +96,11 @@ Q_DESTRUCTOR_FUNCTION(qt_free_tls) /* QThreadData */ +void QThreadData::clearCurrentThreadData() +{ + TlsSetValue(qt_current_thread_data_tls_index, 0); +} + QThreadData *QThreadData::current() { qt_create_tls(); diff --git a/src/corelib/thread/thread.pri b/src/corelib/thread/thread.pri index 7247f2984e..13f0502b62 100644 --- a/src/corelib/thread/thread.pri +++ b/src/corelib/thread/thread.pri @@ -56,7 +56,7 @@ integrity:SOURCES += thread/qmutex_unix.cpp \ thread/qwaitcondition_unix.cpp unix: { - macx-* { + mac { SOURCES += thread/qmutex_mac.cpp } else:linux-*:!linux-lsb-* { SOURCES += thread/qmutex_linux.cpp diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h index f7f30ea0d5..6199cdb19b 100644 --- a/src/corelib/tools/qlocale.h +++ b/src/corelib/tools/qlocale.h @@ -206,7 +206,7 @@ public: Turkish = 125, Turkmen = 126, Tahitian = 127, - Uigur = 128, + Uighur = 128, Ukrainian = 129, Urdu = 130, Uzbek = 131, @@ -339,6 +339,57 @@ public: Kako = 258, Meta = 259, Ngiemboon = 260, + Aragonese = 261, + Akkadian = 262, + AncientEgyptian = 263, + AncientGreek = 264, + Aramaic = 265, + Balinese = 266, + Bamun = 267, + BatakToba = 268, + Buginese = 269, + Buhid = 270, + Carian = 271, + Chakma = 272, + ClassicalMandaic = 273, + Coptic = 274, + Dogri = 275, + EasternCham = 276, + EasternKayah = 277, + Etruscan = 278, + Gothic = 279, + Hanunoo = 280, + Ingush = 281, + LargeFloweryMiao = 282, + Lepcha = 283, + Limbu = 284, + Lisu = 285, + Lu = 286, + Lycian = 287, + Lydian = 288, + Mandingo = 289, + Manipuri = 290, + Meroitic = 291, + NorthernThai = 292, + OldIrish = 293, + OldNorse = 294, + OldPersian = 295, + OldTurkish = 296, + Pahlavi = 297, + Parthian = 298, + Phoenician = 299, + PrakritLanguage = 300, + Rejang = 301, + Sabaean = 302, + Samaritan = 303, + Santali = 304, + Saurashtra = 305, + Sora = 306, + Sylheti = 307, + Tagbanwa = 308, + TaiDam = 309, + TaiNua = 310, + Ugaritic = 311, Norwegian = NorwegianBokmal, Moldavian = Romanian, SerboCroatian = Serbian, @@ -352,7 +403,8 @@ public: RhaetoRomance = Romansh, Chewa = Nyanja, Frisian = WesternFrisian, - LastLanguage = Ngiemboon + Uigur = Uighur, + LastLanguage = Ugaritic }; enum Script { @@ -392,9 +444,76 @@ public: SyriacScript = 33, YiScript = 34, VaiScript = 35, + AvestanScript = 36, + BalineseScript = 37, + BamumScript = 38, + BatakScript = 39, + BopomofoScript = 40, + BrahmiScript = 41, + BugineseScript = 42, + BuhidScript = 43, + CanadianAboriginalScript = 44, + CarianScript = 45, + ChakmaScript = 46, + ChamScript = 47, + CopticScript = 48, + CypriotScript = 49, + EgyptianHieroglyphsScript = 50, + FraserScript = 51, + GlagoliticScript = 52, + GothicScript = 53, + HanScript = 54, + HangulScript = 55, + HanunooScript = 56, + ImperialAramaicScript = 57, + InscriptionalPahlaviScript = 58, + InscriptionalParthianScript = 59, + JavaneseScript = 60, + KaithiScript = 61, + KatakanaScript = 62, + KayahLiScript = 63, + KharoshthiScript = 64, + LannaScript = 65, + LepchaScript = 66, + LimbuScript = 67, + LinearBScript = 68, + LycianScript = 69, + LydianScript = 70, + MandaeanScript = 71, + MeiteiMayekScript = 72, + MeroiticScript = 73, + MeroiticCursiveScript = 74, + NkoScript = 75, + NewTaiLueScript = 76, + OghamScript = 77, + OlChikiScript = 78, + OldItalicScript = 79, + OldPersianScript = 80, + OldSouthArabianScript = 81, + OrkhonScript = 82, + OsmanyaScript = 83, + PhagsPaScript = 84, + PhoenicianScript = 85, + PollardPhoneticScript = 86, + RejangScript = 87, + RunicScript = 88, + SamaritanScript = 89, + SaurashtraScript = 90, + SharadaScript = 91, + ShavianScript = 92, + SoraSompengScript = 93, + CuneiformScript = 94, + SundaneseScript = 95, + SylotiNagriScript = 96, + TagalogScript = 97, + TagbanwaScript = 98, + TaiLeScript = 99, + TaiVietScript = 100, + TakriScript = 101, + UgariticScript = 102, SimplifiedChineseScript = SimplifiedHanScript, TraditionalChineseScript = TraditionalHanScript, - LastScript = VaiScript + LastScript = UgariticScript }; enum Country { AnyCountry = 0, diff --git a/src/corelib/tools/qlocale.qdoc b/src/corelib/tools/qlocale.qdoc index 8c76833fc1..770c72e476 100644 --- a/src/corelib/tools/qlocale.qdoc +++ b/src/corelib/tools/qlocale.qdoc @@ -289,7 +289,8 @@ \value Turkish \value Turkmen \value Twi Obsolete, please use Akan - \value Uigur + \value Uighur + \value Uigur Obsolete, please use Uighur \value Ukrainian \value Urdu \value Uzbek @@ -401,6 +402,57 @@ \value Kako \value Meta \value Ngiemboon + \value Aragonese + \value Akkadian + \value AncientEgyptian + \value AncientGreek + \value Aramaic + \value Balinese + \value Bamun + \value BatakToba + \value Buginese + \value Buhid + \value Carian + \value Chakma + \value ClassicalMandaic + \value Coptic + \value Dogri + \value EasternCham + \value EasternKayah + \value Etruscan + \value Gothic + \value Hanunoo + \value Ingush + \value LargeFloweryMiao + \value Lepcha + \value Limbu + \value Lisu + \value Lu + \value Lycian + \value Lydian + \value Mandingo + \value Manipuri + \value Meroitic + \value NorthernThai + \value OldIrish + \value OldNorse + \value OldPersian + \value OldTurkish + \value Pahlavi + \value Parthian + \value Phoenician + \value PrakritLanguage + \value Rejang + \value Sabaean + \value Samaritan + \value Santali + \value Saurashtra + \value Sora + \value Sylheti + \value Tagbanwa + \value TaiDam + \value TaiNua + \value Ugaritic \omitvalue LastLanguage \sa language(), languageToString() @@ -686,42 +738,109 @@ \value AnyScript \value ArabicScript - \value CyrillicScript - \value DeseretScript - \value GurmukhiScript - \value SimplifiedHanScript same as SimplifiedChineseScript - \value SimplifiedChineseScript same as SimplifiedHanScript - \value TraditionalHanScript same as TraditionalChineseScript - \value TraditionalChineseScript same as TraditionalHanScript - \value LatinScript - \value MongolianScript - \value TifinaghScript \value ArmenianScript + \value AvestanScript + \value BalineseScript + \value BamumScript + \value BatakScript \value BengaliScript + \value BopomofoScript + \value BrahmiScript + \value BugineseScript + \value BuhidScript + \value CanadianAboriginalScript + \value CarianScript + \value ChakmaScript + \value ChamScript \value CherokeeScript + \value CopticScript + \value CypriotScript + \value CyrillicScript + \value DeseretScript \value DevanagariScript + \value EgyptianHieroglyphsScript \value EthiopicScript + \value FraserScript \value GeorgianScript + \value GlagoliticScript + \value GothicScript \value GreekScript \value GujaratiScript + \value GurmukhiScript + \value HanScript + \value HangulScript + \value HanunooScript \value HebrewScript + \value ImperialAramaicScript + \value InscriptionalPahlaviScript + \value InscriptionalParthianScript \value JapaneseScript - \value KhmerScript + \value JavaneseScript + \value KaithiScript \value KannadaScript + \value KatakanaScript + \value KayahLiScript + \value KharoshthiScript + \value KhmerScript \value KoreanScript + \value LannaScript \value LaoScript + \value LatinScript + \value LepchaScript + \value LimbuScript + \value LinearBScript + \value LycianScript + \value LydianScript \value MalayalamScript + \value MandaeanScript + \value MeiteiMayekScript + \value MeroiticScript + \value MeroiticCursiveScript + \value MongolianScript \value MyanmarScript + \value NkoScript + \value NewTaiLueScript + \value OghamScript + \value OlChikiScript + \value OldItalicScript + \value OldPersianScript + \value OldSouthArabianScript \value OriyaScript + \value OrkhonScript + \value OsmanyaScript + \value PhagsPaScript + \value PhoenicianScript + \value PollardPhoneticScript + \value RejangScript + \value RunicScript + \value SamaritanScript + \value SaurashtraScript + \value SharadaScript + \value ShavianScript + \value SimplifiedHanScript same as SimplifiedChineseScript + \value SimplifiedChineseScript same as SimplifiedHanScript + \value SinhalaScript + \value SoraSompengScript + \value CuneiformScript + \value SundaneseScript + \value SylotiNagriScript + \value SyriacScript + \value TagalogScript + \value TagbanwaScript + \value TaiLeScript + \value TaiVietScript + \value TakriScript \value TamilScript \value TeluguScript \value ThaanaScript \value ThaiScript \value TibetanScript - \value SinhalaScript - \value SyriacScript - \value YiScript + \value TifinaghScript + \value TraditionalHanScript same as TraditionalChineseScript + \value TraditionalChineseScript same as TraditionalHanScript + \value UgariticScript \value VaiScript + \value YiScript \omitvalue LastScript \sa script(), scriptToString(), languageToString() diff --git a/src/corelib/tools/qlocale_data_p.h b/src/corelib/tools/qlocale_data_p.h index c7e9e83dbd..1f1a6ef4c7 100644 --- a/src/corelib/tools/qlocale_data_p.h +++ b/src/corelib/tools/qlocale_data_p.h @@ -77,7 +77,7 @@ static const int ImperialMeasurementSystemsCount = // GENERATED PART STARTS HERE /* - This part of the file was generated on 2012-11-23 from the + This part of the file was generated on 2012-12-19 from the Common Locale Data Repository v22.1 http://www.unicode.org/cldr/ @@ -172,6 +172,7 @@ static const QLocaleId likely_subtags[] = { { 52, 0, 0 }, { 52, 7, 101 }, // id -> id_Latn_ID { 149, 0, 0 }, { 149, 7, 157 }, // ig -> ig_Latn_NG { 168, 0, 0 }, { 168, 34, 44 }, // ii -> ii_Yiii_CN + { 281, 0, 0 }, { 281, 2, 178 }, // inh -> inh_Cyrl_RU { 51, 0, 0 }, { 51, 7, 99 }, // is -> is_Latn_IS { 58, 0, 0 }, { 58, 7, 106 }, // it -> it_Latn_IT { 59, 0, 0 }, { 59, 19, 108 }, // ja -> ja_Jpan_JP @@ -273,6 +274,7 @@ static const QLocaleId likely_subtags[] = { { 99, 0, 0 }, { 99, 13, 100 }, // sa -> sa_Deva_IN { 248, 0, 0 }, { 248, 2, 178 }, // sah -> sah_Cyrl_RU { 179, 0, 0 }, { 179, 7, 111 }, // saq -> saq_Latn_KE + { 304, 0, 0 }, { 304, 7, 100 }, // sat -> sat_Latn_IN { 249, 0, 0 }, { 249, 7, 210 }, // sbp -> sbp_Latn_TZ { 105, 0, 0 }, { 105, 1, 100 }, // sd -> sd_Arab_IN { 173, 0, 0 }, { 173, 7, 161 }, // se -> se_Latn_NO @@ -334,7 +336,9 @@ static const QLocaleId likely_subtags[] = { { 0, 1, 100 }, { 130, 1, 100 }, // und_Arab_IN -> ur_Arab_IN { 0, 1, 157 }, { 47, 1, 157 }, // und_Arab_NG -> ha_Arab_NG { 0, 1, 163 }, { 130, 1, 163 }, // und_Arab_PK -> ur_Arab_PK + { 0, 57, 0 }, { 265, 57, 102 }, // und_Armi -> arc_Armi_IR { 0, 10, 0 }, { 9, 10, 11 }, // und_Armn -> hy_Armn_AM + { 0, 36, 0 }, { 255, 36, 102 }, // und_Avst -> ae_Avst_IR { 0, 0, 27 }, { 142, 7, 27 }, // und_BA -> bs_Latn_BA { 0, 0, 18 }, { 15, 11, 18 }, // und_BD -> bn_Beng_BD { 0, 0, 21 }, { 30, 7, 21 }, // und_BE -> nl_Latn_BE @@ -349,7 +353,14 @@ static const QLocaleId likely_subtags[] = { { 0, 0, 30 }, { 91, 7, 30 }, // und_BR -> pt_Latn_BR { 0, 0, 25 }, { 16, 31, 25 }, // und_BT -> dz_Tibt_BT { 0, 0, 20 }, { 22, 2, 20 }, // und_BY -> be_Cyrl_BY + { 0, 37, 0 }, { 266, 37, 101 }, // und_Bali -> ban_Bali_ID + { 0, 38, 0 }, { 267, 38, 37 }, // und_Bamu -> bax_Bamu_CM + { 0, 39, 0 }, { 268, 39, 101 }, // und_Batk -> bbc_Batk_ID { 0, 11, 0 }, { 15, 11, 18 }, // und_Beng -> bn_Beng_BD + { 0, 40, 0 }, { 25, 40, 208 }, // und_Bopo -> zh_Bopo_TW + { 0, 41, 0 }, { 300, 41, 100 }, // und_Brah -> pra_Brah_IN + { 0, 42, 0 }, { 269, 42, 101 }, // und_Bugi -> bug_Bugi_ID + { 0, 43, 0 }, { 270, 43, 170 }, // und_Buhd -> bku_Buhd_PH { 0, 0, 49 }, { 113, 7, 49 }, // und_CD -> sw_Latn_CD { 0, 0, 41 }, { 37, 7, 41 }, // und_CF -> fr_Latn_CF { 0, 0, 50 }, { 37, 7, 50 }, // und_CG -> fr_Latn_CG @@ -365,7 +376,13 @@ static const QLocaleId likely_subtags[] = { { 0, 0, 39 }, { 91, 7, 39 }, // und_CV -> pt_Latn_CV { 0, 0, 56 }, { 43, 16, 56 }, // und_CY -> el_Grek_CY { 0, 0, 57 }, { 28, 7, 57 }, // und_CZ -> cs_Latn_CZ + { 0, 46, 0 }, { 272, 46, 18 }, // und_Cakm -> ccp_Cakm_BD + { 0, 44, 0 }, { 221, 44, 38 }, // und_Cans -> cr_Cans_CA + { 0, 45, 0 }, { 271, 45, 217 }, // und_Cari -> xcr_Cari_TR + { 0, 47, 0 }, { 276, 47, 232 }, // und_Cham -> cjm_Cham_VN { 0, 12, 0 }, { 190, 12, 225 }, // und_Cher -> chr_Cher_US + { 0, 48, 0 }, { 274, 48, 64 }, // und_Copt -> cop_Copt_EG + { 0, 49, 0 }, { 264, 49, 56 }, // und_Cprt -> grc_Cprt_CY { 0, 2, 0 }, { 96, 2, 178 }, // und_Cyrl -> ru_Cyrl_RU { 0, 2, 27 }, { 100, 2, 27 }, // und_Cyrl_BA -> sr_Cyrl_BA { 0, 2, 81 }, { 2, 2, 81 }, // und_Cyrl_GE -> ab_Cyrl_GE @@ -382,6 +399,7 @@ static const QLocaleId likely_subtags[] = { { 0, 0, 236 }, { 8, 1, 236 }, // und_EH -> ar_Arab_EH { 0, 0, 67 }, { 122, 14, 67 }, // und_ER -> ti_Ethi_ER { 0, 0, 197 }, { 111, 7, 197 }, // und_ES -> es_Latn_ES + { 0, 50, 0 }, { 263, 50, 64 }, // und_Egyp -> egy_Egyp_EG { 0, 14, 0 }, { 7, 14, 69 }, // und_Ethi -> am_Ethi_ET { 0, 0, 73 }, { 36, 7, 73 }, // und_FI -> fi_Latn_FI { 0, 0, 71 }, { 34, 7, 71 }, // und_FO -> fo_Latn_FO @@ -398,6 +416,8 @@ static const QLocaleId likely_subtags[] = { { 0, 0, 90 }, { 111, 7, 90 }, // und_GT -> es_Latn_GT { 0, 0, 92 }, { 91, 7, 92 }, // und_GW -> pt_Latn_GW { 0, 15, 0 }, { 41, 15, 81 }, // und_Geor -> ka_Geor_GE + { 0, 52, 0 }, { 219, 52, 33 }, // und_Glag -> cu_Glag_BG + { 0, 53, 0 }, { 279, 53, 222 }, // und_Goth -> got_Goth_UA { 0, 16, 0 }, { 43, 16, 85 }, // und_Grek -> el_Grek_GR { 0, 17, 0 }, { 46, 17, 100 }, // und_Gujr -> gu_Gujr_IN { 0, 4, 0 }, { 92, 4, 100 }, // und_Guru -> pa_Guru_IN @@ -406,6 +426,9 @@ static const QLocaleId likely_subtags[] = { { 0, 0, 54 }, { 27, 7, 54 }, // und_HR -> hr_Latn_HR { 0, 0, 94 }, { 222, 7, 94 }, // und_HT -> ht_Latn_HT { 0, 0, 98 }, { 50, 7, 98 }, // und_HU -> hu_Latn_HU + { 0, 55, 0 }, { 66, 55, 114 }, // und_Hang -> ko_Hang_KR + { 0, 54, 0 }, { 25, 5, 44 }, // und_Hani -> zh_Hans_CN + { 0, 56, 0 }, { 280, 56, 170 }, // und_Hano -> hnn_Hano_PH { 0, 5, 0 }, { 25, 5, 44 }, // und_Hans -> zh_Hans_CN { 0, 6, 0 }, { 25, 6, 208 }, // und_Hant -> zh_Hant_TW { 0, 18, 0 }, { 48, 18, 105 }, // und_Hebr -> he_Hebr_IL @@ -417,8 +440,10 @@ static const QLocaleId likely_subtags[] = { { 0, 0, 102 }, { 89, 1, 102 }, // und_IR -> fa_Arab_IR { 0, 0, 99 }, { 51, 7, 99 }, // und_IS -> is_Latn_IS { 0, 0, 106 }, { 58, 7, 106 }, // und_IT -> it_Latn_IT + { 0, 79, 0 }, { 278, 79, 106 }, // und_Ital -> ett_Ital_IT { 0, 0, 109 }, { 8, 1, 109 }, // und_JO -> ar_Arab_JO { 0, 0, 108 }, { 59, 19, 108 }, // und_JP -> ja_Jpan_JP + { 0, 60, 0 }, { 60, 60, 101 }, // und_Java -> jv_Java_ID { 0, 19, 0 }, { 59, 19, 108 }, // und_Jpan -> ja_Jpan_JP { 0, 0, 116 }, { 65, 2, 116 }, // und_KG -> ky_Cyrl_KG { 0, 0, 36 }, { 23, 20, 36 }, // und_KH -> km_Khmr_KH @@ -427,9 +452,13 @@ static const QLocaleId likely_subtags[] = { { 0, 0, 114 }, { 66, 22, 114 }, // und_KR -> ko_Kore_KR { 0, 0, 115 }, { 8, 1, 115 }, // und_KW -> ar_Arab_KW { 0, 0, 110 }, { 96, 2, 110 }, // und_KZ -> ru_Cyrl_KZ + { 0, 63, 0 }, { 277, 63, 147 }, // und_Kali -> eky_Kali_MM + { 0, 62, 0 }, { 59, 62, 108 }, // und_Kana -> ja_Kana_JP + { 0, 64, 0 }, { 300, 64, 163 }, // und_Khar -> pra_Khar_PK { 0, 20, 0 }, { 23, 20, 36 }, // und_Khmr -> km_Khmr_KH { 0, 21, 0 }, { 61, 21, 100 }, // und_Knda -> kn_Knda_IN { 0, 22, 0 }, { 66, 22, 114 }, // und_Kore -> ko_Kore_KR + { 0, 61, 0 }, { 17, 61, 100 }, // und_Kthi -> bh_Kthi_IN { 0, 0, 117 }, { 69, 23, 117 }, // und_LA -> lo_Laoo_LA { 0, 0, 119 }, { 8, 1, 119 }, // und_LB -> ar_Arab_LB { 0, 0, 123 }, { 42, 7, 123 }, // und_LI -> de_Latn_LI @@ -439,6 +468,7 @@ static const QLocaleId likely_subtags[] = { { 0, 0, 125 }, { 37, 7, 125 }, // und_LU -> fr_Latn_LU { 0, 0, 118 }, { 71, 7, 118 }, // und_LV -> lv_Latn_LV { 0, 0, 122 }, { 8, 1, 122 }, // und_LY -> ar_Arab_LY + { 0, 65, 0 }, { 292, 65, 211 }, // und_Lana -> nod_Lana_TH { 0, 23, 0 }, { 69, 23, 117 }, // und_Laoo -> lo_Laoo_LA { 0, 7, 44 }, { 139, 7, 44 }, // und_Latn_CN -> za_Latn_CN { 0, 7, 56 }, { 125, 7, 56 }, // und_Latn_CY -> tr_Latn_CY @@ -450,6 +480,12 @@ static const QLocaleId likely_subtags[] = { { 0, 7, 136 }, { 37, 7, 136 }, // und_Latn_MR -> fr_Latn_MR { 0, 7, 207 }, { 37, 7, 207 }, // und_Latn_SY -> fr_Latn_SY { 0, 7, 216 }, { 37, 7, 216 }, // und_Latn_TN -> fr_Latn_TN + { 0, 66, 0 }, { 283, 66, 100 }, // und_Lepc -> lep_Lepc_IN + { 0, 67, 0 }, { 284, 67, 100 }, // und_Limb -> lif_Limb_IN + { 0, 68, 0 }, { 264, 68, 85 }, // und_Linb -> grc_Linb_GR + { 0, 51, 0 }, { 285, 51, 44 }, // und_Lisu -> lis_Lisu_CN + { 0, 69, 0 }, { 287, 69, 217 }, // und_Lyci -> xlc_Lyci_TR + { 0, 70, 0 }, { 288, 70, 217 }, // und_Lydi -> xld_Lydi_TR { 0, 0, 145 }, { 8, 1, 145 }, // und_MA -> ar_Arab_MA { 0, 0, 142 }, { 37, 7, 142 }, // und_MC -> fr_Latn_MC { 0, 0, 141 }, { 95, 7, 141 }, // und_MD -> ro_Latn_MD @@ -469,8 +505,12 @@ static const QLocaleId likely_subtags[] = { { 0, 0, 139 }, { 111, 7, 139 }, // und_MX -> es_Latn_MX { 0, 0, 130 }, { 76, 7, 130 }, // und_MY -> ms_Latn_MY { 0, 0, 146 }, { 91, 7, 146 }, // und_MZ -> pt_Latn_MZ + { 0, 71, 0 }, { 273, 71, 102 }, // und_Mand -> myz_Mand_IR + { 0, 74, 0 }, { 291, 74, 201 }, // und_Merc -> xmr_Merc_SD + { 0, 73, 0 }, { 291, 73, 201 }, // und_Mero -> xmr_Mero_SD { 0, 24, 0 }, { 77, 24, 100 }, // und_Mlym -> ml_Mlym_IN { 0, 8, 0 }, { 82, 8, 44 }, // und_Mong -> mn_Mong_CN + { 0, 72, 0 }, { 290, 72, 100 }, // und_Mtei -> mni_Mtei_IN { 0, 25, 0 }, { 21, 25, 147 }, // und_Mymr -> my_Mymr_MM { 0, 0, 148 }, { 228, 7, 148 }, // und_NA -> kj_Latn_NA { 0, 0, 153 }, { 37, 7, 153 }, // und_NC -> fr_Latn_NC @@ -479,8 +519,13 @@ static const QLocaleId likely_subtags[] = { { 0, 0, 151 }, { 30, 7, 151 }, // und_NL -> nl_Latn_NL { 0, 0, 161 }, { 85, 7, 161 }, // und_NO -> nb_Latn_NO { 0, 0, 150 }, { 84, 13, 150 }, // und_NP -> ne_Deva_NP + { 0, 75, 0 }, { 289, 75, 91 }, // und_Nkoo -> man_Nkoo_GN { 0, 0, 162 }, { 8, 1, 162 }, // und_OM -> ar_Arab_OM + { 0, 77, 0 }, { 293, 77, 104 }, // und_Ogam -> sga_Ogam_IE + { 0, 78, 0 }, { 304, 78, 100 }, // und_Olck -> sat_Olck_IN + { 0, 82, 0 }, { 296, 82, 143 }, // und_Orkh -> otk_Orkh_MN { 0, 26, 0 }, { 87, 26, 100 }, // und_Orya -> or_Orya_IN + { 0, 83, 0 }, { 110, 83, 194 }, // und_Osma -> so_Osma_SO { 0, 0, 166 }, { 111, 7, 166 }, // und_PA -> es_Latn_PA { 0, 0, 169 }, { 111, 7, 169 }, // und_PE -> es_Latn_PE { 0, 0, 77 }, { 37, 7, 77 }, // und_PF -> fr_Latn_PF @@ -492,12 +537,18 @@ static const QLocaleId likely_subtags[] = { { 0, 0, 165 }, { 8, 1, 165 }, // und_PS -> ar_Arab_PS { 0, 0, 173 }, { 91, 7, 173 }, // und_PT -> pt_Latn_PT { 0, 0, 168 }, { 45, 7, 168 }, // und_PY -> gn_Latn_PY + { 0, 58, 0 }, { 297, 58, 102 }, // und_Phli -> pal_Phli_IR + { 0, 85, 0 }, { 299, 85, 119 }, // und_Phnx -> phn_Phnx_LB + { 0, 86, 0 }, { 282, 86, 44 }, // und_Plrd -> hmd_Plrd_CN + { 0, 59, 0 }, { 298, 59, 102 }, // und_Prti -> xpr_Prti_IR { 0, 0, 175 }, { 8, 1, 175 }, // und_QA -> ar_Arab_QA { 0, 0, 176 }, { 37, 7, 176 }, // und_RE -> fr_Latn_RE { 0, 0, 177 }, { 95, 7, 177 }, // und_RO -> ro_Latn_RO { 0, 0, 243 }, { 100, 2, 243 }, // und_RS -> sr_Cyrl_RS { 0, 0, 178 }, { 96, 2, 178 }, // und_RU -> ru_Cyrl_RU { 0, 0, 179 }, { 64, 7, 179 }, // und_RW -> rw_Latn_RW + { 0, 87, 0 }, { 301, 87, 101 }, // und_Rjng -> rej_Rjng_ID + { 0, 88, 0 }, { 294, 88, 205 }, // und_Runr -> non_Runr_SE { 0, 0, 186 }, { 8, 1, 186 }, // und_SA -> ar_Arab_SA { 0, 0, 188 }, { 37, 7, 188 }, // und_SC -> fr_Latn_SC { 0, 0, 201 }, { 8, 1, 201 }, // und_SD -> ar_Arab_SD @@ -512,7 +563,16 @@ static const QLocaleId likely_subtags[] = { { 0, 0, 185 }, { 91, 7, 185 }, // und_ST -> pt_Latn_ST { 0, 0, 65 }, { 111, 7, 65 }, // und_SV -> es_Latn_SV { 0, 0, 207 }, { 8, 1, 207 }, // und_SY -> ar_Arab_SY + { 0, 89, 0 }, { 303, 89, 105 }, // und_Samr -> smp_Samr_IL + { 0, 81, 0 }, { 302, 81, 237 }, // und_Sarb -> xsa_Sarb_YE + { 0, 90, 0 }, { 305, 90, 100 }, // und_Saur -> saz_Saur_IN + { 0, 92, 0 }, { 31, 92, 224 }, // und_Shaw -> en_Shaw_GB + { 0, 91, 0 }, { 99, 91, 100 }, // und_Shrd -> sa_Shrd_IN { 0, 32, 0 }, { 106, 32, 198 }, // und_Sinh -> si_Sinh_LK + { 0, 93, 0 }, { 306, 93, 100 }, // und_Sora -> srb_Sora_IN + { 0, 95, 0 }, { 112, 95, 101 }, // und_Sund -> su_Sund_ID + { 0, 96, 0 }, { 307, 96, 18 }, // und_Sylo -> syl_Sylo_BD + { 0, 33, 0 }, { 151, 33, 207 }, // und_Syrc -> syr_Syrc_SY { 0, 0, 42 }, { 37, 7, 42 }, // und_TD -> fr_Latn_TD { 0, 0, 212 }, { 37, 7, 212 }, // und_TG -> fr_Latn_TG { 0, 0, 211 }, { 120, 30, 211 }, // und_TH -> th_Thai_TH @@ -524,9 +584,15 @@ static const QLocaleId likely_subtags[] = { { 0, 0, 217 }, { 125, 7, 217 }, // und_TR -> tr_Latn_TR { 0, 0, 208 }, { 25, 6, 208 }, // und_TW -> zh_Hant_TW { 0, 0, 210 }, { 113, 7, 210 }, // und_TZ -> sw_Latn_TZ + { 0, 98, 0 }, { 308, 98, 170 }, // und_Tagb -> tbw_Tagb_PH + { 0, 101, 0 }, { 275, 101, 100 }, // und_Takr -> doi_Takr_IN + { 0, 99, 0 }, { 310, 99, 44 }, // und_Tale -> tdd_Tale_CN + { 0, 76, 0 }, { 286, 76, 44 }, // und_Talu -> khb_Talu_CN { 0, 27, 0 }, { 117, 27, 100 }, // und_Taml -> ta_Taml_IN + { 0, 100, 0 }, { 309, 100, 232 }, // und_Tavt -> blt_Tavt_VN { 0, 28, 0 }, { 119, 28, 100 }, // und_Telu -> te_Telu_IN { 0, 9, 0 }, { 183, 9, 216 }, // und_Tfng -> shi_Tfng_TN + { 0, 97, 0 }, { 166, 97, 170 }, // und_Tglg -> fil_Tglg_PH { 0, 29, 0 }, { 143, 29, 131 }, // und_Thaa -> dv_Thaa_MV { 0, 30, 0 }, { 120, 30, 211 }, // und_Thai -> th_Thai_TH { 0, 31, 0 }, { 121, 31, 44 }, // und_Tibt -> bo_Tibt_CN @@ -534,6 +600,7 @@ static const QLocaleId likely_subtags[] = { { 0, 0, 221 }, { 113, 7, 221 }, // und_UG -> sw_Latn_UG { 0, 0, 227 }, { 111, 7, 227 }, // und_UY -> es_Latn_UY { 0, 0, 228 }, { 131, 2, 228 }, // und_UZ -> uz_Cyrl_UZ + { 0, 102, 0 }, { 311, 102, 207 }, // und_Ugar -> uga_Ugar_SY { 0, 0, 230 }, { 70, 7, 230 }, // und_VA -> la_Latn_VA { 0, 0, 231 }, { 111, 7, 231 }, // und_VE -> es_Latn_VE { 0, 0, 232 }, { 132, 7, 232 }, // und_VN -> vi_Latn_VN @@ -541,6 +608,8 @@ static const QLocaleId likely_subtags[] = { { 0, 35, 0 }, { 252, 35, 121 }, // und_Vaii -> vai_Vaii_LR { 0, 0, 235 }, { 37, 7, 235 }, // und_WF -> fr_Latn_WF { 0, 0, 183 }, { 97, 7, 183 }, // und_WS -> sm_Latn_WS + { 0, 80, 0 }, { 295, 80, 102 }, // und_Xpeo -> peo_Xpeo_IR + { 0, 94, 0 }, { 262, 94, 103 }, // und_Xsux -> akk_Xsux_IQ { 0, 0, 237 }, { 8, 1, 237 }, // und_YE -> ar_Arab_YE { 0, 0, 138 }, { 37, 7, 138 }, // und_YT -> fr_Latn_YT { 0, 34, 0 }, { 168, 34, 44 }, // und_Yiii -> ii_Yiii_CN @@ -563,6 +632,7 @@ static const QLocaleId likely_subtags[] = { { 139, 0, 0 }, { 139, 7, 44 }, // za -> za_Latn_CN { 25, 0, 0 }, { 25, 5, 44 }, // zh -> zh_Hans_CN { 25, 0, 97 }, { 25, 6, 97 }, // zh_HK -> zh_Hant_HK + { 25, 54, 0 }, { 25, 5, 44 }, // zh_Hani -> zh_Hans_CN { 25, 6, 0 }, { 25, 6, 208 }, // zh_Hant -> zh_Hant_TW { 25, 0, 126 }, { 25, 6, 126 }, // zh_MO -> zh_Hant_MO { 25, 0, 208 }, { 25, 6, 208 }, // zh_TW -> zh_Hant_TW @@ -698,7 +768,7 @@ static const quint16 locale_index[] = { 332, // Turkish 0, // Turkmen 0, // Tahitian - 0, // Uigur + 0, // Uighur 334, // Ukrainian 335, // Urdu 337, // Uzbek @@ -831,6 +901,57 @@ static const quint16 locale_index[] = { 435, // Kako 436, // Meta 437, // Ngiemboon + 0, // Aragonese + 0, // Akkadian + 0, // AncientEgyptian + 0, // AncientGreek + 0, // Aramaic + 0, // Balinese + 0, // Bamun + 0, // BatakToba + 0, // Buginese + 0, // Buhid + 0, // Carian + 0, // Chakma + 0, // ClassicalMandaic + 0, // Coptic + 0, // Dogri + 0, // EasternCham + 0, // EasternKayah + 0, // Etruscan + 0, // Gothic + 0, // Hanunoo + 0, // Ingush + 0, // LargeFloweryMiao + 0, // Lepcha + 0, // Limbu + 0, // Lisu + 0, // Lu + 0, // Lycian + 0, // Lydian + 0, // Mandingo + 0, // Manipuri + 0, // Meroitic + 0, // NorthernThai + 0, // OldIrish + 0, // OldNorse + 0, // OldPersian + 0, // OldTurkish + 0, // Pahlavi + 0, // Parthian + 0, // Phoenician + 0, // PrakritLanguage + 0, // Rejang + 0, // Sabaean + 0, // Samaritan + 0, // Santali + 0, // Saurashtra + 0, // Sora + 0, // Sylheti + 0, // Tagbanwa + 0, // TaiDam + 0, // TaiNua + 0, // Ugaritic 0 // trailing 0 }; @@ -5275,7 +5396,7 @@ static const char language_name_list[] = "Turkish\0" "Turkmen\0" "Tahitian\0" -"Uigur\0" +"Uighur\0" "Ukrainian\0" "Urdu\0" "Uzbek\0" @@ -5408,6 +5529,57 @@ static const char language_name_list[] = "Kako\0" "Meta\0" "Ngiemboon\0" +"Aragonese\0" +"Akkadian\0" +"AncientEgyptian\0" +"AncientGreek\0" +"Aramaic\0" +"Balinese\0" +"Bamun\0" +"BatakToba\0" +"Buginese\0" +"Buhid\0" +"Carian\0" +"Chakma\0" +"ClassicalMandaic\0" +"Coptic\0" +"Dogri\0" +"EasternCham\0" +"EasternKayah\0" +"Etruscan\0" +"Gothic\0" +"Hanunoo\0" +"Ingush\0" +"LargeFloweryMiao\0" +"Lepcha\0" +"Limbu\0" +"Lisu\0" +"Lu\0" +"Lycian\0" +"Lydian\0" +"Mandingo\0" +"Manipuri\0" +"Meroitic\0" +"NorthernThai\0" +"OldIrish\0" +"OldNorse\0" +"OldPersian\0" +"OldTurkish\0" +"Pahlavi\0" +"Parthian\0" +"Phoenician\0" +"PrakritLanguage\0" +"Rejang\0" +"Sabaean\0" +"Samaritan\0" +"Santali\0" +"Saurashtra\0" +"Sora\0" +"Sylheti\0" +"Tagbanwa\0" +"TaiDam\0" +"TaiNua\0" +"Ugaritic\0" ; static const quint16 language_name_index[] = { @@ -5539,139 +5711,190 @@ static const quint16 language_name_index[] = { 1023, // Turkish 1031, // Turkmen 1039, // Tahitian - 1048, // Uigur - 1054, // Ukrainian - 1064, // Urdu - 1069, // Uzbek - 1075, // Vietnamese - 1086, // Volapuk - 1094, // Welsh - 1100, // Wolof - 1106, // Xhosa - 1112, // Yiddish - 1120, // Yoruba - 1127, // Zhuang - 1134, // Zulu - 1139, // NorwegianNynorsk - 1156, // Bosnian - 1164, // Divehi - 1171, // Manx - 1176, // Cornish - 1184, // Akan - 1189, // Konkani - 1197, // Ga - 1200, // Igbo - 1205, // Kamba - 1211, // Syriac - 1218, // Blin - 1223, // Geez - 1228, // Koro - 1233, // Sidamo - 1240, // Atsam - 1246, // Tigre - 1252, // Jju - 1256, // Friulian - 1265, // Venda - 1271, // Ewe - 1275, // Walamo - 1282, // Hawaiian - 1291, // Tyap - 1296, // Nyanja - 1303, // Filipino - 1312, // Swiss German - 1325, // Sichuan Yi - 1336, // Kpelle - 1343, // Low German - 1354, // South Ndebele - 1368, // Northern Sotho - 1383, // Northern Sami - 1397, // Taroko - 1404, // Gusii - 1410, // Taita - 1416, // Fulah - 1422, // Kikuyu - 1429, // Samburu - 1437, // Sena - 1442, // North Ndebele - 1456, // Rombo - 1462, // Tachelhit - 1472, // Kabyle - 1479, // Nyankole - 1488, // Bena - 1493, // Vunjo - 1499, // Bambara - 1507, // Embu - 1512, // Cherokee - 1521, // Morisyen - 1530, // Makonde - 1538, // Langi - 1544, // Ganda - 1550, // Bemba - 1556, // Kabuverdianu - 1569, // Meru - 1574, // Kalenjin - 1583, // Nama - 1588, // Machame - 1596, // Colognian - 1606, // Masai - 1612, // Soga - 1617, // Luyia - 1623, // Asu - 1627, // Teso - 1632, // Saho - 1637, // Koyra Chiini - 1650, // Rwa - 1654, // Luo - 1658, // Chiga - 1664, // Central Morocco Tamazight - 1690, // Koyraboro Senni - 1706, // Shambala - 1715, // Bodo - 1720, // Avaric - 1727, // Chamorro - 1736, // Chechen - 1744, // Church - 1751, // Chuvash - 1759, // Cree - 1764, // Haitian - 1772, // Herero - 1779, // Hiri Motu - 1789, // Kanuri - 1796, // Komi - 1801, // Kongo - 1807, // Kwanyama - 1816, // Limburgish - 1827, // LubaKatanga - 1839, // Luxembourgish - 1853, // Navaho - 1860, // Ndonga - 1867, // Ojibwa - 1874, // Pali - 1879, // Walloon - 1887, // Aghem - 1893, // Basaa - 1899, // Zarma - 1905, // Duala - 1911, // JolaFonyi - 1921, // Ewondo - 1928, // Bafia - 1934, // MakhuwaMeetto - 1948, // Mundang - 1956, // Kwasio - 1963, // Nuer - 1968, // Sakha - 1974, // Sangu - 1980, // Congo Swahili - 1994, // Tasawaq - 2002, // Vai - 2006, // Walser - 2013, // Yangben - 2021, // Avestan - 2029, // Asturian - 2038, // Ngomba - 2045, // Kako - 2050, // Meta - 2055, // Ngiemboon + 1048, // Uighur + 1055, // Ukrainian + 1065, // Urdu + 1070, // Uzbek + 1076, // Vietnamese + 1087, // Volapuk + 1095, // Welsh + 1101, // Wolof + 1107, // Xhosa + 1113, // Yiddish + 1121, // Yoruba + 1128, // Zhuang + 1135, // Zulu + 1140, // NorwegianNynorsk + 1157, // Bosnian + 1165, // Divehi + 1172, // Manx + 1177, // Cornish + 1185, // Akan + 1190, // Konkani + 1198, // Ga + 1201, // Igbo + 1206, // Kamba + 1212, // Syriac + 1219, // Blin + 1224, // Geez + 1229, // Koro + 1234, // Sidamo + 1241, // Atsam + 1247, // Tigre + 1253, // Jju + 1257, // Friulian + 1266, // Venda + 1272, // Ewe + 1276, // Walamo + 1283, // Hawaiian + 1292, // Tyap + 1297, // Nyanja + 1304, // Filipino + 1313, // Swiss German + 1326, // Sichuan Yi + 1337, // Kpelle + 1344, // Low German + 1355, // South Ndebele + 1369, // Northern Sotho + 1384, // Northern Sami + 1398, // Taroko + 1405, // Gusii + 1411, // Taita + 1417, // Fulah + 1423, // Kikuyu + 1430, // Samburu + 1438, // Sena + 1443, // North Ndebele + 1457, // Rombo + 1463, // Tachelhit + 1473, // Kabyle + 1480, // Nyankole + 1489, // Bena + 1494, // Vunjo + 1500, // Bambara + 1508, // Embu + 1513, // Cherokee + 1522, // Morisyen + 1531, // Makonde + 1539, // Langi + 1545, // Ganda + 1551, // Bemba + 1557, // Kabuverdianu + 1570, // Meru + 1575, // Kalenjin + 1584, // Nama + 1589, // Machame + 1597, // Colognian + 1607, // Masai + 1613, // Soga + 1618, // Luyia + 1624, // Asu + 1628, // Teso + 1633, // Saho + 1638, // Koyra Chiini + 1651, // Rwa + 1655, // Luo + 1659, // Chiga + 1665, // Central Morocco Tamazight + 1691, // Koyraboro Senni + 1707, // Shambala + 1716, // Bodo + 1721, // Avaric + 1728, // Chamorro + 1737, // Chechen + 1745, // Church + 1752, // Chuvash + 1760, // Cree + 1765, // Haitian + 1773, // Herero + 1780, // Hiri Motu + 1790, // Kanuri + 1797, // Komi + 1802, // Kongo + 1808, // Kwanyama + 1817, // Limburgish + 1828, // LubaKatanga + 1840, // Luxembourgish + 1854, // Navaho + 1861, // Ndonga + 1868, // Ojibwa + 1875, // Pali + 1880, // Walloon + 1888, // Aghem + 1894, // Basaa + 1900, // Zarma + 1906, // Duala + 1912, // JolaFonyi + 1922, // Ewondo + 1929, // Bafia + 1935, // MakhuwaMeetto + 1949, // Mundang + 1957, // Kwasio + 1964, // Nuer + 1969, // Sakha + 1975, // Sangu + 1981, // Congo Swahili + 1995, // Tasawaq + 2003, // Vai + 2007, // Walser + 2014, // Yangben + 2022, // Avestan + 2030, // Asturian + 2039, // Ngomba + 2046, // Kako + 2051, // Meta + 2056, // Ngiemboon + 2066, // Aragonese + 2076, // Akkadian + 2085, // AncientEgyptian + 2101, // AncientGreek + 2114, // Aramaic + 2122, // Balinese + 2131, // Bamun + 2137, // BatakToba + 2147, // Buginese + 2156, // Buhid + 2162, // Carian + 2169, // Chakma + 2176, // ClassicalMandaic + 2193, // Coptic + 2200, // Dogri + 2206, // EasternCham + 2218, // EasternKayah + 2231, // Etruscan + 2240, // Gothic + 2247, // Hanunoo + 2255, // Ingush + 2262, // LargeFloweryMiao + 2279, // Lepcha + 2286, // Limbu + 2292, // Lisu + 2297, // Lu + 2300, // Lycian + 2307, // Lydian + 2314, // Mandingo + 2323, // Manipuri + 2332, // Meroitic + 2341, // NorthernThai + 2354, // OldIrish + 2363, // OldNorse + 2372, // OldPersian + 2383, // OldTurkish + 2394, // Pahlavi + 2402, // Parthian + 2411, // Phoenician + 2422, // PrakritLanguage + 2438, // Rejang + 2445, // Sabaean + 2453, // Samaritan + 2463, // Santali + 2471, // Saurashtra + 2482, // Sora + 2487, // Sylheti + 2495, // Tagbanwa + 2504, // TaiDam + 2511, // TaiNua + 2518, // Ugaritic }; static const char script_name_list[] = @@ -5711,6 +5934,73 @@ static const char script_name_list[] = "Syriac\0" "Yi\0" "Vai\0" +"Avestan\0" +"Balinese\0" +"Bamum\0" +"Batak\0" +"Bopomofo\0" +"Brahmi\0" +"Buginese\0" +"Buhid\0" +"CanadianAboriginal\0" +"Carian\0" +"Chakma\0" +"Cham\0" +"Coptic\0" +"Cypriot\0" +"Egyptian Hieroglyphs\0" +"Fraser\0" +"Glagolitic\0" +"Gothic\0" +"Han\0" +"Hangul\0" +"Hanunoo\0" +"Imperial Aramaic\0" +"Inscriptional Pahlavi\0" +"Inscriptional Parthian\0" +"Javanese\0" +"Kaithi\0" +"Katakana\0" +"Kayah Li\0" +"Kharoshthi\0" +"Lanna\0" +"Lepcha\0" +"Limbu\0" +"Linear B\0" +"Lycian\0" +"Lydian\0" +"Mandaean\0" +"Meitei Mayek\0" +"Meroitic\0" +"Meroitic Cursive\0" +"Nko\0" +"New Tai Lue\0" +"Ogham\0" +"Ol Chiki\0" +"Old Italic\0" +"Old Persian\0" +"Old South Arabian\0" +"Orkhon\0" +"Osmanya\0" +"Phags Pa\0" +"Phoenician\0" +"Pollard Phonetic\0" +"Rejang\0" +"Runic\0" +"Samaritan\0" +"Saurashtra\0" +"Sharada\0" +"Shavian\0" +"Sora Sompeng\0" +"Cuneiform\0" +"Sundanese\0" +"Syloti Nagri\0" +"Tagalog\0" +"Tagbanwa\0" +"Tai Le\0" +"Tai Viet\0" +"Takri\0" +"Ugaritic\0" ; static const quint16 script_name_index[] = { @@ -5750,6 +6040,73 @@ static const quint16 script_name_index[] = { 273, // Syriac 280, // Yi 283, // Vai + 287, // Avestan + 295, // Balinese + 304, // Bamum + 310, // Batak + 316, // Bopomofo + 325, // Brahmi + 332, // Buginese + 341, // Buhid + 347, // CanadianAboriginal + 366, // Carian + 373, // Chakma + 380, // Cham + 385, // Coptic + 392, // Cypriot + 400, // Egyptian Hieroglyphs + 421, // Fraser + 428, // Glagolitic + 439, // Gothic + 446, // Han + 450, // Hangul + 457, // Hanunoo + 465, // Imperial Aramaic + 482, // Inscriptional Pahlavi + 504, // Inscriptional Parthian + 527, // Javanese + 536, // Kaithi + 543, // Katakana + 552, // Kayah Li + 561, // Kharoshthi + 572, // Lanna + 578, // Lepcha + 585, // Limbu + 591, // Linear B + 600, // Lycian + 607, // Lydian + 614, // Mandaean + 623, // Meitei Mayek + 636, // Meroitic + 645, // Meroitic Cursive + 662, // Nko + 666, // New Tai Lue + 678, // Ogham + 684, // Ol Chiki + 693, // Old Italic + 704, // Old Persian + 716, // Old South Arabian + 734, // Orkhon + 741, // Osmanya + 749, // Phags Pa + 758, // Phoenician + 769, // Pollard Phonetic + 786, // Rejang + 793, // Runic + 799, // Samaritan + 809, // Saurashtra + 820, // Sharada + 828, // Shavian + 836, // Sora Sompeng + 849, // Cuneiform + 859, // Sundanese + 869, // Syloti Nagri + 882, // Tagalog + 890, // Tagbanwa + 899, // Tai Le + 906, // Tai Viet + 915, // Takri + 921, // Ugaritic }; static const char country_name_list[] = @@ -6401,7 +6758,7 @@ static const unsigned char language_code_list[] = "tr\0" // Turkish "tk\0" // Turkmen "ty\0" // Tahitian -"ug\0" // Uigur +"ug\0" // Uighur "uk\0" // Ukrainian "ur\0" // Urdu "uz\0" // Uzbek @@ -6534,6 +6891,57 @@ static const unsigned char language_code_list[] = "kkj" // Kako "mgo" // Meta "nnh" // Ngiemboon +"an\0" // Aragonese +"akk" // Akkadian +"egy" // AncientEgyptian +"grc" // AncientGreek +"arc" // Aramaic +"ban" // Balinese +"bax" // Bamun +"bbc" // BatakToba +"bug" // Buginese +"bku" // Buhid +"xcr" // Carian +"ccp" // Chakma +"myz" // ClassicalMandaic +"cop" // Coptic +"doi" // Dogri +"cjm" // EasternCham +"eky" // EasternKayah +"ett" // Etruscan +"got" // Gothic +"hnn" // Hanunoo +"inh" // Ingush +"hmd" // LargeFloweryMiao +"lep" // Lepcha +"lif" // Limbu +"lis" // Lisu +"khb" // Lu +"xlc" // Lycian +"xld" // Lydian +"man" // Mandingo +"mni" // Manipuri +"xmr" // Meroitic +"nod" // NorthernThai +"sga" // OldIrish +"non" // OldNorse +"peo" // OldPersian +"otk" // OldTurkish +"pal" // Pahlavi +"xpr" // Parthian +"phn" // Phoenician +"pra" // PrakritLanguage +"rej" // Rejang +"xsa" // Sabaean +"smp" // Samaritan +"sat" // Santali +"saz" // Saurashtra +"srb" // Sora +"syl" // Sylheti +"tbw" // Tagbanwa +"blt" // TaiDam +"tdd" // TaiNua +"uga" // Ugaritic ; static const unsigned char script_code_list[] = @@ -6570,9 +6978,76 @@ static const unsigned char script_code_list[] = "Thai" // Thai "Tibt" // Tibetan "Sinh" // Sinhala -"Syri" // Syriac +"Syrc" // Syriac "Yiii" // Yi "Vaii" // Vai +"Avst" // Avestan +"Bali" // Balinese +"Bamu" // Bamum +"Batk" // Batak +"Bopo" // Bopomofo +"Brah" // Brahmi +"Bugi" // Buginese +"Buhd" // Buhid +"Cans" // CanadianAboriginal +"Cari" // Carian +"Cakm" // Chakma +"Cham" // Cham +"Copt" // Coptic +"Cprt" // Cypriot +"Egyp" // Egyptian Hieroglyphs +"Lisu" // Fraser +"Glag" // Glagolitic +"Goth" // Gothic +"Hani" // Han +"Hang" // Hangul +"Hano" // Hanunoo +"Armi" // Imperial Aramaic +"Phli" // Inscriptional Pahlavi +"Prti" // Inscriptional Parthian +"Java" // Javanese +"Kthi" // Kaithi +"Kana" // Katakana +"Kali" // Kayah Li +"Khar" // Kharoshthi +"Lana" // Lanna +"Lepc" // Lepcha +"Limb" // Limbu +"Linb" // Linear B +"Lyci" // Lycian +"Lydi" // Lydian +"Mand" // Mandaean +"Mtei" // Meitei Mayek +"Mero" // Meroitic +"Merc" // Meroitic Cursive +"Nkoo" // Nko +"Talu" // New Tai Lue +"Ogam" // Ogham +"Olck" // Ol Chiki +"Ital" // Old Italic +"Xpeo" // Old Persian +"Sarb" // Old South Arabian +"Orkh" // Orkhon +"Osma" // Osmanya +"Phag" // Phags Pa +"Phnx" // Phoenician +"Plrd" // Pollard Phonetic +"Rjng" // Rejang +"Runr" // Runic +"Samr" // Samaritan +"Saur" // Saurashtra +"Shrd" // Sharada +"Shaw" // Shavian +"Sora" // Sora Sompeng +"Xsux" // Cuneiform +"Sund" // Sundanese +"Sylo" // Syloti Nagri +"Tglg" // Tagalog +"Tagb" // Tagbanwa +"Tale" // Tai Le +"Tavt" // Tai Viet +"Takr" // Takri +"Ugar" // Ugaritic ; static const unsigned char country_code_list[] = "ZZ\0" // AnyCountry diff --git a/src/network/socket/qlocalsocket.cpp b/src/network/socket/qlocalsocket.cpp index bd2c4258b5..1ce6568364 100644 --- a/src/network/socket/qlocalsocket.cpp +++ b/src/network/socket/qlocalsocket.cpp @@ -71,18 +71,17 @@ QT_BEGIN_NAMESPACE */ /*! - \fn void QLocalSocket::connectToServer(const QString &name, OpenMode openMode) + \fn void QLocalSocket::open(OpenMode openMode) - Attempts to make a connection to \a name. + Equivalent to connectToServer(OpenMode mode). + The socket is opened in the given \a openMode to the server defined by setServerName(). - The socket is opened in the given \a openMode and first enters ConnectingState. - It then attempts to connect to the address or addresses returned by the lookup. - Finally, if a connection is established, QLocalSocket enters ConnectedState - and emits connected(). - - At any point, the socket can emit error() to signal that an error occurred. + Note that unlike in most other QIODevice subclasses, open() may not open the device directly. + The function return false if the socket was already connected or if the server to connect + to was not defined and true in any other case. The connected() or error() signals will be + emitted once the device is actualy open (or the connection failed). - See also state(), serverName(), and waitForConnected(). + See connectToServer() for more details. */ /*! @@ -354,8 +353,62 @@ QLocalSocket::~QLocalSocket() } /*! - Returns the name of the peer as specified by connectToServer(), or an - empty QString if connectToServer() has not been called or it failed. + \since 5.1 + + Attempts to make a connection to serverName(). + setServerName() must be called before you open the connection. + Alternatively you can use connectToServer(const QString &name, OpenMode openMode); + + The socket is opened in the given \a openMode and first enters ConnectingState. + If a connection is established, QLocalSocket enters ConnectedState and emits connected(). + + After calling this function, the socket can emit error() to signal that an error occurred. + + \sa state(), serverName(), waitForConnected() +*/ +void QLocalSocket::connectToServer(OpenMode openMode) +{ + open(openMode); +} + +/*! \overload + + Set the server \a name and attempts to make a connection to it. + + The socket is opened in the given \a openMode and first enters ConnectingState. + If a connection is established, QLocalSocket enters ConnectedState and emits connected(). + + After calling this function, the socket can emit error() to signal that an error occurred. + + \sa state(), serverName(), waitForConnected() +*/ +void QLocalSocket::connectToServer(const QString &name, OpenMode openMode) +{ + setServerName(name); + open(openMode); +} + +/*! + \since 5.1 + + Set the \a name of the peer to connect to. + On Windows name is the name of a named pipe; on Unix name is the name of a local domain socket. + + This function must be called when the socket is not connected. +*/ +void QLocalSocket::setServerName(const QString & name) +{ + Q_D(QLocalSocket); + if (d->state != UnconnectedState) { + qWarning("QLocalSocket::setServerName() called while not in unconnected state"); + return; + } + d->serverName = name; +} + +/*! + Returns the name of the peer as specified by setServerName(), or an + empty QString if setServerName() has not been called or connectToServer() failed. \sa connectToServer(), fullServerName() diff --git a/src/network/socket/qlocalsocket.h b/src/network/socket/qlocalsocket.h index 2ff4b2fc5b..427dab1def 100644 --- a/src/network/socket/qlocalsocket.h +++ b/src/network/socket/qlocalsocket.h @@ -84,9 +84,11 @@ public: QLocalSocket(QObject *parent = 0); ~QLocalSocket(); + void connectToServer(OpenMode openMode = ReadWrite); void connectToServer(const QString &name, OpenMode openMode = ReadWrite); void disconnectFromServer(); + void setServerName(const QString &name); QString serverName() const; QString fullServerName() const; @@ -95,6 +97,7 @@ public: virtual qint64 bytesAvailable() const; virtual qint64 bytesToWrite() const; virtual bool canReadLine() const; + virtual bool open(OpenMode openMode = ReadWrite) Q_DECL_OVERRIDE; virtual void close(); LocalSocketError error() const; bool flush(); diff --git a/src/network/socket/qlocalsocket_tcp.cpp b/src/network/socket/qlocalsocket_tcp.cpp index cbae8d58ff..edde5a4687 100644 --- a/src/network/socket/qlocalsocket_tcp.cpp +++ b/src/network/socket/qlocalsocket_tcp.cpp @@ -214,29 +214,30 @@ void QLocalSocketPrivate::errorOccurred(QLocalSocket::LocalSocketError error, co q->emit stateChanged(state); } -void QLocalSocket::connectToServer(const QString &name, OpenMode openMode) +bool QLocalSocket::open(OpenMode openMode) { Q_D(QLocalSocket); - if (state() == ConnectedState - || state() == ConnectingState) - return; + if (state() == ConnectedState || state() == ConnectingState) { + setErrorString(tr("Trying to connect while connection is in progress")); + emit error(QLocalSocket::OperationError); + return false; + } d->errorString.clear(); d->state = ConnectingState; emit stateChanged(d->state); - if (name.isEmpty()) { + if (d->serverName.isEmpty()) { d->errorOccurred(ServerNotFoundError, QLatin1String("QLocalSocket::connectToServer")); - return; + return false; } - d->serverName = name; const QLatin1String prefix("QLocalServer/"); if (name.startsWith(prefix)) - d->fullServerName = name; + d->fullServerName = d->serverName; else - d->fullServerName = prefix + name; + d->fullServerName = prefix + d->serverName; QSettings settings(QLatin1String("QtProject"), QLatin1String("Qt")); bool ok; @@ -244,10 +245,11 @@ void QLocalSocket::connectToServer(const QString &name, OpenMode openMode) if (!ok) { d->errorOccurred(ServerNotFoundError, QLatin1String("QLocalSocket::connectToServer")); - return; + return false; } d->tcpSocket->connectToHost(QHostAddress::LocalHost, port, openMode); QIODevice::open(openMode); + return true; } bool QLocalSocket::setSocketDescriptor(qintptr socketDescriptor, diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp index e846e43e73..67182e57b0 100644 --- a/src/network/socket/qlocalsocket_unix.cpp +++ b/src/network/socket/qlocalsocket_unix.cpp @@ -221,14 +221,14 @@ void QLocalSocketPrivate::errorOccurred(QLocalSocket::LocalSocketError error, co q->emit stateChanged(state); } -void QLocalSocket::connectToServer(const QString &name, OpenMode openMode) +bool QLocalSocket::open(OpenMode openMode) { Q_D(QLocalSocket); if (state() == ConnectedState || state() == ConnectingState) { QString errorString = d->generateErrorString(QLocalSocket::OperationError, QLatin1String("QLocalSocket::connectToserver")); setErrorString(errorString); emit error(QLocalSocket::OperationError); - return; + return false; } d->errorString.clear(); @@ -236,17 +236,17 @@ void QLocalSocket::connectToServer(const QString &name, OpenMode openMode) d->state = ConnectingState; emit stateChanged(d->state); - if (name.isEmpty()) { + if (d->serverName.isEmpty()) { d->errorOccurred(ServerNotFoundError, QLatin1String("QLocalSocket::connectToServer")); - return; + return false; } // create the socket if (-1 == (d->connectingSocket = qt_safe_socket(PF_UNIX, SOCK_STREAM, 0))) { d->errorOccurred(UnsupportedSocketOperationError, QLatin1String("QLocalSocket::connectToServer")); - return; + return false; } // set non blocking so we can try to connect and it won't wait int flags = fcntl(d->connectingSocket, F_GETFL, 0); @@ -254,13 +254,14 @@ void QLocalSocket::connectToServer(const QString &name, OpenMode openMode) || -1 == (fcntl(d->connectingSocket, F_SETFL, flags | O_NONBLOCK))) { d->errorOccurred(UnknownSocketError, QLatin1String("QLocalSocket::connectToServer")); - return; + return false; } // _q_connectToSocket does the actual connecting - d->connectingName = name; + d->connectingName = d->serverName; d->connectingOpenMode = openMode; d->_q_connectToSocket(); + return true; } /*! diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp index 660e0901f8..cdfa18377d 100644 --- a/src/network/socket/qlocalsocket_win.cpp +++ b/src/network/socket/qlocalsocket_win.cpp @@ -128,33 +128,33 @@ void QLocalSocketPrivate::destroyPipeHandles() } } -void QLocalSocket::connectToServer(const QString &name, OpenMode openMode) +bool QLocalSocket::open(OpenMode openMode) { Q_D(QLocalSocket); if (state() == ConnectedState || state() == ConnectingState) { setErrorString(tr("Trying to connect while connection is in progress")); emit error(QLocalSocket::OperationError); - return; + return false; } d->error = QLocalSocket::UnknownSocketError; d->errorString = QString(); d->state = ConnectingState; emit stateChanged(d->state); - if (name.isEmpty()) { + if (d->serverName.isEmpty()) { d->error = QLocalSocket::ServerNotFoundError; setErrorString(QLocalSocket::tr("%1: Invalid name").arg(QLatin1String("QLocalSocket::connectToServer"))); d->state = UnconnectedState; emit error(d->error); emit stateChanged(d->state); - return; + return false; } QString pipePath = QLatin1String("\\\\.\\pipe\\"); - if (name.startsWith(pipePath)) - d->fullServerName = name; + if (d->serverName.startsWith(pipePath)) + d->fullServerName = d->serverName; else - d->fullServerName = pipePath + name; + d->fullServerName = pipePath + d->serverName; // Try to open a named pipe HANDLE localSocket; forever { @@ -184,15 +184,15 @@ void QLocalSocket::connectToServer(const QString &name, OpenMode openMode) if (localSocket == INVALID_HANDLE_VALUE) { d->setErrorString(QLatin1String("QLocalSocket::connectToServer")); d->fullServerName = QString(); - return; + return false; } // we have a valid handle - d->serverName = name; if (setSocketDescriptor((qintptr)localSocket, ConnectedState, openMode)) { d->handle = localSocket; emit connected(); } + return true; } // This is reading from the buffer diff --git a/src/platformsupport/jniconvenience/jniconvenience.pri b/src/platformsupport/jniconvenience/jniconvenience.pri new file mode 100644 index 0000000000..991518e370 --- /dev/null +++ b/src/platformsupport/jniconvenience/jniconvenience.pri @@ -0,0 +1,9 @@ +android { + QT += gui-private + + HEADERS += $$PWD/qjnihelpers_p.h \ + $$PWD/qjniobject_p.h + + SOURCES += $$PWD/qjnihelpers.cpp \ + $$PWD/qjniobject.cpp +} diff --git a/src/platformsupport/jniconvenience/qjnihelpers.cpp b/src/platformsupport/jniconvenience/qjnihelpers.cpp new file mode 100644 index 0000000000..3f9b568368 --- /dev/null +++ b/src/platformsupport/jniconvenience/qjnihelpers.cpp @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qjnihelpers_p.h" + +#include <qpa/qplatformnativeinterface.h> +#include <qguiapplication.h> + +QT_BEGIN_NAMESPACE + +QString qt_convertJString(jstring string) +{ + QAttachedJNIEnv env; + int strLength = env->GetStringLength(string); + QString res; + res.resize(strLength); + env->GetStringRegion(string, 0, strLength, (jchar*)res.utf16()); + return res; +} + +QJNILocalRef<jstring> qt_toJString(const QString &string) +{ + QAttachedJNIEnv env; + return QJNILocalRef<jstring>(env->NewString(reinterpret_cast<const jchar*>(string.constData()), + string.length())); +} + + +static JavaVM *g_javaVM = 0; + +static JavaVM *getJavaVM() +{ + if (!g_javaVM){ + QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); + g_javaVM = static_cast<JavaVM*>(nativeInterface->nativeResourceForIntegration("JavaVM")); + } + return g_javaVM; +} + +QThreadStorage<int> QAttachedJNIEnv::m_refCount; + +QAttachedJNIEnv::QAttachedJNIEnv() +{ + JavaVM *vm = javaVM(); + if (vm->GetEnv((void**)&jniEnv, JNI_VERSION_1_6) == JNI_EDETACHED) { + if (vm->AttachCurrentThread(&jniEnv, 0) < 0) { + jniEnv = 0; + return; + } + } + + if (!m_refCount.hasLocalData()) + m_refCount.setLocalData(1); + else + m_refCount.setLocalData(m_refCount.localData() + 1); +} + +QAttachedJNIEnv::~QAttachedJNIEnv() +{ + if (!jniEnv) + return; + + int newRef = m_refCount.localData() - 1; + m_refCount.setLocalData(newRef); + + if (newRef == 0) + javaVM()->DetachCurrentThread(); + + jniEnv = 0; +} + +JavaVM *QAttachedJNIEnv::javaVM() +{ + return getJavaVM(); +} + +QT_END_NAMESPACE diff --git a/src/platformsupport/jniconvenience/qjnihelpers_p.h b/src/platformsupport/jniconvenience/qjnihelpers_p.h new file mode 100644 index 0000000000..fb44d156bd --- /dev/null +++ b/src/platformsupport/jniconvenience/qjnihelpers_p.h @@ -0,0 +1,191 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QJNIHELPERS_H +#define QJNIHELPERS_H + +#include <jni.h> +#include <qglobal.h> +#include <QString> +#include <QThreadStorage> + +QT_BEGIN_NAMESPACE + +template <typename T> +class QJNILocalRef; + +QString qt_convertJString(jstring string); +QJNILocalRef<jstring> qt_toJString(const QString &string); + + +struct QAttachedJNIEnv +{ + QAttachedJNIEnv(); + ~QAttachedJNIEnv(); + + static JavaVM *javaVM(); + + JNIEnv *operator->() + { + return jniEnv; + } + + operator JNIEnv*() const + { + return jniEnv; + } + + JNIEnv *jniEnv; + +private: + static QThreadStorage<int> m_refCount; +}; + + +template <typename T> +class QJNILocalRef +{ +public: + inline QJNILocalRef() : m_obj(0) { } + inline explicit QJNILocalRef(T o) : m_obj(o) { } + inline QJNILocalRef(const QJNILocalRef<T> &other) : m_obj(other.m_obj) + { + if (other.m_obj) + m_obj = static_cast<T>(m_env->NewLocalRef(other.m_obj)); + } + + template <typename X> + inline QJNILocalRef(const QJNILocalRef<X> &other) : m_obj(other.m_obj) + { + if (other.m_obj) + m_obj = static_cast<T>(m_env->NewLocalRef(other.m_obj)); + } + + inline ~QJNILocalRef() { release(); } + + inline QJNILocalRef<T> &operator=(const QJNILocalRef<T> &other) + { + release(); + m_obj = other.m_obj; // for type checking + if (other.m_obj) + m_obj = static_cast<T>(m_env->NewLocalRef(other.m_obj)); + return *this; + } + + template <typename X> + inline QJNILocalRef<T> &operator=(const QJNILocalRef<X> &other) + { + release(); + m_obj = other.m_obj; // for type checking + if (other.m_obj) + m_obj = static_cast<T>(m_env->NewLocalRef(other.m_obj)); + return *this; + } + + inline QJNILocalRef<T> &operator=(T o) + { + release(); + m_obj = o; + return *this; + } + + template <typename X> + inline QJNILocalRef<T> &operator=(X o) + { + release(); + m_obj = o; + return *this; + } + + inline bool operator !() const { return !m_obj; } + inline bool isNull() const { return !m_obj; } + inline T object() const { return m_obj; } + +private: + void release() + { + if (m_obj) { + m_env->DeleteLocalRef(m_obj); + m_obj = 0; + } + } + + QAttachedJNIEnv m_env; + T m_obj; + + template <class X> friend class QJNILocalRef; +}; + +template <class T, class X> +bool operator==(const QJNILocalRef<T> &ptr1, const QJNILocalRef<X> &ptr2) +{ + return ptr1.m_obj == ptr2.m_obj; +} +template <class T, class X> +bool operator!=(const QJNILocalRef<T> &ptr1, const QJNILocalRef<X> &ptr2) +{ + return ptr1.m_obj != ptr2.m_obj; +} + +template <class T, class X> +bool operator==(const QJNILocalRef<T> &ptr1, X ptr2) +{ + return ptr1.m_obj == ptr2; +} +template <class T, class X> +bool operator==(T ptr1, const QJNILocalRef<X> &ptr2) +{ + return ptr1 == ptr2.m_obj; +} +template <class T, class X> +bool operator!=(const QJNILocalRef<T> &ptr1, X ptr2) +{ + return !(ptr1 == ptr2); +} +template <class T, class X> +bool operator!=(const T *ptr1, const QJNILocalRef<X> &ptr2) +{ + return !(ptr2 == ptr1); +} + +QT_END_NAMESPACE + +#endif // QJNIHELPERS_H diff --git a/src/platformsupport/jniconvenience/qjniobject.cpp b/src/platformsupport/jniconvenience/qjniobject.cpp new file mode 100644 index 0000000000..515e82b2f0 --- /dev/null +++ b/src/platformsupport/jniconvenience/qjniobject.cpp @@ -0,0 +1,3098 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qjniobject_p.h" + +#include "qjnihelpers_p.h" +#include <qhash.h> + +QT_BEGIN_NAMESPACE + +static QHash<QString, jclass> g_cachedClasses; + +static jclass getCachedClass(JNIEnv *env, const char *className) +{ + jclass clazz = 0; + QString key = QLatin1String(className); + QHash<QString, jclass>::iterator it = g_cachedClasses.find(key); + if (it == g_cachedClasses.end()) { + jclass c = env->FindClass(className); + if (env->ExceptionCheck()) { + c = 0; + env->ExceptionClear(); + } + if (c) + clazz = static_cast<jclass>(env->NewGlobalRef(c)); + g_cachedClasses.insert(key, clazz); + } else { + clazz = it.value(); + } + return clazz; +} + +static QHash<QString, jmethodID> g_cachedMethodIDs; +static QString g_keyBase(QLatin1String("%1%2%3")); + +static jmethodID getCachedMethodID(JNIEnv *env, + jclass clazz, + const char *name, + const char *sig, + bool isStatic = false) +{ + jmethodID id = 0; + QString key = g_keyBase.arg(size_t(clazz)).arg(QLatin1String(name)).arg(QLatin1String(sig)); + QHash<QString, jmethodID>::iterator it = g_cachedMethodIDs.find(key); + if (it == g_cachedMethodIDs.end()) { + if (isStatic) + id = env->GetStaticMethodID(clazz, name, sig); + else + id = env->GetMethodID(clazz, name, sig); + + if (env->ExceptionCheck()) { + id = 0; + env->ExceptionClear(); + } + + g_cachedMethodIDs.insert(key, id); + } else { + id = it.value(); + } + return id; +} + +static QHash<QString, jfieldID> g_cachedFieldIDs; + +static jfieldID getCachedFieldID(JNIEnv *env, + jclass clazz, + const char *name, + const char *sig, + bool isStatic = false) +{ + jfieldID id = 0; + QString key = g_keyBase.arg(size_t(clazz)).arg(QLatin1String(name)).arg(QLatin1String(sig)); + QHash<QString, jfieldID>::iterator it = g_cachedFieldIDs.find(key); + if (it == g_cachedFieldIDs.end()) { + if (isStatic) + id = env->GetStaticFieldID(clazz, name, sig); + else + id = env->GetFieldID(clazz, name, sig); + + if (env->ExceptionCheck()) { + id = 0; + env->ExceptionClear(); + } + + g_cachedFieldIDs.insert(key, id); + } else { + id = it.value(); + } + return id; +} + +QJNIObject::QJNIObject(const char *className) + : m_jobject(0) + , m_jclass(0) + , m_own_jclass(false) +{ + QAttachedJNIEnv env; + m_jclass = getCachedClass(env, className); + if (m_jclass) { + // get default constructor + jmethodID constructorId = getCachedMethodID(env, m_jclass, "<init>", "()V"); + if (constructorId) { + jobject obj = env->NewObject(m_jclass, constructorId); + if (obj) { + m_jobject = env->NewGlobalRef(obj); + env->DeleteLocalRef(obj); + } + } + } +} + +QJNIObject::QJNIObject(const char *className, const char *sig, ...) + : m_jobject(0) + , m_jclass(0) + , m_own_jclass(false) +{ + QAttachedJNIEnv env; + m_jclass = getCachedClass(env, className); + if (m_jclass) { + jmethodID constructorId = getCachedMethodID(env, m_jclass, "<init>", sig); + if (constructorId) { + va_list args; + va_start(args, sig); + jobject obj = env->NewObjectV(m_jclass, constructorId, args); + va_end(args); + if (obj) { + m_jobject = env->NewGlobalRef(obj); + env->DeleteLocalRef(obj); + } + } + } +} + +QJNIObject::QJNIObject(jclass clazz) + : m_jobject(0) + , m_jclass(0) + , m_own_jclass(true) +{ + QAttachedJNIEnv env; + m_jclass = static_cast<jclass>(env->NewGlobalRef(clazz)); + if (m_jclass) { + // get default constructor + jmethodID constructorId = getCachedMethodID(env, m_jclass, "<init>", "()V"); + if (constructorId) { + jobject obj = env->NewObject(m_jclass, constructorId); + if (obj) { + m_jobject = env->NewGlobalRef(obj); + env->DeleteLocalRef(obj); + } + } + } +} + +QJNIObject::QJNIObject(jclass clazz, const char *sig, ...) + : m_jobject(0) + , m_jclass(0) + , m_own_jclass(true) +{ + QAttachedJNIEnv env; + if (clazz) { + m_jclass = static_cast<jclass>(env->NewGlobalRef(clazz)); + if (m_jclass) { + jmethodID constructorId = getCachedMethodID(env, m_jclass, "<init>", sig); + if (constructorId) { + va_list args; + va_start(args, sig); + jobject obj = env->NewObjectV(m_jclass, constructorId, args); + va_end(args); + if (obj) { + m_jobject = env->NewGlobalRef(obj); + env->DeleteLocalRef(obj); + } + } + } + } +} + +QJNIObject::QJNIObject(jobject obj) + : m_jobject(0) + , m_jclass(0) + , m_own_jclass(true) +{ + QAttachedJNIEnv env; + m_jobject = env->NewGlobalRef(obj); + m_jclass = static_cast<jclass>(env->NewGlobalRef(env->GetObjectClass(m_jobject))); +} + +QJNIObject::~QJNIObject() +{ + QAttachedJNIEnv env; + if (m_jobject) + env->DeleteGlobalRef(m_jobject); + if (m_jclass && m_own_jclass) + env->DeleteGlobalRef(m_jclass); +} + +bool QJNIObject::isClassAvailable(const char *className) +{ + QAttachedJNIEnv env; + + if (!env.jniEnv) + return false; + + jclass clazz = getCachedClass(env, className); + + return (clazz != 0); +} + +template <> +void QJNIObject::callMethod<void>(const char *methodName, const char *sig, ...) +{ + QAttachedJNIEnv env; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + env->CallVoidMethodV(m_jobject, id, args); + va_end(args); + } +} + +template <> +jboolean QJNIObject::callMethod<jboolean>(const char *methodName, const char *sig, ...) +{ + QAttachedJNIEnv env; + jboolean res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallBooleanMethodV(m_jobject, id, args); + va_end(args); + } + return res; +} + +template <> +jbyte QJNIObject::callMethod<jbyte>(const char *methodName, const char *sig, ...) +{ + QAttachedJNIEnv env; + jbyte res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallByteMethodV(m_jobject, id, args); + va_end(args); + } + return res; +} + +template <> +jchar QJNIObject::callMethod<jchar>(const char *methodName, const char *sig, ...) +{ + QAttachedJNIEnv env; + jchar res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallCharMethodV(m_jobject, id, args); + va_end(args); + } + return res; +} + +template <> +jshort QJNIObject::callMethod<jshort>(const char *methodName, const char *sig, ...) +{ + QAttachedJNIEnv env; + jshort res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallShortMethodV(m_jobject, id, args); + va_end(args); + } + return res; +} + +template <> +jint QJNIObject::callMethod<jint>(const char *methodName, const char *sig, ...) +{ + QAttachedJNIEnv env; + jint res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallIntMethodV(m_jobject, id, args); + va_end(args); + } + return res; +} + +template <> +jlong QJNIObject::callMethod<jlong>(const char *methodName, const char *sig, ...) +{ + QAttachedJNIEnv env; + jlong res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallLongMethodV(m_jobject, id, args); + va_end(args); + } + return res; +} + +template <> +jfloat QJNIObject::callMethod<jfloat>(const char *methodName, const char *sig, ...) +{ + QAttachedJNIEnv env; + jfloat res = 0.f; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallFloatMethodV(m_jobject, id, args); + va_end(args); + } + return res; +} + +template <> +jdouble QJNIObject::callMethod<jdouble>(const char *methodName, const char *sig, ...) +{ + QAttachedJNIEnv env; + jdouble res = 0.; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallDoubleMethodV(m_jobject, id, args); + va_end(args); + } + return res; +} + +template <> +QJNILocalRef<jobject> QJNIObject::callObjectMethod<jobject>(const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + jobject res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallObjectMethodV(m_jobject, id, args); + va_end(args); + } + return QJNILocalRef<jobject>(res); +} + +template <> +QJNILocalRef<jstring> QJNIObject::callObjectMethod<jstring>(const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + jstring res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast<jstring>(env->CallObjectMethodV(m_jobject, id, args)); + va_end(args); + } + return QJNILocalRef<jstring>(res); +} + +template <> +QJNILocalRef<jobjectArray> QJNIObject::callObjectMethod<jobjectArray>(const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + jobjectArray res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast<jobjectArray>(env->CallObjectMethodV(m_jobject, id, args)); + va_end(args); + } + return QJNILocalRef<jobjectArray>(res); +} + +template <> +QJNILocalRef<jbooleanArray> QJNIObject::callObjectMethod<jbooleanArray>(const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + jbooleanArray res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast<jbooleanArray>(env->CallObjectMethodV(m_jobject, id, args)); + va_end(args); + } + return QJNILocalRef<jbooleanArray>(res); +} + +template <> +QJNILocalRef<jbyteArray> QJNIObject::callObjectMethod<jbyteArray>(const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + jbyteArray res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast<jbyteArray>(env->CallObjectMethodV(m_jobject, id, args)); + va_end(args); + } + return QJNILocalRef<jbyteArray>(res); +} + +template <> +QJNILocalRef<jcharArray> QJNIObject::callObjectMethod<jcharArray>(const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + jcharArray res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast<jcharArray>(env->CallObjectMethodV(m_jobject, id, args)); + va_end(args); + } + return QJNILocalRef<jcharArray>(res); +} + +template <> +QJNILocalRef<jshortArray> QJNIObject::callObjectMethod<jshortArray>(const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + jshortArray res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast<jshortArray>(env->CallObjectMethodV(m_jobject, id, args)); + va_end(args); + } + return QJNILocalRef<jshortArray>(res); +} + +template <> +QJNILocalRef<jintArray> QJNIObject::callObjectMethod<jintArray>(const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + jintArray res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast<jintArray>(env->CallObjectMethodV(m_jobject, id, args)); + va_end(args); + } + return QJNILocalRef<jintArray>(res); +} + +template <> +QJNILocalRef<jlongArray> QJNIObject::callObjectMethod<jlongArray>(const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + jlongArray res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast<jlongArray>(env->CallObjectMethodV(m_jobject, id, args)); + va_end(args); + } + return QJNILocalRef<jlongArray>(res); +} + +template <> +QJNILocalRef<jfloatArray> QJNIObject::callObjectMethod<jfloatArray>(const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + jfloatArray res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast<jfloatArray>(env->CallObjectMethodV(m_jobject, id, args)); + va_end(args); + } + return QJNILocalRef<jfloatArray>(res); +} + +template <> +QJNILocalRef<jdoubleArray> QJNIObject::callObjectMethod<jdoubleArray>(const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + jdoubleArray res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast<jdoubleArray>(env->CallObjectMethodV(m_jobject, id, args)); + va_end(args); + } + return QJNILocalRef<jdoubleArray>(res); +} + +template <> +void QJNIObject::callMethod<void>(const char *methodName) +{ + callMethod<void>(methodName, "()V"); +} + +template <> +jboolean QJNIObject::callMethod<jboolean>(const char *methodName) +{ + return callMethod<jboolean>(methodName, "()Z"); +} + +template <> +jbyte QJNIObject::callMethod<jbyte>(const char *methodName) +{ + return callMethod<jbyte>(methodName, "()B"); +} + +template <> +jchar QJNIObject::callMethod<jchar>(const char *methodName) +{ + return callMethod<jchar>(methodName, "()C"); +} + +template <> +jshort QJNIObject::callMethod<jshort>(const char *methodName) +{ + return callMethod<jshort>(methodName, "()S"); +} + +template <> +jint QJNIObject::callMethod<jint>(const char *methodName) +{ + return callMethod<jint>(methodName, "()I"); +} + +template <> +jlong QJNIObject::callMethod<jlong>(const char *methodName) +{ + return callMethod<jlong>(methodName, "()J"); +} + +template <> +jfloat QJNIObject::callMethod<jfloat>(const char *methodName) +{ + return callMethod<jfloat>(methodName, "()F"); +} + +template <> +jdouble QJNIObject::callMethod<jdouble>(const char *methodName) +{ + return callMethod<jdouble>(methodName, "()D"); +} + +template <> +QJNILocalRef<jstring> QJNIObject::callObjectMethod<jstring>(const char *methodName) +{ + return callObjectMethod<jstring>(methodName, "()Ljava/lang/String;"); +} + +template <> +QJNILocalRef<jbooleanArray> QJNIObject::callObjectMethod<jbooleanArray>(const char *methodName) +{ + return callObjectMethod<jbooleanArray>(methodName, "()[Z"); +} + +template <> +QJNILocalRef<jbyteArray> QJNIObject::callObjectMethod<jbyteArray>(const char *methodName) +{ + return callObjectMethod<jbyteArray>(methodName, "()[B"); +} + +template <> +QJNILocalRef<jshortArray> QJNIObject::callObjectMethod<jshortArray>(const char *methodName) +{ + return callObjectMethod<jshortArray>(methodName, "()[S"); +} + +template <> +QJNILocalRef<jintArray> QJNIObject::callObjectMethod<jintArray>(const char *methodName) +{ + return callObjectMethod<jintArray>(methodName, "()[I"); +} + +template <> +QJNILocalRef<jlongArray> QJNIObject::callObjectMethod<jlongArray>(const char *methodName) +{ + return callObjectMethod<jlongArray>(methodName, "()[J"); +} + +template <> +QJNILocalRef<jfloatArray> QJNIObject::callObjectMethod<jfloatArray>(const char *methodName) +{ + return callObjectMethod<jfloatArray>(methodName, "()[F"); +} + +template <> +QJNILocalRef<jdoubleArray> QJNIObject::callObjectMethod<jdoubleArray>(const char *methodName) +{ + return callObjectMethod<jdoubleArray>(methodName, "()[D"); +} + +template <> +void QJNIObject::callStaticMethod<void>(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + env->CallStaticVoidMethodV(clazz, id, args); + va_end(args); + } + } +} + +template <> +void QJNIObject::callStaticMethod<void>(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + env->CallStaticVoidMethodV(clazz, id, args); + va_end(args); + } +} + +template <> +jboolean QJNIObject::callStaticMethod<jboolean>(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jboolean res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticBooleanMethodV(clazz, id, args); + va_end(args); + } + } + + return res; +} + +template <> +jboolean QJNIObject::callStaticMethod<jboolean>(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jboolean res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticBooleanMethodV(clazz, id, args); + va_end(args); + } + + return res; +} + +template <> +jbyte QJNIObject::callStaticMethod<jbyte>(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jbyte res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticByteMethodV(clazz, id, args); + va_end(args); + } + } + + return res; +} + +template <> +jbyte QJNIObject::callStaticMethod<jbyte>(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jbyte res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticByteMethodV(clazz, id, args); + va_end(args); + } + + return res; +} + +template <> +jchar QJNIObject::callStaticMethod<jchar>(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jchar res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticCharMethodV(clazz, id, args); + va_end(args); + } + } + + return res; +} + +template <> +jchar QJNIObject::callStaticMethod<jchar>(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jchar res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticCharMethodV(clazz, id, args); + va_end(args); + } + + return res; +} + + +template <> +jshort QJNIObject::callStaticMethod<jshort>(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jshort res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticShortMethodV(clazz, id, args); + va_end(args); + } + } + + return res; +} + +template <> +jshort QJNIObject::callStaticMethod<jshort>(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jshort res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticShortMethodV(clazz, id, args); + va_end(args); + } + + return res; +} + +template <> +jint QJNIObject::callStaticMethod<jint>(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jint res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticIntMethodV(clazz, id, args); + va_end(args); + } + } + + return res; +} + +template <> +jint QJNIObject::callStaticMethod<jint>(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jint res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticIntMethodV(clazz, id, args); + va_end(args); + } + + return res; +} + +template <> +jlong QJNIObject::callStaticMethod<jlong>(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jlong res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticLongMethodV(clazz, id, args); + va_end(args); + } + } + + return res; +} + +template <> +jlong QJNIObject::callStaticMethod<jlong>(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jlong res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticLongMethodV(clazz, id, args); + va_end(args); + } + + return res; +} + +template <> +jfloat QJNIObject::callStaticMethod<jfloat>(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jfloat res = 0.f; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticFloatMethodV(clazz, id, args); + va_end(args); + } + } + + return res; +} + +template <> +jfloat QJNIObject::callStaticMethod<jfloat>(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jfloat res = 0.f; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticFloatMethodV(clazz, id, args); + va_end(args); + } + + return res; +} + +template <> +jdouble QJNIObject::callStaticMethod<jdouble>(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jdouble res = 0.; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticDoubleMethodV(clazz, id, args); + va_end(args); + } + } + + return res; +} + +template <> +jdouble QJNIObject::callStaticMethod<jdouble>(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jdouble res = 0.; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticDoubleMethodV(clazz, id, args); + va_end(args); + } + + return res; +} + +template <> +QJNILocalRef<jobject> QJNIObject::callStaticObjectMethod<jobject>(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jobject res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticObjectMethodV(clazz, id, args); + va_end(args); + } + } + + return QJNILocalRef<jobject>(res); +} + +template <> +QJNILocalRef<jobject> QJNIObject::callStaticObjectMethod<jobject>(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jobject res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticObjectMethodV(clazz, id, args); + va_end(args); + } + + return QJNILocalRef<jobject>(res); +} + +template <> +QJNILocalRef<jstring> QJNIObject::callStaticObjectMethod<jstring>(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jstring res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast<jstring>(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + } + + return QJNILocalRef<jstring>(res); +} + +template <> +QJNILocalRef<jstring> QJNIObject::callStaticObjectMethod<jstring>(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jstring res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast<jstring>(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + + return QJNILocalRef<jstring>(res); +} + +template <> +QJNILocalRef<jobjectArray> QJNIObject::callStaticObjectMethod<jobjectArray>(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jobjectArray res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast<jobjectArray>(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + } + + return QJNILocalRef<jobjectArray>(res); +} + +template <> +QJNILocalRef<jobjectArray> QJNIObject::callStaticObjectMethod<jobjectArray>(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jobjectArray res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast<jobjectArray>(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + + return QJNILocalRef<jobjectArray>(res); +} + +template <> +QJNILocalRef<jbooleanArray> QJNIObject::callStaticObjectMethod<jbooleanArray>(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jbooleanArray res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast<jbooleanArray>(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + } + + return QJNILocalRef<jbooleanArray>(res); +} + +template <> +QJNILocalRef<jbooleanArray> QJNIObject::callStaticObjectMethod<jbooleanArray>(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jbooleanArray res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast<jbooleanArray>(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + + return QJNILocalRef<jbooleanArray>(res); +} + +template <> +QJNILocalRef<jbyteArray> QJNIObject::callStaticObjectMethod<jbyteArray>(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jbyteArray res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast<jbyteArray>(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + } + + return QJNILocalRef<jbyteArray>(res); +} + +template <> +QJNILocalRef<jbyteArray> QJNIObject::callStaticObjectMethod<jbyteArray>(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jbyteArray res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast<jbyteArray>(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + + return QJNILocalRef<jbyteArray>(res); +} + +template <> +QJNILocalRef<jcharArray> QJNIObject::callStaticObjectMethod<jcharArray>(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jcharArray res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast<jcharArray>(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + } + + return QJNILocalRef<jcharArray>(res); +} + +template <> +QJNILocalRef<jcharArray> QJNIObject::callStaticObjectMethod<jcharArray>(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jcharArray res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast<jcharArray>(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + + return QJNILocalRef<jcharArray>(res); +} + +template <> +QJNILocalRef<jshortArray> QJNIObject::callStaticObjectMethod<jshortArray>(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jshortArray res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast<jshortArray>(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + } + + return QJNILocalRef<jshortArray>(res); +} + +template <> +QJNILocalRef<jshortArray> QJNIObject::callStaticObjectMethod<jshortArray>(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jshortArray res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast<jshortArray>(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + + return QJNILocalRef<jshortArray>(res); +} + +template <> +QJNILocalRef<jintArray> QJNIObject::callStaticObjectMethod<jintArray>(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jintArray res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast<jintArray>(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + } + + return QJNILocalRef<jintArray>(res); +} + +template <> +QJNILocalRef<jintArray> QJNIObject::callStaticObjectMethod<jintArray>(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jintArray res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast<jintArray>(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + + return QJNILocalRef<jintArray>(res); +} + +template <> +QJNILocalRef<jlongArray> QJNIObject::callStaticObjectMethod<jlongArray>(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jlongArray res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast<jlongArray>(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + } + + return QJNILocalRef<jlongArray>(res); +} + +template <> +QJNILocalRef<jlongArray> QJNIObject::callStaticObjectMethod<jlongArray>(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jlongArray res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast<jlongArray>(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + + return QJNILocalRef<jlongArray>(res); +} + +template <> +QJNILocalRef<jfloatArray> QJNIObject::callStaticObjectMethod<jfloatArray>(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jfloatArray res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast<jfloatArray>(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + } + + return QJNILocalRef<jfloatArray>(res); +} + +template <> +QJNILocalRef<jfloatArray> QJNIObject::callStaticObjectMethod<jfloatArray>(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jfloatArray res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast<jfloatArray>(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + + return QJNILocalRef<jfloatArray>(res); +} + +template <> +QJNILocalRef<jdoubleArray> QJNIObject::callStaticObjectMethod<jdoubleArray>(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jdoubleArray res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast<jdoubleArray>(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + } + + return QJNILocalRef<jdoubleArray>(res); +} + +template <> +QJNILocalRef<jdoubleArray> QJNIObject::callStaticObjectMethod<jdoubleArray>(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jdoubleArray res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast<jdoubleArray>(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + + return QJNILocalRef<jdoubleArray>(res); +} + +template <> +void QJNIObject::callStaticMethod<void>(const char *className, const char *methodName) +{ + callStaticMethod<void>(className, methodName, "()V"); +} + +template <> +void QJNIObject::callStaticMethod<void>(jclass clazz, const char *methodName) +{ + callStaticMethod<void>(clazz, methodName, "()V"); +} + +template <> +jboolean QJNIObject::callStaticMethod<jboolean>(const char *className, const char *methodName) +{ + return callStaticMethod<jboolean>(className, methodName, "()Z"); +} + +template <> +jboolean QJNIObject::callStaticMethod<jboolean>(jclass clazz, const char *methodName) +{ + return callStaticMethod<jboolean>(clazz, methodName, "()Z"); +} + +template <> +jbyte QJNIObject::callStaticMethod<jbyte>(const char *className, const char *methodName) +{ + return callStaticMethod<jbyte>(className, methodName, "()B"); +} + +template <> +jbyte QJNIObject::callStaticMethod<jbyte>(jclass clazz, const char *methodName) +{ + return callStaticMethod<jbyte>(clazz, methodName, "()B"); +} + +template <> +jchar QJNIObject::callStaticMethod<jchar>(const char *className, const char *methodName) +{ + return callStaticMethod<jchar>(className, methodName, "()C"); +} + +template <> +jchar QJNIObject::callStaticMethod<jchar>(jclass clazz, const char *methodName) +{ + return callStaticMethod<jchar>(clazz, methodName, "()C"); +} + +template <> +jshort QJNIObject::callStaticMethod<jshort>(const char *className, const char *methodName) +{ + return callStaticMethod<jshort>(className, methodName, "()S"); +} + +template <> +jshort QJNIObject::callStaticMethod<jshort>(jclass clazz, const char *methodName) +{ + return callStaticMethod<jshort>(clazz, methodName, "()S"); +} + +template <> +jint QJNIObject::callStaticMethod<jint>(const char *className, const char *methodName) +{ + return callStaticMethod<jint>(className, methodName, "()I"); +} + +template <> +jint QJNIObject::callStaticMethod<jint>(jclass clazz, const char *methodName) +{ + return callStaticMethod<jint>(clazz, methodName, "()I"); +} + +template <> +jlong QJNIObject::callStaticMethod<jlong>(const char *className, const char *methodName) +{ + return callStaticMethod<jlong>(className, methodName, "()J"); +} + +template <> +jlong QJNIObject::callStaticMethod<jlong>(jclass clazz, const char *methodName) +{ + return callStaticMethod<jlong>(clazz, methodName, "()J"); +} + +template <> +jfloat QJNIObject::callStaticMethod<jfloat>(const char *className, const char *methodName) +{ + return callStaticMethod<jfloat>(className, methodName, "()F"); +} + +template <> +jfloat QJNIObject::callStaticMethod<jfloat>(jclass clazz, const char *methodName) +{ + return callStaticMethod<jfloat>(clazz, methodName, "()F"); +} + +template <> +jdouble QJNIObject::callStaticMethod<jdouble>(const char *className, const char *methodName) +{ + return callStaticMethod<jdouble>(className, methodName, "()D"); +} + +template <> +jdouble QJNIObject::callStaticMethod<jdouble>(jclass clazz, const char *methodName) +{ + return callStaticMethod<jdouble>(clazz, methodName, "()D"); +} + +template <> +QJNILocalRef<jstring> QJNIObject::callStaticObjectMethod<jstring>(const char *className, + const char *methodName) +{ + return callStaticObjectMethod<jstring>(className, methodName, "()Ljava/lang/String;"); +} + +template <> +QJNILocalRef<jstring> QJNIObject::callStaticObjectMethod<jstring>(jclass clazz, + const char *methodName) +{ + return callStaticObjectMethod<jstring>(clazz, methodName, "()Ljava/lang/String;"); +} + +template <> +QJNILocalRef<jbooleanArray> QJNIObject::callStaticObjectMethod<jbooleanArray>(const char *className, + const char *methodName) +{ + return callStaticObjectMethod<jbooleanArray>(className, methodName, "()[Z"); +} + +template <> +QJNILocalRef<jbooleanArray> QJNIObject::callStaticObjectMethod<jbooleanArray>(jclass clazz, + const char *methodName) +{ + return callStaticObjectMethod<jbooleanArray>(clazz, methodName, "()[Z"); +} + +template <> +QJNILocalRef<jbyteArray> QJNIObject::callStaticObjectMethod<jbyteArray>(const char *className, + const char *methodName) +{ + return callStaticObjectMethod<jbyteArray>(className, methodName, "()[B"); +} + +template <> +QJNILocalRef<jbyteArray> QJNIObject::callStaticObjectMethod<jbyteArray>(jclass clazz, + const char *methodName) +{ + return callStaticObjectMethod<jbyteArray>(clazz, methodName, "()[B"); +} + +template <> +QJNILocalRef<jcharArray> QJNIObject::callStaticObjectMethod<jcharArray>(const char *className, + const char *methodName) +{ + return callStaticObjectMethod<jcharArray>(className, methodName, "()[C"); +} + +template <> +QJNILocalRef<jcharArray> QJNIObject::callStaticObjectMethod<jcharArray>(jclass clazz, + const char *methodName) +{ + return callStaticObjectMethod<jcharArray>(clazz, methodName, "()[C"); +} + +template <> +QJNILocalRef<jshortArray> QJNIObject::callStaticObjectMethod<jshortArray>(const char *className, + const char *methodName) +{ + return callStaticObjectMethod<jshortArray>(className, methodName, "()[S"); +} + +template <> +QJNILocalRef<jshortArray> QJNIObject::callStaticObjectMethod<jshortArray>(jclass clazz, + const char *methodName) +{ + return callStaticObjectMethod<jshortArray>(clazz, methodName, "()[S"); +} + +template <> +QJNILocalRef<jintArray> QJNIObject::callStaticObjectMethod<jintArray>(const char *className, + const char *methodName) +{ + return callStaticObjectMethod<jintArray>(className, methodName, "()[I"); +} + +template <> +QJNILocalRef<jintArray> QJNIObject::callStaticObjectMethod<jintArray>(jclass clazz, + const char *methodName) +{ + return callStaticObjectMethod<jintArray>(clazz, methodName, "()[I"); +} + +template <> +QJNILocalRef<jlongArray> QJNIObject::callStaticObjectMethod<jlongArray>(const char *className, + const char *methodName) +{ + return callStaticObjectMethod<jlongArray>(className, methodName, "()[J"); +} + +template <> +QJNILocalRef<jlongArray> QJNIObject::callStaticObjectMethod<jlongArray>(jclass clazz, + const char *methodName) +{ + return callStaticObjectMethod<jlongArray>(clazz, methodName, "()[J"); +} + +template <> +QJNILocalRef<jfloatArray> QJNIObject::callStaticObjectMethod<jfloatArray>(const char *className, + const char *methodName) +{ + return callStaticObjectMethod<jfloatArray>(className, methodName, "()[F"); +} + +template <> +QJNILocalRef<jfloatArray> QJNIObject::callStaticObjectMethod<jfloatArray>(jclass clazz, + const char *methodName) +{ + return callStaticObjectMethod<jfloatArray>(clazz, methodName, "()[F"); +} + +template <> +QJNILocalRef<jdoubleArray> QJNIObject::callStaticObjectMethod<jdoubleArray>(const char *className, + const char *methodName) +{ + return callStaticObjectMethod<jdoubleArray>(className, methodName, "()[D"); +} + +template <> +QJNILocalRef<jdoubleArray> QJNIObject::callStaticObjectMethod<jdoubleArray>(jclass clazz, + const char *methodName) +{ + return callStaticObjectMethod<jdoubleArray>(clazz, methodName, "()[D"); +} + +template <> +jboolean QJNIObject::getField<jboolean>(const char *fieldName) +{ + QAttachedJNIEnv env; + jboolean res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "Z"); + if (id) + res = env->GetBooleanField(m_jobject, id); + + return res; +} + +template <> +jbyte QJNIObject::getField<jbyte>(const char *fieldName) +{ + QAttachedJNIEnv env; + jbyte res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "B"); + if (id) + res = env->GetByteField(m_jobject, id); + + return res; +} + +template <> +jchar QJNIObject::getField<jchar>(const char *fieldName) +{ + QAttachedJNIEnv env; + jchar res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "C"); + if (id) + res = env->GetCharField(m_jobject, id); + + return res; +} + +template <> +jshort QJNIObject::getField<jshort>(const char *fieldName) +{ + QAttachedJNIEnv env; + jshort res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "S"); + if (id) + res = env->GetShortField(m_jobject, id); + + return res; +} + +template <> +jint QJNIObject::getField<jint>(const char *fieldName) +{ + QAttachedJNIEnv env; + jint res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "I"); + if (id) + res = env->GetIntField(m_jobject, id); + + return res; +} + +template <> +jlong QJNIObject::getField<jlong>(const char *fieldName) +{ + QAttachedJNIEnv env; + jlong res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "J"); + if (id) + res = env->GetLongField(m_jobject, id); + + return res; +} + +template <> +jfloat QJNIObject::getField<jfloat>(const char *fieldName) +{ + QAttachedJNIEnv env; + jfloat res = 0.f; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "F"); + if (id) + res = env->GetFloatField(m_jobject, id); + + return res; +} + +template <> +jdouble QJNIObject::getField<jdouble>(const char *fieldName) +{ + QAttachedJNIEnv env; + jdouble res = 0.; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "D"); + if (id) + res = env->GetDoubleField(m_jobject, id); + + return res; +} + +template <> +QJNILocalRef<jobject> QJNIObject::getObjectField<jobject>(const char *fieldName, const char *sig) +{ + QAttachedJNIEnv env; + jobject res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, sig); + if (id) + res = env->GetObjectField(m_jobject, id); + + return QJNILocalRef<jobject>(res); +} + +template <> +QJNILocalRef<jbooleanArray> QJNIObject::getObjectField<jbooleanArray>(const char *fieldName) +{ + QAttachedJNIEnv env; + jbooleanArray res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[Z"); + if (id) + res = static_cast<jbooleanArray>(env->GetObjectField(m_jobject, id)); + + return QJNILocalRef<jbooleanArray>(res); +} + +template <> +QJNILocalRef<jbyteArray> QJNIObject::getObjectField<jbyteArray>(const char *fieldName) +{ + QAttachedJNIEnv env; + jbyteArray res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[B"); + if (id) + res = static_cast<jbyteArray>(env->GetObjectField(m_jobject, id)); + + return QJNILocalRef<jbyteArray>(res); +} + +template <> +QJNILocalRef<jcharArray> QJNIObject::getObjectField<jcharArray>(const char *fieldName) +{ + QAttachedJNIEnv env; + jcharArray res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[C"); + if (id) + res = static_cast<jcharArray>(env->GetObjectField(m_jobject, id)); + + return QJNILocalRef<jcharArray>(res); +} + +template <> +QJNILocalRef<jshortArray> QJNIObject::getObjectField<jshortArray>(const char *fieldName) +{ + QAttachedJNIEnv env; + jshortArray res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[S"); + if (id) + res = static_cast<jshortArray>(env->GetObjectField(m_jobject, id)); + + return QJNILocalRef<jshortArray>(res); +} + +template <> +QJNILocalRef<jintArray> QJNIObject::getObjectField<jintArray>(const char *fieldName) +{ + QAttachedJNIEnv env; + jintArray res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[I"); + if (id) + res = static_cast<jintArray>(env->GetObjectField(m_jobject, id)); + + return QJNILocalRef<jintArray>(res); +} + +template <> +QJNILocalRef<jlongArray> QJNIObject::getObjectField<jlongArray>(const char *fieldName) +{ + QAttachedJNIEnv env; + jlongArray res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[J"); + if (id) + res = static_cast<jlongArray>(env->GetObjectField(m_jobject, id)); + + return QJNILocalRef<jlongArray>(res); +} + +template <> +QJNILocalRef<jfloatArray> QJNIObject::getObjectField<jfloatArray>(const char *fieldName) +{ + QAttachedJNIEnv env; + jfloatArray res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[F"); + if (id) + res = static_cast<jfloatArray>(env->GetObjectField(m_jobject, id)); + + return QJNILocalRef<jfloatArray>(res); +} + +template <> +QJNILocalRef<jdoubleArray> QJNIObject::getObjectField<jdoubleArray>(const char *fieldName) +{ + QAttachedJNIEnv env; + jdoubleArray res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[D"); + if (id) + res = static_cast<jdoubleArray>(env->GetObjectField(m_jobject, id)); + + return QJNILocalRef<jdoubleArray>(res); +} + +template <> +QJNILocalRef<jstring> QJNIObject::getObjectField<jstring>(const char *fieldName) +{ + QAttachedJNIEnv env; + jstring res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "Ljava/lang/String;"); + if (id) + res = static_cast<jstring>(env->GetObjectField(m_jobject, id)); + + return QJNILocalRef<jstring>(res); +} + +template <> +QJNILocalRef<jobjectArray> QJNIObject::getObjectField<jobjectArray>(const char *fieldName, + const char *sig) +{ + QAttachedJNIEnv env; + jobjectArray res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, sig); + if (id) + res = static_cast<jobjectArray>(env->GetObjectField(m_jobject, id)); + + return QJNILocalRef<jobjectArray>(res); +} + +template <> +void QJNIObject::setField<jboolean>(const char *fieldName, jboolean value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "Z"); + if (id) + env->SetBooleanField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField<jbyte>(const char *fieldName, jbyte value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "B"); + if (id) + env->SetByteField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField<jchar>(const char *fieldName, jchar value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "C"); + if (id) + env->SetCharField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField<jshort>(const char *fieldName, jshort value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "S"); + if (id) + env->SetShortField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField<jint>(const char *fieldName, jint value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "I"); + if (id) + env->SetIntField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField<jlong>(const char *fieldName, jlong value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "J"); + if (id) + env->SetLongField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField<jfloat>(const char *fieldName, jfloat value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "F"); + if (id) + env->SetFloatField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField<jdouble>(const char *fieldName, jdouble value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "D"); + if (id) + env->SetDoubleField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField<jbooleanArray>(const char *fieldName, jbooleanArray value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[Z"); + if (id) + env->SetObjectField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField<jbyteArray>(const char *fieldName, jbyteArray value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[B"); + if (id) + env->SetObjectField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField<jcharArray>(const char *fieldName, jcharArray value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[C"); + if (id) + env->SetObjectField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField<jshortArray>(const char *fieldName, jshortArray value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[S"); + if (id) + env->SetObjectField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField<jintArray>(const char *fieldName, jintArray value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[I"); + if (id) + env->SetObjectField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField<jlongArray>(const char *fieldName, jlongArray value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[J"); + if (id) + env->SetObjectField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField<jfloatArray>(const char *fieldName, jfloatArray value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[F"); + if (id) + env->SetObjectField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField<jdoubleArray>(const char *fieldName, jdoubleArray value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[D"); + if (id) + env->SetObjectField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField<jstring>(const char *fieldName, jstring value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "Ljava/lang/String;"); + if (id) + env->SetObjectField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField<jobject>(const char *fieldName, const char *sig, jobject value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, sig); + if (id) + env->SetObjectField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField<jobjectArray>(const char *fieldName, + const char *sig, + jobjectArray value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, sig); + if (id) + env->SetObjectField(m_jobject, id, value); + +} + +template <> +jboolean QJNIObject::getStaticField<jboolean>(jclass clazz, const char *fieldName) +{ + QAttachedJNIEnv env; + + jboolean res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "Z", true); + if (id) + res = env->GetStaticBooleanField(clazz, id); + + return res; +} + +template <> +jboolean QJNIObject::getStaticField<jboolean>(const char *className, const char *fieldName) +{ + QAttachedJNIEnv env; + + jboolean res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticField<jboolean>(clazz, fieldName); + + return res; +} + +template <> +jbyte QJNIObject::getStaticField<jbyte>(jclass clazz, const char *fieldName) +{ + QAttachedJNIEnv env; + + jbyte res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "B", true); + if (id) + res = env->GetStaticByteField(clazz, id); + + return res; +} + +template <> +jbyte QJNIObject::getStaticField<jbyte>(const char *className, const char *fieldName) +{ + QAttachedJNIEnv env; + + jbyte res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticField<jbyte>(clazz, fieldName); + + return res; +} + +template <> +jchar QJNIObject::getStaticField<jchar>(jclass clazz, const char *fieldName) +{ + QAttachedJNIEnv env; + + jchar res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "C", true); + if (id) + res = env->GetStaticCharField(clazz, id); + + return res; +} + +template <> +jchar QJNIObject::getStaticField<jchar>(const char *className, const char *fieldName) +{ + QAttachedJNIEnv env; + + jchar res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticField<jchar>(clazz, fieldName); + + return res; +} + +template <> +jshort QJNIObject::getStaticField<jshort>(jclass clazz, const char *fieldName) +{ + QAttachedJNIEnv env; + + jshort res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "S", true); + if (id) + res = env->GetStaticShortField(clazz, id); + + return res; +} + +template <> +jshort QJNIObject::getStaticField<jshort>(const char *className, const char *fieldName) +{ + QAttachedJNIEnv env; + + jshort res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticField<jshort>(clazz, fieldName); + + return res; +} + +template <> +jint QJNIObject::getStaticField<jint>(jclass clazz, const char *fieldName) +{ + QAttachedJNIEnv env; + + jint res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "I", true); + if (id) + res = env->GetStaticIntField(clazz, id); + + return res; +} + +template <> +jint QJNIObject::getStaticField<jint>(const char *className, const char *fieldName) +{ + QAttachedJNIEnv env; + + jint res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticField<jint>(clazz, fieldName); + + return res; +} + +template <> +jlong QJNIObject::getStaticField<jlong>(jclass clazz, const char *fieldName) +{ + QAttachedJNIEnv env; + + jlong res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "J", true); + if (id) + res = env->GetStaticLongField(clazz, id); + + return res; +} + +template <> +jlong QJNIObject::getStaticField<jlong>(const char *className, const char *fieldName) +{ + QAttachedJNIEnv env; + + jlong res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticField<jlong>(clazz, fieldName); + + return res; +} + +template <> +jfloat QJNIObject::getStaticField<jfloat>(jclass clazz, const char *fieldName) +{ + QAttachedJNIEnv env; + + jfloat res = 0.f; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "F", true); + if (id) + res = env->GetStaticFloatField(clazz, id); + + return res; +} + +template <> +jfloat QJNIObject::getStaticField<jfloat>(const char *className, const char *fieldName) +{ + QAttachedJNIEnv env; + + jfloat res = 0.f; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticField<jfloat>(clazz, fieldName); + + return res; +} + +template <> +jdouble QJNIObject::getStaticField<jdouble>(jclass clazz, const char *fieldName) +{ + QAttachedJNIEnv env; + + jdouble res = 0.; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "D", true); + if (id) + res = env->GetStaticDoubleField(clazz, id); + + return res; +} + +template <> +jdouble QJNIObject::getStaticField<jdouble>(const char *className, const char *fieldName) +{ + QAttachedJNIEnv env; + + jdouble res = 0.; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticField<jdouble>(clazz, fieldName); + + return res; +} + +template <> +QJNILocalRef<jobject> QJNIObject::getStaticObjectField<jobject>(jclass clazz, + const char *fieldName, + const char *sig) +{ + QAttachedJNIEnv env; + + jobject res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, sig, true); + if (id) + res = env->GetStaticObjectField(clazz, id); + + return QJNILocalRef<jobject>(res); +} + +template <> +QJNILocalRef<jobject> QJNIObject::getStaticObjectField<jobject>(const char *className, + const char *fieldName, + const char *sig) +{ + QAttachedJNIEnv env; + + QJNILocalRef<jobject> res; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticObjectField<jobject>(clazz, fieldName, sig); + + return res; +} + +template <> +QJNILocalRef<jstring> QJNIObject::getStaticObjectField<jstring>(jclass clazz, + const char *fieldName) +{ + QAttachedJNIEnv env; + + jstring res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "Ljava/lang/String;", true); + if (id) + res = static_cast<jstring>(env->GetStaticObjectField(clazz, id)); + + return QJNILocalRef<jstring>(res); +} + +template <> +QJNILocalRef<jstring> QJNIObject::getStaticObjectField<jstring>(const char *className, + const char *fieldName) +{ + QAttachedJNIEnv env; + + QJNILocalRef<jstring> res; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticObjectField<jstring>(clazz, fieldName); + + return res; +} + +template <> +QJNILocalRef<jbooleanArray> QJNIObject::getStaticObjectField<jbooleanArray>(jclass clazz, + const char *fieldName) +{ + QAttachedJNIEnv env; + + jbooleanArray res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "[Z", true); + if (id) + res = static_cast<jbooleanArray>(env->GetStaticObjectField(clazz, id)); + + return QJNILocalRef<jbooleanArray>(res); +} + +template <> +QJNILocalRef<jbooleanArray> QJNIObject::getStaticObjectField<jbooleanArray>(const char *className, + const char *fieldName) +{ + QAttachedJNIEnv env; + + QJNILocalRef<jbooleanArray> res; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticObjectField<jbooleanArray>(clazz, fieldName); + + return res; +} + +template <> +QJNILocalRef<jbyteArray> QJNIObject::getStaticObjectField<jbyteArray>(jclass clazz, + const char *fieldName) +{ + QAttachedJNIEnv env; + + jbyteArray res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "[B", true); + if (id) + res = static_cast<jbyteArray>(env->GetStaticObjectField(clazz, id)); + + return QJNILocalRef<jbyteArray>(res); +} + +template <> +QJNILocalRef<jbyteArray> QJNIObject::getStaticObjectField<jbyteArray>(const char *className, + const char *fieldName) +{ + QAttachedJNIEnv env; + + QJNILocalRef<jbyteArray> res; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticObjectField<jbyteArray>(clazz, fieldName); + + return res; +} + +template <> +QJNILocalRef<jcharArray> QJNIObject::getStaticObjectField<jcharArray>(jclass clazz, + const char *fieldName) +{ + QAttachedJNIEnv env; + + jcharArray res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "[C", true); + if (id) + res = static_cast<jcharArray>(env->GetStaticObjectField(clazz, id)); + + return QJNILocalRef<jcharArray>(res); +} + +template <> +QJNILocalRef<jcharArray> QJNIObject::getStaticObjectField<jcharArray>(const char *className, + const char *fieldName) +{ + QAttachedJNIEnv env; + + QJNILocalRef<jcharArray> res; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticObjectField<jcharArray>(clazz, fieldName); + + return res; +} + +template <> +QJNILocalRef<jshortArray> QJNIObject::getStaticObjectField<jshortArray>(jclass clazz, + const char *fieldName) +{ + QAttachedJNIEnv env; + + jshortArray res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "[S", true); + if (id) + res = static_cast<jshortArray>(env->GetStaticObjectField(clazz, id)); + + return QJNILocalRef<jshortArray>(res); +} + +template <> +QJNILocalRef<jshortArray> QJNIObject::getStaticObjectField<jshortArray>(const char *className, + const char *fieldName) +{ + QAttachedJNIEnv env; + + QJNILocalRef<jshortArray> res; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticObjectField<jshortArray>(clazz, fieldName); + + return res; +} + +template <> +QJNILocalRef<jintArray> QJNIObject::getStaticObjectField<jintArray>(jclass clazz, + const char *fieldName) +{ + QAttachedJNIEnv env; + + jintArray res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "[I", true); + if (id) + res = static_cast<jintArray>(env->GetStaticObjectField(clazz, id)); + + return QJNILocalRef<jintArray>(res); +} + +template <> +QJNILocalRef<jintArray> QJNIObject::getStaticObjectField<jintArray>(const char *className, + const char *fieldName) +{ + QAttachedJNIEnv env; + + QJNILocalRef<jintArray> res; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticObjectField<jintArray>(clazz, fieldName); + + return res; +} + +template <> +QJNILocalRef<jlongArray> QJNIObject::getStaticObjectField<jlongArray>(jclass clazz, + const char *fieldName) +{ + QAttachedJNIEnv env; + + jlongArray res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "[J", true); + if (id) + res = static_cast<jlongArray>(env->GetStaticObjectField(clazz, id)); + + return QJNILocalRef<jlongArray>(res); +} + +template <> +QJNILocalRef<jlongArray> QJNIObject::getStaticObjectField<jlongArray>(const char *className, + const char *fieldName) +{ + QAttachedJNIEnv env; + + QJNILocalRef<jlongArray> res; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticObjectField<jlongArray>(clazz, fieldName); + + return res; +} + +template <> +QJNILocalRef<jfloatArray> QJNIObject::getStaticObjectField<jfloatArray>(jclass clazz, + const char *fieldName) +{ + QAttachedJNIEnv env; + + jfloatArray res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "[F", true); + if (id) + res = static_cast<jfloatArray>(env->GetStaticObjectField(clazz, id)); + + return QJNILocalRef<jfloatArray>(res); +} + +template <> +QJNILocalRef<jfloatArray> QJNIObject::getStaticObjectField<jfloatArray>(const char *className, + const char *fieldName) +{ + QAttachedJNIEnv env; + + QJNILocalRef<jfloatArray> res; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticObjectField<jfloatArray>(clazz, fieldName); + + return res; +} + +template <> +QJNILocalRef<jdoubleArray> QJNIObject::getStaticObjectField<jdoubleArray>(jclass clazz, + const char *fieldName) +{ + QAttachedJNIEnv env; + + jdoubleArray res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "[D", true); + if (id) + res = static_cast<jdoubleArray>(env->GetStaticObjectField(clazz, id)); + + return QJNILocalRef<jdoubleArray>(res); +} + +template <> +QJNILocalRef<jdoubleArray> QJNIObject::getStaticObjectField<jdoubleArray>(const char *className, + const char *fieldName) +{ + QAttachedJNIEnv env; + + QJNILocalRef<jdoubleArray> res; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticObjectField<jdoubleArray>(clazz, fieldName); + + return res; +} + +template <> +QJNILocalRef<jobjectArray> QJNIObject::getStaticObjectField<jobjectArray>(jclass clazz, + const char *fieldName, + const char *sig) +{ + QAttachedJNIEnv env; + + jobjectArray res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, sig, true); + if (id) + res = static_cast<jobjectArray>(env->GetStaticObjectField(clazz, id)); + + return QJNILocalRef<jobjectArray>(res); +} + +template <> +QJNILocalRef<jobjectArray> QJNIObject::getStaticObjectField<jobjectArray>(const char *className, + const char *fieldName, + const char *sig) +{ + QAttachedJNIEnv env; + + QJNILocalRef<jobjectArray> res; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticObjectField<jobjectArray>(clazz, fieldName, sig); + + return res; +} + +template <> +void QJNIObject::setStaticField<jboolean>(jclass clazz, const char *fieldName, jboolean value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, clazz, fieldName, "Z", true); + if (id) + env->SetStaticBooleanField(clazz, id, value); +} + +template <> +void QJNIObject::setStaticField<jboolean>(const char *className, + const char *fieldName, + jboolean value) +{ + QAttachedJNIEnv env; + jclass clazz = getCachedClass(env, className); + if (clazz) + setStaticField<jboolean>(clazz, fieldName, value); +} + +template <> +void QJNIObject::setStaticField<jbyte>(jclass clazz, const char *fieldName, jbyte value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, clazz, fieldName, "B", true); + if (id) + env->SetStaticByteField(clazz, id, value); +} + +template <> +void QJNIObject::setStaticField<jbyte>(const char *className, + const char *fieldName, + jbyte value) +{ + QAttachedJNIEnv env; + jclass clazz = getCachedClass(env, className); + if (clazz) + setStaticField<jbyte>(clazz, fieldName, value); +} + +template <> +void QJNIObject::setStaticField<jchar>(jclass clazz, const char *fieldName, jchar value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, clazz, fieldName, "C", true); + if (id) + env->SetStaticCharField(clazz, id, value); +} + +template <> +void QJNIObject::setStaticField<jchar>(const char *className, + const char *fieldName, + jchar value) +{ + QAttachedJNIEnv env; + jclass clazz = getCachedClass(env, className); + if (clazz) + setStaticField<jchar>(clazz, fieldName, value); +} + +template <> +void QJNIObject::setStaticField<jshort>(jclass clazz, const char *fieldName, jshort value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, clazz, fieldName, "S", true); + if (id) + env->SetStaticShortField(clazz, id, value); +} + +template <> +void QJNIObject::setStaticField<jshort>(const char *className, + const char *fieldName, + jshort value) +{ + QAttachedJNIEnv env; + jclass clazz = getCachedClass(env, className); + if (clazz) + setStaticField<jshort>(clazz, fieldName, value); +} + +template <> +void QJNIObject::setStaticField<jint>(jclass clazz, const char *fieldName, jint value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, clazz, fieldName, "I", true); + if (id) + env->SetStaticIntField(clazz, id, value); +} + +template <> +void QJNIObject::setStaticField<jint>(const char *className, const char *fieldName, jint value) +{ + QAttachedJNIEnv env; + jclass clazz = getCachedClass(env, className); + if (clazz) + setStaticField<jint>(clazz, fieldName, value); +} + +template <> +void QJNIObject::setStaticField<jlong>(jclass clazz, const char *fieldName, jlong value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, clazz, fieldName, "J", true); + if (id) + env->SetStaticLongField(clazz, id, value); +} + +template <> +void QJNIObject::setStaticField<jlong>(const char *className, + const char *fieldName, + jlong value) +{ + QAttachedJNIEnv env; + jclass clazz = getCachedClass(env, className); + if (clazz) + setStaticField<jlong>(clazz, fieldName, value); +} + +template <> +void QJNIObject::setStaticField<jfloat>(jclass clazz, const char *fieldName, jfloat value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, clazz, fieldName, "F", true); + if (id) + env->SetStaticFloatField(clazz, id, value); +} + +template <> +void QJNIObject::setStaticField<jfloat>(const char *className, + const char *fieldName, + jfloat value) +{ + QAttachedJNIEnv env; + jclass clazz = getCachedClass(env, className); + if (clazz) + setStaticField<jfloat>(clazz, fieldName, value); +} + +template <> +void QJNIObject::setStaticField<jdouble>(jclass clazz, const char *fieldName, jdouble value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, clazz, fieldName, "D", true); + if (id) + env->SetStaticDoubleField(clazz, id, value); +} + +template <> +void QJNIObject::setStaticField<jdouble>(const char *className, + const char *fieldName, + jdouble value) +{ + QAttachedJNIEnv env; + jclass clazz = getCachedClass(env, className); + if (clazz) + setStaticField<jdouble>(clazz, fieldName, value); +} + +template <> +void QJNIObject::setStaticField<jobject>(jclass clazz, + const char *fieldName, + const char *sig, + jobject value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, clazz, fieldName, sig, true); + if (id) + env->SetStaticObjectField(clazz, id, value); +} + +template <> +void QJNIObject::setStaticField<jobject>(const char *className, + const char *fieldName, + const char *sig, + jobject value) +{ + QAttachedJNIEnv env; + jclass clazz = getCachedClass(env, className); + if (clazz) + setStaticField<jobject>(clazz, fieldName, sig, value); +} + +template <> +void QJNIObject::setStaticField<jstring>(const char *className, + const char *fieldName, + jstring value) +{ + setStaticField<jobject>(className, fieldName, "Ljava/lang/String;", value); +} + +template <> +void QJNIObject::setStaticField<jstring>(jclass clazz, const char *fieldName, jstring value) +{ + setStaticField<jobject>(clazz, fieldName, "Ljava/lang/String;", value); +} + +template <> +void QJNIObject::setStaticField<jbooleanArray>(const char *className, + const char *fieldName, + jbooleanArray value) +{ + setStaticField<jobject>(className, fieldName, "[Z", value); +} + +template <> +void QJNIObject::setStaticField<jbooleanArray>(jclass clazz, + const char *fieldName, + jbooleanArray value) +{ + setStaticField<jobject>(clazz, fieldName, "[Z", value); +} + +template <> +void QJNIObject::setStaticField<jbyteArray>(const char *className, + const char *fieldName, + jbyteArray value) +{ + setStaticField<jobject>(className, fieldName, "[B", value); +} + +template <> +void QJNIObject::setStaticField<jbyteArray>(jclass clazz, + const char *fieldName, + jbyteArray value) +{ + setStaticField<jobject>(clazz, fieldName, "[B", value); +} + +template <> +void QJNIObject::setStaticField<jcharArray>(const char *className, + const char *fieldName, + jcharArray value) +{ + setStaticField<jobject>(className, fieldName, "[C", value); +} + +template <> +void QJNIObject::setStaticField<jcharArray>(jclass clazz, + const char *fieldName, + jcharArray value) +{ + setStaticField<jobject>(clazz, fieldName, "[C", value); +} + +template <> +void QJNIObject::setStaticField<jshortArray>(const char *className, + const char *fieldName, + jshortArray value) +{ + setStaticField<jobject>(className, fieldName, "[S", value); +} + +template <> +void QJNIObject::setStaticField<jshortArray>(jclass clazz, + const char *fieldName, + jshortArray value) +{ + setStaticField<jobject>(clazz, fieldName, "[S", value); +} + +template <> +void QJNIObject::setStaticField<jintArray>(const char *className, + const char *fieldName, + jintArray value) +{ + setStaticField<jobject>(className, fieldName, "[I", value); +} + +template <> +void QJNIObject::setStaticField<jintArray>(jclass clazz, + const char *fieldName, + jintArray value) +{ + setStaticField<jobject>(clazz, fieldName, "[I", value); +} + +template <> +void QJNIObject::setStaticField<jlongArray>(const char *className, + const char *fieldName, + jlongArray value) +{ + setStaticField<jobject>(className, fieldName, "[J", value); +} + +template <> +void QJNIObject::setStaticField<jlongArray>(jclass clazz, + const char *fieldName, + jlongArray value) +{ + setStaticField<jobject>(clazz, fieldName, "[J", value); +} + +template <> +void QJNIObject::setStaticField<jfloatArray>(const char *className, + const char *fieldName, + jfloatArray value) +{ + setStaticField<jobject>(className, fieldName, "[F", value); +} + +template <> +void QJNIObject::setStaticField<jfloatArray>(jclass clazz, + const char *fieldName, + jfloatArray value) +{ + setStaticField<jobject>(clazz, fieldName, "[F", value); +} + +template <> +void QJNIObject::setStaticField<jdoubleArray>(const char *className, + const char *fieldName, + jdoubleArray value) +{ + setStaticField<jobject>(className, fieldName, "[D", value); +} + +template <> +void QJNIObject::setStaticField<jdoubleArray>(jclass clazz, + const char *fieldName, + jdoubleArray value) +{ + setStaticField<jobject>(clazz, fieldName, "[D", value); +} + + +QT_END_NAMESPACE diff --git a/src/platformsupport/jniconvenience/qjniobject_p.h b/src/platformsupport/jniconvenience/qjniobject_p.h new file mode 100644 index 0000000000..6874765f06 --- /dev/null +++ b/src/platformsupport/jniconvenience/qjniobject_p.h @@ -0,0 +1,169 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QJNIOBJECT_H +#define QJNIOBJECT_H + +#include <qglobal.h> +#include <jni.h> + +QT_BEGIN_NAMESPACE + +template <typename T> +class QJNILocalRef; + +/** + * Allows to wrap any Java class and partially hide some of the jni calls. + * + * Usage example: + * + * QJNIObject javaString("java/lang/String"); + * jchar char = javaString.callMethod<jchar>("charAt", "(I)C", 0); + * + * ---- + * + * jstring string = QJNIObject::callStaticMethod<jstring>("java/lang/String", + * "valueOf", + * "(I)Ljava/lang/String;", 2); + * + * ---- + * + * // Constructor with argument + * jstring someString; + * QJNIObject someObject("java/some/Class", "(Ljava/lang/String;)V", someString); + * someObject.setField<jint>("fieldName", 10); + * someObject.callMethod<void>("doStuff"); + */ +class QJNIObject +{ +public: + QJNIObject(const char *className); + QJNIObject(const char *className, const char *sig, ...); + QJNIObject(jclass clazz); + QJNIObject(jclass clazz, const char *sig, ...); + QJNIObject(jobject obj); + virtual ~QJNIObject(); + + static bool isClassAvailable(const char *className); + + bool isValid() const { return m_jobject != 0; } + jobject object() const { return m_jobject; } + + template <typename T> + T callMethod(const char *methodName); + template <typename T> + T callMethod(const char *methodName, const char *sig, ...); + template <typename T> + QJNILocalRef<T> callObjectMethod(const char *methodName); + template <typename T> + QJNILocalRef<T> callObjectMethod(const char *methodName, const char *sig, ...); + + template <typename T> + static T callStaticMethod(const char *className, const char *methodName); + template <typename T> + static T callStaticMethod(const char *className, const char *methodName, const char *sig, ...); + template <typename T> + static QJNILocalRef<T> callStaticObjectMethod(const char *className, const char *methodName); + template <typename T> + static QJNILocalRef<T> callStaticObjectMethod(const char *className, + const char *methodName, + const char *sig, ...); + template <typename T> + static T callStaticMethod(jclass clazz, const char *methodName); + template <typename T> + static T callStaticMethod(jclass clazz, const char *methodName, const char *sig, ...); + template <typename T> + static QJNILocalRef<T> callStaticObjectMethod(jclass clazz, const char *methodName); + template <typename T> + static QJNILocalRef<T> callStaticObjectMethod(jclass clazz, + const char *methodName, + const char *sig, ...); + + template <typename T> + T getField(const char *fieldName); + template <typename T> + T getField(const char *fieldName, const char *sig); + template <typename T> + QJNILocalRef<T> getObjectField(const char *fieldName); + template <typename T> + QJNILocalRef<T> getObjectField(const char *fieldName, const char *sig); + + template <typename T> + void setField(const char *fieldName, T value); + template <typename T> + void setField(const char *fieldName, const char *sig, T value); + + template <typename T> + static QJNILocalRef<T> getStaticObjectField(const char *className, const char *fieldName); + template <typename T> + static QJNILocalRef<T> getStaticObjectField(const char *className, + const char *fieldName, + const char *sig); + template <typename T> + static T getStaticField(const char *className, const char *fieldName); + template <typename T> + static QJNILocalRef<T> getStaticObjectField(jclass clazz, const char *fieldName); + template <typename T> + static QJNILocalRef<T> getStaticObjectField(jclass clazz, const char *fieldName, const char *sig); + template <typename T> + static T getStaticField(jclass clazz, const char *fieldName); + + template <typename T> + static void setStaticField(const char *className, + const char *fieldName, + const char *sig, + T value); + template <typename T> + static void setStaticField(const char *className, const char *fieldName, T value); + template <typename T> + static void setStaticField(jclass clazz, const char *fieldName, const char *sig, T value); + template <typename T> + static void setStaticField(jclass clazz, const char *fieldName, T value); + +protected: + jobject m_jobject; + jclass m_jclass; + bool m_own_jclass; +}; + +QT_END_NAMESPACE + +#endif // QJNIOBJECT_H diff --git a/src/platformsupport/platformsupport.pro b/src/platformsupport/platformsupport.pro index 8e0f396993..0566e9d3ec 100644 --- a/src/platformsupport/platformsupport.pro +++ b/src/platformsupport/platformsupport.pro @@ -22,3 +22,4 @@ include(devicediscovery/devicediscovery.pri) include(services/services.pri) include(themes/themes.pri) include(linuxaccessibility/linuxaccessibility.pri) +include(jniconvenience/jniconvenience.pri) diff --git a/src/plugins/bearer/bearer.pro b/src/plugins/bearer/bearer.pro index 0375500306..42f039b19b 100644 --- a/src/plugins/bearer/bearer.pro +++ b/src/plugins/bearer/bearer.pro @@ -9,7 +9,7 @@ linux*:qtHaveModule(dbus) { win32:SUBDIRS += generic blackberry:SUBDIRS += blackberry win32:!wince*:SUBDIRS += nativewifi -macx:contains(QT_CONFIG, corewlan):SUBDIRS += corewlan -macx:SUBDIRS += generic +mac:contains(QT_CONFIG, corewlan):SUBDIRS += corewlan +mac:SUBDIRS += generic isEmpty(SUBDIRS):SUBDIRS = generic diff --git a/src/plugins/platforminputcontexts/platforminputcontexts.pro b/src/plugins/platforminputcontexts/platforminputcontexts.pro index c8449e7e44..7b3c6e9c36 100644 --- a/src/plugins/platforminputcontexts/platforminputcontexts.pro +++ b/src/plugins/platforminputcontexts/platforminputcontexts.pro @@ -1,4 +1,4 @@ TEMPLATE = subdirs qtHaveModule(dbus) { -!macx:!win32:SUBDIRS += ibus maliit +!mac:!win32:SUBDIRS += ibus maliit } diff --git a/src/sql/drivers/oci/qsql_oci.pri b/src/sql/drivers/oci/qsql_oci.pri index 9108dbaa3c..66ccdb1abb 100644 --- a/src/sql/drivers/oci/qsql_oci.pri +++ b/src/sql/drivers/oci/qsql_oci.pri @@ -6,4 +6,4 @@ unix { } else { LIBS *= -loci } -macx:QMAKE_LFLAGS += -Wl,-flat_namespace,-U,_environ +mac:QMAKE_LFLAGS += -Wl,-flat_namespace,-U,_environ diff --git a/src/sql/kernel/qsqlresult.cpp b/src/sql/kernel/qsqlresult.cpp index ea972abf50..db55ad7813 100644 --- a/src/sql/kernel/qsqlresult.cpp +++ b/src/sql/kernel/qsqlresult.cpp @@ -218,11 +218,24 @@ QString QSqlResultPrivate::namedToPositionalBinding(const QString &query) QSqlResult::QSqlResult(const QSqlDriver *db) { - d = new QSqlResultPrivate(this); + d_ptr = new QSqlResultPrivate; + Q_D(QSqlResult); + d->q_ptr = this; d->sqldriver = const_cast<QSqlDriver *>(db); - if(db) { - setNumericalPrecisionPolicy(db->numericalPrecisionPolicy()); - } + if (d->sqldriver) + setNumericalPrecisionPolicy(d->sqldriver->numericalPrecisionPolicy()); +} + +/*! \internal +*/ +QSqlResult::QSqlResult(QSqlResultPrivate &dd, const QSqlDriver *db) +{ + d_ptr = ⅆ + Q_D(QSqlResult); + d->q_ptr = this; + d->sqldriver = const_cast<QSqlDriver *>(db); + if (d->sqldriver) + setNumericalPrecisionPolicy(d->sqldriver->numericalPrecisionPolicy()); } /*! @@ -231,6 +244,7 @@ QSqlResult::QSqlResult(const QSqlDriver *db) QSqlResult::~QSqlResult() { + Q_D(QSqlResult); delete d; } @@ -243,6 +257,7 @@ QSqlResult::~QSqlResult() void QSqlResult::setQuery(const QString& query) { + Q_D(QSqlResult); d->sql = query; } @@ -255,6 +270,7 @@ void QSqlResult::setQuery(const QString& query) QString QSqlResult::lastQuery() const { + Q_D(const QSqlResult); return d->sql; } @@ -267,6 +283,7 @@ QString QSqlResult::lastQuery() const */ int QSqlResult::at() const { + Q_D(const QSqlResult); return d->idx; } @@ -281,6 +298,7 @@ int QSqlResult::at() const bool QSqlResult::isValid() const { + Q_D(const QSqlResult); return d->idx != QSql::BeforeFirstRow && d->idx != QSql::AfterLastRow; } @@ -298,6 +316,7 @@ bool QSqlResult::isValid() const bool QSqlResult::isActive() const { + Q_D(const QSqlResult); return d->active; } @@ -310,6 +329,7 @@ bool QSqlResult::isActive() const void QSqlResult::setAt(int index) { + Q_D(QSqlResult); d->idx = index; } @@ -325,6 +345,7 @@ void QSqlResult::setAt(int index) void QSqlResult::setSelect(bool select) { + Q_D(QSqlResult); d->isSel = select; } @@ -337,6 +358,7 @@ void QSqlResult::setSelect(bool select) bool QSqlResult::isSelect() const { + Q_D(const QSqlResult); return d->isSel; } @@ -347,6 +369,7 @@ bool QSqlResult::isSelect() const const QSqlDriver *QSqlResult::driver() const { + Q_D(const QSqlResult); return d->sqldriver; } @@ -360,6 +383,7 @@ const QSqlDriver *QSqlResult::driver() const void QSqlResult::setActive(bool active) { + Q_D(QSqlResult); if (active && d->executedQuery.isEmpty()) d->executedQuery = d->sql; @@ -375,6 +399,7 @@ void QSqlResult::setActive(bool active) void QSqlResult::setLastError(const QSqlError &error) { + Q_D(QSqlResult); d->error = error; } @@ -385,6 +410,7 @@ void QSqlResult::setLastError(const QSqlError &error) QSqlError QSqlResult::lastError() const { + Q_D(const QSqlResult); return d->error; } @@ -519,6 +545,7 @@ bool QSqlResult::fetchPrevious() */ bool QSqlResult::isForwardOnly() const { + Q_D(const QSqlResult); return d->forwardOnly; } @@ -540,6 +567,7 @@ bool QSqlResult::isForwardOnly() const */ void QSqlResult::setForwardOnly(bool forward) { + Q_D(QSqlResult); d->forwardOnly = forward; } @@ -554,6 +582,7 @@ void QSqlResult::setForwardOnly(bool forward) */ bool QSqlResult::savePrepare(const QString& query) { + Q_D(QSqlResult); if (!driver()) return false; d->clear(); @@ -579,6 +608,7 @@ bool QSqlResult::savePrepare(const QString& query) */ bool QSqlResult::prepare(const QString& query) { + Q_D(QSqlResult); d->sql = query; if (d->holders.isEmpty()) { // parse the query to memorize parameter location @@ -595,6 +625,7 @@ bool QSqlResult::prepare(const QString& query) */ bool QSqlResult::exec() { + Q_D(QSqlResult); bool ret; // fake preparation - just replace the placeholders.. QString query = lastQuery(); @@ -647,6 +678,7 @@ bool QSqlResult::exec() */ void QSqlResult::bindValue(int index, const QVariant& val, QSql::ParamType paramType) { + Q_D(QSqlResult); d->binds = PositionalBinding; d->indexes[QSqlResultPrivate::fieldSerial(index)].append(index); if (d->values.count() <= index) @@ -675,6 +707,7 @@ void QSqlResult::bindValue(int index, const QVariant& val, QSql::ParamType param void QSqlResult::bindValue(const QString& placeholder, const QVariant& val, QSql::ParamType paramType) { + Q_D(QSqlResult); d->binds = NamedBinding; // if the index has already been set when doing emulated named // bindings - don't reset it @@ -696,6 +729,7 @@ void QSqlResult::bindValue(const QString& placeholder, const QVariant& val, */ void QSqlResult::addBindValue(const QVariant& val, QSql::ParamType paramType) { + Q_D(QSqlResult); d->binds = PositionalBinding; bindValue(d->bindCount, val, paramType); ++d->bindCount; @@ -709,6 +743,7 @@ void QSqlResult::addBindValue(const QVariant& val, QSql::ParamType paramType) */ QVariant QSqlResult::boundValue(int index) const { + Q_D(const QSqlResult); return d->values.value(index); } @@ -722,6 +757,7 @@ QVariant QSqlResult::boundValue(int index) const */ QVariant QSqlResult::boundValue(const QString& placeholder) const { + Q_D(const QSqlResult); QList<int> indexes = d->indexes.value(placeholder); return d->values.value(indexes.value(0,-1)); } @@ -733,6 +769,7 @@ QVariant QSqlResult::boundValue(const QString& placeholder) const */ QSql::ParamType QSqlResult::bindValueType(int index) const { + Q_D(const QSqlResult); return d->types.value(index, QSql::In); } @@ -744,6 +781,7 @@ QSql::ParamType QSqlResult::bindValueType(int index) const */ QSql::ParamType QSqlResult::bindValueType(const QString& placeholder) const { + Q_D(const QSqlResult); return d->types.value(d->indexes.value(placeholder).value(0,-1), QSql::In); } @@ -754,6 +792,7 @@ QSql::ParamType QSqlResult::bindValueType(const QString& placeholder) const */ int QSqlResult::boundValueCount() const { + Q_D(const QSqlResult); return d->values.count(); } @@ -765,7 +804,8 @@ int QSqlResult::boundValueCount() const */ QVector<QVariant>& QSqlResult::boundValues() const { - return d->values; + Q_D(const QSqlResult); + return const_cast<QSqlResultPrivate *>(d)->values; } /*! @@ -773,6 +813,7 @@ QVector<QVariant>& QSqlResult::boundValues() const */ QSqlResult::BindingSyntax QSqlResult::bindingSyntax() const { + Q_D(const QSqlResult); return d->binds; } @@ -782,6 +823,7 @@ QSqlResult::BindingSyntax QSqlResult::bindingSyntax() const */ void QSqlResult::clear() { + Q_D(QSqlResult); d->clear(); } @@ -795,11 +837,13 @@ void QSqlResult::clear() */ QString QSqlResult::executedQuery() const { + Q_D(const QSqlResult); return d->executedQuery; } void QSqlResult::resetBindCount() { + Q_D(QSqlResult); d->resetBindCount(); } @@ -811,6 +855,7 @@ void QSqlResult::resetBindCount() */ QString QSqlResult::boundValueName(int index) const { + Q_D(const QSqlResult); return d->holderAt(index); } @@ -822,6 +867,7 @@ QString QSqlResult::boundValueName(int index) const */ bool QSqlResult::hasOutValues() const { + Q_D(const QSqlResult); if (d->types.isEmpty()) return false; QHash<int, QSql::ParamType>::ConstIterator it; @@ -901,6 +947,7 @@ void QSqlResult::virtual_hook(int, void *) bool QSqlResult::execBatch(bool arrayBind) { Q_UNUSED(arrayBind); + Q_D(QSqlResult); QVector<QVariant> values = d->values; if (values.count() == 0) @@ -924,6 +971,7 @@ void QSqlResult::detachFromResultSet() */ void QSqlResult::setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy policy) { + Q_D(QSqlResult); d->precisionPolicy = policy; } @@ -931,6 +979,7 @@ void QSqlResult::setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy poli */ QSql::NumericalPrecisionPolicy QSqlResult::numericalPrecisionPolicy() const { + Q_D(const QSqlResult); return d->precisionPolicy; } diff --git a/src/sql/kernel/qsqlresult.h b/src/sql/kernel/qsqlresult.h index 649e3587ab..05f3d7ffec 100644 --- a/src/sql/kernel/qsqlresult.h +++ b/src/sql/kernel/qsqlresult.h @@ -59,9 +59,9 @@ class QSqlResultPrivate; class Q_SQL_EXPORT QSqlResult { + Q_DECLARE_PRIVATE(QSqlResult) friend class QSqlQuery; friend class QSqlTableModelPrivate; - friend class QSqlResultPrivate; public: virtual ~QSqlResult(); @@ -74,6 +74,7 @@ protected: }; explicit QSqlResult(const QSqlDriver * db); + QSqlResult(QSqlResultPrivate &dd, const QSqlDriver *db); int at() const; QString lastQuery() const; QSqlError lastError() const; @@ -132,8 +133,7 @@ protected: virtual bool nextResult(); void resetBindCount(); // HACK -private: - QSqlResultPrivate* d; + QSqlResultPrivate *d_ptr; private: Q_DISABLE_COPY(QSqlResult) diff --git a/src/sql/kernel/qsqlresult_p.h b/src/sql/kernel/qsqlresult_p.h index 246b914ec7..46ee6ce195 100644 --- a/src/sql/kernel/qsqlresult_p.h +++ b/src/sql/kernel/qsqlresult_p.h @@ -70,9 +70,10 @@ struct QHolder { class Q_SQL_EXPORT QSqlResultPrivate { + public: - QSqlResultPrivate(QSqlResult *d) - : q(d), + QSqlResultPrivate() + : q_ptr(0), idx(QSql::BeforeFirstRow), active(false), isSel(false), @@ -81,6 +82,7 @@ public: bindCount(0), binds(QSqlResult::PositionalBinding) { } + virtual ~QSqlResultPrivate() { } void clearValues() { @@ -116,7 +118,7 @@ public: QString namedToPositionalBinding(const QString &query); QString holderAt(int index) const; - QSqlResult *q; + QSqlResult *q_ptr; QPointer<QSqlDriver> sqldriver; int idx; QString sql; diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro index 0d4b62fd16..cc7d40c43e 100644 --- a/src/tools/bootstrap/bootstrap.pro +++ b/src/tools/bootstrap/bootstrap.pro @@ -113,7 +113,7 @@ win32:SOURCES += ../../corelib/io/qfilesystemengine_win.cpp \ ../../corelib/io/qsettings_win.cpp \ ../../corelib/plugin/qsystemlibrary.cpp \ -macx: { +mac { SOURCES += ../../corelib/io/qfilesystemengine_mac.cpp \ ../../corelib/io/qsettings_mac.cpp \ ../../corelib/kernel/qcore_mac.cpp diff --git a/src/widgets/styles/styles.pri b/src/widgets/styles/styles.pri index 9f23fb30cc..a207cd2761 100644 --- a/src/widgets/styles/styles.pri +++ b/src/widgets/styles/styles.pri @@ -40,7 +40,7 @@ contains( styles, all ) { styles = fusion mac windows windowsxp windowsvista } -!macx-*|ios:styles -= mac +!mac:styles -= mac contains(QT_CONFIG, gtkstyle) { QMAKE_CXXFLAGS += $$QT_CFLAGS_QGTKSTYLE diff --git a/src/widgets/util/util.pri b/src/widgets/util/util.pri index 5847b12166..598a3082c0 100644 --- a/src/widgets/util/util.pri +++ b/src/widgets/util/util.pri @@ -36,6 +36,6 @@ win32:!wince* { SOURCES += util/qsystemtrayicon_qpa.cpp } -macx { +mac { OBJECTIVE_SOURCES += util/qscroller_mac.mm } diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index 11824f4ab6..f01e319872 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -81,6 +81,7 @@ private slots: void getSetCheck(); void constructing(); void simpleStart(); + void startWithOpen(); void execute(); void startDetached(); void crashTest(); @@ -283,6 +284,25 @@ void tst_QProcess::simpleStart() QCOMPARE(qvariant_cast<QProcess::ProcessState>(spy.at(1).at(0)), QProcess::Running); QCOMPARE(qvariant_cast<QProcess::ProcessState>(spy.at(2).at(0)), QProcess::NotRunning); } + +//----------------------------------------------------------------------------- +void tst_QProcess::startWithOpen() +{ + QProcess p; + QTest::ignoreMessage(QtWarningMsg, "QProcess::start: program not set"); + QCOMPARE(p.open(QIODevice::ReadOnly), false); + + p.setProgram("testProcessNormal/testProcessNormal"); + QCOMPARE(p.program(), QString("testProcessNormal/testProcessNormal")); + + p.setArguments(QStringList() << "arg1" << "arg2"); + QCOMPARE(p.arguments().size(), 2); + + QVERIFY(p.open(QIODevice::ReadOnly)); + QCOMPARE(p.openMode(), QIODevice::ReadOnly); + QVERIFY(p.waitForFinished(5000)); +} + //----------------------------------------------------------------------------- void tst_QProcess::execute() { diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp index 42bf9eeca3..10c00e2a67 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp +++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp @@ -769,6 +769,18 @@ void tst_QCoreApplication::testQuitLock() app.exec(); } +static void createQObjectOnDestruction() +{ + // Make sure that we can create a QObject after the last QObject has been + // destroyed (especially after QCoreApplication has). + // + // Before the fixes, this would cause a dangling pointer dereference. If + // the problem comes back, it's possible that the following causes no + // effect. + QObject obj; + obj.thread()->setProperty("testing", 1); +} +Q_DESTRUCTOR_FUNCTION(createQObjectOnDestruction) QTEST_APPLESS_MAIN(tst_QCoreApplication) #include "tst_qcoreapplication.moc" diff --git a/tests/auto/corelib/kernel/qmetamethod/qmetamethod.pro b/tests/auto/corelib/kernel/qmetamethod/qmetamethod.pro index e253702d56..8340bc06e3 100644 --- a/tests/auto/corelib/kernel/qmetamethod/qmetamethod.pro +++ b/tests/auto/corelib/kernel/qmetamethod/qmetamethod.pro @@ -3,5 +3,5 @@ CONFIG += parallel_test TARGET = tst_qmetamethod QT = core testlib SOURCES = tst_qmetamethod.cpp -macx:CONFIG -= app_bundle +mac:CONFIG -= app_bundle DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/corelib/kernel/qmetaobjectbuilder/qmetaobjectbuilder.pro b/tests/auto/corelib/kernel/qmetaobjectbuilder/qmetaobjectbuilder.pro index 008b596b72..9e2d3519e6 100644 --- a/tests/auto/corelib/kernel/qmetaobjectbuilder/qmetaobjectbuilder.pro +++ b/tests/auto/corelib/kernel/qmetaobjectbuilder/qmetaobjectbuilder.pro @@ -2,5 +2,5 @@ CONFIG += testcase parallel_test TARGET = tst_qmetaobjectbuilder QT = core-private gui-private testlib SOURCES = tst_qmetaobjectbuilder.cpp -macx:CONFIG -= app_bundle +mac:CONFIG -= app_bundle DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro b/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro index 5aa7b4805b..0cba19887e 100644 --- a/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro +++ b/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro @@ -4,7 +4,7 @@ CONFIG += ordered SUBDIRS = lib \ theplugin \ tst -!win32: !macx-*: SUBDIRS += almostplugin +!win32: !mac: SUBDIRS += almostplugin TARGET = tst_qpluginloader # no special install rule for subdir diff --git a/tests/manual/dialogs/dialogs.pro b/tests/manual/dialogs/dialogs.pro index fe40994241..4ed200ab7f 100644 --- a/tests/manual/dialogs/dialogs.pro +++ b/tests/manual/dialogs/dialogs.pro @@ -4,5 +4,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = dialogs TEMPLATE = app -SOURCES += main.cpp filedialogpanel.cpp colordialogpanel.cpp fontdialogpanel.cpp -HEADERS += filedialogpanel.h colordialogpanel.h fontdialogpanel.h +SOURCES += main.cpp filedialogpanel.cpp colordialogpanel.cpp fontdialogpanel.cpp \ + wizardpanel.cpp +HEADERS += filedialogpanel.h colordialogpanel.h fontdialogpanel.h \ + wizardpanel.h diff --git a/tests/manual/dialogs/main.cpp b/tests/manual/dialogs/main.cpp index f137df1f49..86e6c90b3f 100644 --- a/tests/manual/dialogs/main.cpp +++ b/tests/manual/dialogs/main.cpp @@ -42,6 +42,7 @@ #include "filedialogpanel.h" #include "colordialogpanel.h" #include "fontdialogpanel.h" +#include "wizardpanel.h" #include <QMainWindow> #include <QApplication> @@ -71,6 +72,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) tabWidget->addTab(new FileDialogPanel, tr("QFileDialog")); tabWidget->addTab(new ColorDialogPanel, tr("QColorDialog")); tabWidget->addTab(new FontDialogPanel, tr("QFontDialog")); + tabWidget->addTab(new WizardPanel, tr("QWizard")); setCentralWidget(tabWidget); } diff --git a/tests/manual/dialogs/wizardpanel.cpp b/tests/manual/dialogs/wizardpanel.cpp new file mode 100644 index 0000000000..1306062426 --- /dev/null +++ b/tests/manual/dialogs/wizardpanel.cpp @@ -0,0 +1,361 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "wizardpanel.h" + +#include <QWizard> +#include <QWizardPage> +#include <QVBoxLayout> +#include <QGridLayout> +#include <QRadioButton> +#include <QPushButton> +#include <QCheckBox> +#include <QButtonGroup> +#include <QSpacerItem> +#include <QGroupBox> +#include <QLabel> +#include <QStyle> +#include <QIcon> +#include <QImage> +#include <QPainter> +#include <QFont> +#include <QFontMetrics> +#include <QHash> + +static QIcon coloredIcon(const Qt::GlobalColor color) +{ + QImage image(QSize(24, 24), QImage::Format_RGB32); + image.fill(color); + return QIcon(QPixmap::fromImage(image)); +} + +static QPixmap pixmapWithText(const QString &text, const QColor color) +{ + QFont font; + QFontMetrics metric(font); + QRect rectangle = metric.boundingRect(text); + rectangle.setBottomRight(rectangle.bottomRight() + QPoint(20, 20)); + QImage image(rectangle.size(), QImage::Format_RGB32); + image.fill(color); + QPainter painter(&image); + painter.setFont(font); + painter.drawText(rectangle, Qt::AlignHCenter | Qt::AlignVCenter, text); + return QPixmap::fromImage(image); +} + +// A radio-group control for QWizard::WizardStyle. +class WizardStyleControl : public QGroupBox +{ + Q_OBJECT +public: + WizardStyleControl(QWidget *parent = 0); + + void setWizardStyle(int style); + QWizard::WizardStyle wizardStyle() const; + +signals: + void wizardStyleChanged(int); + +private: + QButtonGroup *m_group; +}; + +WizardStyleControl::WizardStyleControl(QWidget *parent) + : QGroupBox(tr("Style"), parent) + , m_group(new QButtonGroup(this)) +{ + m_group->setExclusive(true); + connect(m_group, SIGNAL(buttonClicked(int)), this, SIGNAL(wizardStyleChanged(int))); + QVBoxLayout *vLayout = new QVBoxLayout(this); + QRadioButton *radioButton = new QRadioButton(tr("None/OS Default"), this); + m_group->addButton(radioButton, QWizard::NStyles); + vLayout->addWidget(radioButton); + radioButton = new QRadioButton(tr("ClassicStyle"), this); + m_group->addButton(radioButton, QWizard::ClassicStyle); + vLayout->addWidget(radioButton); + radioButton = new QRadioButton(tr("ModernStyle"), this); + m_group->addButton(radioButton, QWizard::ModernStyle); + vLayout->addWidget(radioButton); + radioButton = new QRadioButton(tr("MacStyle"), this); + m_group->addButton(radioButton, QWizard::MacStyle); + vLayout->addWidget(radioButton); + radioButton = new QRadioButton(tr("AeroStyle"), this); + m_group->addButton(radioButton, QWizard::AeroStyle); + vLayout->addWidget(radioButton); + vLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding)); + + setWizardStyle(style()->styleHint(QStyle::SH_WizardStyle)); +} + +QWizard::WizardStyle WizardStyleControl::wizardStyle() const +{ + return static_cast<QWizard::WizardStyle>(m_group->checkedId()); +} + +void WizardStyleControl::setWizardStyle(int wizardStyle) +{ + if (wizardStyle < 0 || wizardStyle > QWizard::NStyles) + wizardStyle = QWizard::NStyles; + QAbstractButton *button = m_group->button(wizardStyle); + Q_ASSERT(button); + const bool blocked = m_group->blockSignals(true); + button->setChecked(true); + m_group->blockSignals(blocked); +} + +// A control with checkboxes for QWizard::WizardOption. +class WizardOptionsControl : public QGroupBox +{ +public: + explicit WizardOptionsControl(QWidget *parent = 0); + + QWizard::WizardOption wizardOptions() const; + void setWizardOptions(int options); + +private: + typedef QHash<int, QCheckBox *> CheckBoxHash; + + void addCheckBox(QVBoxLayout *layout, int flag, const QString &title); + + CheckBoxHash m_checkBoxes; +}; + +WizardOptionsControl::WizardOptionsControl(QWidget *parent) + : QGroupBox(tr("Options"), parent) +{ + QVBoxLayout *vLayout = new QVBoxLayout(this); + addCheckBox(vLayout, QWizard::IndependentPages, QLatin1String("IndependentPages")); + addCheckBox(vLayout, QWizard::IgnoreSubTitles, QLatin1String("IgnoreSubTitles")); + addCheckBox(vLayout, QWizard::ExtendedWatermarkPixmap, QLatin1String("ExtendedWatermarkPixmap")); + addCheckBox(vLayout, QWizard::NoDefaultButton, QLatin1String("NoDefaultButton")); + addCheckBox(vLayout, QWizard::NoBackButtonOnStartPage, QLatin1String("NoBackButtonOnStartPage")); + addCheckBox(vLayout, QWizard::NoBackButtonOnLastPage, QLatin1String("NoBackButtonOnLastPage")); + addCheckBox(vLayout, QWizard::DisabledBackButtonOnLastPage, QLatin1String("DisabledBackButtonOnLastPage")); + addCheckBox(vLayout, QWizard::HaveNextButtonOnLastPage, QLatin1String("HaveNextButtonOnLastPage")); + addCheckBox(vLayout, QWizard::HaveFinishButtonOnEarlyPages, QLatin1String("HaveFinishButtonOnEarlyPages")); + addCheckBox(vLayout, QWizard::NoCancelButton, QLatin1String("NoCancelButton")); + addCheckBox(vLayout, QWizard::CancelButtonOnLeft, QLatin1String("CancelButtonOnLeft")); + addCheckBox(vLayout, QWizard::HaveHelpButton, QLatin1String("HaveHelpButton")); + addCheckBox(vLayout, QWizard::HelpButtonOnRight, QLatin1String("HelpButtonOnRight")); + addCheckBox(vLayout, QWizard::HaveCustomButton1, QLatin1String("HaveCustomButton1")); + addCheckBox(vLayout, QWizard::HaveCustomButton2, QLatin1String("HaveCustomButton2")); + addCheckBox(vLayout, QWizard::HaveCustomButton3, QLatin1String("HaveCustomButton3")); + vLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding)); +} + +void WizardOptionsControl::addCheckBox(QVBoxLayout *layout, int flag, const QString &title) +{ + QCheckBox *checkBox = new QCheckBox(title, this); + layout->addWidget(checkBox); + m_checkBoxes.insert(flag, checkBox); +} + +QWizard::WizardOption WizardOptionsControl::wizardOptions() const +{ + int result = 0; + typedef CheckBoxHash::const_iterator ConstIterator; + const ConstIterator cend = m_checkBoxes.constEnd(); + for (ConstIterator it = m_checkBoxes.constBegin(); it != cend; ++it) + if (it.value()->isChecked()) + result |= it.key(); + return static_cast<QWizard::WizardOption>(result); +} + +void WizardOptionsControl::setWizardOptions(int options) +{ + typedef CheckBoxHash::iterator Iterator; + const Iterator end = m_checkBoxes.end(); + for (Iterator it = m_checkBoxes.begin(); it != end; ++it) + it.value()->setChecked(options & it.key()); +} + +// A test wizard with a slot to change its style. +class Wizard : public QWizard { + Q_OBJECT +public: + explicit Wizard(QWidget *parent = 0, Qt::WindowFlags flags = 0); + +public slots: + void changeWizardStyle(int newStyle); +}; + +void Wizard::changeWizardStyle(int newStyle) +{ + if (newStyle >= 0 && newStyle < int(QWizard::NStyles)) + setWizardStyle(static_cast<QWizard::WizardStyle>(newStyle)); +} + +// A test wizard page with a WizardStyleControl. +class WizardPage : public QWizardPage +{ +public: + explicit WizardPage(const QString &title, QWidget *parent = 0); + + void initializePage(); + +private: + WizardStyleControl *m_styleControl; + bool m_firstTimeShown; +}; + +WizardPage::WizardPage(const QString &title, QWidget *parent) + : QWizardPage(parent) + , m_styleControl(new WizardStyleControl(this)) + , m_firstTimeShown(true) +{ + setTitle(title); + setSubTitle(title + QLatin1String(" SubTitle")); + QVBoxLayout *vLayout = new QVBoxLayout(this); + vLayout->addWidget(m_styleControl); +} + +void WizardPage::initializePage() +{ + m_styleControl->setWizardStyle(wizard()->wizardStyle()); + if (m_firstTimeShown) { + m_firstTimeShown = false; + connect(m_styleControl, SIGNAL(wizardStyleChanged(int)), + wizard(), SLOT(changeWizardStyle(int))); + } +} + +Wizard::Wizard(QWidget *parent, Qt::WindowFlags flags) + : QWizard(parent, flags) +{ + setWindowIcon(coloredIcon(Qt::red)); + setWindowTitle(QLatin1String("Wizard ") + QLatin1String(QT_VERSION_STR)); + addPage(new WizardPage(tr("Page 1"), this)); + addPage(new WizardPage(tr("Page 2"), this)); + addPage(new WizardPage(tr("Page 3"), this)); +} + +// A dialog using a Wizard as child widget (emulating Qt Designer). +class WizardEmbeddingDialog : public QDialog { +public: + explicit WizardEmbeddingDialog(QWidget *parent = 0); + + Wizard *wizard() const { return m_wizard; } + +private: + Wizard *m_wizard; +}; + +WizardEmbeddingDialog::WizardEmbeddingDialog(QWidget *parent) + : QDialog(parent) + , m_wizard(new Wizard) +{ + setWindowTitle(QString::fromLatin1("Dialog Embedding QWizard %1").arg(QT_VERSION_STR)); + QGridLayout *gridLayout = new QGridLayout(this); + gridLayout->addWidget(new QLabel(tr("Above wizard")), 0, 0, 1, 3); + gridLayout->addWidget(new QLabel(tr("Left of wizard")), 1, 0); + m_wizard->setObjectName(QLatin1String("EmbeddedWizard")); + m_wizard->setParent(this, Qt::Widget); + gridLayout->addWidget(m_wizard, 1, 1); + gridLayout->addWidget(new QLabel(tr("Right of wizard")), 1, 2); + gridLayout->addWidget(new QLabel(tr("Below wizard")), 2, 0, 1, 3); +} + +WizardPanel::WizardPanel(QWidget *parent) + : QWidget(parent) + , m_styleControl(new WizardStyleControl(this)) + , m_optionsControl(new WizardOptionsControl(this)) +{ + { + QWizard wizard; + m_optionsControl->setWizardOptions(wizard.options()); + m_styleControl->setWizardStyle(wizard.wizardStyle()); + } + + QGridLayout *gridLayout = new QGridLayout(this); + gridLayout->addWidget(m_optionsControl, 0, 0, 2, 1); + gridLayout->addWidget(m_styleControl, 0, 1); + QGroupBox *buttonGroupBox = new QGroupBox(this); + QVBoxLayout *vLayout = new QVBoxLayout(buttonGroupBox); + QPushButton *button = new QPushButton(tr("Show modal"), this); + connect(button, SIGNAL(clicked()), this, SLOT(showModal())); + vLayout->addWidget(button); + button = new QPushButton(tr("Show non-modal"), this); + connect(button, SIGNAL(clicked()), this, SLOT(showNonModal())); + vLayout->addWidget(button); + button = new QPushButton(tr("Show embedded"), this); + button->setToolTip(tr("Test QWizard's behavior when used as a widget child.")); + connect(button, SIGNAL(clicked()), this, SLOT(showEmbedded())); + vLayout->addWidget(button); + vLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding)); + gridLayout->addWidget(buttonGroupBox, 1, 1); +} + +void WizardPanel::showModal() +{ + Wizard wizard(this); + applyParameters(&wizard); + wizard.exec(); +} + +void WizardPanel::showNonModal() +{ + Wizard *wizard = new Wizard(this); + applyParameters(wizard); + wizard->setModal(false); + wizard->setAttribute(Qt::WA_DeleteOnClose); + wizard->show(); +} + +void WizardPanel::showEmbedded() +{ + WizardEmbeddingDialog *dialog = new WizardEmbeddingDialog(this); + applyParameters(dialog->wizard()); + dialog->setModal(false); + dialog->setAttribute(Qt::WA_DeleteOnClose); + dialog->show(); +} + +void WizardPanel::applyParameters(QWizard *wizard) const +{ + wizard->setWizardStyle(m_styleControl->wizardStyle()); + wizard->setOptions(m_optionsControl->wizardOptions()); + wizard->setPixmap(QWizard::WatermarkPixmap, pixmapWithText(QLatin1String("Watermark"), QColor(Qt::blue).lighter())); + wizard->setPixmap(QWizard::LogoPixmap, pixmapWithText(QLatin1String("Logo"), Qt::green)); + wizard->setPixmap(QWizard::BannerPixmap, pixmapWithText(QLatin1String("Banner"), Qt::green)); + wizard->setPixmap(QWizard::BackgroundPixmap, pixmapWithText(QLatin1String("Background"), QColor(Qt::red).lighter())); +} + +#include "wizardpanel.moc" diff --git a/mkspecs/common/ios/qplatformdefs.h b/tests/manual/dialogs/wizardpanel.h index 0b32d6dbc9..0a4ec8e467 100644 --- a/mkspecs/common/ios/qplatformdefs.h +++ b/tests/manual/dialogs/wizardpanel.h @@ -3,7 +3,7 @@ ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** -** This file is part of the qmake spec of the Qt Toolkit. +** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage @@ -39,55 +39,31 @@ ** ****************************************************************************/ -#ifndef QPLATFORMDEFS_H -#define QPLATFORMDEFS_H +#ifndef WIZARDPANEL_H +#define WIZARDPANEL_H -// Get Qt defines/settings +#include <QWidget> -#include "qglobal.h" +class WizardStyleControl; +class WizardOptionsControl; +class QWizard; -// Set any POSIX/XOPEN defines at the top of this file to turn on specific APIs +class WizardPanel : public QWidget +{ + Q_OBJECT +public: + explicit WizardPanel(QWidget *parent = 0); -#include <unistd.h> +public slots: + void showModal(); + void showNonModal(); + void showEmbedded(); +private: + void applyParameters(QWizard *wizard) const; -// We are hot - unistd.h should have turned on the specific APIs we requested + WizardStyleControl *m_styleControl; + WizardOptionsControl *m_optionsControl; +}; - -#include <pthread.h> -#include <dirent.h> -#include <fcntl.h> -#include <grp.h> -#include <pwd.h> -#include <signal.h> -#define QT_NO_LIBRARY_UNLOAD - -#include <sys/types.h> -#include <sys/ioctl.h> -#include <sys/ipc.h> -#include <sys/time.h> -#include <sys/shm.h> -#include <sys/socket.h> -#include <sys/stat.h> -#include <sys/wait.h> -#include <netinet/in.h> -#ifndef QT_NO_IPV6IFNAME -#include <net/if.h> -#endif - -#include "../../common/posix/qplatformdefs.h" - -#undef QT_OPEN_LARGEFILE -#undef QT_SOCKLEN_T -#undef QT_SIGNAL_IGNORE - -#define QT_OPEN_LARGEFILE 0 - -#define QT_SOCKLEN_T socklen_t - -#define QT_SIGNAL_IGNORE (void (*)(int))1 - -#define QT_SNPRINTF ::snprintf -#define QT_VSNPRINTF ::vsnprintf - -#endif // QPLATFORMDEFS_H +#endif // WIZARDPANEL_H diff --git a/util/local_database/enumdata.py b/util/local_database/enumdata.py index 7d802e7492..e889dfbf91 100644 --- a/util/local_database/enumdata.py +++ b/util/local_database/enumdata.py @@ -173,7 +173,7 @@ language_list = { 125 : [ "Turkish", "tr" ], 126 : [ "Turkmen", "tk" ], 127 : [ "Tahitian", "ty" ], - 128 : [ "Uigur", "ug" ], + 128 : [ "Uighur", "ug" ], 129 : [ "Ukrainian", "uk" ], 130 : [ "Urdu", "ur" ], 131 : [ "Uzbek", "uz" ], # macrolanguage @@ -305,7 +305,58 @@ language_list = { 257 : [ "Ngomba", "jgo" ], 258 : [ "Kako", "kkj" ], 259 : [ "Meta", "mgo" ], - 260 : [ "Ngiemboon", "nnh" ] + 260 : [ "Ngiemboon", "nnh" ], + 261 : [ "Aragonese", "an" ], + 262 : [ "Akkadian", "akk" ], + 263 : [ "AncientEgyptian", "egy" ], + 264 : [ "AncientGreek", "grc" ], + 265 : [ "Aramaic", "arc" ], + 266 : [ "Balinese", "ban" ], + 267 : [ "Bamun", "bax" ], + 268 : [ "BatakToba", "bbc" ], + 269 : [ "Buginese", "bug" ], + 270 : [ "Buhid", "bku" ], + 271 : [ "Carian", "xcr" ], + 272 : [ "Chakma", "ccp" ], + 273 : [ "ClassicalMandaic", "myz" ], + 274 : [ "Coptic", "cop" ], + 275 : [ "Dogri", "doi" ], # macrolanguage + 276 : [ "EasternCham", "cjm" ], + 277 : [ "EasternKayah", "eky" ], + 278 : [ "Etruscan", "ett" ], + 279 : [ "Gothic", "got" ], + 280 : [ "Hanunoo", "hnn" ], + 281 : [ "Ingush", "inh" ], + 282 : [ "LargeFloweryMiao", "hmd" ], + 283 : [ "Lepcha", "lep" ], + 284 : [ "Limbu", "lif" ], + 285 : [ "Lisu", "lis" ], + 286 : [ "Lu", "khb" ], + 287 : [ "Lycian", "xlc" ], + 288 : [ "Lydian", "xld" ], + 289 : [ "Mandingo", "man" ], # macrolanguage + 290 : [ "Manipuri", "mni" ], + 291 : [ "Meroitic", "xmr" ], + 292 : [ "NorthernThai", "nod" ], + 293 : [ "OldIrish", "sga" ], + 294 : [ "OldNorse", "non" ], + 295 : [ "OldPersian", "peo" ], + 296 : [ "OldTurkish", "otk" ], + 297 : [ "Pahlavi", "pal" ], + 298 : [ "Parthian", "xpr" ], + 299 : [ "Phoenician", "phn" ], + 300 : [ "PrakritLanguage", "pra" ], + 301 : [ "Rejang", "rej" ], + 302 : [ "Sabaean", "xsa" ], + 303 : [ "Samaritan", "smp" ], + 304 : [ "Santali", "sat" ], + 305 : [ "Saurashtra", "saz" ], + 306 : [ "Sora", "srb" ], + 307 : [ "Sylheti", "syl" ], + 308 : [ "Tagbanwa", "tbw" ], + 309 : [ "TaiDam", "blt" ], + 310 : [ "TaiNua", "tdd" ], + 311 : [ "Ugaritic", "uga" ] } country_list = { @@ -602,9 +653,82 @@ script_list = { 30 : [ "Thai", "Thai" ], 31 : [ "Tibetan", "Tibt" ], 32 : [ "Sinhala", "Sinh" ], - 33 : [ "Syriac", "Syri" ], + 33 : [ "Syriac", "Syrc" ], 34 : [ "Yi", "Yiii" ], - 35 : [ "Vai", "Vaii" ] + 35 : [ "Vai", "Vaii" ], + 36 : [ "Avestan", "Avst" ], + 37 : [ "Balinese", "Bali" ], + 38 : [ "Bamum", "Bamu" ], + 39 : [ "Batak", "Batk" ], + 40 : [ "Bopomofo", "Bopo" ], + 41 : [ "Brahmi", "Brah" ], + 42 : [ "Buginese", "Bugi" ], + 43 : [ "Buhid", "Buhd" ], + 44 : [ "CanadianAboriginal", "Cans" ], + 45 : [ "Carian", "Cari" ], + 46 : [ "Chakma", "Cakm" ], + 47 : [ "Cham", "Cham" ], + 48 : [ "Coptic", "Copt" ], + 49 : [ "Cypriot", "Cprt" ], + 50 : [ "Egyptian Hieroglyphs", "Egyp" ], + 51 : [ "Fraser", "Lisu" ], + 52 : [ "Glagolitic", "Glag" ], + 53 : [ "Gothic", "Goth" ], + 54 : [ "Han", "Hani" ], + 55 : [ "Hangul", "Hang" ], + 56 : [ "Hanunoo", "Hano" ], + 57 : [ "Imperial Aramaic", "Armi" ], + 58 : [ "Inscriptional Pahlavi", "Phli" ], + 59 : [ "Inscriptional Parthian", "Prti" ], + 60 : [ "Javanese", "Java" ], + 61 : [ "Kaithi", "Kthi" ], + 62 : [ "Katakana", "Kana" ], + 63 : [ "Kayah Li", "Kali" ], + 64 : [ "Kharoshthi", "Khar" ], + 65 : [ "Lanna", "Lana" ], + 66 : [ "Lepcha", "Lepc" ], + 67 : [ "Limbu", "Limb" ], + 68 : [ "Linear B", "Linb" ], + 69 : [ "Lycian", "Lyci" ], + 70 : [ "Lydian", "Lydi" ], + 71 : [ "Mandaean", "Mand" ], + 72 : [ "Meitei Mayek", "Mtei" ], + 73 : [ "Meroitic", "Mero" ], + 74 : [ "Meroitic Cursive", "Merc" ], + 75 : [ "Nko", "Nkoo" ], + 76 : [ "New Tai Lue", "Talu" ], + 77 : [ "Ogham", "Ogam" ], + 78 : [ "Ol Chiki", "Olck" ], + 79 : [ "Old Italic", "Ital" ], + 80 : [ "Old Persian", "Xpeo" ], + 81 : [ "Old South Arabian", "Sarb" ], + 82 : [ "Orkhon", "Orkh" ], + 83 : [ "Osmanya", "Osma" ], + 84 : [ "Phags Pa", "Phag" ], + 85 : [ "Phoenician", "Phnx" ], + 86 : [ "Pollard Phonetic", "Plrd" ], + 87 : [ "Rejang", "Rjng" ], + 88 : [ "Runic", "Runr" ], + 89 : [ "Samaritan", "Samr" ], + 90 : [ "Saurashtra", "Saur" ], + 91 : [ "Sharada", "Shrd" ], + 92 : [ "Shavian", "Shaw" ], + 93 : [ "Sora Sompeng", "Sora" ], + 94 : [ "Cuneiform", "Xsux" ], + 95 : [ "Sundanese", "Sund" ], + 96 : [ "Syloti Nagri", "Sylo" ], + 97 : [ "Tagalog", "Tglg" ], + 98 : [ "Tagbanwa", "Tagb" ], + 99 : [ "Tai Le", "Tale" ], + 100 : [ "Tai Viet", "Tavt" ], + 101 : [ "Takri", "Takr" ], + 102 : [ "Ugaritic", "Ugar" ] + +# ### : [ "Blissymbols", "Blis" ], +# ### : [ "Linear A", "Lina" ], +# ### : [ "Naxi Geba", "Nkgb" ], +# ### : [ "Pahawh Hmong", "Hmng" ], +# ### : [ "Varang Kshiti", "Wara" ], } def countryCodeToId(code): diff --git a/util/local_database/qlocalexml2cpp.py b/util/local_database/qlocalexml2cpp.py index d3120d256f..b038eec6c4 100755 --- a/util/local_database/qlocalexml2cpp.py +++ b/util/local_database/qlocalexml2cpp.py @@ -899,6 +899,7 @@ def main(): qlocaleh_temp_file.write(" RhaetoRomance = Romansh,\n") qlocaleh_temp_file.write(" Chewa = Nyanja,\n") qlocaleh_temp_file.write(" Frisian = WesternFrisian,\n") + qlocaleh_temp_file.write(" Uigur = Uighur,\n") qlocaleh_temp_file.write(" LastLanguage = " + language + "\n") qlocaleh_temp_file.write(" };\n") |