Created
September 20, 2010 18:25
-
-
Save I82Much/588374 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <jni.h> | |
#include "Translator.h" | |
#include <stdio.h> | |
extern "C" { | |
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { | |
printf("We're loaded by the OS!\n"); | |
return JNI_VERSION_1_4; | |
} | |
/* | |
* Class: TranslatorWrapper | |
* Method: fromBinary | |
* Signature: ([B)Ljava/lang/String; | |
*/ | |
JNIEXPORT jstring JNICALL Java_com_example_hellojni_HelloJni_fromBinary | |
(JNIEnv * env, jobject, jbyteArray) { | |
Translator * x = new Translator(); | |
unsigned char chars[] = {1,2,3}; | |
return env->NewStringUTF("HI"); | |
} | |
/* | |
* Class: TranslatorWrapper | |
* Method: fromXML | |
* Signature: (Ljava/lang/String;)[B | |
*/ | |
JNIEXPORT jbyteArray JNICALL Java_com_example_hellojni_HelloJni_fromXML | |
(JNIEnv * env, jobject, jstring) { | |
int numElems = 10; | |
jbyteArray result = env->NewByteArray(numElems); | |
return result; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment