| 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 // Step 1: forward declarations. | 17 // Step 1: forward declarations. |
| 18 namespace { | 18 namespace { |
| 19 const char kTestClassPath[] = "org/chromium/example/jni_generator/Test"; | |
| 20 // Leaking this jclass as we cannot use LazyInstance from some threads. | |
| 21 jclass g_Test_clazz = NULL; | |
| 22 | 19 |
| 23 } // namespace | 20 } // namespace |
| 24 | 21 |
| 22 extern "C"{ |
| 23 |
| 25 // Step 2: method stubs. | 24 // Step 2: method stubs. |
| 26 static jlong Method(JNIEnv* env, jobject jcaller, | 25 static jlong Method(JNIEnv* env, jobject jcaller, |
| 27 jlong nativeTest, | 26 jlong nativeTest, |
| 28 jint arg1) { | 27 jint arg1) { |
| 29 Test* native = reinterpret_cast<Test*>(nativeTest); | 28 Test* native = reinterpret_cast<Test*>(nativeTest); |
| 30 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0); | 29 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0); |
| 31 return native->Method(arg1); | 30 return native->Method(arg1); |
| 32 } | 31 } |
| 32 __attribute__((alias("Method"), visibility("default"))) |
| 33 jlong Java_org_chromium_example_jni_1generator_Test_nativeMethod(JNIEnv* env, |
| 34 jobject jcaller, |
| 35 jlong nativeTest, |
| 36 jint arg1); |
| 37 |
| 38 }; |
| 33 | 39 |
| 34 // Step 3: RegisterNatives. | 40 // Step 3: RegisterNatives. |
| 35 | 41 |
| 36 static const JNINativeMethod kMethodsTest[] = { | |
| 37 { "nativeMethod", | |
| 38 "(" | |
| 39 "J" | |
| 40 "I" | |
| 41 ")" | |
| 42 "J", reinterpret_cast<void*>(Method) }, | |
| 43 }; | |
| 44 | |
| 45 static bool RegisterNativesImpl(JNIEnv* env) { | |
| 46 g_Test_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( | |
| 47 base::android::GetClass(env, kTestClassPath).obj())); | |
| 48 | |
| 49 const int kMethodsTestSize = arraysize(kMethodsTest); | |
| 50 | |
| 51 if (env->RegisterNatives(g_Test_clazz, | |
| 52 kMethodsTest, | |
| 53 kMethodsTestSize) < 0) { | |
| 54 jni_generator::HandleRegistrationError( | |
| 55 env, g_Test_clazz, __FILE__); | |
| 56 return false; | |
| 57 } | |
| 58 | |
| 59 return true; | |
| 60 } | |
| 61 | |
| 62 #endif // org_chromium_example_jni_generator_Test_JNI | 42 #endif // org_chromium_example_jni_generator_Test_JNI |
| OLD | NEW |