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

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

Issue 147533004: Remove unneeded JNI registrations. (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Fix android webview build issues. 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
1 // Copyright 2014 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/example/jni_generator/Test 8 // org/chromium/example/jni_generator/Test
9 9
10 #ifndef org_chromium_example_jni_generator_Test_JNI 10 #ifndef org_chromium_example_jni_generator_Test_JNI
11 #define org_chromium_example_jni_generator_Test_JNI 11 #define org_chromium_example_jni_generator_Test_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 // Step 1: forward declarations. 17 // Step 1: forward declarations.
18 namespace { 18 namespace {
19 const char kTestClassPath[] = "org/chromium/example/jni_generator/Test"; 19 const char kTestClassPath[] = "org/chromium/example/jni_generator/Test";
20 // Leaking this jclass as we cannot use LazyInstance from some threads. 20 // Leaking this jclass as we cannot use LazyInstance from some threads.
21 jclass g_Test_clazz = NULL; 21 jclass g_Test_clazz = NULL;
22 jmethodID g_Test_testMethodWithParam = NULL; 22 jmethodID g_Test_testMethodWithParam = NULL;
23 jmethodID g_Test_testStaticMethodWithParam = NULL; 23 jmethodID g_Test_testStaticMethodWithParam = NULL;
24 jmethodID g_Test_testMethodWithNoParam = NULL; 24 jmethodID g_Test_testMethodWithNoParam = NULL;
25 jmethodID g_Test_testStaticMethodWithNoParam = NULL; 25 jmethodID g_Test_testStaticMethodWithNoParam = NULL;
26 } // namespace 26 } // namespace
27 27
28 extern "C"{
29
28 // Step 2: method stubs. 30 // Step 2: method stubs.
29 static jint Method(JNIEnv* env, jobject jcaller, 31 static jint Method(JNIEnv* env, jobject jcaller,
30 jlong nativeTest, 32 jlong nativeTest,
31 jint arg1) { 33 jint arg1) {
32 Test* native = reinterpret_cast<Test*>(nativeTest); 34 Test* native = reinterpret_cast<Test*>(nativeTest);
33 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0); 35 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0);
34 return native->Method(env, jcaller, arg1); 36 return native->Method(env, jcaller, arg1);
35 } 37 }
38 __attribute__((alias("Method"), visibility("default")))
39 jint Java_org_chromium_example_jni_1generator_Test_nativeMethod(JNIEnv* env,
40 jobject jcaller,
41 jlong nativeTest,
42 jint arg1);
36 43
37 namespace { 44 namespace {
38 45
39 static void testMethodWithParam(JNIEnv* env, jobject obj, jint iParam) { 46 static void testMethodWithParam(JNIEnv* env, jobject obj, jint iParam) {
40 env->CallVoidMethod(obj, 47 env->CallVoidMethod(obj,
41 g_Test_testMethodWithParam, iParam); 48 g_Test_testMethodWithParam, iParam);
42 49
43 } 50 }
44 51
45 static jint testStaticMethodWithParam(JNIEnv* env, jint iParam) { 52 static jint testStaticMethodWithParam(JNIEnv* env, jint iParam) {
46 jint ret = env->CallStaticIntMethod(g_Test_clazz, 53 jint ret = env->CallStaticIntMethod(g_Test_clazz,
47 g_Test_testStaticMethodWithParam, iParam); 54 g_Test_testStaticMethodWithParam, iParam);
48 return ret; 55 return ret;
49 } 56 }
50 57
51 static jdouble testMethodWithNoParam(JNIEnv* env) { 58 static jdouble testMethodWithNoParam(JNIEnv* env) {
52 jdouble ret = env->CallStaticDoubleMethod(g_Test_clazz, 59 jdouble ret = env->CallStaticDoubleMethod(g_Test_clazz,
53 g_Test_testMethodWithNoParam); 60 g_Test_testMethodWithNoParam);
54 return ret; 61 return ret;
55 } 62 }
56 63
57 static base::android::ScopedJavaLocalRef<jstring> 64 static base::android::ScopedJavaLocalRef<jstring>
58 testStaticMethodWithNoParam(JNIEnv* env) { 65 testStaticMethodWithNoParam(JNIEnv* env) {
59 jstring ret = static_cast<jstring>(env->CallStaticObjectMethod(g_Test_clazz, 66 jstring ret = static_cast<jstring>(env->CallStaticObjectMethod(g_Test_clazz,
60 g_Test_testStaticMethodWithNoParam)); 67 g_Test_testStaticMethodWithNoParam));
61 return base::android::ScopedJavaLocalRef<jstring>(env, ret); 68 return base::android::ScopedJavaLocalRef<jstring>(env, ret);
62 } 69 }
63 } // namespace 70 } // namespace
71 };
64 72
65 // Step 3: RegisterNatives. 73 // Step 3: RegisterNatives.
66
67 static const JNINativeMethod kMethodsTest[] = {
68 { "nativeMethod",
69 "("
70 "J"
71 "I"
72 ")"
73 "I", reinterpret_cast<void*>(Method) },
74 };
75
76 static bool RegisterNativesImpl(JNIEnv* env, jclass clazz) { 74 static bool RegisterNativesImpl(JNIEnv* env, jclass clazz) {
77 g_Test_clazz = static_cast<jclass>(env->NewWeakGlobalRef(clazz)); 75 g_Test_clazz = static_cast<jclass>(env->NewWeakGlobalRef(clazz));
78
79 const int kMethodsTestSize = arraysize(kMethodsTest);
80
81 if (env->RegisterNatives(g_Test_clazz,
82 kMethodsTest,
83 kMethodsTestSize) < 0) {
84 jni_generator::HandleRegistrationError(
85 env, g_Test_clazz, __FILE__);
86 return false;
87 }
88
89 g_Test_testMethodWithParam = env->GetMethodID( 76 g_Test_testMethodWithParam = env->GetMethodID(
90 g_Test_clazz, 77 g_Test_clazz,
91 "testMethodWithParam", 78 "testMethodWithParam",
92 "(" 79 "("
93 "I" 80 "I"
94 ")" 81 ")"
95 "V"); 82 "V");
96 if (g_Test_testMethodWithParam == NULL) { 83 if (g_Test_testMethodWithParam == NULL) {
97 return false; 84 return false;
98 } 85 }
(...skipping 25 matching lines...) Expand all
124 "(" 111 "("
125 ")" 112 ")"
126 "Ljava/lang/String;"); 113 "Ljava/lang/String;");
127 if (g_Test_testStaticMethodWithNoParam == NULL) { 114 if (g_Test_testStaticMethodWithNoParam == NULL) {
128 return false; 115 return false;
129 } 116 }
130 117
131 return true; 118 return true;
132 } 119 }
133 120
134 extern "C" JNIEXPORT bool JNICALL
135 Java_org_chromium_example_jni_generator_Test_nativeInitNativeClass(JNIEnv* env,
136 jclass clazz) {
137 return RegisterNativesImpl(env, clazz);
138 }
139
140 #endif // org_chromium_example_jni_generator_Test_JNI 121 #endif // org_chromium_example_jni_generator_Test_JNI
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698