Bug 1277624 - Move JNI class name out of Context; r=snorp
Move the class name strings into ObjectBase, so that the strings can be overridden by derived classes in other namespaces.
This commit is contained in:
@@ -42,13 +42,14 @@ public class CodeGenerator {
|
||||
unqualifiedName + ", jobject>\n" +
|
||||
"{\n" +
|
||||
"public:\n" +
|
||||
" static const char name[];\n" +
|
||||
"\n" +
|
||||
" explicit " + unqualifiedName + "(const Context& ctx) : ObjectBase<" +
|
||||
unqualifiedName + ", jobject>(ctx) {}\n" +
|
||||
"\n");
|
||||
|
||||
cpp.append(
|
||||
"template<> const char mozilla::jni::Context<" +
|
||||
clsName + ", jobject>::name[] =\n" +
|
||||
"const char " + clsName + "::name[] =\n" +
|
||||
" \"" + cls.getName().replace('.', '/') + "\";\n" +
|
||||
"\n");
|
||||
|
||||
|
||||
@@ -173,8 +173,6 @@ protected:
|
||||
JNIEnv* const mEnv;
|
||||
|
||||
public:
|
||||
static const char name[];
|
||||
|
||||
static jclass RawClassRef()
|
||||
{
|
||||
return sClassRef;
|
||||
@@ -193,7 +191,7 @@ public:
|
||||
jclass ClassRef() const
|
||||
{
|
||||
if (!sClassRef) {
|
||||
sClassRef = GetClassGlobalRef(mEnv, name);
|
||||
sClassRef = GetClassGlobalRef(mEnv, Cls::name);
|
||||
}
|
||||
return sClassRef;
|
||||
}
|
||||
@@ -251,6 +249,7 @@ public:
|
||||
using Param = const Ref&;
|
||||
|
||||
static const bool isMultithreaded = true;
|
||||
static const char name[];
|
||||
|
||||
explicit ObjectBase(const Context& ctx) : mCtx(ctx) {}
|
||||
|
||||
|
||||
@@ -47,19 +47,19 @@ DEFINE_PRIMITIVE_TYPE_ADAPTER(double, jdouble, Double, MOZ_JNICALL_ABI);
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<> const char Context<Object, jobject>::name[] = "java/lang/Object";
|
||||
template<> const char Context<TypedObject<jstring>, jstring>::name[] = "java/lang/String";
|
||||
template<> const char Context<TypedObject<jclass>, jclass>::name[] = "java/lang/Class";
|
||||
template<> const char Context<TypedObject<jthrowable>, jthrowable>::name[] = "java/lang/Throwable";
|
||||
template<> const char Context<TypedObject<jbooleanArray>, jbooleanArray>::name[] = "[Z";
|
||||
template<> const char Context<TypedObject<jbyteArray>, jbyteArray>::name[] = "[B";
|
||||
template<> const char Context<TypedObject<jcharArray>, jcharArray>::name[] = "[C";
|
||||
template<> const char Context<TypedObject<jshortArray>, jshortArray>::name[] = "[S";
|
||||
template<> const char Context<TypedObject<jintArray>, jintArray>::name[] = "[I";
|
||||
template<> const char Context<TypedObject<jlongArray>, jlongArray>::name[] = "[J";
|
||||
template<> const char Context<TypedObject<jfloatArray>, jfloatArray>::name[] = "[F";
|
||||
template<> const char Context<TypedObject<jdoubleArray>, jdoubleArray>::name[] = "[D";
|
||||
template<> const char Context<TypedObject<jobjectArray>, jobjectArray>::name[] = "[Ljava/lang/Object;";
|
||||
template<> const char ObjectBase<Object, jobject>::name[] = "java/lang/Object";
|
||||
template<> const char ObjectBase<TypedObject<jstring>, jstring>::name[] = "java/lang/String";
|
||||
template<> const char ObjectBase<TypedObject<jclass>, jclass>::name[] = "java/lang/Class";
|
||||
template<> const char ObjectBase<TypedObject<jthrowable>, jthrowable>::name[] = "java/lang/Throwable";
|
||||
template<> const char ObjectBase<TypedObject<jbooleanArray>, jbooleanArray>::name[] = "[Z";
|
||||
template<> const char ObjectBase<TypedObject<jbyteArray>, jbyteArray>::name[] = "[B";
|
||||
template<> const char ObjectBase<TypedObject<jcharArray>, jcharArray>::name[] = "[C";
|
||||
template<> const char ObjectBase<TypedObject<jshortArray>, jshortArray>::name[] = "[S";
|
||||
template<> const char ObjectBase<TypedObject<jintArray>, jintArray>::name[] = "[I";
|
||||
template<> const char ObjectBase<TypedObject<jlongArray>, jlongArray>::name[] = "[J";
|
||||
template<> const char ObjectBase<TypedObject<jfloatArray>, jfloatArray>::name[] = "[F";
|
||||
template<> const char ObjectBase<TypedObject<jdoubleArray>, jdoubleArray>::name[] = "[D";
|
||||
template<> const char ObjectBase<TypedObject<jobjectArray>, jobjectArray>::name[] = "[Ljava/lang/Object;";
|
||||
|
||||
|
||||
JNIEnv* sGeckoThreadEnv;
|
||||
|
||||
Reference in New Issue
Block a user