• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/Example
9
10#ifndef org_chromium_example_jni_generator_Example_JNI
11#define org_chromium_example_jni_generator_Example_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.
20namespace {
21const char kExampleClassPath[] = "com/test/jni_generator/Example";
22// Leaking this jclass as we cannot use LazyInstance from some threads.
23jclass g_Example_clazz = NULL;
24#define Example_clazz(env) g_Example_clazz
25
26}  // namespace
27
28static void Test(JNIEnv* env, jclass jcaller,
29    jobject t);
30
31static void Test2(JNIEnv* env, jclass jcaller,
32    jobject t);
33
34static void Test3(JNIEnv* env, jclass jcaller,
35    jobject t);
36
37static void Test4(JNIEnv* env, jclass jcaller,
38    jobject t);
39
40// Step 2: method stubs.
41
42// Step 3: RegisterNatives.
43
44static const JNINativeMethod kMethodsExample[] = {
45    { "nativeTest",
46"("
47"Lorg/test2/Test;"
48")"
49"V", reinterpret_cast<void*>(Test) },
50    { "nativeTest2",
51"("
52"Lorg/chromium/example3/PrefixFoo;"
53")"
54"V", reinterpret_cast<void*>(Test2) },
55    { "nativeTest3",
56"("
57"Lorg/test3/Test;"
58")"
59"V", reinterpret_cast<void*>(Test3) },
60    { "nativeTest4",
61"("
62"Lorg/test3/TestBar$Inner;"
63")"
64"V", reinterpret_cast<void*>(Test4) },
65};
66
67static bool RegisterNativesImpl(JNIEnv* env) {
68  g_Example_clazz = reinterpret_cast<jclass>(env->NewGlobalRef(
69      base::android::GetClass(env, kExampleClassPath).obj()));
70
71  const int kMethodsExampleSize = arraysize(kMethodsExample);
72
73  if (env->RegisterNatives(Example_clazz(env),
74                           kMethodsExample,
75                           kMethodsExampleSize) < 0) {
76    jni_generator::HandleRegistrationError(
77        env, Example_clazz(env), __FILE__);
78    return false;
79  }
80
81  return true;
82}
83
84#endif  // org_chromium_example_jni_generator_Example_JNI
85