| 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 #if __clang__ |
| 24 #pragma clang diagnostic push |
| 25 #pragma clang diagnostic ignored "-Wunused-function" |
| 26 #endif |
| 23 // Leaking this jclass as we cannot use LazyInstance from some threads. | 27 // Leaking this jclass as we cannot use LazyInstance from some threads. |
| 24 jclass g_SampleForTests_clazz = NULL; | 28 base::subtle::AtomicWord g_SampleForTests_clazz = 0; |
| 29 jclass SampleForTests_clazz(JNIEnv* env) { |
| 30 return base::android::LazyGetClass(env, kSampleForTestsClassPath, |
| 31 &g_SampleForTests_clazz); |
| 32 } |
| 33 #if __clang__ |
| 34 #pragma clang diagnostic pop |
| 35 #endif |
| 25 | 36 |
| 26 } // namespace | 37 } // namespace |
| 27 | 38 |
| 28 extern "C" { | 39 extern "C" { |
| 29 | 40 |
| 30 static jint Init(JNIEnv* env, jobject jcaller); | 41 static jint Init(JNIEnv* env, jobject jcaller); |
| 31 | 42 |
| 32 __attribute__((visibility("default"))) | 43 __attribute__((visibility("default"))) |
| 33 jint | 44 jint |
| 34 Java_org_chromium_example_jni_1generator_SampleForTests_00024MyInnerClass_na
tiveInit(JNIEnv* | 45 Java_org_chromium_example_jni_1generator_SampleForTests_00024MyInnerClass_na
tiveInit(JNIEnv* |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 Test* native = reinterpret_cast<Test*>(nativeTest); | 83 Test* native = reinterpret_cast<Test*>(nativeTest); |
| 73 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0); | 84 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0); |
| 74 return native->Method(env, jcaller, arg1); | 85 return native->Method(env, jcaller, arg1); |
| 75 } | 86 } |
| 76 | 87 |
| 77 static base::subtle::AtomicWord g_SampleForTests_testMethodWithParam = 0; | 88 static base::subtle::AtomicWord g_SampleForTests_testMethodWithParam = 0; |
| 78 static void Java_SampleForTests_testMethodWithParam(JNIEnv* env, jobject obj, | 89 static void Java_SampleForTests_testMethodWithParam(JNIEnv* env, jobject obj, |
| 79 JniIntWrapper iParam) { | 90 JniIntWrapper iParam) { |
| 80 /* Must call RegisterNativesImpl() */ | 91 /* Must call RegisterNativesImpl() */ |
| 81 CHECK_CLAZZ(env, obj, | 92 CHECK_CLAZZ(env, obj, |
| 82 g_SampleForTests_clazz); | 93 SampleForTests_clazz(env)); |
| 83 jmethodID method_id = | 94 jmethodID method_id = |
| 84 base::android::MethodID::LazyGet< | 95 base::android::MethodID::LazyGet< |
| 85 base::android::MethodID::TYPE_INSTANCE>( | 96 base::android::MethodID::TYPE_INSTANCE>( |
| 86 env, g_SampleForTests_clazz, | 97 env, SampleForTests_clazz(env), |
| 87 "testMethodWithParam", | 98 "testMethodWithParam", |
| 88 | 99 |
| 89 "(" | 100 "(" |
| 90 "I" | 101 "I" |
| 91 ")" | 102 ")" |
| 92 "V", | 103 "V", |
| 93 &g_SampleForTests_testMethodWithParam); | 104 &g_SampleForTests_testMethodWithParam); |
| 94 | 105 |
| 95 env->CallVoidMethod(obj, | 106 env->CallVoidMethod(obj, |
| 96 method_id, as_jint(iParam)); | 107 method_id, as_jint(iParam)); |
| 97 jni_generator::CheckException(env); | 108 jni_generator::CheckException(env); |
| 98 | 109 |
| 99 } | 110 } |
| 100 | 111 |
| 101 static base::subtle::AtomicWord g_SampleForTests_testMethodWithParamAndReturn = | 112 static base::subtle::AtomicWord g_SampleForTests_testMethodWithParamAndReturn = |
| 102 0; | 113 0; |
| 103 static base::android::ScopedJavaLocalRef<jstring> | 114 static base::android::ScopedJavaLocalRef<jstring> |
| 104 Java_SampleForTests_testMethodWithParamAndReturn(JNIEnv* env, jobject obj, | 115 Java_SampleForTests_testMethodWithParamAndReturn(JNIEnv* env, jobject obj, |
| 105 JniIntWrapper iParam) { | 116 JniIntWrapper iParam) { |
| 106 /* Must call RegisterNativesImpl() */ | 117 /* Must call RegisterNativesImpl() */ |
| 107 CHECK_CLAZZ(env, obj, | 118 CHECK_CLAZZ(env, obj, |
| 108 g_SampleForTests_clazz, NULL); | 119 SampleForTests_clazz(env), NULL); |
| 109 jmethodID method_id = | 120 jmethodID method_id = |
| 110 base::android::MethodID::LazyGet< | 121 base::android::MethodID::LazyGet< |
| 111 base::android::MethodID::TYPE_INSTANCE>( | 122 base::android::MethodID::TYPE_INSTANCE>( |
| 112 env, g_SampleForTests_clazz, | 123 env, SampleForTests_clazz(env), |
| 113 "testMethodWithParamAndReturn", | 124 "testMethodWithParamAndReturn", |
| 114 | 125 |
| 115 "(" | 126 "(" |
| 116 "I" | 127 "I" |
| 117 ")" | 128 ")" |
| 118 "Ljava/lang/String;", | 129 "Ljava/lang/String;", |
| 119 &g_SampleForTests_testMethodWithParamAndReturn); | 130 &g_SampleForTests_testMethodWithParamAndReturn); |
| 120 | 131 |
| 121 jstring ret = | 132 jstring ret = |
| 122 static_cast<jstring>(env->CallObjectMethod(obj, | 133 static_cast<jstring>(env->CallObjectMethod(obj, |
| 123 method_id, as_jint(iParam))); | 134 method_id, as_jint(iParam))); |
| 124 jni_generator::CheckException(env); | 135 jni_generator::CheckException(env); |
| 125 return base::android::ScopedJavaLocalRef<jstring>(env, ret); | 136 return base::android::ScopedJavaLocalRef<jstring>(env, ret); |
| 126 } | 137 } |
| 127 | 138 |
| 128 static base::subtle::AtomicWord g_SampleForTests_testStaticMethodWithParam = 0; | 139 static base::subtle::AtomicWord g_SampleForTests_testStaticMethodWithParam = 0; |
| 129 static jint Java_SampleForTests_testStaticMethodWithParam(JNIEnv* env, | 140 static jint Java_SampleForTests_testStaticMethodWithParam(JNIEnv* env, |
| 130 JniIntWrapper iParam) { | 141 JniIntWrapper iParam) { |
| 131 /* Must call RegisterNativesImpl() */ | 142 /* Must call RegisterNativesImpl() */ |
| 132 CHECK_CLAZZ(env, g_SampleForTests_clazz, | 143 CHECK_CLAZZ(env, SampleForTests_clazz(env), |
| 133 g_SampleForTests_clazz, 0); | 144 SampleForTests_clazz(env), 0); |
| 134 jmethodID method_id = | 145 jmethodID method_id = |
| 135 base::android::MethodID::LazyGet< | 146 base::android::MethodID::LazyGet< |
| 136 base::android::MethodID::TYPE_STATIC>( | 147 base::android::MethodID::TYPE_STATIC>( |
| 137 env, g_SampleForTests_clazz, | 148 env, SampleForTests_clazz(env), |
| 138 "testStaticMethodWithParam", | 149 "testStaticMethodWithParam", |
| 139 | 150 |
| 140 "(" | 151 "(" |
| 141 "I" | 152 "I" |
| 142 ")" | 153 ")" |
| 143 "I", | 154 "I", |
| 144 &g_SampleForTests_testStaticMethodWithParam); | 155 &g_SampleForTests_testStaticMethodWithParam); |
| 145 | 156 |
| 146 jint ret = | 157 jint ret = |
| 147 env->CallStaticIntMethod(g_SampleForTests_clazz, | 158 env->CallStaticIntMethod(SampleForTests_clazz(env), |
| 148 method_id, as_jint(iParam)); | 159 method_id, as_jint(iParam)); |
| 149 jni_generator::CheckException(env); | 160 jni_generator::CheckException(env); |
| 150 return ret; | 161 return ret; |
| 151 } | 162 } |
| 152 | 163 |
| 153 static base::subtle::AtomicWord g_SampleForTests_testMethodWithNoParam = 0; | 164 static base::subtle::AtomicWord g_SampleForTests_testMethodWithNoParam = 0; |
| 154 static jdouble Java_SampleForTests_testMethodWithNoParam(JNIEnv* env) { | 165 static jdouble Java_SampleForTests_testMethodWithNoParam(JNIEnv* env) { |
| 155 /* Must call RegisterNativesImpl() */ | 166 /* Must call RegisterNativesImpl() */ |
| 156 CHECK_CLAZZ(env, g_SampleForTests_clazz, | 167 CHECK_CLAZZ(env, SampleForTests_clazz(env), |
| 157 g_SampleForTests_clazz, 0); | 168 SampleForTests_clazz(env), 0); |
| 158 jmethodID method_id = | 169 jmethodID method_id = |
| 159 base::android::MethodID::LazyGet< | 170 base::android::MethodID::LazyGet< |
| 160 base::android::MethodID::TYPE_STATIC>( | 171 base::android::MethodID::TYPE_STATIC>( |
| 161 env, g_SampleForTests_clazz, | 172 env, SampleForTests_clazz(env), |
| 162 "testMethodWithNoParam", | 173 "testMethodWithNoParam", |
| 163 | 174 |
| 164 "(" | 175 "(" |
| 165 ")" | 176 ")" |
| 166 "D", | 177 "D", |
| 167 &g_SampleForTests_testMethodWithNoParam); | 178 &g_SampleForTests_testMethodWithNoParam); |
| 168 | 179 |
| 169 jdouble ret = | 180 jdouble ret = |
| 170 env->CallStaticDoubleMethod(g_SampleForTests_clazz, | 181 env->CallStaticDoubleMethod(SampleForTests_clazz(env), |
| 171 method_id); | 182 method_id); |
| 172 jni_generator::CheckException(env); | 183 jni_generator::CheckException(env); |
| 173 return ret; | 184 return ret; |
| 174 } | 185 } |
| 175 | 186 |
| 176 static base::subtle::AtomicWord g_SampleForTests_testStaticMethodWithNoParam = | 187 static base::subtle::AtomicWord g_SampleForTests_testStaticMethodWithNoParam = |
| 177 0; | 188 0; |
| 178 static base::android::ScopedJavaLocalRef<jstring> | 189 static base::android::ScopedJavaLocalRef<jstring> |
| 179 Java_SampleForTests_testStaticMethodWithNoParam(JNIEnv* env) { | 190 Java_SampleForTests_testStaticMethodWithNoParam(JNIEnv* env) { |
| 180 /* Must call RegisterNativesImpl() */ | 191 /* Must call RegisterNativesImpl() */ |
| 181 CHECK_CLAZZ(env, g_SampleForTests_clazz, | 192 CHECK_CLAZZ(env, SampleForTests_clazz(env), |
| 182 g_SampleForTests_clazz, NULL); | 193 SampleForTests_clazz(env), NULL); |
| 183 jmethodID method_id = | 194 jmethodID method_id = |
| 184 base::android::MethodID::LazyGet< | 195 base::android::MethodID::LazyGet< |
| 185 base::android::MethodID::TYPE_STATIC>( | 196 base::android::MethodID::TYPE_STATIC>( |
| 186 env, g_SampleForTests_clazz, | 197 env, SampleForTests_clazz(env), |
| 187 "testStaticMethodWithNoParam", | 198 "testStaticMethodWithNoParam", |
| 188 | 199 |
| 189 "(" | 200 "(" |
| 190 ")" | 201 ")" |
| 191 "Ljava/lang/String;", | 202 "Ljava/lang/String;", |
| 192 &g_SampleForTests_testStaticMethodWithNoParam); | 203 &g_SampleForTests_testStaticMethodWithNoParam); |
| 193 | 204 |
| 194 jstring ret = | 205 jstring ret = |
| 195 static_cast<jstring>(env->CallStaticObjectMethod(g_SampleForTests_clazz, | 206 static_cast<jstring>(env->CallStaticObjectMethod(SampleForTests_clazz(env), |
| 196 method_id)); | 207 method_id)); |
| 197 jni_generator::CheckException(env); | 208 jni_generator::CheckException(env); |
| 198 return base::android::ScopedJavaLocalRef<jstring>(env, ret); | 209 return base::android::ScopedJavaLocalRef<jstring>(env, ret); |
| 199 } | 210 } |
| 200 }; // extern "C" | 211 }; // extern "C" |
| 201 | 212 |
| 202 // Step 3: RegisterNatives. | 213 // Step 3: RegisterNatives. |
| 203 | 214 |
| 204 static bool RegisterNativesImpl(JNIEnv* env, jclass clazz) { | 215 static bool RegisterNativesImpl(JNIEnv* env, jclass clazz) { |
| 205 g_SampleForTests_clazz = static_cast<jclass>(env->NewWeakGlobalRef(clazz)); | 216 base::subtle::Release_Store(&g_SampleForTests_clazz, |
| 217 static_cast<base::subtle::AtomicWord>(env->NewWeakGlobalRef(clazz)); |
| 206 | 218 |
| 207 return true; | 219 return true; |
| 208 } | 220 } |
| 209 | 221 |
| 210 extern "C" JNIEXPORT bool JNICALL | 222 extern "C" JNIEXPORT bool JNICALL |
| 211 Java_org_chromium_example_jni_1generator_SampleForTests_nativeInitNativeClass(JN
IEnv* | 223 Java_org_chromium_example_jni_1generator_SampleForTests_nativeInitNativeClass(JN
IEnv* |
| 212 env, jclass clazz) { | 224 env, jclass clazz) { |
| 213 return RegisterNativesImpl(env, clazz); | 225 return RegisterNativesImpl(env, clazz); |
| 214 } | 226 } |
| 215 | 227 |
| 216 #endif // org_chromium_example_jni_generator_SampleForTests_JNI | 228 #endif // org_chromium_example_jni_generator_SampleForTests_JNI |
| OLD | NEW |