Convert JNI types to Native types

后端 未结 6 501
温柔的废话
温柔的废话 2020-12-30 18:47

While there is documentation regarding turning a jstring to a native string (string nativeString = env->GetStringUTFChars(jStringVariable, NULL);

6条回答
  •  粉色の甜心
    2020-12-30 18:54

    Same issue–fixed. In my case I'm using openFrameworks so I don't know if this applies to non-openFrameworks projects (haven't tested). However, it appears that the first two arguments in an external function are always "env" and "thiz" and these need to be defined explicitly for each new extern function.

    extern "C"{
    
    // casts the variable properly
    void Java_com_package_JavaClass_someFunction( JNIEnv*  env, jobject  thiz, jboolean yourBool ){
        myTestApp->someFunction( (bool) yourBool );
    }
    
    // "yourBool" will always be "1" because its taking the spot of "thiz" which is not null
    void Java_com_package_JavaClass_someFunction( JNIEnv*  env, jboolean yourBool ){
        myTestApp->someFunction( (bool) yourBool );
    }
    
    // "yourBool" will always be "1" because its taking the spot of "env" which is not null
    void Java_com_package_JavaClass_someFunction( jboolean yourBool ){
        myTestApp->someFunction( (bool) yourBool );
    }
    
    
    }
    

提交回复
热议问题