Update broken references to image assets
[chromium-blink-merge.git] / base / android / jni_generator / golden_sample_for_tests_jni.h
blobe146acada34001dbb25a27b2e23988f1fbbd8040
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
3 // found in the LICENSE file.
5 // This file is autogenerated by
6 // base/android/jni_generator/jni_generator.py
7 // For
8 // org/chromium/example/jni_generator/SampleForTests
10 #ifndef org_chromium_example_jni_generator_SampleForTests_JNI
11 #define org_chromium_example_jni_generator_SampleForTests_JNI
13 #include <jni.h>
15 #include "base/android/jni_generator/jni_generator_helper.h"
17 #include "base/android/jni_int_wrapper.h"
19 // Step 1: forward declarations.
20 namespace {
21 const char kInnerStructAClassPath[] =
22 "org/chromium/example/jni_generator/SampleForTests$InnerStructA";
23 const char kSampleForTestsClassPath[] =
24 "org/chromium/example/jni_generator/SampleForTests";
25 const char kInnerStructBClassPath[] =
26 "org/chromium/example/jni_generator/SampleForTests$InnerStructB";
27 // Leaking this jclass as we cannot use LazyInstance from some threads.
28 jclass g_InnerStructA_clazz = NULL;
29 #define InnerStructA_clazz(env) g_InnerStructA_clazz
30 // Leaking this jclass as we cannot use LazyInstance from some threads.
31 jclass g_SampleForTests_clazz = NULL;
32 #define SampleForTests_clazz(env) g_SampleForTests_clazz
33 // Leaking this jclass as we cannot use LazyInstance from some threads.
34 jclass g_InnerStructB_clazz = NULL;
35 #define InnerStructB_clazz(env) g_InnerStructB_clazz
37 } // namespace
39 namespace base {
40 namespace android {
42 // Step 2: method stubs.
44 static jlong Init(JNIEnv* env, jobject jcaller,
45 jstring param);
47 static jlong
48 Java_org_chromium_example_jni_1generator_SampleForTests_nativeInit(JNIEnv*
49 env, jobject jcaller,
50 jstring param) {
51 return Init(env, jcaller, param);
54 static void
55 Java_org_chromium_example_jni_1generator_SampleForTests_nativeDestroy(JNIEnv*
56 env,
57 jobject jcaller,
58 jlong nativeCPPClass) {
59 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass);
60 CHECK_NATIVE_PTR(env, jcaller, native, "Destroy");
61 return native->Destroy(env, jcaller);
64 static jdouble GetDoubleFunction(JNIEnv* env, jobject jcaller);
66 static jdouble
67 Java_org_chromium_example_jni_1generator_SampleForTests_nativeGetDoubleFunction(JNIEnv*
68 env, jobject jcaller) {
69 return GetDoubleFunction(env, jcaller);
72 static jfloat GetFloatFunction(JNIEnv* env, jclass jcaller);
74 static jfloat
75 Java_org_chromium_example_jni_1generator_SampleForTests_nativeGetFloatFunction(JNIEnv*
76 env, jclass jcaller) {
77 return GetFloatFunction(env, jcaller);
80 static void SetNonPODDatatype(JNIEnv* env, jobject jcaller,
81 jobject rect);
83 static void
84 Java_org_chromium_example_jni_1generator_SampleForTests_nativeSetNonPODDatatype(JNIEnv*
85 env, jobject jcaller,
86 jobject rect) {
87 return SetNonPODDatatype(env, jcaller, rect);
90 static jobject GetNonPODDatatype(JNIEnv* env, jobject jcaller);
92 static jobject
93 Java_org_chromium_example_jni_1generator_SampleForTests_nativeGetNonPODDatatype(JNIEnv*
94 env, jobject jcaller) {
95 return GetNonPODDatatype(env, jcaller);
98 static jint
99 Java_org_chromium_example_jni_1generator_SampleForTests_nativeMethod(JNIEnv*
100 env,
101 jobject jcaller,
102 jlong nativeCPPClass) {
103 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass);
104 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0);
105 return native->Method(env, jcaller);
108 static jdouble
109 Java_org_chromium_example_jni_1generator_SampleForTests_nativeMethodOtherP0(JNIEnv*
110 env,
111 jobject jcaller,
112 jlong nativePtr) {
113 CPPClass::InnerClass* native =
114 reinterpret_cast<CPPClass::InnerClass*>(nativePtr);
115 CHECK_NATIVE_PTR(env, jcaller, native, "MethodOtherP0", 0);
116 return native->MethodOtherP0(env, jcaller);
119 static void
120 Java_org_chromium_example_jni_1generator_SampleForTests_nativeAddStructB(JNIEnv*
121 env,
122 jobject jcaller,
123 jlong nativeCPPClass,
124 jobject b) {
125 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass);
126 CHECK_NATIVE_PTR(env, jcaller, native, "AddStructB");
127 return native->AddStructB(env, jcaller, b);
130 static void
131 Java_org_chromium_example_jni_1generator_SampleForTests_nativeIterateAndDoSomethingWithStructB(JNIEnv*
132 env,
133 jobject jcaller,
134 jlong nativeCPPClass) {
135 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass);
136 CHECK_NATIVE_PTR(env, jcaller, native, "IterateAndDoSomethingWithStructB");
137 return native->IterateAndDoSomethingWithStructB(env, jcaller);
140 static jstring
141 Java_org_chromium_example_jni_1generator_SampleForTests_nativeReturnAString(JNIEnv*
142 env,
143 jobject jcaller,
144 jlong nativeCPPClass) {
145 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass);
146 CHECK_NATIVE_PTR(env, jcaller, native, "ReturnAString", NULL);
147 return native->ReturnAString(env, jcaller).Release();
150 static base::subtle::AtomicWord g_SampleForTests_javaMethod = 0;
151 static jint Java_SampleForTests_javaMethod(JNIEnv* env, jobject obj,
152 JniIntWrapper foo,
153 JniIntWrapper bar) {
154 /* Must call RegisterNativesImpl() */
155 CHECK_CLAZZ(env, obj,
156 SampleForTests_clazz(env), 0);
157 jmethodID method_id =
158 base::android::MethodID::LazyGet<
159 base::android::MethodID::TYPE_INSTANCE>(
160 env, SampleForTests_clazz(env),
161 "javaMethod",
167 "I",
168 &g_SampleForTests_javaMethod);
170 jint ret =
171 env->CallIntMethod(obj,
172 method_id, as_jint(foo), as_jint(bar));
173 jni_generator::CheckException(env);
174 return ret;
177 static base::subtle::AtomicWord g_SampleForTests_staticJavaMethod = 0;
178 static jboolean Java_SampleForTests_staticJavaMethod(JNIEnv* env) {
179 /* Must call RegisterNativesImpl() */
180 CHECK_CLAZZ(env, SampleForTests_clazz(env),
181 SampleForTests_clazz(env), false);
182 jmethodID method_id =
183 base::android::MethodID::LazyGet<
184 base::android::MethodID::TYPE_STATIC>(
185 env, SampleForTests_clazz(env),
186 "staticJavaMethod",
190 "Z",
191 &g_SampleForTests_staticJavaMethod);
193 jboolean ret =
194 env->CallStaticBooleanMethod(SampleForTests_clazz(env),
195 method_id);
196 jni_generator::CheckException(env);
197 return ret;
200 static base::subtle::AtomicWord g_SampleForTests_packagePrivateJavaMethod = 0;
201 static void Java_SampleForTests_packagePrivateJavaMethod(JNIEnv* env, jobject
202 obj) {
203 /* Must call RegisterNativesImpl() */
204 CHECK_CLAZZ(env, obj,
205 SampleForTests_clazz(env));
206 jmethodID method_id =
207 base::android::MethodID::LazyGet<
208 base::android::MethodID::TYPE_INSTANCE>(
209 env, SampleForTests_clazz(env),
210 "packagePrivateJavaMethod",
214 "V",
215 &g_SampleForTests_packagePrivateJavaMethod);
217 env->CallVoidMethod(obj,
218 method_id);
219 jni_generator::CheckException(env);
223 static base::subtle::AtomicWord g_SampleForTests_methodThatThrowsException = 0;
224 static void Java_SampleForTests_methodThatThrowsException(JNIEnv* env, jobject
225 obj) {
226 /* Must call RegisterNativesImpl() */
227 CHECK_CLAZZ(env, obj,
228 SampleForTests_clazz(env));
229 jmethodID method_id =
230 base::android::MethodID::LazyGet<
231 base::android::MethodID::TYPE_INSTANCE>(
232 env, SampleForTests_clazz(env),
233 "methodThatThrowsException",
237 "V",
238 &g_SampleForTests_methodThatThrowsException);
240 env->CallVoidMethod(obj,
241 method_id);
245 static base::subtle::AtomicWord g_InnerStructA_create = 0;
246 static base::android::ScopedJavaLocalRef<jobject>
247 Java_InnerStructA_create(JNIEnv* env, jlong l,
248 JniIntWrapper i,
249 jstring s) {
250 /* Must call RegisterNativesImpl() */
251 CHECK_CLAZZ(env, InnerStructA_clazz(env),
252 InnerStructA_clazz(env), NULL);
253 jmethodID method_id =
254 base::android::MethodID::LazyGet<
255 base::android::MethodID::TYPE_STATIC>(
256 env, InnerStructA_clazz(env),
257 "create",
262 "Ljava/lang/String;"
264 "Lorg/chromium/example/jni_generator/SampleForTests$InnerStructA;",
265 &g_InnerStructA_create);
267 jobject ret =
268 env->CallStaticObjectMethod(InnerStructA_clazz(env),
269 method_id, l, as_jint(i), s);
270 jni_generator::CheckException(env);
271 return base::android::ScopedJavaLocalRef<jobject>(env, ret);
274 static base::subtle::AtomicWord g_SampleForTests_addStructA = 0;
275 static void Java_SampleForTests_addStructA(JNIEnv* env, jobject obj, jobject a)
277 /* Must call RegisterNativesImpl() */
278 CHECK_CLAZZ(env, obj,
279 SampleForTests_clazz(env));
280 jmethodID method_id =
281 base::android::MethodID::LazyGet<
282 base::android::MethodID::TYPE_INSTANCE>(
283 env, SampleForTests_clazz(env),
284 "addStructA",
287 "Lorg/chromium/example/jni_generator/SampleForTests$InnerStructA;"
289 "V",
290 &g_SampleForTests_addStructA);
292 env->CallVoidMethod(obj,
293 method_id, a);
294 jni_generator::CheckException(env);
298 static base::subtle::AtomicWord g_SampleForTests_iterateAndDoSomething = 0;
299 static void Java_SampleForTests_iterateAndDoSomething(JNIEnv* env, jobject obj)
301 /* Must call RegisterNativesImpl() */
302 CHECK_CLAZZ(env, obj,
303 SampleForTests_clazz(env));
304 jmethodID method_id =
305 base::android::MethodID::LazyGet<
306 base::android::MethodID::TYPE_INSTANCE>(
307 env, SampleForTests_clazz(env),
308 "iterateAndDoSomething",
312 "V",
313 &g_SampleForTests_iterateAndDoSomething);
315 env->CallVoidMethod(obj,
316 method_id);
317 jni_generator::CheckException(env);
321 static base::subtle::AtomicWord g_InnerStructB_getKey = 0;
322 static jlong Java_InnerStructB_getKey(JNIEnv* env, jobject obj) {
323 /* Must call RegisterNativesImpl() */
324 CHECK_CLAZZ(env, obj,
325 InnerStructB_clazz(env), 0);
326 jmethodID method_id =
327 base::android::MethodID::LazyGet<
328 base::android::MethodID::TYPE_INSTANCE>(
329 env, InnerStructB_clazz(env),
330 "getKey",
334 "J",
335 &g_InnerStructB_getKey);
337 jlong ret =
338 env->CallLongMethod(obj,
339 method_id);
340 jni_generator::CheckException(env);
341 return ret;
344 static base::subtle::AtomicWord g_InnerStructB_getValue = 0;
345 static base::android::ScopedJavaLocalRef<jstring>
346 Java_InnerStructB_getValue(JNIEnv* env, jobject obj) {
347 /* Must call RegisterNativesImpl() */
348 CHECK_CLAZZ(env, obj,
349 InnerStructB_clazz(env), NULL);
350 jmethodID method_id =
351 base::android::MethodID::LazyGet<
352 base::android::MethodID::TYPE_INSTANCE>(
353 env, InnerStructB_clazz(env),
354 "getValue",
358 "Ljava/lang/String;",
359 &g_InnerStructB_getValue);
361 jstring ret =
362 static_cast<jstring>(env->CallObjectMethod(obj,
363 method_id));
364 jni_generator::CheckException(env);
365 return base::android::ScopedJavaLocalRef<jstring>(env, ret);
368 // Step 3: RegisterNatives.
370 static const JNINativeMethod kMethodsSampleForTests[] = {
371 { "nativeInit",
373 "Ljava/lang/String;"
375 "J",
376 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTests_nativeInit)
378 { "nativeDestroy",
382 "V",
383 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTests_nativeDestroy)
385 { "nativeGetDoubleFunction",
388 "D",
389 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTests_nativeGetDoubleFunction)
391 { "nativeGetFloatFunction",
394 "F",
395 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTests_nativeGetFloatFunction)
397 { "nativeSetNonPODDatatype",
399 "Landroid/graphics/Rect;"
401 "V",
402 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTests_nativeSetNonPODDatatype)
404 { "nativeGetNonPODDatatype",
407 "Ljava/lang/Object;",
408 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTests_nativeGetNonPODDatatype)
410 { "nativeMethod",
414 "I",
415 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTests_nativeMethod)
417 { "nativeMethodOtherP0",
421 "D",
422 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTests_nativeMethodOtherP0)
424 { "nativeAddStructB",
427 "Lorg/chromium/example/jni_generator/SampleForTests$InnerStructB;"
429 "V",
430 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTests_nativeAddStructB)
432 { "nativeIterateAndDoSomethingWithStructB",
436 "V",
437 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTests_nativeIterateAndDoSomethingWithStructB)
439 { "nativeReturnAString",
443 "Ljava/lang/String;",
444 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTests_nativeReturnAString)
448 static bool RegisterNativesImpl(JNIEnv* env) {
450 g_InnerStructA_clazz = reinterpret_cast<jclass>(env->NewGlobalRef(
451 base::android::GetClass(env, kInnerStructAClassPath).obj()));
452 g_SampleForTests_clazz = reinterpret_cast<jclass>(env->NewGlobalRef(
453 base::android::GetClass(env, kSampleForTestsClassPath).obj()));
454 g_InnerStructB_clazz = reinterpret_cast<jclass>(env->NewGlobalRef(
455 base::android::GetClass(env, kInnerStructBClassPath).obj()));
457 const int kMethodsSampleForTestsSize = arraysize(kMethodsSampleForTests);
459 if (env->RegisterNatives(SampleForTests_clazz(env),
460 kMethodsSampleForTests,
461 kMethodsSampleForTestsSize) < 0) {
462 jni_generator::HandleRegistrationError(
463 env, SampleForTests_clazz(env), __FILE__);
464 return false;
467 return true;
470 } // namespace android
471 } // namespace base
473 #endif // org_chromium_example_jni_generator_SampleForTests_JNI