Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: base/android/jni_generator/testNativeExportsOptionalOption.golden

Issue 1279163006: jni_generator: Wrap all native methods in stubs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove separate forward declaration section entirely Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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_generator/jni_generator_helper.h" 15 #include "base/android/jni_generator/jni_generator_helper.h"
16 16
17 #include "base/android/jni_int_wrapper.h" 17 #include "base/android/jni_int_wrapper.h"
18 18
19 // Step 1: forward declarations. 19 // Step 1: forward declarations.
20 namespace { 20 namespace {
21 const char kSampleForTestsClassPath[] = 21 const char kSampleForTestsClassPath[] =
22 "org/chromium/example/jni_generator/SampleForTests"; 22 "org/chromium/example/jni_generator/SampleForTests";
23 // Leaking this jclass as we cannot use LazyInstance from some threads. 23 // Leaking this jclass as we cannot use LazyInstance from some threads.
24 base::subtle::AtomicWord g_SampleForTests_clazz __attribute__((unused)) = 0; 24 base::subtle::AtomicWord g_SampleForTests_clazz __attribute__((unused)) = 0;
25 #define SampleForTests_clazz(env) base::android::LazyGetClass(env, kSampleForTes tsClassPath, &g_SampleForTests_clazz) 25 #define SampleForTests_clazz(env) base::android::LazyGetClass(env, kSampleForTes tsClassPath, &g_SampleForTests_clazz)
26 26
27 } // namespace 27 } // namespace
28 28
29 extern "C" {
30
31 static jint Init(JNIEnv* env, jobject jcaller);
32
33 __attribute__((visibility("default")))
34 jint
35 Java_org_chromium_example_jni_1generator_SampleForTests_00024MyInnerClass_na tiveInit(JNIEnv*
36 env, jobject jcaller) {
37 return Init(env, jcaller);
38 }
39
40 static jint Init(JNIEnv* env, jobject jcaller);
41
42 __attribute__((visibility("default")))
43 jint
44 Java_org_chromium_example_jni_1generator_SampleForTests_00024MyOtherInnerCla ss_nativeInit(JNIEnv*
45 env, jobject jcaller) {
46 return Init(env, jcaller);
47 }
48
49 }; // extern "C"
50
51 // Step 2: method stubs. 29 // Step 2: method stubs.
52 30 extern "C" __attribute__((visibility("default")))
53 extern "C" {
54 __attribute__((visibility("default")))
55 jint 31 jint
56 Java_org_chromium_example_jni_1generator_SampleForTests_nativeStaticMethod(J NIEnv* 32 Java_org_chromium_example_jni_1generator_SampleForTests_nativeStaticMethod(J NIEnv*
57 env, 33 env,
58 jobject jcaller, 34 jobject jcaller,
59 jlong nativeTest, 35 jlong nativeTest,
60 jint arg1) { 36 jint arg1) {
61 Test* native = reinterpret_cast<Test*>(nativeTest); 37 Test* native = reinterpret_cast<Test*>(nativeTest);
62 CHECK_NATIVE_PTR(env, jcaller, native, "StaticMethod", 0); 38 CHECK_NATIVE_PTR(env, jcaller, native, "StaticMethod", 0);
63 return native->StaticMethod(env, jcaller, arg1); 39 return native->StaticMethod(env, jcaller, arg1);
64 } 40 }
65 41
66 __attribute__((visibility("default"))) 42 extern "C" __attribute__((visibility("default")))
67 jint 43 jint
68 Java_org_chromium_example_jni_1generator_SampleForTests_nativeMethod(JNIEnv* 44 Java_org_chromium_example_jni_1generator_SampleForTests_nativeMethod(JNIEnv*
69 env, 45 env,
70 jobject jcaller, 46 jobject jcaller,
71 jlong nativeTest, 47 jlong nativeTest,
72 jint arg1) { 48 jint arg1) {
73 Test* native = reinterpret_cast<Test*>(nativeTest); 49 Test* native = reinterpret_cast<Test*>(nativeTest);
74 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0); 50 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0);
75 return native->Method(env, jcaller, arg1); 51 return native->Method(env, jcaller, arg1);
76 } 52 }
77 53
54 static jint Init(JNIEnv* env, jobject jcaller);
55
56 extern "C" __attribute__((visibility("default")))
57 jint
58 Java_org_chromium_example_jni_1generator_SampleForTests_00024MyInnerClass_na tiveInit(JNIEnv*
59 env, jobject jcaller) {
60 return Init(env, jcaller);
61 }
62
63 static jint Init(JNIEnv* env, jobject jcaller);
64
65 extern "C" __attribute__((visibility("default")))
66 jint
67 Java_org_chromium_example_jni_1generator_SampleForTests_00024MyOtherInnerCla ss_nativeInit(JNIEnv*
68 env, jobject jcaller) {
69 return Init(env, jcaller);
70 }
71
78 static base::subtle::AtomicWord g_SampleForTests_testMethodWithParam = 0; 72 static base::subtle::AtomicWord g_SampleForTests_testMethodWithParam = 0;
79 static void Java_SampleForTests_testMethodWithParam(JNIEnv* env, jobject obj, 73 static void Java_SampleForTests_testMethodWithParam(JNIEnv* env, jobject obj,
80 JniIntWrapper iParam) { 74 JniIntWrapper iParam) {
81 /* Must call RegisterNativesImpl() */ 75 /* Must call RegisterNativesImpl() */
82 CHECK_CLAZZ(env, obj, 76 CHECK_CLAZZ(env, obj,
83 SampleForTests_clazz(env)); 77 SampleForTests_clazz(env));
84 jmethodID method_id = 78 jmethodID method_id =
85 base::android::MethodID::LazyGet< 79 base::android::MethodID::LazyGet<
86 base::android::MethodID::TYPE_INSTANCE>( 80 base::android::MethodID::TYPE_INSTANCE>(
87 env, SampleForTests_clazz(env), 81 env, SampleForTests_clazz(env),
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 ")" 185 ")"
192 "Ljava/lang/String;", 186 "Ljava/lang/String;",
193 &g_SampleForTests_testStaticMethodWithNoParam); 187 &g_SampleForTests_testStaticMethodWithNoParam);
194 188
195 jstring ret = 189 jstring ret =
196 static_cast<jstring>(env->CallStaticObjectMethod(SampleForTests_clazz(env), 190 static_cast<jstring>(env->CallStaticObjectMethod(SampleForTests_clazz(env),
197 method_id)); 191 method_id));
198 jni_generator::CheckException(env); 192 jni_generator::CheckException(env);
199 return base::android::ScopedJavaLocalRef<jstring>(env, ret); 193 return base::android::ScopedJavaLocalRef<jstring>(env, ret);
200 } 194 }
201 }; // extern "C"
202 195
203 // Step 3: RegisterNatives. 196 // Step 3: RegisterNatives.
204 197
205 static const JNINativeMethod kMethodsMyOtherInnerClass[] = { 198 static const JNINativeMethod kMethodsMyOtherInnerClass[] = {
206 { "nativeInit", 199 { "nativeInit",
207 "(" 200 "("
208 ")" 201 ")"
209 "I", 202 "I",
210 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTe sts_00024MyOtherInnerClass_nativeInit) 203 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTe sts_00024MyOtherInnerClass_nativeInit)
211 }, 204 },
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 return true; 272 return true;
280 } 273 }
281 274
282 extern "C" JNIEXPORT bool JNICALL 275 extern "C" JNIEXPORT bool JNICALL
283 Java_org_chromium_example_jni_1generator_SampleForTests_nativeInitNativeClass(JN IEnv* 276 Java_org_chromium_example_jni_1generator_SampleForTests_nativeInitNativeClass(JN IEnv*
284 env, jclass clazz) { 277 env, jclass clazz) {
285 return RegisterNativesImpl(env, clazz); 278 return RegisterNativesImpl(env, clazz);
286 } 279 }
287 280
288 #endif // org_chromium_example_jni_generator_SampleForTests_JNI 281 #endif // org_chromium_example_jni_generator_SampleForTests_JNI
OLDNEW
« no previous file with comments | « base/android/jni_generator/testNativeExportsOption.golden ('k') | base/android/jni_generator/testNatives.golden » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698