| 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/Test | 8 // org/chromium/example/jni_generator/Test |
| 9 | 9 |
| 10 #ifndef org_chromium_example_jni_generator_Test_JNI | 10 #ifndef org_chromium_example_jni_generator_Test_JNI |
| 11 #define org_chromium_example_jni_generator_Test_JNI | 11 #define org_chromium_example_jni_generator_Test_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 // Step 1: forward declarations. | 17 // Step 1: forward declarations. |
| 18 namespace { | 18 namespace { |
| 19 const char kTestClassPath[] = "org/chromium/example/jni_generator/Test"; | 19 const char kTestClassPath[] = "org/chromium/example/jni_generator/Test"; |
| 20 // Leaking this jclass as we cannot use LazyInstance from some threads. | 20 // Leaking this jclass as we cannot use LazyInstance from some threads. |
| 21 jclass g_Test_clazz = NULL; | 21 jclass g_Test_clazz = NULL; |
| 22 jmethodID g_Test_testMethodWithParam = NULL; | 22 jmethodID g_Test_testMethodWithParam = NULL; |
| 23 jmethodID g_Test_testStaticMethodWithParam = NULL; | 23 jmethodID g_Test_testStaticMethodWithParam = NULL; |
| 24 jmethodID g_Test_testMethodWithNoParam = NULL; | 24 jmethodID g_Test_testMethodWithNoParam = NULL; |
| 25 jmethodID g_Test_testStaticMethodWithNoParam = NULL; | 25 jmethodID g_Test_testStaticMethodWithNoParam = NULL; |
| 26 } // namespace | 26 } // namespace |
| 27 | 27 |
| 28 // Step 2: method stubs. | 28 // Step 2: method stubs. |
| 29 static jint Method(JNIEnv* env, jobject jcaller, | 29 static jint Method(JNIEnv* env, jobject jcaller, |
| 30 jint nativeTest, | 30 jlong nativeTest, |
| 31 jint arg1) { | 31 jint arg1) { |
| 32 Test* native = reinterpret_cast<Test*>(nativeTest); | 32 Test* native = reinterpret_cast<Test*>(nativeTest); |
| 33 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0); | 33 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0); |
| 34 return native->Method(env, jcaller, arg1); | 34 return native->Method(env, jcaller, arg1); |
| 35 } | 35 } |
| 36 | 36 |
| 37 namespace { | 37 namespace { |
| 38 | 38 |
| 39 static void testMethodWithParam(JNIEnv* env, jobject obj, jint iParam) { | 39 static void testMethodWithParam(JNIEnv* env, jobject obj, jint iParam) { |
| 40 env->CallVoidMethod(obj, | 40 env->CallVoidMethod(obj, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 60 g_Test_testStaticMethodWithNoParam)); | 60 g_Test_testStaticMethodWithNoParam)); |
| 61 return base::android::ScopedJavaLocalRef<jstring>(env, ret); | 61 return base::android::ScopedJavaLocalRef<jstring>(env, ret); |
| 62 } | 62 } |
| 63 } // namespace | 63 } // namespace |
| 64 | 64 |
| 65 // Step 3: RegisterNatives. | 65 // Step 3: RegisterNatives. |
| 66 | 66 |
| 67 static const JNINativeMethod kMethodsTest[] = { | 67 static const JNINativeMethod kMethodsTest[] = { |
| 68 { "nativeMethod", | 68 { "nativeMethod", |
| 69 "(" | 69 "(" |
| 70 "I" | 70 "J" |
| 71 "I" | 71 "I" |
| 72 ")" | 72 ")" |
| 73 "I", reinterpret_cast<void*>(Method) }, | 73 "I", reinterpret_cast<void*>(Method) }, |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 static bool RegisterNativesImpl(JNIEnv* env, jclass clazz) { | 76 static bool RegisterNativesImpl(JNIEnv* env, jclass clazz) { |
| 77 g_Test_clazz = static_cast<jclass>(env->NewWeakGlobalRef(clazz)); | 77 g_Test_clazz = static_cast<jclass>(env->NewWeakGlobalRef(clazz)); |
| 78 | 78 |
| 79 const int kMethodsTestSize = arraysize(kMethodsTest); | 79 const int kMethodsTestSize = arraysize(kMethodsTest); |
| 80 | 80 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 return true; | 131 return true; |
| 132 } | 132 } |
| 133 | 133 |
| 134 extern "C" JNIEXPORT bool JNICALL | 134 extern "C" JNIEXPORT bool JNICALL |
| 135 Java_org_chromium_example_jni_generator_Test_initNativeClass(JNIEnv* env, jclass | 135 Java_org_chromium_example_jni_generator_Test_initNativeClass(JNIEnv* env, jclass |
| 136 clazz) { | 136 clazz) { |
| 137 return RegisterNativesImpl(env, clazz); | 137 return RegisterNativesImpl(env, clazz); |
| 138 } | 138 } |
| 139 | 139 |
| 140 #endif // org_chromium_example_jni_generator_Test_JNI | 140 #endif // org_chromium_example_jni_generator_Test_JNI |
| OLD | NEW |