Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / base / android / jni_generator / testNativeExportsOptionalOption.golden
blobe2cf051775061ebef7c7d7d0327d56260f85b422
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 kSampleForTestsClassPath[] =
22     "org/chromium/example/jni_generator/SampleForTests";
23 // Leaking this jclass as we cannot use LazyInstance from some threads.
24 base::subtle::AtomicWord g_SampleForTests_clazz __attribute__((unused)) = 0;
25 #define SampleForTests_clazz(env) base::android::LazyGetClass(env, kSampleForTestsClassPath, &g_SampleForTests_clazz)
27 }  // namespace
29 // Step 2: method stubs.
30 extern "C" __attribute__((visibility("default")))
31 jint
32     Java_org_chromium_example_jni_1generator_SampleForTests_nativeStaticMethod(JNIEnv*
33     env,
34     jobject jcaller,
35     jlong nativeTest,
36     jint arg1) {
37   Test* native = reinterpret_cast<Test*>(nativeTest);
38   CHECK_NATIVE_PTR(env, jcaller, native, "StaticMethod", 0);
39   return native->StaticMethod(env, JavaParamRef<jobject>(env, jcaller), arg1);
42 extern "C" __attribute__((visibility("default")))
43 jint
44     Java_org_chromium_example_jni_1generator_SampleForTests_nativeMethod(JNIEnv*
45     env,
46     jobject jcaller,
47     jlong nativeTest,
48     jint arg1) {
49   Test* native = reinterpret_cast<Test*>(nativeTest);
50   CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0);
51   return native->Method(env, JavaParamRef<jobject>(env, jcaller), arg1);
54 static jint Init(JNIEnv* env, const JavaParamRef<jobject>& jcaller);
56 extern "C" __attribute__((visibility("default")))
57 jint
58     Java_org_chromium_example_jni_1generator_SampleForTests_00024MyInnerClass_nativeInit(JNIEnv*
59     env, jobject jcaller) {
60   return Init(env, JavaParamRef<jobject>(env, jcaller));
63 static jint Init(JNIEnv* env, const JavaParamRef<jobject>& jcaller);
65 extern "C" __attribute__((visibility("default")))
66 jint
67     Java_org_chromium_example_jni_1generator_SampleForTests_00024MyOtherInnerClass_nativeInit(JNIEnv*
68     env, jobject jcaller) {
69   return Init(env, JavaParamRef<jobject>(env, jcaller));
72 static base::subtle::AtomicWord g_SampleForTests_testMethodWithParam = 0;
73 static void Java_SampleForTests_testMethodWithParam(JNIEnv* env, jobject obj,
74     JniIntWrapper iParam) {
75   /* Must call RegisterNativesImpl()  */
76   CHECK_CLAZZ(env, obj,
77       SampleForTests_clazz(env));
78   jmethodID method_id =
79       base::android::MethodID::LazyGet<
80       base::android::MethodID::TYPE_INSTANCE>(
81       env, SampleForTests_clazz(env),
82       "testMethodWithParam",
84 "("
85 "I"
86 ")"
87 "V",
88       &g_SampleForTests_testMethodWithParam);
90      env->CallVoidMethod(obj,
91           method_id, as_jint(iParam));
92   jni_generator::CheckException(env);
96 static base::subtle::AtomicWord g_SampleForTests_testMethodWithParamAndReturn =
97     0;
98 static ScopedJavaLocalRef<jstring>
99     Java_SampleForTests_testMethodWithParamAndReturn(JNIEnv* env, jobject obj,
100     JniIntWrapper iParam) {
101   /* Must call RegisterNativesImpl()  */
102   CHECK_CLAZZ(env, obj,
103       SampleForTests_clazz(env), NULL);
104   jmethodID method_id =
105       base::android::MethodID::LazyGet<
106       base::android::MethodID::TYPE_INSTANCE>(
107       env, SampleForTests_clazz(env),
108       "testMethodWithParamAndReturn",
113 "Ljava/lang/String;",
114       &g_SampleForTests_testMethodWithParamAndReturn);
116   jstring ret =
117       static_cast<jstring>(env->CallObjectMethod(obj,
118           method_id, as_jint(iParam)));
119   jni_generator::CheckException(env);
120   return ScopedJavaLocalRef<jstring>(env, ret);
123 static base::subtle::AtomicWord g_SampleForTests_testStaticMethodWithParam = 0;
124 static jint Java_SampleForTests_testStaticMethodWithParam(JNIEnv* env,
125     JniIntWrapper iParam) {
126   /* Must call RegisterNativesImpl()  */
127   CHECK_CLAZZ(env, SampleForTests_clazz(env),
128       SampleForTests_clazz(env), 0);
129   jmethodID method_id =
130       base::android::MethodID::LazyGet<
131       base::android::MethodID::TYPE_STATIC>(
132       env, SampleForTests_clazz(env),
133       "testStaticMethodWithParam",
138 "I",
139       &g_SampleForTests_testStaticMethodWithParam);
141   jint ret =
142       env->CallStaticIntMethod(SampleForTests_clazz(env),
143           method_id, as_jint(iParam));
144   jni_generator::CheckException(env);
145   return ret;
148 static base::subtle::AtomicWord g_SampleForTests_testMethodWithNoParam = 0;
149 static jdouble Java_SampleForTests_testMethodWithNoParam(JNIEnv* env) {
150   /* Must call RegisterNativesImpl()  */
151   CHECK_CLAZZ(env, SampleForTests_clazz(env),
152       SampleForTests_clazz(env), 0);
153   jmethodID method_id =
154       base::android::MethodID::LazyGet<
155       base::android::MethodID::TYPE_STATIC>(
156       env, SampleForTests_clazz(env),
157       "testMethodWithNoParam",
161 "D",
162       &g_SampleForTests_testMethodWithNoParam);
164   jdouble ret =
165       env->CallStaticDoubleMethod(SampleForTests_clazz(env),
166           method_id);
167   jni_generator::CheckException(env);
168   return ret;
171 static base::subtle::AtomicWord g_SampleForTests_testStaticMethodWithNoParam =
172     0;
173 static ScopedJavaLocalRef<jstring>
174     Java_SampleForTests_testStaticMethodWithNoParam(JNIEnv* env) {
175   /* Must call RegisterNativesImpl()  */
176   CHECK_CLAZZ(env, SampleForTests_clazz(env),
177       SampleForTests_clazz(env), NULL);
178   jmethodID method_id =
179       base::android::MethodID::LazyGet<
180       base::android::MethodID::TYPE_STATIC>(
181       env, SampleForTests_clazz(env),
182       "testStaticMethodWithNoParam",
186 "Ljava/lang/String;",
187       &g_SampleForTests_testStaticMethodWithNoParam);
189   jstring ret =
190 static_cast<jstring>(env->CallStaticObjectMethod(SampleForTests_clazz(env),
191           method_id));
192   jni_generator::CheckException(env);
193   return ScopedJavaLocalRef<jstring>(env, ret);
196 // Step 3: RegisterNatives.
198 static const JNINativeMethod kMethodsMyOtherInnerClass[] = {
199     { "nativeInit",
202 "I",
203     reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTests_00024MyOtherInnerClass_nativeInit)
204     },
207 static const JNINativeMethod kMethodsMyInnerClass[] = {
208     { "nativeInit",
211 "I",
212     reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTests_00024MyInnerClass_nativeInit)
213     },
216 static const JNINativeMethod kMethodsSampleForTests[] = {
217     { "nativeStaticMethod",
222 "I",
223     reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTests_nativeStaticMethod)
224     },
225     { "nativeMethod",
230 "I",
231     reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTests_nativeMethod)
232     },
235 static bool RegisterNativesImpl(JNIEnv* env, jclass clazz) {
236   if (base::android::IsManualJniRegistrationDisabled()) return true;
238   base::subtle::Release_Store(&g_SampleForTests_clazz,
239       static_cast<base::subtle::AtomicWord>(env->NewWeakGlobalRef(clazz));
241   const int kMethodsMyOtherInnerClassSize =
242       arraysize(kMethodsMyOtherInnerClass);
244   if (env->RegisterNatives(MyOtherInnerClass_clazz(env),
245                            kMethodsMyOtherInnerClass,
246                            kMethodsMyOtherInnerClassSize) < 0) {
247     jni_generator::HandleRegistrationError(
248         env, MyOtherInnerClass_clazz(env), __FILE__);
249     return false;
250   }
252   const int kMethodsMyInnerClassSize = arraysize(kMethodsMyInnerClass);
254   if (env->RegisterNatives(MyInnerClass_clazz(env),
255                            kMethodsMyInnerClass,
256                            kMethodsMyInnerClassSize) < 0) {
257     jni_generator::HandleRegistrationError(
258         env, MyInnerClass_clazz(env), __FILE__);
259     return false;
260   }
262   const int kMethodsSampleForTestsSize = arraysize(kMethodsSampleForTests);
264   if (env->RegisterNatives(SampleForTests_clazz(env),
265                            kMethodsSampleForTests,
266                            kMethodsSampleForTestsSize) < 0) {
267     jni_generator::HandleRegistrationError(
268         env, SampleForTests_clazz(env), __FILE__);
269     return false;
270   }
272   return true;
275 extern "C" JNIEXPORT bool JNICALL
276 Java_org_chromium_example_jni_1generator_SampleForTests_nativeInitNativeClass(JNIEnv*
277     env, jclass clazz) {
278   return RegisterNativesImpl(env, clazz);
281 #endif  // org_chromium_example_jni_generator_SampleForTests_JNI