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