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/example/jni_generator/SampleForTests | 8 // org/chromium/example/jni_generator/SampleForTests |
9 | 9 |
10 #ifndef org_chromium_example_jni_generator_SampleForTests_JNI | 10 #ifndef org_chromium_example_jni_generator_SampleForTests_JNI |
11 #define org_chromium_example_jni_generator_SampleForTests_JNI | 11 #define org_chromium_example_jni_generator_SampleForTests_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 kSampleForTestsClassPath[] = | 21 const char kSampleForTestsClassPath[] = |
22 "org/chromium/example/jni_generator/SampleForTests"; | 22 "org/chromium/example/jni_generator/SampleForTests"; |
23 // Leaking this jclass as we cannot use LazyInstance from some threads. | 23 // Leaking this jclass as we cannot use LazyInstance from some threads. |
24 base::subtle::AtomicWord g_SampleForTests_clazz __attribute__((unused)) = 0; | 24 base::subtle::AtomicWord g_SampleForTests_clazz __attribute__((unused)) = 0; |
25 #define SampleForTests_clazz(env) base::android::LazyGetClass(env, kSampleForTes
tsClassPath, &g_SampleForTests_clazz) | 25 #define SampleForTests_clazz(env) base::android::LazyGetClass(env, kSampleForTes
tsClassPath, &g_SampleForTests_clazz) |
26 | 26 |
27 } // namespace | 27 } // namespace |
28 | 28 |
29 extern "C" { | |
30 | |
31 static jint Init(JNIEnv* env, jobject jcaller); | 29 static jint Init(JNIEnv* env, jobject jcaller); |
32 | 30 |
33 __attribute__((visibility("default"))) | 31 extern "C" __attribute__((visibility("default"))) |
34 jint | 32 jint |
35 Java_org_chromium_example_jni_1generator_SampleForTests_00024MyInnerClass_na
tiveInit(JNIEnv* | 33 Java_org_chromium_example_jni_1generator_SampleForTests_00024MyInnerClass_na
tiveInit(JNIEnv* |
36 env, jobject jcaller) { | 34 env, jobject jcaller) { |
37 return Init(env, jcaller); | 35 return Init(env, jcaller); |
38 } | 36 } |
39 | 37 |
40 static jint Init(JNIEnv* env, jobject jcaller); | 38 static jint Init(JNIEnv* env, jobject jcaller); |
41 | 39 |
42 __attribute__((visibility("default"))) | 40 extern "C" __attribute__((visibility("default"))) |
43 jint | 41 jint |
44 Java_org_chromium_example_jni_1generator_SampleForTests_00024MyOtherInnerCla
ss_nativeInit(JNIEnv* | 42 Java_org_chromium_example_jni_1generator_SampleForTests_00024MyOtherInnerCla
ss_nativeInit(JNIEnv* |
45 env, jobject jcaller) { | 43 env, jobject jcaller) { |
46 return Init(env, jcaller); | 44 return Init(env, jcaller); |
47 } | 45 } |
48 | 46 |
49 }; // extern "C" | |
50 | |
51 // Step 2: method stubs. | 47 // Step 2: method stubs. |
52 | 48 extern "C" __attribute__((visibility("default"))) |
53 extern "C" { | |
54 __attribute__((visibility("default"))) | |
55 jint | 49 jint |
56 Java_org_chromium_example_jni_1generator_SampleForTests_nativeStaticMethod(J
NIEnv* | 50 Java_org_chromium_example_jni_1generator_SampleForTests_nativeStaticMethod(J
NIEnv* |
57 env, | 51 env, |
58 jobject jcaller, | 52 jobject jcaller, |
59 jlong nativeTest, | 53 jlong nativeTest, |
60 jint arg1) { | 54 jint arg1) { |
61 Test* native = reinterpret_cast<Test*>(nativeTest); | 55 Test* native = reinterpret_cast<Test*>(nativeTest); |
62 CHECK_NATIVE_PTR(env, jcaller, native, "StaticMethod", 0); | 56 CHECK_NATIVE_PTR(env, jcaller, native, "StaticMethod", 0); |
63 return native->StaticMethod(env, jcaller, arg1); | 57 return native->StaticMethod(env, jcaller, arg1); |
64 } | 58 } |
65 | 59 |
66 __attribute__((visibility("default"))) | 60 extern "C" __attribute__((visibility("default"))) |
67 jint | 61 jint |
68 Java_org_chromium_example_jni_1generator_SampleForTests_nativeMethod(JNIEnv* | 62 Java_org_chromium_example_jni_1generator_SampleForTests_nativeMethod(JNIEnv* |
69 env, | 63 env, |
70 jobject jcaller, | 64 jobject jcaller, |
71 jlong nativeTest, | 65 jlong nativeTest, |
72 jint arg1) { | 66 jint arg1) { |
73 Test* native = reinterpret_cast<Test*>(nativeTest); | 67 Test* native = reinterpret_cast<Test*>(nativeTest); |
74 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0); | 68 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0); |
75 return native->Method(env, jcaller, arg1); | 69 return native->Method(env, jcaller, arg1); |
76 } | 70 } |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 ")" | 185 ")" |
192 "Ljava/lang/String;", | 186 "Ljava/lang/String;", |
193 &g_SampleForTests_testStaticMethodWithNoParam); | 187 &g_SampleForTests_testStaticMethodWithNoParam); |
194 | 188 |
195 jstring ret = | 189 jstring ret = |
196 static_cast<jstring>(env->CallStaticObjectMethod(SampleForTests_clazz(env), | 190 static_cast<jstring>(env->CallStaticObjectMethod(SampleForTests_clazz(env), |
197 method_id)); | 191 method_id)); |
198 jni_generator::CheckException(env); | 192 jni_generator::CheckException(env); |
199 return base::android::ScopedJavaLocalRef<jstring>(env, ret); | 193 return base::android::ScopedJavaLocalRef<jstring>(env, ret); |
200 } | 194 } |
201 }; // extern "C" | |
202 | 195 |
203 // Step 3: RegisterNatives. | 196 // Step 3: RegisterNatives. |
204 | 197 |
205 static bool RegisterNativesImpl(JNIEnv* env, jclass clazz) { | 198 static bool RegisterNativesImpl(JNIEnv* env, jclass clazz) { |
206 | 199 |
207 base::subtle::Release_Store(&g_SampleForTests_clazz, | 200 base::subtle::Release_Store(&g_SampleForTests_clazz, |
208 static_cast<base::subtle::AtomicWord>(env->NewWeakGlobalRef(clazz)); | 201 static_cast<base::subtle::AtomicWord>(env->NewWeakGlobalRef(clazz)); |
209 | 202 |
210 return true; | 203 return true; |
211 } | 204 } |
212 | 205 |
213 extern "C" JNIEXPORT bool JNICALL | 206 extern "C" JNIEXPORT bool JNICALL |
214 Java_org_chromium_example_jni_1generator_SampleForTests_nativeInitNativeClass(JN
IEnv* | 207 Java_org_chromium_example_jni_1generator_SampleForTests_nativeInitNativeClass(JN
IEnv* |
215 env, jclass clazz) { | 208 env, jclass clazz) { |
216 return RegisterNativesImpl(env, clazz); | 209 return RegisterNativesImpl(env, clazz); |
217 } | 210 } |
218 | 211 |
219 #endif // org_chromium_example_jni_generator_SampleForTests_JNI | 212 #endif // org_chromium_example_jni_generator_SampleForTests_JNI |
OLD | NEW |