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

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

Issue 2154293002: jni_generator: handle inner class natives properly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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/TestJni 8 // org/chromium/TestJni
9 9
10 #ifndef org_chromium_TestJni_JNI 10 #ifndef org_chromium_TestJni_JNI
11 #define org_chromium_TestJni_JNI 11 #define org_chromium_TestJni_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 kMyOtherInnerClassClassPath[] = 21 const char kMyOtherInnerClassClassPath[] =
22 "org/chromium/TestJni$MyOtherInnerClass"; 22 "org/chromium/TestJni$MyOtherInnerClass";
23 const char kTestJniClassPath[] = "org/chromium/TestJni"; 23 const char kTestJniClassPath[] = "org/chromium/TestJni";
24 // Leaking this jclass as we cannot use LazyInstance from some threads. 24 // Leaking this jclass as we cannot use LazyInstance from some threads.
25 jclass g_MyOtherInnerClass_clazz = NULL;
26 #define MyOtherInnerClass_clazz(env) g_MyOtherInnerClass_clazz
27 // Leaking this jclass as we cannot use LazyInstance from some threads.
25 jclass g_TestJni_clazz = NULL; 28 jclass g_TestJni_clazz = NULL;
26 #define TestJni_clazz(env) g_TestJni_clazz 29 #define TestJni_clazz(env) g_TestJni_clazz
27 30
28 } // namespace 31 } // namespace
29 32
30 // Step 2: method stubs. 33 // Step 2: method stubs.
31 34
32 static jint Init(JNIEnv* env, const JavaParamRef<jobject>& jcaller); 35 static jint Init(JNIEnv* env, const JavaParamRef<jobject>& jcaller);
33 36
34 static jint Java_org_chromium_TestJni_nativeInit(JNIEnv* env, jobject jcaller) { 37 static jint Java_org_chromium_TestJni_nativeInit(JNIEnv* env, jobject jcaller) {
(...skipping 20 matching lines...) Expand all
55 58
56 static const JNINativeMethod kMethodsTestJni[] = { 59 static const JNINativeMethod kMethodsTestJni[] = {
57 { "nativeInit", 60 { "nativeInit",
58 "(" 61 "("
59 ")" 62 ")"
60 "I", reinterpret_cast<void*>(Java_org_chromium_TestJni_nativeInit) }, 63 "I", reinterpret_cast<void*>(Java_org_chromium_TestJni_nativeInit) },
61 }; 64 };
62 65
63 static bool RegisterNativesImpl(JNIEnv* env) { 66 static bool RegisterNativesImpl(JNIEnv* env) {
64 67
68 g_MyOtherInnerClass_clazz = reinterpret_cast<jclass>(env->NewGlobalRef(
69 base::android::GetClass(env, kMyOtherInnerClassClassPath).obj()));
65 g_TestJni_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( 70 g_TestJni_clazz = reinterpret_cast<jclass>(env->NewGlobalRef(
66 base::android::GetClass(env, kTestJniClassPath).obj())); 71 base::android::GetClass(env, kTestJniClassPath).obj()));
67 72
68 const int kMethodsMyOtherInnerClassSize = 73 const int kMethodsMyOtherInnerClassSize =
69 arraysize(kMethodsMyOtherInnerClass); 74 arraysize(kMethodsMyOtherInnerClass);
70 75
71 if (env->RegisterNatives(MyOtherInnerClass_clazz(env), 76 if (env->RegisterNatives(MyOtherInnerClass_clazz(env),
72 kMethodsMyOtherInnerClass, 77 kMethodsMyOtherInnerClass,
73 kMethodsMyOtherInnerClassSize) < 0) { 78 kMethodsMyOtherInnerClassSize) < 0) {
74 jni_generator::HandleRegistrationError( 79 jni_generator::HandleRegistrationError(
75 env, MyOtherInnerClass_clazz(env), __FILE__); 80 env, MyOtherInnerClass_clazz(env), __FILE__);
76 return false; 81 return false;
77 } 82 }
78 83
79 const int kMethodsTestJniSize = arraysize(kMethodsTestJni); 84 const int kMethodsTestJniSize = arraysize(kMethodsTestJni);
80 85
81 if (env->RegisterNatives(TestJni_clazz(env), 86 if (env->RegisterNatives(TestJni_clazz(env),
82 kMethodsTestJni, 87 kMethodsTestJni,
83 kMethodsTestJniSize) < 0) { 88 kMethodsTestJniSize) < 0) {
84 jni_generator::HandleRegistrationError( 89 jni_generator::HandleRegistrationError(
85 env, TestJni_clazz(env), __FILE__); 90 env, TestJni_clazz(env), __FILE__);
86 return false; 91 return false;
87 } 92 }
88 93
89 return true; 94 return true;
90 } 95 }
91 96
92 #endif // org_chromium_TestJni_JNI 97 #endif // org_chromium_TestJni_JNI
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698