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

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

Issue 147533004: Remove unneeded JNI registrations. (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Rebaes, added native_exports switch, don't remove empty RegisterNatives. Created 6 years, 8 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
(Empty)
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
3 // found in the LICENSE file.
4
5 // This file is autogenerated by
6 // base/android/jni_generator/jni_generator.py
7 // For
8 // org/chromium/example/jni_generator/Test
9
10 #ifndef org_chromium_example_jni_generator_Test_JNI
11 #define org_chromium_example_jni_generator_Test_JNI
12
13 #include <jni.h>
14
15 #include "base/android/jni_generator/jni_generator_helper.h"
16
17 // Step 1: forward declarations.
18 namespace {
19 const char kTestClassPath[] = "org/chromium/example/jni_generator/Test";
20 // Leaking this jclass as we cannot use LazyInstance from some threads.
21 jclass g_Test_clazz = NULL;
22
23 } // namespace
24
25 // Step 2: method stubs.
26
27 extern "C" {
28 static jint Method(JNIEnv* env, jobject jcaller,
bulach 2014/04/14 13:16:02 shouldn't this method name start with Java_org_chr
ostap 2014/04/15 23:30:20 No, here it is as it defined in native code.
29 jlong nativeTest,
30 jint arg1) {
31 Test* native = reinterpret_cast<Test*>(nativeTest);
32 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0);
33 return native->Method(env, jcaller, arg1);
34 }
35
36 __attribute__((alias("Method"), visibility("default")))
37 jint Java_org_chromium_example_jni_1generator_Test_nativeMethod(JNIEnv* env,
bulach 2014/04/14 13:16:02 what's up with "1"generator? also: if I'm understa
ostap 2014/04/15 23:30:20 The class is org/chromium/example/jni_generator/Te
38 jobject jcaller,
39 jlong nativeTest,
40 jint arg1);
41
42 static base::subtle::AtomicWord g_Test_testMethodWithParam = 0;
43 static void Java_Test_testMethodWithParam(JNIEnv* env, jobject obj, jint iParam)
44 {
45 /* Must call RegisterNativesImpl() */
46 CHECK_CLAZZ(env, obj,
47 g_Test_clazz);
48 jmethodID method_id =
49 base::android::MethodID::LazyGet<
50 base::android::MethodID::TYPE_INSTANCE>(
51 env, g_Test_clazz,
52 "testMethodWithParam",
53
54 "("
55 "I"
56 ")"
57 "V",
58 &g_Test_testMethodWithParam);
59
60 env->CallVoidMethod(obj,
61 method_id, iParam);
62 jni_generator::CheckException(env);
63
64 }
65
66 static base::subtle::AtomicWord g_Test_testStaticMethodWithParam = 0;
67 static jint Java_Test_testStaticMethodWithParam(JNIEnv* env, jint iParam) {
68 /* Must call RegisterNativesImpl() */
69 CHECK_CLAZZ(env, g_Test_clazz,
70 g_Test_clazz, 0);
71 jmethodID method_id =
72 base::android::MethodID::LazyGet<
73 base::android::MethodID::TYPE_STATIC>(
74 env, g_Test_clazz,
75 "testStaticMethodWithParam",
76
77 "("
78 "I"
79 ")"
80 "I",
81 &g_Test_testStaticMethodWithParam);
82
83 jint ret =
84 env->CallStaticIntMethod(g_Test_clazz,
85 method_id, iParam);
86 jni_generator::CheckException(env);
87 return ret;
88 }
89
90 static base::subtle::AtomicWord g_Test_testMethodWithNoParam = 0;
91 static jdouble Java_Test_testMethodWithNoParam(JNIEnv* env) {
92 /* Must call RegisterNativesImpl() */
93 CHECK_CLAZZ(env, g_Test_clazz,
94 g_Test_clazz, 0);
95 jmethodID method_id =
96 base::android::MethodID::LazyGet<
97 base::android::MethodID::TYPE_STATIC>(
98 env, g_Test_clazz,
99 "testMethodWithNoParam",
100
101 "("
102 ")"
103 "D",
104 &g_Test_testMethodWithNoParam);
105
106 jdouble ret =
107 env->CallStaticDoubleMethod(g_Test_clazz,
108 method_id);
109 jni_generator::CheckException(env);
110 return ret;
111 }
112
113 static base::subtle::AtomicWord g_Test_testStaticMethodWithNoParam = 0;
114 static base::android::ScopedJavaLocalRef<jstring>
115 Java_Test_testStaticMethodWithNoParam(JNIEnv* env) {
116 /* Must call RegisterNativesImpl() */
117 CHECK_CLAZZ(env, g_Test_clazz,
118 g_Test_clazz, NULL);
119 jmethodID method_id =
120 base::android::MethodID::LazyGet<
121 base::android::MethodID::TYPE_STATIC>(
122 env, g_Test_clazz,
123 "testStaticMethodWithNoParam",
124
125 "("
126 ")"
127 "Ljava/lang/String;",
128 &g_Test_testStaticMethodWithNoParam);
129
130 jstring ret =
131 static_cast<jstring>(env->CallStaticObjectMethod(g_Test_clazz,
132 method_id));
133 jni_generator::CheckException(env);
134 return base::android::ScopedJavaLocalRef<jstring>(env, ret);
135 }
136 };
137
138 // Step 3: RegisterNatives.
139
140 static bool RegisterNativesImpl(JNIEnv* env, jclass clazz) {
141 g_Test_clazz = static_cast<jclass>(env->NewWeakGlobalRef(clazz));
142
143 return true;
144 }
145
146 #endif // org_chromium_example_jni_generator_Test_JNI
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698