so I've managed to pass an int from java to c++ and to c# and back.
no problems cause it gets serialized automatically.
but when dealing with string - the object JNI passes is jstring which
casts to char* but how to pass it to c#?
Do I need to Marshal it on the c# side??? can someone post a bit of
code example????
my C++ code is like so :
Expand|Select|Wrap|Line Numbers
- ...
- JNIEXPORT jint JNICALL Java_jni_ExecuteString_executeString (JNIEnv *env, jobject, jstring strinput) {
- ExecuteStringC* myObj = new ExecuteStringC();
- const char *str;
- int result;
- str = env->GetStringUTFChars(strinput, 0);
- result = myObj->callExecuteString(str);
- env->ReleaseStringUTFChars(strinput, str);
- return result;
Expand|Select|Wrap|Line Numbers
- public __gc class ExecuteStringC
- {
- public:
- CSharpExecuteString __gc *execObj;
- ExecuteStringC() {
- execObj = new CSharpExecuteString();
- }
- int callExecuteString(const char* str) {
- return execObj->executeString(str);
- }
- };
Expand|Select|Wrap|Line Numbers
- class CSharpExecuteString
- {
- public int executeString(string stringToExec)
- {
- Console.WriteLine("C# Says : " + stringToExec);
- return 0;
- }
- }
I do believe it's the lather, but if anyone can shed some info on the subject (posting some code will be nice...)
10x in advance to all contributors :)