Roll src/third_party/WebKit b3f094a:f697bbd (svn 194310:194313)
[chromium-blink-merge.git] / base / android / jni_generator / testNativeExportsOptionalOption.golden
blobf47cb98e187256f6f41170bb9496d88945b38012
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 extern "C" {
31 static jint Init(JNIEnv* env, jobject jcaller);
33 __attribute__((visibility("default")))
34 jint
35     Java_org_chromium_example_jni_1generator_SampleForTests_00024MyInnerClass_nativeInit(JNIEnv*
36     env, jobject jcaller) {
37   return Init(env, jcaller);
40 static jint Init(JNIEnv* env, jobject jcaller);
42 __attribute__((visibility("default")))
43 jint
44     Java_org_chromium_example_jni_1generator_SampleForTests_00024MyOtherInnerClass_nativeInit(JNIEnv*
45     env, jobject jcaller) {
46   return Init(env, jcaller);
49 };  // extern "C"
51 // Step 2: method stubs.
53 extern "C" {
54 __attribute__((visibility("default")))
55 jint
56     Java_org_chromium_example_jni_1generator_SampleForTests_nativeStaticMethod(JNIEnv*
57     env,
58     jobject jcaller,
59     jlong nativeTest,
60     jint arg1) {
61   Test* native = reinterpret_cast<Test*>(nativeTest);
62   CHECK_NATIVE_PTR(env, jcaller, native, "StaticMethod", 0);
63   return native->StaticMethod(env, jcaller, arg1);
66 __attribute__((visibility("default")))
67 jint
68     Java_org_chromium_example_jni_1generator_SampleForTests_nativeMethod(JNIEnv*
69     env,
70     jobject jcaller,
71     jlong nativeTest,
72     jint arg1) {
73   Test* native = reinterpret_cast<Test*>(nativeTest);
74   CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0);
75   return native->Method(env, jcaller, arg1);
78 static base::subtle::AtomicWord g_SampleForTests_testMethodWithParam = 0;
79 static void Java_SampleForTests_testMethodWithParam(JNIEnv* env, jobject obj,
80     JniIntWrapper iParam) {
81   /* Must call RegisterNativesImpl()  */
82   CHECK_CLAZZ(env, obj,
83       SampleForTests_clazz(env));
84   jmethodID method_id =
85       base::android::MethodID::LazyGet<
86       base::android::MethodID::TYPE_INSTANCE>(
87       env, SampleForTests_clazz(env),
88       "testMethodWithParam",
90 "("
91 "I"
92 ")"
93 "V",
94       &g_SampleForTests_testMethodWithParam);
96      env->CallVoidMethod(obj,
97           method_id, as_jint(iParam));
98   jni_generator::CheckException(env);
102 static base::subtle::AtomicWord g_SampleForTests_testMethodWithParamAndReturn =
103     0;
104 static base::android::ScopedJavaLocalRef<jstring>
105     Java_SampleForTests_testMethodWithParamAndReturn(JNIEnv* env, jobject obj,
106     JniIntWrapper iParam) {
107   /* Must call RegisterNativesImpl()  */
108   CHECK_CLAZZ(env, obj,
109       SampleForTests_clazz(env), NULL);
110   jmethodID method_id =
111       base::android::MethodID::LazyGet<
112       base::android::MethodID::TYPE_INSTANCE>(
113       env, SampleForTests_clazz(env),
114       "testMethodWithParamAndReturn",
119 "Ljava/lang/String;",
120       &g_SampleForTests_testMethodWithParamAndReturn);
122   jstring ret =
123       static_cast<jstring>(env->CallObjectMethod(obj,
124           method_id, as_jint(iParam)));
125   jni_generator::CheckException(env);
126   return base::android::ScopedJavaLocalRef<jstring>(env, ret);
129 static base::subtle::AtomicWord g_SampleForTests_testStaticMethodWithParam = 0;
130 static jint Java_SampleForTests_testStaticMethodWithParam(JNIEnv* env,
131     JniIntWrapper iParam) {
132   /* Must call RegisterNativesImpl()  */
133   CHECK_CLAZZ(env, SampleForTests_clazz(env),
134       SampleForTests_clazz(env), 0);
135   jmethodID method_id =
136       base::android::MethodID::LazyGet<
137       base::android::MethodID::TYPE_STATIC>(
138       env, SampleForTests_clazz(env),
139       "testStaticMethodWithParam",
144 "I",
145       &g_SampleForTests_testStaticMethodWithParam);
147   jint ret =
148       env->CallStaticIntMethod(SampleForTests_clazz(env),
149           method_id, as_jint(iParam));
150   jni_generator::CheckException(env);
151   return ret;
154 static base::subtle::AtomicWord g_SampleForTests_testMethodWithNoParam = 0;
155 static jdouble Java_SampleForTests_testMethodWithNoParam(JNIEnv* env) {
156   /* Must call RegisterNativesImpl()  */
157   CHECK_CLAZZ(env, SampleForTests_clazz(env),
158       SampleForTests_clazz(env), 0);
159   jmethodID method_id =
160       base::android::MethodID::LazyGet<
161       base::android::MethodID::TYPE_STATIC>(
162       env, SampleForTests_clazz(env),
163       "testMethodWithNoParam",
167 "D",
168       &g_SampleForTests_testMethodWithNoParam);
170   jdouble ret =
171       env->CallStaticDoubleMethod(SampleForTests_clazz(env),
172           method_id);
173   jni_generator::CheckException(env);
174   return ret;
177 static base::subtle::AtomicWord g_SampleForTests_testStaticMethodWithNoParam =
178     0;
179 static base::android::ScopedJavaLocalRef<jstring>
180     Java_SampleForTests_testStaticMethodWithNoParam(JNIEnv* env) {
181   /* Must call RegisterNativesImpl()  */
182   CHECK_CLAZZ(env, SampleForTests_clazz(env),
183       SampleForTests_clazz(env), NULL);
184   jmethodID method_id =
185       base::android::MethodID::LazyGet<
186       base::android::MethodID::TYPE_STATIC>(
187       env, SampleForTests_clazz(env),
188       "testStaticMethodWithNoParam",
192 "Ljava/lang/String;",
193       &g_SampleForTests_testStaticMethodWithNoParam);
195   jstring ret =
196 static_cast<jstring>(env->CallStaticObjectMethod(SampleForTests_clazz(env),
197           method_id));
198   jni_generator::CheckException(env);
199   return base::android::ScopedJavaLocalRef<jstring>(env, ret);
201 };  // extern "C"
203 // Step 3: RegisterNatives.
205 static const JNINativeMethod kMethodsMyOtherInnerClass[] = {
206     { "nativeInit",
209 "I",
210     reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTests_00024MyOtherInnerClass_nativeInit)
211     },
214 static const JNINativeMethod kMethodsMyInnerClass[] = {
215     { "nativeInit",
218 "I",
219     reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTests_00024MyInnerClass_nativeInit)
220     },
223 static const JNINativeMethod kMethodsSampleForTests[] = {
224     { "nativeStaticMethod",
229 "I",
230     reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTests_nativeStaticMethod)
231     },
232     { "nativeMethod",
237 "I",
238     reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTests_nativeMethod)
239     },
242 static bool RegisterNativesImpl(JNIEnv* env, jclass clazz) {
243   if (base::android::IsManualJniRegistrationDisabled()) return true;
245   base::subtle::Release_Store(&g_SampleForTests_clazz,
246       static_cast<base::subtle::AtomicWord>(env->NewWeakGlobalRef(clazz));
248   const int kMethodsMyOtherInnerClassSize =
249       arraysize(kMethodsMyOtherInnerClass);
251   if (env->RegisterNatives(MyOtherInnerClass_clazz(env),
252                            kMethodsMyOtherInnerClass,
253                            kMethodsMyOtherInnerClassSize) < 0) {
254     jni_generator::HandleRegistrationError(
255         env, MyOtherInnerClass_clazz(env), __FILE__);
256     return false;
257   }
259   const int kMethodsMyInnerClassSize = arraysize(kMethodsMyInnerClass);
261   if (env->RegisterNatives(MyInnerClass_clazz(env),
262                            kMethodsMyInnerClass,
263                            kMethodsMyInnerClassSize) < 0) {
264     jni_generator::HandleRegistrationError(
265         env, MyInnerClass_clazz(env), __FILE__);
266     return false;
267   }
269   const int kMethodsSampleForTestsSize = arraysize(kMethodsSampleForTests);
271   if (env->RegisterNatives(SampleForTests_clazz(env),
272                            kMethodsSampleForTests,
273                            kMethodsSampleForTestsSize) < 0) {
274     jni_generator::HandleRegistrationError(
275         env, SampleForTests_clazz(env), __FILE__);
276     return false;
277   }
279   return true;
282 extern "C" JNIEXPORT bool JNICALL
283 Java_org_chromium_example_jni_1generator_SampleForTests_nativeInitNativeClass(JNIEnv*
284     env, jclass clazz) {
285   return RegisterNativesImpl(env, clazz);
288 #endif  // org_chromium_example_jni_generator_SampleForTests_JNI