-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// 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.
#include "base/android/jni_generator/jni_generator_helper.h"
+#include "base/android/jni_int_wrapper.h"
+
// Step 1: forward declarations.
namespace {
const char kTestJniClassPath[] = "org/chromium/TestJni";
const char kInfoBarClassPath[] = "org/chromium/TestJni$InfoBar";
// Leaking this jclass as we cannot use LazyInstance from some threads.
jclass g_TestJni_clazz = NULL;
+#define TestJni_clazz(env) g_TestJni_clazz
// Leaking this jclass as we cannot use LazyInstance from some threads.
jclass g_InfoBar_clazz = NULL;
+#define InfoBar_clazz(env) g_InfoBar_clazz
} // namespace
static base::subtle::AtomicWord g_TestJni_showConfirmInfoBar = 0;
static base::android::ScopedJavaLocalRef<jobject>
- Java_TestJni_showConfirmInfoBar(JNIEnv* env, jobject obj, jint
+ Java_TestJni_showConfirmInfoBar(JNIEnv* env, jobject obj, JniIntWrapper
nativeInfoBar,
jstring buttonOk,
jstring buttonCancel,
jobject icon) {
/* Must call RegisterNativesImpl() */
CHECK_CLAZZ(env, obj,
- g_TestJni_clazz, NULL);
+ TestJni_clazz(env), NULL);
jmethodID method_id =
base::android::MethodID::LazyGet<
base::android::MethodID::TYPE_INSTANCE>(
- env, g_TestJni_clazz,
+ env, TestJni_clazz(env),
"showConfirmInfoBar",
"("
jobject ret =
env->CallObjectMethod(obj,
- method_id, nativeInfoBar, buttonOk, buttonCancel, title, icon);
+ method_id, as_jint(nativeInfoBar), buttonOk, buttonCancel, title,
+ icon);
jni_generator::CheckException(env);
return base::android::ScopedJavaLocalRef<jobject>(env, ret);
}
static base::subtle::AtomicWord g_TestJni_showAutoLoginInfoBar = 0;
static base::android::ScopedJavaLocalRef<jobject>
- Java_TestJni_showAutoLoginInfoBar(JNIEnv* env, jobject obj, jint
+ Java_TestJni_showAutoLoginInfoBar(JNIEnv* env, jobject obj, JniIntWrapper
nativeInfoBar,
jstring realm,
jstring account,
jstring args) {
/* Must call RegisterNativesImpl() */
CHECK_CLAZZ(env, obj,
- g_TestJni_clazz, NULL);
+ TestJni_clazz(env), NULL);
jmethodID method_id =
base::android::MethodID::LazyGet<
base::android::MethodID::TYPE_INSTANCE>(
- env, g_TestJni_clazz,
+ env, TestJni_clazz(env),
"showAutoLoginInfoBar",
"("
jobject ret =
env->CallObjectMethod(obj,
- method_id, nativeInfoBar, realm, account, args);
+ method_id, as_jint(nativeInfoBar), realm, account, args);
jni_generator::CheckException(env);
return base::android::ScopedJavaLocalRef<jobject>(env, ret);
}
static void Java_InfoBar_dismiss(JNIEnv* env, jobject obj) {
/* Must call RegisterNativesImpl() */
CHECK_CLAZZ(env, obj,
- g_InfoBar_clazz);
+ InfoBar_clazz(env));
jmethodID method_id =
base::android::MethodID::LazyGet<
base::android::MethodID::TYPE_INSTANCE>(
- env, g_InfoBar_clazz,
+ env, InfoBar_clazz(env),
"dismiss",
"("
jstring account,
jstring args) {
/* Must call RegisterNativesImpl() */
- CHECK_CLAZZ(env, g_TestJni_clazz,
- g_TestJni_clazz, false);
+ CHECK_CLAZZ(env, TestJni_clazz(env),
+ TestJni_clazz(env), false);
jmethodID method_id =
base::android::MethodID::LazyGet<
base::android::MethodID::TYPE_STATIC>(
- env, g_TestJni_clazz,
+ env, TestJni_clazz(env),
"shouldShowAutoLogin",
"("
&g_TestJni_shouldShowAutoLogin);
jboolean ret =
- env->CallStaticBooleanMethod(g_TestJni_clazz,
+ env->CallStaticBooleanMethod(TestJni_clazz(env),
method_id, view, realm, account, args);
jni_generator::CheckException(env);
return ret;
static base::android::ScopedJavaLocalRef<jobject> Java_TestJni_openUrl(JNIEnv*
env, jstring url) {
/* Must call RegisterNativesImpl() */
- CHECK_CLAZZ(env, g_TestJni_clazz,
- g_TestJni_clazz, NULL);
+ CHECK_CLAZZ(env, TestJni_clazz(env),
+ TestJni_clazz(env), NULL);
jmethodID method_id =
base::android::MethodID::LazyGet<
base::android::MethodID::TYPE_STATIC>(
- env, g_TestJni_clazz,
+ env, TestJni_clazz(env),
"openUrl",
"("
&g_TestJni_openUrl);
jobject ret =
- env->CallStaticObjectMethod(g_TestJni_clazz,
+ env->CallStaticObjectMethod(TestJni_clazz(env),
method_id, url);
jni_generator::CheckException(env);
return base::android::ScopedJavaLocalRef<jobject>(env, ret);
static base::subtle::AtomicWord g_TestJni_activateHardwareAcceleration = 0;
static void Java_TestJni_activateHardwareAcceleration(JNIEnv* env, jobject obj,
jboolean activated,
- jint iPid,
- jint iType,
- jint iPrimaryID,
- jint iSecondaryID) {
+ JniIntWrapper iPid,
+ JniIntWrapper iType,
+ JniIntWrapper iPrimaryID,
+ JniIntWrapper iSecondaryID) {
/* Must call RegisterNativesImpl() */
CHECK_CLAZZ(env, obj,
- g_TestJni_clazz);
+ TestJni_clazz(env));
jmethodID method_id =
base::android::MethodID::LazyGet<
base::android::MethodID::TYPE_INSTANCE>(
- env, g_TestJni_clazz,
+ env, TestJni_clazz(env),
"activateHardwareAcceleration",
"("
&g_TestJni_activateHardwareAcceleration);
env->CallVoidMethod(obj,
- method_id, activated, iPid, iType, iPrimaryID, iSecondaryID);
+ method_id, activated, as_jint(iPid), as_jint(iType),
+ as_jint(iPrimaryID), as_jint(iSecondaryID));
jni_generator::CheckException(env);
}
static base::subtle::AtomicWord g_TestJni_uncheckedCall = 0;
-static void Java_TestJni_uncheckedCall(JNIEnv* env, jobject obj, jint iParam) {
+static void Java_TestJni_uncheckedCall(JNIEnv* env, jobject obj, JniIntWrapper
+ iParam) {
/* Must call RegisterNativesImpl() */
CHECK_CLAZZ(env, obj,
- g_TestJni_clazz);
+ TestJni_clazz(env));
jmethodID method_id =
base::android::MethodID::LazyGet<
base::android::MethodID::TYPE_INSTANCE>(
- env, g_TestJni_clazz,
+ env, TestJni_clazz(env),
"uncheckedCall",
"("
&g_TestJni_uncheckedCall);
env->CallVoidMethod(obj,
- method_id, iParam);
+ method_id, as_jint(iParam));
}
Java_TestJni_returnByteArray(JNIEnv* env, jobject obj) {
/* Must call RegisterNativesImpl() */
CHECK_CLAZZ(env, obj,
- g_TestJni_clazz, NULL);
+ TestJni_clazz(env), NULL);
jmethodID method_id =
base::android::MethodID::LazyGet<
base::android::MethodID::TYPE_INSTANCE>(
- env, g_TestJni_clazz,
+ env, TestJni_clazz(env),
"returnByteArray",
"("
Java_TestJni_returnBooleanArray(JNIEnv* env, jobject obj) {
/* Must call RegisterNativesImpl() */
CHECK_CLAZZ(env, obj,
- g_TestJni_clazz, NULL);
+ TestJni_clazz(env), NULL);
jmethodID method_id =
base::android::MethodID::LazyGet<
base::android::MethodID::TYPE_INSTANCE>(
- env, g_TestJni_clazz,
+ env, TestJni_clazz(env),
"returnBooleanArray",
"("
Java_TestJni_returnCharArray(JNIEnv* env, jobject obj) {
/* Must call RegisterNativesImpl() */
CHECK_CLAZZ(env, obj,
- g_TestJni_clazz, NULL);
+ TestJni_clazz(env), NULL);
jmethodID method_id =
base::android::MethodID::LazyGet<
base::android::MethodID::TYPE_INSTANCE>(
- env, g_TestJni_clazz,
+ env, TestJni_clazz(env),
"returnCharArray",
"("
Java_TestJni_returnShortArray(JNIEnv* env, jobject obj) {
/* Must call RegisterNativesImpl() */
CHECK_CLAZZ(env, obj,
- g_TestJni_clazz, NULL);
+ TestJni_clazz(env), NULL);
jmethodID method_id =
base::android::MethodID::LazyGet<
base::android::MethodID::TYPE_INSTANCE>(
- env, g_TestJni_clazz,
+ env, TestJni_clazz(env),
"returnShortArray",
"("
Java_TestJni_returnIntArray(JNIEnv* env, jobject obj) {
/* Must call RegisterNativesImpl() */
CHECK_CLAZZ(env, obj,
- g_TestJni_clazz, NULL);
+ TestJni_clazz(env), NULL);
jmethodID method_id =
base::android::MethodID::LazyGet<
base::android::MethodID::TYPE_INSTANCE>(
- env, g_TestJni_clazz,
+ env, TestJni_clazz(env),
"returnIntArray",
"("
Java_TestJni_returnLongArray(JNIEnv* env, jobject obj) {
/* Must call RegisterNativesImpl() */
CHECK_CLAZZ(env, obj,
- g_TestJni_clazz, NULL);
+ TestJni_clazz(env), NULL);
jmethodID method_id =
base::android::MethodID::LazyGet<
base::android::MethodID::TYPE_INSTANCE>(
- env, g_TestJni_clazz,
+ env, TestJni_clazz(env),
"returnLongArray",
"("
Java_TestJni_returnDoubleArray(JNIEnv* env, jobject obj) {
/* Must call RegisterNativesImpl() */
CHECK_CLAZZ(env, obj,
- g_TestJni_clazz, NULL);
+ TestJni_clazz(env), NULL);
jmethodID method_id =
base::android::MethodID::LazyGet<
base::android::MethodID::TYPE_INSTANCE>(
- env, g_TestJni_clazz,
+ env, TestJni_clazz(env),
"returnDoubleArray",
"("
Java_TestJni_returnObjectArray(JNIEnv* env, jobject obj) {
/* Must call RegisterNativesImpl() */
CHECK_CLAZZ(env, obj,
- g_TestJni_clazz, NULL);
+ TestJni_clazz(env), NULL);
jmethodID method_id =
base::android::MethodID::LazyGet<
base::android::MethodID::TYPE_INSTANCE>(
- env, g_TestJni_clazz,
+ env, TestJni_clazz(env),
"returnObjectArray",
"("
Java_TestJni_returnArrayOfByteArray(JNIEnv* env, jobject obj) {
/* Must call RegisterNativesImpl() */
CHECK_CLAZZ(env, obj,
- g_TestJni_clazz, NULL);
+ TestJni_clazz(env), NULL);
jmethodID method_id =
base::android::MethodID::LazyGet<
base::android::MethodID::TYPE_INSTANCE>(
- env, g_TestJni_clazz,
+ env, TestJni_clazz(env),
"returnArrayOfByteArray",
"("
Java_TestJni_getCompressFormat(JNIEnv* env, jobject obj) {
/* Must call RegisterNativesImpl() */
CHECK_CLAZZ(env, obj,
- g_TestJni_clazz, NULL);
+ TestJni_clazz(env), NULL);
jmethodID method_id =
base::android::MethodID::LazyGet<
base::android::MethodID::TYPE_INSTANCE>(
- env, g_TestJni_clazz,
+ env, TestJni_clazz(env),
"getCompressFormat",
"("
Java_TestJni_getCompressFormatList(JNIEnv* env, jobject obj) {
/* Must call RegisterNativesImpl() */
CHECK_CLAZZ(env, obj,
- g_TestJni_clazz, NULL);
+ TestJni_clazz(env), NULL);
jmethodID method_id =
base::android::MethodID::LazyGet<
base::android::MethodID::TYPE_INSTANCE>(
- env, g_TestJni_clazz,
+ env, TestJni_clazz(env),
"getCompressFormatList",
"("