| OLD | NEW |
| (Empty) |
| 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 | |
| 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 #include "base/android/jni_int_wrapper.h" | |
| 18 | |
| 19 // Step 1: forward declarations. | |
| 20 namespace { | |
| 21 const char kSampleForTestsClassPath[] = | |
| 22 "org/chromium/example/jni_generator/SampleForTests"; | |
| 23 // Leaking this jclass as we cannot use LazyInstance from some threads. | |
| 24 base::subtle::AtomicWord g_SampleForTests_clazz __attribute__((unused)) = 0; | |
| 25 #define SampleForTests_clazz(env) base::android::LazyGetClass(env, kSampleForTes
tsClassPath, &g_SampleForTests_clazz) | |
| 26 | |
| 27 } // namespace | |
| 28 | |
| 29 // Step 2: method stubs. | |
| 30 extern "C" __attribute__((visibility("default"))) | |
| 31 jint | |
| 32 Java_org_chromium_example_jni_1generator_SampleForTests_nativeStaticMethod(J
NIEnv* | |
| 33 env, | |
| 34 jobject jcaller, | |
| 35 jlong nativeTest, | |
| 36 jint arg1) { | |
| 37 Test* native = reinterpret_cast<Test*>(nativeTest); | |
| 38 CHECK_NATIVE_PTR(env, jcaller, native, "StaticMethod", 0); | |
| 39 return native->StaticMethod(env, JavaParamRef<jobject>(env, jcaller), arg1); | |
| 40 } | |
| 41 | |
| 42 extern "C" __attribute__((visibility("default"))) | |
| 43 jint | |
| 44 Java_org_chromium_example_jni_1generator_SampleForTests_nativeMethod(JNIEnv* | |
| 45 env, | |
| 46 jobject jcaller, | |
| 47 jlong nativeTest, | |
| 48 jint arg1) { | |
| 49 Test* native = reinterpret_cast<Test*>(nativeTest); | |
| 50 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0); | |
| 51 return native->Method(env, JavaParamRef<jobject>(env, jcaller), arg1); | |
| 52 } | |
| 53 | |
| 54 static jint Init(JNIEnv* env, const JavaParamRef<jobject>& jcaller); | |
| 55 | |
| 56 extern "C" __attribute__((visibility("default"))) | |
| 57 jint | |
| 58 Java_org_chromium_example_jni_1generator_SampleForTests_00024MyInnerClass_na
tiveInit(JNIEnv* | |
| 59 env, jobject jcaller) { | |
| 60 return Init(env, JavaParamRef<jobject>(env, jcaller)); | |
| 61 } | |
| 62 | |
| 63 static jint Init(JNIEnv* env, const JavaParamRef<jobject>& jcaller); | |
| 64 | |
| 65 extern "C" __attribute__((visibility("default"))) | |
| 66 jint | |
| 67 Java_org_chromium_example_jni_1generator_SampleForTests_00024MyOtherInnerCla
ss_nativeInit(JNIEnv* | |
| 68 env, jobject jcaller) { | |
| 69 return Init(env, JavaParamRef<jobject>(env, jcaller)); | |
| 70 } | |
| 71 | |
| 72 static base::subtle::AtomicWord g_SampleForTests_testMethodWithParam = 0; | |
| 73 static void Java_SampleForTests_testMethodWithParam(JNIEnv* env, jobject obj, | |
| 74 JniIntWrapper iParam) { | |
| 75 /* Must call RegisterNativesImpl() */ | |
| 76 CHECK_CLAZZ(env, obj, | |
| 77 SampleForTests_clazz(env)); | |
| 78 jmethodID method_id = | |
| 79 base::android::MethodID::LazyGet< | |
| 80 base::android::MethodID::TYPE_INSTANCE>( | |
| 81 env, SampleForTests_clazz(env), | |
| 82 "testMethodWithParam", | |
| 83 | |
| 84 "(" | |
| 85 "I" | |
| 86 ")" | |
| 87 "V", | |
| 88 &g_SampleForTests_testMethodWithParam); | |
| 89 | |
| 90 env->CallVoidMethod(obj, | |
| 91 method_id, as_jint(iParam)); | |
| 92 jni_generator::CheckException(env); | |
| 93 | |
| 94 } | |
| 95 | |
| 96 static base::subtle::AtomicWord g_SampleForTests_testMethodWithParamAndReturn = | |
| 97 0; | |
| 98 static ScopedJavaLocalRef<jstring> | |
| 99 Java_SampleForTests_testMethodWithParamAndReturn(JNIEnv* env, jobject obj, | |
| 100 JniIntWrapper iParam) { | |
| 101 /* Must call RegisterNativesImpl() */ | |
| 102 CHECK_CLAZZ(env, obj, | |
| 103 SampleForTests_clazz(env), NULL); | |
| 104 jmethodID method_id = | |
| 105 base::android::MethodID::LazyGet< | |
| 106 base::android::MethodID::TYPE_INSTANCE>( | |
| 107 env, SampleForTests_clazz(env), | |
| 108 "testMethodWithParamAndReturn", | |
| 109 | |
| 110 "(" | |
| 111 "I" | |
| 112 ")" | |
| 113 "Ljava/lang/String;", | |
| 114 &g_SampleForTests_testMethodWithParamAndReturn); | |
| 115 | |
| 116 jstring ret = | |
| 117 static_cast<jstring>(env->CallObjectMethod(obj, | |
| 118 method_id, as_jint(iParam))); | |
| 119 jni_generator::CheckException(env); | |
| 120 return ScopedJavaLocalRef<jstring>(env, ret); | |
| 121 } | |
| 122 | |
| 123 static base::subtle::AtomicWord g_SampleForTests_testStaticMethodWithParam = 0; | |
| 124 static jint Java_SampleForTests_testStaticMethodWithParam(JNIEnv* env, | |
| 125 JniIntWrapper iParam) { | |
| 126 /* Must call RegisterNativesImpl() */ | |
| 127 CHECK_CLAZZ(env, SampleForTests_clazz(env), | |
| 128 SampleForTests_clazz(env), 0); | |
| 129 jmethodID method_id = | |
| 130 base::android::MethodID::LazyGet< | |
| 131 base::android::MethodID::TYPE_STATIC>( | |
| 132 env, SampleForTests_clazz(env), | |
| 133 "testStaticMethodWithParam", | |
| 134 | |
| 135 "(" | |
| 136 "I" | |
| 137 ")" | |
| 138 "I", | |
| 139 &g_SampleForTests_testStaticMethodWithParam); | |
| 140 | |
| 141 jint ret = | |
| 142 env->CallStaticIntMethod(SampleForTests_clazz(env), | |
| 143 method_id, as_jint(iParam)); | |
| 144 jni_generator::CheckException(env); | |
| 145 return ret; | |
| 146 } | |
| 147 | |
| 148 static base::subtle::AtomicWord g_SampleForTests_testMethodWithNoParam = 0; | |
| 149 static jdouble Java_SampleForTests_testMethodWithNoParam(JNIEnv* env) { | |
| 150 /* Must call RegisterNativesImpl() */ | |
| 151 CHECK_CLAZZ(env, SampleForTests_clazz(env), | |
| 152 SampleForTests_clazz(env), 0); | |
| 153 jmethodID method_id = | |
| 154 base::android::MethodID::LazyGet< | |
| 155 base::android::MethodID::TYPE_STATIC>( | |
| 156 env, SampleForTests_clazz(env), | |
| 157 "testMethodWithNoParam", | |
| 158 | |
| 159 "(" | |
| 160 ")" | |
| 161 "D", | |
| 162 &g_SampleForTests_testMethodWithNoParam); | |
| 163 | |
| 164 jdouble ret = | |
| 165 env->CallStaticDoubleMethod(SampleForTests_clazz(env), | |
| 166 method_id); | |
| 167 jni_generator::CheckException(env); | |
| 168 return ret; | |
| 169 } | |
| 170 | |
| 171 static base::subtle::AtomicWord g_SampleForTests_testStaticMethodWithNoParam = | |
| 172 0; | |
| 173 static ScopedJavaLocalRef<jstring> | |
| 174 Java_SampleForTests_testStaticMethodWithNoParam(JNIEnv* env) { | |
| 175 /* Must call RegisterNativesImpl() */ | |
| 176 CHECK_CLAZZ(env, SampleForTests_clazz(env), | |
| 177 SampleForTests_clazz(env), NULL); | |
| 178 jmethodID method_id = | |
| 179 base::android::MethodID::LazyGet< | |
| 180 base::android::MethodID::TYPE_STATIC>( | |
| 181 env, SampleForTests_clazz(env), | |
| 182 "testStaticMethodWithNoParam", | |
| 183 | |
| 184 "(" | |
| 185 ")" | |
| 186 "Ljava/lang/String;", | |
| 187 &g_SampleForTests_testStaticMethodWithNoParam); | |
| 188 | |
| 189 jstring ret = | |
| 190 static_cast<jstring>(env->CallStaticObjectMethod(SampleForTests_clazz(env), | |
| 191 method_id)); | |
| 192 jni_generator::CheckException(env); | |
| 193 return ScopedJavaLocalRef<jstring>(env, ret); | |
| 194 } | |
| 195 | |
| 196 // Step 3: RegisterNatives. | |
| 197 | |
| 198 static bool RegisterNativesImpl(JNIEnv* env) { | |
| 199 | |
| 200 return true; | |
| 201 } | |
| 202 | |
| 203 #endif // org_chromium_example_jni_generator_SampleForTests_JNI | |
| OLD | NEW |