Changeset 13997
- Timestamp:
- 11/21/12 17:22:39 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/android/ISSM/jni/Main.cpp
r13959 r13997 1 1 #include <jni.h> 2 2 #include "../../../c/android/fac.h" 3 #include <cstddef> 4 /////////////////////////////////////////////////////////////////////////////////////////// 3 5 namespace com_example_issm 4 6 { 5 static jlong factorial(JNIEnv *env, jclass clazz, jlong n) 7 fac* f; 8 //------------------------------------------------------------------------------------ 9 void initilizeObject(JNIEnv *env, jclass clazz) 6 10 { 7 fac *f = new fac(); 8 jlong result = (jlong) (f->factorial(n)); 9 delete(f); 10 return (jlong) result; 11 f = new fac(); 11 12 } 12 13 //------------------------------------------------------------------------------------ 13 static JNINativeMethod method_table[] = { 14 {"fac" ,"(J)J" , (void *) factorial}, 14 //fill out the first two slots, extract the same way in java using get(int position) 15 void fillBuffer(JNIEnv *env, jclass clazz , jobject buf) 16 { 17 jdouble *bBuf = (jdouble *)env->GetDirectBufferAddress(buf); 18 bBuf[1] = 10.67; 19 bBuf[2] = 100.0; 20 } 21 //------------------------------------------------------------------------------------ 22 jlong factorial(JNIEnv *env, jclass clazz, jlong n) 23 { 24 if( f != NULL) 25 return (jlong) (f->factorial(n)); 26 return 0; 27 } 28 29 //------------------------------------------------------------------------------------ 30 static JNINativeMethod method_table[] = 31 { 32 {"fac" , "(J)J" , (void *) factorial}, 33 {"initialize" , "()V" , (void *) initilizeObject}, 34 {"processBuffer", "(Ljava/nio/DoubleBuffer;)V", (void *) fillBuffer} 15 35 }; 16 36 } 17 37 //------------------------------------------------------------------------------------ 18 38 using namespace com_example_issm; 19 39 … … 29 49 if(clazz) 30 50 { 31 env->RegisterNatives(clazz, method_table, 1);51 env->RegisterNatives(clazz, method_table, 3); 32 52 env->DeleteLocalRef(clazz); 33 53 return JNI_VERSION_1_6; … … 39 59 // Register methods with env->RegisterNatives. 40 60 } 61 ///////////////////////////////////////////////////////////////////////////////////////////
Note:
See TracChangeset
for help on using the changeset viewer.