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

Side by Side Diff: base/android/jni_generator/testSingleJNIAdditionalImport.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
« no previous file with comments | « base/android/jni_generator/testPureNativeMethodsOption.golden ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/foo/Foo 8 // org/chromium/foo/Foo
9 9
10 #ifndef org_chromium_foo_Foo_JNI 10 #ifndef org_chromium_foo_Foo_JNI
11 #define org_chromium_foo_Foo_JNI 11 #define org_chromium_foo_Foo_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 kFooClassPath[] = "org/chromium/foo/Foo"; 21 const char kFooClassPath[] = "org/chromium/foo/Foo";
22 // Leaking this jclass as we cannot use LazyInstance from some threads. 22 // Leaking this jclass as we cannot use LazyInstance from some threads.
23 jclass g_Foo_clazz = NULL; 23 jclass g_Foo_clazz = NULL;
24 #define Foo_clazz(env) g_Foo_clazz 24 #define Foo_clazz(env) g_Foo_clazz
25 25
26 } // namespace 26 } // namespace
27 27
28 // Step 2: method stubs.
29
28 static void DoSomething(JNIEnv* env, jclass jcaller, 30 static void DoSomething(JNIEnv* env, jclass jcaller,
29 jobject callback); 31 jobject callback);
30 32
31 // Step 2: method stubs. 33 static void Java_org_chromium_foo_Foo_nativeDoSomething(JNIEnv* env, jclass
34 jcaller,
35 jobject callback) {
36 return DoSomething(env, jcaller, callback);
37 }
32 38
33 static base::subtle::AtomicWord g_Foo_calledByNative = 0; 39 static base::subtle::AtomicWord g_Foo_calledByNative = 0;
34 static void Java_Foo_calledByNative(JNIEnv* env, jobject callback) { 40 static void Java_Foo_calledByNative(JNIEnv* env, jobject callback) {
35 /* Must call RegisterNativesImpl() */ 41 /* Must call RegisterNativesImpl() */
36 CHECK_CLAZZ(env, Foo_clazz(env), 42 CHECK_CLAZZ(env, Foo_clazz(env),
37 Foo_clazz(env)); 43 Foo_clazz(env));
38 jmethodID method_id = 44 jmethodID method_id =
39 base::android::MethodID::LazyGet< 45 base::android::MethodID::LazyGet<
40 base::android::MethodID::TYPE_STATIC>( 46 base::android::MethodID::TYPE_STATIC>(
41 env, Foo_clazz(env), 47 env, Foo_clazz(env),
(...skipping 11 matching lines...) Expand all
53 59
54 } 60 }
55 61
56 // Step 3: RegisterNatives. 62 // Step 3: RegisterNatives.
57 63
58 static const JNINativeMethod kMethodsFoo[] = { 64 static const JNINativeMethod kMethodsFoo[] = {
59 { "nativeDoSomething", 65 { "nativeDoSomething",
60 "(" 66 "("
61 "Lorg/chromium/foo/Bar$Callback;" 67 "Lorg/chromium/foo/Bar$Callback;"
62 ")" 68 ")"
63 "V", reinterpret_cast<void*>(DoSomething) }, 69 "V", reinterpret_cast<void*>(Java_org_chromium_foo_Foo_nativeDoSomething) },
64 }; 70 };
65 71
66 static bool RegisterNativesImpl(JNIEnv* env) { 72 static bool RegisterNativesImpl(JNIEnv* env) {
67 73
68 g_Foo_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( 74 g_Foo_clazz = reinterpret_cast<jclass>(env->NewGlobalRef(
69 base::android::GetClass(env, kFooClassPath).obj())); 75 base::android::GetClass(env, kFooClassPath).obj()));
70 76
71 const int kMethodsFooSize = arraysize(kMethodsFoo); 77 const int kMethodsFooSize = arraysize(kMethodsFoo);
72 78
73 if (env->RegisterNatives(Foo_clazz(env), 79 if (env->RegisterNatives(Foo_clazz(env),
74 kMethodsFoo, 80 kMethodsFoo,
75 kMethodsFooSize) < 0) { 81 kMethodsFooSize) < 0) {
76 jni_generator::HandleRegistrationError( 82 jni_generator::HandleRegistrationError(
77 env, Foo_clazz(env), __FILE__); 83 env, Foo_clazz(env), __FILE__);
78 return false; 84 return false;
79 } 85 }
80 86
81 return true; 87 return true;
82 } 88 }
83 89
84 #endif // org_chromium_foo_Foo_JNI 90 #endif // org_chromium_foo_Foo_JNI
OLDNEW
« no previous file with comments | « base/android/jni_generator/testPureNativeMethodsOption.golden ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698