Skip to content

Commit

Permalink
clean up some function naming
Browse files Browse the repository at this point in the history
fix typo
  • Loading branch information
twall committed Apr 21, 2013
1 parent 5d8243e commit 8d37675
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 27 deletions.
2 changes: 2 additions & 0 deletions native/Makefile
Expand Up @@ -367,6 +367,8 @@ $(LIBRARY): $(JNIDISPATCH_OBJS) $(FFI_LIB)
$(TESTLIB): $(BUILD)/testlib.o
$(LD) $(LDFLAGS) $< $(LIBS)

# These targets provide for different shared library loading methods
# without getting into native library load conflicts
$(TESTLIB_JAR) $(TESTLIB_PATH) $(TESTLIB_TRUNC): $(TESTLIB)
@cp $< $@

Expand Down
10 changes: 5 additions & 5 deletions native/callback.c
Expand Up @@ -538,23 +538,23 @@ static void make_thread_keys() {

/** Store the requested detach state for the current thread. */
void
jnidispatch_detach(jboolean d) {
JNA_detach(jboolean d) {
if (!TLS_SET(tls_detach_key, L2A((jlong)(d?THREAD_DETACH:THREAD_LEAVE_ATTACHED)))) {
fprintf(stderr, "JNA: unable to set thread-local detach value\n");
}
}

/** Store the value of errno/GetLastError in TLS */
void
jnidispatch_set_last_error(int err) {
JNA_set_last_error(int err) {
if (!TLS_SET(tls_errno_key, L2A((jlong)err))) {
fprintf(stderr, "JNA: unable to set thread-local errno value\n");
}
}

/** Store the value of errno/GetLastError in TLS */
int
jnidispatch_get_last_error() {
JNA_get_last_error() {
return (int)A2L(TLS_GET(tls_errno_key));
}

Expand Down Expand Up @@ -645,7 +645,7 @@ callback_dispatch(ffi_cif* cif, void* resp, void** cbargs, void* user_data) {
}

const char*
jnidispatch_callback_init(JNIEnv* env) {
JNA_callback_init(JNIEnv* env) {
#ifndef _WIN32
static pthread_once_t key_once = PTHREAD_ONCE_INIT;
pthread_once(&key_once, make_thread_keys);
Expand All @@ -657,7 +657,7 @@ jnidispatch_callback_init(JNIEnv* env) {
}

void
jnidispatch_callback_dispose(JNIEnv* env) {
JNA_callback_dispose(JNIEnv* env) {
if (classObject) {
(*env)->DeleteWeakGlobalRef(env, classObject);
classObject = NULL;
Expand Down
32 changes: 16 additions & 16 deletions native/dispatch.c
Expand Up @@ -2,7 +2,7 @@
* @(#)dispatch.c 1.9 98/03/22
*
* Copyright (c) 1998 Sun Microsystems, Inc. All Rights Reserved.
* Copyright (c) 2007-2012 Timothy Wall. All Rights Reserved.
* Copyright (c) 2007-2013 Timothy Wall. All Rights Reserved.
* Copyright (c) 2007 Wayne Meissner. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
Expand All @@ -28,19 +28,19 @@
#include <psapi.h>
#define STRTYPE wchar_t*
#define NAME2CSTR(ENV,JSTR) newWideCString(ENV,JSTR)
#ifdef _WIN32_WCE
#include <tlhelp32.h>
#define DEFAULT_LOAD_OPTS 0 /* altered search path unsupported on CE */
#undef GetProcAddress
#define GetProcAddress GetProcAddressA
#else
/* See http://msdn.microsoft.com/en-us/library/ms682586(VS.85).aspx:
* "Note that the standard search strategy and the alternate search strategy
* specified by LoadLibraryEx with LOAD_WITH_ALTERED_SEARCH_PATH differ in
* just one way: The standard search begins in the calling application's
* directory, and the alternate search begins in the directory of the
* executable module that LoadLibraryEx is loading."
*/
#ifdef _WIN32_WCE
#include <tlhelp32.h>
#define DEFAULT_LOAD_OPTS 0 /* altered search path unsupported on CE */
#undef GetProcAddress
#define GetProcAddress GetProcAddressA
#else
#define DEFAULT_LOAD_OPTS LOAD_WITH_ALTERED_SEARCH_PATH
#endif
#define LOAD_LIBRARY(NAME,OPTS) (NAME ? LoadLibraryExW(NAME, NULL, OPTS) : GetModuleHandleW(NULL))
Expand Down Expand Up @@ -571,7 +571,7 @@ dispatch(JNIEnv *env, void* func, jint flags, jobjectArray arr,
}
}
else if (preserve_last_error) {
jnidispatch_set_last_error(GET_LAST_ERROR());
JNA_set_last_error(GET_LAST_ERROR());
}
PROTECTED_END(do { throw_type=EError;throw_msg="Invalid memory access";} while(0));
}
Expand Down Expand Up @@ -1226,7 +1226,7 @@ get_system_property(JNIEnv* env, const char* name, jboolean wide) {
}

static const char*
jnidispatch_init(JNIEnv* env) {
JNA_init(JNIEnv* env) {
if (!LOAD_CREF(env, Object, "java/lang/Object")) return "java.lang.Object";
if (!LOAD_CREF(env, Class, "java/lang/Class")) return "java.lang.Class";
if (!LOAD_CREF(env, Method, "java/lang/reflect/Method")) return "java.lang.reflect.Method";
Expand Down Expand Up @@ -1718,7 +1718,7 @@ method_handler(ffi_cif* cif, void* volatile resp, void** argp, void *cdata) {
}
}
else if (preserve_last_error) {
jnidispatch_set_last_error(GET_LAST_ERROR());
JNA_set_last_error(GET_LAST_ERROR());
}
PROTECTED_END(do { throw_type=EError;throw_msg="Invalid memory access"; } while(0));
}
Expand Down Expand Up @@ -2939,13 +2939,13 @@ Java_com_sun_jna_Native_getPreserveLastError(JNIEnv *UNUSED(env), jclass UNUSED(

JNIEXPORT void JNICALL
Java_com_sun_jna_Native_setLastError(JNIEnv *env, jclass UNUSED(classp), jint code) {
jnidispatch_set_last_error(code);
JNA_set_last_error(code);
SET_LAST_ERROR(code);
}

JNIEXPORT jint JNICALL
Java_com_sun_jna_Native_getLastError(JNIEnv *env, jclass UNUSED(classp)) {
return jnidispatch_get_last_error();
return JNA_get_last_error();
}

JNIEXPORT jstring JNICALL
Expand Down Expand Up @@ -2978,11 +2978,11 @@ JNI_OnLoad(JavaVM *jvm, void *UNUSED(reserved)) {
}
}

if ((err = jnidispatch_init(env)) != NULL) {
if ((err = JNA_init(env)) != NULL) {
fprintf(stderr, "JNA: Problems loading core IDs: %s\n", err);
result = 0;
}
else if ((err = jnidispatch_callback_init(env)) != NULL) {
else if ((err = JNA_callback_init(env)) != NULL) {
fprintf(stderr, "JNA: Problems loading callback IDs: %s\n", err);
result = 0;
}
Expand Down Expand Up @@ -3034,7 +3034,7 @@ JNI_OnUnload(JavaVM *vm, void *UNUSED(reserved)) {
}
}

jnidispatch_callback_dispose(env);
JNA_callback_dispose(env);

#ifdef JAWT_HEADLESS_HACK
if (jawt_handle != NULL) {
Expand Down Expand Up @@ -3249,7 +3249,7 @@ Java_com_sun_jna_Native_initialize_1ffi_1type(JNIEnv *env, jclass UNUSED(cls), j

JNIEXPORT void JNICALL
Java_com_sun_jna_Native_detach(JNIEnv* env, jclass UNUSED(cls), jboolean d) {
jnidispatch_detach(d);
JNA_detach(d);
}

#ifdef __cplusplus
Expand Down
10 changes: 5 additions & 5 deletions native/dispatch.h
Expand Up @@ -174,11 +174,11 @@ extern void throwByName(JNIEnv *env, const char *name, const char *msg);
extern int get_jtype(JNIEnv*, jclass);
extern ffi_type* get_ffi_type(JNIEnv*, jclass, char);
extern ffi_type* get_ffi_rtype(JNIEnv*, jclass, char);
extern const char* jnidispatch_callback_init(JNIEnv*);
extern void jnidispatch_set_last_error(int);
extern int jnidispatch_get_last_error();
extern void jnidispatch_callback_dispose(JNIEnv*);
extern void jnidispatch_detach(jboolean);
extern const char* JNA_callback_init(JNIEnv*);
extern void JNA_set_last_error(int);
extern int JNA_get_last_error();
extern void JNA_callback_dispose(JNIEnv*);
extern void JNA_detach(jboolean);
extern callback* create_callback(JNIEnv*, jobject, jobject,
jobjectArray, jclass,
callconv_t, jint);
Expand Down
2 changes: 1 addition & 1 deletion test/com/sun/jna/PlatformTest.java
@@ -1,4 +1,4 @@
/* Copyright (c) 20013 Timothy Wall, All Rights Reserved
/* Copyright (c) 2013 Timothy Wall, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down

0 comments on commit 8d37675

Please sign in to comment.