OLD | NEW |
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_tests.py | 6 // base/android/jni_generator/jni_generator_tests.py |
7 // For | 7 // For |
8 // org/chromium/example/jni_generator/SampleForTests | 8 // org/chromium/example/jni_generator/SampleForTests |
9 | 9 |
10 #ifndef org_chromium_example_jni_generator_SampleForTests_JNI | 10 #ifndef org_chromium_example_jni_generator_SampleForTests_JNI |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 jint nativeCPPClass) { | 59 jint nativeCPPClass) { |
60 DCHECK(nativeCPPClass) << "Method"; | 60 DCHECK(nativeCPPClass) << "Method"; |
61 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); | 61 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); |
62 return native->Method(env, obj); | 62 return native->Method(env, obj); |
63 } | 63 } |
64 | 64 |
65 static jdouble MethodOtherP0(JNIEnv* env, jobject obj, | 65 static jdouble MethodOtherP0(JNIEnv* env, jobject obj, |
66 jint nativePtr) { | 66 jint nativePtr) { |
67 DCHECK(nativePtr) << "MethodOtherP0"; | 67 DCHECK(nativePtr) << "MethodOtherP0"; |
68 CPPClass::InnerClass* native = | 68 CPPClass::InnerClass* native = |
69 reinterpret_cast<CPPClass::InnerClass*>(nativePtr); | 69 reinterpret_cast<CPPClass::InnerClass*>(nativePtr); |
70 return native->MethodOtherP0(env, obj); | 70 return native->MethodOtherP0(env, obj); |
71 } | 71 } |
72 | 72 |
73 static jstring InnerMethod(JNIEnv* env, jobject obj, | 73 static jstring InnerMethod(JNIEnv* env, jobject obj, |
74 jint nativeCPPClass) { | 74 jint nativeCPPClass) { |
75 DCHECK(nativeCPPClass) << "InnerMethod"; | 75 DCHECK(nativeCPPClass) << "InnerMethod"; |
76 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); | 76 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); |
77 return native->InnerMethod(env, obj).Release(); | 77 return native->InnerMethod(env, obj).Release(); |
78 } | 78 } |
79 | 79 |
80 static jmethodID g_SampleForTests_javaMethod = 0; | 80 static jmethodID g_SampleForTests_javaMethod = 0; |
81 static jint Java_SampleForTests_javaMethod(JNIEnv* env, jobject obj, jint foo, | 81 static jint Java_SampleForTests_javaMethod(JNIEnv* env, jobject obj, jint foo, |
82 jint bar) { | 82 jint bar) { |
83 /* Must call RegisterNativesImpl() */ | 83 /* Must call RegisterNativesImpl() */ |
84 DCHECK(g_SampleForTests_clazz); | 84 DCHECK(g_SampleForTests_clazz); |
85 DCHECK(g_SampleForTests_javaMethod); | 85 |
| 86 base::android::LazyMethodID::Get< |
| 87 base::android::LazyMethodID::METHODTYPE_NORMAL, |
| 88 base::android::LazyMethodID::EXCEPTIONCHECK_YES>( |
| 89 env, g_SampleForTests_clazz, |
| 90 "javaMethod", |
| 91 |
| 92 "(" |
| 93 "I" |
| 94 "I" |
| 95 ")" |
| 96 "I", |
| 97 &g_SampleForTests_javaMethod); |
| 98 |
86 jint ret = | 99 jint ret = |
87 env->CallIntMethod(obj, | 100 env->CallIntMethod(obj, |
88 g_SampleForTests_javaMethod, foo, bar); | 101 g_SampleForTests_javaMethod, foo, bar); |
89 base::android::CheckException(env); | 102 base::android::CheckException(env); |
90 return ret; | 103 return ret; |
91 } | 104 } |
92 | 105 |
93 static jmethodID g_SampleForTests_staticJavaMethod = 0; | 106 static jmethodID g_SampleForTests_staticJavaMethod = 0; |
94 static jboolean Java_SampleForTests_staticJavaMethod(JNIEnv* env) { | 107 static jboolean Java_SampleForTests_staticJavaMethod(JNIEnv* env) { |
95 /* Must call RegisterNativesImpl() */ | 108 /* Must call RegisterNativesImpl() */ |
96 DCHECK(g_SampleForTests_clazz); | 109 DCHECK(g_SampleForTests_clazz); |
97 DCHECK(g_SampleForTests_staticJavaMethod); | 110 |
| 111 base::android::LazyMethodID::Get< |
| 112 base::android::LazyMethodID::METHODTYPE_STATIC, |
| 113 base::android::LazyMethodID::EXCEPTIONCHECK_YES>( |
| 114 env, g_SampleForTests_clazz, |
| 115 "staticJavaMethod", |
| 116 |
| 117 "(" |
| 118 ")" |
| 119 "Z", |
| 120 &g_SampleForTests_staticJavaMethod); |
| 121 |
98 jboolean ret = | 122 jboolean ret = |
99 env->CallStaticBooleanMethod(g_SampleForTests_clazz, | 123 env->CallStaticBooleanMethod(g_SampleForTests_clazz, |
100 g_SampleForTests_staticJavaMethod); | 124 g_SampleForTests_staticJavaMethod); |
101 base::android::CheckException(env); | 125 base::android::CheckException(env); |
102 return ret; | 126 return ret; |
103 } | 127 } |
104 | 128 |
105 static jmethodID g_SampleForTests_packagePrivateJavaMethod = 0; | 129 static jmethodID g_SampleForTests_packagePrivateJavaMethod = 0; |
106 static void Java_SampleForTests_packagePrivateJavaMethod(JNIEnv* env, jobject | 130 static void Java_SampleForTests_packagePrivateJavaMethod(JNIEnv* env, jobject |
107 obj) { | 131 obj) { |
108 /* Must call RegisterNativesImpl() */ | 132 /* Must call RegisterNativesImpl() */ |
109 DCHECK(g_SampleForTests_clazz); | 133 DCHECK(g_SampleForTests_clazz); |
110 DCHECK(g_SampleForTests_packagePrivateJavaMethod); | 134 |
| 135 base::android::LazyMethodID::Get< |
| 136 base::android::LazyMethodID::METHODTYPE_NORMAL, |
| 137 base::android::LazyMethodID::EXCEPTIONCHECK_YES>( |
| 138 env, g_SampleForTests_clazz, |
| 139 "packagePrivateJavaMethod", |
| 140 |
| 141 "(" |
| 142 ")" |
| 143 "V", |
| 144 &g_SampleForTests_packagePrivateJavaMethod); |
111 | 145 |
112 env->CallVoidMethod(obj, | 146 env->CallVoidMethod(obj, |
113 g_SampleForTests_packagePrivateJavaMethod); | 147 g_SampleForTests_packagePrivateJavaMethod); |
114 base::android::CheckException(env); | 148 base::android::CheckException(env); |
115 | 149 |
116 } | 150 } |
117 | 151 |
118 static jmethodID g_SampleForTests_methodThatThrowsException = 0; | 152 static jmethodID g_SampleForTests_methodThatThrowsException = 0; |
119 static void Java_SampleForTests_methodThatThrowsException(JNIEnv* env, jobject | 153 static void Java_SampleForTests_methodThatThrowsException(JNIEnv* env, jobject |
120 obj) { | 154 obj) { |
121 /* Must call RegisterNativesImpl() */ | 155 /* Must call RegisterNativesImpl() */ |
122 DCHECK(g_SampleForTests_clazz); | 156 DCHECK(g_SampleForTests_clazz); |
123 DCHECK(g_SampleForTests_methodThatThrowsException); | 157 |
| 158 base::android::LazyMethodID::Get< |
| 159 base::android::LazyMethodID::METHODTYPE_NORMAL, |
| 160 base::android::LazyMethodID::EXCEPTIONCHECK_YES>( |
| 161 env, g_SampleForTests_clazz, |
| 162 "methodThatThrowsException", |
| 163 |
| 164 "(" |
| 165 ")" |
| 166 "V", |
| 167 &g_SampleForTests_methodThatThrowsException); |
124 | 168 |
125 env->CallVoidMethod(obj, | 169 env->CallVoidMethod(obj, |
126 g_SampleForTests_methodThatThrowsException); | 170 g_SampleForTests_methodThatThrowsException); |
127 | 171 |
128 } | 172 } |
129 | 173 |
130 static jmethodID g_InnerClass_JavaInnerMethod = 0; | 174 static jmethodID g_InnerClass_JavaInnerMethod = 0; |
131 static jfloat Java_InnerClass_JavaInnerMethod(JNIEnv* env, jobject obj) { | 175 static jfloat Java_InnerClass_JavaInnerMethod(JNIEnv* env, jobject obj) { |
132 /* Must call RegisterNativesImpl() */ | 176 /* Must call RegisterNativesImpl() */ |
133 DCHECK(g_InnerClass_clazz); | 177 DCHECK(g_InnerClass_clazz); |
134 DCHECK(g_InnerClass_JavaInnerMethod); | 178 |
| 179 base::android::LazyMethodID::Get< |
| 180 base::android::LazyMethodID::METHODTYPE_NORMAL, |
| 181 base::android::LazyMethodID::EXCEPTIONCHECK_YES>( |
| 182 env, g_InnerClass_clazz, |
| 183 "JavaInnerMethod", |
| 184 |
| 185 "(" |
| 186 ")" |
| 187 "F", |
| 188 &g_InnerClass_JavaInnerMethod); |
| 189 |
135 jfloat ret = | 190 jfloat ret = |
136 env->CallFloatMethod(obj, | 191 env->CallFloatMethod(obj, |
137 g_InnerClass_JavaInnerMethod); | 192 g_InnerClass_JavaInnerMethod); |
138 base::android::CheckException(env); | 193 base::android::CheckException(env); |
139 return ret; | 194 return ret; |
140 } | 195 } |
141 | 196 |
142 static jmethodID g_InnerClass_javaInnerFunction = 0; | 197 static jmethodID g_InnerClass_javaInnerFunction = 0; |
143 static void Java_InnerClass_javaInnerFunction(JNIEnv* env) { | 198 static void Java_InnerClass_javaInnerFunction(JNIEnv* env) { |
144 /* Must call RegisterNativesImpl() */ | 199 /* Must call RegisterNativesImpl() */ |
145 DCHECK(g_InnerClass_clazz); | 200 DCHECK(g_InnerClass_clazz); |
146 DCHECK(g_InnerClass_javaInnerFunction); | 201 |
| 202 base::android::LazyMethodID::Get< |
| 203 base::android::LazyMethodID::METHODTYPE_STATIC, |
| 204 base::android::LazyMethodID::EXCEPTIONCHECK_YES>( |
| 205 env, g_InnerClass_clazz, |
| 206 "javaInnerFunction", |
| 207 |
| 208 "(" |
| 209 ")" |
| 210 "V", |
| 211 &g_InnerClass_javaInnerFunction); |
147 | 212 |
148 env->CallStaticVoidMethod(g_InnerClass_clazz, | 213 env->CallStaticVoidMethod(g_InnerClass_clazz, |
149 g_InnerClass_javaInnerFunction); | 214 g_InnerClass_javaInnerFunction); |
150 base::android::CheckException(env); | 215 base::android::CheckException(env); |
151 | 216 |
152 } | 217 } |
153 | 218 |
154 // Step 3: GetMethodIDs and RegisterNatives. | 219 // Step 3: RegisterNatives. |
155 static void GetMethodIDsImpl(JNIEnv* env) { | 220 |
| 221 static bool RegisterNativesImpl(JNIEnv* env) { |
| 222 |
156 g_InnerClass_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( | 223 g_InnerClass_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( |
157 base::android::GetUnscopedClass(env, kInnerClassClassPath))); | 224 base::android::GetUnscopedClass(env, kInnerClassClassPath))); |
158 g_SampleForTests_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( | 225 g_SampleForTests_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( |
159 base::android::GetUnscopedClass(env, kSampleForTestsClassPath))); | 226 base::android::GetUnscopedClass(env, kSampleForTestsClassPath))); |
160 g_SampleForTests_javaMethod = | |
161 base::android::GetMethodID( | |
162 env, g_SampleForTests_clazz, | |
163 "javaMethod", | |
164 | |
165 "(" | |
166 "I" | |
167 "I" | |
168 ")" | |
169 "I"); | |
170 | |
171 g_SampleForTests_staticJavaMethod = | |
172 base::android::GetStaticMethodID( | |
173 env, g_SampleForTests_clazz, | |
174 "staticJavaMethod", | |
175 | |
176 "(" | |
177 ")" | |
178 "Z"); | |
179 | |
180 g_SampleForTests_packagePrivateJavaMethod = | |
181 base::android::GetMethodID( | |
182 env, g_SampleForTests_clazz, | |
183 "packagePrivateJavaMethod", | |
184 | |
185 "(" | |
186 ")" | |
187 "V"); | |
188 | |
189 g_SampleForTests_methodThatThrowsException = | |
190 base::android::GetMethodID( | |
191 env, g_SampleForTests_clazz, | |
192 "methodThatThrowsException", | |
193 | |
194 "(" | |
195 ")" | |
196 "V"); | |
197 | |
198 g_InnerClass_JavaInnerMethod = | |
199 base::android::GetMethodID( | |
200 env, g_InnerClass_clazz, | |
201 "JavaInnerMethod", | |
202 | |
203 "(" | |
204 ")" | |
205 "F"); | |
206 | |
207 g_InnerClass_javaInnerFunction = | |
208 base::android::GetStaticMethodID( | |
209 env, g_InnerClass_clazz, | |
210 "javaInnerFunction", | |
211 | |
212 "(" | |
213 ")" | |
214 "V"); | |
215 | |
216 } | |
217 | |
218 static bool RegisterNativesImpl(JNIEnv* env) { | |
219 GetMethodIDsImpl(env); | |
220 | |
221 static const JNINativeMethod kMethodsInnerClass[] = { | 227 static const JNINativeMethod kMethodsInnerClass[] = { |
222 { "nativeInnerFunction", | 228 { "nativeInnerFunction", |
223 "(" | 229 "(" |
224 ")" | 230 ")" |
225 "I", reinterpret_cast<void*>(InnerFunction) }, | 231 "I", reinterpret_cast<void*>(InnerFunction) }, |
226 { "nativeInnerMethod", | 232 { "nativeInnerMethod", |
227 "(" | 233 "(" |
228 "I" | 234 "I" |
229 ")" | 235 ")" |
230 "Ljava/lang/String;", reinterpret_cast<void*>(InnerMethod) }, | 236 "Ljava/lang/String;", reinterpret_cast<void*>(InnerMethod) }, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 LOG(ERROR) << "RegisterNatives failed in " << __FILE__; | 290 LOG(ERROR) << "RegisterNatives failed in " << __FILE__; |
285 return false; | 291 return false; |
286 } | 292 } |
287 | 293 |
288 return true; | 294 return true; |
289 } | 295 } |
290 } // namespace android | 296 } // namespace android |
291 } // namespace base | 297 } // namespace base |
292 | 298 |
293 #endif // org_chromium_example_jni_generator_SampleForTests_JNI | 299 #endif // org_chromium_example_jni_generator_SampleForTests_JNI |
OLD | NEW |