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

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

Issue 1279163006: jni_generator: Wrap all native methods in stubs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove separate forward declaration section entirely Created 5 years, 4 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
« no previous file with comments | « no previous file | base/android/jni_generator/jni_generator.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 21 matching lines...) Expand all
32 #define SampleForTests_clazz(env) g_SampleForTests_clazz 32 #define SampleForTests_clazz(env) g_SampleForTests_clazz
33 // Leaking this jclass as we cannot use LazyInstance from some threads. 33 // Leaking this jclass as we cannot use LazyInstance from some threads.
34 jclass g_InnerStructB_clazz = NULL; 34 jclass g_InnerStructB_clazz = NULL;
35 #define InnerStructB_clazz(env) g_InnerStructB_clazz 35 #define InnerStructB_clazz(env) g_InnerStructB_clazz
36 36
37 } // namespace 37 } // namespace
38 38
39 namespace base { 39 namespace base {
40 namespace android { 40 namespace android {
41 41
42 // Step 2: method stubs.
43
42 static jlong Init(JNIEnv* env, jobject jcaller, 44 static jlong Init(JNIEnv* env, jobject jcaller,
43 jstring param); 45 jstring param);
44 46
45 static jdouble GetDoubleFunction(JNIEnv* env, jobject jcaller); 47 static jlong
48 Java_org_chromium_example_jni_1generator_SampleForTests_nativeInit(JNIEnv*
49 env, jobject jcaller,
50 jstring param) {
51 return Init(env, jcaller, param);
52 }
46 53
47 static jfloat GetFloatFunction(JNIEnv* env, jclass jcaller); 54 static void
48 55 Java_org_chromium_example_jni_1generator_SampleForTests_nativeDestroy(JNIEnv *
49 static void SetNonPODDatatype(JNIEnv* env, jobject jcaller, 56 env,
50 jobject rect); 57 jobject jcaller,
51
52 static jobject GetNonPODDatatype(JNIEnv* env, jobject jcaller);
53
54 // Step 2: method stubs.
55 static void Destroy(JNIEnv* env, jobject jcaller,
56 jlong nativeCPPClass) { 58 jlong nativeCPPClass) {
57 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); 59 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass);
58 CHECK_NATIVE_PTR(env, jcaller, native, "Destroy"); 60 CHECK_NATIVE_PTR(env, jcaller, native, "Destroy");
59 return native->Destroy(env, jcaller); 61 return native->Destroy(env, jcaller);
60 } 62 }
61 63
62 static jint Method(JNIEnv* env, jobject jcaller, 64 static jdouble GetDoubleFunction(JNIEnv* env, jobject jcaller);
65
66 static jdouble
67 Java_org_chromium_example_jni_1generator_SampleForTests_nativeGetDoubleFunct ion(JNIEnv*
68 env, jobject jcaller) {
69 return GetDoubleFunction(env, jcaller);
70 }
71
72 static jfloat GetFloatFunction(JNIEnv* env, jclass jcaller);
73
74 static jfloat
75 Java_org_chromium_example_jni_1generator_SampleForTests_nativeGetFloatFuncti on(JNIEnv*
76 env, jclass jcaller) {
77 return GetFloatFunction(env, jcaller);
78 }
79
80 static void SetNonPODDatatype(JNIEnv* env, jobject jcaller,
81 jobject rect);
82
83 static void
84 Java_org_chromium_example_jni_1generator_SampleForTests_nativeSetNonPODDatat ype(JNIEnv*
85 env, jobject jcaller,
86 jobject rect) {
87 return SetNonPODDatatype(env, jcaller, rect);
88 }
89
90 static jobject GetNonPODDatatype(JNIEnv* env, jobject jcaller);
91
92 static jobject
93 Java_org_chromium_example_jni_1generator_SampleForTests_nativeGetNonPODDatat ype(JNIEnv*
94 env, jobject jcaller) {
95 return GetNonPODDatatype(env, jcaller);
96 }
97
98 static jint
99 Java_org_chromium_example_jni_1generator_SampleForTests_nativeMethod(JNIEnv*
100 env,
101 jobject jcaller,
63 jlong nativeCPPClass) { 102 jlong nativeCPPClass) {
64 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); 103 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass);
65 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0); 104 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0);
66 return native->Method(env, jcaller); 105 return native->Method(env, jcaller);
67 } 106 }
68 107
69 static jdouble MethodOtherP0(JNIEnv* env, jobject jcaller, 108 static jdouble
109 Java_org_chromium_example_jni_1generator_SampleForTests_nativeMethodOtherP0( JNIEnv*
110 env,
111 jobject jcaller,
70 jlong nativePtr) { 112 jlong nativePtr) {
71 CPPClass::InnerClass* native = 113 CPPClass::InnerClass* native =
72 reinterpret_cast<CPPClass::InnerClass*>(nativePtr); 114 reinterpret_cast<CPPClass::InnerClass*>(nativePtr);
73 CHECK_NATIVE_PTR(env, jcaller, native, "MethodOtherP0", 0); 115 CHECK_NATIVE_PTR(env, jcaller, native, "MethodOtherP0", 0);
74 return native->MethodOtherP0(env, jcaller); 116 return native->MethodOtherP0(env, jcaller);
75 } 117 }
76 118
77 static void AddStructB(JNIEnv* env, jobject jcaller, 119 static void
120 Java_org_chromium_example_jni_1generator_SampleForTests_nativeAddStructB(JNI Env*
121 env,
122 jobject jcaller,
78 jlong nativeCPPClass, 123 jlong nativeCPPClass,
79 jobject b) { 124 jobject b) {
80 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); 125 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass);
81 CHECK_NATIVE_PTR(env, jcaller, native, "AddStructB"); 126 CHECK_NATIVE_PTR(env, jcaller, native, "AddStructB");
82 return native->AddStructB(env, jcaller, b); 127 return native->AddStructB(env, jcaller, b);
83 } 128 }
84 129
85 static void IterateAndDoSomethingWithStructB(JNIEnv* env, jobject jcaller, 130 static void
131 Java_org_chromium_example_jni_1generator_SampleForTests_nativeIterateAndDoSo methingWithStructB(JNIEnv*
132 env,
133 jobject jcaller,
86 jlong nativeCPPClass) { 134 jlong nativeCPPClass) {
87 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); 135 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass);
88 CHECK_NATIVE_PTR(env, jcaller, native, "IterateAndDoSomethingWithStructB"); 136 CHECK_NATIVE_PTR(env, jcaller, native, "IterateAndDoSomethingWithStructB");
89 return native->IterateAndDoSomethingWithStructB(env, jcaller); 137 return native->IterateAndDoSomethingWithStructB(env, jcaller);
90 } 138 }
91 139
92 static jstring ReturnAString(JNIEnv* env, jobject jcaller, 140 static jstring
141 Java_org_chromium_example_jni_1generator_SampleForTests_nativeReturnAString( JNIEnv*
142 env,
143 jobject jcaller,
93 jlong nativeCPPClass) { 144 jlong nativeCPPClass) {
94 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); 145 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass);
95 CHECK_NATIVE_PTR(env, jcaller, native, "ReturnAString", NULL); 146 CHECK_NATIVE_PTR(env, jcaller, native, "ReturnAString", NULL);
96 return native->ReturnAString(env, jcaller).Release(); 147 return native->ReturnAString(env, jcaller).Release();
97 } 148 }
98 149
99 static base::subtle::AtomicWord g_SampleForTests_javaMethod = 0; 150 static base::subtle::AtomicWord g_SampleForTests_javaMethod = 0;
100 static jint Java_SampleForTests_javaMethod(JNIEnv* env, jobject obj, 151 static jint Java_SampleForTests_javaMethod(JNIEnv* env, jobject obj,
101 JniIntWrapper foo, 152 JniIntWrapper foo,
102 JniIntWrapper bar) { 153 JniIntWrapper bar) {
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 return base::android::ScopedJavaLocalRef<jstring>(env, ret); 365 return base::android::ScopedJavaLocalRef<jstring>(env, ret);
315 } 366 }
316 367
317 // Step 3: RegisterNatives. 368 // Step 3: RegisterNatives.
318 369
319 static const JNINativeMethod kMethodsSampleForTests[] = { 370 static const JNINativeMethod kMethodsSampleForTests[] = {
320 { "nativeInit", 371 { "nativeInit",
321 "(" 372 "("
322 "Ljava/lang/String;" 373 "Ljava/lang/String;"
323 ")" 374 ")"
324 "J", reinterpret_cast<void*>(Init) }, 375 "J",
376 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTe sts_nativeInit)
377 },
325 { "nativeDestroy", 378 { "nativeDestroy",
326 "(" 379 "("
327 "J" 380 "J"
328 ")" 381 ")"
329 "V", reinterpret_cast<void*>(Destroy) }, 382 "V",
383 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTe sts_nativeDestroy)
384 },
330 { "nativeGetDoubleFunction", 385 { "nativeGetDoubleFunction",
331 "(" 386 "("
332 ")" 387 ")"
333 "D", reinterpret_cast<void*>(GetDoubleFunction) }, 388 "D",
389 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTe sts_nativeGetDoubleFunction)
390 },
334 { "nativeGetFloatFunction", 391 { "nativeGetFloatFunction",
335 "(" 392 "("
336 ")" 393 ")"
337 "F", reinterpret_cast<void*>(GetFloatFunction) }, 394 "F",
395 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTe sts_nativeGetFloatFunction)
396 },
338 { "nativeSetNonPODDatatype", 397 { "nativeSetNonPODDatatype",
339 "(" 398 "("
340 "Landroid/graphics/Rect;" 399 "Landroid/graphics/Rect;"
341 ")" 400 ")"
342 "V", reinterpret_cast<void*>(SetNonPODDatatype) }, 401 "V",
402 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTe sts_nativeSetNonPODDatatype)
403 },
343 { "nativeGetNonPODDatatype", 404 { "nativeGetNonPODDatatype",
344 "(" 405 "("
345 ")" 406 ")"
346 "Ljava/lang/Object;", reinterpret_cast<void*>(GetNonPODDatatype) }, 407 "Ljava/lang/Object;",
408 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTe sts_nativeGetNonPODDatatype)
409 },
347 { "nativeMethod", 410 { "nativeMethod",
348 "(" 411 "("
349 "J" 412 "J"
350 ")" 413 ")"
351 "I", reinterpret_cast<void*>(Method) }, 414 "I",
415 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTe sts_nativeMethod)
416 },
352 { "nativeMethodOtherP0", 417 { "nativeMethodOtherP0",
353 "(" 418 "("
354 "J" 419 "J"
355 ")" 420 ")"
356 "D", reinterpret_cast<void*>(MethodOtherP0) }, 421 "D",
422 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTe sts_nativeMethodOtherP0)
423 },
357 { "nativeAddStructB", 424 { "nativeAddStructB",
358 "(" 425 "("
359 "J" 426 "J"
360 "Lorg/chromium/example/jni_generator/SampleForTests$InnerStructB;" 427 "Lorg/chromium/example/jni_generator/SampleForTests$InnerStructB;"
361 ")" 428 ")"
362 "V", reinterpret_cast<void*>(AddStructB) }, 429 "V",
430 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTe sts_nativeAddStructB)
431 },
363 { "nativeIterateAndDoSomethingWithStructB", 432 { "nativeIterateAndDoSomethingWithStructB",
364 "(" 433 "("
365 "J" 434 "J"
366 ")" 435 ")"
367 "V", reinterpret_cast<void*>(IterateAndDoSomethingWithStructB) }, 436 "V",
437 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTe sts_nativeIterateAndDoSomethingWithStructB)
438 },
368 { "nativeReturnAString", 439 { "nativeReturnAString",
369 "(" 440 "("
370 "J" 441 "J"
371 ")" 442 ")"
372 "Ljava/lang/String;", reinterpret_cast<void*>(ReturnAString) }, 443 "Ljava/lang/String;",
444 reinterpret_cast<void*>(Java_org_chromium_example_jni_1generator_SampleForTe sts_nativeReturnAString)
445 },
373 }; 446 };
374 447
375 static bool RegisterNativesImpl(JNIEnv* env) { 448 static bool RegisterNativesImpl(JNIEnv* env) {
376 449
377 g_InnerStructA_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( 450 g_InnerStructA_clazz = reinterpret_cast<jclass>(env->NewGlobalRef(
378 base::android::GetClass(env, kInnerStructAClassPath).obj())); 451 base::android::GetClass(env, kInnerStructAClassPath).obj()));
379 g_SampleForTests_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( 452 g_SampleForTests_clazz = reinterpret_cast<jclass>(env->NewGlobalRef(
380 base::android::GetClass(env, kSampleForTestsClassPath).obj())); 453 base::android::GetClass(env, kSampleForTestsClassPath).obj()));
381 g_InnerStructB_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( 454 g_InnerStructB_clazz = reinterpret_cast<jclass>(env->NewGlobalRef(
382 base::android::GetClass(env, kInnerStructBClassPath).obj())); 455 base::android::GetClass(env, kInnerStructBClassPath).obj()));
383 456
384 const int kMethodsSampleForTestsSize = arraysize(kMethodsSampleForTests); 457 const int kMethodsSampleForTestsSize = arraysize(kMethodsSampleForTests);
385 458
386 if (env->RegisterNatives(SampleForTests_clazz(env), 459 if (env->RegisterNatives(SampleForTests_clazz(env),
387 kMethodsSampleForTests, 460 kMethodsSampleForTests,
388 kMethodsSampleForTestsSize) < 0) { 461 kMethodsSampleForTestsSize) < 0) {
389 jni_generator::HandleRegistrationError( 462 jni_generator::HandleRegistrationError(
390 env, SampleForTests_clazz(env), __FILE__); 463 env, SampleForTests_clazz(env), __FILE__);
391 return false; 464 return false;
392 } 465 }
393 466
394 return true; 467 return true;
395 } 468 }
396 469
397 } // namespace android 470 } // namespace android
398 } // namespace base 471 } // namespace base
399 472
400 #endif // org_chromium_example_jni_generator_SampleForTests_JNI 473 #endif // org_chromium_example_jni_generator_SampleForTests_JNI
OLDNEW
« no previous file with comments | « no previous file | base/android/jni_generator/jni_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698