| OLD | NEW |
| 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/Example | 8 // org/chromium/example/jni_generator/Example |
| 9 | 9 |
| 10 #ifndef org_chromium_example_jni_generator_Example_JNI | 10 #ifndef org_chromium_example_jni_generator_Example_JNI |
| 11 #define org_chromium_example_jni_generator_Example_JNI | 11 #define org_chromium_example_jni_generator_Example_JNI |
| 12 | 12 |
| 13 #include <jni.h> | 13 #include <jni.h> |
| 14 | 14 |
| 15 #include "base/android/jni_generator/jni_generator_helper.h" | 15 #include "base/android/jni_generator/jni_generator_helper.h" |
| 16 | 16 |
| 17 #include "base/android/jni_int_wrapper.h" | 17 #include "base/android/jni_int_wrapper.h" |
| 18 | 18 |
| 19 // Step 1: forward declarations. | 19 // Step 1: forward declarations. |
| 20 namespace { | 20 namespace { |
| 21 const char kExampleClassPath[] = "com/test/jni_generator/Example"; | 21 const char kExampleClassPath[] = "com/test/jni_generator/Example"; |
| 22 // Leaking this jclass as we cannot use LazyInstance from some threads. | 22 // Leaking this jclass as we cannot use LazyInstance from some threads. |
| 23 jclass g_Example_clazz = NULL; | 23 jclass g_Example_clazz = NULL; |
| 24 #define Example_clazz(env) g_Example_clazz | 24 #define Example_clazz(env) g_Example_clazz |
| 25 | 25 |
| 26 } // namespace | 26 } // namespace |
| 27 | 27 |
| 28 // Step 2: method stubs. |
| 29 |
| 28 static void Test(JNIEnv* env, jclass jcaller, | 30 static void Test(JNIEnv* env, jclass jcaller, |
| 29 jobject t); | 31 jobject t); |
| 30 | 32 |
| 33 static void Java_com_test_jni_1generator_Example_nativeTest(JNIEnv* env, jclass |
| 34 jcaller, |
| 35 jobject t) { |
| 36 return Test(env, jcaller, t); |
| 37 } |
| 38 |
| 31 static void Test2(JNIEnv* env, jclass jcaller, | 39 static void Test2(JNIEnv* env, jclass jcaller, |
| 32 jobject t); | 40 jobject t); |
| 33 | 41 |
| 42 static void Java_com_test_jni_1generator_Example_nativeTest2(JNIEnv* env, jclass |
| 43 jcaller, |
| 44 jobject t) { |
| 45 return Test2(env, jcaller, t); |
| 46 } |
| 47 |
| 34 static void Test3(JNIEnv* env, jclass jcaller, | 48 static void Test3(JNIEnv* env, jclass jcaller, |
| 35 jobject t); | 49 jobject t); |
| 36 | 50 |
| 51 static void Java_com_test_jni_1generator_Example_nativeTest3(JNIEnv* env, jclass |
| 52 jcaller, |
| 53 jobject t) { |
| 54 return Test3(env, jcaller, t); |
| 55 } |
| 56 |
| 37 static void Test4(JNIEnv* env, jclass jcaller, | 57 static void Test4(JNIEnv* env, jclass jcaller, |
| 38 jobject t); | 58 jobject t); |
| 39 | 59 |
| 40 // Step 2: method stubs. | 60 static void Java_com_test_jni_1generator_Example_nativeTest4(JNIEnv* env, jclass |
| 61 jcaller, |
| 62 jobject t) { |
| 63 return Test4(env, jcaller, t); |
| 64 } |
| 41 | 65 |
| 42 // Step 3: RegisterNatives. | 66 // Step 3: RegisterNatives. |
| 43 | 67 |
| 44 static const JNINativeMethod kMethodsExample[] = { | 68 static const JNINativeMethod kMethodsExample[] = { |
| 45 { "nativeTest", | 69 { "nativeTest", |
| 46 "(" | 70 "(" |
| 47 "Lorg/test2/Test;" | 71 "Lorg/test2/Test;" |
| 48 ")" | 72 ")" |
| 49 "V", reinterpret_cast<void*>(Test) }, | 73 "V", reinterpret_cast<void*>(Java_com_test_jni_1generator_Example_nativeTest) }, |
| 50 { "nativeTest2", | 74 { "nativeTest2", |
| 51 "(" | 75 "(" |
| 52 "Lorg/chromium/example3/PrefixFoo;" | 76 "Lorg/chromium/example3/PrefixFoo;" |
| 53 ")" | 77 ")" |
| 54 "V", reinterpret_cast<void*>(Test2) }, | 78 "V", reinterpret_cast<void*>(Java_com_test_jni_1generator_Example_nativeTest2) |
| 79 }, |
| 55 { "nativeTest3", | 80 { "nativeTest3", |
| 56 "(" | 81 "(" |
| 57 "Lorg/test3/Test;" | 82 "Lorg/test3/Test;" |
| 58 ")" | 83 ")" |
| 59 "V", reinterpret_cast<void*>(Test3) }, | 84 "V", reinterpret_cast<void*>(Java_com_test_jni_1generator_Example_nativeTest3) |
| 85 }, |
| 60 { "nativeTest4", | 86 { "nativeTest4", |
| 61 "(" | 87 "(" |
| 62 "Lorg/test3/TestBar$Inner;" | 88 "Lorg/test3/TestBar$Inner;" |
| 63 ")" | 89 ")" |
| 64 "V", reinterpret_cast<void*>(Test4) }, | 90 "V", reinterpret_cast<void*>(Java_com_test_jni_1generator_Example_nativeTest4) |
| 91 }, |
| 65 }; | 92 }; |
| 66 | 93 |
| 67 static bool RegisterNativesImpl(JNIEnv* env) { | 94 static bool RegisterNativesImpl(JNIEnv* env) { |
| 68 | 95 |
| 69 g_Example_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( | 96 g_Example_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( |
| 70 base::android::GetClass(env, kExampleClassPath).obj())); | 97 base::android::GetClass(env, kExampleClassPath).obj())); |
| 71 | 98 |
| 72 const int kMethodsExampleSize = arraysize(kMethodsExample); | 99 const int kMethodsExampleSize = arraysize(kMethodsExample); |
| 73 | 100 |
| 74 if (env->RegisterNatives(Example_clazz(env), | 101 if (env->RegisterNatives(Example_clazz(env), |
| 75 kMethodsExample, | 102 kMethodsExample, |
| 76 kMethodsExampleSize) < 0) { | 103 kMethodsExampleSize) < 0) { |
| 77 jni_generator::HandleRegistrationError( | 104 jni_generator::HandleRegistrationError( |
| 78 env, Example_clazz(env), __FILE__); | 105 env, Example_clazz(env), __FILE__); |
| 79 return false; | 106 return false; |
| 80 } | 107 } |
| 81 | 108 |
| 82 return true; | 109 return true; |
| 83 } | 110 } |
| 84 | 111 |
| 85 #endif // org_chromium_example_jni_generator_Example_JNI | 112 #endif // org_chromium_example_jni_generator_Example_JNI |
| OLD | NEW |