OLD | NEW |
1 // Copyright (c) 2012 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 kInnerStructAClassPath[] = | 21 const char kInnerStructAClassPath[] = |
22 "org/chromium/example/jni_generator/SampleForTests$InnerStructA"; | 22 "org/chromium/example/jni_generator/SampleForTests$InnerStructA"; |
23 const char kSampleForTestsClassPath[] = | 23 const char kSampleForTestsClassPath[] = |
24 "org/chromium/example/jni_generator/SampleForTests"; | 24 "org/chromium/example/jni_generator/SampleForTests"; |
25 const char kInnerStructBClassPath[] = | 25 const char kInnerStructBClassPath[] = |
26 "org/chromium/example/jni_generator/SampleForTests$InnerStructB"; | 26 "org/chromium/example/jni_generator/SampleForTests$InnerStructB"; |
| 27 #if __clang__ |
| 28 #pragma clang diagnostic push |
| 29 #pragma clang diagnostic ignored "-Wunused-function" |
| 30 #endif |
27 // Leaking this jclass as we cannot use LazyInstance from some threads. | 31 // Leaking this jclass as we cannot use LazyInstance from some threads. |
28 jclass g_InnerStructA_clazz = NULL; | 32 jclass g_InnerStructA_clazz = NULL; |
| 33 jclass InnerStructA_clazz(JNIEnv*) { return g_InnerStructA_clazz; } |
29 // Leaking this jclass as we cannot use LazyInstance from some threads. | 34 // Leaking this jclass as we cannot use LazyInstance from some threads. |
30 jclass g_SampleForTests_clazz = NULL; | 35 jclass g_SampleForTests_clazz = NULL; |
| 36 jclass SampleForTests_clazz(JNIEnv*) { return g_SampleForTests_clazz; } |
31 // Leaking this jclass as we cannot use LazyInstance from some threads. | 37 // Leaking this jclass as we cannot use LazyInstance from some threads. |
32 jclass g_InnerStructB_clazz = NULL; | 38 jclass g_InnerStructB_clazz = NULL; |
| 39 jclass InnerStructB_clazz(JNIEnv*) { return g_InnerStructB_clazz; } |
| 40 #if __clang__ |
| 41 #pragma clang diagnostic pop |
| 42 #endif |
33 | 43 |
34 } // namespace | 44 } // namespace |
35 | 45 |
36 namespace base { | 46 namespace base { |
37 namespace android { | 47 namespace android { |
38 | 48 |
39 static jlong Init(JNIEnv* env, jobject jcaller, | 49 static jlong Init(JNIEnv* env, jobject jcaller, |
40 jstring param); | 50 jstring param); |
41 | 51 |
42 static jdouble GetDoubleFunction(JNIEnv* env, jobject jcaller); | 52 static jdouble GetDoubleFunction(JNIEnv* env, jobject jcaller); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 CHECK_NATIVE_PTR(env, jcaller, native, "ReturnAString", NULL); | 102 CHECK_NATIVE_PTR(env, jcaller, native, "ReturnAString", NULL); |
93 return native->ReturnAString(env, jcaller).Release(); | 103 return native->ReturnAString(env, jcaller).Release(); |
94 } | 104 } |
95 | 105 |
96 static base::subtle::AtomicWord g_SampleForTests_javaMethod = 0; | 106 static base::subtle::AtomicWord g_SampleForTests_javaMethod = 0; |
97 static jint Java_SampleForTests_javaMethod(JNIEnv* env, jobject obj, | 107 static jint Java_SampleForTests_javaMethod(JNIEnv* env, jobject obj, |
98 JniIntWrapper foo, | 108 JniIntWrapper foo, |
99 JniIntWrapper bar) { | 109 JniIntWrapper bar) { |
100 /* Must call RegisterNativesImpl() */ | 110 /* Must call RegisterNativesImpl() */ |
101 CHECK_CLAZZ(env, obj, | 111 CHECK_CLAZZ(env, obj, |
102 g_SampleForTests_clazz, 0); | 112 SampleForTests_clazz(env), 0); |
103 jmethodID method_id = | 113 jmethodID method_id = |
104 base::android::MethodID::LazyGet< | 114 base::android::MethodID::LazyGet< |
105 base::android::MethodID::TYPE_INSTANCE>( | 115 base::android::MethodID::TYPE_INSTANCE>( |
106 env, g_SampleForTests_clazz, | 116 env, SampleForTests_clazz(env), |
107 "javaMethod", | 117 "javaMethod", |
108 | 118 |
109 "(" | 119 "(" |
110 "I" | 120 "I" |
111 "I" | 121 "I" |
112 ")" | 122 ")" |
113 "I", | 123 "I", |
114 &g_SampleForTests_javaMethod); | 124 &g_SampleForTests_javaMethod); |
115 | 125 |
116 jint ret = | 126 jint ret = |
117 env->CallIntMethod(obj, | 127 env->CallIntMethod(obj, |
118 method_id, as_jint(foo), as_jint(bar)); | 128 method_id, as_jint(foo), as_jint(bar)); |
119 jni_generator::CheckException(env); | 129 jni_generator::CheckException(env); |
120 return ret; | 130 return ret; |
121 } | 131 } |
122 | 132 |
123 static base::subtle::AtomicWord g_SampleForTests_staticJavaMethod = 0; | 133 static base::subtle::AtomicWord g_SampleForTests_staticJavaMethod = 0; |
124 static jboolean Java_SampleForTests_staticJavaMethod(JNIEnv* env) { | 134 static jboolean Java_SampleForTests_staticJavaMethod(JNIEnv* env) { |
125 /* Must call RegisterNativesImpl() */ | 135 /* Must call RegisterNativesImpl() */ |
126 CHECK_CLAZZ(env, g_SampleForTests_clazz, | 136 CHECK_CLAZZ(env, SampleForTests_clazz(env), |
127 g_SampleForTests_clazz, false); | 137 SampleForTests_clazz(env), false); |
128 jmethodID method_id = | 138 jmethodID method_id = |
129 base::android::MethodID::LazyGet< | 139 base::android::MethodID::LazyGet< |
130 base::android::MethodID::TYPE_STATIC>( | 140 base::android::MethodID::TYPE_STATIC>( |
131 env, g_SampleForTests_clazz, | 141 env, SampleForTests_clazz(env), |
132 "staticJavaMethod", | 142 "staticJavaMethod", |
133 | 143 |
134 "(" | 144 "(" |
135 ")" | 145 ")" |
136 "Z", | 146 "Z", |
137 &g_SampleForTests_staticJavaMethod); | 147 &g_SampleForTests_staticJavaMethod); |
138 | 148 |
139 jboolean ret = | 149 jboolean ret = |
140 env->CallStaticBooleanMethod(g_SampleForTests_clazz, | 150 env->CallStaticBooleanMethod(SampleForTests_clazz(env), |
141 method_id); | 151 method_id); |
142 jni_generator::CheckException(env); | 152 jni_generator::CheckException(env); |
143 return ret; | 153 return ret; |
144 } | 154 } |
145 | 155 |
146 static base::subtle::AtomicWord g_SampleForTests_packagePrivateJavaMethod = 0; | 156 static base::subtle::AtomicWord g_SampleForTests_packagePrivateJavaMethod = 0; |
147 static void Java_SampleForTests_packagePrivateJavaMethod(JNIEnv* env, jobject | 157 static void Java_SampleForTests_packagePrivateJavaMethod(JNIEnv* env, jobject |
148 obj) { | 158 obj) { |
149 /* Must call RegisterNativesImpl() */ | 159 /* Must call RegisterNativesImpl() */ |
150 CHECK_CLAZZ(env, obj, | 160 CHECK_CLAZZ(env, obj, |
151 g_SampleForTests_clazz); | 161 SampleForTests_clazz(env)); |
152 jmethodID method_id = | 162 jmethodID method_id = |
153 base::android::MethodID::LazyGet< | 163 base::android::MethodID::LazyGet< |
154 base::android::MethodID::TYPE_INSTANCE>( | 164 base::android::MethodID::TYPE_INSTANCE>( |
155 env, g_SampleForTests_clazz, | 165 env, SampleForTests_clazz(env), |
156 "packagePrivateJavaMethod", | 166 "packagePrivateJavaMethod", |
157 | 167 |
158 "(" | 168 "(" |
159 ")" | 169 ")" |
160 "V", | 170 "V", |
161 &g_SampleForTests_packagePrivateJavaMethod); | 171 &g_SampleForTests_packagePrivateJavaMethod); |
162 | 172 |
163 env->CallVoidMethod(obj, | 173 env->CallVoidMethod(obj, |
164 method_id); | 174 method_id); |
165 jni_generator::CheckException(env); | 175 jni_generator::CheckException(env); |
166 | 176 |
167 } | 177 } |
168 | 178 |
169 static base::subtle::AtomicWord g_SampleForTests_methodThatThrowsException = 0; | 179 static base::subtle::AtomicWord g_SampleForTests_methodThatThrowsException = 0; |
170 static void Java_SampleForTests_methodThatThrowsException(JNIEnv* env, jobject | 180 static void Java_SampleForTests_methodThatThrowsException(JNIEnv* env, jobject |
171 obj) { | 181 obj) { |
172 /* Must call RegisterNativesImpl() */ | 182 /* Must call RegisterNativesImpl() */ |
173 CHECK_CLAZZ(env, obj, | 183 CHECK_CLAZZ(env, obj, |
174 g_SampleForTests_clazz); | 184 SampleForTests_clazz(env)); |
175 jmethodID method_id = | 185 jmethodID method_id = |
176 base::android::MethodID::LazyGet< | 186 base::android::MethodID::LazyGet< |
177 base::android::MethodID::TYPE_INSTANCE>( | 187 base::android::MethodID::TYPE_INSTANCE>( |
178 env, g_SampleForTests_clazz, | 188 env, SampleForTests_clazz(env), |
179 "methodThatThrowsException", | 189 "methodThatThrowsException", |
180 | 190 |
181 "(" | 191 "(" |
182 ")" | 192 ")" |
183 "V", | 193 "V", |
184 &g_SampleForTests_methodThatThrowsException); | 194 &g_SampleForTests_methodThatThrowsException); |
185 | 195 |
186 env->CallVoidMethod(obj, | 196 env->CallVoidMethod(obj, |
187 method_id); | 197 method_id); |
188 | 198 |
189 } | 199 } |
190 | 200 |
191 static base::subtle::AtomicWord g_InnerStructA_create = 0; | 201 static base::subtle::AtomicWord g_InnerStructA_create = 0; |
192 static base::android::ScopedJavaLocalRef<jobject> | 202 static base::android::ScopedJavaLocalRef<jobject> |
193 Java_InnerStructA_create(JNIEnv* env, jlong l, | 203 Java_InnerStructA_create(JNIEnv* env, jlong l, |
194 JniIntWrapper i, | 204 JniIntWrapper i, |
195 jstring s) { | 205 jstring s) { |
196 /* Must call RegisterNativesImpl() */ | 206 /* Must call RegisterNativesImpl() */ |
197 CHECK_CLAZZ(env, g_InnerStructA_clazz, | 207 CHECK_CLAZZ(env, InnerStructA_clazz(env), |
198 g_InnerStructA_clazz, NULL); | 208 InnerStructA_clazz(env), NULL); |
199 jmethodID method_id = | 209 jmethodID method_id = |
200 base::android::MethodID::LazyGet< | 210 base::android::MethodID::LazyGet< |
201 base::android::MethodID::TYPE_STATIC>( | 211 base::android::MethodID::TYPE_STATIC>( |
202 env, g_InnerStructA_clazz, | 212 env, InnerStructA_clazz(env), |
203 "create", | 213 "create", |
204 | 214 |
205 "(" | 215 "(" |
206 "J" | 216 "J" |
207 "I" | 217 "I" |
208 "Ljava/lang/String;" | 218 "Ljava/lang/String;" |
209 ")" | 219 ")" |
210 "Lorg/chromium/example/jni_generator/SampleForTests$InnerStructA;", | 220 "Lorg/chromium/example/jni_generator/SampleForTests$InnerStructA;", |
211 &g_InnerStructA_create); | 221 &g_InnerStructA_create); |
212 | 222 |
213 jobject ret = | 223 jobject ret = |
214 env->CallStaticObjectMethod(g_InnerStructA_clazz, | 224 env->CallStaticObjectMethod(InnerStructA_clazz(env), |
215 method_id, l, as_jint(i), s); | 225 method_id, l, as_jint(i), s); |
216 jni_generator::CheckException(env); | 226 jni_generator::CheckException(env); |
217 return base::android::ScopedJavaLocalRef<jobject>(env, ret); | 227 return base::android::ScopedJavaLocalRef<jobject>(env, ret); |
218 } | 228 } |
219 | 229 |
220 static base::subtle::AtomicWord g_SampleForTests_addStructA = 0; | 230 static base::subtle::AtomicWord g_SampleForTests_addStructA = 0; |
221 static void Java_SampleForTests_addStructA(JNIEnv* env, jobject obj, jobject a) | 231 static void Java_SampleForTests_addStructA(JNIEnv* env, jobject obj, jobject a) |
222 { | 232 { |
223 /* Must call RegisterNativesImpl() */ | 233 /* Must call RegisterNativesImpl() */ |
224 CHECK_CLAZZ(env, obj, | 234 CHECK_CLAZZ(env, obj, |
225 g_SampleForTests_clazz); | 235 SampleForTests_clazz(env)); |
226 jmethodID method_id = | 236 jmethodID method_id = |
227 base::android::MethodID::LazyGet< | 237 base::android::MethodID::LazyGet< |
228 base::android::MethodID::TYPE_INSTANCE>( | 238 base::android::MethodID::TYPE_INSTANCE>( |
229 env, g_SampleForTests_clazz, | 239 env, SampleForTests_clazz(env), |
230 "addStructA", | 240 "addStructA", |
231 | 241 |
232 "(" | 242 "(" |
233 "Lorg/chromium/example/jni_generator/SampleForTests$InnerStructA;" | 243 "Lorg/chromium/example/jni_generator/SampleForTests$InnerStructA;" |
234 ")" | 244 ")" |
235 "V", | 245 "V", |
236 &g_SampleForTests_addStructA); | 246 &g_SampleForTests_addStructA); |
237 | 247 |
238 env->CallVoidMethod(obj, | 248 env->CallVoidMethod(obj, |
239 method_id, a); | 249 method_id, a); |
240 jni_generator::CheckException(env); | 250 jni_generator::CheckException(env); |
241 | 251 |
242 } | 252 } |
243 | 253 |
244 static base::subtle::AtomicWord g_SampleForTests_iterateAndDoSomething = 0; | 254 static base::subtle::AtomicWord g_SampleForTests_iterateAndDoSomething = 0; |
245 static void Java_SampleForTests_iterateAndDoSomething(JNIEnv* env, jobject obj) | 255 static void Java_SampleForTests_iterateAndDoSomething(JNIEnv* env, jobject obj) |
246 { | 256 { |
247 /* Must call RegisterNativesImpl() */ | 257 /* Must call RegisterNativesImpl() */ |
248 CHECK_CLAZZ(env, obj, | 258 CHECK_CLAZZ(env, obj, |
249 g_SampleForTests_clazz); | 259 SampleForTests_clazz(env)); |
250 jmethodID method_id = | 260 jmethodID method_id = |
251 base::android::MethodID::LazyGet< | 261 base::android::MethodID::LazyGet< |
252 base::android::MethodID::TYPE_INSTANCE>( | 262 base::android::MethodID::TYPE_INSTANCE>( |
253 env, g_SampleForTests_clazz, | 263 env, SampleForTests_clazz(env), |
254 "iterateAndDoSomething", | 264 "iterateAndDoSomething", |
255 | 265 |
256 "(" | 266 "(" |
257 ")" | 267 ")" |
258 "V", | 268 "V", |
259 &g_SampleForTests_iterateAndDoSomething); | 269 &g_SampleForTests_iterateAndDoSomething); |
260 | 270 |
261 env->CallVoidMethod(obj, | 271 env->CallVoidMethod(obj, |
262 method_id); | 272 method_id); |
263 jni_generator::CheckException(env); | 273 jni_generator::CheckException(env); |
264 | 274 |
265 } | 275 } |
266 | 276 |
267 static base::subtle::AtomicWord g_InnerStructB_getKey = 0; | 277 static base::subtle::AtomicWord g_InnerStructB_getKey = 0; |
268 static jlong Java_InnerStructB_getKey(JNIEnv* env, jobject obj) { | 278 static jlong Java_InnerStructB_getKey(JNIEnv* env, jobject obj) { |
269 /* Must call RegisterNativesImpl() */ | 279 /* Must call RegisterNativesImpl() */ |
270 CHECK_CLAZZ(env, obj, | 280 CHECK_CLAZZ(env, obj, |
271 g_InnerStructB_clazz, 0); | 281 InnerStructB_clazz(env), 0); |
272 jmethodID method_id = | 282 jmethodID method_id = |
273 base::android::MethodID::LazyGet< | 283 base::android::MethodID::LazyGet< |
274 base::android::MethodID::TYPE_INSTANCE>( | 284 base::android::MethodID::TYPE_INSTANCE>( |
275 env, g_InnerStructB_clazz, | 285 env, InnerStructB_clazz(env), |
276 "getKey", | 286 "getKey", |
277 | 287 |
278 "(" | 288 "(" |
279 ")" | 289 ")" |
280 "J", | 290 "J", |
281 &g_InnerStructB_getKey); | 291 &g_InnerStructB_getKey); |
282 | 292 |
283 jlong ret = | 293 jlong ret = |
284 env->CallLongMethod(obj, | 294 env->CallLongMethod(obj, |
285 method_id); | 295 method_id); |
286 jni_generator::CheckException(env); | 296 jni_generator::CheckException(env); |
287 return ret; | 297 return ret; |
288 } | 298 } |
289 | 299 |
290 static base::subtle::AtomicWord g_InnerStructB_getValue = 0; | 300 static base::subtle::AtomicWord g_InnerStructB_getValue = 0; |
291 static base::android::ScopedJavaLocalRef<jstring> | 301 static base::android::ScopedJavaLocalRef<jstring> |
292 Java_InnerStructB_getValue(JNIEnv* env, jobject obj) { | 302 Java_InnerStructB_getValue(JNIEnv* env, jobject obj) { |
293 /* Must call RegisterNativesImpl() */ | 303 /* Must call RegisterNativesImpl() */ |
294 CHECK_CLAZZ(env, obj, | 304 CHECK_CLAZZ(env, obj, |
295 g_InnerStructB_clazz, NULL); | 305 InnerStructB_clazz(env), NULL); |
296 jmethodID method_id = | 306 jmethodID method_id = |
297 base::android::MethodID::LazyGet< | 307 base::android::MethodID::LazyGet< |
298 base::android::MethodID::TYPE_INSTANCE>( | 308 base::android::MethodID::TYPE_INSTANCE>( |
299 env, g_InnerStructB_clazz, | 309 env, InnerStructB_clazz(env), |
300 "getValue", | 310 "getValue", |
301 | 311 |
302 "(" | 312 "(" |
303 ")" | 313 ")" |
304 "Ljava/lang/String;", | 314 "Ljava/lang/String;", |
305 &g_InnerStructB_getValue); | 315 &g_InnerStructB_getValue); |
306 | 316 |
307 jstring ret = | 317 jstring ret = |
308 static_cast<jstring>(env->CallObjectMethod(obj, | 318 static_cast<jstring>(env->CallObjectMethod(obj, |
309 method_id)); | 319 method_id)); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 static bool RegisterNativesImpl(JNIEnv* env) { | 382 static bool RegisterNativesImpl(JNIEnv* env) { |
373 g_InnerStructA_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( | 383 g_InnerStructA_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( |
374 base::android::GetClass(env, kInnerStructAClassPath).obj())); | 384 base::android::GetClass(env, kInnerStructAClassPath).obj())); |
375 g_SampleForTests_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( | 385 g_SampleForTests_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( |
376 base::android::GetClass(env, kSampleForTestsClassPath).obj())); | 386 base::android::GetClass(env, kSampleForTestsClassPath).obj())); |
377 g_InnerStructB_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( | 387 g_InnerStructB_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( |
378 base::android::GetClass(env, kInnerStructBClassPath).obj())); | 388 base::android::GetClass(env, kInnerStructBClassPath).obj())); |
379 | 389 |
380 const int kMethodsSampleForTestsSize = arraysize(kMethodsSampleForTests); | 390 const int kMethodsSampleForTestsSize = arraysize(kMethodsSampleForTests); |
381 | 391 |
382 if (env->RegisterNatives(g_SampleForTests_clazz, | 392 if (env->RegisterNatives(SampleForTests_clazz(env), |
383 kMethodsSampleForTests, | 393 kMethodsSampleForTests, |
384 kMethodsSampleForTestsSize) < 0) { | 394 kMethodsSampleForTestsSize) < 0) { |
385 jni_generator::HandleRegistrationError( | 395 jni_generator::HandleRegistrationError( |
386 env, g_SampleForTests_clazz, __FILE__); | 396 env, SampleForTests_clazz(env), __FILE__); |
387 return false; | 397 return false; |
388 } | 398 } |
389 | 399 |
390 return true; | 400 return true; |
391 } | 401 } |
392 | 402 |
393 } // namespace android | 403 } // namespace android |
394 } // namespace base | 404 } // namespace base |
395 | 405 |
396 #endif // org_chromium_example_jni_generator_SampleForTests_JNI | 406 #endif // org_chromium_example_jni_generator_SampleForTests_JNI |
OLD | NEW |