blob: dbf6d3e19d2817f88400100edd8ed6736b647133 [file] [log] [blame]
Ken Wakasace9e52a2011-06-18 13:09:55 +09001/*
2**
3** Copyright 2011, The Android Open Source Project
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
8**
9** http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16*/
17
18#ifndef LATINIME_JNI_COMMON_H
19#define LATINIME_JNI_COMMON_H
20
Yusuke Nojimade2f8422011-09-27 11:15:18 +090021#include <stdlib.h>
22
Ken Wakasace9e52a2011-06-18 13:09:55 +090023#include "jni.h"
24
25namespace latinime {
26
Yusuke Nojimade2f8422011-09-27 11:15:18 +090027int registerNativeMethods(JNIEnv *env, const char *className, JNINativeMethod *methods,
Ken Wakasace9e52a2011-06-18 13:09:55 +090028 int numMethods);
29
Yusuke Nojimade2f8422011-09-27 11:15:18 +090030inline jint *safeGetIntArrayElements(JNIEnv *env, jintArray jArray) {
31 if (jArray) {
32 return env->GetIntArrayElements(jArray, NULL);
33 } else {
34 return NULL;
35 }
36}
37
38inline void safeReleaseIntArrayElements(JNIEnv *env, jintArray jArray, jint *cArray) {
39 if (jArray) {
40 env->ReleaseIntArrayElements(jArray, cArray, 0);
41 }
42}
43
Ken Wakasace9e52a2011-06-18 13:09:55 +090044} // namespace latinime
45
46#endif // LATINIME_JNI_COMMON_H