| // Copyright 2014 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| // This file is autogenerated by |
| // base/android/jni_generator/jni_generator.py |
| // For |
| // org/chromium/foo/Bar |
| |
| #ifndef org_chromium_foo_Bar_JNI |
| #define org_chromium_foo_Bar_JNI |
| |
| #include <jni.h> |
| |
| #include "base/android/jni_generator/jni_generator_helper.h" |
| |
| #include "base/android/jni_int_wrapper.h" |
| |
| // Step 1: forward declarations. |
| namespace { |
| const char kBarClassPath[] = "org/chromium/foo/Bar"; |
| // Leaking this jclass as we cannot use LazyInstance from some threads. |
| base::subtle::AtomicWord g_Bar_clazz __attribute__((unused)) = 0; |
| #define Bar_clazz(env) base::android::LazyGetClass(env, kBarClassPath, &g_Bar_clazz) |
| |
| } // namespace |
| |
| // Step 2: method stubs. |
| JNI_GENERATOR_EXPORT jint Java_org_chromium_foo_Bar_nativeStaticMethod(JNIEnv* |
| env, jobject jcaller, |
| jlong nativeTest, |
| jint arg1) { |
| Test* native = reinterpret_cast<Test*>(nativeTest); |
| CHECK_NATIVE_PTR(env, jcaller, native, "StaticMethod", 0); |
| return native->StaticMethod(env, base::android::JavaParamRef<jobject>(env, |
| jcaller), arg1); |
| } |
| |
| // Step 3: RegisterNatives. |
| |
| static const JNINativeMethod kMethodsBar[] = { |
| { "nativeStaticMethod", |
| "(" |
| "J" |
| "I" |
| ")" |
| "I", reinterpret_cast<void*>(Java_org_chromium_foo_Bar_nativeStaticMethod) }, |
| }; |
| |
| static bool RegisterNativesImpl(JNIEnv* env) { |
| if (jni_generator::ShouldSkipJniRegistration(true)) |
| return true; |
| |
| const int kMethodsBarSize = arraysize(kMethodsBar); |
| |
| if (env->RegisterNatives(Bar_clazz(env), |
| kMethodsBar, |
| kMethodsBarSize) < 0) { |
| jni_generator::HandleRegistrationError( |
| env, Bar_clazz(env), __FILE__); |
| return false; |
| } |
| |
| return true; |
| } |
| |
| #endif // org_chromium_foo_Bar_JNI |