diff options
author | 2012-06-08 19:05:47 +0900 | |
---|---|---|
committer | 2012-06-08 20:46:19 +0900 | |
commit | e7b34b9f867b64eabc3606e5ef21e26eda8de0f6 (patch) | |
tree | 52354e792d3ea6dc84b62ef1940a62677b195f2d /native | |
parent | aa564e336e6f2562ac05e384e06ed66c6b162c45 (diff) | |
download | latinime-e7b34b9f867b64eabc3606e5ef21e26eda8de0f6.tar.gz latinime-e7b34b9f867b64eabc3606e5ef21e26eda8de0f6.tar.xz latinime-e7b34b9f867b64eabc3606e5ef21e26eda8de0f6.zip |
Add NativeUtils.powf()
Change-Id: I0339f39d49bc6390d098017f32d92c776974e03e
Diffstat (limited to 'native')
-rw-r--r-- | native/jni/Android.mk | 1 | ||||
-rw-r--r-- | native/jni/com_android_inputmethod_latin_NativeUtils.cpp | 40 | ||||
-rw-r--r-- | native/jni/com_android_inputmethod_latin_NativeUtils.h | 29 | ||||
-rw-r--r-- | native/jni/jni_common.cpp | 6 |
4 files changed, 76 insertions, 0 deletions
diff --git a/native/jni/Android.mk b/native/jni/Android.mk index 0f7aef269..edcc0677d 100644 --- a/native/jni/Android.mk +++ b/native/jni/Android.mk @@ -35,6 +35,7 @@ LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-function LATIN_IME_JNI_SRC_FILES := \ com_android_inputmethod_keyboard_ProximityInfo.cpp \ com_android_inputmethod_latin_BinaryDictionary.cpp \ + com_android_inputmethod_latin_NativeUtils.cpp \ jni_common.cpp LATIN_IME_CORE_SRC_FILES := \ diff --git a/native/jni/com_android_inputmethod_latin_NativeUtils.cpp b/native/jni/com_android_inputmethod_latin_NativeUtils.cpp new file mode 100644 index 000000000..c1e586a4b --- /dev/null +++ b/native/jni/com_android_inputmethod_latin_NativeUtils.cpp @@ -0,0 +1,40 @@ +/* +** +** Copyright 2012, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +#include "com_android_inputmethod_latin_NativeUtils.h" +#include "jni.h" +#include "jni_common.h" + +#include <math.h> + +namespace latinime { + +static float latinime_NativeUtils_powf(float x, float y) { + return powf(x, y); +} + +static JNINativeMethod sMethods[] = { + {"powf", "(FF)F", (void*)latinime_NativeUtils_powf} +}; + +int register_NativeUtils(JNIEnv *env) { + const char* const kClassPathName = "com/android/inputmethod/latin/NativeUtils"; + return registerNativeMethods(env, kClassPathName, sMethods, + sizeof(sMethods) / sizeof(sMethods[0])); +} + +} // namespace latinime diff --git a/native/jni/com_android_inputmethod_latin_NativeUtils.h b/native/jni/com_android_inputmethod_latin_NativeUtils.h new file mode 100644 index 000000000..13a348a5c --- /dev/null +++ b/native/jni/com_android_inputmethod_latin_NativeUtils.h @@ -0,0 +1,29 @@ +/* +** +** Copyright 2012, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +#ifndef _COM_ANDROID_INPUTMETHOD_LATIN_NATIVEUTILS_H +#define _COM_ANDROID_INPUTMETHOD_LATIN_NATIVEUTILS_H + +#include "jni.h" + +namespace latinime { + +int register_NativeUtils(JNIEnv *env); + +} + +#endif // _COM_ANDROID_INPUTMETHOD_LATIN_NATIVEUTILS_H diff --git a/native/jni/jni_common.cpp b/native/jni/jni_common.cpp index b9e2c3255..1314bab27 100644 --- a/native/jni/jni_common.cpp +++ b/native/jni/jni_common.cpp @@ -19,6 +19,7 @@ #include "com_android_inputmethod_keyboard_ProximityInfo.h" #include "com_android_inputmethod_latin_BinaryDictionary.h" +#include "com_android_inputmethod_latin_NativeUtils.h" #include "defines.h" #include "jni.h" #include "proximity_info.h" @@ -52,6 +53,11 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) { goto bail; } + if (!register_NativeUtils(env)) { + AKLOGE("ERROR: NativeUtils native registration failed"); + goto bail; + } + /* success -- return valid version number */ result = JNI_VERSION_1_4; |