Merge integration refs/builds/qtci/dev/1618405176
This commit is contained in:
commit
1d59fe368a
@ -136,21 +136,31 @@ QJniEnvironment::~QJniEnvironment()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn JNIEnv *QJniEnvironment::operator->()
|
\fn JNIEnv *QJniEnvironment::operator->() const
|
||||||
|
|
||||||
Provides access to the QJniEnvironment's JNIEnv pointer.
|
Provides access to the JNI Environment's \c JNIEnv pointer.
|
||||||
*/
|
*/
|
||||||
JNIEnv *QJniEnvironment::operator->()
|
JNIEnv *QJniEnvironment::operator->() const
|
||||||
{
|
{
|
||||||
return d->jniEnv;
|
return d->jniEnv;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn QJniEnvironment::operator JNIEnv *() const
|
\fn JNIEnv &QJniEnvironment::operator*() const
|
||||||
|
|
||||||
Returns the JNI Environment pointer.
|
Returns the JNI Environment's \c JNIEnv object.
|
||||||
*/
|
*/
|
||||||
QJniEnvironment::operator JNIEnv* () const
|
JNIEnv &QJniEnvironment::operator*() const
|
||||||
|
{
|
||||||
|
return *d->jniEnv;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn JNIEnv *QJniEnvironment::jniEnv()
|
||||||
|
|
||||||
|
Returns the JNI Environment's \c JNIEnv pointer.
|
||||||
|
*/
|
||||||
|
JNIEnv *QJniEnvironment::jniEnv() const
|
||||||
{
|
{
|
||||||
return d->jniEnv;
|
return d->jniEnv;
|
||||||
}
|
}
|
||||||
|
@ -60,8 +60,9 @@ class Q_CORE_EXPORT QJniEnvironment
|
|||||||
public:
|
public:
|
||||||
QJniEnvironment();
|
QJniEnvironment();
|
||||||
~QJniEnvironment();
|
~QJniEnvironment();
|
||||||
JNIEnv *operator->();
|
JNIEnv *operator->() const;
|
||||||
operator JNIEnv *() const;
|
JNIEnv &operator*() const;
|
||||||
|
JNIEnv *jniEnv() const;
|
||||||
jclass findClass(const char *className);
|
jclass findClass(const char *className);
|
||||||
static JavaVM *javaVM();
|
static JavaVM *javaVM();
|
||||||
bool registerNativeMethods(const char *className, JNINativeMethod methods[], int size);
|
bool registerNativeMethods(const char *className, JNINativeMethod methods[], int size);
|
||||||
@ -74,7 +75,6 @@ public:
|
|||||||
bool checkAndClearExceptions(OutputMode outputMode = OutputMode::Verbose);
|
bool checkAndClearExceptions(OutputMode outputMode = OutputMode::Verbose);
|
||||||
static bool checkAndClearExceptions(JNIEnv *env, OutputMode outputMode = OutputMode::Verbose);
|
static bool checkAndClearExceptions(JNIEnv *env, OutputMode outputMode = OutputMode::Verbose);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY_MOVE(QJniEnvironment)
|
Q_DISABLE_COPY_MOVE(QJniEnvironment)
|
||||||
QScopedPointer<QJniEnvironmentPrivate> d;
|
QScopedPointer<QJniEnvironmentPrivate> d;
|
||||||
|
@ -489,7 +489,7 @@ jclass QtAndroidPrivate::findClass(const char *className, JNIEnv *env)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!clazz) // We didn't get an env. pointer or we got one with the WRONG class loader...
|
if (!clazz) // We didn't get an env. pointer or we got one with the WRONG class loader...
|
||||||
clazz = loadClass(classDotEnc, QJniEnvironment(), true);
|
clazz = loadClass(classDotEnc, QJniEnvironment().jniEnv(), true);
|
||||||
|
|
||||||
return clazz;
|
return clazz;
|
||||||
}
|
}
|
||||||
@ -538,11 +538,11 @@ QJniObject::QJniObject(const char *className)
|
|||||||
{
|
{
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
d->m_className = toBinaryEncClassName(className);
|
d->m_className = toBinaryEncClassName(className);
|
||||||
d->m_jclass = loadClass(d->m_className, env, true);
|
d->m_jclass = loadClass(d->m_className, env.jniEnv(), true);
|
||||||
d->m_own_jclass = false;
|
d->m_own_jclass = false;
|
||||||
if (d->m_jclass) {
|
if (d->m_jclass) {
|
||||||
// get default constructor
|
// get default constructor
|
||||||
jmethodID constructorId = getCachedMethodID(env, d->m_jclass, d->m_className, "<init>", "()V");
|
jmethodID constructorId = getCachedMethodID(env.jniEnv(), d->m_jclass, d->m_className, "<init>", "()V");
|
||||||
if (constructorId) {
|
if (constructorId) {
|
||||||
jobject obj = env->NewObject(d->m_jclass, constructorId);
|
jobject obj = env->NewObject(d->m_jclass, constructorId);
|
||||||
if (obj) {
|
if (obj) {
|
||||||
@ -571,10 +571,10 @@ QJniObject::QJniObject(const char *className, const char *signature, ...)
|
|||||||
{
|
{
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
d->m_className = toBinaryEncClassName(className);
|
d->m_className = toBinaryEncClassName(className);
|
||||||
d->m_jclass = loadClass(d->m_className, env, true);
|
d->m_jclass = loadClass(d->m_className, env.jniEnv(), true);
|
||||||
d->m_own_jclass = false;
|
d->m_own_jclass = false;
|
||||||
if (d->m_jclass) {
|
if (d->m_jclass) {
|
||||||
jmethodID constructorId = getCachedMethodID(env, d->m_jclass, d->m_className, "<init>", signature);
|
jmethodID constructorId = getCachedMethodID(env.jniEnv(), d->m_jclass, d->m_className, "<init>", signature);
|
||||||
if (constructorId) {
|
if (constructorId) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, signature);
|
va_start(args, signature);
|
||||||
@ -593,10 +593,10 @@ QJniObject::QJniObject(const char *className, const char *signature, const QVaLi
|
|||||||
{
|
{
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
d->m_className = toBinaryEncClassName(className);
|
d->m_className = toBinaryEncClassName(className);
|
||||||
d->m_jclass = loadClass(d->m_className, env, true);
|
d->m_jclass = loadClass(d->m_className, env.jniEnv(), true);
|
||||||
d->m_own_jclass = false;
|
d->m_own_jclass = false;
|
||||||
if (d->m_jclass) {
|
if (d->m_jclass) {
|
||||||
jmethodID constructorId = getCachedMethodID(env, d->m_jclass, d->m_className, "<init>", signature);
|
jmethodID constructorId = getCachedMethodID(env.jniEnv(), d->m_jclass, d->m_className, "<init>", signature);
|
||||||
if (constructorId) {
|
if (constructorId) {
|
||||||
jobject obj = env->NewObjectV(d->m_jclass, constructorId, args);
|
jobject obj = env->NewObjectV(d->m_jclass, constructorId, args);
|
||||||
if (obj) {
|
if (obj) {
|
||||||
@ -626,7 +626,7 @@ QJniObject::QJniObject(jclass clazz, const char *signature, ...)
|
|||||||
if (clazz) {
|
if (clazz) {
|
||||||
d->m_jclass = static_cast<jclass>(env->NewGlobalRef(clazz));
|
d->m_jclass = static_cast<jclass>(env->NewGlobalRef(clazz));
|
||||||
if (d->m_jclass) {
|
if (d->m_jclass) {
|
||||||
jmethodID constructorId = getMethodID(env, d->m_jclass, "<init>", signature);
|
jmethodID constructorId = getMethodID(env.jniEnv(), d->m_jclass, "<init>", signature);
|
||||||
if (constructorId) {
|
if (constructorId) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, signature);
|
va_start(args, signature);
|
||||||
@ -658,7 +658,7 @@ QJniObject::QJniObject(jclass clazz)
|
|||||||
d->m_jclass = static_cast<jclass>(env->NewGlobalRef(clazz));
|
d->m_jclass = static_cast<jclass>(env->NewGlobalRef(clazz));
|
||||||
if (d->m_jclass) {
|
if (d->m_jclass) {
|
||||||
// get default constructor
|
// get default constructor
|
||||||
jmethodID constructorId = getMethodID(env, d->m_jclass, "<init>", "()V");
|
jmethodID constructorId = getMethodID(env.jniEnv(), d->m_jclass, "<init>", "()V");
|
||||||
if (constructorId) {
|
if (constructorId) {
|
||||||
jobject obj = env->NewObject(d->m_jclass, constructorId);
|
jobject obj = env->NewObject(d->m_jclass, constructorId);
|
||||||
if (obj) {
|
if (obj) {
|
||||||
@ -676,7 +676,7 @@ QJniObject::QJniObject(jclass clazz, const char *signature, const QVaListPrivate
|
|||||||
if (clazz) {
|
if (clazz) {
|
||||||
d->m_jclass = static_cast<jclass>(env->NewGlobalRef(clazz));
|
d->m_jclass = static_cast<jclass>(env->NewGlobalRef(clazz));
|
||||||
if (d->m_jclass) {
|
if (d->m_jclass) {
|
||||||
jmethodID constructorId = getMethodID(env, d->m_jclass, "<init>", signature);
|
jmethodID constructorId = getMethodID(env.jniEnv(), d->m_jclass, "<init>", signature);
|
||||||
if (constructorId) {
|
if (constructorId) {
|
||||||
jobject obj = env->NewObjectV(d->m_jclass, constructorId, args);
|
jobject obj = env->NewObjectV(d->m_jclass, constructorId, args);
|
||||||
if (obj) {
|
if (obj) {
|
||||||
@ -772,7 +772,7 @@ QJniObject QJniObject::callObjectMethodV(const char *methodName,
|
|||||||
{
|
{
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
jobject res = nullptr;
|
jobject res = nullptr;
|
||||||
jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, signature);
|
jmethodID id = getCachedMethodID(env.jniEnv(), d->m_jclass, d->m_className, methodName, signature);
|
||||||
if (id) {
|
if (id) {
|
||||||
res = env->CallObjectMethodV(d->m_jobject, id, args);
|
res = env->CallObjectMethodV(d->m_jobject, id, args);
|
||||||
if (env.checkAndClearExceptions()) {
|
if (env.checkAndClearExceptions()) {
|
||||||
@ -793,9 +793,9 @@ QJniObject QJniObject::callStaticObjectMethodV(const char *className,
|
|||||||
{
|
{
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
jobject res = nullptr;
|
jobject res = nullptr;
|
||||||
jclass clazz = loadClass(className, env);
|
jclass clazz = loadClass(className, env.jniEnv());
|
||||||
if (clazz) {
|
if (clazz) {
|
||||||
jmethodID id = getCachedMethodID(env, clazz, toBinaryEncClassName(className),
|
jmethodID id = getCachedMethodID(env.jniEnv(), clazz, toBinaryEncClassName(className),
|
||||||
methodName, signature, true);
|
methodName, signature, true);
|
||||||
if (id) {
|
if (id) {
|
||||||
res = env->CallStaticObjectMethodV(clazz, id, args);
|
res = env->CallStaticObjectMethodV(clazz, id, args);
|
||||||
@ -817,7 +817,7 @@ QJniObject QJniObject::callStaticObjectMethodV(jclass clazz,
|
|||||||
va_list args)
|
va_list args)
|
||||||
{
|
{
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
jmethodID id = getMethodID(env, clazz, methodName, signature, true);
|
jmethodID id = getMethodID(env.jniEnv(), clazz, methodName, signature, true);
|
||||||
if (!id)
|
if (!id)
|
||||||
return QJniObject();
|
return QJniObject();
|
||||||
|
|
||||||
@ -840,7 +840,7 @@ template <>
|
|||||||
Q_CORE_EXPORT void QJniObject::callMethod<void>(const char *methodName, const char *signature, ...) const
|
Q_CORE_EXPORT void QJniObject::callMethod<void>(const char *methodName, const char *signature, ...) const
|
||||||
{
|
{
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, signature);
|
jmethodID id = getCachedMethodID(env.jniEnv(), d->m_jclass, d->m_className, methodName, signature);
|
||||||
if (id) {
|
if (id) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, signature);
|
va_start(args, signature);
|
||||||
@ -885,9 +885,9 @@ Q_CORE_EXPORT void QJniObject::callStaticMethod<void>(const char *className,
|
|||||||
...)
|
...)
|
||||||
{
|
{
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
jclass clazz = loadClass(className, env);
|
jclass clazz = loadClass(className, env.jniEnv());
|
||||||
if (clazz) {
|
if (clazz) {
|
||||||
jmethodID id = getCachedMethodID(env, clazz, toBinaryEncClassName(className),
|
jmethodID id = getCachedMethodID(env.jniEnv(), clazz, toBinaryEncClassName(className),
|
||||||
methodName, signature, true);
|
methodName, signature, true);
|
||||||
if (id) {
|
if (id) {
|
||||||
va_list args;
|
va_list args;
|
||||||
@ -936,7 +936,7 @@ Q_CORE_EXPORT void QJniObject::callStaticMethod<void>(jclass clazz,
|
|||||||
{
|
{
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
if (clazz) {
|
if (clazz) {
|
||||||
jmethodID id = getMethodID(env, clazz, methodName, signature, true);
|
jmethodID id = getMethodID(env.jniEnv(), clazz, methodName, signature, true);
|
||||||
if (id) {
|
if (id) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, signature);
|
va_start(args, signature);
|
||||||
@ -954,9 +954,9 @@ Q_CORE_EXPORT void QJniObject::callStaticMethodV<void>(const char *className,
|
|||||||
va_list args)
|
va_list args)
|
||||||
{
|
{
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
jclass clazz = loadClass(className, env);
|
jclass clazz = loadClass(className, env.jniEnv());
|
||||||
if (clazz) {
|
if (clazz) {
|
||||||
jmethodID id = getCachedMethodID(env, clazz,
|
jmethodID id = getCachedMethodID(env.jniEnv(), clazz,
|
||||||
toBinaryEncClassName(className), methodName,
|
toBinaryEncClassName(className), methodName,
|
||||||
signature, true);
|
signature, true);
|
||||||
if (id) {
|
if (id) {
|
||||||
@ -973,7 +973,7 @@ Q_CORE_EXPORT void QJniObject::callStaticMethodV<void>(jclass clazz,
|
|||||||
va_list args)
|
va_list args)
|
||||||
{
|
{
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
jmethodID id = getMethodID(env, clazz, methodName, signature, true);
|
jmethodID id = getMethodID(env.jniEnv(), clazz, methodName, signature, true);
|
||||||
if (id) {
|
if (id) {
|
||||||
env->CallStaticVoidMethodV(clazz, id, args);
|
env->CallStaticVoidMethodV(clazz, id, args);
|
||||||
env.checkAndClearExceptions();
|
env.checkAndClearExceptions();
|
||||||
@ -1002,7 +1002,7 @@ Q_CORE_EXPORT void QJniObject::callMethodV<void>(const char *methodName, const c
|
|||||||
va_list args) const
|
va_list args) const
|
||||||
{
|
{
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, signature);
|
jmethodID id = getCachedMethodID(env.jniEnv(), d->m_jclass, d->m_className, methodName, signature);
|
||||||
if (id) {
|
if (id) {
|
||||||
env->CallVoidMethodV(d->m_jobject, id, args);
|
env->CallVoidMethodV(d->m_jobject, id, args);
|
||||||
env.checkAndClearExceptions();
|
env.checkAndClearExceptions();
|
||||||
@ -1015,7 +1015,7 @@ template <> Q_CORE_EXPORT Type QJniObject::callMethod<Type>(const char *methodNa
|
|||||||
{ \
|
{ \
|
||||||
QJniEnvironment env; \
|
QJniEnvironment env; \
|
||||||
Type res = 0; \
|
Type res = 0; \
|
||||||
jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, signature); \
|
jmethodID id = getCachedMethodID(env.jniEnv(), d->m_jclass, d->m_className, methodName, signature); \
|
||||||
if (id) { \
|
if (id) { \
|
||||||
va_list args; \
|
va_list args; \
|
||||||
va_start(args, signature); \
|
va_start(args, signature); \
|
||||||
@ -1038,9 +1038,9 @@ template <> Q_CORE_EXPORT Type QJniObject::callStaticMethod<Type>(const char *cl
|
|||||||
{ \
|
{ \
|
||||||
QJniEnvironment env; \
|
QJniEnvironment env; \
|
||||||
Type res = 0; \
|
Type res = 0; \
|
||||||
jclass clazz = loadClass(className, env); \
|
jclass clazz = loadClass(className, env.jniEnv()); \
|
||||||
if (clazz) { \
|
if (clazz) { \
|
||||||
jmethodID id = getCachedMethodID(env, clazz, toBinaryEncClassName(className), methodName, \
|
jmethodID id = getCachedMethodID(env.jniEnv(), clazz, toBinaryEncClassName(className), methodName, \
|
||||||
signature, true); \
|
signature, true); \
|
||||||
if (id) { \
|
if (id) { \
|
||||||
va_list args; \
|
va_list args; \
|
||||||
@ -1067,7 +1067,7 @@ template <> Q_CORE_EXPORT Type QJniObject::callStaticMethod<Type>(jclass clazz,
|
|||||||
QJniEnvironment env; \
|
QJniEnvironment env; \
|
||||||
Type res = 0; \
|
Type res = 0; \
|
||||||
if (clazz) { \
|
if (clazz) { \
|
||||||
jmethodID id = getMethodID(env, clazz, methodName, signature, true); \
|
jmethodID id = getMethodID(env.jniEnv(), clazz, methodName, signature, true); \
|
||||||
if (id) { \
|
if (id) { \
|
||||||
va_list args; \
|
va_list args; \
|
||||||
va_start(args, signature); \
|
va_start(args, signature); \
|
||||||
@ -1090,7 +1090,7 @@ Q_CORE_EXPORT Type QJniObject::callMethodV<Type>(const char *methodName, const c
|
|||||||
{\
|
{\
|
||||||
QJniEnvironment env;\
|
QJniEnvironment env;\
|
||||||
Type res = 0;\
|
Type res = 0;\
|
||||||
jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, signature);\
|
jmethodID id = getCachedMethodID(env.jniEnv(), d->m_jclass, d->m_className, methodName, signature);\
|
||||||
if (id) {\
|
if (id) {\
|
||||||
res = env->Call##MethodName##MethodV(d->m_jobject, id, args);\
|
res = env->Call##MethodName##MethodV(d->m_jobject, id, args);\
|
||||||
if (env.checkAndClearExceptions()) \
|
if (env.checkAndClearExceptions()) \
|
||||||
@ -1106,9 +1106,9 @@ Q_CORE_EXPORT Type QJniObject::callStaticMethodV<Type>(const char *className,\
|
|||||||
{\
|
{\
|
||||||
QJniEnvironment env;\
|
QJniEnvironment env;\
|
||||||
Type res = 0;\
|
Type res = 0;\
|
||||||
jclass clazz = loadClass(className, env);\
|
jclass clazz = loadClass(className, env.jniEnv());\
|
||||||
if (clazz) {\
|
if (clazz) {\
|
||||||
jmethodID id = getCachedMethodID(env, clazz, toBinaryEncClassName(className), methodName,\
|
jmethodID id = getCachedMethodID(env.jniEnv(), clazz, toBinaryEncClassName(className), methodName,\
|
||||||
signature, true);\
|
signature, true);\
|
||||||
if (id) {\
|
if (id) {\
|
||||||
res = env->CallStatic##MethodName##MethodV(clazz, id, args);\
|
res = env->CallStatic##MethodName##MethodV(clazz, id, args);\
|
||||||
@ -1126,7 +1126,7 @@ Q_CORE_EXPORT Type QJniObject::callStaticMethodV<Type>(jclass clazz,\
|
|||||||
{\
|
{\
|
||||||
QJniEnvironment env;\
|
QJniEnvironment env;\
|
||||||
Type res = 0;\
|
Type res = 0;\
|
||||||
jmethodID id = getMethodID(env, clazz, methodName, signature, true);\
|
jmethodID id = getMethodID(env.jniEnv(), clazz, methodName, signature, true);\
|
||||||
if (id) {\
|
if (id) {\
|
||||||
res = env->CallStatic##MethodName##MethodV(clazz, id, args);\
|
res = env->CallStatic##MethodName##MethodV(clazz, id, args);\
|
||||||
if (env.checkAndClearExceptions()) \
|
if (env.checkAndClearExceptions()) \
|
||||||
@ -1162,7 +1162,7 @@ DECLARE_JNI_METHODS(Double, jdouble, "()D")
|
|||||||
QJniObject QJniObject::callObjectMethod(const char *methodName, const char *signature, ...) const
|
QJniObject QJniObject::callObjectMethod(const char *methodName, const char *signature, ...) const
|
||||||
{
|
{
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, signature);
|
jmethodID id = getCachedMethodID(env.jniEnv(), d->m_jclass, d->m_className, methodName, signature);
|
||||||
if (id) {
|
if (id) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, signature);
|
va_start(args, signature);
|
||||||
@ -1193,9 +1193,9 @@ QJniObject QJniObject::callStaticObjectMethod(const char *className,
|
|||||||
...)
|
...)
|
||||||
{
|
{
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
jclass clazz = loadClass(className, env);
|
jclass clazz = loadClass(className, env.jniEnv());
|
||||||
if (clazz) {
|
if (clazz) {
|
||||||
jmethodID id = getCachedMethodID(env, clazz, toBinaryEncClassName(className),
|
jmethodID id = getCachedMethodID(env.jniEnv(), clazz, toBinaryEncClassName(className),
|
||||||
methodName, signature, true);
|
methodName, signature, true);
|
||||||
if (id) {
|
if (id) {
|
||||||
va_list args;
|
va_list args;
|
||||||
@ -1222,7 +1222,7 @@ QJniObject QJniObject::callStaticObjectMethod(jclass clazz,
|
|||||||
{
|
{
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
if (clazz) {
|
if (clazz) {
|
||||||
jmethodID id = getMethodID(env, clazz, methodName, signature, true);
|
jmethodID id = getMethodID(env.jniEnv(), clazz, methodName, signature, true);
|
||||||
if (id) {
|
if (id) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, signature);
|
va_start(args, signature);
|
||||||
@ -1349,12 +1349,12 @@ Q_CORE_EXPORT void QJniObject::setStaticField<jobject>(const char *className,
|
|||||||
jobject value)
|
jobject value)
|
||||||
{
|
{
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
jclass clazz = loadClass(className, env);
|
jclass clazz = loadClass(className, env.jniEnv());
|
||||||
|
|
||||||
if (!clazz)
|
if (!clazz)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
jfieldID id = getCachedFieldID(env, clazz, className, fieldName, signature, true);
|
jfieldID id = getCachedFieldID(env.jniEnv(), clazz, className, fieldName, signature, true);
|
||||||
if (id) {
|
if (id) {
|
||||||
env->SetStaticObjectField(clazz, id, value);
|
env->SetStaticObjectField(clazz, id, value);
|
||||||
env.checkAndClearExceptions();
|
env.checkAndClearExceptions();
|
||||||
@ -1373,7 +1373,7 @@ template <> Q_CORE_EXPORT void QJniObject::setStaticField<jobject>(jclass clazz,
|
|||||||
jobject value)
|
jobject value)
|
||||||
{
|
{
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
jfieldID id = getFieldID(env, clazz, fieldName, signature, true);
|
jfieldID id = getFieldID(env.jniEnv(), clazz, fieldName, signature, true);
|
||||||
|
|
||||||
if (id) {
|
if (id) {
|
||||||
env->SetStaticObjectField(clazz, id, value);
|
env->SetStaticObjectField(clazz, id, value);
|
||||||
@ -1420,7 +1420,7 @@ template <> Q_CORE_EXPORT Type QJniObject::getField<Type>(const char *fieldName)
|
|||||||
{ \
|
{ \
|
||||||
QJniEnvironment env; \
|
QJniEnvironment env; \
|
||||||
Type res = 0; \
|
Type res = 0; \
|
||||||
jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, Signature); \
|
jfieldID id = getCachedFieldID(env.jniEnv(), d->m_jclass, d->m_className, fieldName, Signature); \
|
||||||
if (id) {\
|
if (id) {\
|
||||||
res = env->Get##FieldName##Field(d->m_jobject, id); \
|
res = env->Get##FieldName##Field(d->m_jobject, id); \
|
||||||
if (env.checkAndClearExceptions()) \
|
if (env.checkAndClearExceptions()) \
|
||||||
@ -1432,10 +1432,10 @@ template <> \
|
|||||||
Q_CORE_EXPORT Type QJniObject::getStaticField<Type>(const char *className, const char *fieldName) \
|
Q_CORE_EXPORT Type QJniObject::getStaticField<Type>(const char *className, const char *fieldName) \
|
||||||
{ \
|
{ \
|
||||||
QJniEnvironment env; \
|
QJniEnvironment env; \
|
||||||
jclass clazz = loadClass(className, env); \
|
jclass clazz = loadClass(className, env.jniEnv()); \
|
||||||
if (!clazz) \
|
if (!clazz) \
|
||||||
return 0; \
|
return 0; \
|
||||||
jfieldID id = getCachedFieldID(env, clazz, toBinaryEncClassName(className), fieldName, \
|
jfieldID id = getCachedFieldID(env.jniEnv(), clazz, toBinaryEncClassName(className), fieldName, \
|
||||||
Signature, true); \
|
Signature, true); \
|
||||||
if (!id) \
|
if (!id) \
|
||||||
return 0; \
|
return 0; \
|
||||||
@ -1449,7 +1449,7 @@ Q_CORE_EXPORT Type QJniObject::getStaticField<Type>(jclass clazz, const char *fi
|
|||||||
{\
|
{\
|
||||||
QJniEnvironment env;\
|
QJniEnvironment env;\
|
||||||
Type res = 0;\
|
Type res = 0;\
|
||||||
jfieldID id = getFieldID(env, clazz, fieldName, Signature, true);\
|
jfieldID id = getFieldID(env.jniEnv(), clazz, fieldName, Signature, true);\
|
||||||
if (id) {\
|
if (id) {\
|
||||||
res = env->GetStatic##FieldName##Field(clazz, id);\
|
res = env->GetStatic##FieldName##Field(clazz, id);\
|
||||||
if (env.checkAndClearExceptions()) \
|
if (env.checkAndClearExceptions()) \
|
||||||
@ -1462,10 +1462,10 @@ template <> Q_CORE_EXPORT void QJniObject::setStaticField<Type>(const char *clas
|
|||||||
Type value) \
|
Type value) \
|
||||||
{ \
|
{ \
|
||||||
QJniEnvironment env; \
|
QJniEnvironment env; \
|
||||||
jclass clazz = loadClass(className, env); \
|
jclass clazz = loadClass(className, env.jniEnv()); \
|
||||||
if (!clazz) \
|
if (!clazz) \
|
||||||
return; \
|
return; \
|
||||||
jfieldID id = getCachedFieldID(env, clazz, className, fieldName, Signature, true); \
|
jfieldID id = getCachedFieldID(env.jniEnv(), clazz, className, fieldName, Signature, true); \
|
||||||
if (!id) \
|
if (!id) \
|
||||||
return; \
|
return; \
|
||||||
env->SetStatic##FieldName##Field(clazz, id, value); \
|
env->SetStatic##FieldName##Field(clazz, id, value); \
|
||||||
@ -1476,7 +1476,7 @@ template <> Q_CORE_EXPORT void QJniObject::setStaticField<Type>(jclass clazz,\
|
|||||||
Type value)\
|
Type value)\
|
||||||
{\
|
{\
|
||||||
QJniEnvironment env;\
|
QJniEnvironment env;\
|
||||||
jfieldID id = getFieldID(env, clazz, fieldName, Signature, true);\
|
jfieldID id = getFieldID(env.jniEnv(), clazz, fieldName, Signature, true);\
|
||||||
if (id) {\
|
if (id) {\
|
||||||
env->SetStatic##FieldName##Field(clazz, id, value);\
|
env->SetStatic##FieldName##Field(clazz, id, value);\
|
||||||
env.checkAndClearExceptions();\
|
env.checkAndClearExceptions();\
|
||||||
@ -1485,7 +1485,7 @@ template <> Q_CORE_EXPORT void QJniObject::setStaticField<Type>(jclass clazz,\
|
|||||||
template <> Q_CORE_EXPORT void QJniObject::setField<Type>(const char *fieldName, Type value) \
|
template <> Q_CORE_EXPORT void QJniObject::setField<Type>(const char *fieldName, Type value) \
|
||||||
{ \
|
{ \
|
||||||
QJniEnvironment env; \
|
QJniEnvironment env; \
|
||||||
jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, Signature); \
|
jfieldID id = getCachedFieldID(env.jniEnv(), d->m_jclass, d->m_className, fieldName, Signature); \
|
||||||
if (id) { \
|
if (id) { \
|
||||||
env->Set##FieldName##Field(d->m_jobject, id, value); \
|
env->Set##FieldName##Field(d->m_jobject, id, value); \
|
||||||
env.checkAndClearExceptions(); \
|
env.checkAndClearExceptions(); \
|
||||||
@ -1521,10 +1521,10 @@ QJniObject QJniObject::getStaticObjectField(const char *className,
|
|||||||
const char *signature)
|
const char *signature)
|
||||||
{
|
{
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
jclass clazz = loadClass(className, env);
|
jclass clazz = loadClass(className, env.jniEnv());
|
||||||
if (!clazz)
|
if (!clazz)
|
||||||
return QJniObject();
|
return QJniObject();
|
||||||
jfieldID id = getCachedFieldID(env, clazz, toBinaryEncClassName(className), fieldName,
|
jfieldID id = getCachedFieldID(env.jniEnv(), clazz, toBinaryEncClassName(className), fieldName,
|
||||||
signature, true);
|
signature, true);
|
||||||
if (!id)
|
if (!id)
|
||||||
return QJniObject();
|
return QJniObject();
|
||||||
@ -1549,7 +1549,7 @@ QJniObject QJniObject::getStaticObjectField(jclass clazz,
|
|||||||
const char *signature)
|
const char *signature)
|
||||||
{
|
{
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
jfieldID id = getFieldID(env, clazz, fieldName, signature, true);
|
jfieldID id = getFieldID(env.jniEnv(), clazz, fieldName, signature, true);
|
||||||
if (!id)
|
if (!id)
|
||||||
return QJniObject();
|
return QJniObject();
|
||||||
|
|
||||||
@ -1628,7 +1628,7 @@ template <> Q_CORE_EXPORT
|
|||||||
void QJniObject::setField<jobject>(const char *fieldName, const char *signature, jobject value)
|
void QJniObject::setField<jobject>(const char *fieldName, const char *signature, jobject value)
|
||||||
{
|
{
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, signature);
|
jfieldID id = getCachedFieldID(env.jniEnv(), d->m_jclass, d->m_className, fieldName, signature);
|
||||||
if (id) {
|
if (id) {
|
||||||
env->SetObjectField(d->m_jobject, id, value);
|
env->SetObjectField(d->m_jobject, id, value);
|
||||||
env.checkAndClearExceptions();
|
env.checkAndClearExceptions();
|
||||||
@ -1641,7 +1641,7 @@ void QJniObject::setField<jobjectArray>(const char *fieldName,
|
|||||||
jobjectArray value)
|
jobjectArray value)
|
||||||
{
|
{
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, signature);
|
jfieldID id = getCachedFieldID(env.jniEnv(), d->m_jclass, d->m_className, fieldName, signature);
|
||||||
if (id) {
|
if (id) {
|
||||||
env->SetObjectField(d->m_jobject, id, value);
|
env->SetObjectField(d->m_jobject, id, value);
|
||||||
env.checkAndClearExceptions();
|
env.checkAndClearExceptions();
|
||||||
@ -1672,7 +1672,7 @@ void QJniObject::setField<jobjectArray>(const char *fieldName,
|
|||||||
QJniObject QJniObject::getObjectField(const char *fieldName, const char *signature) const
|
QJniObject QJniObject::getObjectField(const char *fieldName, const char *signature) const
|
||||||
{
|
{
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, signature);
|
jfieldID id = getCachedFieldID(env.jniEnv(), d->m_jclass, d->m_className, fieldName, signature);
|
||||||
if (!id)
|
if (!id)
|
||||||
return QJniObject();
|
return QJniObject();
|
||||||
|
|
||||||
@ -1815,10 +1815,10 @@ bool QJniObject::isClassAvailable(const char *className)
|
|||||||
{
|
{
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
|
|
||||||
if (!env)
|
if (!env.jniEnv())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return loadClass(className, env);;
|
return loadClass(className, env.jniEnv());;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -864,7 +864,7 @@ void QRasterizer::rasterizeLine(const QPointF &a, const QPointF &b, qreal width,
|
|||||||
if (leftWidth == QScFixedFactor)
|
if (leftWidth == QScFixedFactor)
|
||||||
coverage[0] = rightWidth * 255;
|
coverage[0] = rightWidth * 255;
|
||||||
else
|
else
|
||||||
coverage[0] = (leftWidth + rightWidth) * 255;
|
coverage[0] = (rightWidth + leftWidth - QScFixedFactor) * 255;
|
||||||
x[0] = iLeft;
|
x[0] = iLeft;
|
||||||
len[0] = 1;
|
len[0] = 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -320,7 +320,7 @@ namespace QtAndroid
|
|||||||
int createSurface(AndroidSurfaceClient *client, const QRect &geometry, bool onTop, int imageDepth)
|
int createSurface(AndroidSurfaceClient *client, const QRect &geometry, bool onTop, int imageDepth)
|
||||||
{
|
{
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
if (!env)
|
if (!env.jniEnv())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
m_surfacesMutex.lock();
|
m_surfacesMutex.lock();
|
||||||
@ -383,7 +383,7 @@ namespace QtAndroid
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
if (!env)
|
if (!env.jniEnv())
|
||||||
return;
|
return;
|
||||||
jint x = 0, y = 0, w = -1, h = -1;
|
jint x = 0, y = 0, w = -1, h = -1;
|
||||||
if (!geometry.isNull()) {
|
if (!geometry.isNull()) {
|
||||||
@ -412,7 +412,7 @@ namespace QtAndroid
|
|||||||
}
|
}
|
||||||
|
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
if (env)
|
if (env.jniEnv())
|
||||||
env->CallStaticVoidMethod(m_applicationClass,
|
env->CallStaticVoidMethod(m_applicationClass,
|
||||||
m_destroySurfaceMethodID,
|
m_destroySurfaceMethodID,
|
||||||
surfaceId);
|
surfaceId);
|
||||||
|
@ -155,7 +155,7 @@ void QAndroidPlatformMenu::showPopup(const QWindow *parentWindow, const QRect &t
|
|||||||
Q_UNUSED(parentWindow);
|
Q_UNUSED(parentWindow);
|
||||||
Q_UNUSED(item);
|
Q_UNUSED(item);
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
QtAndroidMenu::showContextMenu(this, targetRect, QJniEnvironment());
|
QtAndroidMenu::showContextMenu(this, targetRect, QJniEnvironment().jniEnv());
|
||||||
}
|
}
|
||||||
|
|
||||||
QPlatformMenuItem *QAndroidPlatformMenu::menuItemForTag(quintptr tag) const
|
QPlatformMenuItem *QAndroidPlatformMenu::menuItemForTag(quintptr tag) const
|
||||||
|
@ -176,7 +176,7 @@ void QAndroidPlatformOpenGLWindow::createEgl(EGLConfig config)
|
|||||||
{
|
{
|
||||||
clearEgl();
|
clearEgl();
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
m_nativeWindow = ANativeWindow_fromSurface(env, m_androidSurfaceObject.object());
|
m_nativeWindow = ANativeWindow_fromSurface(env.jniEnv(), m_androidSurfaceObject.object());
|
||||||
m_androidSurfaceObject = QJniObject();
|
m_androidSurfaceObject = QJniObject();
|
||||||
m_eglSurface = eglCreateWindowSurface(m_eglDisplay, config, m_nativeWindow, NULL);
|
m_eglSurface = eglCreateWindowSurface(m_eglDisplay, config, m_nativeWindow, NULL);
|
||||||
m_format = q_glFormatFromConfig(m_eglDisplay, config, window()->requestedFormat());
|
m_format = q_glFormatFromConfig(m_eglDisplay, config, window()->requestedFormat());
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <jni.h>
|
||||||
|
|
||||||
#include <QtCore/QJniEnvironment>
|
#include <QtCore/QJniEnvironment>
|
||||||
#include <QtCore/QJniObject>
|
#include <QtCore/QJniObject>
|
||||||
#include <QtTest/QtTest>
|
#include <QtTest/QtTest>
|
||||||
@ -56,7 +58,7 @@ void tst_QJniEnvironment::jniEnv()
|
|||||||
JNIEnv *jni = 0;
|
JNIEnv *jni = 0;
|
||||||
QCOMPARE(javaVM->GetEnv((void**)&jni, JNI_VERSION_1_6), JNI_OK);
|
QCOMPARE(javaVM->GetEnv((void**)&jni, JNI_VERSION_1_6), JNI_OK);
|
||||||
|
|
||||||
JNIEnv *e = env;
|
JNIEnv *e = env.jniEnv();
|
||||||
QVERIFY(e);
|
QVERIFY(e);
|
||||||
|
|
||||||
QCOMPARE(env->GetVersion(), JNI_VERSION_1_6);
|
QCOMPARE(env->GetVersion(), JNI_VERSION_1_6);
|
||||||
@ -71,11 +73,11 @@ void tst_QJniEnvironment::jniEnv()
|
|||||||
env->ExceptionClear();
|
env->ExceptionClear();
|
||||||
|
|
||||||
QVERIFY(env->FindClass("java/lang/Object"));
|
QVERIFY(env->FindClass("java/lang/Object"));
|
||||||
QVERIFY(!QJniEnvironment::checkAndClearExceptions(env));
|
QVERIFY(!QJniEnvironment::checkAndClearExceptions(env.jniEnv()));
|
||||||
|
|
||||||
// try to find a nonexistent class
|
// try to find a nonexistent class
|
||||||
QVERIFY(!env->FindClass("this/doesnt/Exist"));
|
QVERIFY(!env->FindClass("this/doesnt/Exist"));
|
||||||
QVERIFY(QJniEnvironment::checkAndClearExceptions(env));
|
QVERIFY(QJniEnvironment::checkAndClearExceptions(env.jniEnv()));
|
||||||
|
|
||||||
// try to find an existing class with QJniEnvironment
|
// try to find an existing class with QJniEnvironment
|
||||||
QJniEnvironment env;
|
QJniEnvironment env;
|
||||||
@ -110,6 +112,7 @@ void tst_QJniEnvironment::javaVM()
|
|||||||
|
|
||||||
static void callbackFromJava(JNIEnv *env, jobject /*thiz*/, jstring value)
|
static void callbackFromJava(JNIEnv *env, jobject /*thiz*/, jstring value)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(env)
|
||||||
registerNativesString = QJniObject(value).toString();
|
registerNativesString = QJniObject(value).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,9 +85,8 @@ void tst_QMetaType::typeBuiltin_data()
|
|||||||
{
|
{
|
||||||
QTest::addColumn<QByteArray>("typeName");
|
QTest::addColumn<QByteArray>("typeName");
|
||||||
for (int i = 0; i < QMetaType::User; ++i) {
|
for (int i = 0; i < QMetaType::User; ++i) {
|
||||||
const char *name = QMetaType::typeName(i);
|
if (QMetaType metaType(i); metaType.isValid())
|
||||||
if (name)
|
QTest::newRow(metaType.name()) << QByteArray(metaType.name());
|
||||||
QTest::newRow(name) << QByteArray(name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +97,7 @@ void tst_QMetaType::typeBuiltin()
|
|||||||
const char *nm = typeName.constData();
|
const char *nm = typeName.constData();
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
for (int i = 0; i < 100000; ++i)
|
for (int i = 0; i < 100000; ++i)
|
||||||
QMetaType::type(nm);
|
QMetaType::fromName(nm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +112,7 @@ void tst_QMetaType::typeBuiltin_QByteArray()
|
|||||||
QFETCH(QByteArray, typeName);
|
QFETCH(QByteArray, typeName);
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
for (int i = 0; i < 100000; ++i)
|
for (int i = 0; i < 100000; ++i)
|
||||||
QMetaType::type(typeName);
|
QMetaType::fromName(typeName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,9 +120,8 @@ void tst_QMetaType::typeBuiltinNotNormalized_data()
|
|||||||
{
|
{
|
||||||
QTest::addColumn<QByteArray>("typeName");
|
QTest::addColumn<QByteArray>("typeName");
|
||||||
for (int i = 0; i < QMetaType::User; ++i) {
|
for (int i = 0; i < QMetaType::User; ++i) {
|
||||||
const char *name = QMetaType::typeName(i);
|
if (QMetaType metaType(i); metaType.isValid())
|
||||||
if (name)
|
QTest::newRow(metaType.name()) << QByteArray(metaType.name()).append(" ");
|
||||||
QTest::newRow(name) << QByteArray(name).append(" ");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +131,7 @@ void tst_QMetaType::typeBuiltinNotNormalized()
|
|||||||
const char *nm = typeName.constData();
|
const char *nm = typeName.constData();
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
for (int i = 0; i < 10000; ++i)
|
for (int i = 0; i < 10000; ++i)
|
||||||
QMetaType::type(nm);
|
QMetaType::fromName(nm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +142,7 @@ void tst_QMetaType::typeCustom()
|
|||||||
qRegisterMetaType<Foo>("Foo");
|
qRegisterMetaType<Foo>("Foo");
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
for (int i = 0; i < 10000; ++i)
|
for (int i = 0; i < 10000; ++i)
|
||||||
QMetaType::type("Foo");
|
QMetaType::fromName("Foo");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,25 +151,25 @@ void tst_QMetaType::typeCustomNotNormalized()
|
|||||||
qRegisterMetaType<Foo>("Foo");
|
qRegisterMetaType<Foo>("Foo");
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
for (int i = 0; i < 10000; ++i)
|
for (int i = 0; i < 10000; ++i)
|
||||||
QMetaType::type("Foo ");
|
QMetaType::fromName("Foo ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QMetaType::typeNotRegistered()
|
void tst_QMetaType::typeNotRegistered()
|
||||||
{
|
{
|
||||||
Q_ASSERT(QMetaType::type("Bar") == 0);
|
Q_ASSERT(!QMetaType::fromName("Bar").isValid());
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
for (int i = 0; i < 10000; ++i)
|
for (int i = 0; i < 10000; ++i)
|
||||||
QMetaType::type("Bar");
|
QMetaType::fromName("Bar");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QMetaType::typeNotRegisteredNotNormalized()
|
void tst_QMetaType::typeNotRegisteredNotNormalized()
|
||||||
{
|
{
|
||||||
Q_ASSERT(QMetaType::type("Bar") == 0);
|
Q_ASSERT(!QMetaType::fromName("Bar").isValid());
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
for (int i = 0; i < 10000; ++i)
|
for (int i = 0; i < 10000; ++i)
|
||||||
QMetaType::type("Bar ");
|
QMetaType::fromName("Bar ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,9 +177,8 @@ void tst_QMetaType::typeNameBuiltin_data()
|
|||||||
{
|
{
|
||||||
QTest::addColumn<int>("type");
|
QTest::addColumn<int>("type");
|
||||||
for (int i = 0; i < QMetaType::User; ++i) {
|
for (int i = 0; i < QMetaType::User; ++i) {
|
||||||
const char *name = QMetaType::typeName(i);
|
if (QMetaType metaType(i); metaType.isValid())
|
||||||
if (name)
|
QTest::newRow(metaType.name()) << i;
|
||||||
QTest::newRow(name) << i;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +187,7 @@ void tst_QMetaType::typeNameBuiltin()
|
|||||||
QFETCH(int, type);
|
QFETCH(int, type);
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
for (int i = 0; i < 500000; ++i)
|
for (int i = 0; i < 500000; ++i)
|
||||||
QMetaType::typeName(type);
|
QMetaType(type).name();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,17 +196,17 @@ void tst_QMetaType::typeNameCustom()
|
|||||||
int type = qRegisterMetaType<Foo>("Foo");
|
int type = qRegisterMetaType<Foo>("Foo");
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
for (int i = 0; i < 100000; ++i)
|
for (int i = 0; i < 100000; ++i)
|
||||||
QMetaType::typeName(type);
|
QMetaType(type).name();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QMetaType::typeNameNotRegistered()
|
void tst_QMetaType::typeNameNotRegistered()
|
||||||
{
|
{
|
||||||
// We don't care much about this case, but test it anyway.
|
// We don't care much about this case, but test it anyway.
|
||||||
Q_ASSERT(QMetaType::typeName(-1) == 0);
|
Q_ASSERT(QMetaType(-1).name() == nullptr);
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
for (int i = 0; i < 500000; ++i)
|
for (int i = 0; i < 500000; ++i)
|
||||||
QMetaType::typeName(-1);
|
QMetaType(-1).name();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,7 +235,7 @@ void tst_QMetaType::isRegisteredCustom()
|
|||||||
|
|
||||||
void tst_QMetaType::isRegisteredNotRegistered()
|
void tst_QMetaType::isRegisteredNotRegistered()
|
||||||
{
|
{
|
||||||
Q_ASSERT(QMetaType::typeName(-1) == 0);
|
Q_ASSERT(QMetaType(-1).name() == nullptr);
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
for (int i = 0; i < 100000; ++i)
|
for (int i = 0; i < 100000; ++i)
|
||||||
QMetaType::isRegistered(-1);
|
QMetaType::isRegistered(-1);
|
||||||
@ -249,7 +246,7 @@ void tst_QMetaType::constructInPlace_data()
|
|||||||
{
|
{
|
||||||
QTest::addColumn<int>("typeId");
|
QTest::addColumn<int>("typeId");
|
||||||
for (int i = QMetaType::FirstCoreType; i <= QMetaType::LastCoreType; ++i) {
|
for (int i = QMetaType::FirstCoreType; i <= QMetaType::LastCoreType; ++i) {
|
||||||
auto name = QMetaType::typeName(i);
|
auto name = QMetaType(i).name();
|
||||||
if (name && i != QMetaType::Void)
|
if (name && i != QMetaType::Void)
|
||||||
QTest::newRow(name) << i;
|
QTest::newRow(name) << i;
|
||||||
}
|
}
|
||||||
@ -261,14 +258,15 @@ void tst_QMetaType::constructInPlace_data()
|
|||||||
void tst_QMetaType::constructInPlace()
|
void tst_QMetaType::constructInPlace()
|
||||||
{
|
{
|
||||||
QFETCH(int, typeId);
|
QFETCH(int, typeId);
|
||||||
int size = QMetaType::sizeOf(typeId);
|
const QMetaType metaType(typeId);
|
||||||
|
size_t size = metaType.sizeOf();
|
||||||
void *storage = qMallocAligned(size, 2 * sizeof(qlonglong));
|
void *storage = qMallocAligned(size, 2 * sizeof(qlonglong));
|
||||||
QCOMPARE(QMetaType::construct(typeId, storage, /*copy=*/0), storage);
|
QCOMPARE(metaType.construct(storage, /*copy=*/0), storage);
|
||||||
QMetaType::destruct(typeId, storage);
|
metaType.destruct(storage);
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
for (int i = 0; i < 100000; ++i) {
|
for (int i = 0; i < 100000; ++i) {
|
||||||
QMetaType::construct(typeId, storage, /*copy=*/0);
|
metaType.construct(storage, /*copy=*/0);
|
||||||
QMetaType::destruct(typeId, storage);
|
metaType.destruct(storage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qFreeAligned(storage);
|
qFreeAligned(storage);
|
||||||
@ -282,18 +280,19 @@ void tst_QMetaType::constructInPlaceCopy_data()
|
|||||||
void tst_QMetaType::constructInPlaceCopy()
|
void tst_QMetaType::constructInPlaceCopy()
|
||||||
{
|
{
|
||||||
QFETCH(int, typeId);
|
QFETCH(int, typeId);
|
||||||
int size = QMetaType::sizeOf(typeId);
|
const QMetaType metaType(typeId);
|
||||||
|
size_t size = metaType.sizeOf();
|
||||||
void *storage = qMallocAligned(size, 2 * sizeof(qlonglong));
|
void *storage = qMallocAligned(size, 2 * sizeof(qlonglong));
|
||||||
void *other = QMetaType::create(typeId);
|
void *other = metaType.create();
|
||||||
QCOMPARE(QMetaType::construct(typeId, storage, other), storage);
|
QCOMPARE(metaType.construct(storage, other), storage);
|
||||||
QMetaType::destruct(typeId, storage);
|
metaType.destruct(storage);
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
for (int i = 0; i < 100000; ++i) {
|
for (int i = 0; i < 100000; ++i) {
|
||||||
QMetaType::construct(typeId, storage, other);
|
metaType.construct(storage, other);
|
||||||
QMetaType::destruct(typeId, storage);
|
metaType.destruct(storage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QMetaType::destroy(typeId, other);
|
metaType.destroy(other);
|
||||||
qFreeAligned(storage);
|
qFreeAligned(storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,19 +304,19 @@ void tst_QMetaType::constructInPlaceCopyStaticLess_data()
|
|||||||
void tst_QMetaType::constructInPlaceCopyStaticLess()
|
void tst_QMetaType::constructInPlaceCopyStaticLess()
|
||||||
{
|
{
|
||||||
QFETCH(int, typeId);
|
QFETCH(int, typeId);
|
||||||
int size = QMetaType::sizeOf(typeId);
|
const QMetaType metaType(typeId);
|
||||||
|
size_t size = metaType.sizeOf();
|
||||||
void *storage = qMallocAligned(size, 2 * sizeof(qlonglong));
|
void *storage = qMallocAligned(size, 2 * sizeof(qlonglong));
|
||||||
void *other = QMetaType::create(typeId);
|
void *other = metaType.create();
|
||||||
QCOMPARE(QMetaType::construct(typeId, storage, other), storage);
|
QCOMPARE(metaType.construct(storage, other), storage);
|
||||||
QMetaType::destruct(typeId, storage);
|
metaType.destruct(storage);
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
QMetaType type(typeId);
|
|
||||||
for (int i = 0; i < 100000; ++i) {
|
for (int i = 0; i < 100000; ++i) {
|
||||||
type.construct(storage, other);
|
metaType.construct(storage, other);
|
||||||
type.destruct(storage);
|
metaType.destruct(storage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QMetaType::destroy(typeId, other);
|
metaType.destroy(other);
|
||||||
qFreeAligned(storage);
|
qFreeAligned(storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,8 +337,8 @@ void tst_qvariant::createCoreType_data()
|
|||||||
{
|
{
|
||||||
QTest::addColumn<int>("typeId");
|
QTest::addColumn<int>("typeId");
|
||||||
for (int i = QMetaType::FirstCoreType; i <= QMetaType::LastCoreType; ++i) {
|
for (int i = QMetaType::FirstCoreType; i <= QMetaType::LastCoreType; ++i) {
|
||||||
if (QMetaType::typeName(i)) // QMetaType(27) does not exist
|
if (QMetaType metaType(i); metaType.isValid()) // QMetaType(27) does not exist
|
||||||
QTest::newRow(QMetaType::typeName(i)) << i;
|
QTest::newRow(metaType.typeName(i)) << i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,9 +48,8 @@ void tst_QGuiMetaType::constructableGuiTypes()
|
|||||||
{
|
{
|
||||||
QTest::addColumn<int>("typeId");
|
QTest::addColumn<int>("typeId");
|
||||||
for (int i = QMetaType::FirstGuiType; i <= QMetaType::LastGuiType; ++i) {
|
for (int i = QMetaType::FirstGuiType; i <= QMetaType::LastGuiType; ++i) {
|
||||||
QMetaType metaType(i);
|
if (QMetaType metaType(i); metaType.isValid())
|
||||||
if (metaType.isValid())
|
QTest::newRow(metaType.name()) << i;
|
||||||
QTest::newRow(QMetaType::typeName(i)) << i;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,9 +58,8 @@ void tst_QGuiVariant::createGuiType_data()
|
|||||||
{
|
{
|
||||||
QTest::addColumn<int>("typeId");
|
QTest::addColumn<int>("typeId");
|
||||||
for (int i = QMetaType::FirstGuiType; i <= QMetaType::LastGuiType; ++i) {
|
for (int i = QMetaType::FirstGuiType; i <= QMetaType::LastGuiType; ++i) {
|
||||||
QMetaType metaType(i);
|
if (QMetaType metaType(i); metaType.isValid())
|
||||||
if (metaType.isValid())
|
QTest::newRow(metaType.name()) << i;
|
||||||
QTest::newRow(QMetaType::typeName(i)) << i;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user