Home | History | Annotate | Download | only in jni_generator
      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/TestJni
      9 
     10 #ifndef org_chromium_TestJni_JNI
     11 #define org_chromium_TestJni_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.
     20 namespace {
     21 const char kTestJniClassPath[] = "org/chromium/TestJni";
     22 const char kInfoBarClassPath[] = "org/chromium/TestJni$InfoBar";
     23 // Leaking this jclass as we cannot use LazyInstance from some threads.
     24 jclass g_TestJni_clazz = NULL;
     25 #define TestJni_clazz(env) g_TestJni_clazz
     26 // Leaking this jclass as we cannot use LazyInstance from some threads.
     27 jclass g_InfoBar_clazz = NULL;
     28 #define InfoBar_clazz(env) g_InfoBar_clazz
     29 
     30 }  // namespace
     31 
     32 // Step 2: method stubs.
     33 
     34 static base::subtle::AtomicWord g_TestJni_showConfirmInfoBar = 0;
     35 static base::android::ScopedJavaLocalRef<jobject>
     36     Java_TestJni_showConfirmInfoBar(JNIEnv* env, jobject obj, JniIntWrapper
     37     nativeInfoBar,
     38     jstring buttonOk,
     39     jstring buttonCancel,
     40     jstring title,
     41     jobject icon) {
     42   /* Must call RegisterNativesImpl()  */
     43   CHECK_CLAZZ(env, obj,
     44       TestJni_clazz(env), NULL);
     45   jmethodID method_id =
     46       base::android::MethodID::LazyGet<
     47       base::android::MethodID::TYPE_INSTANCE>(
     48       env, TestJni_clazz(env),
     49       "showConfirmInfoBar",
     50 
     51 "("
     52 "I"
     53 "Ljava/lang/String;"
     54 "Ljava/lang/String;"
     55 "Ljava/lang/String;"
     56 "Landroid/graphics/Bitmap;"
     57 ")"
     58 "Lorg/chromium/Foo$InnerClass;",
     59       &g_TestJni_showConfirmInfoBar);
     60 
     61   jobject ret =
     62       env->CallObjectMethod(obj,
     63           method_id, as_jint(nativeInfoBar), buttonOk, buttonCancel, title,
     64               icon);
     65   jni_generator::CheckException(env);
     66   return base::android::ScopedJavaLocalRef<jobject>(env, ret);
     67 }
     68 
     69 static base::subtle::AtomicWord g_TestJni_showAutoLoginInfoBar = 0;
     70 static base::android::ScopedJavaLocalRef<jobject>
     71     Java_TestJni_showAutoLoginInfoBar(JNIEnv* env, jobject obj, JniIntWrapper
     72     nativeInfoBar,
     73     jstring realm,
     74     jstring account,
     75     jstring args) {
     76   /* Must call RegisterNativesImpl()  */
     77   CHECK_CLAZZ(env, obj,
     78       TestJni_clazz(env), NULL);
     79   jmethodID method_id =
     80       base::android::MethodID::LazyGet<
     81       base::android::MethodID::TYPE_INSTANCE>(
     82       env, TestJni_clazz(env),
     83       "showAutoLoginInfoBar",
     84 
     85 "("
     86 "I"
     87 "Ljava/lang/String;"
     88 "Ljava/lang/String;"
     89 "Ljava/lang/String;"
     90 ")"
     91 "Lorg/chromium/Foo$InnerClass;",
     92       &g_TestJni_showAutoLoginInfoBar);
     93 
     94   jobject ret =
     95       env->CallObjectMethod(obj,
     96           method_id, as_jint(nativeInfoBar), realm, account, args);
     97   jni_generator::CheckException(env);
     98   return base::android::ScopedJavaLocalRef<jobject>(env, ret);
     99 }
    100 
    101 static base::subtle::AtomicWord g_InfoBar_dismiss = 0;
    102 static void Java_InfoBar_dismiss(JNIEnv* env, jobject obj) {
    103   /* Must call RegisterNativesImpl()  */
    104   CHECK_CLAZZ(env, obj,
    105       InfoBar_clazz(env));
    106   jmethodID method_id =
    107       base::android::MethodID::LazyGet<
    108       base::android::MethodID::TYPE_INSTANCE>(
    109       env, InfoBar_clazz(env),
    110       "dismiss",
    111 
    112 "("
    113 ")"
    114 "V",
    115       &g_InfoBar_dismiss);
    116 
    117      env->CallVoidMethod(obj,
    118           method_id);
    119   jni_generator::CheckException(env);
    120 
    121 }
    122 
    123 static base::subtle::AtomicWord g_TestJni_shouldShowAutoLogin = 0;
    124 static jboolean Java_TestJni_shouldShowAutoLogin(JNIEnv* env, jobject view,
    125     jstring realm,
    126     jstring account,
    127     jstring args) {
    128   /* Must call RegisterNativesImpl()  */
    129   CHECK_CLAZZ(env, TestJni_clazz(env),
    130       TestJni_clazz(env), false);
    131   jmethodID method_id =
    132       base::android::MethodID::LazyGet<
    133       base::android::MethodID::TYPE_STATIC>(
    134       env, TestJni_clazz(env),
    135       "shouldShowAutoLogin",
    136 
    137 "("
    138 "Landroid/view/View;"
    139 "Ljava/lang/String;"
    140 "Ljava/lang/String;"
    141 "Ljava/lang/String;"
    142 ")"
    143 "Z",
    144       &g_TestJni_shouldShowAutoLogin);
    145 
    146   jboolean ret =
    147       env->CallStaticBooleanMethod(TestJni_clazz(env),
    148           method_id, view, realm, account, args);
    149   jni_generator::CheckException(env);
    150   return ret;
    151 }
    152 
    153 static base::subtle::AtomicWord g_TestJni_openUrl = 0;
    154 static base::android::ScopedJavaLocalRef<jobject> Java_TestJni_openUrl(JNIEnv*
    155     env, jstring url) {
    156   /* Must call RegisterNativesImpl()  */
    157   CHECK_CLAZZ(env, TestJni_clazz(env),
    158       TestJni_clazz(env), NULL);
    159   jmethodID method_id =
    160       base::android::MethodID::LazyGet<
    161       base::android::MethodID::TYPE_STATIC>(
    162       env, TestJni_clazz(env),
    163       "openUrl",
    164 
    165 "("
    166 "Ljava/lang/String;"
    167 ")"
    168 "Ljava/io/InputStream;",
    169       &g_TestJni_openUrl);
    170 
    171   jobject ret =
    172       env->CallStaticObjectMethod(TestJni_clazz(env),
    173           method_id, url);
    174   jni_generator::CheckException(env);
    175   return base::android::ScopedJavaLocalRef<jobject>(env, ret);
    176 }
    177 
    178 static base::subtle::AtomicWord g_TestJni_activateHardwareAcceleration = 0;
    179 static void Java_TestJni_activateHardwareAcceleration(JNIEnv* env, jobject obj,
    180     jboolean activated,
    181     JniIntWrapper iPid,
    182     JniIntWrapper iType,
    183     JniIntWrapper iPrimaryID,
    184     JniIntWrapper iSecondaryID) {
    185   /* Must call RegisterNativesImpl()  */
    186   CHECK_CLAZZ(env, obj,
    187       TestJni_clazz(env));
    188   jmethodID method_id =
    189       base::android::MethodID::LazyGet<
    190       base::android::MethodID::TYPE_INSTANCE>(
    191       env, TestJni_clazz(env),
    192       "activateHardwareAcceleration",
    193 
    194 "("
    195 "Z"
    196 "I"
    197 "I"
    198 "I"
    199 "I"
    200 ")"
    201 "V",
    202       &g_TestJni_activateHardwareAcceleration);
    203 
    204      env->CallVoidMethod(obj,
    205           method_id, activated, as_jint(iPid), as_jint(iType),
    206               as_jint(iPrimaryID), as_jint(iSecondaryID));
    207   jni_generator::CheckException(env);
    208 
    209 }
    210 
    211 static base::subtle::AtomicWord g_TestJni_uncheckedCall = 0;
    212 static void Java_TestJni_uncheckedCall(JNIEnv* env, jobject obj, JniIntWrapper
    213     iParam) {
    214   /* Must call RegisterNativesImpl()  */
    215   CHECK_CLAZZ(env, obj,
    216       TestJni_clazz(env));
    217   jmethodID method_id =
    218       base::android::MethodID::LazyGet<
    219       base::android::MethodID::TYPE_INSTANCE>(
    220       env, TestJni_clazz(env),
    221       "uncheckedCall",
    222 
    223 "("
    224 "I"
    225 ")"
    226 "V",
    227       &g_TestJni_uncheckedCall);
    228 
    229      env->CallVoidMethod(obj,
    230           method_id, as_jint(iParam));
    231 
    232 }
    233 
    234 static base::subtle::AtomicWord g_TestJni_returnByteArray = 0;
    235 static base::android::ScopedJavaLocalRef<jbyteArray>
    236     Java_TestJni_returnByteArray(JNIEnv* env, jobject obj) {
    237   /* Must call RegisterNativesImpl()  */
    238   CHECK_CLAZZ(env, obj,
    239       TestJni_clazz(env), NULL);
    240   jmethodID method_id =
    241       base::android::MethodID::LazyGet<
    242       base::android::MethodID::TYPE_INSTANCE>(
    243       env, TestJni_clazz(env),
    244       "returnByteArray",
    245 
    246 "("
    247 ")"
    248 "[B",
    249       &g_TestJni_returnByteArray);
    250 
    251   jbyteArray ret =
    252       static_cast<jbyteArray>(env->CallObjectMethod(obj,
    253           method_id));
    254   jni_generator::CheckException(env);
    255   return base::android::ScopedJavaLocalRef<jbyteArray>(env, ret);
    256 }
    257 
    258 static base::subtle::AtomicWord g_TestJni_returnBooleanArray = 0;
    259 static base::android::ScopedJavaLocalRef<jbooleanArray>
    260     Java_TestJni_returnBooleanArray(JNIEnv* env, jobject obj) {
    261   /* Must call RegisterNativesImpl()  */
    262   CHECK_CLAZZ(env, obj,
    263       TestJni_clazz(env), NULL);
    264   jmethodID method_id =
    265       base::android::MethodID::LazyGet<
    266       base::android::MethodID::TYPE_INSTANCE>(
    267       env, TestJni_clazz(env),
    268       "returnBooleanArray",
    269 
    270 "("
    271 ")"
    272 "[Z",
    273       &g_TestJni_returnBooleanArray);
    274 
    275   jbooleanArray ret =
    276       static_cast<jbooleanArray>(env->CallObjectMethod(obj,
    277           method_id));
    278   jni_generator::CheckException(env);
    279   return base::android::ScopedJavaLocalRef<jbooleanArray>(env, ret);
    280 }
    281 
    282 static base::subtle::AtomicWord g_TestJni_returnCharArray = 0;
    283 static base::android::ScopedJavaLocalRef<jcharArray>
    284     Java_TestJni_returnCharArray(JNIEnv* env, jobject obj) {
    285   /* Must call RegisterNativesImpl()  */
    286   CHECK_CLAZZ(env, obj,
    287       TestJni_clazz(env), NULL);
    288   jmethodID method_id =
    289       base::android::MethodID::LazyGet<
    290       base::android::MethodID::TYPE_INSTANCE>(
    291       env, TestJni_clazz(env),
    292       "returnCharArray",
    293 
    294 "("
    295 ")"
    296 "[C",
    297       &g_TestJni_returnCharArray);
    298 
    299   jcharArray ret =
    300       static_cast<jcharArray>(env->CallObjectMethod(obj,
    301           method_id));
    302   jni_generator::CheckException(env);
    303   return base::android::ScopedJavaLocalRef<jcharArray>(env, ret);
    304 }
    305 
    306 static base::subtle::AtomicWord g_TestJni_returnShortArray = 0;
    307 static base::android::ScopedJavaLocalRef<jshortArray>
    308     Java_TestJni_returnShortArray(JNIEnv* env, jobject obj) {
    309   /* Must call RegisterNativesImpl()  */
    310   CHECK_CLAZZ(env, obj,
    311       TestJni_clazz(env), NULL);
    312   jmethodID method_id =
    313       base::android::MethodID::LazyGet<
    314       base::android::MethodID::TYPE_INSTANCE>(
    315       env, TestJni_clazz(env),
    316       "returnShortArray",
    317 
    318 "("
    319 ")"
    320 "[S",
    321       &g_TestJni_returnShortArray);
    322 
    323   jshortArray ret =
    324       static_cast<jshortArray>(env->CallObjectMethod(obj,
    325           method_id));
    326   jni_generator::CheckException(env);
    327   return base::android::ScopedJavaLocalRef<jshortArray>(env, ret);
    328 }
    329 
    330 static base::subtle::AtomicWord g_TestJni_returnIntArray = 0;
    331 static base::android::ScopedJavaLocalRef<jintArray>
    332     Java_TestJni_returnIntArray(JNIEnv* env, jobject obj) {
    333   /* Must call RegisterNativesImpl()  */
    334   CHECK_CLAZZ(env, obj,
    335       TestJni_clazz(env), NULL);
    336   jmethodID method_id =
    337       base::android::MethodID::LazyGet<
    338       base::android::MethodID::TYPE_INSTANCE>(
    339       env, TestJni_clazz(env),
    340       "returnIntArray",
    341 
    342 "("
    343 ")"
    344 "[I",
    345       &g_TestJni_returnIntArray);
    346 
    347   jintArray ret =
    348       static_cast<jintArray>(env->CallObjectMethod(obj,
    349           method_id));
    350   jni_generator::CheckException(env);
    351   return base::android::ScopedJavaLocalRef<jintArray>(env, ret);
    352 }
    353 
    354 static base::subtle::AtomicWord g_TestJni_returnLongArray = 0;
    355 static base::android::ScopedJavaLocalRef<jlongArray>
    356     Java_TestJni_returnLongArray(JNIEnv* env, jobject obj) {
    357   /* Must call RegisterNativesImpl()  */
    358   CHECK_CLAZZ(env, obj,
    359       TestJni_clazz(env), NULL);
    360   jmethodID method_id =
    361       base::android::MethodID::LazyGet<
    362       base::android::MethodID::TYPE_INSTANCE>(
    363       env, TestJni_clazz(env),
    364       "returnLongArray",
    365 
    366 "("
    367 ")"
    368 "[J",
    369       &g_TestJni_returnLongArray);
    370 
    371   jlongArray ret =
    372       static_cast<jlongArray>(env->CallObjectMethod(obj,
    373           method_id));
    374   jni_generator::CheckException(env);
    375   return base::android::ScopedJavaLocalRef<jlongArray>(env, ret);
    376 }
    377 
    378 static base::subtle::AtomicWord g_TestJni_returnDoubleArray = 0;
    379 static base::android::ScopedJavaLocalRef<jdoubleArray>
    380     Java_TestJni_returnDoubleArray(JNIEnv* env, jobject obj) {
    381   /* Must call RegisterNativesImpl()  */
    382   CHECK_CLAZZ(env, obj,
    383       TestJni_clazz(env), NULL);
    384   jmethodID method_id =
    385       base::android::MethodID::LazyGet<
    386       base::android::MethodID::TYPE_INSTANCE>(
    387       env, TestJni_clazz(env),
    388       "returnDoubleArray",
    389 
    390 "("
    391 ")"
    392 "[D",
    393       &g_TestJni_returnDoubleArray);
    394 
    395   jdoubleArray ret =
    396       static_cast<jdoubleArray>(env->CallObjectMethod(obj,
    397           method_id));
    398   jni_generator::CheckException(env);
    399   return base::android::ScopedJavaLocalRef<jdoubleArray>(env, ret);
    400 }
    401 
    402 static base::subtle::AtomicWord g_TestJni_returnObjectArray = 0;
    403 static base::android::ScopedJavaLocalRef<jobjectArray>
    404     Java_TestJni_returnObjectArray(JNIEnv* env, jobject obj) {
    405   /* Must call RegisterNativesImpl()  */
    406   CHECK_CLAZZ(env, obj,
    407       TestJni_clazz(env), NULL);
    408   jmethodID method_id =
    409       base::android::MethodID::LazyGet<
    410       base::android::MethodID::TYPE_INSTANCE>(
    411       env, TestJni_clazz(env),
    412       "returnObjectArray",
    413 
    414 "("
    415 ")"
    416 "[Ljava/lang/Object;",
    417       &g_TestJni_returnObjectArray);
    418 
    419   jobjectArray ret =
    420       static_cast<jobjectArray>(env->CallObjectMethod(obj,
    421           method_id));
    422   jni_generator::CheckException(env);
    423   return base::android::ScopedJavaLocalRef<jobjectArray>(env, ret);
    424 }
    425 
    426 static base::subtle::AtomicWord g_TestJni_returnArrayOfByteArray = 0;
    427 static base::android::ScopedJavaLocalRef<jobjectArray>
    428     Java_TestJni_returnArrayOfByteArray(JNIEnv* env, jobject obj) {
    429   /* Must call RegisterNativesImpl()  */
    430   CHECK_CLAZZ(env, obj,
    431       TestJni_clazz(env), NULL);
    432   jmethodID method_id =
    433       base::android::MethodID::LazyGet<
    434       base::android::MethodID::TYPE_INSTANCE>(
    435       env, TestJni_clazz(env),
    436       "returnArrayOfByteArray",
    437 
    438 "("
    439 ")"
    440 "[[B",
    441       &g_TestJni_returnArrayOfByteArray);
    442 
    443   jobjectArray ret =
    444       static_cast<jobjectArray>(env->CallObjectMethod(obj,
    445           method_id));
    446   jni_generator::CheckException(env);
    447   return base::android::ScopedJavaLocalRef<jobjectArray>(env, ret);
    448 }
    449 
    450 static base::subtle::AtomicWord g_TestJni_getCompressFormat = 0;
    451 static base::android::ScopedJavaLocalRef<jobject>
    452     Java_TestJni_getCompressFormat(JNIEnv* env, jobject obj) {
    453   /* Must call RegisterNativesImpl()  */
    454   CHECK_CLAZZ(env, obj,
    455       TestJni_clazz(env), NULL);
    456   jmethodID method_id =
    457       base::android::MethodID::LazyGet<
    458       base::android::MethodID::TYPE_INSTANCE>(
    459       env, TestJni_clazz(env),
    460       "getCompressFormat",
    461 
    462 "("
    463 ")"
    464 "Landroid/graphics/Bitmap$CompressFormat;",
    465       &g_TestJni_getCompressFormat);
    466 
    467   jobject ret =
    468       env->CallObjectMethod(obj,
    469           method_id);
    470   jni_generator::CheckException(env);
    471   return base::android::ScopedJavaLocalRef<jobject>(env, ret);
    472 }
    473 
    474 static base::subtle::AtomicWord g_TestJni_getCompressFormatList = 0;
    475 static base::android::ScopedJavaLocalRef<jobject>
    476     Java_TestJni_getCompressFormatList(JNIEnv* env, jobject obj) {
    477   /* Must call RegisterNativesImpl()  */
    478   CHECK_CLAZZ(env, obj,
    479       TestJni_clazz(env), NULL);
    480   jmethodID method_id =
    481       base::android::MethodID::LazyGet<
    482       base::android::MethodID::TYPE_INSTANCE>(
    483       env, TestJni_clazz(env),
    484       "getCompressFormatList",
    485 
    486 "("
    487 ")"
    488 "Ljava/util/List;",
    489       &g_TestJni_getCompressFormatList);
    490 
    491   jobject ret =
    492       env->CallObjectMethod(obj,
    493           method_id);
    494   jni_generator::CheckException(env);
    495   return base::android::ScopedJavaLocalRef<jobject>(env, ret);
    496 }
    497 
    498 // Step 3: RegisterNatives.
    499 
    500 static bool RegisterNativesImpl(JNIEnv* env) {
    501   g_TestJni_clazz = reinterpret_cast<jclass>(env->NewGlobalRef(
    502       base::android::GetClass(env, kTestJniClassPath).obj()));
    503   g_InfoBar_clazz = reinterpret_cast<jclass>(env->NewGlobalRef(
    504       base::android::GetClass(env, kInfoBarClassPath).obj()));
    505 
    506   return true;
    507 }
    508 
    509 #endif  // org_chromium_TestJni_JNI
    510