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

Side by Side Diff: base/android/jni_generator/golden_sample_for_tests_jni.h

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 (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.py 6 // base/android/jni_generator/jni_generator.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 15 matching lines...) Expand all
26 jclass g_InnerStructA_clazz = NULL; 26 jclass g_InnerStructA_clazz = NULL;
27 // Leaking this jclass as we cannot use LazyInstance from some threads. 27 // Leaking this jclass as we cannot use LazyInstance from some threads.
28 jclass g_SampleForTests_clazz = NULL; 28 jclass g_SampleForTests_clazz = NULL;
29 // Leaking this jclass as we cannot use LazyInstance from some threads. 29 // Leaking this jclass as we cannot use LazyInstance from some threads.
30 jclass g_InnerStructB_clazz = NULL; 30 jclass g_InnerStructB_clazz = NULL;
31 31
32 } // namespace 32 } // namespace
33 33
34 namespace base { 34 namespace base {
35 namespace android { 35 namespace android {
36 extern "C"{
36 37
37 static jlong Init(JNIEnv* env, jobject jcaller, 38 static jlong Init(JNIEnv* env, jobject jcaller,
38 jstring param); 39 jstring param);
40 __attribute__((alias("Init"), visibility("default"))) jlong
41 Java_org_chromium_example_jni_1generator_SampleForTests_nativeInit(JNIEnv*
42 env, jobject jcaller,
43 jstring param);
39 44
40 static jdouble GetDoubleFunction(JNIEnv* env, jobject jcaller); 45 static jdouble GetDoubleFunction(JNIEnv* env, jobject jcaller);
46 __attribute__((alias("GetDoubleFunction"), visibility("default"))) jdouble
47 Java_org_chromium_example_jni_1generator_SampleForTests_nativeGetDoubleFunction( JNIEnv*
48 env, jobject jcaller);
41 49
42 static jfloat GetFloatFunction(JNIEnv* env, jclass jcaller); 50 static jfloat GetFloatFunction(JNIEnv* env, jclass jcaller);
51 __attribute__((alias("GetFloatFunction"), visibility("default"))) jfloat
52 Java_org_chromium_example_jni_1generator_SampleForTests_nativeGetFloatFunction(J NIEnv*
53 env, jclass jcaller);
43 54
44 static void SetNonPODDatatype(JNIEnv* env, jobject jcaller, 55 static void SetNonPODDatatype(JNIEnv* env, jobject jcaller,
45 jobject rect); 56 jobject rect);
57 __attribute__((alias("SetNonPODDatatype"), visibility("default"))) void
58 Java_org_chromium_example_jni_1generator_SampleForTests_nativeSetNonPODDatatype( JNIEnv*
59 env, jobject jcaller,
60 jobject rect);
46 61
47 static jobject GetNonPODDatatype(JNIEnv* env, jobject jcaller); 62 static jobject GetNonPODDatatype(JNIEnv* env, jobject jcaller);
63 __attribute__((alias("GetNonPODDatatype"), visibility("default"))) jobject
64 Java_org_chromium_example_jni_1generator_SampleForTests_nativeGetNonPODDatatype( JNIEnv*
65 env, jobject jcaller);
48 66
49 // Step 2: method stubs. 67 // Step 2: method stubs.
50 static void Destroy(JNIEnv* env, jobject jcaller, 68 static void Destroy(JNIEnv* env, jobject jcaller,
51 jlong nativeCPPClass) { 69 jlong nativeCPPClass) {
52 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); 70 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass);
53 CHECK_NATIVE_PTR(env, jcaller, native, "Destroy"); 71 CHECK_NATIVE_PTR(env, jcaller, native, "Destroy");
54 return native->Destroy(env, jcaller); 72 return native->Destroy(env, jcaller);
55 } 73 }
74 __attribute__((alias("Destroy"), visibility("default")))
75 void
76 Java_org_chromium_example_jni_1generator_SampleForTests_nativeDestroy(JNIE nv*
77 env,
78 jobject jcaller,
79 jlong nativeCPPClass);
56 80
57 static jint Method(JNIEnv* env, jobject jcaller, 81 static jint Method(JNIEnv* env, jobject jcaller,
58 jlong nativeCPPClass) { 82 jlong nativeCPPClass) {
59 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); 83 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass);
60 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0); 84 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0);
61 return native->Method(env, jcaller); 85 return native->Method(env, jcaller);
62 } 86 }
87 __attribute__((alias("Method"), visibility("default")))
88 jint
89 Java_org_chromium_example_jni_1generator_SampleForTests_nativeMethod(JNIEn v*
90 env,
91 jobject jcaller,
92 jlong nativeCPPClass);
63 93
64 static jdouble MethodOtherP0(JNIEnv* env, jobject jcaller, 94 static jdouble MethodOtherP0(JNIEnv* env, jobject jcaller,
65 jlong nativePtr) { 95 jlong nativePtr) {
66 CPPClass::InnerClass* native = 96 CPPClass::InnerClass* native =
67 reinterpret_cast<CPPClass::InnerClass*>(nativePtr); 97 reinterpret_cast<CPPClass::InnerClass*>(nativePtr);
68 CHECK_NATIVE_PTR(env, jcaller, native, "MethodOtherP0", 0); 98 CHECK_NATIVE_PTR(env, jcaller, native, "MethodOtherP0", 0);
69 return native->MethodOtherP0(env, jcaller); 99 return native->MethodOtherP0(env, jcaller);
70 } 100 }
101 __attribute__((alias("MethodOtherP0"), visibility("default")))
102 jdouble
103 Java_org_chromium_example_jni_1generator_SampleForTests_nativeMethodOtherP 0(JNIEnv*
104 env,
105 jobject jcaller,
106 jlong nativePtr);
71 107
72 static void AddStructB(JNIEnv* env, jobject jcaller, 108 static void AddStructB(JNIEnv* env, jobject jcaller,
73 jlong nativeCPPClass, 109 jlong nativeCPPClass,
74 jobject b) { 110 jobject b) {
75 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); 111 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass);
76 CHECK_NATIVE_PTR(env, jcaller, native, "AddStructB"); 112 CHECK_NATIVE_PTR(env, jcaller, native, "AddStructB");
77 return native->AddStructB(env, jcaller, b); 113 return native->AddStructB(env, jcaller, b);
78 } 114 }
115 __attribute__((alias("AddStructB"), visibility("default")))
116 void
117 Java_org_chromium_example_jni_1generator_SampleForTests_nativeAddStructB(J NIEnv*
118 env,
119 jobject jcaller,
120 jlong nativeCPPClass,
121 jobject b);
79 122
80 static void IterateAndDoSomethingWithStructB(JNIEnv* env, jobject jcaller, 123 static void IterateAndDoSomethingWithStructB(JNIEnv* env, jobject jcaller,
81 jlong nativeCPPClass) { 124 jlong nativeCPPClass) {
82 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); 125 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass);
83 CHECK_NATIVE_PTR(env, jcaller, native, "IterateAndDoSomethingWithStructB"); 126 CHECK_NATIVE_PTR(env, jcaller, native, "IterateAndDoSomethingWithStructB");
84 return native->IterateAndDoSomethingWithStructB(env, jcaller); 127 return native->IterateAndDoSomethingWithStructB(env, jcaller);
85 } 128 }
129 __attribute__((alias("IterateAndDoSomethingWithStructB"),
130 visibility("default")))
131 void
132 Java_org_chromium_example_jni_1generator_SampleForTests_nativeIterateAndDo SomethingWithStructB(JNIEnv*
133 env,
134 jobject jcaller,
135 jlong nativeCPPClass);
86 136
87 static jstring ReturnAString(JNIEnv* env, jobject jcaller, 137 static jstring ReturnAString(JNIEnv* env, jobject jcaller,
88 jlong nativeCPPClass) { 138 jlong nativeCPPClass) {
89 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); 139 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass);
90 CHECK_NATIVE_PTR(env, jcaller, native, "ReturnAString", NULL); 140 CHECK_NATIVE_PTR(env, jcaller, native, "ReturnAString", NULL);
91 return native->ReturnAString(env, jcaller).Release(); 141 return native->ReturnAString(env, jcaller).Release();
92 } 142 }
143 __attribute__((alias("ReturnAString"), visibility("default")))
144 jstring
145 Java_org_chromium_example_jni_1generator_SampleForTests_nativeReturnAStrin g(JNIEnv*
146 env,
147 jobject jcaller,
148 jlong nativeCPPClass);
93 149
94 static base::subtle::AtomicWord g_SampleForTests_javaMethod = 0; 150 static base::subtle::AtomicWord g_SampleForTests_javaMethod = 0;
95 static jint Java_SampleForTests_javaMethod(JNIEnv* env, jobject obj, jint foo, 151 static jint Java_SampleForTests_javaMethod(JNIEnv* env, jobject obj, jint foo,
96 jint bar) { 152 jint bar) {
97 /* Must call RegisterNativesImpl() */ 153 /* Must call RegisterNativesImpl() */
98 CHECK_CLAZZ(env, obj, 154 CHECK_CLAZZ(env, obj,
99 g_SampleForTests_clazz, 0); 155 g_SampleForTests_clazz, 0);
100 jmethodID method_id = 156 jmethodID method_id =
101 base::android::MethodID::LazyGet< 157 base::android::MethodID::LazyGet<
102 base::android::MethodID::TYPE_INSTANCE>( 158 base::android::MethodID::TYPE_INSTANCE>(
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 ")" 356 ")"
301 "Ljava/lang/String;", 357 "Ljava/lang/String;",
302 &g_InnerStructB_getValue); 358 &g_InnerStructB_getValue);
303 359
304 jstring ret = 360 jstring ret =
305 static_cast<jstring>(env->CallObjectMethod(obj, 361 static_cast<jstring>(env->CallObjectMethod(obj,
306 method_id)); 362 method_id));
307 jni_generator::CheckException(env); 363 jni_generator::CheckException(env);
308 return base::android::ScopedJavaLocalRef<jstring>(env, ret); 364 return base::android::ScopedJavaLocalRef<jstring>(env, ret);
309 } 365 }
366 };
310 367
311 // Step 3: RegisterNatives. 368 // Step 3: RegisterNatives.
312
313 static const JNINativeMethod kMethodsSampleForTests[] = {
314 { "nativeInit",
315 "("
316 "Ljava/lang/String;"
317 ")"
318 "J", reinterpret_cast<void*>(Init) },
319 { "nativeDestroy",
320 "("
321 "J"
322 ")"
323 "V", reinterpret_cast<void*>(Destroy) },
324 { "nativeGetDoubleFunction",
325 "("
326 ")"
327 "D", reinterpret_cast<void*>(GetDoubleFunction) },
328 { "nativeGetFloatFunction",
329 "("
330 ")"
331 "F", reinterpret_cast<void*>(GetFloatFunction) },
332 { "nativeSetNonPODDatatype",
333 "("
334 "Landroid/graphics/Rect;"
335 ")"
336 "V", reinterpret_cast<void*>(SetNonPODDatatype) },
337 { "nativeGetNonPODDatatype",
338 "("
339 ")"
340 "Ljava/lang/Object;", reinterpret_cast<void*>(GetNonPODDatatype) },
341 { "nativeMethod",
342 "("
343 "J"
344 ")"
345 "I", reinterpret_cast<void*>(Method) },
346 { "nativeMethodOtherP0",
347 "("
348 "J"
349 ")"
350 "D", reinterpret_cast<void*>(MethodOtherP0) },
351 { "nativeAddStructB",
352 "("
353 "J"
354 "Lorg/chromium/example/jni_generator/SampleForTests$InnerStructB;"
355 ")"
356 "V", reinterpret_cast<void*>(AddStructB) },
357 { "nativeIterateAndDoSomethingWithStructB",
358 "("
359 "J"
360 ")"
361 "V", reinterpret_cast<void*>(IterateAndDoSomethingWithStructB) },
362 { "nativeReturnAString",
363 "("
364 "J"
365 ")"
366 "Ljava/lang/String;", reinterpret_cast<void*>(ReturnAString) },
367 };
368
369 static bool RegisterNativesImpl(JNIEnv* env) { 369 static bool RegisterNativesImpl(JNIEnv* env) {
370 g_InnerStructA_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( 370 g_InnerStructA_clazz = reinterpret_cast<jclass>(env->NewGlobalRef(
371 base::android::GetClass(env, kInnerStructAClassPath).obj())); 371 base::android::GetClass(env, kInnerStructAClassPath).obj()));
372 g_SampleForTests_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( 372 g_SampleForTests_clazz = reinterpret_cast<jclass>(env->NewGlobalRef(
373 base::android::GetClass(env, kSampleForTestsClassPath).obj())); 373 base::android::GetClass(env, kSampleForTestsClassPath).obj()));
374 g_InnerStructB_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( 374 g_InnerStructB_clazz = reinterpret_cast<jclass>(env->NewGlobalRef(
375 base::android::GetClass(env, kInnerStructBClassPath).obj())); 375 base::android::GetClass(env, kInnerStructBClassPath).obj()));
376 376
377 const int kMethodsSampleForTestsSize = arraysize(kMethodsSampleForTests);
378
379 if (env->RegisterNatives(g_SampleForTests_clazz,
380 kMethodsSampleForTests,
381 kMethodsSampleForTestsSize) < 0) {
382 jni_generator::HandleRegistrationError(
383 env, g_SampleForTests_clazz, __FILE__);
384 return false;
385 }
386
387 return true; 377 return true;
388 } 378 }
389 379
390 } // namespace android 380 } // namespace android
391 } // namespace base 381 } // namespace base
392 382
393 #endif // org_chromium_example_jni_generator_SampleForTests_JNI 383 #endif // org_chromium_example_jni_generator_SampleForTests_JNI
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698