OLD | NEW |
1 // Copyright 2014 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/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 #include "base/android/jni_int_wrapper.h" |
| 18 |
17 // Step 1: forward declarations. | 19 // Step 1: forward declarations. |
18 namespace { | 20 namespace { |
19 const char kTestClassPath[] = "org/chromium/example/jni_generator/Test"; | 21 const char kTestClassPath[] = "org/chromium/example/jni_generator/Test"; |
20 // Leaking this jclass as we cannot use LazyInstance from some threads. | 22 // Leaking this jclass as we cannot use LazyInstance from some threads. |
21 jclass g_Test_clazz = NULL; | 23 jclass g_Test_clazz = NULL; |
22 jmethodID g_Test_testMethodWithParam = NULL; | 24 jmethodID g_Test_testMethodWithParam = NULL; |
23 jmethodID g_Test_testStaticMethodWithParam = NULL; | 25 jmethodID g_Test_testStaticMethodWithParam = NULL; |
24 jmethodID g_Test_testMethodWithNoParam = NULL; | 26 jmethodID g_Test_testMethodWithNoParam = NULL; |
25 jmethodID g_Test_testStaticMethodWithNoParam = NULL; | 27 jmethodID g_Test_testStaticMethodWithNoParam = NULL; |
26 } // namespace | 28 } // namespace |
27 | 29 |
28 // Step 2: method stubs. | 30 // Step 2: method stubs. |
29 static jint Method(JNIEnv* env, jobject jcaller, | 31 static jint Method(JNIEnv* env, jobject jcaller, |
30 jlong nativeTest, | 32 jlong nativeTest, |
31 jint arg1) { | 33 jint arg1) { |
32 Test* native = reinterpret_cast<Test*>(nativeTest); | 34 Test* native = reinterpret_cast<Test*>(nativeTest); |
33 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0); | 35 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0); |
34 return native->Method(env, jcaller, arg1); | 36 return native->Method(env, jcaller, arg1); |
35 } | 37 } |
36 | 38 |
37 namespace { | 39 namespace { |
38 | 40 |
39 static void testMethodWithParam(JNIEnv* env, jobject obj, jint iParam) { | 41 static void testMethodWithParam(JNIEnv* env, jobject obj, JniIntWrapper iParam) |
| 42 { |
40 env->CallVoidMethod(obj, | 43 env->CallVoidMethod(obj, |
41 g_Test_testMethodWithParam, iParam); | 44 g_Test_testMethodWithParam, as_jint(iParam)); |
42 | 45 |
43 } | 46 } |
44 | 47 |
45 static jint testStaticMethodWithParam(JNIEnv* env, jint iParam) { | 48 static jint testStaticMethodWithParam(JNIEnv* env, JniIntWrapper iParam) { |
46 jint ret = env->CallStaticIntMethod(g_Test_clazz, | 49 jint ret = env->CallStaticIntMethod(g_Test_clazz, |
47 g_Test_testStaticMethodWithParam, iParam); | 50 g_Test_testStaticMethodWithParam, as_jint(iParam)); |
48 return ret; | 51 return ret; |
49 } | 52 } |
50 | 53 |
51 static jdouble testMethodWithNoParam(JNIEnv* env) { | 54 static jdouble testMethodWithNoParam(JNIEnv* env) { |
52 jdouble ret = env->CallStaticDoubleMethod(g_Test_clazz, | 55 jdouble ret = env->CallStaticDoubleMethod(g_Test_clazz, |
53 g_Test_testMethodWithNoParam); | 56 g_Test_testMethodWithNoParam); |
54 return ret; | 57 return ret; |
55 } | 58 } |
56 | 59 |
57 static base::android::ScopedJavaLocalRef<jstring> | 60 static base::android::ScopedJavaLocalRef<jstring> |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 return true; | 134 return true; |
132 } | 135 } |
133 | 136 |
134 extern "C" JNIEXPORT bool JNICALL | 137 extern "C" JNIEXPORT bool JNICALL |
135 Java_org_chromium_example_jni_generator_Test_nativeInitNativeClass(JNIEnv* env, | 138 Java_org_chromium_example_jni_generator_Test_nativeInitNativeClass(JNIEnv* env, |
136 jclass clazz) { | 139 jclass clazz) { |
137 return RegisterNativesImpl(env, clazz); | 140 return RegisterNativesImpl(env, clazz); |
138 } | 141 } |
139 | 142 |
140 #endif // org_chromium_example_jni_generator_Test_JNI | 143 #endif // org_chromium_example_jni_generator_Test_JNI |
OLD | NEW |