changed String handling to use proper localizing method
This commit is contained in:
parent
028606af8a
commit
1bda864efd
|
@ -161,6 +161,45 @@ void throwException(JNIEnv * env, const char * err) {
|
|||
throwGeneralException(env, "org/lwjgl/LWJGLException", err);
|
||||
}
|
||||
|
||||
// retrieves the locale-specific C string
|
||||
char * GetStringNativeChars(JNIEnv *env, jstring jstr) {
|
||||
jbyteArray bytes = 0;
|
||||
jthrowable exc;
|
||||
char *result = 0;
|
||||
jclass jcls_str;
|
||||
jmethodID MID_String_getBytes;
|
||||
|
||||
/* out of memory error? */
|
||||
if ((*env)->EnsureLocalCapacity(env, 2) < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// aquire getBytes method
|
||||
jcls_str = (*env)->FindClass(env, "java/lang/String");
|
||||
MID_String_getBytes = (*env)->GetMethodID(env, jcls_str, "getBytes", "()[B");
|
||||
|
||||
// get the bytes
|
||||
bytes = (jbyteArray) (*env)->CallObjectMethod(env, jstr, MID_String_getBytes);
|
||||
exc = (*env)->ExceptionOccurred(env);
|
||||
|
||||
// if no exception occured while getting bytes - continue
|
||||
if (!exc) {
|
||||
jint len = (*env)->GetArrayLength(env, bytes);
|
||||
result = (char *) malloc(len + 1);
|
||||
if (result == 0) {
|
||||
throwGeneralException(env, "java/lang/OutOfMemoryError", NULL);
|
||||
(*env)->DeleteLocalRef(env, bytes);
|
||||
return 0;
|
||||
}
|
||||
(*env)->GetByteArrayRegion(env, bytes, 0, len, (jbyte *) result);
|
||||
result[len] = 0; /* NULL-terminate */
|
||||
} else {
|
||||
(*env)->DeleteLocalRef(env, exc);
|
||||
}
|
||||
(*env)->DeleteLocalRef(env, bytes);
|
||||
return (char*) result;
|
||||
}
|
||||
|
||||
bool ext_InitializeFunctions(ExtGetProcAddressPROC gpa, int num_functions, ExtFunction *functions) {
|
||||
int i;
|
||||
void **ext_function_pointer_pointer;
|
||||
|
|
|
@ -130,7 +130,7 @@ extern void throwFMODException(JNIEnv * env, const char * err);
|
|||
extern void setDebugEnabled(bool enable);
|
||||
extern void printfDebug(const char *format, ...);
|
||||
extern bool getBooleanProperty(JNIEnv *env, const char* propertyName);
|
||||
|
||||
extern char * GetStringNativeChars(JNIEnv *env, jstring jstr);
|
||||
|
||||
extern void ext_InitializeClass(JNIEnv *env, jclass clazz, ExtGetProcAddressPROC gpa, int num_functions, JavaMethodAndExtFunction *functions);
|
||||
extern bool ext_InitializeFunctions(ExtGetProcAddressPROC gpa, int num_functions, ExtFunction *functions);
|
||||
|
|
|
@ -39,9 +39,9 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilActiveMipmap(JNIEnv *env, j
|
|||
* Signature: (Ljava/lang/String;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilApplyPal(JNIEnv *env, jclass clazz, jstring fileName) {
|
||||
const char *strFileName = (*env)->GetStringUTFChars(env, fileName, 0);
|
||||
char *strFileName = GetStringNativeChars(env, fileName, 0);
|
||||
jboolean result = ilApplyPal((const ILstring)strFileName);
|
||||
(*env)->ReleaseStringUTFChars(env, fileName, strFileName);
|
||||
free(strFileName);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -52,11 +52,11 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilApplyPal(JNIEnv *env, jclas
|
|||
* Signature: (Ljava/lang/String;Ljava/lang/String;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilApplyProfile(JNIEnv *env, jclass clazz, jstring inProfile, jstring outProfile) {
|
||||
const char *strInProfile = (*env)->GetStringUTFChars(env, inProfile, 0);
|
||||
const char *strOutProfile = (*env)->GetStringUTFChars(env, outProfile, 0);
|
||||
char *strInProfile = GetStringNativeChars(env, inProfile);
|
||||
char *strOutProfile = GetStringNativeChars(env, outProfile);
|
||||
jboolean result = ilApplyProfile((const ILstring)strInProfile, (const ILstring)strOutProfile);
|
||||
(*env)->ReleaseStringUTFChars(env, inProfile, strInProfile);
|
||||
(*env)->ReleaseStringUTFChars(env, outProfile, strOutProfile);
|
||||
free(strInProfile);
|
||||
free(strOutProfile);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -378,9 +378,9 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilIsImage(JNIEnv *env, jclass
|
|||
* Signature: (ILjava/lang/String;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilIsValid(JNIEnv *env, jclass clazz, jint type, jstring fileName) {
|
||||
const char *strFileName = (*env)->GetStringUTFChars(env, fileName, 0);
|
||||
char *strFileName = GetStringNativeChars(env, fileName);
|
||||
jboolean result = ilIsValid((ILuint)type, (const ILstring)strFileName);
|
||||
(*env)->ReleaseStringUTFChars(env, fileName, strFileName);
|
||||
free(strFileName);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -411,9 +411,9 @@ JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_ilKeyColour(JNIEnv *env, jclass c
|
|||
* Signature: (ILjava/lang/String;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilLoad(JNIEnv *env, jclass clazz, jint type, jstring fileName) {
|
||||
const char *strFileName = (*env)->GetStringUTFChars(env, fileName, 0);
|
||||
char *strFileName = GetStringNativeChars(env, fileName);
|
||||
jboolean result = ilLoad((ILenum)type, (const ILstring)strFileName);
|
||||
(*env)->ReleaseStringUTFChars(env, fileName, strFileName);
|
||||
free(strFileName);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -424,9 +424,9 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilLoad(JNIEnv *env, jclass cl
|
|||
* Signature: (Ljava/lang/String;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilLoadImage(JNIEnv *env, jclass clazz, jstring fileName) {
|
||||
const char *strFileName = (*env)->GetStringUTFChars(env, fileName, 0);
|
||||
char *strFileName = GetStringNativeChars(env, fileName, 0);
|
||||
jboolean result = ilLoadImage((const ILstring)strFileName);
|
||||
(*env)->ReleaseStringUTFChars(env, fileName, strFileName);
|
||||
free(strFileName);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -449,9 +449,9 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_nilLoadL(JNIEnv *env, jclass
|
|||
* Signature: (Ljava/lang/String;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilLoadPal(JNIEnv *env, jclass clazz, jstring fileName) {
|
||||
const char *strFileName = (*env)->GetStringUTFChars(env, fileName, 0);
|
||||
char *strFileName = GetStringNativeChars(env, fileName);
|
||||
jboolean result = ilLoadPal((const ILstring)strFileName);
|
||||
(*env)->ReleaseStringUTFChars(env, fileName, strFileName);
|
||||
free(strFileName);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -498,9 +498,9 @@ JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_ilPushAttrib(JNIEnv *env, jclass
|
|||
* Signature: (Ljava/lang/String;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilRemoveLoad(JNIEnv *env, jclass clazz, jstring ext) {
|
||||
const char *strExt = (*env)->GetStringUTFChars(env, ext, 0);
|
||||
char *strExt = GetStringNativeChars(env, ext, 0);
|
||||
jboolean result = ilRemoveLoad((const ILstring)strExt);
|
||||
(*env)->ReleaseStringUTFChars(env, ext, strExt);
|
||||
free(strExt);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -511,9 +511,9 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilRemoveLoad(JNIEnv *env, jcl
|
|||
* Signature: (Ljava/lang/String;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilRemoveSave(JNIEnv *env, jclass clazz, jstring ext) {
|
||||
const char *strExt = (*env)->GetStringUTFChars(env, ext, 0);
|
||||
char *strExt = GetStringNativeChars(env, ext, 0);
|
||||
jboolean result = ilRemoveSave((const ILstring)strExt);
|
||||
(*env)->ReleaseStringUTFChars(env, ext, strExt);
|
||||
free(strExt);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -551,9 +551,9 @@ JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_ilResetWrite(JNIEnv *env, jclass
|
|||
* Signature: (ILjava/lang/String;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilSave(JNIEnv *env, jclass clazz, jint type, jstring fileName) {
|
||||
const char *strFileName = (*env)->GetStringUTFChars(env, fileName, 0);
|
||||
char *strFileName = GetStringNativeChars(env, fileName);
|
||||
jboolean result = ilSave((ILenum)type, (const ILstring)strFileName);
|
||||
(*env)->ReleaseStringUTFChars(env, fileName, strFileName);
|
||||
free(strFileName);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -564,9 +564,9 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilSave(JNIEnv *env, jclass cl
|
|||
* Signature: (Ljava/lang/String;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilSaveImage(JNIEnv *env, jclass clazz, jstring fileName) {
|
||||
const char *strFileName = (*env)->GetStringUTFChars(env, fileName, 0);
|
||||
char *strFileName = GetStringNativeChars(env, fileName);
|
||||
jboolean result = ilSaveImage((const ILstring)strFileName);
|
||||
(*env)->ReleaseStringUTFChars(env, fileName, strFileName);
|
||||
free(strFileName);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -588,9 +588,9 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_devil_IL_nilSaveL(JNIEnv *env, jclass claz
|
|||
* Signature: (Ljava/lang/String;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilSavePal(JNIEnv *env, jclass clazz, jstring fileName) {
|
||||
const char *strFileName = (*env)->GetStringUTFChars(env, fileName, 0);
|
||||
char *strFileName = GetStringNativeChars(env, fileName);
|
||||
jboolean result = ilSavePal((const ILstring)strFileName);
|
||||
(*env)->ReleaseStringUTFChars(env, fileName, strFileName);
|
||||
free(strFileName);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -641,10 +641,10 @@ JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_nilSetPixels(JNIEnv *env, jclass
|
|||
* Signature: (ILjava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_devil_IL_ilSetString(JNIEnv *env, jclass clazz, jint mode, jstring string) {
|
||||
const char *strString = (*env)->GetStringUTFChars(env, string, 0);
|
||||
char *strString = GetStringNativeChars(env, string);
|
||||
|
||||
ilSetString(mode, (const ILstring)strString);
|
||||
(*env)->ReleaseStringUTFChars(env, string, strString);
|
||||
free(strString);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -682,9 +682,9 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilTypeFunc(JNIEnv *env, jclas
|
|||
* Signature: (Ljava/lang/String;IIIB)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilLoadData(JNIEnv *env, jclass clazz, jstring fileName, jint width, jint height, jint depth, jbyte bpp) {
|
||||
const char *strFileName = (*env)->GetStringUTFChars(env, fileName, 0);
|
||||
char *strFileName = GetStringNativeChars(env, fileName);
|
||||
jboolean result = ilLoadData((const ILstring)strFileName, (ILuint)width, (ILuint)height, (ILuint)depth, (ILubyte)bpp);
|
||||
(*env)->ReleaseStringUTFChars(env, fileName, strFileName);
|
||||
free(strFileName);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -706,9 +706,9 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_nilLoadDataL(JNIEnv *env, jcl
|
|||
* Signature: (Ljava/lang/String;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_devil_IL_ilSaveData(JNIEnv *env, jclass clazz, jstring fileName) {
|
||||
const char *strFileName = (*env)->GetStringUTFChars(env, fileName, 0);
|
||||
char *strFileName = GetStringNativeChars(env, fileName);
|
||||
jboolean result = ilSaveData((const ILstring)strFileName);
|
||||
(*env)->ReleaseStringUTFChars(env, fileName, strFileName);
|
||||
free(strFileName);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -147,13 +147,13 @@ static bool LoadOpenAL(JNIEnv *env, jobjectArray oalPaths) {
|
|||
jsize pathcount = (*env)->GetArrayLength(env, oalPaths);
|
||||
int i;
|
||||
jstring path;
|
||||
const char *path_str;
|
||||
char *path_str;
|
||||
char *lib_str;
|
||||
|
||||
printfDebug("Found %d OpenAL paths\n", (int)pathcount);
|
||||
for(i=0;i<pathcount;i++) {
|
||||
path = (jstring) (*env)->GetObjectArrayElement(env, oalPaths, i);
|
||||
path_str = (*env)->GetStringUTFChars(env, path, NULL);
|
||||
path_str = GetStringNativeChars(env, path);
|
||||
printfDebug("Testing '%s'\n", path_str);
|
||||
#ifdef _WIN32
|
||||
lib_str = concatenate(path_str, "lwjglaudio.dll");
|
||||
|
@ -190,7 +190,7 @@ static bool LoadOpenAL(JNIEnv *env, jobjectArray oalPaths) {
|
|||
printfDebug("Found OpenAL at '%s'\n", path_str);
|
||||
return true;
|
||||
}
|
||||
(*env)->ReleaseStringUTFChars(env, path, path_str);
|
||||
free(path_str);
|
||||
}
|
||||
throwException(env, "Could not load openal library.");
|
||||
return false;
|
||||
|
|
|
@ -65,12 +65,12 @@ JNIEXPORT void JNICALL Java_org_lwjgl_fmod3_FMOD_nCreate(JNIEnv *env, jclass cla
|
|||
jsize pathcount = (*env)->GetArrayLength(env, paths);
|
||||
int i;
|
||||
jstring path;
|
||||
const char *path_str;
|
||||
char *path_str;
|
||||
char *lib_str;
|
||||
|
||||
for(i=0;i<pathcount;i++) {
|
||||
path = (jstring) (*env)->GetObjectArrayElement(env, paths, i);
|
||||
path_str = (*env)->GetStringUTFChars(env, path, NULL);
|
||||
path_str = GetStringNativeChars(env, path);
|
||||
#ifdef _WIN32
|
||||
lib_str = concatenate(path_str, "fmod.dll");
|
||||
#endif
|
||||
|
@ -82,8 +82,8 @@ JNIEXPORT void JNICALL Java_org_lwjgl_fmod3_FMOD_nCreate(JNIEnv *env, jclass cla
|
|||
#endif
|
||||
printfDebug("Testing '%s'\n", lib_str);
|
||||
fmod_create(env, lib_str);
|
||||
free(lib_str);
|
||||
(*env)->ReleaseStringUTFChars(env, path, path_str);
|
||||
free(lib_str);
|
||||
free(path_str);
|
||||
|
||||
if(fmod_instance != NULL) {
|
||||
return;
|
||||
|
|
|
@ -45,8 +45,11 @@ void F_CALLBACKAPI fmusic_zxxcallback(FMUSIC_MODULE *mod, unsigned char param);
|
|||
* Signature: (Ljava/lang/String;)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_org_lwjgl_fmod3_FMusic_nFMUSIC_1LoadSong(JNIEnv *env, jclass clazz, jstring name) {
|
||||
const char* filename = (const char*) ((*env)->GetStringUTFChars(env, name, 0));
|
||||
return (jlong) fmod_instance->FMUSIC_LoadSong(filename);
|
||||
jlong result;
|
||||
char* filename = GetStringNativeChars(env, name);
|
||||
result = (jlong) fmod_instance->FMUSIC_LoadSong(filename);
|
||||
free(filename);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -72,12 +75,15 @@ JNIEXPORT jlong JNICALL Java_org_lwjgl_fmod3_FMusic_nFMUSIC_1LoadSongEx__Ljava_n
|
|||
*/
|
||||
JNIEXPORT jlong JNICALL Java_org_lwjgl_fmod3_FMusic_nFMUSIC_1LoadSongEx__Ljava_lang_String_2IIILjava_nio_IntBuffer_2II
|
||||
(JNIEnv *env, jclass clazz, jstring name, jint offset, jint length, jint mode, jobject sampleList, jint sampleListOffset, jint samplelistnum){
|
||||
int *sampleData = NULL;
|
||||
const char* filename = (const char*) ((*env)->GetStringUTFChars(env, name, 0));
|
||||
jlong result;
|
||||
int *sampleData = NULL;
|
||||
char* filename = GetStringNativeChars(env, name);
|
||||
if(sampleList != NULL) {
|
||||
sampleData = sampleListOffset + (int *) (*env)->GetDirectBufferAddress(env, sampleList);
|
||||
}
|
||||
return (jlong) fmod_instance->FMUSIC_LoadSongEx(filename, offset, length, mode, sampleData, samplelistnum);
|
||||
result = (jlong) fmod_instance->FMUSIC_LoadSongEx(filename, offset, length, mode, sampleData, samplelistnum);
|
||||
free(filename);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -449,8 +449,11 @@ JNIEXPORT jlong JNICALL Java_org_lwjgl_fmod3_FSound_nFSOUND_1Sample_1Load__ILjav
|
|||
* Signature: (ILjava/lang/String;III)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_org_lwjgl_fmod3_FSound_nFSOUND_1Sample_1Load__ILjava_lang_String_2III(JNIEnv * env, jclass clazz, jint index, jstring name, jint inputmode, jint offset, jint length) {
|
||||
const char* nName = (const char*) ((*env)->GetStringUTFChars(env, name, 0));
|
||||
return (long) fmod_instance->FSOUND_Sample_Load(index, nName, inputmode, offset, length);
|
||||
jlong result;
|
||||
char* nName = GetStringNativeChars(env, name);
|
||||
result = (jlong) fmod_instance->FSOUND_Sample_Load(index, nName, inputmode, offset, length);
|
||||
free(nName);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -977,8 +980,11 @@ JNIEXPORT jlong JNICALL Java_org_lwjgl_fmod3_FSound_nFSOUND_1Stream_1Open__Ljava
|
|||
* Signature: (Ljava/lang/String;III)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_org_lwjgl_fmod3_FSound_nFSOUND_1Stream_1Open__Ljava_lang_String_2III(JNIEnv * env, jclass clazz, jstring name, jint mode, jint offset, jint length) {
|
||||
const char* filename = (const char*) ((*env)->GetStringUTFChars(env, name, 0));
|
||||
return (jlong) fmod_instance->FSOUND_Stream_Open(filename, mode, offset, length);
|
||||
jlong result;
|
||||
char* filename = GetStringNativeChars(env, name);
|
||||
result = (jlong) fmod_instance->FSOUND_Stream_Open(filename, mode, offset, length);
|
||||
free(filename);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1043,9 +1049,9 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_fmod3_FSound_nFSOUND_1Stream_1SetSubStream
|
|||
* Signature: (JILjava/lang/String;)J
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_org_lwjgl_fmod3_FSound_nFSOUND_1Stream_1AddSyncPoint(JNIEnv * env, jclass clazz, jlong stream, jint pcmOffset, jstring name) {
|
||||
const char * nName = (*env)->GetStringUTFChars(env, name, 0);
|
||||
char * nName = GetStringNativeChars(env, name);
|
||||
FSOUND_SYNCPOINT * result = fmod_instance->FSOUND_Stream_AddSyncPoint((FSOUND_STREAM*) stream, pcmOffset, (void *) nName);
|
||||
(*env)->ReleaseStringUTFChars (env, name, nName);
|
||||
free(nName);
|
||||
return safeNewBuffer(env, result, 0);;
|
||||
}
|
||||
|
||||
|
@ -1087,7 +1093,7 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_fmod3_FSound_nFSOUND_1Stream_1CreateDSP
|
|||
* Signature: (JILjava/lang/String;Lorg/lwjgl/fmod_instance/FSoundTagField;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_fmod3_FSound_nFSOUND_1Stream_1FindTagField(JNIEnv * env, jclass clazz, jlong stream, jint type, jstring name, jobject tagField) {
|
||||
const char * nName = (*env)->GetStringUTFChars(env, name, 0);
|
||||
char * nName = GetStringNativeChars(env, name);
|
||||
bool result = false;
|
||||
void* value;
|
||||
jint length;
|
||||
|
@ -1100,7 +1106,7 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_fmod3_FSound_nFSOUND_1Stream_1FindTagF
|
|||
(*env)->CallVoidMethod(env, tagField, mid, name, safeNewBuffer(env, value, length), type);
|
||||
result = true;
|
||||
}
|
||||
(*env)->ReleaseStringUTFChars (env, name, nName);
|
||||
free(nName);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1288,9 +1294,9 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_fmod3_FSound_nFSOUND_1Stream_1Net_1Set
|
|||
* Signature: (Ljava/lang/String;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_fmod3_FSound_FSOUND_1Stream_1Net_1SetProxy(JNIEnv * env, jclass clazz, jstring proxy) {
|
||||
const char * proxyString = (*env)->GetStringUTFChars(env, proxy, 0);
|
||||
char * proxyString = GetStringNativeChars(env, proxy);
|
||||
jboolean result = fmod_instance->FSOUND_Stream_Net_SetProxy(proxyString);
|
||||
(*env)->ReleaseStringUTFChars(env, proxy, proxyString);
|
||||
free(proxyString);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -294,9 +294,9 @@ static jint JNICALL Java_org_lwjgl_openal_AL10_alGetError (JNIEnv *env, jclass c
|
|||
* ALboolean alIsExtensionPresent(ALubyte *extName);
|
||||
*/
|
||||
static jboolean JNICALL Java_org_lwjgl_openal_AL10_alIsExtensionPresent (JNIEnv *env, jclass clazz, jstring fname) {
|
||||
ALubyte* functionname = (ALubyte*) ((*env)->GetStringUTFChars(env, fname, 0));
|
||||
ALubyte* functionname = (ALubyte*) GetStringNativeChars(env, fname);
|
||||
jboolean result = (jboolean) alIsExtensionPresent(functionname);
|
||||
(*env)->ReleaseStringUTFChars(env, (jstring)functionname, 0);
|
||||
free(functionname);
|
||||
|
||||
CHECK_AL_ERROR
|
||||
return result;
|
||||
|
@ -309,9 +309,9 @@ static jboolean JNICALL Java_org_lwjgl_openal_AL10_alIsExtensionPresent (JNIEnv
|
|||
* ALenum alGetEnumValue(ALubyte *enumName);
|
||||
*/
|
||||
static jint JNICALL Java_org_lwjgl_openal_AL10_alGetEnumValue (JNIEnv *env, jclass clazz, jstring ename) {
|
||||
ALubyte* functionname = (ALubyte*) ((*env)->GetStringUTFChars(env, ename, 0));
|
||||
ALubyte* functionname = (ALubyte*) GetStringNativeChars(env, ename);
|
||||
jint result = (jint) alGetEnumValue(functionname);
|
||||
(*env)->ReleaseStringUTFChars(env, (jstring)functionname, 0);
|
||||
free(functionname);
|
||||
|
||||
CHECK_AL_ERROR
|
||||
return result;
|
||||
|
|
|
@ -117,16 +117,15 @@ static void JNICALL Java_org_lwjgl_openal_ALC_nalcGetIntegerv (JNIEnv *env, jcla
|
|||
* ALCdevice *alcOpenDevice( const ALubyte *tokstr );
|
||||
*/
|
||||
static jobject JNICALL Java_org_lwjgl_openal_ALC_alcOpenDevice (JNIEnv *env, jclass clazz, jstring tokstr) {
|
||||
const char * tokenstring;
|
||||
char * tokenstring;
|
||||
ALCdevice* device;
|
||||
/* get ready to create ALCdevice instance */
|
||||
jobject alcDevice_object = NULL;
|
||||
jclass alcDevice_class = NULL;
|
||||
jmethodID alcDevice_method = NULL;
|
||||
|
||||
jboolean isCopy = JNI_FALSE;
|
||||
if(tokstr != NULL) {
|
||||
tokenstring = ((*env)->GetStringUTFChars(env, tokstr, &isCopy));
|
||||
tokenstring = GetStringNativeChars(env, tokstr);
|
||||
} else {
|
||||
tokenstring = NULL;
|
||||
}
|
||||
|
@ -137,7 +136,7 @@ static jobject JNICALL Java_org_lwjgl_openal_ALC_alcOpenDevice (JNIEnv *env, jcl
|
|||
/* if error - cleanup and get out */
|
||||
if(device == NULL) {
|
||||
if(tokenstring != NULL) {
|
||||
(*env)->ReleaseStringUTFChars(env, tokstr, tokenstring);
|
||||
free(tokenstring);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -151,7 +150,7 @@ static jobject JNICALL Java_org_lwjgl_openal_ALC_alcOpenDevice (JNIEnv *env, jcl
|
|||
|
||||
/* clean up */
|
||||
if (tokenstring != NULL)
|
||||
(*env)->ReleaseStringUTFChars(env, tokstr, tokenstring);
|
||||
free(tokenstring);
|
||||
|
||||
return alcDevice_object;
|
||||
}
|
||||
|
@ -324,11 +323,11 @@ static jint JNICALL Java_org_lwjgl_openal_ALC_nalcGetError (JNIEnv *env, jclass
|
|||
*/
|
||||
static jboolean JNICALL Java_org_lwjgl_openal_ALC_nalcIsExtensionPresent (JNIEnv *env, jclass clazz, jint deviceaddress, jstring extName) {
|
||||
/* get extension */
|
||||
ALubyte* functionname = (ALubyte*) ((*env)->GetStringUTFChars(env, extName, 0));
|
||||
ALubyte* functionname = (ALubyte*) GetStringNativeChars(env, extName);
|
||||
|
||||
jboolean result = (jboolean) alcIsExtensionPresent((ALCdevice*) deviceaddress, functionname);
|
||||
|
||||
(*env)->ReleaseStringUTFChars(env, extName, (const char *)functionname);
|
||||
free(functionname);
|
||||
|
||||
CHECK_ALC_ERROR
|
||||
return result;
|
||||
|
@ -342,11 +341,11 @@ static jboolean JNICALL Java_org_lwjgl_openal_ALC_nalcIsExtensionPresent (JNIEnv
|
|||
*/
|
||||
static jint JNICALL Java_org_lwjgl_openal_ALC_nalcGetEnumValue (JNIEnv *env, jclass clazz, jint deviceaddress, jstring enumName) {
|
||||
/* get extension */
|
||||
ALubyte* enumerationname = (ALubyte*) ((*env)->GetStringUTFChars(env, enumName, 0));
|
||||
ALubyte* enumerationname = (ALubyte*) GetStringNativeChars(env, enumName);
|
||||
|
||||
jint result = (jint) alcGetEnumValue((ALCdevice*) deviceaddress, enumerationname);
|
||||
|
||||
(*env)->ReleaseStringUTFChars(env, enumName, (const char *)enumerationname);
|
||||
free(enumerationname);
|
||||
|
||||
CHECK_ALC_ERROR
|
||||
return result;
|
||||
|
|
|
@ -140,13 +140,14 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Sys_setProcessPriority
|
|||
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_Sys_nAlert(JNIEnv * env, jclass clazz, jstring title, jstring message)
|
||||
{
|
||||
jboolean copy = JNI_FALSE;
|
||||
const char * eMessageText = (*env)->GetStringUTFChars(env, message, ©);
|
||||
const char * cTitleBarText = (*env)->GetStringUTFChars(env, title, ©);
|
||||
printf("*** Alert ***\n%s\n%s\n", cTitleBarText, eMessageText);
|
||||
char * eMessageText = GetStringNativeChars(env, message);
|
||||
char * cTitleBarText = GetStringNativeChars(env, title);
|
||||
MessageBox(getCurrentHWND(), eMessageText, cTitleBarText, MB_OK | MB_TOPMOST);
|
||||
|
||||
(*env)->ReleaseStringUTFChars(env, message, eMessageText);
|
||||
(*env)->ReleaseStringUTFChars(env, title, cTitleBarText);
|
||||
printfDebug("*** Alert ***%s\n%s\n", cTitleBarText, eMessageText);
|
||||
|
||||
free(eMessageText);
|
||||
free(cTitleBarText);
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_org_lwjgl_Sys_getNativeLibraryVersion(JNIEnv *env, jclass clazz) {
|
||||
|
@ -161,9 +162,9 @@ JNIEXPORT jstring JNICALL Java_org_lwjgl_Sys_getNativeLibraryVersion(JNIEnv *env
|
|||
JNIEXPORT void JNICALL Java_org_lwjgl_Sys_nOpenURL
|
||||
(JNIEnv * env, jclass clazz, jstring url)
|
||||
{
|
||||
const char * urlString = (*env)->GetStringUTFChars(env, url, NULL);
|
||||
char * urlString = GetStringNativeChars(env, url);
|
||||
printf("*** Please visit %s\n", urlString);
|
||||
(*env)->ReleaseStringUTFChars(env, url, urlString);
|
||||
free(urlString);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -310,9 +310,9 @@ static void setWindowTitle(const char *title) {
|
|||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_setTitle(JNIEnv * env, jobject this, jstring title_obj) {
|
||||
const char * title = (*env)->GetStringUTFChars(env, title_obj, NULL);
|
||||
char * title = GetStringNativeChars(env, title_obj);
|
||||
setWindowTitle(title);
|
||||
(*env)->ReleaseStringUTFChars(env, title_obj, title);
|
||||
free(title);
|
||||
}
|
||||
|
||||
static void destroyWindow(void) {
|
||||
|
|
|
@ -97,7 +97,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Sys_nAlert(JNIEnv * env, jclass clazz, jst
|
|||
JNIEXPORT void JNICALL Java_org_lwjgl_Sys_nOpenURL
|
||||
(JNIEnv * env, jclass clazz, jstring url)
|
||||
{
|
||||
/* const char * urlString = env->GetStringUTFChars(url, NULL);
|
||||
/* char * urlString = GetStringNativeChars(env, url);
|
||||
|
||||
OSStatus err;
|
||||
ICInstance inst;
|
||||
|
@ -106,7 +106,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Sys_nOpenURL
|
|||
Str255 urlStr;
|
||||
|
||||
CopyCStringToPascal(urlString, urlStr);
|
||||
env->ReleaseStringUTFChars(url, urlString);
|
||||
free(urlString);
|
||||
err = ICStart(&inst, '????'); // Use your creator code if you have one!
|
||||
if (err == noErr) {
|
||||
startSel = 0;
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "Window.h"
|
||||
#include "org_lwjgl_Sys.h"
|
||||
#include "common_tools.h"
|
||||
#include <malloc.h>
|
||||
|
||||
unsigned __int64 hires_timer_freq = 0; // Hires timer frequency
|
||||
unsigned __int64 hires_timer = 0; // Hires timer current time
|
||||
|
@ -119,15 +120,14 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Sys_setProcessPriority
|
|||
JNIEXPORT void JNICALL Java_org_lwjgl_Sys_nAlert
|
||||
(JNIEnv * env, jclass clazz, jstring title, jstring message)
|
||||
{
|
||||
jboolean copy = JNI_FALSE;
|
||||
const char * eMessageText = env->GetStringUTFChars(message, ©);
|
||||
const char * cTitleBarText = env->GetStringUTFChars(title, ©);
|
||||
char * eMessageText = GetStringNativeChars(env, message);
|
||||
char * cTitleBarText = GetStringNativeChars(env, title);
|
||||
MessageBox(getCurrentHWND(), eMessageText, cTitleBarText, MB_OK | MB_TOPMOST);
|
||||
|
||||
printfDebug("*** Alert ***%s\n%s\n", cTitleBarText, eMessageText);
|
||||
|
||||
env->ReleaseStringUTFChars(message, eMessageText);
|
||||
env->ReleaseStringUTFChars(title, cTitleBarText);
|
||||
free(eMessageText);
|
||||
free(cTitleBarText);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -138,13 +138,13 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Sys_nAlert
|
|||
JNIEXPORT void JNICALL Java_org_lwjgl_Sys_nOpenURL
|
||||
(JNIEnv * env, jclass clazz, jstring url)
|
||||
{
|
||||
const char * urlString = env->GetStringUTFChars(url, NULL);
|
||||
char * urlString = GetStringNativeChars(env, url);
|
||||
|
||||
char command[256];
|
||||
strcpy(command, "");
|
||||
strcat(command, "rundll32 url.dll,FileProtocolHandler ");
|
||||
strncat(command, urlString, 200); // Prevent buffer overflow
|
||||
env->ReleaseStringUTFChars(url, urlString);
|
||||
free(urlString);
|
||||
|
||||
STARTUPINFO si;
|
||||
PROCESS_INFORMATION pi;
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "extgl_wgl.h"
|
||||
#include "display.h"
|
||||
#include "org_lwjgl_opengl_Win32Display.h"
|
||||
#include <malloc.h>
|
||||
|
||||
static bool oneShotInitialised = false; // Registers the LWJGL window class
|
||||
|
||||
|
@ -525,9 +526,9 @@ HWND createWindow(int x, int y, int width, int height, bool fullscreen, bool und
|
|||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_setTitle
|
||||
(JNIEnv * env, jobject self, jstring title_obj)
|
||||
{
|
||||
const char * title = env->GetStringUTFChars(title_obj, NULL);
|
||||
char * title = GetStringNativeChars(env, title_obj);
|
||||
SetWindowText(display_hwnd, title);
|
||||
env->ReleaseStringUTFChars(title_obj, title);
|
||||
free(title);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue