summaryrefslogtreecommitdiff
path: root/base/android/jni_generator/testNativeExportsOption.golden
blob: 395fc390e34f1475f8d276ef39c0c04ba2064fde (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
// 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/SampleForTests

#ifndef org_chromium_example_jni_generator_SampleForTests_JNI
#define org_chromium_example_jni_generator_SampleForTests_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 kSampleForTestsClassPath[] =
    "org/chromium/example/jni_generator/SampleForTests";
// Leaking this jclass as we cannot use LazyInstance from some threads.
base::subtle::AtomicWord g_SampleForTests_clazz __attribute__((unused)) = 0;
#define SampleForTests_clazz(env) base::android::LazyGetClass(env, kSampleForTestsClassPath, &g_SampleForTests_clazz)

}  // namespace

extern "C" {

static jint Init(JNIEnv* env, jobject jcaller);

__attribute__((visibility("default")))
jint
    Java_org_chromium_example_jni_1generator_SampleForTests_00024MyInnerClass_nativeInit(JNIEnv*
    env, jobject jcaller) {
  return Init(env, jcaller);
}

static jint Init(JNIEnv* env, jobject jcaller);

__attribute__((visibility("default")))
jint
    Java_org_chromium_example_jni_1generator_SampleForTests_00024MyOtherInnerClass_nativeInit(JNIEnv*
    env, jobject jcaller) {
  return Init(env, jcaller);
}

};  // extern "C"

// Step 2: method stubs.

extern "C" {
__attribute__((visibility("default")))
jint
    Java_org_chromium_example_jni_1generator_SampleForTests_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, jcaller, arg1);
}

__attribute__((visibility("default")))
jint
    Java_org_chromium_example_jni_1generator_SampleForTests_nativeMethod(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);
}

static base::subtle::AtomicWord g_SampleForTests_testMethodWithParam = 0;
static void Java_SampleForTests_testMethodWithParam(JNIEnv* env, jobject obj,
    JniIntWrapper iParam) {
  /* Must call RegisterNativesImpl()  */
  CHECK_CLAZZ(env, obj,
      SampleForTests_clazz(env));
  jmethodID method_id =
      base::android::MethodID::LazyGet<
      base::android::MethodID::TYPE_INSTANCE>(
      env, SampleForTests_clazz(env),
      "testMethodWithParam",

"("
"I"
")"
"V",
      &g_SampleForTests_testMethodWithParam);

     env->CallVoidMethod(obj,
          method_id, as_jint(iParam));
  jni_generator::CheckException(env);

}

static base::subtle::AtomicWord g_SampleForTests_testMethodWithParamAndReturn =
    0;
static base::android::ScopedJavaLocalRef<jstring>
    Java_SampleForTests_testMethodWithParamAndReturn(JNIEnv* env, jobject obj,
    JniIntWrapper iParam) {
  /* Must call RegisterNativesImpl()  */
  CHECK_CLAZZ(env, obj,
      SampleForTests_clazz(env), NULL);
  jmethodID method_id =
      base::android::MethodID::LazyGet<
      base::android::MethodID::TYPE_INSTANCE>(
      env, SampleForTests_clazz(env),
      "testMethodWithParamAndReturn",

"("
"I"
")"
"Ljava/lang/String;",
      &g_SampleForTests_testMethodWithParamAndReturn);

  jstring ret =
      static_cast<jstring>(env->CallObjectMethod(obj,
          method_id, as_jint(iParam)));
  jni_generator::CheckException(env);
  return base::android::ScopedJavaLocalRef<jstring>(env, ret);
}

static base::subtle::AtomicWord g_SampleForTests_testStaticMethodWithParam = 0;
static jint Java_SampleForTests_testStaticMethodWithParam(JNIEnv* env,
    JniIntWrapper iParam) {
  /* Must call RegisterNativesImpl()  */
  CHECK_CLAZZ(env, SampleForTests_clazz(env),
      SampleForTests_clazz(env), 0);
  jmethodID method_id =
      base::android::MethodID::LazyGet<
      base::android::MethodID::TYPE_STATIC>(
      env, SampleForTests_clazz(env),
      "testStaticMethodWithParam",

"("
"I"
")"
"I",
      &g_SampleForTests_testStaticMethodWithParam);

  jint ret =
      env->CallStaticIntMethod(SampleForTests_clazz(env),
          method_id, as_jint(iParam));
  jni_generator::CheckException(env);
  return ret;
}

static base::subtle::AtomicWord g_SampleForTests_testMethodWithNoParam = 0;
static jdouble Java_SampleForTests_testMethodWithNoParam(JNIEnv* env) {
  /* Must call RegisterNativesImpl()  */
  CHECK_CLAZZ(env, SampleForTests_clazz(env),
      SampleForTests_clazz(env), 0);
  jmethodID method_id =
      base::android::MethodID::LazyGet<
      base::android::MethodID::TYPE_STATIC>(
      env, SampleForTests_clazz(env),
      "testMethodWithNoParam",

"("
")"
"D",
      &g_SampleForTests_testMethodWithNoParam);

  jdouble ret =
      env->CallStaticDoubleMethod(SampleForTests_clazz(env),
          method_id);
  jni_generator::CheckException(env);
  return ret;
}

static base::subtle::AtomicWord g_SampleForTests_testStaticMethodWithNoParam =
    0;
static base::android::ScopedJavaLocalRef<jstring>
    Java_SampleForTests_testStaticMethodWithNoParam(JNIEnv* env) {
  /* Must call RegisterNativesImpl()  */
  CHECK_CLAZZ(env, SampleForTests_clazz(env),
      SampleForTests_clazz(env), NULL);
  jmethodID method_id =
      base::android::MethodID::LazyGet<
      base::android::MethodID::TYPE_STATIC>(
      env, SampleForTests_clazz(env),
      "testStaticMethodWithNoParam",

"("
")"
"Ljava/lang/String;",
      &g_SampleForTests_testStaticMethodWithNoParam);

  jstring ret =
static_cast<jstring>(env->CallStaticObjectMethod(SampleForTests_clazz(env),
          method_id));
  jni_generator::CheckException(env);
  return base::android::ScopedJavaLocalRef<jstring>(env, ret);
}
};  // extern "C"

// Step 3: RegisterNatives.

static bool RegisterNativesImpl(JNIEnv* env, jclass clazz) {

  base::subtle::Release_Store(&g_SampleForTests_clazz,
      static_cast<base::subtle::AtomicWord>(env->NewWeakGlobalRef(clazz));

  return true;
}

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

#endif  // org_chromium_example_jni_generator_SampleForTests_JNI