[ctypes-commit] ctypes-java/src/jni ctypesj.ncb,1.2,1.3 ctypesj.plg,1.2,1.3 ctypesj.opt,1.2,1.3 supp
Brought to you by:
theller
From: Bradley L S. <bs...@us...> - 2004-08-29 01:30:22
|
Update of /cvsroot/ctypes/ctypes-java/src/jni In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19625/src/jni Modified Files: support.c ctypes_java_CCallbackFunction.h ctypesj.dsp module.c CCallbackFunction.c support.h CFunction.c Added Files: ctypesj.ncb ctypesj.plg ctypesj.opt Log Message: --- NEW FILE: ctypesj.ncb --- (This appears to be a binary file; contents omitted.) Index: support.c =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/jni/support.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** support.c 21 Mar 2004 23:43:35 -0000 1.3 --- support.c 29 Aug 2004 01:30:03 -0000 1.4 *************** *** 193,197 **** } ! void SetException(JNIEnv * env, DWORD code) { char *lpMsgBuf; --- 193,205 ---- } ! DWORD HandleException(EXCEPTION_POINTERS *ptrs, ! DWORD *pdw, EXCEPTION_RECORD *record) ! { ! *pdw = ptrs->ExceptionRecord->ExceptionCode; ! *record = *ptrs->ExceptionRecord; ! return EXCEPTION_EXECUTE_HANDLER; ! } ! ! void SetException(JNIEnv * env, DWORD code, EXCEPTION_RECORD *pr) { char *lpMsgBuf; --- NEW FILE: ctypesj.opt --- (This appears to be a binary file; contents omitted.) Index: CFunction.c =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/jni/CFunction.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CFunction.c 23 Mar 2004 06:37:34 -0000 1.6 --- CFunction.c 29 Aug 2004 01:30:03 -0000 1.7 *************** *** 42,46 **** #else #include <dlfcn.h> - #include <ffi.h> #include <malloc.h> #include <alloca.h> --- 42,45 ---- *************** *** 48,51 **** --- 47,51 ---- #endif + #include <ffi.h> #include <jni.h> #include "ctypes_java_CFunction.h" *************** *** 124,127 **** --- 124,129 ---- } + + static jobject GetResult(JNIEnv * env, jclass restype, JavaCArgObject *result) { *************** *** 147,150 **** --- 149,159 ---- } break; + case 'h': + if ((*env)->IsAssignableFrom(env, restype, Class_CShort)) { + mid = (*env)->GetMethodID(env, restype, "<init>", "(S)V"); + ret = (*env)->NewObject(env, restype, mid, result->value.h); + return ret; + } + break; case 'i': case 'I': *************** *** 244,248 **** if ((*env)->IsInstanceOf(env, obj, Class_CCallbackFunction)) { ! jfieldID fid = (*env)->GetFieldID(env, Class_CCallbackFunction, "address", "J"); jbyte * buf = (jbyte*) (*env)->GetLongField(env, obj, fid); parm->tag = 'p'; --- 253,257 ---- if ((*env)->IsInstanceOf(env, obj, Class_CCallbackFunction)) { ! jfieldID fid = (*env)->GetFieldID(env, Class_CCallbackFunction, "thunk", "J"); jbyte * buf = (jbyte*) (*env)->GetLongField(env, obj, fid); parm->tag = 'p'; *************** *** 515,541 **** - #ifndef MS_WIN32 - /* - There's a problem with current CVS versions of libffi (2003-01-21). - It redefines ffi_type_slong and ffi_type_ulong to - ffi_type_sint64 and ffi_type_uint64. - - Fortunately, ctypes' unittests catch this. - - printf("SIZEOF_LONG %d\n", SIZEOF_LONG); - printf("ffi_type_slong %p\n", &ffi_type_slong); - printf("ffi_type_sint64 %p\n", &ffi_type_sint64); - printf("ffi_type_sint %p\n", &ffi_type_sint); - printf("ffi_type_sint32 %p\n", &ffi_type_sint32); - */ - #if (SIZEOF_LONG_LONG == 8 && SIZEOF_LONG == 4) - #undef ffi_type_ulong - #define ffi_type_ulong ffi_type_uint32 - #define ffi_type_ulonglong ffi_type_uint64 - #undef ffi_type_slong - #define ffi_type_slong ffi_type_sint32 - #define ffi_type_slonglong ffi_type_sint64 - #endif ffi_type *tag2ffitype(char tag) --- 524,528 ---- *************** *** 560,567 **** --- 547,557 ---- case 'L': return &ffi_type_ulong; + #ifndef MS_WIN32 case 'q': return &ffi_type_slonglong; + case 'Q': return &ffi_type_ulonglong; + #endif case 'z': case 'Z': *************** *** 600,603 **** --- 590,594 ---- int argcount) { + char buffer[200]; ffi_cif cif; ffi_type *rtype; *************** *** 605,608 **** --- 596,605 ---- void **values; int i; + int cc; + #ifdef MS_WIN32 + int delta; + DWORD dwExceptionCode; + EXCEPTION_RECORD record; + #endif atypes = (ffi_type **)alloca(argcount * sizeof(ffi_type *)); *************** *** 614,619 **** } rtype = tag2ffitype(res->tag); ! ! if (FFI_OK != ffi_prep_cif(&cif, FFI_DEFAULT_ABI, argcount, rtype, --- 611,622 ---- } rtype = tag2ffitype(res->tag); ! ! cc = FFI_DEFAULT_ABI; ! #ifdef MS_WIN32 ! if ((flags & FUNCFLAG_CDECL) == 0) ! cc = FFI_STDCALL; ! dwExceptionCode = 0; ! #endif ! if (FFI_OK != ffi_prep_cif(&cif, cc, argcount, rtype, *************** *** 623,836 **** } ! ffi_call(&cif, (void *)pProc, &res->value, values); ! return 0; ! } ! ! #else ! ! #pragma optimize ("", off) ! /* ! * Can you figure out what this does? ;-) ! */ ! static void __stdcall push(void) ! { ! } ! ! static int _call_function_pointer(JNIEnv * env, int flags, ! PPROC pProc, ! JavaCArgObject **parms, ! JavaCArgObject *res, ! int argcount) ! { ! char buffer[200]; ! int i; ! DWORD dwExceptionCode; ! int new_esp, save_esp; ! int argbytes = 0; ! ! /* ! The idea was to do this in C, without assembler. But how can we ! guard against passing the wrong number of arguments? How do we ! save and restore the stack pointer? ! ! Apparently MSVC does not use ESP addressing but EBP addressing, ! so we can use local variables (on the stack) for saving and ! restoring the value of ESP! ! */ ! ! _asm mov save_esp, esp; ! new_esp = save_esp; ! ! #pragma warning (disable: 4087) ! /* Both __stdcall and __cdecl calling conventions pass the arguments ! 'right to left'. The difference is in the stack cleaning: __stdcall ! __stdcall functions pop their arguments off the stack themselves, ! __cdecl functions leave this to the caller. ! */ ! for (i = argcount-1; i >= 0; --i) { ! float f; ! ! switch(parms[i]->tag) { ! case 'c': ! push(parms[i]->value.c); ! argbytes += sizeof(int); ! break; ! ! /* This works, although it doesn't look correct! */ ! case 'b': ! case 'h': ! case 'i': ! case 'B': ! case 'H': ! case 'I': ! case 'u': ! push(parms[i]->value.i); ! argbytes += sizeof(int); ! break; ! case 'l': ! case 'L': ! push(parms[i]->value.l); ! argbytes += sizeof(long); ! break; ! #ifdef HAVE_LONG_LONG ! case 'q': ! case 'Q': ! push(parms[i]->value.q); ! argbytes += sizeof(PY_LONG_LONG); ! break; ! #endif ! case 'f': ! case 'F': ! /* Cannot use push(parms[i]->value.f) here, because ! the C compiler would promote it to a double ! */ ! f = parms[i]->value.f; ! _asm push f; ! argbytes += sizeof(float); ! break; ! case 'd': ! push(parms[i]->value.d); ! argbytes += sizeof(double); ! break; ! case 'z': ! case 'Z': ! case 'p': ! case 'P': ! case 'X': /* BSTR */ ! push(parms[i]->value.p); ! argbytes += sizeof(void *); ! break; ! default: ! /* ! PyErr_Format(PyExc_ValueError, ! "BUG: Invalid format tag '%c' for argument", ! parms[i]->tag); ! /* try to clean the stack */ ! _asm mov esp, save_esp; ! return -1; ! } ! } ! ! #pragma warning (default: 4087) ! ! dwExceptionCode = 0; #ifndef DEBUG_EXCEPTIONS __try { #endif ! switch(res->tag) { ! case 'c': ! res->value.c = ((char(*)())pProc)(); ! break; ! case 'B': ! case 'b': ! res->value.b = ((char(*)())pProc)(); ! break; ! case 'H': ! case 'h': ! res->value.h = ((short(*)())pProc)(); ! break; ! case 'I': ! case 'i': ! res->value.i = ((int(*)())pProc)(); ! break; ! case 'l': ! case 'L': ! res->value.l = ((long(*)())pProc)(); ! break; ! case 'd': ! res->value.d = ((double(*)())pProc)(); ! break; ! case 'f': ! case 'F': ! res->value.f = ((float(*)())pProc)(); ! break; ! #ifdef HAVE_LONG_LONG ! case 'q': ! case 'Q': ! res->value.q = ((PY_LONG_LONG(*)())pProc)(); ! break; ! #endif ! case 'z': ! case 'Z': ! case 'p': ! case 'P': ! res->value.p = ((void *(*)())pProc)(); ! break; ! case 'v': ! (pProc)(); ! break; ! default: ! /* XXX Signal bug */ ! res->tag |= 0x80; ! break; ! } } ! __except (dwExceptionCode = GetExceptionCode(), EXCEPTION_EXECUTE_HANDLER) { ; } ! ! _asm sub new_esp, esp; ! _asm mov esp, save_esp; ! ! if (dwExceptionCode) { ! SetException(env, dwExceptionCode); ! return -1; ! } ! ! if (res->tag & 0x80) { ! sprintf(buffer, "BUG: Invalid format tag for restype '%c'", res->tag & ~0x80); ! JNU_ThrowByName(env, "ctypes/java/CException", buffer); return -1; } ! ! ! if (flags & FUNCFLAG_CDECL) /* Clean up stack if needed */ ! new_esp -= argbytes; ! if (new_esp < 0) { if (flags & FUNCFLAG_CDECL) { ! sprintf(buffer, "Procedure called with not enough" "arguments (%d bytes missing) " ! "or wrong calling convention", -new_esp); JNU_ThrowByName(env, "ctypes/java/CException", buffer); } else { sprintf(buffer, "Procedure probably called with not enough " ! "arguments (%d bytes missing)", -new_esp); JNU_ThrowByName(env, "ctypes/java/CException", buffer); } return -1; ! ! } ! if (new_esp > 0) { sprintf(buffer, "Procedure probably called with too many " ! "arguments (%d bytes in excess)", new_esp); JNU_ThrowByName(env, "ctypes/java/CException", buffer); - return -1; - } - return 0; - } - #pragma optimize ("", on) #endif --- 626,670 ---- } ! #ifdef MS_WIN32 #ifndef DEBUG_EXCEPTIONS __try { #endif ! delta = ! #endif ! ffi_call(&cif, (void *)pProc, &res->value, values); ! #ifdef MS_WIN32 ! #ifndef DEBUG_EXCEPTIONS } ! __except (HandleException(GetExceptionInformation(), ! &dwExceptionCode, &record)) { ; } ! #endif ! #endif ! #ifdef MS_WIN32 if (dwExceptionCode) { ! SetException(env, dwExceptionCode, &record); return -1; } ! if (delta < 0) { if (flags & FUNCFLAG_CDECL) { ! sprintf(buffer, "Procedure called with not enough" "arguments (%d bytes missing) " ! "or wrong calling convention", -delta); JNU_ThrowByName(env, "ctypes/java/CException", buffer); } else { sprintf(buffer, "Procedure probably called with not enough " ! "arguments (%d bytes missing)", -delta); JNU_ThrowByName(env, "ctypes/java/CException", buffer); } return -1; ! } else if (delta > 0) { sprintf(buffer, "Procedure probably called with too many " ! "arguments (%d bytes in excess)", delta); JNU_ThrowByName(env, "ctypes/java/CException", buffer); return -1; } #endif + return 0; + } Index: CCallbackFunction.c =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/jni/CCallbackFunction.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CCallbackFunction.c 19 Apr 2004 13:39:04 -0000 1.5 --- CCallbackFunction.c 29 Aug 2004 01:30:03 -0000 1.6 *************** *** 27,31 **** #include <memory.h> #else - #include <ffi.h> #include <alloca.h> #include <string.h> --- 27,30 ---- *************** *** 35,39 **** #endif ! #include <jni.h> #include <malloc.h> --- 34,38 ---- #endif ! #include <ffi.h> #include <jni.h> #include <malloc.h> *************** *** 47,58 **** */ - #ifdef MS_WIN32 - typedef struct { - BYTE *pStart; - BYTE *pEnd; - } CALLBACKINFO; - static CALLBACKINFO ti; - #endif THUNK AllocFunctionCallback(jobject callable, --- 46,50 ---- *************** *** 63,78 **** - #ifdef MS_WIN32 - THUNK AllocCallback(jobject callable, - int nArgBytes, - jobject converters, - DWORD RouterAddress, - int is_cdecl); - - #endif - - - - static void __stdcall CallJavaObject(void *mem, char *format, --- 55,58 ---- *************** *** 81,85 **** void **pArgs); ! JNIEXPORT jlong JNICALL Java_ctypes_java_CCallbackFunction_init (JNIEnv * env, jobject obj, jclass restype, jobjectArray converters, jint numbytes, jint calltype) { --- 61,92 ---- void **pArgs); ! ! typedef struct { ! ffi_closure cl; /* the C callable */ ! ffi_cif cif; ! jobjectArray converters; ! jobject callable; ! char *format; ! ffi_type *atypes[0]; ! } ffi_info; ! ! ! JNIEXPORT void JNICALL Java_ctypes_java_CCallbackFunction_pokeThunk(JNIEnv * env, jobject obj, jlong val) { ! long peer = (long) (*env)->GetLongField(env, obj, FID_CType_address); ! jlong * i = (jint*) peer; ! *i = val; ! } ! ! /* ! * Class: NativeInt ! * Method: getInt ! * Signature: ()I ! */ ! JNIEXPORT jlong JNICALL Java_ctypes_java_CCallbackFunction_peekThunk(JNIEnv * env, jobject obj) { ! long peer = (long) (*env)->GetLongField(env, obj, FID_CType_address); ! jlong * i = (jint*) peer; ! return *i; ! } ! JNIEXPORT jlong JNICALL Java_ctypes_java_CCallbackFunction_init (JNIEnv * env, jobject obj, jclass restype, jobjectArray converters, jint numbytes, jint calltype) { *************** *** 99,102 **** --- 106,123 ---- } + JNIEXPORT void JNICALL Java_ctypes_java_CCallbackFunction_fini + (JNIEnv * env, jobject obj, jlong address) { + jobject callable; + jobjectArray converters; + int tmp = (int) address; + ffi_info * thunk = (ffi_info *) tmp; + + callable = thunk->callable; + converters = thunk->converters, + + (*env)->DeleteGlobalRef(env, callable); + (*env)->DeleteGlobalRef(env, converters); + free(thunk); + } /* * based on the type of the object and the format, extract the value of the jobject into the result *************** *** 127,154 **** } - #ifdef MS_WIN32 - /* - finalize the trampoline. In this case this involves deleting the - global references stored in the trampoline. - */ - JNIEXPORT void JNICALL Java_ctypes_java_CCallbackFunction_fini - (JNIEnv * env, jobject obj, jlong address) { - BYTE *pCallback, *pConverters, *pCalladdr; - jobject callable; - jobjectArray arguments; - long trampoline; - trampoline = (long) address; - pCallback = (BYTE*) trampoline; - pConverters = pCallback + (ti.pEnd - ti.pStart) - 12; - pCalladdr = pCallback + (ti.pEnd - ti.pStart) - 8; - callable = (jobject) *(DWORD *)pConverters; - arguments = (jobject) *(DWORD *)pCalladdr; - - (*env)->DeleteGlobalRef(env, callable); - (*env)->DeleteGlobalRef(env, arguments); - free((void *)trampoline); - } - #endif /* --- 148,152 ---- *************** *** 201,206 **** #ifdef MS_WIN32 ! DWORD dwExceptionCode = 0; #endif JNIEnv* env = JNU_GetEnv(); --- 199,207 ---- #ifdef MS_WIN32 ! int delta; ! DWORD dwExceptionCode; ! EXCEPTION_RECORD record; #endif + JNIEnv* env = JNU_GetEnv(); *************** *** 274,279 **** } ! __except (dwExceptionCode = GetExceptionCode(), EXCEPTION_EXECUTE_HANDLER) { ! SetException(env, dwExceptionCode); return; } --- 275,281 ---- } ! __except (HandleException(GetExceptionInformation(), ! &dwExceptionCode, &record)) { ! SetException(env, dwExceptionCode, NULL); return; } *************** *** 287,559 **** - #ifdef MS_WIN32 - static int __stdcall i_CallJavaObject(jobject callable, - jobject converters, - void **pArgs) - { - JavaCArgObject result; - CallJavaObject(&result.value, "i", callable, converters, pArgs); - return result.value.i; - } - static double __stdcall d_CallJavaObject(jobject callable, - jobject converters, - void **pArgs) - { - JavaCArgObject result; - CallJavaObject(&result.value, "d", callable, converters, pArgs); - return result.value.d; - } - static float __stdcall f_CallJavaObject(jobject callable, - jobject converters, - void **pArgs) - { - JavaCArgObject result; - CallJavaObject(&result.value, "f", callable, converters, pArgs); - return result.value.f; - } - - #ifdef HAVE_LONG_LONG - static PY_LONG_LONG __stdcall q_CallJavaObject(jobject callable, - jobject converters, - void **pArgs) - { - JavaCArgObject result; - CallJavaObject(&result.value, "L", callable, converters, pArgs); - return result.value.q; - } - #endif - - #define NOSTACKFRAME - //#define BREAKPOINTS - - #pragma warning( disable : 4035 ) /* Disable warning about no return value */ - /* - * Callbacks are small blocks of code which create an interface between code - * using different calling conventions. - * In this case, an interface from __stdcall and __cdecl C-functions to python - * callable objects is provided. - * - * Callbacks are created by allocating some memory, copying the bytes from this - * template into it, and configuring the callback by setting the number of - * argument bytes and the address of the python object. - * For copying and configuring the callback we need the addresses of some - * assembler labels. These addresses are returned when the CallbackTemplate - * is called directly, without beeing configured. - */ - static int __declspec ( naked ) CallbackTemplate(DWORD arg) - { - /* This function will be called with the __stdcall calling convention: - * Arguments are pushed in right to left order onto the stack. - * Callee has to remove its own arguments from stack. - */ - _asm { - CallbackStart: - #ifdef BREAKPOINTS - int 3 - #endif - #ifndef NOSTACKFRAME - push ebp - mov ebp, esp - #endif - /* Trick for position independent code, transferring NumberArgs into ecx */ - call _1 - _1: - pop eax - add eax, OFFSET NumberArgs - sub eax, OFFSET _1 - mov ecx, [eax] - - /* Trick for position independent code, transferring CallAddress into edx */ - call _2 - _2: - pop eax - add eax, OFFSET CallAddress - sub eax, OFFSET _2 - mov edx, [eax] - - or edx, edx - jz ReturnInfo - - call _2a - _2a: - pop eax - add eax, OFFSET ConvertersAddress - sub eax, OFFSET _2a - mov ecx, [eax] - - #ifdef NOSTACKFRAME - mov eax, esp - add eax, 4 // return address is on stack - #else - mov eax, ebp - add eax, 8 // return address and ebp is on stack - #endif - /* push arguments in reverse order - * Register contents: - * EAX: Pointer to arguments - * ECX: Pointer to converters - * EDX: Pointer to python callable object - */ - push eax - push ecx - push edx - - /* Trick for position independent code, transferring CallAddress into eax */ - call _3 - _3: - pop eax - add eax, OFFSET RouterAddress - sub eax, OFFSET _3 - - call[eax] - - #ifndef NOSTACKFRAME - mov esp, ebp - pop ebp - #endif - #ifdef BREAKPOINTS - int 3 - #endif - /* For __stdcall functions: */ - _emit 0xC2 /* ret ... */ - /* __cdecl functions would require a simple 'ret' 0xC3 here... */ - /* - * Static storage for four DWORDS, containing the callbacks number of arguments - * and the address of the python object to call - * Note that NumberArgs must follow immediately the 'ret' instruction - * above! - */ - NumberArgs: - _emit 0 - _emit 0 - _emit 0 - _emit 0 - ConvertersAddress: - _emit 0 - _emit 0 - _emit 0 - _emit 0 - CallAddress: /* Python object to call */ - _emit 0 - _emit 0 - _emit 0 - _emit 0 - RouterAddress: /* C-function to route call */ - _emit 0 - _emit 0 - _emit 0 - _emit 0 - CallbackEnd: - - ReturnInfo: - mov eax, OFFSET CallbackStart - mov edx, OFFSET CallbackEnd - - #ifndef NOSTACKFRAME - mov esp, ebp - pop ebp - #endif - ret 4 - } - } - #pragma warning( default : 4035 ) /* Reenable warning about no return value */ - - /*****************************************************************************/ - - - - /* - * Allocate a callback and configure it - */ - static THUNK AllocCallback(jobject callable, int nArgBytes, - jobjectArray converters, DWORD RouterAddress, - int is_cdecl) - { - BYTE *pCallback, *pNargBytes, *pConverters, *pCalladdr, *pRouter; - - pCallback = malloc(ti.pEnd - ti.pStart); - memcpy(pCallback, ti.pStart, ti.pEnd - ti.pStart); - pNargBytes = pCallback +(ti.pEnd - ti.pStart) - 16; - pConverters = pCallback + (ti.pEnd - ti.pStart) - 12; - pCalladdr = pCallback + (ti.pEnd - ti.pStart) - 8; - pRouter = pCallback + (ti.pEnd - ti.pStart) - 4; - *(DWORD *)pNargBytes = nArgBytes; - if (is_cdecl) - ((BYTE *)pNargBytes)[-1] = 0xC3; /* ret: for cdecl */ - else - ((BYTE *)pNargBytes)[-1] = 0xC2; /* ret <args>: for stdcall */ - *(DWORD *)pConverters = (DWORD)converters; - *(DWORD *)pCalladdr = (DWORD)callable; - *(DWORD *)pRouter = RouterAddress; - return (THUNK)pCallback; - } - - - THUNK AllocFunctionCallback(jobject callable, - int nArgBytes, - jobjectArray converters, - jclass restype, - int is_cdecl) - { - JavaCArgObject result; - DWORD func; - jclass newExcCls; - char buf[200]; - JNIEnv* env = JNU_GetEnv(); - - PrepareResult(env, restype, &result); - switch (result.tag) { - /* "bBhHiIlLqQdfP" */ - case 'b': - case 'B': - case 'h': - case 'H': - case 'i': - case 'I': - case 'l': - case 'L': - case 'P': - /* Everything is an integer, only float, double, LONG_LONG is different */ - func = (DWORD)i_CallJavaObject; - break; - #ifdef HAVE_LONG_LONG - case 'q': - case 'Q': - func = (DWORD)q_CallJavaObject; - break; - #endif - case 'd': - func = (DWORD)d_CallJavaObject; - break; - case 'f': - case 'F': - func = (DWORD)f_CallJavaObject; - break; - default: - sprintf(buf, "invalid restype %c", result.tag); - newExcCls = (*env)->FindClass(env, "ctypes/java/CException"); - (*env)->ThrowNew(env, newExcCls, buf); - return NULL; - } - /* XXX restype -> CallJavaObject */ - return AllocCallback(callable, - nArgBytes, - converters, - func, - is_cdecl); - } - - #else /* ! MS_WIN32 */ - - typedef struct { - ffi_closure cl; /* the C callable */ - ffi_cif cif; - jobjectArray converters; - jobject callable; - char *format; - ffi_type *atypes[0]; - } ffi_info; static void closure_fcn(ffi_cif *cif, --- 289,294 ---- *************** *** 562,565 **** --- 297,302 ---- void *userdata) { + int i; + void **pArgs; ffi_info * p = userdata; JNIEnv* env = JNU_GetEnv(); *************** *** 569,579 **** } ! void **pArgs = alloca(sizeof(void *) * nArgs); ! int i; /* args is an array containing pointers to pointers to arguments, but CallJavaObject expects an array containing pointers to arguments. */ ! for (i = 0; i < nArgs; ++i) { pArgs[i] = *(void ***)args[i]; } --- 306,316 ---- } ! pArgs = alloca(sizeof(void *) * nArgs); ! /* args is an array containing pointers to pointers to arguments, but CallJavaObject expects an array containing pointers to arguments. */ ! for ( i = 0; i < nArgs; ++i) { pArgs[i] = *(void ***)args[i]; } *************** *** 648,652 **** break; case 'v': ! p->format = 'v'; break; default: --- 385,389 ---- break; case 'v': ! p->format = "v"; break; default: *************** *** 662,680 **** return (THUNK)p; } - #endif - void FreeCallback(THUNK thunk) - { - free(thunk); - } - void init_callbacks_in_module() - { - #ifdef MS_WIN32 - CALLBACKINFO (__stdcall *pFunc)(DWORD); - pFunc = (CALLBACKINFO (__stdcall *)(DWORD)) CallbackTemplate; - ti = pFunc(0); - #endif ! } --- 399,405 ---- return (THUNK)p; } ! Index: module.c =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/jni/module.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** module.c 21 Mar 2004 23:43:35 -0000 1.4 --- module.c 29 Aug 2004 01:30:03 -0000 1.5 *************** *** 208,213 **** return JNI_ERR; } - /* init the callbacks */ - init_callbacks_in_module(); return JNI_VERSION_1_2; --- 208,211 ---- Index: support.h =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/jni/support.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** support.h 21 Mar 2004 23:43:35 -0000 1.4 --- support.h 29 Aug 2004 01:30:03 -0000 1.5 *************** *** 22,26 **** #ifdef MS_WIN32 ! void SetException(JNIEnv * env, DWORD code); #endif --- 22,27 ---- #ifdef MS_WIN32 ! DWORD HandleException(EXCEPTION_POINTERS *ptrs, DWORD *pdw, EXCEPTION_RECORD *record); ! void SetException(JNIEnv * env, DWORD code, EXCEPTION_RECORD *pr); #endif Index: ctypes_java_CCallbackFunction.h =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/jni/ctypes_java_CCallbackFunction.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ctypes_java_CCallbackFunction.h 21 Mar 2004 23:43:35 -0000 1.3 --- ctypes_java_CCallbackFunction.h 29 Aug 2004 01:30:03 -0000 1.4 *************** *** 1,32 **** /* DO NOT EDIT THIS FILE - it is machine generated */ ! #include <jni.h> /* Header for class ctypes_java_CCallbackFunction */ #ifndef _Included_ctypes_java_CCallbackFunction ! #define _Included_ctypes_java_CCallbackFunction #ifdef __cplusplus extern "C" { ! #endif ! /* Inaccessible static: SYNCDIR_TOC */ ! /* Inaccessible static: SYNCDIR_TOJAVA */ ! /* Inaccessible static: class_00024ctypes_00024java_00024CInt */ ! /* ! * Class: ctypes_java_CCallbackFunction ! * Method: init ! * Signature: (Ljava/lang/Class;[Ljava/lang/Class;II)J ! */ ! JNIEXPORT jlong JNICALL Java_ctypes_java_CCallbackFunction_init (JNIEnv *, jobject, jclass, jobjectArray, jint, jint); ! ! /* ! * Class: ctypes_java_CCallbackFunction ! * Method: fini ! * Signature: (J)V ! */ ! JNIEXPORT void JNICALL Java_ctypes_java_CCallbackFunction_fini (JNIEnv *, jobject, jlong); ! #ifdef __cplusplus } ! #endif ! #endif --- 1,48 ---- /* DO NOT EDIT THIS FILE - it is machine generated */ ! #include <jni.h> /* Header for class ctypes_java_CCallbackFunction */ #ifndef _Included_ctypes_java_CCallbackFunction ! #define _Included_ctypes_java_CCallbackFunction #ifdef __cplusplus extern "C" { ! #endif ! /* Inaccessible static: SYNCDIR_TOC */ ! /* Inaccessible static: SYNCDIR_TOJAVA */ ! /* Inaccessible static: class_00024ctypes_00024java_00024CInt */ ! /* ! * Class: ctypes_java_CCallbackFunction ! * Method: init ! * Signature: (Ljava/lang/Class;[Ljava/lang/Class;II)J ! */ ! JNIEXPORT jlong JNICALL Java_ctypes_java_CCallbackFunction_init (JNIEnv *, jobject, jclass, jobjectArray, jint, jint); ! ! /* ! * Class: ctypes_java_CCallbackFunction ! * Method: fini ! * Signature: (J)V ! */ ! JNIEXPORT void JNICALL Java_ctypes_java_CCallbackFunction_fini (JNIEnv *, jobject, jlong); ! ! /* ! * Class: ctypes_java_CCallbackFunction ! * Method: pokeThunk ! * Signature: (J)V ! */ ! JNIEXPORT void JNICALL Java_ctypes_java_CCallbackFunction_pokeThunk ! (JNIEnv *, jobject, jlong); ! ! /* ! * Class: ctypes_java_CCallbackFunction ! * Method: peekThunk ! * Signature: ()J ! */ ! JNIEXPORT jlong JNICALL Java_ctypes_java_CCallbackFunction_peekThunk ! (JNIEnv *, jobject); ! #ifdef __cplusplus } ! #endif ! #endif Index: ctypesj.dsp =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/jni/ctypesj.dsp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ctypesj.dsp 11 Mar 2004 01:35:35 -0000 1.2 --- ctypesj.dsp 29 Aug 2004 01:30:03 -0000 1.3 *************** *** 44,48 **** # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CTYPESJ_EXPORTS" /YX /FD /c ! # ADD CPP /nologo /MT /W3 /GX /O2 /I "C:\j2sdk1.4.2_03\include" /I "C:\j2sdk1.4.2_03\include\win32" /D "MS_WIN32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CTYPESJ_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 --- 44,48 ---- # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CTYPESJ_EXPORTS" /YX /FD /c ! # ADD CPP /nologo /MT /W3 /GX /O2 /I "C:\j2sdk1.4.2_03\include" /I "C:\j2sdk1.4.2_03\include\win32" /I "E:\eclipse\workspace\ctypes-java\src\jni\libffi_msvc" /D "MS_WIN32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CTYPESJ_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 *************** *** 54,58 **** LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 ! # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 !ELSEIF "$(CFG)" == "ctypesj - Win32 Debug" --- 54,58 ---- LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 ! # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"Release/ctypes4j.dll" !ELSEIF "$(CFG)" == "ctypesj - Win32 Debug" *************** *** 70,74 **** # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CTYPESJ_EXPORTS" /YX /FD /GZ /c ! # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "C:\j2sdk1.4.2_03\include" /I "C:\j2sdk1.4.2_03\include\win32" /D "MS_WIN32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CTYPESJ_EXPORTS" /FD /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 --- 70,74 ---- # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CTYPESJ_EXPORTS" /YX /FD /GZ /c ! # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "C:\j2sdk1.4.2_03\include" /I "C:\j2sdk1.4.2_03\include\win32" /I "E:\eclipse\workspace\ctypes-java\src\jni\libffi_msvc" /D "MS_WIN32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CTYPESJ_EXPORTS" /FD /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 *************** *** 80,84 **** LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept ! # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept !ENDIF --- 80,84 ---- LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept ! # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"Debug/ctypes4j.dll" /pdbtype:sept !ENDIF *************** *** 129,133 **** # Begin Source File ! SOURCE=.\CMalloc.cpp # End Source File # Begin Source File --- 129,133 ---- # Begin Source File ! SOURCE=.\CMalloc.c # End Source File # Begin Source File *************** *** 149,158 **** --- 149,174 ---- # Begin Source File + SOURCE=.\libffi_msvc\ffi.c + # End Source File + # Begin Source File + SOURCE=.\module.c # End Source File # Begin Source File + SOURCE=.\libffi_msvc\prep_cif.c + # End Source File + # Begin Source File + SOURCE=.\support.c # End Source File + # Begin Source File + + SOURCE=.\libffi_msvc\types.c + # End Source File + # Begin Source File + + SOURCE=.\libffi_msvc\win32.c + # End Source File # End Group # Begin Group "Header Files" *************** *** 217,220 **** --- 233,256 ---- # Begin Source File + SOURCE=.\ctypes_java_WinDLL.h + # End Source File + # Begin Source File + + SOURCE=.\libffi_msvc\ffi.h + # End Source File + # Begin Source File + + SOURCE=.\libffi_msvc\ffi_common.h + # End Source File + # Begin Source File + + SOURCE=.\libffi_msvc\fficonfig.h + # End Source File + # Begin Source File + + SOURCE=.\libffi_msvc\ffitarget.h + # End Source File + # Begin Source File + SOURCE=.\javactypes.h # End Source File --- NEW FILE: ctypesj.plg --- <html> <body> <pre> <h1>Build Log</h1> <h3> --------------------Configuration: ctypesj - Win32 Debug-------------------- </h3> <h3>Command Lines</h3> Creating temporary file "C:\DOCUME~1\bradley\LOCALS~1\Temp\RSP1C7.tmp" with contents [ /nologo /MTd /W3 /Gm /GX /ZI /Od /I "C:\j2sdk1.4.2_03\include" /I "C:\j2sdk1.4.2_03\include\win32" /I "E:\eclipse\workspace\ctypes-java\src\jni\libffi_msvc" /D "MS_WIN32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CTYPESJ_EXPORTS" /Fo"Debug/" /Fd"Debug/" /FD /c "E:\eclipse\workspace\ctypes-java\src\jni\CFunction.c" ] Creating command line "cl.exe @C:\DOCUME~1\bradley\LOCALS~1\Temp\RSP1C7.tmp" Creating temporary file "C:\DOCUME~1\bradley\LOCALS~1\Temp\RSP1C8.tmp" with contents [ kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:yes /pdb:"Debug/ctypes4j.pdb" /debug /machine:I386 /out:"Debug/ctypes4j.dll" /implib:"Debug/ctypes4j.lib" /pdbtype:sept ".\Debug\CBuffer.obj" ".\Debug\CByte.obj" ".\Debug\CCallbackFunction.obj" ".\Debug\CDLL.obj" ".\Debug\CDouble.obj" ".\Debug\CFloat.obj" ".\Debug\CFunction.obj" ".\Debug\CInt.obj" ".\Debug\CLongLong.obj" ".\Debug\CMalloc.obj" ".\Debug\CPointer.obj" ".\Debug\CShort.obj" ".\Debug\CUlong.obj" ".\Debug\CWChar.obj" ".\Debug\ffi.obj" ".\Debug\module.obj" ".\Debug\prep_cif.obj" ".\Debug\support.obj" ".\Debug\types.obj" ".\Debug\win32.obj" ] Creating command line "link.exe @C:\DOCUME~1\bradley\LOCALS~1\Temp\RSP1C8.tmp" <h3>Output Window</h3> Compiling... CFunction.c e:\eclipse\workspace\ctypes-java\src\jni\cfunction.c(275) : warning C4244: '=' : conversion from '__int64 ' to 'long ', possible loss of data Linking... <h3>Results</h3> ctypes4j.dll - 0 error(s), 1 warning(s) </pre> </body> </html> |