JNIEXPORT jobjectArray JNICALL Java_com_congnt_ndkguide_Store_getColorArray( JNIEnv* pEnv, jobject pThis, jstring pKey) { StoreEntry* lEntry = findEntry(pEnv, &gStore, pKey, NULL); if (isEntryValid(pEnv, lEntry, StoreType_ArrayColor)) { jclass lColorClass = (*pEnv)->FindClass(pEnv, "com/congnt/ndkguide/Color"); if (lColorClass == NULL) return NULL; jobjectArray lColorJavaArray = (*pEnv)->NewObjectArray(pEnv, lEntry->mLength, lColorClass, NULL); (*pEnv)->DeleteLocalRef(pEnv, lColorClass); if (lColorJavaArray == NULL) return NULL; int32_t i; for (i = 0; i < lEntry->mLength; ++i) { (*pEnv)->SetObjectArrayElement(pEnv, lColorJavaArray, i, lEntry->mValue.mColorArray[i]); if ((*pEnv)->ExceptionCheck(pEnv)) { return NULL; } } return lColorJavaArray; } else { return NULL; } }
JNIEXPORT jobject JNICALL Java_com_congnt_ndkguide_Store_getColor(JNIEnv* pEnv, jobject pThis, jstring pKey) { StoreEntry* lEntry = findEntry(pEnv, &gStore, pKey, NULL); if (isEntryValid(pEnv, lEntry, StoreType_Color)) { return lEntry->mValue.mColor; } else { return NULL; } }
JNIEXPORT jstring JNICALL Java_com_congnt_ndkguide_Store_getString(JNIEnv* pEnv, jobject pThis, jstring pKey) { StoreEntry* lEntry = findEntry(pEnv, &gStore, pKey, NULL); if (isEntryValid(pEnv, lEntry, StoreType_String)) { return (*pEnv)->NewStringUTF(pEnv, lEntry->mValue.mString); } else { return NULL; } }
JNIEXPORT jint JNICALL Java_com_congnt_ndkguide_Store_getInteger(JNIEnv* pEnv, jobject pThis, jstring pKey) { StoreEntry* lEntry = findEntry(pEnv, &gStore, pKey, NULL); if (isEntryValid(pEnv, lEntry, StoreType_Integer)) { return lEntry->mValue.mInteger; } else { return 0.0f; } }
JNIEXPORT jint JNICALL Java_com_example_micthebick_ndktest_Store_getInteger (JNIEnv *pEnv, jobject pThis, jstring pKey){ StoreEntry* lEntry = findEntry(pEnv, &mStore, pKey, NULL); if (isEntryValid(pEnv, lEntry, StoreType_Integer)){ return lEntry->mValue.mInteger; } else{ return 0; } }
JNIEXPORT jintArray JNICALL Java_com_congnt_ndkguide_Store_getIntegerArray( JNIEnv* pEnv, jobject pThis, jstring pKey) { StoreEntry* lEntry = findEntry(pEnv, &gStore, pKey, NULL); if (isEntryValid(pEnv, lEntry, StoreType_ArrayInteger)) { jintArray lJavaArray = (*pEnv)->NewIntArray(pEnv, lEntry->mLength); if (lJavaArray == NULL) { return; } (*pEnv)->SetIntArrayRegion(pEnv, lJavaArray, 0, lEntry->mLength, lEntry->mValue.mIntegerArray); return lJavaArray; } else { return NULL; } }