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