Permission messages: Add a bunch of missing combinations/suppressions.
[chromium-blink-merge.git] / base / android / jni_generator / golden_sample_for_tests_jni.h
blob974cfffde8a17a4ca08a32f5ef5e8b827bad390e
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 ScopedJavaLocalRef<jobject> GetNonPODDatatype(JNIEnv* env, jobject
91 jcaller);
93 static jobject
94 Java_org_chromium_example_jni_1generator_SampleForTests_nativeGetNonPODDatatype(JNIEnv*
95 env, jobject jcaller) {
96 return GetNonPODDatatype(env, jcaller).Release();
99 static jint
100 Java_org_chromium_example_jni_1generator_SampleForTests_nativeMethod(JNIEnv*
101 env,
102 jobject jcaller,
103 jlong nativeCPPClass) {
104 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass);
105 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0);
106 return native->Method(env, jcaller);
109 static jdouble
110 Java_org_chromium_example_jni_1generator_SampleForTests_nativeMethodOtherP0(JNIEnv*
111 env,
112 jobject jcaller,
113 jlong nativePtr) {
114 CPPClass::InnerClass* native =
115 reinterpret_cast<CPPClass::InnerClass*>(nativePtr);
116 CHECK_NATIVE_PTR(env, jcaller, native, "MethodOtherP0", 0);
117 return native->MethodOtherP0(env, jcaller);
120 static void
121 Java_org_chromium_example_jni_1generator_SampleForTests_nativeAddStructB(JNIEnv*
122 env,
123 jobject jcaller,
124 jlong nativeCPPClass,
125 jobject b) {
126 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass);
127 CHECK_NATIVE_PTR(env, jcaller, native, "AddStructB");
128 return native->AddStructB(env, jcaller, b);
131 static void
132 Java_org_chromium_example_jni_1generator_SampleForTests_nativeIterateAndDoSomethingWithStructB(JNIEnv*
133 env,
134 jobject jcaller,
135 jlong nativeCPPClass) {
136 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass);
137 CHECK_NATIVE_PTR(env, jcaller, native, "IterateAndDoSomethingWithStructB");
138 return native->IterateAndDoSomethingWithStructB(env, jcaller);
141 static jstring
142 Java_org_chromium_example_jni_1generator_SampleForTests_nativeReturnAString(JNIEnv*
143 env,
144 jobject jcaller,
145 jlong nativeCPPClass) {
146 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass);
147 CHECK_NATIVE_PTR(env, jcaller, native, "ReturnAString", NULL);
148 return native->ReturnAString(env, jcaller).Release();
151 static base::subtle::AtomicWord g_SampleForTests_javaMethod = 0;
152 static jint Java_SampleForTests_javaMethod(JNIEnv* env, jobject obj,
153 JniIntWrapper foo,
154 JniIntWrapper bar) {
155 /* Must call RegisterNativesImpl() */
156 CHECK_CLAZZ(env, obj,
157 SampleForTests_clazz(env), 0);
158 jmethodID method_id =
159 base::android::MethodID::LazyGet<
160 base::android::MethodID::TYPE_INSTANCE>(
161 env, SampleForTests_clazz(env),
162 "javaMethod",
168 "I",
169 &g_SampleForTests_javaMethod);
171 jint ret =
172 env->CallIntMethod(obj,
173 method_id, as_jint(foo), as_jint(bar));
174 jni_generator::CheckException(env);
175 return ret;
178 static base::subtle::AtomicWord g_SampleForTests_staticJavaMethod = 0;
179 static jboolean Java_SampleForTests_staticJavaMethod(JNIEnv* env) {
180 /* Must call RegisterNativesImpl() */
181 CHECK_CLAZZ(env, SampleForTests_clazz(env),
182 SampleForTests_clazz(env), false);
183 jmethodID method_id =
184 base::android::MethodID::LazyGet<
185 base::android::MethodID::TYPE_STATIC>(
186 env, SampleForTests_clazz(env),
187 "staticJavaMethod",
191 "Z",
192 &g_SampleForTests_staticJavaMethod);
194 jboolean ret =
195 env->CallStaticBooleanMethod(SampleForTests_clazz(env),
196 method_id);
197 jni_generator::CheckException(env);
198 return ret;
201 static base::subtle::AtomicWord g_SampleForTests_packagePrivateJavaMethod = 0;
202 static void Java_SampleForTests_packagePrivateJavaMethod(JNIEnv* env, jobject
203 obj) {
204 /* Must call RegisterNativesImpl() */
205 CHECK_CLAZZ(env, obj,
206 SampleForTests_clazz(env));
207 jmethodID method_id =
208 base::android::MethodID::LazyGet<
209 base::android::MethodID::TYPE_INSTANCE>(
210 env, SampleForTests_clazz(env),
211 "packagePrivateJavaMethod",
215 "V",
216 &g_SampleForTests_packagePrivateJavaMethod);
218 env->CallVoidMethod(obj,
219 method_id);
220 jni_generator::CheckException(env);
224 static base::subtle::AtomicWord g_SampleForTests_methodThatThrowsException = 0;
225 static void Java_SampleForTests_methodThatThrowsException(JNIEnv* env, jobject
226 obj) {
227 /* Must call RegisterNativesImpl() */
228 CHECK_CLAZZ(env, obj,
229 SampleForTests_clazz(env));
230 jmethodID method_id =
231 base::android::MethodID::LazyGet<
232 base::android::MethodID::TYPE_INSTANCE>(
233 env, SampleForTests_clazz(env),
234 "methodThatThrowsException",
238 "V",
239 &g_SampleForTests_methodThatThrowsException);
241 env->CallVoidMethod(obj,
242 method_id);
246 static base::subtle::AtomicWord g_InnerStructA_create = 0;
247 static ScopedJavaLocalRef<jobject> Java_InnerStructA_create(JNIEnv* env, jlong
249 JniIntWrapper i,
250 jstring s) {
251 /* Must call RegisterNativesImpl() */
252 CHECK_CLAZZ(env, InnerStructA_clazz(env),
253 InnerStructA_clazz(env), NULL);
254 jmethodID method_id =
255 base::android::MethodID::LazyGet<
256 base::android::MethodID::TYPE_STATIC>(
257 env, InnerStructA_clazz(env),
258 "create",
263 "Ljava/lang/String;"
265 "Lorg/chromium/example/jni_generator/SampleForTests$InnerStructA;",
266 &g_InnerStructA_create);
268 jobject ret =
269 env->CallStaticObjectMethod(InnerStructA_clazz(env),
270 method_id, l, as_jint(i), s);
271 jni_generator::CheckException(env);
272 return ScopedJavaLocalRef<jobject>(env, ret);
275 static base::subtle::AtomicWord g_SampleForTests_addStructA = 0;
276 static void Java_SampleForTests_addStructA(JNIEnv* env, jobject obj, jobject a)
278 /* Must call RegisterNativesImpl() */
279 CHECK_CLAZZ(env, obj,
280 SampleForTests_clazz(env));
281 jmethodID method_id =
282 base::android::MethodID::LazyGet<
283 base::android::MethodID::TYPE_INSTANCE>(
284 env, SampleForTests_clazz(env),
285 "addStructA",
288 "Lorg/chromium/example/jni_generator/SampleForTests$InnerStructA;"
290 "V",
291 &g_SampleForTests_addStructA);
293 env->CallVoidMethod(obj,
294 method_id, a);
295 jni_generator::CheckException(env);
299 static base::subtle::AtomicWord g_SampleForTests_iterateAndDoSomething = 0;
300 static void Java_SampleForTests_iterateAndDoSomething(JNIEnv* env, jobject obj)
302 /* Must call RegisterNativesImpl() */
303 CHECK_CLAZZ(env, obj,
304 SampleForTests_clazz(env));
305 jmethodID method_id =
306 base::android::MethodID::LazyGet<
307 base::android::MethodID::TYPE_INSTANCE>(
308 env, SampleForTests_clazz(env),
309 "iterateAndDoSomething",
313 "V",
314 &g_SampleForTests_iterateAndDoSomething);
316 env->CallVoidMethod(obj,
317 method_id);
318 jni_generator::CheckException(env);
322 static base::subtle::AtomicWord g_InnerStructB_getKey = 0;
323 static jlong Java_InnerStructB_getKey(JNIEnv* env, jobject obj) {
324 /* Must call RegisterNativesImpl() */
325 CHECK_CLAZZ(env, obj,
326 InnerStructB_clazz(env), 0);
327 jmethodID method_id =
328 base::android::MethodID::LazyGet<
329 base::android::MethodID::TYPE_INSTANCE>(
330 env, InnerStructB_clazz(env),
331 "getKey",
335 "J",
336 &g_InnerStructB_getKey);
338 jlong ret =
339 env->CallLongMethod(obj,
340 method_id);
341 jni_generator::CheckException(env);
342 return ret;
345 static base::subtle::AtomicWord g_InnerStructB_getValue = 0;
346 static ScopedJavaLocalRef<jstring> Java_InnerStructB_getValue(JNIEnv* env,
347 jobject obj) {
348 /* Must call RegisterNativesImpl() */
349 CHECK_CLAZZ(env, obj,
350 InnerStructB_clazz(env), NULL);
351 jmethodID method_id =
352 base::android::MethodID::LazyGet<
353 base::android::MethodID::TYPE_INSTANCE>(
354 env, InnerStructB_clazz(env),
355 "getValue",
359 "Ljava/lang/String;",
360 &g_InnerStructB_getValue);
362 jstring ret =
363 static_cast<jstring>(env->CallObjectMethod(obj,
364 method_id));
365 jni_generator::CheckException(env);
366 return ScopedJavaLocalRef<jstring>(env, ret);
369 // Step 3: RegisterNatives.
371 static const JNINativeMethod kMethodsSampleForTests[] = {
372 { "nativeInit",
374 "Ljava/lang/String;"
376 "J",
377 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTests_nativeInit)
379 { "nativeDestroy",
383 "V",
384 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTests_nativeDestroy)
386 { "nativeGetDoubleFunction",
389 "D",
390 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTests_nativeGetDoubleFunction)
392 { "nativeGetFloatFunction",
395 "F",
396 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTests_nativeGetFloatFunction)
398 { "nativeSetNonPODDatatype",
400 "Landroid/graphics/Rect;"
402 "V",
403 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTests_nativeSetNonPODDatatype)
405 { "nativeGetNonPODDatatype",
408 "Ljava/lang/Object;",
409 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTests_nativeGetNonPODDatatype)
411 { "nativeMethod",
415 "I",
416 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTests_nativeMethod)
418 { "nativeMethodOtherP0",
422 "D",
423 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTests_nativeMethodOtherP0)
425 { "nativeAddStructB",
428 "Lorg/chromium/example/jni_generator/SampleForTests$InnerStructB;"
430 "V",
431 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTests_nativeAddStructB)
433 { "nativeIterateAndDoSomethingWithStructB",
437 "V",
438 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTests_nativeIterateAndDoSomethingWithStructB)
440 { "nativeReturnAString",
444 "Ljava/lang/String;",
445 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTests_nativeReturnAString)
449 static bool RegisterNativesImpl(JNIEnv* env) {
451 g_InnerStructA_clazz = reinterpret_cast<jclass>(env->NewGlobalRef(
452 base::android::GetClass(env, kInnerStructAClassPath).obj()));
453 g_SampleForTests_clazz = reinterpret_cast<jclass>(env->NewGlobalRef(
454 base::android::GetClass(env, kSampleForTestsClassPath).obj()));
455 g_InnerStructB_clazz = reinterpret_cast<jclass>(env->NewGlobalRef(
456 base::android::GetClass(env, kInnerStructBClassPath).obj()));
458 const int kMethodsSampleForTestsSize = arraysize(kMethodsSampleForTests);
460 if (env->RegisterNatives(SampleForTests_clazz(env),
461 kMethodsSampleForTests,
462 kMethodsSampleForTestsSize) < 0) {
463 jni_generator::HandleRegistrationError(
464 env, SampleForTests_clazz(env), __FILE__);
465 return false;
468 return true;
471 } // namespace android
472 } // namespace base
474 #endif // org_chromium_example_jni_generator_SampleForTests_JNI