diff options
author | Kenneth Russel <[email protected]> | 2006-08-01 23:22:54 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2006-08-01 23:22:54 +0000 |
commit | 5f3f32052969e8133c8fe7c50835763cedfebb43 (patch) | |
tree | 6ccd8ac7f94ee02ce16b5568d8c965b1c74c9a09 /src/native/windows | |
parent | ff5fa954165c45037849b986f41f4a192cad163e (diff) |
Added NativeLibrary helper class to com.sun.gluegen.runtime package,
principally to generally solve the problem of downloading dependent
libraries of GlueGen-generated native code, as in the case of JOAL and
OpenAL reported recently by Shawn Kendall on JOAL forums.
Autogenerated Java and native code associated with this new
NativeLibrary helper class is currently checked in to the GlueGen
workspace to make it easier to build across multiple platforms; it can
be regenerated by running the generate.nativelibrary.sources Ant
target in the GlueGen workspace. Building of the native code in the
GlueGen workspace is currently disabled by default and can be enabled
by specifying -Dbuild.native=1 on the ant command line. Use of the new
NativeLibrary class in JOAL is currently disabled by default and can
be enabled by specifying -Djoal.use.gluegen=1 to applications using
JOAL. New functionality has been lightly tested with JOAL on Windows
and appears to be working. More testing, including build and Java Web
Start deployment testing, to follow on other platforms.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/gluegen/trunk@37 a78bb65f-1512-4460-ba86-f6dc96a7bf27
Diffstat (limited to 'src/native/windows')
-rwxr-xr-x | src/native/windows/WindowsDynamicLinkerImpl_JNI.c | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/src/native/windows/WindowsDynamicLinkerImpl_JNI.c b/src/native/windows/WindowsDynamicLinkerImpl_JNI.c new file mode 100755 index 0000000..2b99098 --- /dev/null +++ b/src/native/windows/WindowsDynamicLinkerImpl_JNI.c @@ -0,0 +1,92 @@ +/* !---- DO NOT EDIT: This file autogenerated by com\sun\gluegen\JavaEmitter.java on Mon Jul 31 16:26:59 PDT 2006 ----! */ + +#include <jni.h> + +#include <assert.h> + + #include <windows.h> + /* This typedef is only needed for VC6 */ + #if _MSC_VER <= 1200 + typedef int intptr_t; + #endif + +/* Java->C glue code: + * Java package: com.sun.gluegen.runtime.WindowsDynamicLinkerImpl + * Java method: int FreeLibrary(long hLibModule) + * C function: BOOL FreeLibrary(HANDLE hLibModule); + */ +JNIEXPORT jint JNICALL +Java_com_sun_gluegen_runtime_WindowsDynamicLinkerImpl_FreeLibrary__J(JNIEnv *env, jclass _unused, jlong hLibModule) { + BOOL _res; + _res = FreeLibrary((HANDLE) (intptr_t) hLibModule); + return _res; +} + + +/* Java->C glue code: + * Java package: com.sun.gluegen.runtime.WindowsDynamicLinkerImpl + * Java method: int GetLastError() + * C function: DWORD GetLastError(void); + */ +JNIEXPORT jint JNICALL +Java_com_sun_gluegen_runtime_WindowsDynamicLinkerImpl_GetLastError__(JNIEnv *env, jclass _unused) { + DWORD _res; + _res = GetLastError(); + return _res; +} + + +/* 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); + */ +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; + PROC _res; + if (lpProcName != NULL) { + if (lpProcName != NULL) { + _UTF8lpProcName = (*env)->GetStringUTFChars(env, lpProcName, (jboolean*)NULL); + if (_UTF8lpProcName == NULL) { + (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/OutOfMemoryError"), + "Failed to get UTF-8 chars for argument \"lpProcName\" in native dispatcher for \"GetProcAddress\""); + return 0; + } + } + } + _res = GetProcAddress((HANDLE) (intptr_t) hModule, (LPCSTR) _UTF8lpProcName); + if (lpProcName != NULL) { + (*env)->ReleaseStringUTFChars(env, lpProcName, _UTF8lpProcName); + } + return (jlong) (intptr_t) _res; +} + + +/* 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); + */ +JNIEXPORT jlong JNICALL +Java_com_sun_gluegen_runtime_WindowsDynamicLinkerImpl_LoadLibraryA__Ljava_lang_String_2(JNIEnv *env, jclass _unused, jstring lpLibFileName) { + const char* _UTF8lpLibFileName = NULL; + HANDLE _res; + if (lpLibFileName != NULL) { + if (lpLibFileName != NULL) { + _UTF8lpLibFileName = (*env)->GetStringUTFChars(env, lpLibFileName, (jboolean*)NULL); + if (_UTF8lpLibFileName == NULL) { + (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/OutOfMemoryError"), + "Failed to get UTF-8 chars for argument \"lpLibFileName\" in native dispatcher for \"LoadLibraryA\""); + return 0; + } + } + } + _res = LoadLibraryA((LPCSTR) _UTF8lpLibFileName); + if (lpLibFileName != NULL) { + (*env)->ReleaseStringUTFChars(env, lpLibFileName, _UTF8lpLibFileName); + } + return (jlong) (intptr_t) _res; +} + + |