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.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_android.h" | 15 #include "base/android/jni_generator/jni_generator_helper.h" |
16 #include "base/android/scoped_java_ref.h" | |
17 #include "base/basictypes.h" | |
18 #include "base/logging.h" | |
19 | |
20 using base::android::ScopedJavaLocalRef; | |
21 | 16 |
22 // Step 1: forward declarations. | 17 // Step 1: forward declarations. |
23 namespace { | 18 namespace { |
24 const char kInnerStructAClassPath[] = | 19 const char kInnerStructAClassPath[] = |
25 "org/chromium/example/jni_generator/SampleForTests$InnerStructA"; | 20 "org/chromium/example/jni_generator/SampleForTests$InnerStructA"; |
26 const char kSampleForTestsClassPath[] = | 21 const char kSampleForTestsClassPath[] = |
27 "org/chromium/example/jni_generator/SampleForTests"; | 22 "org/chromium/example/jni_generator/SampleForTests"; |
28 const char kInnerStructBClassPath[] = | 23 const char kInnerStructBClassPath[] = |
29 "org/chromium/example/jni_generator/SampleForTests$InnerStructB"; | 24 "org/chromium/example/jni_generator/SampleForTests$InnerStructB"; |
30 // Leaking this jclass as we cannot use LazyInstance from some threads. | 25 // Leaking this jclass as we cannot use LazyInstance from some threads. |
31 jclass g_InnerStructA_clazz = NULL; | 26 jclass g_InnerStructA_clazz = NULL; |
32 // Leaking this jclass as we cannot use LazyInstance from some threads. | 27 // Leaking this jclass as we cannot use LazyInstance from some threads. |
33 jclass g_SampleForTests_clazz = NULL; | 28 jclass g_SampleForTests_clazz = NULL; |
34 // Leaking this jclass as we cannot use LazyInstance from some threads. | 29 // Leaking this jclass as we cannot use LazyInstance from some threads. |
35 jclass g_InnerStructB_clazz = NULL; | 30 jclass g_InnerStructB_clazz = NULL; |
| 31 |
36 } // namespace | 32 } // namespace |
37 | 33 |
38 namespace base { | 34 namespace base { |
39 namespace android { | 35 namespace android { |
40 | 36 |
41 static jint Init(JNIEnv* env, jobject obj, | 37 static jint Init(JNIEnv* env, jobject obj, |
42 jstring param); | 38 jstring param); |
43 | 39 |
44 static jdouble GetDoubleFunction(JNIEnv* env, jobject obj); | 40 static jdouble GetDoubleFunction(JNIEnv* env, jobject obj); |
45 | 41 |
46 static jfloat GetFloatFunction(JNIEnv* env, jclass clazz); | 42 static jfloat GetFloatFunction(JNIEnv* env, jclass clazz); |
47 | 43 |
48 static void SetNonPODDatatype(JNIEnv* env, jobject obj, | 44 static void SetNonPODDatatype(JNIEnv* env, jobject obj, |
49 jobject rect); | 45 jobject rect); |
50 | 46 |
51 static jobject GetNonPODDatatype(JNIEnv* env, jobject obj); | 47 static jobject GetNonPODDatatype(JNIEnv* env, jobject obj); |
52 | 48 |
53 // Step 2: method stubs. | 49 // Step 2: method stubs. |
54 static void Destroy(JNIEnv* env, jobject obj, | 50 static void Destroy(JNIEnv* env, jobject obj, |
55 jint nativeCPPClass) { | 51 jint nativeCPPClass) { |
56 DCHECK(nativeCPPClass) << "Destroy"; | |
57 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); | 52 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); |
| 53 DCHECK_NATIVE_PTR(native, "Destroy"); |
58 return native->Destroy(env, obj); | 54 return native->Destroy(env, obj); |
59 } | 55 } |
60 | 56 |
61 static jint Method(JNIEnv* env, jobject obj, | 57 static jint Method(JNIEnv* env, jobject obj, |
62 jint nativeCPPClass) { | 58 jint nativeCPPClass) { |
63 DCHECK(nativeCPPClass) << "Method"; | |
64 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); | 59 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); |
| 60 DCHECK_NATIVE_PTR(native, "Method", 0); |
65 return native->Method(env, obj); | 61 return native->Method(env, obj); |
66 } | 62 } |
67 | 63 |
68 static jdouble MethodOtherP0(JNIEnv* env, jobject obj, | 64 static jdouble MethodOtherP0(JNIEnv* env, jobject obj, |
69 jint nativePtr) { | 65 jint nativePtr) { |
70 DCHECK(nativePtr) << "MethodOtherP0"; | |
71 CPPClass::InnerClass* native = | 66 CPPClass::InnerClass* native = |
72 reinterpret_cast<CPPClass::InnerClass*>(nativePtr); | 67 reinterpret_cast<CPPClass::InnerClass*>(nativePtr); |
| 68 DCHECK_NATIVE_PTR(native, "MethodOtherP0", 0); |
73 return native->MethodOtherP0(env, obj); | 69 return native->MethodOtherP0(env, obj); |
74 } | 70 } |
75 | 71 |
76 static void AddStructB(JNIEnv* env, jobject obj, | 72 static void AddStructB(JNIEnv* env, jobject obj, |
77 jint nativeCPPClass, | 73 jint nativeCPPClass, |
78 jobject b) { | 74 jobject b) { |
79 DCHECK(nativeCPPClass) << "AddStructB"; | |
80 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); | 75 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); |
| 76 DCHECK_NATIVE_PTR(native, "AddStructB"); |
81 return native->AddStructB(env, obj, b); | 77 return native->AddStructB(env, obj, b); |
82 } | 78 } |
83 | 79 |
84 static void IterateAndDoSomethingWithStructB(JNIEnv* env, jobject obj, | 80 static void IterateAndDoSomethingWithStructB(JNIEnv* env, jobject obj, |
85 jint nativeCPPClass) { | 81 jint nativeCPPClass) { |
86 DCHECK(nativeCPPClass) << "IterateAndDoSomethingWithStructB"; | |
87 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); | 82 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); |
| 83 DCHECK_NATIVE_PTR(native, "IterateAndDoSomethingWithStructB"); |
88 return native->IterateAndDoSomethingWithStructB(env, obj); | 84 return native->IterateAndDoSomethingWithStructB(env, obj); |
89 } | 85 } |
90 | 86 |
| 87 static jstring ReturnAString(JNIEnv* env, jobject obj, |
| 88 jint nativeCPPClass) { |
| 89 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); |
| 90 DCHECK_NATIVE_PTR(native, "ReturnAString", NULL); |
| 91 return native->ReturnAString(env, obj).Release(); |
| 92 } |
| 93 |
91 static base::subtle::AtomicWord g_SampleForTests_javaMethod = 0; | 94 static base::subtle::AtomicWord g_SampleForTests_javaMethod = 0; |
92 static jint Java_SampleForTests_javaMethod(JNIEnv* env, jobject obj, jint foo, | 95 static jint Java_SampleForTests_javaMethod(JNIEnv* env, jobject obj, jint foo, |
93 jint bar) { | 96 jint bar) { |
94 /* Must call RegisterNativesImpl() */ | 97 /* Must call RegisterNativesImpl() */ |
95 DCHECK(g_SampleForTests_clazz); | 98 DCHECK_CLAZZ(g_SampleForTests_clazz, 0); |
96 jmethodID method_id = | 99 jmethodID method_id = |
97 base::android::MethodID::LazyGet< | 100 base::android::MethodID::LazyGet< |
98 base::android::MethodID::TYPE_INSTANCE>( | 101 base::android::MethodID::TYPE_INSTANCE>( |
99 env, g_SampleForTests_clazz, | 102 env, g_SampleForTests_clazz, |
100 "javaMethod", | 103 "javaMethod", |
101 | 104 |
102 "(" | 105 "(" |
103 "I" | 106 "I" |
104 "I" | 107 "I" |
105 ")" | 108 ")" |
106 "I", | 109 "I", |
107 &g_SampleForTests_javaMethod); | 110 &g_SampleForTests_javaMethod); |
108 | 111 |
109 jint ret = | 112 jint ret = |
110 env->CallIntMethod(obj, | 113 env->CallIntMethod(obj, |
111 method_id, foo, bar); | 114 method_id, foo, bar); |
112 base::android::CheckException(env); | 115 jni_generator::CheckException(env); |
113 return ret; | 116 return ret; |
114 } | 117 } |
115 | 118 |
116 static base::subtle::AtomicWord g_SampleForTests_staticJavaMethod = 0; | 119 static base::subtle::AtomicWord g_SampleForTests_staticJavaMethod = 0; |
117 static jboolean Java_SampleForTests_staticJavaMethod(JNIEnv* env) { | 120 static jboolean Java_SampleForTests_staticJavaMethod(JNIEnv* env) { |
118 /* Must call RegisterNativesImpl() */ | 121 /* Must call RegisterNativesImpl() */ |
119 DCHECK(g_SampleForTests_clazz); | 122 DCHECK_CLAZZ(g_SampleForTests_clazz, false); |
120 jmethodID method_id = | 123 jmethodID method_id = |
121 base::android::MethodID::LazyGet< | 124 base::android::MethodID::LazyGet< |
122 base::android::MethodID::TYPE_STATIC>( | 125 base::android::MethodID::TYPE_STATIC>( |
123 env, g_SampleForTests_clazz, | 126 env, g_SampleForTests_clazz, |
124 "staticJavaMethod", | 127 "staticJavaMethod", |
125 | 128 |
126 "(" | 129 "(" |
127 ")" | 130 ")" |
128 "Z", | 131 "Z", |
129 &g_SampleForTests_staticJavaMethod); | 132 &g_SampleForTests_staticJavaMethod); |
130 | 133 |
131 jboolean ret = | 134 jboolean ret = |
132 env->CallStaticBooleanMethod(g_SampleForTests_clazz, | 135 env->CallStaticBooleanMethod(g_SampleForTests_clazz, |
133 method_id); | 136 method_id); |
134 base::android::CheckException(env); | 137 jni_generator::CheckException(env); |
135 return ret; | 138 return ret; |
136 } | 139 } |
137 | 140 |
138 static base::subtle::AtomicWord g_SampleForTests_packagePrivateJavaMethod = 0; | 141 static base::subtle::AtomicWord g_SampleForTests_packagePrivateJavaMethod = 0; |
139 static void Java_SampleForTests_packagePrivateJavaMethod(JNIEnv* env, jobject | 142 static void Java_SampleForTests_packagePrivateJavaMethod(JNIEnv* env, jobject |
140 obj) { | 143 obj) { |
141 /* Must call RegisterNativesImpl() */ | 144 /* Must call RegisterNativesImpl() */ |
142 DCHECK(g_SampleForTests_clazz); | 145 DCHECK_CLAZZ(g_SampleForTests_clazz); |
143 jmethodID method_id = | 146 jmethodID method_id = |
144 base::android::MethodID::LazyGet< | 147 base::android::MethodID::LazyGet< |
145 base::android::MethodID::TYPE_INSTANCE>( | 148 base::android::MethodID::TYPE_INSTANCE>( |
146 env, g_SampleForTests_clazz, | 149 env, g_SampleForTests_clazz, |
147 "packagePrivateJavaMethod", | 150 "packagePrivateJavaMethod", |
148 | 151 |
149 "(" | 152 "(" |
150 ")" | 153 ")" |
151 "V", | 154 "V", |
152 &g_SampleForTests_packagePrivateJavaMethod); | 155 &g_SampleForTests_packagePrivateJavaMethod); |
153 | 156 |
154 env->CallVoidMethod(obj, | 157 env->CallVoidMethod(obj, |
155 method_id); | 158 method_id); |
156 base::android::CheckException(env); | 159 jni_generator::CheckException(env); |
157 | 160 |
158 } | 161 } |
159 | 162 |
160 static base::subtle::AtomicWord g_SampleForTests_methodThatThrowsException = 0; | 163 static base::subtle::AtomicWord g_SampleForTests_methodThatThrowsException = 0; |
161 static void Java_SampleForTests_methodThatThrowsException(JNIEnv* env, jobject | 164 static void Java_SampleForTests_methodThatThrowsException(JNIEnv* env, jobject |
162 obj) { | 165 obj) { |
163 /* Must call RegisterNativesImpl() */ | 166 /* Must call RegisterNativesImpl() */ |
164 DCHECK(g_SampleForTests_clazz); | 167 DCHECK_CLAZZ(g_SampleForTests_clazz); |
165 jmethodID method_id = | 168 jmethodID method_id = |
166 base::android::MethodID::LazyGet< | 169 base::android::MethodID::LazyGet< |
167 base::android::MethodID::TYPE_INSTANCE>( | 170 base::android::MethodID::TYPE_INSTANCE>( |
168 env, g_SampleForTests_clazz, | 171 env, g_SampleForTests_clazz, |
169 "methodThatThrowsException", | 172 "methodThatThrowsException", |
170 | 173 |
171 "(" | 174 "(" |
172 ")" | 175 ")" |
173 "V", | 176 "V", |
174 &g_SampleForTests_methodThatThrowsException); | 177 &g_SampleForTests_methodThatThrowsException); |
175 | 178 |
176 env->CallVoidMethod(obj, | 179 env->CallVoidMethod(obj, |
177 method_id); | 180 method_id); |
178 | 181 |
179 } | 182 } |
180 | 183 |
181 static base::subtle::AtomicWord g_InnerStructA_create = 0; | 184 static base::subtle::AtomicWord g_InnerStructA_create = 0; |
182 static ScopedJavaLocalRef<jobject> Java_InnerStructA_create(JNIEnv* env, jlong | 185 static base::android::ScopedJavaLocalRef<jobject> |
183 l, | 186 Java_InnerStructA_create(JNIEnv* env, jlong l, |
184 jint i, | 187 jint i, |
185 jstring s) { | 188 jstring s) { |
186 /* Must call RegisterNativesImpl() */ | 189 /* Must call RegisterNativesImpl() */ |
187 DCHECK(g_InnerStructA_clazz); | 190 DCHECK_CLAZZ(g_InnerStructA_clazz, NULL); |
188 jmethodID method_id = | 191 jmethodID method_id = |
189 base::android::MethodID::LazyGet< | 192 base::android::MethodID::LazyGet< |
190 base::android::MethodID::TYPE_STATIC>( | 193 base::android::MethodID::TYPE_STATIC>( |
191 env, g_InnerStructA_clazz, | 194 env, g_InnerStructA_clazz, |
192 "create", | 195 "create", |
193 | 196 |
194 "(" | 197 "(" |
195 "J" | 198 "J" |
196 "I" | 199 "I" |
197 "Ljava/lang/String;" | 200 "Ljava/lang/String;" |
198 ")" | 201 ")" |
199 "Lorg/chromium/example/jni_generator/SampleForTests$InnerStructA;", | 202 "Lorg/chromium/example/jni_generator/SampleForTests$InnerStructA;", |
200 &g_InnerStructA_create); | 203 &g_InnerStructA_create); |
201 | 204 |
202 jobject ret = | 205 jobject ret = |
203 env->CallStaticObjectMethod(g_InnerStructA_clazz, | 206 env->CallStaticObjectMethod(g_InnerStructA_clazz, |
204 method_id, l, i, s); | 207 method_id, l, i, s); |
205 base::android::CheckException(env); | 208 jni_generator::CheckException(env); |
206 return ScopedJavaLocalRef<jobject>(env, ret); | 209 return base::android::ScopedJavaLocalRef<jobject>(env, ret); |
207 } | 210 } |
208 | 211 |
209 static base::subtle::AtomicWord g_SampleForTests_addStructA = 0; | 212 static base::subtle::AtomicWord g_SampleForTests_addStructA = 0; |
210 static void Java_SampleForTests_addStructA(JNIEnv* env, jobject obj, jobject a) | 213 static void Java_SampleForTests_addStructA(JNIEnv* env, jobject obj, jobject a) |
211 { | 214 { |
212 /* Must call RegisterNativesImpl() */ | 215 /* Must call RegisterNativesImpl() */ |
213 DCHECK(g_SampleForTests_clazz); | 216 DCHECK_CLAZZ(g_SampleForTests_clazz); |
214 jmethodID method_id = | 217 jmethodID method_id = |
215 base::android::MethodID::LazyGet< | 218 base::android::MethodID::LazyGet< |
216 base::android::MethodID::TYPE_INSTANCE>( | 219 base::android::MethodID::TYPE_INSTANCE>( |
217 env, g_SampleForTests_clazz, | 220 env, g_SampleForTests_clazz, |
218 "addStructA", | 221 "addStructA", |
219 | 222 |
220 "(" | 223 "(" |
221 "Lorg/chromium/example/jni_generator/SampleForTests$InnerStructA;" | 224 "Lorg/chromium/example/jni_generator/SampleForTests$InnerStructA;" |
222 ")" | 225 ")" |
223 "V", | 226 "V", |
224 &g_SampleForTests_addStructA); | 227 &g_SampleForTests_addStructA); |
225 | 228 |
226 env->CallVoidMethod(obj, | 229 env->CallVoidMethod(obj, |
227 method_id, a); | 230 method_id, a); |
228 base::android::CheckException(env); | 231 jni_generator::CheckException(env); |
229 | 232 |
230 } | 233 } |
231 | 234 |
232 static base::subtle::AtomicWord g_SampleForTests_iterateAndDoSomething = 0; | 235 static base::subtle::AtomicWord g_SampleForTests_iterateAndDoSomething = 0; |
233 static void Java_SampleForTests_iterateAndDoSomething(JNIEnv* env, jobject obj) | 236 static void Java_SampleForTests_iterateAndDoSomething(JNIEnv* env, jobject obj) |
234 { | 237 { |
235 /* Must call RegisterNativesImpl() */ | 238 /* Must call RegisterNativesImpl() */ |
236 DCHECK(g_SampleForTests_clazz); | 239 DCHECK_CLAZZ(g_SampleForTests_clazz); |
237 jmethodID method_id = | 240 jmethodID method_id = |
238 base::android::MethodID::LazyGet< | 241 base::android::MethodID::LazyGet< |
239 base::android::MethodID::TYPE_INSTANCE>( | 242 base::android::MethodID::TYPE_INSTANCE>( |
240 env, g_SampleForTests_clazz, | 243 env, g_SampleForTests_clazz, |
241 "iterateAndDoSomething", | 244 "iterateAndDoSomething", |
242 | 245 |
243 "(" | 246 "(" |
244 ")" | 247 ")" |
245 "V", | 248 "V", |
246 &g_SampleForTests_iterateAndDoSomething); | 249 &g_SampleForTests_iterateAndDoSomething); |
247 | 250 |
248 env->CallVoidMethod(obj, | 251 env->CallVoidMethod(obj, |
249 method_id); | 252 method_id); |
250 base::android::CheckException(env); | 253 jni_generator::CheckException(env); |
251 | 254 |
252 } | 255 } |
253 | 256 |
254 static base::subtle::AtomicWord g_InnerStructB_getKey = 0; | 257 static base::subtle::AtomicWord g_InnerStructB_getKey = 0; |
255 static jlong Java_InnerStructB_getKey(JNIEnv* env, jobject obj) { | 258 static jlong Java_InnerStructB_getKey(JNIEnv* env, jobject obj) { |
256 /* Must call RegisterNativesImpl() */ | 259 /* Must call RegisterNativesImpl() */ |
257 DCHECK(g_InnerStructB_clazz); | 260 DCHECK_CLAZZ(g_InnerStructB_clazz, 0); |
258 jmethodID method_id = | 261 jmethodID method_id = |
259 base::android::MethodID::LazyGet< | 262 base::android::MethodID::LazyGet< |
260 base::android::MethodID::TYPE_INSTANCE>( | 263 base::android::MethodID::TYPE_INSTANCE>( |
261 env, g_InnerStructB_clazz, | 264 env, g_InnerStructB_clazz, |
262 "getKey", | 265 "getKey", |
263 | 266 |
264 "(" | 267 "(" |
265 ")" | 268 ")" |
266 "J", | 269 "J", |
267 &g_InnerStructB_getKey); | 270 &g_InnerStructB_getKey); |
268 | 271 |
269 jlong ret = | 272 jlong ret = |
270 env->CallLongMethod(obj, | 273 env->CallLongMethod(obj, |
271 method_id); | 274 method_id); |
272 base::android::CheckException(env); | 275 jni_generator::CheckException(env); |
273 return ret; | 276 return ret; |
274 } | 277 } |
275 | 278 |
276 static base::subtle::AtomicWord g_InnerStructB_getValue = 0; | 279 static base::subtle::AtomicWord g_InnerStructB_getValue = 0; |
277 static ScopedJavaLocalRef<jstring> Java_InnerStructB_getValue(JNIEnv* env, | 280 static base::android::ScopedJavaLocalRef<jstring> |
278 jobject obj) { | 281 Java_InnerStructB_getValue(JNIEnv* env, jobject obj) { |
279 /* Must call RegisterNativesImpl() */ | 282 /* Must call RegisterNativesImpl() */ |
280 DCHECK(g_InnerStructB_clazz); | 283 DCHECK_CLAZZ(g_InnerStructB_clazz, NULL); |
281 jmethodID method_id = | 284 jmethodID method_id = |
282 base::android::MethodID::LazyGet< | 285 base::android::MethodID::LazyGet< |
283 base::android::MethodID::TYPE_INSTANCE>( | 286 base::android::MethodID::TYPE_INSTANCE>( |
284 env, g_InnerStructB_clazz, | 287 env, g_InnerStructB_clazz, |
285 "getValue", | 288 "getValue", |
286 | 289 |
287 "(" | 290 "(" |
288 ")" | 291 ")" |
289 "Ljava/lang/String;", | 292 "Ljava/lang/String;", |
290 &g_InnerStructB_getValue); | 293 &g_InnerStructB_getValue); |
291 | 294 |
292 jstring ret = | 295 jstring ret = |
293 static_cast<jstring>(env->CallObjectMethod(obj, | 296 static_cast<jstring>(env->CallObjectMethod(obj, |
294 method_id)); | 297 method_id)); |
295 base::android::CheckException(env); | 298 jni_generator::CheckException(env); |
296 return ScopedJavaLocalRef<jstring>(env, ret); | 299 return base::android::ScopedJavaLocalRef<jstring>(env, ret); |
297 } | 300 } |
298 | 301 |
299 // Step 3: RegisterNatives. | 302 // Step 3: RegisterNatives. |
300 | 303 |
301 static bool RegisterNativesImpl(JNIEnv* env) { | 304 static const JNINativeMethod kMethodsSampleForTests[] = { |
302 | |
303 g_InnerStructA_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( | |
304 base::android::GetClass(env, kInnerStructAClassPath).obj())); | |
305 g_SampleForTests_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( | |
306 base::android::GetClass(env, kSampleForTestsClassPath).obj())); | |
307 g_InnerStructB_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( | |
308 base::android::GetClass(env, kInnerStructBClassPath).obj())); | |
309 static const JNINativeMethod kMethodsSampleForTests[] = { | |
310 { "nativeInit", | 305 { "nativeInit", |
311 "(" | 306 "(" |
312 "Ljava/lang/String;" | 307 "Ljava/lang/String;" |
313 ")" | 308 ")" |
314 "I", reinterpret_cast<void*>(Init) }, | 309 "I", reinterpret_cast<void*>(Init) }, |
315 { "nativeDestroy", | 310 { "nativeDestroy", |
316 "(" | 311 "(" |
317 "I" | 312 "I" |
318 ")" | 313 ")" |
319 "V", reinterpret_cast<void*>(Destroy) }, | 314 "V", reinterpret_cast<void*>(Destroy) }, |
(...skipping 28 matching lines...) Expand all Loading... |
348 "(" | 343 "(" |
349 "I" | 344 "I" |
350 "Lorg/chromium/example/jni_generator/SampleForTests$InnerStructB;" | 345 "Lorg/chromium/example/jni_generator/SampleForTests$InnerStructB;" |
351 ")" | 346 ")" |
352 "V", reinterpret_cast<void*>(AddStructB) }, | 347 "V", reinterpret_cast<void*>(AddStructB) }, |
353 { "nativeIterateAndDoSomethingWithStructB", | 348 { "nativeIterateAndDoSomethingWithStructB", |
354 "(" | 349 "(" |
355 "I" | 350 "I" |
356 ")" | 351 ")" |
357 "V", reinterpret_cast<void*>(IterateAndDoSomethingWithStructB) }, | 352 "V", reinterpret_cast<void*>(IterateAndDoSomethingWithStructB) }, |
358 }; | 353 { "nativeReturnAString", |
| 354 "(" |
| 355 "I" |
| 356 ")" |
| 357 "Ljava/lang/String;", reinterpret_cast<void*>(ReturnAString) }, |
| 358 }; |
| 359 |
| 360 static bool RegisterNativesImpl(JNIEnv* env) { |
| 361 g_InnerStructA_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( |
| 362 base::android::GetClass(env, kInnerStructAClassPath).obj())); |
| 363 g_SampleForTests_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( |
| 364 base::android::GetClass(env, kSampleForTestsClassPath).obj())); |
| 365 g_InnerStructB_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( |
| 366 base::android::GetClass(env, kInnerStructBClassPath).obj())); |
| 367 |
359 const int kMethodsSampleForTestsSize = arraysize(kMethodsSampleForTests); | 368 const int kMethodsSampleForTestsSize = arraysize(kMethodsSampleForTests); |
360 | 369 |
361 if (env->RegisterNatives(g_SampleForTests_clazz, | 370 if (env->RegisterNatives(g_SampleForTests_clazz, |
362 kMethodsSampleForTests, | 371 kMethodsSampleForTests, |
363 kMethodsSampleForTestsSize) < 0) { | 372 kMethodsSampleForTestsSize) < 0) { |
364 LOG(ERROR) << "RegisterNatives failed in " << __FILE__; | 373 jni_generator::HandleRegistrationError( |
| 374 env, g_SampleForTests_clazz, __FILE__); |
365 return false; | 375 return false; |
366 } | 376 } |
367 | 377 |
368 return true; | 378 return true; |
369 } | 379 } |
| 380 |
370 } // namespace android | 381 } // namespace android |
371 } // namespace base | 382 } // namespace base |
372 | 383 |
373 #endif // org_chromium_example_jni_generator_SampleForTests_JNI | 384 #endif // org_chromium_example_jni_generator_SampleForTests_JNI |
OLD | NEW |