aboutsummaryrefslogtreecommitdiffstats
path: root/src/native/windows/WindowsDynamicLinkerImpl_JNI.c
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2008-05-27 10:06:20 +0000
committerKenneth Russel <[email protected]>2008-05-27 10:06:20 +0000
commitf1e08a23facb2d718276b3fbf59b0df2b54fceb9 (patch)
treeb7f5b37c2187d39e90681400206685293d758aaa /src/native/windows/WindowsDynamicLinkerImpl_JNI.c
parent0ce0a36ec694da77a0ef02ed46c2b152a17d5c80 (diff)
Changed implementation of ArgumentIsString to work with wide-character
null-terminated strings on Windows. Changed Windows dynamic linker to use LoadLibraryW which is the only variant available on Windows CE. Changed GetProcAddress to explicitly named GetProcAddressA; this is implicitly the only variant available on Windows XP. Tested by compiling gluegen-rt.dll for both Windows XP and Windows CE. Also brought dynlink-unix-CustomJavaCode.java in line with modifications that were apparently hand made to the UnixDynamicLinkerImpl and MacOSXDynamicLinkerImpl classes. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/gluegen/trunk@79 a78bb65f-1512-4460-ba86-f6dc96a7bf27
Diffstat (limited to 'src/native/windows/WindowsDynamicLinkerImpl_JNI.c')
-rwxr-xr-xsrc/native/windows/WindowsDynamicLinkerImpl_JNI.c53
1 files changed, 28 insertions, 25 deletions
diff --git a/src/native/windows/WindowsDynamicLinkerImpl_JNI.c b/src/native/windows/WindowsDynamicLinkerImpl_JNI.c
index db20b15..63afd99 100755
--- a/src/native/windows/WindowsDynamicLinkerImpl_JNI.c
+++ b/src/native/windows/WindowsDynamicLinkerImpl_JNI.c
@@ -1,14 +1,20 @@
-/* !---- DO NOT EDIT: This file autogenerated by com\sun\gluegen\JavaEmitter.java on Mon Jul 31 16:26:59 PDT 2006 ----! */
+/* !---- DO NOT EDIT: This file autogenerated by com\sun\gluegen\JavaEmitter.java on Tue May 27 02:37:55 PDT 2008 ----! */
#include <jni.h>
+#include <stdlib.h>
#include <assert.h>
#include <windows.h>
- /* This typedef is apparently needed for compilers before VC8 */
- #if _MSC_VER < 1400
+ /* This typedef is apparently needed for compilers before VC8,
+ and for the embedded ARM compilers we're using */
+ #if (_MSC_VER < 1400) || defined(UNDER_CE)
typedef int intptr_t;
#endif
+ /* GetProcAddress doesn't exist in A/W variants under desktop Windows */
+ #ifndef UNDER_CE
+ #define GetProcAddressA GetProcAddress
+ #endif
/* Java->C glue code:
* Java package: com.sun.gluegen.runtime.WindowsDynamicLinkerImpl
@@ -38,26 +44,24 @@ Java_com_sun_gluegen_runtime_WindowsDynamicLinkerImpl_GetLastError__(JNIEnv *env
/* Java->C glue code:
* Java package: com.sun.gluegen.runtime.WindowsDynamicLinkerImpl
- * Java method: long GetProcAddress(long hModule, java.lang.String lpProcName)
- * C function: PROC GetProcAddress(HANDLE hModule, LPCSTR lpProcName);
+ * Java method: long GetProcAddressA(long hModule, java.lang.String lpProcName)
+ * C function: PROC GetProcAddressA(HANDLE hModule, LPCSTR lpProcName);
*/
JNIEXPORT jlong JNICALL
-Java_com_sun_gluegen_runtime_WindowsDynamicLinkerImpl_GetProcAddress__JLjava_lang_String_2(JNIEnv *env, jclass _unused, jlong hModule, jstring lpProcName) {
- const char* _UTF8lpProcName = NULL;
+Java_com_sun_gluegen_runtime_WindowsDynamicLinkerImpl_GetProcAddressA__JLjava_lang_String_2(JNIEnv *env, jclass _unused, jlong hModule, jstring lpProcName) {
+ const char* _strchars_lpProcName = NULL;
PROC _res;
if (lpProcName != NULL) {
- if (lpProcName != NULL) {
- _UTF8lpProcName = (*env)->GetStringUTFChars(env, lpProcName, (jboolean*)NULL);
- if (_UTF8lpProcName == NULL) {
+ _strchars_lpProcName = (*env)->GetStringUTFChars(env, lpProcName, (jboolean*)NULL);
+ if (_strchars_lpProcName == NULL) {
(*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/OutOfMemoryError"),
- "Failed to get UTF-8 chars for argument \"lpProcName\" in native dispatcher for \"GetProcAddress\"");
+ "Failed to get UTF-8 chars for argument \"lpProcName\" in native dispatcher for \"GetProcAddressA\"");
return 0;
}
- }
}
- _res = GetProcAddress((HANDLE) (intptr_t) hModule, (LPCSTR) _UTF8lpProcName);
+ _res = GetProcAddressA((HANDLE) (intptr_t) hModule, (LPCSTR) _strchars_lpProcName);
if (lpProcName != NULL) {
- (*env)->ReleaseStringUTFChars(env, lpProcName, _UTF8lpProcName);
+ (*env)->ReleaseStringUTFChars(env, lpProcName, _strchars_lpProcName);
}
return (jlong) (intptr_t) _res;
}
@@ -65,26 +69,25 @@ Java_com_sun_gluegen_runtime_WindowsDynamicLinkerImpl_GetProcAddress__JLjava_lan
/* Java->C glue code:
* Java package: com.sun.gluegen.runtime.WindowsDynamicLinkerImpl
- * Java method: long LoadLibraryA(java.lang.String lpLibFileName)
- * C function: HANDLE LoadLibraryA(LPCSTR lpLibFileName);
+ * Java method: long LoadLibraryW(java.lang.String lpLibFileName)
+ * C function: HANDLE LoadLibraryW(LPCWSTR lpLibFileName);
*/
JNIEXPORT jlong JNICALL
-Java_com_sun_gluegen_runtime_WindowsDynamicLinkerImpl_LoadLibraryA__Ljava_lang_String_2(JNIEnv *env, jclass _unused, jstring lpLibFileName) {
- const char* _UTF8lpLibFileName = NULL;
+Java_com_sun_gluegen_runtime_WindowsDynamicLinkerImpl_LoadLibraryW__Ljava_lang_String_2(JNIEnv *env, jclass _unused, jstring lpLibFileName) {
+ jchar* _strchars_lpLibFileName = NULL;
HANDLE _res;
if (lpLibFileName != NULL) {
- if (lpLibFileName != NULL) {
- _UTF8lpLibFileName = (*env)->GetStringUTFChars(env, lpLibFileName, (jboolean*)NULL);
- if (_UTF8lpLibFileName == NULL) {
+ _strchars_lpLibFileName = (jchar *) calloc((*env)->GetStringLength(env, lpLibFileName) + 1, sizeof(jchar));
+ if (_strchars_lpLibFileName == NULL) {
(*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/OutOfMemoryError"),
- "Failed to get UTF-8 chars for argument \"lpLibFileName\" in native dispatcher for \"LoadLibraryA\"");
+ "Could not allocate temporary buffer for copying string argument \"lpLibFileName\" in native dispatcher for \"LoadLibraryW\"");
return 0;
}
- }
+ (*env)->GetStringRegion(env, lpLibFileName, 0, (*env)->GetStringLength(env, lpLibFileName), _strchars_lpLibFileName);
}
- _res = LoadLibraryA((LPCSTR) _UTF8lpLibFileName);
+ _res = LoadLibraryW((LPCWSTR) _strchars_lpLibFileName);
if (lpLibFileName != NULL) {
- (*env)->ReleaseStringUTFChars(env, lpLibFileName, _UTF8lpLibFileName);
+ free((void*) _strchars_lpLibFileName);
}
return (jlong) (intptr_t) _res;
}