Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_tests.py | 6 // base/android/jni_generator/jni_generator_tests.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 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 jint nativeCPPClass) { | 59 jint nativeCPPClass) { |
| 60 DCHECK(nativeCPPClass) << "Method"; | 60 DCHECK(nativeCPPClass) << "Method"; |
| 61 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); | 61 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); |
| 62 return native->Method(env, obj); | 62 return native->Method(env, obj); |
| 63 } | 63 } |
| 64 | 64 |
| 65 static jdouble MethodOtherP0(JNIEnv* env, jobject obj, | 65 static jdouble MethodOtherP0(JNIEnv* env, jobject obj, |
| 66 jint nativePtr) { | 66 jint nativePtr) { |
| 67 DCHECK(nativePtr) << "MethodOtherP0"; | 67 DCHECK(nativePtr) << "MethodOtherP0"; |
| 68 CPPClass::InnerClass* native = | 68 CPPClass::InnerClass* native = |
| 69 reinterpret_cast<CPPClass::InnerClass*>(nativePtr); | 69 reinterpret_cast<CPPClass::InnerClass*>(nativePtr); |
| 70 return native->MethodOtherP0(env, obj); | 70 return native->MethodOtherP0(env, obj); |
| 71 } | 71 } |
| 72 | 72 |
| 73 static jstring InnerMethod(JNIEnv* env, jobject obj, | 73 static jstring InnerMethod(JNIEnv* env, jobject obj, |
| 74 jint nativeCPPClass) { | 74 jint nativeCPPClass) { |
| 75 DCHECK(nativeCPPClass) << "InnerMethod"; | 75 DCHECK(nativeCPPClass) << "InnerMethod"; |
| 76 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); | 76 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); |
| 77 return native->InnerMethod(env, obj).Release(); | 77 return native->InnerMethod(env, obj).Release(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 static jmethodID g_SampleForTests_javaMethod = 0; | 80 static base::subtle::AtomicWord g_SampleForTests_javaMethod = 0; |
| 81 static jint Java_SampleForTests_javaMethod(JNIEnv* env, jobject obj, jint foo, | 81 static jint Java_SampleForTests_javaMethod(JNIEnv* env, jobject obj, jint foo, |
| 82 jint bar) { | 82 jint bar) { |
| 83 /* Must call RegisterNativesImpl() */ | 83 /* Must call RegisterNativesImpl() */ |
| 84 DCHECK(g_SampleForTests_clazz); | 84 DCHECK(g_SampleForTests_clazz); |
| 85 DCHECK(g_SampleForTests_javaMethod); | 85 jmethodID method_id = |
| 86 jint ret = | |
| 87 env->CallIntMethod(obj, | |
| 88 g_SampleForTests_javaMethod, foo, bar); | |
| 89 base::android::CheckException(env); | |
| 90 return ret; | |
| 91 } | |
| 92 | 86 |
|
joth
2012/10/04 17:59:59
nit: still have 2 spurious \n here
bulach
2012/10/04 18:58:17
Done.
| |
| 93 static jmethodID g_SampleForTests_staticJavaMethod = 0; | 87 base::android::MethodID::LazyGet< |
| 94 static jboolean Java_SampleForTests_staticJavaMethod(JNIEnv* env) { | 88 base::android::MethodID::METHODTYPE_NORMAL, |
| 95 /* Must call RegisterNativesImpl() */ | 89 base::android::MethodID::EXCEPTIONCHECK_YES>( |
| 96 DCHECK(g_SampleForTests_clazz); | 90 env, g_SampleForTests_clazz, |
| 97 DCHECK(g_SampleForTests_staticJavaMethod); | 91 "javaMethod", |
| 98 jboolean ret = | |
| 99 env->CallStaticBooleanMethod(g_SampleForTests_clazz, | |
| 100 g_SampleForTests_staticJavaMethod); | |
| 101 base::android::CheckException(env); | |
| 102 return ret; | |
| 103 } | |
| 104 | |
| 105 static jmethodID g_SampleForTests_packagePrivateJavaMethod = 0; | |
| 106 static void Java_SampleForTests_packagePrivateJavaMethod(JNIEnv* env, jobject | |
| 107 obj) { | |
| 108 /* Must call RegisterNativesImpl() */ | |
| 109 DCHECK(g_SampleForTests_clazz); | |
| 110 DCHECK(g_SampleForTests_packagePrivateJavaMethod); | |
| 111 | |
| 112 env->CallVoidMethod(obj, | |
| 113 g_SampleForTests_packagePrivateJavaMethod); | |
| 114 base::android::CheckException(env); | |
| 115 | |
| 116 } | |
| 117 | |
| 118 static jmethodID g_SampleForTests_methodThatThrowsException = 0; | |
| 119 static void Java_SampleForTests_methodThatThrowsException(JNIEnv* env, jobject | |
| 120 obj) { | |
| 121 /* Must call RegisterNativesImpl() */ | |
| 122 DCHECK(g_SampleForTests_clazz); | |
| 123 DCHECK(g_SampleForTests_methodThatThrowsException); | |
| 124 | |
| 125 env->CallVoidMethod(obj, | |
| 126 g_SampleForTests_methodThatThrowsException); | |
| 127 | |
| 128 } | |
| 129 | |
| 130 static jmethodID g_InnerClass_JavaInnerMethod = 0; | |
| 131 static jfloat Java_InnerClass_JavaInnerMethod(JNIEnv* env, jobject obj) { | |
| 132 /* Must call RegisterNativesImpl() */ | |
| 133 DCHECK(g_InnerClass_clazz); | |
| 134 DCHECK(g_InnerClass_JavaInnerMethod); | |
| 135 jfloat ret = | |
| 136 env->CallFloatMethod(obj, | |
| 137 g_InnerClass_JavaInnerMethod); | |
| 138 base::android::CheckException(env); | |
| 139 return ret; | |
| 140 } | |
| 141 | |
| 142 static jmethodID g_InnerClass_javaInnerFunction = 0; | |
| 143 static void Java_InnerClass_javaInnerFunction(JNIEnv* env) { | |
| 144 /* Must call RegisterNativesImpl() */ | |
| 145 DCHECK(g_InnerClass_clazz); | |
| 146 DCHECK(g_InnerClass_javaInnerFunction); | |
| 147 | |
| 148 env->CallStaticVoidMethod(g_InnerClass_clazz, | |
| 149 g_InnerClass_javaInnerFunction); | |
| 150 base::android::CheckException(env); | |
| 151 | |
| 152 } | |
| 153 | |
| 154 // Step 3: GetMethodIDs and RegisterNatives. | |
| 155 static void GetMethodIDsImpl(JNIEnv* env) { | |
| 156 g_InnerClass_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( | |
| 157 base::android::GetUnscopedClass(env, kInnerClassClassPath))); | |
| 158 g_SampleForTests_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( | |
| 159 base::android::GetUnscopedClass(env, kSampleForTestsClassPath))); | |
| 160 g_SampleForTests_javaMethod = | |
| 161 base::android::GetMethodID( | |
| 162 env, g_SampleForTests_clazz, | |
| 163 "javaMethod", | |
| 164 | 92 |
| 165 "(" | 93 "(" |
| 166 "I" | 94 "I" |
| 167 "I" | 95 "I" |
| 168 ")" | 96 ")" |
| 169 "I"); | 97 "I", |
| 98 &g_SampleForTests_javaMethod); | |
| 170 | 99 |
| 171 g_SampleForTests_staticJavaMethod = | 100 jint ret = |
| 172 base::android::GetStaticMethodID( | 101 env->CallIntMethod(obj, |
| 173 env, g_SampleForTests_clazz, | 102 method_id, foo, bar); |
| 174 "staticJavaMethod", | 103 base::android::CheckException(env); |
| 104 return ret; | |
| 105 } | |
| 106 | |
| 107 static base::subtle::AtomicWord g_SampleForTests_staticJavaMethod = 0; | |
| 108 static jboolean Java_SampleForTests_staticJavaMethod(JNIEnv* env) { | |
| 109 /* Must call RegisterNativesImpl() */ | |
| 110 DCHECK(g_SampleForTests_clazz); | |
| 111 jmethodID method_id = | |
| 112 | |
| 113 base::android::MethodID::LazyGet< | |
| 114 base::android::MethodID::METHODTYPE_STATIC, | |
| 115 base::android::MethodID::EXCEPTIONCHECK_YES>( | |
| 116 env, g_SampleForTests_clazz, | |
| 117 "staticJavaMethod", | |
| 175 | 118 |
| 176 "(" | 119 "(" |
| 177 ")" | 120 ")" |
| 178 "Z"); | 121 "Z", |
| 122 &g_SampleForTests_staticJavaMethod); | |
| 179 | 123 |
| 180 g_SampleForTests_packagePrivateJavaMethod = | 124 jboolean ret = |
| 181 base::android::GetMethodID( | 125 env->CallStaticBooleanMethod(g_SampleForTests_clazz, |
| 182 env, g_SampleForTests_clazz, | 126 method_id); |
| 183 "packagePrivateJavaMethod", | 127 base::android::CheckException(env); |
| 128 return ret; | |
| 129 } | |
| 130 | |
| 131 static base::subtle::AtomicWord g_SampleForTests_packagePrivateJavaMethod = 0; | |
| 132 static void Java_SampleForTests_packagePrivateJavaMethod(JNIEnv* env, jobject | |
| 133 obj) { | |
| 134 /* Must call RegisterNativesImpl() */ | |
| 135 DCHECK(g_SampleForTests_clazz); | |
| 136 jmethodID method_id = | |
| 137 | |
| 138 base::android::MethodID::LazyGet< | |
| 139 base::android::MethodID::METHODTYPE_NORMAL, | |
| 140 base::android::MethodID::EXCEPTIONCHECK_YES>( | |
| 141 env, g_SampleForTests_clazz, | |
| 142 "packagePrivateJavaMethod", | |
| 184 | 143 |
| 185 "(" | 144 "(" |
| 186 ")" | 145 ")" |
| 187 "V"); | 146 "V", |
| 147 &g_SampleForTests_packagePrivateJavaMethod); | |
| 188 | 148 |
| 189 g_SampleForTests_methodThatThrowsException = | 149 env->CallVoidMethod(obj, |
| 190 base::android::GetMethodID( | 150 method_id); |
| 191 env, g_SampleForTests_clazz, | 151 base::android::CheckException(env); |
| 192 "methodThatThrowsException", | 152 |
| 153 } | |
| 154 | |
| 155 static base::subtle::AtomicWord g_SampleForTests_methodThatThrowsException = 0; | |
| 156 static void Java_SampleForTests_methodThatThrowsException(JNIEnv* env, jobject | |
| 157 obj) { | |
| 158 /* Must call RegisterNativesImpl() */ | |
| 159 DCHECK(g_SampleForTests_clazz); | |
| 160 jmethodID method_id = | |
| 161 | |
| 162 base::android::MethodID::LazyGet< | |
| 163 base::android::MethodID::METHODTYPE_NORMAL, | |
| 164 base::android::MethodID::EXCEPTIONCHECK_YES>( | |
| 165 env, g_SampleForTests_clazz, | |
| 166 "methodThatThrowsException", | |
| 193 | 167 |
| 194 "(" | 168 "(" |
| 195 ")" | 169 ")" |
| 196 "V"); | 170 "V", |
| 171 &g_SampleForTests_methodThatThrowsException); | |
| 197 | 172 |
| 198 g_InnerClass_JavaInnerMethod = | 173 env->CallVoidMethod(obj, |
| 199 base::android::GetMethodID( | 174 method_id); |
| 200 env, g_InnerClass_clazz, | 175 |
| 201 "JavaInnerMethod", | 176 } |
| 177 | |
| 178 static base::subtle::AtomicWord g_InnerClass_JavaInnerMethod = 0; | |
| 179 static jfloat Java_InnerClass_JavaInnerMethod(JNIEnv* env, jobject obj) { | |
| 180 /* Must call RegisterNativesImpl() */ | |
| 181 DCHECK(g_InnerClass_clazz); | |
| 182 jmethodID method_id = | |
| 183 | |
| 184 base::android::MethodID::LazyGet< | |
| 185 base::android::MethodID::METHODTYPE_NORMAL, | |
| 186 base::android::MethodID::EXCEPTIONCHECK_YES>( | |
| 187 env, g_InnerClass_clazz, | |
| 188 "JavaInnerMethod", | |
| 202 | 189 |
| 203 "(" | 190 "(" |
| 204 ")" | 191 ")" |
| 205 "F"); | 192 "F", |
| 193 &g_InnerClass_JavaInnerMethod); | |
| 206 | 194 |
| 207 g_InnerClass_javaInnerFunction = | 195 jfloat ret = |
| 208 base::android::GetStaticMethodID( | 196 env->CallFloatMethod(obj, |
| 209 env, g_InnerClass_clazz, | 197 method_id); |
| 210 "javaInnerFunction", | 198 base::android::CheckException(env); |
| 199 return ret; | |
| 200 } | |
| 201 | |
| 202 static base::subtle::AtomicWord g_InnerClass_javaInnerFunction = 0; | |
| 203 static void Java_InnerClass_javaInnerFunction(JNIEnv* env) { | |
| 204 /* Must call RegisterNativesImpl() */ | |
| 205 DCHECK(g_InnerClass_clazz); | |
| 206 jmethodID method_id = | |
| 207 | |
| 208 base::android::MethodID::LazyGet< | |
| 209 base::android::MethodID::METHODTYPE_STATIC, | |
| 210 base::android::MethodID::EXCEPTIONCHECK_YES>( | |
| 211 env, g_InnerClass_clazz, | |
| 212 "javaInnerFunction", | |
| 211 | 213 |
| 212 "(" | 214 "(" |
| 213 ")" | 215 ")" |
| 214 "V"); | 216 "V", |
| 217 &g_InnerClass_javaInnerFunction); | |
| 218 | |
| 219 env->CallStaticVoidMethod(g_InnerClass_clazz, | |
| 220 method_id); | |
| 221 base::android::CheckException(env); | |
| 215 | 222 |
| 216 } | 223 } |
| 217 | 224 |
| 225 // Step 3: RegisterNatives. | |
| 226 | |
| 218 static bool RegisterNativesImpl(JNIEnv* env) { | 227 static bool RegisterNativesImpl(JNIEnv* env) { |
| 219 GetMethodIDsImpl(env); | |
| 220 | 228 |
| 229 g_InnerClass_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( | |
| 230 base::android::GetUnscopedClass(env, kInnerClassClassPath))); | |
| 231 g_SampleForTests_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( | |
| 232 base::android::GetUnscopedClass(env, kSampleForTestsClassPath))); | |
| 221 static const JNINativeMethod kMethodsInnerClass[] = { | 233 static const JNINativeMethod kMethodsInnerClass[] = { |
| 222 { "nativeInnerFunction", | 234 { "nativeInnerFunction", |
| 223 "(" | 235 "(" |
| 224 ")" | 236 ")" |
| 225 "I", reinterpret_cast<void*>(InnerFunction) }, | 237 "I", reinterpret_cast<void*>(InnerFunction) }, |
| 226 { "nativeInnerMethod", | 238 { "nativeInnerMethod", |
| 227 "(" | 239 "(" |
| 228 "I" | 240 "I" |
| 229 ")" | 241 ")" |
| 230 "Ljava/lang/String;", reinterpret_cast<void*>(InnerMethod) }, | 242 "Ljava/lang/String;", reinterpret_cast<void*>(InnerMethod) }, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 284 LOG(ERROR) << "RegisterNatives failed in " << __FILE__; | 296 LOG(ERROR) << "RegisterNatives failed in " << __FILE__; |
| 285 return false; | 297 return false; |
| 286 } | 298 } |
| 287 | 299 |
| 288 return true; | 300 return true; |
| 289 } | 301 } |
| 290 } // namespace android | 302 } // namespace android |
| 291 } // namespace base | 303 } // namespace base |
| 292 | 304 |
| 293 #endif // org_chromium_example_jni_generator_SampleForTests_JNI | 305 #endif // org_chromium_example_jni_generator_SampleForTests_JNI |
| OLD | NEW |