| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This file is autogenerated by | 5 // This file is autogenerated by |
| 6 // base/android/jni_generator/jni_generator.py | 6 // base/android/jni_generator/jni_generator.py |
| 7 // For | 7 // For |
| 8 // org/chromium/TestJni | 8 // org/chromium/TestJni |
| 9 | 9 |
| 10 #ifndef org_chromium_TestJni_JNI | 10 #ifndef org_chromium_TestJni_JNI |
| 11 #define org_chromium_TestJni_JNI | 11 #define org_chromium_TestJni_JNI |
| 12 | 12 |
| 13 #include <jni.h> | 13 #include <jni.h> |
| 14 | 14 |
| 15 #include "base/android/jni_generator/jni_generator_helper.h" | 15 #include "base/android/jni_generator/jni_generator_helper.h" |
| 16 | 16 |
| 17 #include "base/android/jni_int_wrapper.h" | 17 #include "base/android/jni_int_wrapper.h" |
| 18 | 18 |
| 19 // Step 1: forward declarations. | 19 // Step 1: forward declarations. |
| 20 namespace { | 20 namespace { |
| 21 const char kMyOtherInnerClassClassPath[] = | 21 const char kMyOtherInnerClassClassPath[] = |
| 22 "org/chromium/TestJni$MyOtherInnerClass"; | 22 "org/chromium/TestJni$MyOtherInnerClass"; |
| 23 const char kTestJniClassPath[] = "org/chromium/TestJni"; | 23 const char kTestJniClassPath[] = "org/chromium/TestJni"; |
| 24 // Leaking this jclass as we cannot use LazyInstance from some threads. | 24 // Leaking this jclass as we cannot use LazyInstance from some threads. |
| 25 jclass g_MyOtherInnerClass_clazz = NULL; | 25 base::subtle::AtomicWord g_MyOtherInnerClass_clazz __attribute__((unused)) = 0; |
| 26 #define MyOtherInnerClass_clazz(env) g_MyOtherInnerClass_clazz | 26 #define MyOtherInnerClass_clazz(env) base::android::LazyGetClass(env, kMyOtherIn
nerClassClassPath, &g_MyOtherInnerClass_clazz) |
| 27 // Leaking this jclass as we cannot use LazyInstance from some threads. | 27 // Leaking this jclass as we cannot use LazyInstance from some threads. |
| 28 jclass g_TestJni_clazz = NULL; | 28 base::subtle::AtomicWord g_TestJni_clazz __attribute__((unused)) = 0; |
| 29 #define TestJni_clazz(env) g_TestJni_clazz | 29 #define TestJni_clazz(env) base::android::LazyGetClass(env, kTestJniClassPath, &
g_TestJni_clazz) |
| 30 | 30 |
| 31 } // namespace | 31 } // namespace |
| 32 | 32 |
| 33 // Step 2: method stubs. | 33 // Step 2: method stubs. |
| 34 | 34 |
| 35 static jint Init(JNIEnv* env, const JavaParamRef<jobject>& jcaller); | 35 static jint Init(JNIEnv* env, const JavaParamRef<jobject>& jcaller); |
| 36 | 36 |
| 37 static jint Java_org_chromium_TestJni_nativeInit(JNIEnv* env, jobject jcaller) { | 37 extern "C" __attribute__((visibility("default"))) |
| 38 jint Java_org_chromium_TestJni_nativeInit(JNIEnv* env, jobject jcaller) { |
| 38 return Init(env, JavaParamRef<jobject>(env, jcaller)); | 39 return Init(env, JavaParamRef<jobject>(env, jcaller)); |
| 39 } | 40 } |
| 40 | 41 |
| 41 static jint Init(JNIEnv* env, const JavaParamRef<jobject>& jcaller); | 42 static jint Init(JNIEnv* env, const JavaParamRef<jobject>& jcaller); |
| 42 | 43 |
| 43 static jint Java_org_chromium_TestJni_00024MyOtherInnerClass_nativeInit(JNIEnv* | 44 extern "C" __attribute__((visibility("default"))) |
| 44 env, jobject jcaller) { | 45 jint Java_org_chromium_TestJni_00024MyOtherInnerClass_nativeInit(JNIEnv* env, |
| 46 jobject jcaller) { |
| 45 return Init(env, JavaParamRef<jobject>(env, jcaller)); | 47 return Init(env, JavaParamRef<jobject>(env, jcaller)); |
| 46 } | 48 } |
| 47 | 49 |
| 48 // Step 3: RegisterNatives. | 50 // Step 3: RegisterNatives. |
| 49 | 51 |
| 50 static const JNINativeMethod kMethodsMyOtherInnerClass[] = { | 52 static const JNINativeMethod kMethodsMyOtherInnerClass[] = { |
| 51 { "nativeInit", | 53 { "nativeInit", |
| 52 "(" | 54 "(" |
| 53 ")" | 55 ")" |
| 54 "I", | 56 "I", |
| 55 reinterpret_cast<void*>(Java_org_chromium_TestJni_00024MyOtherInnerClass_nat
iveInit) | 57 reinterpret_cast<void*>(Java_org_chromium_TestJni_00024MyOtherInnerClass_nat
iveInit) |
| 56 }, | 58 }, |
| 57 }; | 59 }; |
| 58 | 60 |
| 59 static const JNINativeMethod kMethodsTestJni[] = { | 61 static const JNINativeMethod kMethodsTestJni[] = { |
| 60 { "nativeInit", | 62 { "nativeInit", |
| 61 "(" | 63 "(" |
| 62 ")" | 64 ")" |
| 63 "I", reinterpret_cast<void*>(Java_org_chromium_TestJni_nativeInit) }, | 65 "I", reinterpret_cast<void*>(Java_org_chromium_TestJni_nativeInit) }, |
| 64 }; | 66 }; |
| 65 | 67 |
| 66 static bool RegisterNativesImpl(JNIEnv* env) { | 68 static bool RegisterNativesImpl(JNIEnv* env) { |
| 67 | 69 if (base::android::IsManualJniRegistrationDisabled()) return true; |
| 68 g_MyOtherInnerClass_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( | |
| 69 base::android::GetClass(env, kMyOtherInnerClassClassPath).obj())); | |
| 70 g_TestJni_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( | |
| 71 base::android::GetClass(env, kTestJniClassPath).obj())); | |
| 72 | 70 |
| 73 const int kMethodsMyOtherInnerClassSize = | 71 const int kMethodsMyOtherInnerClassSize = |
| 74 arraysize(kMethodsMyOtherInnerClass); | 72 arraysize(kMethodsMyOtherInnerClass); |
| 75 | 73 |
| 76 if (env->RegisterNatives(MyOtherInnerClass_clazz(env), | 74 if (env->RegisterNatives(MyOtherInnerClass_clazz(env), |
| 77 kMethodsMyOtherInnerClass, | 75 kMethodsMyOtherInnerClass, |
| 78 kMethodsMyOtherInnerClassSize) < 0) { | 76 kMethodsMyOtherInnerClassSize) < 0) { |
| 79 jni_generator::HandleRegistrationError( | 77 jni_generator::HandleRegistrationError( |
| 80 env, MyOtherInnerClass_clazz(env), __FILE__); | 78 env, MyOtherInnerClass_clazz(env), __FILE__); |
| 81 return false; | 79 return false; |
| 82 } | 80 } |
| 83 | 81 |
| 84 const int kMethodsTestJniSize = arraysize(kMethodsTestJni); | 82 const int kMethodsTestJniSize = arraysize(kMethodsTestJni); |
| 85 | 83 |
| 86 if (env->RegisterNatives(TestJni_clazz(env), | 84 if (env->RegisterNatives(TestJni_clazz(env), |
| 87 kMethodsTestJni, | 85 kMethodsTestJni, |
| 88 kMethodsTestJniSize) < 0) { | 86 kMethodsTestJniSize) < 0) { |
| 89 jni_generator::HandleRegistrationError( | 87 jni_generator::HandleRegistrationError( |
| 90 env, TestJni_clazz(env), __FILE__); | 88 env, TestJni_clazz(env), __FILE__); |
| 91 return false; | 89 return false; |
| 92 } | 90 } |
| 93 | 91 |
| 94 return true; | 92 return true; |
| 95 } | 93 } |
| 96 | 94 |
| 97 #endif // org_chromium_TestJni_JNI | 95 #endif // org_chromium_TestJni_JNI |
| OLD | NEW |