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

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

Issue 132013003: Android: moves jni_generator samples to use long for JNI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: With fixes Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | base/android/jni_generator/java/src/org/chromium/example/jni_generator/SampleForTests.java » ('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 (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 16 matching lines...) Expand all
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 36
37 static jint Init(JNIEnv* env, jobject jcaller, 37 static jlong Init(JNIEnv* env, jobject jcaller,
38 jstring param); 38 jstring param);
39 39
40 static jdouble GetDoubleFunction(JNIEnv* env, jobject jcaller); 40 static jdouble GetDoubleFunction(JNIEnv* env, jobject jcaller);
41 41
42 static jfloat GetFloatFunction(JNIEnv* env, jclass jcaller); 42 static jfloat GetFloatFunction(JNIEnv* env, jclass jcaller);
43 43
44 static void SetNonPODDatatype(JNIEnv* env, jobject jcaller, 44 static void SetNonPODDatatype(JNIEnv* env, jobject jcaller,
45 jobject rect); 45 jobject rect);
46 46
47 static jobject GetNonPODDatatype(JNIEnv* env, jobject jcaller); 47 static jobject GetNonPODDatatype(JNIEnv* env, jobject jcaller);
48 48
49 // Step 2: method stubs. 49 // Step 2: method stubs.
50 static void Destroy(JNIEnv* env, jobject jcaller, 50 static void Destroy(JNIEnv* env, jobject jcaller,
51 jint nativeCPPClass) { 51 jlong nativeCPPClass) {
52 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); 52 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass);
53 CHECK_NATIVE_PTR(env, jcaller, native, "Destroy"); 53 CHECK_NATIVE_PTR(env, jcaller, native, "Destroy");
54 return native->Destroy(env, jcaller); 54 return native->Destroy(env, jcaller);
55 } 55 }
56 56
57 static jint Method(JNIEnv* env, jobject jcaller, 57 static jint Method(JNIEnv* env, jobject jcaller,
58 jint nativeCPPClass) { 58 jlong nativeCPPClass) {
59 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); 59 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass);
60 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0); 60 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0);
61 return native->Method(env, jcaller); 61 return native->Method(env, jcaller);
62 } 62 }
63 63
64 static jdouble MethodOtherP0(JNIEnv* env, jobject jcaller, 64 static jdouble MethodOtherP0(JNIEnv* env, jobject jcaller,
65 jint nativePtr) { 65 jlong nativePtr) {
66 CPPClass::InnerClass* native = 66 CPPClass::InnerClass* native =
67 reinterpret_cast<CPPClass::InnerClass*>(nativePtr); 67 reinterpret_cast<CPPClass::InnerClass*>(nativePtr);
68 CHECK_NATIVE_PTR(env, jcaller, native, "MethodOtherP0", 0); 68 CHECK_NATIVE_PTR(env, jcaller, native, "MethodOtherP0", 0);
69 return native->MethodOtherP0(env, jcaller); 69 return native->MethodOtherP0(env, jcaller);
70 } 70 }
71 71
72 static void AddStructB(JNIEnv* env, jobject jcaller, 72 static void AddStructB(JNIEnv* env, jobject jcaller,
73 jint nativeCPPClass, 73 jlong nativeCPPClass,
74 jobject b) { 74 jobject b) {
75 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); 75 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass);
76 CHECK_NATIVE_PTR(env, jcaller, native, "AddStructB"); 76 CHECK_NATIVE_PTR(env, jcaller, native, "AddStructB");
77 return native->AddStructB(env, jcaller, b); 77 return native->AddStructB(env, jcaller, b);
78 } 78 }
79 79
80 static void IterateAndDoSomethingWithStructB(JNIEnv* env, jobject jcaller, 80 static void IterateAndDoSomethingWithStructB(JNIEnv* env, jobject jcaller,
81 jint nativeCPPClass) { 81 jlong nativeCPPClass) {
82 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); 82 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass);
83 CHECK_NATIVE_PTR(env, jcaller, native, "IterateAndDoSomethingWithStructB"); 83 CHECK_NATIVE_PTR(env, jcaller, native, "IterateAndDoSomethingWithStructB");
84 return native->IterateAndDoSomethingWithStructB(env, jcaller); 84 return native->IterateAndDoSomethingWithStructB(env, jcaller);
85 } 85 }
86 86
87 static jstring ReturnAString(JNIEnv* env, jobject jcaller, 87 static jstring ReturnAString(JNIEnv* env, jobject jcaller,
88 jint nativeCPPClass) { 88 jlong nativeCPPClass) {
89 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); 89 CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass);
90 CHECK_NATIVE_PTR(env, jcaller, native, "ReturnAString", NULL); 90 CHECK_NATIVE_PTR(env, jcaller, native, "ReturnAString", NULL);
91 return native->ReturnAString(env, jcaller).Release(); 91 return native->ReturnAString(env, jcaller).Release();
92 } 92 }
93 93
94 static base::subtle::AtomicWord g_SampleForTests_javaMethod = 0; 94 static base::subtle::AtomicWord g_SampleForTests_javaMethod = 0;
95 static jint Java_SampleForTests_javaMethod(JNIEnv* env, jobject obj, jint foo, 95 static jint Java_SampleForTests_javaMethod(JNIEnv* env, jobject obj, jint foo,
96 jint bar) { 96 jint bar) {
97 /* Must call RegisterNativesImpl() */ 97 /* Must call RegisterNativesImpl() */
98 CHECK_CLAZZ(env, obj, 98 CHECK_CLAZZ(env, obj,
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 return base::android::ScopedJavaLocalRef<jstring>(env, ret); 308 return base::android::ScopedJavaLocalRef<jstring>(env, ret);
309 } 309 }
310 310
311 // Step 3: RegisterNatives. 311 // Step 3: RegisterNatives.
312 312
313 static const JNINativeMethod kMethodsSampleForTests[] = { 313 static const JNINativeMethod kMethodsSampleForTests[] = {
314 { "nativeInit", 314 { "nativeInit",
315 "(" 315 "("
316 "Ljava/lang/String;" 316 "Ljava/lang/String;"
317 ")" 317 ")"
318 "I", reinterpret_cast<void*>(Init) }, 318 "J", reinterpret_cast<void*>(Init) },
319 { "nativeDestroy", 319 { "nativeDestroy",
320 "(" 320 "("
321 "I" 321 "J"
322 ")" 322 ")"
323 "V", reinterpret_cast<void*>(Destroy) }, 323 "V", reinterpret_cast<void*>(Destroy) },
324 { "nativeGetDoubleFunction", 324 { "nativeGetDoubleFunction",
325 "(" 325 "("
326 ")" 326 ")"
327 "D", reinterpret_cast<void*>(GetDoubleFunction) }, 327 "D", reinterpret_cast<void*>(GetDoubleFunction) },
328 { "nativeGetFloatFunction", 328 { "nativeGetFloatFunction",
329 "(" 329 "("
330 ")" 330 ")"
331 "F", reinterpret_cast<void*>(GetFloatFunction) }, 331 "F", reinterpret_cast<void*>(GetFloatFunction) },
332 { "nativeSetNonPODDatatype", 332 { "nativeSetNonPODDatatype",
333 "(" 333 "("
334 "Landroid/graphics/Rect;" 334 "Landroid/graphics/Rect;"
335 ")" 335 ")"
336 "V", reinterpret_cast<void*>(SetNonPODDatatype) }, 336 "V", reinterpret_cast<void*>(SetNonPODDatatype) },
337 { "nativeGetNonPODDatatype", 337 { "nativeGetNonPODDatatype",
338 "(" 338 "("
339 ")" 339 ")"
340 "Ljava/lang/Object;", reinterpret_cast<void*>(GetNonPODDatatype) }, 340 "Ljava/lang/Object;", reinterpret_cast<void*>(GetNonPODDatatype) },
341 { "nativeMethod", 341 { "nativeMethod",
342 "(" 342 "("
343 "I" 343 "J"
344 ")" 344 ")"
345 "I", reinterpret_cast<void*>(Method) }, 345 "I", reinterpret_cast<void*>(Method) },
346 { "nativeMethodOtherP0", 346 { "nativeMethodOtherP0",
347 "(" 347 "("
348 "I" 348 "J"
349 ")" 349 ")"
350 "D", reinterpret_cast<void*>(MethodOtherP0) }, 350 "D", reinterpret_cast<void*>(MethodOtherP0) },
351 { "nativeAddStructB", 351 { "nativeAddStructB",
352 "(" 352 "("
353 "I" 353 "J"
354 "Lorg/chromium/example/jni_generator/SampleForTests$InnerStructB;" 354 "Lorg/chromium/example/jni_generator/SampleForTests$InnerStructB;"
355 ")" 355 ")"
356 "V", reinterpret_cast<void*>(AddStructB) }, 356 "V", reinterpret_cast<void*>(AddStructB) },
357 { "nativeIterateAndDoSomethingWithStructB", 357 { "nativeIterateAndDoSomethingWithStructB",
358 "(" 358 "("
359 "I" 359 "J"
360 ")" 360 ")"
361 "V", reinterpret_cast<void*>(IterateAndDoSomethingWithStructB) }, 361 "V", reinterpret_cast<void*>(IterateAndDoSomethingWithStructB) },
362 { "nativeReturnAString", 362 { "nativeReturnAString",
363 "(" 363 "("
364 "I" 364 "J"
365 ")" 365 ")"
366 "Ljava/lang/String;", reinterpret_cast<void*>(ReturnAString) }, 366 "Ljava/lang/String;", reinterpret_cast<void*>(ReturnAString) },
367 }; 367 };
368 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); 377 const int kMethodsSampleForTestsSize = arraysize(kMethodsSampleForTests);
378 378
379 if (env->RegisterNatives(g_SampleForTests_clazz, 379 if (env->RegisterNatives(g_SampleForTests_clazz,
380 kMethodsSampleForTests, 380 kMethodsSampleForTests,
381 kMethodsSampleForTestsSize) < 0) { 381 kMethodsSampleForTestsSize) < 0) {
382 jni_generator::HandleRegistrationError( 382 jni_generator::HandleRegistrationError(
383 env, g_SampleForTests_clazz, __FILE__); 383 env, g_SampleForTests_clazz, __FILE__);
384 return false; 384 return false;
385 } 385 }
386 386
387 return true; 387 return true;
388 } 388 }
389 389
390 } // namespace android 390 } // namespace android
391 } // namespace base 391 } // namespace base
392 392
393 #endif // org_chromium_example_jni_generator_SampleForTests_JNI 393 #endif // org_chromium_example_jni_generator_SampleForTests_JNI
OLDNEW
« no previous file with comments | « no previous file | base/android/jni_generator/java/src/org/chromium/example/jni_generator/SampleForTests.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698