OLD | NEW |
1 // Copyright 2013 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/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_android.h" | 15 #include "base/android/jni_generator/jni_generator_helper.h" |
16 #include "base/android/scoped_java_ref.h" | |
17 #include "base/basictypes.h" | |
18 #include "base/logging.h" | |
19 | |
20 using base::android::ScopedJavaLocalRef; | |
21 | 16 |
22 // Step 1: forward declarations. | 17 // Step 1: forward declarations. |
23 namespace { | 18 namespace { |
24 const char kMyOtherInnerClassClassPath[] = | 19 const char kMyOtherInnerClassClassPath[] = |
25 "org/chromium/TestJni$MyOtherInnerClass"; | 20 "org/chromium/TestJni$MyOtherInnerClass"; |
26 const char kTestJniClassPath[] = "org/chromium/TestJni"; | 21 const char kTestJniClassPath[] = "org/chromium/TestJni"; |
27 const char kMyInnerClassClassPath[] = "org/chromium/TestJni$MyInnerClass"; | 22 const char kMyInnerClassClassPath[] = "org/chromium/TestJni$MyInnerClass"; |
28 // Leaking this jclass as we cannot use LazyInstance from some threads. | 23 // Leaking this jclass as we cannot use LazyInstance from some threads. |
29 jclass g_TestJni_clazz = NULL; | 24 jclass g_TestJni_clazz = NULL; |
| 25 |
30 } // namespace | 26 } // namespace |
31 | 27 |
32 static jint Init(JNIEnv* env, jobject obj); | 28 static jint Init(JNIEnv* env, jobject obj); |
33 | 29 |
34 static jint Init(JNIEnv* env, jobject obj); | 30 static jint Init(JNIEnv* env, jobject obj); |
35 | 31 |
36 // Step 2: method stubs. | 32 // Step 2: method stubs. |
37 | 33 |
38 // Step 3: RegisterNatives. | 34 // Step 3: RegisterNatives. |
39 | 35 |
40 static bool RegisterNativesImpl(JNIEnv* env) { | 36 static const JNINativeMethod kMethodsMyOtherInnerClass[] = { |
41 | |
42 g_TestJni_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( | |
43 base::android::GetClass(env, kTestJniClassPath).obj())); | |
44 static const JNINativeMethod kMethodsMyOtherInnerClass[] = { | |
45 { "nativeInit", | 37 { "nativeInit", |
46 "(" | 38 "(" |
47 ")" | 39 ")" |
48 "I", reinterpret_cast<void*>(Init) }, | 40 "I", reinterpret_cast<void*>(Init) }, |
49 }; | 41 }; |
| 42 |
| 43 static const JNINativeMethod kMethodsMyInnerClass[] = { |
| 44 { "nativeInit", |
| 45 "(" |
| 46 ")" |
| 47 "I", reinterpret_cast<void*>(Init) }, |
| 48 }; |
| 49 |
| 50 static bool RegisterNativesImpl(JNIEnv* env) { |
| 51 g_TestJni_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( |
| 52 base::android::GetClass(env, kTestJniClassPath).obj())); |
| 53 |
50 const int kMethodsMyOtherInnerClassSize = | 54 const int kMethodsMyOtherInnerClassSize = |
51 arraysize(kMethodsMyOtherInnerClass); | 55 arraysize(kMethodsMyOtherInnerClass); |
52 | 56 |
53 if (env->RegisterNatives(g_MyOtherInnerClass_clazz, | 57 if (env->RegisterNatives(g_MyOtherInnerClass_clazz, |
54 kMethodsMyOtherInnerClass, | 58 kMethodsMyOtherInnerClass, |
55 kMethodsMyOtherInnerClassSize) < 0) { | 59 kMethodsMyOtherInnerClassSize) < 0) { |
56 LOG(ERROR) << "RegisterNatives failed in " << __FILE__; | 60 jni_generator::HandleRegistrationError( |
| 61 env, g_MyOtherInnerClass_clazz, __FILE__); |
57 return false; | 62 return false; |
58 } | 63 } |
59 | 64 |
60 static const JNINativeMethod kMethodsMyInnerClass[] = { | |
61 { "nativeInit", | |
62 "(" | |
63 ")" | |
64 "I", reinterpret_cast<void*>(Init) }, | |
65 }; | |
66 const int kMethodsMyInnerClassSize = arraysize(kMethodsMyInnerClass); | 65 const int kMethodsMyInnerClassSize = arraysize(kMethodsMyInnerClass); |
67 | 66 |
68 if (env->RegisterNatives(g_MyInnerClass_clazz, | 67 if (env->RegisterNatives(g_MyInnerClass_clazz, |
69 kMethodsMyInnerClass, | 68 kMethodsMyInnerClass, |
70 kMethodsMyInnerClassSize) < 0) { | 69 kMethodsMyInnerClassSize) < 0) { |
71 LOG(ERROR) << "RegisterNatives failed in " << __FILE__; | 70 jni_generator::HandleRegistrationError( |
| 71 env, g_MyInnerClass_clazz, __FILE__); |
72 return false; | 72 return false; |
73 } | 73 } |
74 | 74 |
75 return true; | 75 return true; |
76 } | 76 } |
77 | 77 |
78 #endif // org_chromium_TestJni_JNI | 78 #endif // org_chromium_TestJni_JNI |
OLD | NEW |