ctypes-commit Mailing List for ctypes (Page 109)
Brought to you by:
theller
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(8) |
May
(90) |
Jun
(143) |
Jul
(106) |
Aug
(94) |
Sep
(84) |
Oct
(163) |
Nov
(60) |
Dec
(58) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(128) |
Feb
(79) |
Mar
(227) |
Apr
(192) |
May
(179) |
Jun
(41) |
Jul
(53) |
Aug
(103) |
Sep
(28) |
Oct
(38) |
Nov
(81) |
Dec
(17) |
2006 |
Jan
(184) |
Feb
(111) |
Mar
(188) |
Apr
(67) |
May
(58) |
Jun
(123) |
Jul
(73) |
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
From: Thomas H. <th...@us...> - 2004-05-18 13:52:19
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv962 Modified Files: callbacks.c Log Message: Start using libffi for callbacks. Index: callbacks.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callbacks.c,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** callbacks.c 14 May 2004 20:13:32 -0000 1.45 --- callbacks.c 18 May 2004 13:52:09 -0000 1.46 *************** *** 8,11 **** --- 8,12 ---- #endif + #define USE_LIBFFI /* For 2.3, use the PyGILState_ calls, see PEP 311 */ *************** *** 54,58 **** ! #ifdef MS_WIN32 staticforward THUNK AllocCallback(PyObject *callable, int nArgBytes, --- 55,59 ---- ! #ifndef USE_LIBFFI staticforward THUNK AllocCallback(PyObject *callable, int nArgBytes, *************** *** 127,131 **** --- 128,136 ---- if (dict && dict->getfunc) { + #ifdef USE_LIBFFI + PyObject *v = dict->getfunc(*pArgs, dict->size); + #else PyObject *v = dict->getfunc(pArgs, dict->size); + #endif if (!v) { PrintError("create argument %d:\n", i); *************** *** 138,146 **** BTW, the same problem occurrs when they are pushed as parameters */ pArgs += (dict->size + sizeof(int) - 1) / sizeof(int); ! continue; ! } ! ! if (dict) { /* Hm, shouldn't we use CData_AtAddress() or something like that instead? */ CDataObject *obj = (CDataObject *)PyObject_CallFunctionObjArgs(cnv, NULL); --- 143,150 ---- BTW, the same problem occurrs when they are pushed as parameters */ + #ifndef USE_LIBFFI pArgs += (dict->size + sizeof(int) - 1) / sizeof(int); ! #endif ! } else if (dict) { /* Hm, shouldn't we use CData_AtAddress() or something like that instead? */ CDataObject *obj = (CDataObject *)PyObject_CallFunctionObjArgs(cnv, NULL); *************** *** 154,160 **** goto Done; } memcpy(obj->b_ptr, pArgs, dict->size); - /* XXX See above */ pArgs += (dict->size + sizeof(int) - 1) / sizeof(int); PyTuple_SET_ITEM(arglist, i, (PyObject *)obj); } else { --- 158,167 ---- goto Done; } + #ifdef USE_LIBFFI + memcpy(obj->b_ptr, *pArgs, dict->size); + #else memcpy(obj->b_ptr, pArgs, dict->size); pArgs += (dict->size + sizeof(int) - 1) / sizeof(int); + #endif PyTuple_SET_ITEM(arglist, i, (PyObject *)obj); } else { *************** *** 165,168 **** --- 172,178 ---- } /* XXX error handling! */ + #ifdef USE_LIBFFI + pArgs++; + #endif } result = PyObject_CallObject(callable, arglist); *************** *** 187,191 **** } ! #ifdef MS_WIN32 static int __stdcall z_CallPythonObject(PyObject *callable, PyObject *converters, --- 197,201 ---- } ! #ifndef USE_LIBFFI static int __stdcall z_CallPythonObject(PyObject *callable, PyObject *converters, *************** *** 466,470 **** is_cdecl); } ! #else /* ! MS_WIN32 */ typedef struct { --- 476,480 ---- is_cdecl); } ! #else /* USE_LIBFFI */ typedef struct { *************** *** 483,496 **** { ffi_info *p = userdata; - int nArgs = PySequence_Length(p->converters); - void **pArgs = alloca(sizeof(void *) * nArgs); - int i; - - /* args is an array containing pointers to pointers to arguments, but - CallPythonObject expects an array containing pointers to arguments. - */ - for (i = 0; i < nArgs; ++i) { - pArgs[i] = *(void ***)args[i]; - } _CallPythonObject(resp, --- 493,496 ---- *************** *** 498,502 **** p->callable, p->converters, ! pArgs); } --- 498,502 ---- p->callable, p->converters, ! args); } *************** *** 600,604 **** void init_callbacks_in_module(PyObject *m) { ! #ifdef MS_WIN32 CALLBACKINFO (__stdcall *pFunc)(DWORD); pFunc = (CALLBACKINFO (__stdcall *)(DWORD)) CallbackTemplate; --- 600,604 ---- void init_callbacks_in_module(PyObject *m) { ! #ifndef USE_LIBFFI CALLBACKINFO (__stdcall *pFunc)(DWORD); pFunc = (CALLBACKINFO (__stdcall *)(DWORD)) CallbackTemplate; |
From: Thomas H. <th...@us...> - 2004-05-18 12:41:28
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17076 Modified Files: callproc.c Log Message: Remove unused and unneeded code. Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.74 retrieving revision 1.75 diff -C2 -d -r1.74 -r1.75 *** callproc.c 18 May 2004 12:17:20 -0000 1.74 --- callproc.c 18 May 2004 12:41:07 -0000 1.75 *************** *** 677,681 **** return 0; } ! #else #pragma optimize ("", off) /* --- 677,681 ---- return 0; } ! #else /* USE_LIBFFI */ #pragma optimize ("", off) /* *************** *** 903,907 **** #pragma optimize ("", on) ! #endif #define RESULT_PASTE_INTO 1 --- 903,907 ---- #pragma optimize ("", on) ! #endif /* USE_LIBFFI */ #define RESULT_PASTE_INTO 1 *************** *** 1223,1226 **** --- 1223,1228 ---- } + /* obsolete, should be removed */ + /* Only used by sample code (in samples\Windows\COM.py) */ static PyObject * call_commethod(PyObject *self, PyObject *args) *************** *** 1329,1386 **** #endif - /* - * Only for debugging so far: So that we can call CFunction instances - * - * XXX Needs to accept more arguments: flags, argtypes, restype - */ - static PyObject * - call_function(PyObject *self, PyObject *args) - { - PPROC func; - PyObject *arguments; - PyObject *result; - - if (!PyArg_ParseTuple(args, - "iO!", - &func, - &PyTuple_Type, &arguments)) - return NULL; - - result = _CallProc(func, - arguments, - NULL, - 0, /* flags */ - NULL, /* self->argtypes */ - NULL); /* self->restype */ - return result; - } - - /* - * Only for debugging so far: So that we can call CFunction instances - * - * XXX Needs to accept more arguments: flags, argtypes, restype - */ - static PyObject * - call_cdeclfunction(PyObject *self, PyObject *args) - { - PPROC func; - PyObject *arguments; - PyObject *result; - - if (!PyArg_ParseTuple(args, - "iO!", - &func, - &PyTuple_Type, &arguments)) - return NULL; - - result = _CallProc(func, - arguments, - NULL, - FUNCFLAG_CDECL, /* flags */ - NULL, /* self->argtypes */ - NULL); /* self->restype */ - return result; - } - PyMethodDef module_methods[] = { #ifdef MS_WIN32 --- 1331,1334 ---- *************** *** 1399,1404 **** {"byref", byref, METH_O}, {"addressof", addressof, METH_O}, - {"call_function", call_function, METH_VARARGS }, - {"call_cdeclfunction", call_cdeclfunction, METH_VARARGS }, {NULL, NULL} /* Sentinel */ }; --- 1347,1350 ---- |
From: Thomas H. <th...@us...> - 2004-05-18 12:25:48
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13779 Modified Files: setup.py Log Message: Structure passing by value bow also works on linux. Index: setup.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/setup.py,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** setup.py 18 May 2004 09:01:22 -0000 1.44 --- setup.py 18 May 2004 12:25:38 -0000 1.45 *************** *** 71,74 **** --- 71,75 ---- extensions = [Extension("_ctypes", + define_macros=[("CAN_PASS_BY_VALUE", "1")], libraries=["ffi"], include_dirs=include_dirs, |
From: Thomas H. <th...@us...> - 2004-05-18 12:24:18
|
Update of /cvsroot/ctypes/ctypes/samples/Windows In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13468 Modified Files: COM.py Log Message: Make the sample work again. Index: COM.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/samples/Windows/COM.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** COM.py 12 Mar 2003 20:48:13 -0000 1.4 --- COM.py 18 May 2004 12:24:09 -0000 1.5 *************** *** 563,573 **** def CreateTypeLib(syskind, name): ctl = ICreateTypeLibPointer() - - oleaut32.CreateTypeLib.argtypes = [c_int, c_wchar_p, POINTER(ICreateTypeLibPointer)] - # Using the prototype above will allow us to use a normal string - # as second parameter: It will be passed as unicode. oleaut32.CreateTypeLib(syskind, ! ## unicode(name), ! name, byref(ctl)) return ctl --- 563,568 ---- def CreateTypeLib(syskind, name): ctl = ICreateTypeLibPointer() oleaut32.CreateTypeLib(syskind, ! unicode(name), byref(ctl)) return ctl |
From: Thomas H. <th...@us...> - 2004-05-18 12:23:51
|
Update of /cvsroot/ctypes/ctypes/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13337 Modified Files: rt.bat Log Message: I now use pydebug.iss to install the Python debug binaries. Index: rt.bat =================================================================== RCS file: /cvsroot/ctypes/ctypes/samples/rt.bat,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** rt.bat 3 Nov 2003 20:53:07 -0000 1.9 --- rt.bat 18 May 2004 12:23:42 -0000 1.10 *************** *** 2,6 **** @setlocal @set _exe=c:\python23\python.exe ! @if "%1"=="-d" set _exe=c:\sf\python\dist\src-maint23\PCBuild\python_d.exe %_exe% Windows\FindFile.py --- 2,6 ---- @setlocal @set _exe=c:\python23\python.exe ! @if "%1"=="-d" set _exe=c:\python23\python_d.exe %_exe% Windows\FindFile.py |
From: Thomas H. <th...@us...> - 2004-05-18 12:17:30
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11797 Modified Files: _ctypes.c callproc.c Log Message: Fix some compiler warnings. Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** callproc.c 18 May 2004 12:06:30 -0000 1.73 --- callproc.c 18 May 2004 12:17:20 -0000 1.74 *************** *** 674,679 **** return -1; } - return 0; #endif } #else --- 674,679 ---- return -1; } #endif + return 0; } #else Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.141 retrieving revision 1.142 diff -C2 -d -r1.141 -r1.142 *** _ctypes.c 18 May 2004 12:06:30 -0000 1.141 --- _ctypes.c 18 May 2004 12:17:20 -0000 1.142 *************** *** 605,609 **** int size; if (PyBuffer_Check(value)) { ! size = value->ob_type->tp_as_buffer->bf_getreadbuffer(value, 0, &ptr); if (size < 0) return -1; --- 605,609 ---- int size; if (PyBuffer_Check(value)) { ! size = value->ob_type->tp_as_buffer->bf_getreadbuffer(value, 0, (void *)&ptr); if (size < 0) return -1; *************** *** 2572,2576 **** parg->tag = 'V'; ! stgdict = PyObject_stgdict(self); parg->pffi_type = &stgdict->ffi_type; /* For structure parameters (by value), parg->value doesn't contain the structure --- 2572,2576 ---- parg->tag = 'V'; ! stgdict = PyObject_stgdict((PyObject *)self); parg->pffi_type = &stgdict->ffi_type; /* For structure parameters (by value), parg->value doesn't contain the structure |
From: Thomas H. <th...@us...> - 2004-05-18 12:06:41
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9420 Modified Files: stgdict.c callproc.c _ctypes.c Log Message: Can now pass structures by value. Index: stgdict.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/stgdict.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** stgdict.c 7 May 2004 19:56:24 -0000 1.10 --- stgdict.c 18 May 2004 12:06:30 -0000 1.11 *************** *** 208,211 **** --- 208,215 ---- size = ((size + total_align - 1) / total_align) * total_align; + stgdict->ffi_type.type = FFI_TYPE_STRUCT; + stgdict->ffi_type.alignment = total_align; + stgdict->ffi_type.size = size; + stgdict->size = size; stgdict->align = total_align; Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** callproc.c 18 May 2004 09:00:16 -0000 1.72 --- callproc.c 18 May 2004 12:06:30 -0000 1.73 *************** *** 441,445 **** { PyCArgObject *parm; - if (PyCArg_CheckExact(obj)) { Py_INCREF(obj); --- 441,444 ---- *************** *** 600,604 **** } atypes[i] = tp; ! values[i] = &parms[i]->value; } if (res->pffi_type == NULL) { --- 599,611 ---- } atypes[i] = tp; ! /* For structure parameters (by value), parg->value doesn't ! contain the structure data itself, instead parg->value.p ! *points* to the structure's data. See also _ctypes.c, function ! Struct_as_parameter(). ! */ ! if (tp->type == FFI_TYPE_STRUCT) ! values[i] = parms[i]->value.p; ! else ! values[i] = &parms[i]->value; } if (res->pffi_type == NULL) { Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.140 retrieving revision 1.141 diff -C2 -d -r1.140 -r1.141 *** _ctypes.c 14 May 2004 18:50:03 -0000 1.140 --- _ctypes.c 18 May 2004 12:06:30 -0000 1.141 *************** *** 2565,2568 **** --- 2565,2569 ---- { PyCArgObject *parg; + StgDictObject *stgdict; parg = new_CArgObject(); *************** *** 2571,2575 **** parg->tag = 'V'; ! //XXX parg->pffi_type = ?? parg->value.p = self->b_ptr; parg->size = self->b_size; --- 2572,2581 ---- parg->tag = 'V'; ! stgdict = PyObject_stgdict(self); ! parg->pffi_type = &stgdict->ffi_type; ! /* For structure parameters (by value), parg->value doesn't contain the structure ! data itself, instead parg->value.p *points* to the structure's data ! See also _ctypes.c, function _call_function_pointer(). ! */ parg->value.p = self->b_ptr; parg->size = self->b_size; |
From: Thomas H. <th...@us...> - 2004-05-18 12:04:06
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8905 Modified Files: test_win32.py Log Message: A system independend test passing a structure by value. Index: test_win32.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_win32.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_win32.py 18 May 2004 09:29:31 -0000 1.5 --- test_win32.py 18 May 2004 12:03:56 -0000 1.6 *************** *** 39,49 **** self.assertRaises(WindowsError, windll.kernel32.GetModuleHandleA, 32) ! # TODO: Add tests for passing structures (and unions?) by value. def test_struct_by_value(self): ! from ctypes.wintypes import POINT, RECT pt = POINT(10, 10) rect = RECT(0, 0, 20, 20) ! self.failUnlessEqual(True, windll.user32.PtInRect(byref(rect), pt)) if __name__ == '__main__': --- 39,61 ---- self.assertRaises(WindowsError, windll.kernel32.GetModuleHandleA, 32) ! class Structures(unittest.TestCase): ! def test_struct_by_value(self): ! class POINT(Structure): ! _fields_ = [("x", c_long), ! ("y", c_long)] ! ! class RECT(Structure): ! _fields_ = [("left", c_long), ! ("top", c_long), ! ("right", c_long), ! ("bottom", c_long)] ! ! import _ctypes_test ! dll = CDLL(_ctypes_test.__file__) pt = POINT(10, 10) rect = RECT(0, 0, 20, 20) ! self.failUnlessEqual(True, dll.PointInRect(byref(rect), pt)) if __name__ == '__main__': |
From: Thomas H. <th...@us...> - 2004-05-18 12:03:02
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8712 Modified Files: _ctypes_test.c Log Message: A PointInRect test function. Index: _ctypes_test.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes_test.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** _ctypes_test.c 18 May 2004 08:58:43 -0000 1.16 --- _ctypes_test.c 18 May 2004 12:02:53 -0000 1.17 *************** *** 413,416 **** --- 413,445 ---- /********/ + + #ifndef MS_WIN32 + + typedef struct { + long x; + long y; + } POINT; + + typedef struct { + long left; + long top; + long right; + long bottom; + } RECT; + + #endif + + EXPORT(int) PointInRect(RECT *prc, POINT pt) + { + if (pt.x < prc->left) + return 0; + if (pt.x > prc->right) + return 0; + if (pt.y < prc->top) + return 0; + if (pt.y > prc->bottom) + return 0; + return 1; + } DL_EXPORT(void) |
From: Thomas H. <th...@us...> - 2004-05-18 09:29:41
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12861 Modified Files: test_win32.py Log Message: It is safer to call IsWindow instead of GetModuleHandle with wrong arguments. Index: test_win32.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_win32.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_win32.py 18 May 2004 08:28:14 -0000 1.4 --- test_win32.py 18 May 2004 09:29:31 -0000 1.5 *************** *** 8,31 **** class WindowsTestCase(unittest.TestCase): def test_callconv_1(self): ! "Call functions with the wrong number of arguments, or the wrong calling convention" ! GetModuleHandle = windll.kernel32.GetModuleHandleA # ValueError: Procedure probably called with not enough arguments (4 bytes missing) ! self.assertRaises(ValueError, GetModuleHandle) # This one should succeeed... ! self.failUnless(GetModuleHandle(None)) # ValueError: Procedure probably called with too many arguments (8 bytes in excess) ! self.assertRaises(ValueError, GetModuleHandle, 0, 0, 0) def test_callconv_2(self): ! "Call functions with the wrong number of arguments, or the wrong calling convention" ! GetModuleHandleA = cdll.kernel32.GetModuleHandleA # ValueError: Procedure called with not enough arguments (4 bytes missing) # or wrong calling convention ! self.assertRaises(ValueError, GetModuleHandleA, None) ! self.assertRaises(ValueError, GetModuleHandleA) def test_SEH(self): --- 8,31 ---- class WindowsTestCase(unittest.TestCase): def test_callconv_1(self): ! # Testing stdcall function + IsWindow = windll.user32.IsWindow # ValueError: Procedure probably called with not enough arguments (4 bytes missing) ! self.assertRaises(ValueError, IsWindow) # This one should succeeed... ! self.failUnlessEqual(0, IsWindow(0)) # ValueError: Procedure probably called with too many arguments (8 bytes in excess) ! self.assertRaises(ValueError, IsWindow, 0, 0, 0) def test_callconv_2(self): ! # Calling stdcall function as cdecl ! ! IsWindow = cdll.user32.IsWindow # ValueError: Procedure called with not enough arguments (4 bytes missing) # or wrong calling convention ! self.assertRaises(ValueError, IsWindow, None) def test_SEH(self): |
From: Thomas H. <th...@us...> - 2004-05-18 09:28:51
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12668 Modified Files: test_returnfuncptrs.py Log Message: Fix a typo. Index: test_returnfuncptrs.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_returnfuncptrs.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_returnfuncptrs.py 4 May 2004 09:15:19 -0000 1.4 --- test_returnfuncptrs.py 18 May 2004 09:28:37 -0000 1.5 *************** *** 17,21 **** self.assertRaises(TypeError, strchr, "abcdef") ! def test__without_prototype(self): dll = CDLL(_ctypes_test.__file__) get_strchr = dll.get_strchr --- 17,21 ---- self.assertRaises(TypeError, strchr, "abcdef") ! def test_without_prototype(self): dll = CDLL(_ctypes_test.__file__) get_strchr = dll.get_strchr |
From: Thomas H. <th...@us...> - 2004-05-18 09:01:32
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7860 Modified Files: setup.py Log Message: Use libffi on windows, for calling functions. Index: setup.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/setup.py,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** setup.py 7 May 2004 20:04:00 -0000 1.43 --- setup.py 18 May 2004 09:01:22 -0000 1.44 *************** *** 36,42 **** kw["sources"].extend([ ## "source/libffi_msvc/types.c", ! ## "source/libffi_msvc/ffi.c", ! ## "source/libffi_msvc/prep_cif.c", ! ## "source/libffi_msvc/win32.c", ]) extensions = [Extension("_ctypes", --- 36,42 ---- kw["sources"].extend([ ## "source/libffi_msvc/types.c", ! "source/libffi_msvc/ffi.c", ! "source/libffi_msvc/prep_cif.c", ! "source/libffi_msvc/win32.c", ]) extensions = [Extension("_ctypes", |
From: Thomas H. <th...@us...> - 2004-05-18 09:00:41
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7673 Modified Files: callproc.c Log Message: Use libffi on windows, for calling functions. Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** callproc.c 14 May 2004 19:26:37 -0000 1.71 --- callproc.c 18 May 2004 09:00:16 -0000 1.72 *************** *** 74,77 **** --- 74,83 ---- #endif + #define USE_LIBFFI + + #ifdef MS_WIN32 + #define alloca _alloca + #endif + #include <ffi.h> #include "ctypes.h" *************** *** 246,249 **** --- 252,263 ---- } + static DWORD HandleException(EXCEPTION_POINTERS *ptrs, + DWORD *pdw, EXCEPTION_RECORD *record) + { + *pdw = ptrs->ExceptionRecord->ExceptionCode; + *record = *ptrs->ExceptionRecord; + return EXCEPTION_EXECUTE_HANDLER; + } + static PyObject * check_hresult(PyObject *self, PyObject *args) *************** *** 545,549 **** ! #ifndef MS_WIN32 /* --- 559,563 ---- ! #ifdef USE_LIBFFI /* *************** *** 569,573 **** void **values; int i; ! atypes = (ffi_type **)alloca(argcount * sizeof(ffi_type *)); values = (void **)alloca(argcount * sizeof(void *)); --- 583,592 ---- 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 *)); values = (void **)alloca(argcount * sizeof(void *)); *************** *** 588,593 **** return -1; } ! ! if (FFI_OK != ffi_prep_cif(&cif, FFI_DEFAULT_ABI, argcount, res->pffi_type, --- 607,619 ---- return -1; } ! ! 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, res->pffi_type, *************** *** 599,606 **** Py_BEGIN_ALLOW_THREADS ! ffi_call(&cif, (void *)pProc, &res->value, values); Py_END_ALLOW_THREADS ! return 0; } #else --- 625,672 ---- Py_BEGIN_ALLOW_THREADS ! #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 Py_END_ALLOW_THREADS ! #ifdef MS_WIN32 ! if (dwExceptionCode) { ! SetException(dwExceptionCode, &record); ! return -1; ! } ! if (delta < 0) { ! if (flags & FUNCFLAG_CDECL) ! PyErr_Format(PyExc_ValueError, ! "Procedure called with not enough " ! "arguments (%d bytes missing) " ! "or wrong calling convention", ! -delta); ! else ! PyErr_Format(PyExc_ValueError, ! "Procedure probably called with not enough " ! "arguments (%d bytes missing)", ! -delta); ! return -1; ! } else if (delta > 0) { ! PyErr_Format(PyExc_ValueError, ! "Procedure probably called with too many " ! "arguments (%d bytes in excess)", ! delta); ! return -1; ! } return 0; + #endif } #else *************** *** 613,624 **** } - static DWORD HandleException(EXCEPTION_POINTERS *ptrs, - DWORD *pdw, EXCEPTION_RECORD *record) - { - *pdw = ptrs->ExceptionRecord->ExceptionCode; - *record = *ptrs->ExceptionRecord; - return EXCEPTION_EXECUTE_HANDLER; - } - static int _call_function_pointer(int flags, PPROC pProc, --- 679,682 ---- |
From: Thomas H. <th...@us...> - 2004-05-18 08:58:56
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7298 Modified Files: _ctypes_test.c Log Message: Remove debug code. Index: _ctypes_test.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes_test.c,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** _ctypes_test.c 17 May 2004 20:31:04 -0000 1.15 --- _ctypes_test.c 18 May 2004 08:58:43 -0000 1.16 *************** *** 322,328 **** EXPORT(short) tf_h(short c) { - #ifdef _DEBUG - _asm int 3; - #endif return c; } --- 322,325 ---- |
From: Thomas H. <th...@us...> - 2004-05-18 08:28:39
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1598 Modified Files: test_win32.py Log Message: Run the SEH test only with the release build of the _ctypes extension module. Index: test_win32.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_win32.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_win32.py 4 May 2004 09:16:23 -0000 1.3 --- test_win32.py 18 May 2004 08:28:14 -0000 1.4 *************** *** 32,36 **** """Call functions with invalid arguments, and make sure that access violations are trapped and raise an exception""" ! self.assertRaises(WindowsError, windll.kernel32.GetModuleHandleA, 32) # TODO: Add tests for passing structures (and unions?) by value. --- 32,41 ---- """Call functions with invalid arguments, and make sure that access violations are trapped and raise an exception""" ! # Normally, in a debug build of the _ctypes extension ! # module, exceptions are not trapped, so we can only run ! # this test in a release build. ! import sys ! if not hasattr(sys, "getobjects"): ! self.assertRaises(WindowsError, windll.kernel32.GetModuleHandleA, 32) # TODO: Add tests for passing structures (and unions?) by value. |
From: Thomas H. <th...@us...> - 2004-05-17 20:57:57
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31170 Modified Files: test_callbacks.py Log Message: Revert last checkin. Index: test_callbacks.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_callbacks.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** test_callbacks.py 17 May 2004 20:54:56 -0000 1.13 --- test_callbacks.py 17 May 2004 20:57:48 -0000 1.14 *************** *** 4,8 **** class CallbacksBase(unittest.TestCase): def callback(self, *args): - print "GOT", args self.got_args = args return args[-1] --- 4,7 ---- |
From: Thomas H. <th...@us...> - 2004-05-17 20:56:52
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30851/unittests Modified Files: test_cfuncs.py Log Message: Even more tests. Index: test_cfuncs.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_cfuncs.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_cfuncs.py 17 May 2004 20:31:30 -0000 1.1 --- test_cfuncs.py 17 May 2004 20:56:43 -0000 1.2 *************** *** 42,45 **** --- 42,77 ---- self.failUnlessEqual(dll.tf_bL(0, 42), 42) + def test_longlong(self): + dll.tf_q.restype = c_longlong + dll.tf_q.argtypes = (c_longlong, ) + self.failUnlessEqual(dll.tf_q(-42L), -42L) + dll.tf_bq.restype = c_longlong + dll.tf_bq.argtypes = (c_byte, c_longlong) + self.failUnlessEqual(dll.tf_bq(0, -42), -42) + + def test_ulonglong(self): + dll.tf_Q.restype = c_ulonglong + dll.tf_Q.argtypes = (c_longlong, ) + self.failUnlessEqual(dll.tf_Q(42), 42) + dll.tf_bQ.restype = c_ulonglong + dll.tf_bQ.argtypes = (c_byte, c_ulonglong) + self.failUnlessEqual(dll.tf_bQ(0, 42), 42) + + def test_float(self): + dll.tf_f.restype = c_float + dll.tf_f.argtypes = (c_float,) + self.failUnlessEqual(dll.tf_f(-42.), -42.) + dll.tf_bf.restype = c_float + dll.tf_bf.argtypes = (c_byte, c_float) + self.failUnlessEqual(dll.tf_bf(0, -42.), -42.) + + def test_double(self): + dll.tf_d.restype = c_double + dll.tf_d.argtypes = (c_double,) + self.failUnlessEqual(dll.tf_d(42), 42) + dll.tf_bd.restype = c_double + dll.tf_bd.argtypes = (c_byte, c_double) + self.failUnlessEqual(dll.tf_bd(0, 42), 42) + if __name__ == '__main__': unittest.main() |
From: Thomas H. <th...@us...> - 2004-05-17 20:55:05
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30524/unittests Modified Files: test_callbacks.py Log Message: Even more tests. Index: test_callbacks.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_callbacks.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** test_callbacks.py 17 May 2004 12:36:34 -0000 1.12 --- test_callbacks.py 17 May 2004 20:54:56 -0000 1.13 *************** *** 4,7 **** --- 4,8 ---- class CallbacksBase(unittest.TestCase): def callback(self, *args): + print "GOT", args self.got_args = args return args[-1] |
From: Thomas H. <th...@us...> - 2004-05-17 20:31:39
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24999 Added Files: test_cfuncs.py Log Message: More tests. --- NEW FILE: test_cfuncs.py --- import unittest from ctypes import * import _ctypes_test dll = CDLL(_ctypes_test.__file__) class CFunctions(unittest.TestCase): def test_short(self): dll.tf_h.restype = c_short self.failUnlessEqual(dll.tf_h(-42), -42) dll.tf_bh.restype = c_short self.failUnlessEqual(dll.tf_bh(0, -42), -42) def test_ushort(self): dll.tf_H.restype = c_ushort self.failUnlessEqual(dll.tf_H(42), 42) dll.tf_bH.restype = c_ushort self.failUnlessEqual(dll.tf_bH(0, 42), 42) def test_int(self): dll.tf_i.restype = c_int self.failUnlessEqual(dll.tf_i(-42), -42) dll.tf_bi.restype = c_int self.failUnlessEqual(dll.tf_bi(0, -42), -42) def test_uint(self): dll.tf_I.restype = c_uint self.failUnlessEqual(dll.tf_I(42), 42) dll.tf_bI.restype = c_uint self.failUnlessEqual(dll.tf_bI(0, 42), 42) def test_long(self): dll.tf_l.restype = c_long self.failUnlessEqual(dll.tf_l(-42), -42) dll.tf_bl.restype = c_long self.failUnlessEqual(dll.tf_bl(0, -42), -42) def test_ulong(self): dll.tf_L.restype = c_ulong self.failUnlessEqual(dll.tf_L(42), 42) dll.tf_bL.restype = c_ulong self.failUnlessEqual(dll.tf_bL(0, 42), 42) if __name__ == '__main__': unittest.main() |
From: Thomas H. <th...@us...> - 2004-05-17 20:31:15
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24892 Modified Files: _ctypes_test.c Log Message: More tests. Index: _ctypes_test.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes_test.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** _ctypes_test.c 7 May 2004 19:56:24 -0000 1.14 --- _ctypes_test.c 17 May 2004 20:31:04 -0000 1.15 *************** *** 312,315 **** --- 312,420 ---- }; + EXPORT(char) tf_b(char c) + { + return c; + } + EXPORT(unsigned char) tf_B(unsigned char c) + { + return c; + } + EXPORT(short) tf_h(short c) + { + #ifdef _DEBUG + _asm int 3; + #endif + return c; + } + EXPORT(unsigned short) tf_H(unsigned short c) + { + return c; + } + EXPORT(int) tf_i(int c) + { + return c; + } + EXPORT(unsigned int) tf_I(unsigned int c) + { + return c; + } + EXPORT(long) tf_l(long c) + { + return c; + } + EXPORT(unsigned long) tf_L(unsigned long c) + { + return c; + } + EXPORT(PY_LONG_LONG) tf_q(PY_LONG_LONG c) + { + return c; + } + EXPORT(unsigned PY_LONG_LONG) tf_Q(unsigned PY_LONG_LONG c) + { + return c; + } + EXPORT(float) tf_f(float c) + { + return c; + } + EXPORT(double) tf_d(double c) + { + return c; + } + + /*******/ + + EXPORT(char) tf_bb(char x, char c) + { + return c; + } + EXPORT(unsigned char) tf_bB(char x, unsigned char c) + { + return c; + } + EXPORT(short) tf_bh(char x, short c) + { + return c; + } + EXPORT(unsigned short) tf_bH(char x, unsigned short c) + { + return c; + } + EXPORT(int) tf_bi(char x, int c) + { + return c; + } + EXPORT(unsigned int) tf_bI(char x, unsigned int c) + { + return c; + } + EXPORT(long) tf_bl(char x, long c) + { + return c; + } + EXPORT(unsigned long) tf_bL(char x, unsigned long c) + { + return c; + } + EXPORT(PY_LONG_LONG) tf_bq(char x, PY_LONG_LONG c) + { + return c; + } + EXPORT(unsigned PY_LONG_LONG) tf_bQ(char x, unsigned PY_LONG_LONG c) + { + return c; + } + EXPORT(float) tf_bf(char x, float c) + { + return c; + } + EXPORT(double) tf_bd(char x, double c) + { + return c; + } + + /********/ + DL_EXPORT(void) init_ctypes_test(void) |
From: Thomas H. <th...@us...> - 2004-05-17 12:36:43
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11132 Modified Files: test_callbacks.py Log Message: More tests. Index: test_callbacks.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_callbacks.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** test_callbacks.py 7 May 2004 17:02:09 -0000 1.11 --- test_callbacks.py 17 May 2004 12:36:34 -0000 1.12 *************** *** 4,7 **** --- 4,8 ---- class CallbacksBase(unittest.TestCase): def callback(self, *args): + self.got_args = args return args[-1] *************** *** 18,60 **** --- 19,85 ---- class IntegerCallbacks(CallbacksBase): + def test_cint(self): + PROTO = CFUNCTYPE(c_longlong, c_longlong, c_longlong, c_longlong) + PROTO(self.callback)(0x10, 0x20, 0x30) + def test_byte(self): self.failUnlessEqual(self.check_type(c_byte, 42), 42) + self.failUnlessEqual(self.got_args, (42,)) self.failUnlessEqual(self.check_type_1(c_byte, 42), 42) + self.failUnlessEqual(self.got_args, (0, 42)) def test_ubyte(self): self.failUnlessEqual(self.check_type(c_ubyte, 42), 42) + self.failUnlessEqual(self.got_args, (42,)) self.failUnlessEqual(self.check_type_1(c_ubyte, 42), 42) + self.failUnlessEqual(self.got_args, (0, 42)) def test_short(self): self.failUnlessEqual(self.check_type(c_short, 42), 42) + self.failUnlessEqual(self.got_args, (42,)) self.failUnlessEqual(self.check_type_1(c_short, 42), 42) + self.failUnlessEqual(self.got_args, (0, 42)) def test_ushort(self): self.failUnlessEqual(self.check_type(c_ushort, 42), 42) + self.failUnlessEqual(self.got_args, (42,)) self.failUnlessEqual(self.check_type_1(c_ushort, 42), 42) + self.failUnlessEqual(self.got_args, (0, 42)) def test_int(self): self.failUnlessEqual(self.check_type(c_int, 42), 42) + self.failUnlessEqual(self.got_args, (42,)) self.failUnlessEqual(self.check_type_1(c_int, 42), 42) + self.failUnlessEqual(self.got_args, (0, 42)) def test_uint(self): self.failUnlessEqual(self.check_type(c_uint, 42), 42) + self.failUnlessEqual(self.got_args, (42,)) self.failUnlessEqual(self.check_type_1(c_uint, 42), 42) + self.failUnlessEqual(self.got_args, (0, 42)) def test_long(self): self.failUnlessEqual(self.check_type(c_long, 42), 42) + self.failUnlessEqual(self.got_args, (42,)) self.failUnlessEqual(self.check_type_1(c_long, 42), 42) + self.failUnlessEqual(self.got_args, (0, 42)) def test_ulong(self): self.failUnlessEqual(self.check_type(c_ulong, 42), 42) + self.failUnlessEqual(self.got_args, (42,)) self.failUnlessEqual(self.check_type_1(c_ulong, 42), 42) + self.failUnlessEqual(self.got_args, (0, 42)) def test_longlong(self): self.failUnlessEqual(self.check_type(c_longlong, 42), 42) + self.failUnlessEqual(self.got_args, (42,)) self.failUnlessEqual(self.check_type_1(c_longlong, 42), 42) + self.failUnlessEqual(self.got_args, (0, 42)) def test_ulonglong(self): self.failUnlessEqual(self.check_type(c_ulonglong, 42), 42) + self.failUnlessEqual(self.got_args, (42,)) self.failUnlessEqual(self.check_type_1(c_ulonglong, 42), 42) + self.failUnlessEqual(self.got_args, (0, 42)) def test_float(self): *************** *** 63,81 **** --- 88,114 ---- self.failUnlessAlmostEqual(self.check_type(c_float, math.e), math.e, places=6) + self.failUnlessAlmostEqual(self.got_args[0], math.e, places=6) self.failUnlessAlmostEqual(self.check_type_1(c_float, math.e), math.e, places=6) + self.failUnlessAlmostEqual(self.got_args[1], math.e, places=6) def test_double(self): self.failUnlessEqual(self.check_type(c_double, 3.14), 3.14) + self.failUnlessEqual(self.got_args, (3.14,)) self.failUnlessEqual(self.check_type_1(c_double, 3.14), 3.14) + self.failUnlessEqual(self.got_args, (0, 3.14)) class CharCallbacks(CallbacksBase): def test_char(self): self.failUnlessEqual(self.check_type(c_char, "x"), "x") + self.failUnlessEqual(self.got_args, ("x",)) self.failUnlessEqual(self.check_type_1(c_char, "x"), "x") + self.failUnlessEqual(self.got_args, (0, "x")) def test_char_p(self): self.failUnlessEqual(self.check_type(c_char_p, "abc"), "abc") + self.failUnlessEqual(self.got_args, ("abc",)) self.failUnlessEqual(self.check_type_1(c_char_p, "abc"), "abc") + self.failUnlessEqual(self.got_args, (0, "abc")) class SampleCallbacksTestCase(unittest.TestCase): |
From: Thomas H. <th...@us...> - 2004-05-14 20:19:17
|
Update of /cvsroot/ctypes/ctypes/build/lib.win32-2.4 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26406 Modified Files: _ctypes.pyd Log Message: Recompiled the binaries. Index: _ctypes.pyd =================================================================== RCS file: /cvsroot/ctypes/ctypes/build/lib.win32-2.4/_ctypes.pyd,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 Binary files /tmp/cvsqcmKxz and /tmp/cvsjCNpZa differ |
From: Thomas H. <th...@us...> - 2004-05-14 20:19:07
|
Update of /cvsroot/ctypes/ctypes/build/lib.win32-2.3 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26315 Modified Files: _ctypes.pyd Log Message: Recompiled the binaries. Index: _ctypes.pyd =================================================================== RCS file: /cvsroot/ctypes/ctypes/build/lib.win32-2.3/_ctypes.pyd,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 Binary files /tmp/cvs2uufmR and /tmp/cvskItgwl differ |
From: Thomas H. <th...@us...> - 2004-05-14 20:13:41
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25001 Modified Files: callbacks.c Log Message: Add some missing error checks. Index: callbacks.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callbacks.c,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** callbacks.c 14 May 2004 19:26:37 -0000 1.44 --- callbacks.c 14 May 2004 20:13:32 -0000 1.45 *************** *** 514,519 **** nArgs = PySequence_Size(converters); p = (ffi_info *)PyMem_Malloc(sizeof(ffi_info) + sizeof(ffi_type) * nArgs); - /* Check for NULL */ for (i = 0; i < nArgs; ++i) { PyObject *cnv = PySequence_GetItem(converters, i); --- 514,522 ---- nArgs = PySequence_Size(converters); p = (ffi_info *)PyMem_Malloc(sizeof(ffi_info) + sizeof(ffi_type) * nArgs); + if (p == NULL) { + PyErr_NoMemory(); + return NULL; + } for (i = 0; i < nArgs; ++i) { PyObject *cnv = PySequence_GetItem(converters, i); *************** *** 524,534 **** PrepareResult(restype, &cResult); ! /* XXX Check for FFI_OK */ result = ffi_prep_cif(&p->cif, FFI_DEFAULT_ABI, nArgs, cResult.pffi_type, &p->atypes[0]); - /* XXX Check for FFI_OK */ result = ffi_prep_closure(&p->cl, &p->cif, closure_fcn, p); switch (cResult.tag) { --- 527,548 ---- PrepareResult(restype, &cResult); ! result = ffi_prep_cif(&p->cif, FFI_DEFAULT_ABI, nArgs, cResult.pffi_type, &p->atypes[0]); + if (result != FFI_OK) { + PyErr_Format(PyExc_RuntimeError, + "ffi_prep_cif failed with %d", result); + PyMem_Free(p); + return NULL; + } result = ffi_prep_closure(&p->cl, &p->cif, closure_fcn, p); + if (result != FFI_OK) { + PyErr_Format(PyExc_RuntimeError, + "ffi_prep_closure failed with %d", result); + PyMem_Free(p); + return NULL; + } switch (cResult.tag) { |
From: Thomas H. <th...@us...> - 2004-05-14 19:26:49
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13773 Modified Files: callbacks.c callproc.c Log Message: Get rid of tag2ffitype(). Index: callbacks.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callbacks.c,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** callbacks.c 14 May 2004 16:48:54 -0000 1.43 --- callbacks.c 14 May 2004 19:26:37 -0000 1.44 *************** *** 501,506 **** } - extern ffi_type *tag2ffitype(char tag); - THUNK AllocFunctionCallback(PyObject *callable, int nArgBytes, --- 501,504 ---- *************** *** 521,525 **** PyObject *cnv = PySequence_GetItem(converters, i); PrepareResult(restype, &cResult); ! p->atypes[i] = tag2ffitype(cResult.tag); Py_DECREF(cnv); } --- 519,523 ---- PyObject *cnv = PySequence_GetItem(converters, i); PrepareResult(restype, &cResult); ! p->atypes[i] = cResult.pffi_type; Py_DECREF(cnv); } *************** *** 528,532 **** /* XXX Check for FFI_OK */ result = ffi_prep_cif(&p->cif, FFI_DEFAULT_ABI, nArgs, ! tag2ffitype(cResult.tag), &p->atypes[0]); --- 526,530 ---- /* XXX Check for FFI_OK */ result = ffi_prep_cif(&p->cif, FFI_DEFAULT_ABI, nArgs, ! cResult.pffi_type, &p->atypes[0]); Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** callproc.c 14 May 2004 19:01:14 -0000 1.70 --- callproc.c 14 May 2004 19:26:37 -0000 1.71 *************** *** 547,596 **** #ifndef MS_WIN32 - ffi_type *tag2ffitype(char tag) - { - switch (tag) { - case 'c': - return &ffi_type_schar; - case 'b': - return &ffi_type_sint8; - case 'B': - return &ffi_type_uint8; - case 'h': - return &ffi_type_sint16; - case 'H': - return &ffi_type_uint16; - case 'i': - return &ffi_type_sint32; - case 'I': - return &ffi_type_uint32; - case 'l': - return &ffi_type_sint32; - case 'L': - return &ffi_type_uint32; - case 'q': - return &ffi_type_sint64; - case 'Q': - return &ffi_type_uint64; - case 'z': - case 'Z': - case 'P': - return &ffi_type_pointer; - case 'd': - return &ffi_type_double; - case 'f': - return &ffi_type_float; - case 'v': - return &ffi_type_void; - /* Ahh. - case 'V': - return &ffi_type_structure; - */ - default: - PyErr_Format(PyExc_TypeError, - "cannot pass type tag %c", tag); - return NULL; - } - } - /* * libffi uses: --- 547,550 ---- *************** *** 612,616 **** { ffi_cif cif; - ffi_type *rtype; ffi_type **atypes; void **values; --- 566,569 ---- *************** *** 623,643 **** ffi_type *tp = parms[i]->pffi_type; if (tp == NULL) { ! fprintf(stderr, "BUG (arg): NO TYPE FOR '%c'\n", parms[i]->tag); ! tp = tag2ffitype(parms[i]->tag); ! } ! if (tp == NULL) return -1; atypes[i] = tp; values[i] = &parms[i]->value; } ! rtype = res->pffi_type; ! if (rtype == NULL) { ! fprintf(stderr, "BUG (result): NO TYPE FOR '%c'\n", res->tag); ! rtype = tag2ffitype(res->tag); } if (FFI_OK != ffi_prep_cif(&cif, FFI_DEFAULT_ABI, argcount, ! rtype, atypes)) { PyErr_SetString(PyExc_RuntimeError, --- 576,595 ---- ffi_type *tp = parms[i]->pffi_type; if (tp == NULL) { ! PyErr_SetString(PyExc_RuntimeError, ! "No ffi_type for an argument"); return -1; + } atypes[i] = tp; values[i] = &parms[i]->value; } ! if (res->pffi_type == NULL) { ! PyErr_SetString(PyExc_RuntimeError, ! "No ffi_type for result"); ! return -1; } if (FFI_OK != ffi_prep_cif(&cif, FFI_DEFAULT_ABI, argcount, ! res->pffi_type, atypes)) { PyErr_SetString(PyExc_RuntimeError, |