JAVA 쪽
1 2 3 4 5 | static private void javaDefineArray(Object ... args) { for (Object o : args) { print( "javaDefineArray " + o); } } |
C쪽
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | // Lookup the method using GetMethodID or GetStaticMethodID mid = (*env)->GetStaticMethodID(env, class , "javaDefineArray" , "([Ljava/lang/Object;)V" ); // C function taking variable args ( all String in this example ) static void javaDefineArray(JNIEnv * env, jobject o, ...) { int i = 0; int count = 0; char * msg[100+1] = {0}; // 100 args max jobjectArray ja; va_list list; va_start (list, o); do {msg[count] = va_arg (list, char *); } while (msg[count] !=0 && ++count < 100); // end/saftey check va_end (list); ja = (*env)->NewObjectArray(env, count, (*env)->FindClass(env, "java/lang/String" ), (*env)->NewStringUTF(env, "" )); for (i=0;i!=count;i++) { (*env)->SetObjectArrayElement(env,ja,i,(*env)->NewStringUTF(env, msg[i])); } (*env)->CallVoidMethod(env, o, mid, ja); } |
Designed by sketchbooks.co.kr / sketchbook5 board skin
Sketchbook5, 스케치북5
Sketchbook5, 스케치북5
Sketchbook5, 스케치북5
Sketchbook5, 스케치북5