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

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

Issue 298973005: Updating JNIAdditionalImport to allow more than one import. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Follow review Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 24
25 } // namespace 25 } // namespace
26 26
27 static void DoSomething(JNIEnv* env, jclass jcaller, 27 static void DoSomething(JNIEnv* env, jclass jcaller,
28 jobject callback); 28 jobject callback);
29 29
30 static void DoSomething(JNIEnv* env, jclass jcaller,
31 jobject callback1,
32 jobject callback2);
33
30 // Step 2: method stubs. 34 // Step 2: method stubs.
31 35
32 static base::subtle::AtomicWord g_Foo_calledByNative = 0; 36 static base::subtle::AtomicWord g_Foo_calledByNativeV_OCFBC = 0;
33 static void Java_Foo_calledByNative(JNIEnv* env, jobject callback) { 37 static void Java_Foo_calledByNativeV_OCFBC(JNIEnv* env, jobject callback) {
34 /* Must call RegisterNativesImpl() */ 38 /* Must call RegisterNativesImpl() */
35 CHECK_CLAZZ(env, g_Foo_clazz, 39 CHECK_CLAZZ(env, g_Foo_clazz,
36 g_Foo_clazz); 40 g_Foo_clazz);
37 jmethodID method_id = 41 jmethodID method_id =
38 base::android::MethodID::LazyGet< 42 base::android::MethodID::LazyGet<
39 base::android::MethodID::TYPE_STATIC>( 43 base::android::MethodID::TYPE_STATIC>(
40 env, g_Foo_clazz, 44 env, g_Foo_clazz,
41 "calledByNative", 45 "calledByNative",
42 46
43 "(" 47 "("
44 "Lorg/chromium/foo/Bar$Callback;" 48 "Lorg/chromium/foo/Bar$Callback;"
45 ")" 49 ")"
46 "V", 50 "V",
47 &g_Foo_calledByNative); 51 &g_Foo_calledByNativeV_OCFBC);
48 52
49 env->CallStaticVoidMethod(g_Foo_clazz, 53 env->CallStaticVoidMethod(g_Foo_clazz,
50 method_id, callback); 54 method_id, callback);
51 jni_generator::CheckException(env); 55 jni_generator::CheckException(env);
52 56
53 } 57 }
54 58
59 static base::subtle::AtomicWord g_Foo_calledByNativeV_OCFBC_OCFBC = 0;
60 static void Java_Foo_calledByNativeV_OCFBC_OCFBC(JNIEnv* env, jobject callback1,
61 jobject callback2) {
62 /* Must call RegisterNativesImpl() */
63 CHECK_CLAZZ(env, g_Foo_clazz,
64 g_Foo_clazz);
65 jmethodID method_id =
66 base::android::MethodID::LazyGet<
67 base::android::MethodID::TYPE_STATIC>(
68 env, g_Foo_clazz,
bulach 2014/05/22 17:13:45 as above, this g_Foo_clazz is wrong, but that's ju
qsr 2014/05/23 08:11:38 Done.
69 "calledByNative",
70
71 "("
72 "Lorg/chromium/foo/Bar2$Callback;"
73 "Lorg/chromium/foo/Bar3$Callback;"
74 ")"
75 "V",
76 &g_Foo_calledByNativeV_OCFBC_OCFBC);
77
78 env->CallStaticVoidMethod(g_Foo_clazz,
79 method_id, callback1, callback2);
80 jni_generator::CheckException(env);
81
82 }
83
55 // Step 3: RegisterNatives. 84 // Step 3: RegisterNatives.
56 85
57 static const JNINativeMethod kMethodsFoo[] = { 86 static const JNINativeMethod kMethodsFoo[] = {
58 { "nativeDoSomething", 87 { "nativeDoSomething",
59 "(" 88 "("
60 "Lorg/chromium/foo/Bar$Callback;" 89 "Lorg/chromium/foo/Bar$Callback;"
61 ")" 90 ")"
62 "V", reinterpret_cast<void*>(DoSomething) }, 91 "V", reinterpret_cast<void*>(DoSomething) },
92 { "nativeDoSomething",
93 "("
94 "Lorg/chromium/foo/Bar2$Callback;"
95 "Lorg/chromium/foo/Bar3$Callback;"
96 ")"
97 "V", reinterpret_cast<void*>(DoSomething) },
63 }; 98 };
64 99
65 static bool RegisterNativesImpl(JNIEnv* env) { 100 static bool RegisterNativesImpl(JNIEnv* env) {
66 g_Foo_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( 101 g_Foo_clazz = reinterpret_cast<jclass>(env->NewGlobalRef(
67 base::android::GetClass(env, kFooClassPath).obj())); 102 base::android::GetClass(env, kFooClassPath).obj()));
68 103
69 const int kMethodsFooSize = arraysize(kMethodsFoo); 104 const int kMethodsFooSize = arraysize(kMethodsFoo);
70 105
71 if (env->RegisterNatives(g_Foo_clazz, 106 if (env->RegisterNatives(g_Foo_clazz,
72 kMethodsFoo, 107 kMethodsFoo,
73 kMethodsFooSize) < 0) { 108 kMethodsFooSize) < 0) {
74 jni_generator::HandleRegistrationError( 109 jni_generator::HandleRegistrationError(
75 env, g_Foo_clazz, __FILE__); 110 env, g_Foo_clazz, __FILE__);
76 return false; 111 return false;
77 } 112 }
78 113
79 return true; 114 return true;
80 } 115 }
81 116
82 #endif // org_chromium_foo_Foo_JNI 117 #endif // org_chromium_foo_Foo_JNI
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698