OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 // This file is autogenerated by | |
6 // base/android/jni_generator/jni_generator.py | |
7 // For | |
8 // org/chromium/example/jni_generator/SampleForTests | |
9 | |
10 #ifndef org_chromium_example_jni_generator_SampleForTests_JNI | |
11 #define org_chromium_example_jni_generator_SampleForTests_JNI | |
12 | |
13 #include <jni.h> | |
14 | |
15 #include "base/android/jni_generator/jni_generator_helper.h" | |
16 | |
17 // Step 1: forward declarations. | |
18 namespace { | |
19 const char kSampleForTestsClassPath[] = | |
20 "org/chromium/example/jni_generator/SampleForTests"; | |
21 // Leaking this jclass as we cannot use LazyInstance from some threads. | |
22 jclass g_SampleForTests_clazz = NULL; | |
23 | |
24 } // namespace | |
25 | |
26 // Step 2: method stubs. | |
27 | |
28 extern "C" { | |
29 __attribute__((visibility("default"))) | |
30 jint | |
31 Java_org_chromium_example_jni_1generator_SampleForTests_nativeStaticMethod(J NIEnv* | |
32 env, | |
33 jobject jcaller, | |
34 jlong nativeTest, | |
35 jint arg1) { | |
36 Test* native = reinterpret_cast<Test*>(nativeTest); | |
37 CHECK_NATIVE_PTR(env, jcaller, native, "StaticMethod", 0); | |
38 return native->StaticMethod(env, jcaller, arg1); | |
39 } | |
40 | |
41 __attribute__((visibility("default"))) | |
42 jint | |
43 Java_org_chromium_example_jni_1generator_SampleForTests_nativeMethod(JNIEnv* | |
bulach
2014/04/16 11:22:35
hmm... looks like "nativeInitClass" is missing?
it
ostap
2014/04/16 20:36:04
That's was a special case for native methods regis
| |
44 env, | |
45 jobject jcaller, | |
46 jlong nativeTest, | |
47 jint arg1) { | |
48 Test* native = reinterpret_cast<Test*>(nativeTest); | |
49 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0); | |
50 return native->Method(env, jcaller, arg1); | |
51 } | |
52 | |
53 static base::subtle::AtomicWord g_SampleForTests_testMethodWithParam = 0; | |
54 static void Java_SampleForTests_testMethodWithParam(JNIEnv* env, jobject obj, | |
55 jint iParam) { | |
56 /* Must call RegisterNativesImpl() */ | |
57 CHECK_CLAZZ(env, obj, | |
58 g_SampleForTests_clazz); | |
59 jmethodID method_id = | |
60 base::android::MethodID::LazyGet< | |
61 base::android::MethodID::TYPE_INSTANCE>( | |
62 env, g_SampleForTests_clazz, | |
63 "testMethodWithParam", | |
64 | |
65 "(" | |
66 "I" | |
67 ")" | |
68 "V", | |
69 &g_SampleForTests_testMethodWithParam); | |
70 | |
71 env->CallVoidMethod(obj, | |
72 method_id, iParam); | |
73 jni_generator::CheckException(env); | |
74 | |
75 } | |
76 | |
77 static base::subtle::AtomicWord g_SampleForTests_testMethodWithParamAndReturn = | |
78 0; | |
79 static base::android::ScopedJavaLocalRef<jstring> | |
80 Java_SampleForTests_testMethodWithParamAndReturn(JNIEnv* env, jobject obj, | |
81 jint iParam) { | |
82 /* Must call RegisterNativesImpl() */ | |
83 CHECK_CLAZZ(env, obj, | |
84 g_SampleForTests_clazz, NULL); | |
85 jmethodID method_id = | |
86 base::android::MethodID::LazyGet< | |
87 base::android::MethodID::TYPE_INSTANCE>( | |
88 env, g_SampleForTests_clazz, | |
89 "testMethodWithParamAndReturn", | |
90 | |
91 "(" | |
92 "I" | |
93 ")" | |
94 "Ljava/lang/String;", | |
95 &g_SampleForTests_testMethodWithParamAndReturn); | |
96 | |
97 jstring ret = | |
98 static_cast<jstring>(env->CallObjectMethod(obj, | |
99 method_id, iParam)); | |
100 jni_generator::CheckException(env); | |
101 return base::android::ScopedJavaLocalRef<jstring>(env, ret); | |
102 } | |
103 | |
104 static base::subtle::AtomicWord g_SampleForTests_testStaticMethodWithParam = 0; | |
105 static jint Java_SampleForTests_testStaticMethodWithParam(JNIEnv* env, jint | |
106 iParam) { | |
107 /* Must call RegisterNativesImpl() */ | |
108 CHECK_CLAZZ(env, g_SampleForTests_clazz, | |
109 g_SampleForTests_clazz, 0); | |
110 jmethodID method_id = | |
111 base::android::MethodID::LazyGet< | |
112 base::android::MethodID::TYPE_STATIC>( | |
113 env, g_SampleForTests_clazz, | |
114 "testStaticMethodWithParam", | |
115 | |
116 "(" | |
117 "I" | |
118 ")" | |
119 "I", | |
120 &g_SampleForTests_testStaticMethodWithParam); | |
121 | |
122 jint ret = | |
123 env->CallStaticIntMethod(g_SampleForTests_clazz, | |
124 method_id, iParam); | |
125 jni_generator::CheckException(env); | |
126 return ret; | |
127 } | |
128 | |
129 static base::subtle::AtomicWord g_SampleForTests_testMethodWithNoParam = 0; | |
130 static jdouble Java_SampleForTests_testMethodWithNoParam(JNIEnv* env) { | |
131 /* Must call RegisterNativesImpl() */ | |
132 CHECK_CLAZZ(env, g_SampleForTests_clazz, | |
133 g_SampleForTests_clazz, 0); | |
134 jmethodID method_id = | |
135 base::android::MethodID::LazyGet< | |
136 base::android::MethodID::TYPE_STATIC>( | |
137 env, g_SampleForTests_clazz, | |
138 "testMethodWithNoParam", | |
139 | |
140 "(" | |
141 ")" | |
142 "D", | |
143 &g_SampleForTests_testMethodWithNoParam); | |
144 | |
145 jdouble ret = | |
146 env->CallStaticDoubleMethod(g_SampleForTests_clazz, | |
147 method_id); | |
148 jni_generator::CheckException(env); | |
149 return ret; | |
150 } | |
151 | |
152 static base::subtle::AtomicWord g_SampleForTests_testStaticMethodWithNoParam = | |
153 0; | |
154 static base::android::ScopedJavaLocalRef<jstring> | |
155 Java_SampleForTests_testStaticMethodWithNoParam(JNIEnv* env) { | |
156 /* Must call RegisterNativesImpl() */ | |
157 CHECK_CLAZZ(env, g_SampleForTests_clazz, | |
158 g_SampleForTests_clazz, NULL); | |
159 jmethodID method_id = | |
160 base::android::MethodID::LazyGet< | |
161 base::android::MethodID::TYPE_STATIC>( | |
162 env, g_SampleForTests_clazz, | |
163 "testStaticMethodWithNoParam", | |
164 | |
165 "(" | |
166 ")" | |
167 "Ljava/lang/String;", | |
168 &g_SampleForTests_testStaticMethodWithNoParam); | |
169 | |
170 jstring ret = | |
171 static_cast<jstring>(env->CallStaticObjectMethod(g_SampleForTests_clazz, | |
172 method_id)); | |
173 jni_generator::CheckException(env); | |
174 return base::android::ScopedJavaLocalRef<jstring>(env, ret); | |
175 } | |
176 }; // extern "C" | |
177 | |
178 // Step 3: RegisterNatives. | |
179 | |
180 static bool RegisterNativesImpl(JNIEnv* env, jclass clazz) { | |
181 g_SampleForTests_clazz = static_cast<jclass>(env->NewWeakGlobalRef(clazz)); | |
182 | |
183 return true; | |
184 } | |
185 | |
186 #endif // org_chromium_example_jni_generator_SampleForTests_JNI | |
OLD | NEW |