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/foo/Bar |
| 9 |
| 10 #ifndef org_chromium_foo_Bar_JNI |
| 11 #define org_chromium_foo_Bar_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 kBarClassPath[] = "org/chromium/foo/Bar"; |
| 22 // Leaking this jclass as we cannot use LazyInstance from some threads. |
| 23 base::subtle::AtomicWord g_Bar_clazz __attribute__((unused)) = 0; |
| 24 #define Bar_clazz(env) base::android::LazyGetClass(env, kBarClassPath, &g_Bar_cl
azz) |
| 25 |
| 26 } // namespace |
| 27 |
| 28 // Step 2: method stubs. |
| 29 JNI_GENERATOR_EXPORT jint Java_org_chromium_foo_Bar_nativeStaticMethod(JNIEnv* |
| 30 env, jobject jcaller, |
| 31 jlong nativeTest, |
| 32 jint arg1) { |
| 33 Test* native = reinterpret_cast<Test*>(nativeTest); |
| 34 CHECK_NATIVE_PTR(env, jcaller, native, "StaticMethod", 0); |
| 35 return native->StaticMethod(env, base::android::JavaParamRef<jobject>(env, |
| 36 jcaller), arg1); |
| 37 } |
| 38 |
| 39 // Step 3: RegisterNatives. |
| 40 |
| 41 static const JNINativeMethod kMethodsBar[] = { |
| 42 { "nativeStaticMethod", |
| 43 "(" |
| 44 "J" |
| 45 "I" |
| 46 ")" |
| 47 "I", reinterpret_cast<void*>(Java_org_chromium_foo_Bar_nativeStaticMethod) }, |
| 48 }; |
| 49 |
| 50 static bool RegisterNativesImpl(JNIEnv* env) { |
| 51 if (jni_generator::ShouldSkipJniRegistration(true)) |
| 52 return true; |
| 53 |
| 54 const int kMethodsBarSize = arraysize(kMethodsBar); |
| 55 |
| 56 if (env->RegisterNatives(Bar_clazz(env), |
| 57 kMethodsBar, |
| 58 kMethodsBarSize) < 0) { |
| 59 jni_generator::HandleRegistrationError( |
| 60 env, Bar_clazz(env), __FILE__); |
| 61 return false; |
| 62 } |
| 63 |
| 64 return true; |
| 65 } |
| 66 |
| 67 #endif // org_chromium_foo_Bar_JNI |
OLD | NEW |