summaryrefslogtreecommitdiffstats
path: root/base/android/jni_generator/testJNIInitNativeNameOption.golden
blob: 54e7b281c09084ab555a8cef5289d2f000c80490 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// 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/example/jni_generator/Test

#ifndef org_chromium_example_jni_generator_Test_JNI
#define org_chromium_example_jni_generator_Test_JNI

#include <jni.h>

#include "base/android/jni_generator/jni_generator_helper.h"

// Step 1: forward declarations.
namespace {
const char kTestClassPath[] = "org/chromium/example/jni_generator/Test";
// Leaking this jclass as we cannot use LazyInstance from some threads.
jclass g_Test_clazz = NULL;

}  // namespace

// Step 2: method stubs.
static jint Method(JNIEnv* env, jobject jcaller,
    jlong nativeTest,
    jint arg1) {
  Test* native = reinterpret_cast<Test*>(nativeTest);
  CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0);
  return native->Method(env, jcaller, arg1);
}

// Step 3: RegisterNatives.

static const JNINativeMethod kMethodsTest[] = {
    { "nativeMethod",
"("
"J"
"I"
")"
"I", reinterpret_cast<void*>(Method) },
};

static bool RegisterNativesImpl(JNIEnv* env, jclass clazz) {
  g_Test_clazz = static_cast<jclass>(env->NewWeakGlobalRef(clazz));

  const int kMethodsTestSize = arraysize(kMethodsTest);

  if (env->RegisterNatives(g_Test_clazz,
                           kMethodsTest,
                           kMethodsTestSize) < 0) {
    jni_generator::HandleRegistrationError(
        env, g_Test_clazz, __FILE__);
    return false;
  }

  return true;
}

extern "C" JNIEXPORT bool JNICALL
Java_org_chromium_example_jni_generator_Test_nativeInitNativeClass(JNIEnv* env,
    jclass clazz) {
  return RegisterNativesImpl(env, clazz);
}

#endif  // org_chromium_example_jni_generator_Test_JNI