mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 20:30:41 +00:00
Bug 1485833 - Use a backwards compatible way of handling NDK changes in jni.h. r=jchen
When building with the NDK clang, which is the easiest way of building locally, NDK r17 doesn't work for ARM builds because of a broken clang, and while the NDK r18-beta fixes that problem, for some people it causes a different set of issues. Since NDK r15c doesn't have the ndk-version.h headers, switch to a different way of bridging the differences that allows people to continue building with r15c locally. Differential Revision: https://phabricator.services.mozilla.com/D4471 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
c9cfb100eb
commit
07d61a0e0f
@ -1,7 +1,6 @@
|
||||
#ifndef mozilla_jni_Types_h__
|
||||
#define mozilla_jni_Types_h__
|
||||
|
||||
#include <android/ndk-version.h>
|
||||
#include <jni.h>
|
||||
|
||||
#include "mozilla/jni/Refs.h"
|
||||
@ -54,16 +53,20 @@ template<class Cls> struct TypeAdapter<LocalRef<Cls>> {
|
||||
#define MOZ_JNICALL_ABI
|
||||
#endif
|
||||
|
||||
#if __NDK_MAJOR__ >= 18
|
||||
#define JVALUE_PTR const jvalue*
|
||||
#else
|
||||
#define JVALUE_PTR jvalue*
|
||||
#endif
|
||||
// NDK r18 made jvalue* method parameters const. We detect the change directly
|
||||
// instead of using ndk-version.h in order to remain compatible with r15 for
|
||||
// now, which doesn't include those headers.
|
||||
class CallArgs {
|
||||
static const jvalue* test(void (JNIEnv::*)(jobject, jmethodID, const jvalue*));
|
||||
static jvalue* test(void (JNIEnv::*)(jobject, jmethodID, jvalue*));
|
||||
public:
|
||||
using JValueType = decltype(test(&JNIEnv::CallVoidMethodA));
|
||||
};
|
||||
|
||||
template<class Cls> constexpr jobject
|
||||
(JNIEnv::*TypeAdapter<LocalRef<Cls>>::Call)(jobject, jmethodID, JVALUE_PTR) MOZ_JNICALL_ABI;
|
||||
(JNIEnv::*TypeAdapter<LocalRef<Cls>>::Call)(jobject, jmethodID, CallArgs::JValueType) MOZ_JNICALL_ABI;
|
||||
template<class Cls> constexpr jobject
|
||||
(JNIEnv::*TypeAdapter<LocalRef<Cls>>::StaticCall)(jclass, jmethodID, JVALUE_PTR) MOZ_JNICALL_ABI;
|
||||
(JNIEnv::*TypeAdapter<LocalRef<Cls>>::StaticCall)(jclass, jmethodID, CallArgs::JValueType) MOZ_JNICALL_ABI;
|
||||
template<class Cls> constexpr jobject
|
||||
(JNIEnv::*TypeAdapter<LocalRef<Cls>>::Get)(jobject, jfieldID);
|
||||
template<class Cls> constexpr jobject
|
||||
|
@ -19,9 +19,9 @@ namespace detail {
|
||||
#define DEFINE_PRIMITIVE_TYPE_ADAPTER(NativeType, JNIType, JNIName, ABIName) \
|
||||
\
|
||||
constexpr JNIType (JNIEnv::*TypeAdapter<NativeType>::Call) \
|
||||
(jobject, jmethodID, JVALUE_PTR) MOZ_JNICALL_ABI; \
|
||||
(jobject, jmethodID, CallArgs::JValueType) MOZ_JNICALL_ABI; \
|
||||
constexpr JNIType (JNIEnv::*TypeAdapter<NativeType>::StaticCall) \
|
||||
(jclass, jmethodID, JVALUE_PTR) MOZ_JNICALL_ABI; \
|
||||
(jclass, jmethodID, CallArgs::JValueType) MOZ_JNICALL_ABI; \
|
||||
constexpr JNIType (JNIEnv::*TypeAdapter<NativeType>::Get) \
|
||||
(jobject, jfieldID) ABIName; \
|
||||
constexpr JNIType (JNIEnv::*TypeAdapter<NativeType>::StaticGet) \
|
||||
|
Loading…
x
Reference in New Issue
Block a user