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

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

Powered by Google App Engine
This is Rietveld 408576698