ctypes-commit Mailing List for ctypes (Page 107)
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-06-11 09:43:21
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22966 Modified Files: test_stringptr.py Log Message: More portable way to find libc. Index: test_stringptr.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_stringptr.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_stringptr.py 4 May 2004 09:21:16 -0000 1.6 --- test_stringptr.py 11 Jun 2004 09:43:11 -0000 1.7 *************** *** 2,5 **** --- 2,19 ---- from ctypes import * + import os, sys + if os.name == "nt": + libc = cdll.msvcrt + + elif os.name == "posix": + if sys.platform == "darwin": + libc = cdll.LoadLibrary("/usr/lib/libc.dylib") + elif sys.platform == "cygwin": + libc = cdll.LoadLibrary("/bin/cygwin1.dll") + elif sys.platform == "sunos5": + libc = cdll.LoadLibrary("/lib/libc.so") + else: + libc = cdll.LoadLibrary("/lib/libc.so.6") + class StringPtrTestCase(unittest.TestCase): *************** *** 39,47 **** def test_functions(self): ! try: ! clib = cdll.msvcrt ! except OSError: ! clib = CDLL("/lib/libc.so.6") ! strchr = clib.strchr strchr.restype = c_char_p --- 53,57 ---- def test_functions(self): ! strchr = libc.strchr strchr.restype = c_char_p |
From: Thomas H. <th...@us...> - 2004-06-11 09:38:05
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17110 Modified Files: test_funcptr.py Log Message: libc for sunos. Index: test_funcptr.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_funcptr.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** test_funcptr.py 4 May 2004 09:15:19 -0000 1.13 --- test_funcptr.py 11 Jun 2004 09:37:56 -0000 1.14 *************** *** 17,20 **** --- 17,22 ---- elif sys.platform == "cygwin": libc = cdll.LoadLibrary("/bin/cygwin1.dll") + elif sys.platform == "sunos5": + libc = cdll.LoadLibrary("/lib/libc.so") else: libc = cdll.LoadLibrary("/lib/libc.so.6") |
From: Thomas H. <th...@us...> - 2004-06-11 09:09:08
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23163 Modified Files: test_cfuncs.py Log Message: More argtypes specs (for solaris). Index: test_cfuncs.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_cfuncs.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** test_cfuncs.py 11 Jun 2004 08:50:30 -0000 1.8 --- test_cfuncs.py 11 Jun 2004 09:08:55 -0000 1.9 *************** *** 10,21 **** --- 10,25 ---- def test_byte(self): self.dll.tf_b.restype = c_byte + self.dll.tf_b.argtypes = (c_byte,) self.failUnlessEqual(self.dll.tf_b(-42), -42) self.dll.tf_bb.restype = c_byte + self.dll.tf_bb.argtypes = (c_byte, c_byte) self.failUnlessEqual(self.dll.tf_bb(0, -42), -42) def test_ubyte(self): self.dll.tf_B.restype = c_ubyte + self.dll.tf_B.argtypes = (c_ubyte,) self.failUnlessEqual(self.dll.tf_B(42), 42) self.dll.tf_bB.restype = c_ubyte + self.dll.tf_bB.argtypes = (c_byte, c_ubyte) self.failUnlessEqual(self.dll.tf_bB(0, 42), 42) |
From: Thomas H. <th...@us...> - 2004-06-11 08:50:40
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9553 Modified Files: test_cfuncs.py Log Message: Fix typo. Index: test_cfuncs.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_cfuncs.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** test_cfuncs.py 11 Jun 2004 08:48:19 -0000 1.7 --- test_cfuncs.py 11 Jun 2004 08:50:30 -0000 1.8 *************** *** 49,53 **** self.failUnlessEqual(self.dll.tf_l(-42), -42) self.dll.tf_bl.restype = c_long ! self.dll.tf_l.argtypes = (c_byte, c_long) self.failUnlessEqual(self.dll.tf_bl(0, -42), -42) --- 49,53 ---- self.failUnlessEqual(self.dll.tf_l(-42), -42) self.dll.tf_bl.restype = c_long ! self.dll.tf_bl.argtypes = (c_byte, c_long) self.failUnlessEqual(self.dll.tf_bl(0, -42), -42) |
From: Thomas H. <th...@us...> - 2004-06-11 08:48:29
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7534 Modified Files: test_cfuncs.py Log Message: We need argtypes for c_long arguments (at least on 64-bit platforms, where sizeof(int) != sizeof(long)) Index: test_cfuncs.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_cfuncs.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_cfuncs.py 9 Jun 2004 14:59:40 -0000 1.6 --- test_cfuncs.py 11 Jun 2004 08:48:19 -0000 1.7 *************** *** 46,51 **** --- 46,53 ---- def test_long(self): self.dll.tf_l.restype = c_long + self.dll.tf_l.argtypes = (c_long,) self.failUnlessEqual(self.dll.tf_l(-42), -42) self.dll.tf_bl.restype = c_long + self.dll.tf_l.argtypes = (c_byte, c_long) self.failUnlessEqual(self.dll.tf_bl(0, -42), -42) |
From: Thomas H. <th...@us...> - 2004-06-09 20:06:31
|
Update of /cvsroot/ctypes/ctypes/build/lib.win32-2.4 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19924 Modified Files: _ctypes_test.pyd _ctypes.pyd Log Message: Recompiled the binaries after recent source changes. Index: _ctypes_test.pyd =================================================================== RCS file: /cvsroot/ctypes/ctypes/build/lib.win32-2.4/_ctypes_test.pyd,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 Binary files /tmp/cvs8MkNWt and /tmp/cvsXMnUSM differ Index: _ctypes.pyd =================================================================== RCS file: /cvsroot/ctypes/ctypes/build/lib.win32-2.4/_ctypes.pyd,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 Binary files /tmp/cvsiZEyFM and /tmp/cvsa6AeO5 differ |
From: Thomas H. <th...@us...> - 2004-06-09 20:06:24
|
Update of /cvsroot/ctypes/ctypes/build/lib.win32-2.3 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19766 Modified Files: _ctypes.pyd Log Message: Recompiled the binaries after recent source changes. Index: _ctypes.pyd =================================================================== RCS file: /cvsroot/ctypes/ctypes/build/lib.win32-2.3/_ctypes.pyd,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 Binary files /tmp/cvsaG8l2p and /tmp/cvsMmLv3B differ |
From: Thomas H. <th...@us...> - 2004-06-09 19:52:44
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7297 Modified Files: callbacks.c Log Message: Remove another large chuck of unneeded code - the format tag is no longer used, instead the SETFUNC is used. Index: callbacks.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callbacks.c,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** callbacks.c 9 Jun 2004 14:05:54 -0000 1.50 --- callbacks.c 9 Jun 2004 19:52:27 -0000 1.51 *************** *** 74,78 **** */ static void _CallPythonObject(void *mem, ! char *format, PyObject *callable, PyObject *converters, --- 74,78 ---- */ static void _CallPythonObject(void *mem, ! SETFUNC setfunc, PyObject *callable, PyObject *converters, *************** *** 155,163 **** Extend_Error_Info("(in callback) "); PyErr_Print(); ! } else { ! if ((result != Py_None) ! && !PyArg_Parse(result, format, mem)) { Extend_Error_Info("(callback return type) "); PyErr_Print(); } } --- 155,168 ---- Extend_Error_Info("(in callback) "); PyErr_Print(); ! } else if (result != Py_None) { ! PyObject *keep = setfunc(mem, result, 0); ! if (keep == NULL) { Extend_Error_Info("(callback return type) "); PyErr_Print(); + } else { + /* assert (keep == Py_None); */ + /* XXX We have no way to keep the needed reference XXX */ + /* Should we emit a warning? */ + Py_DECREF(keep); } } *************** *** 177,181 **** PyObject *converters; PyObject *callable; ! char *format; ffi_type *atypes[0]; } ffi_info; --- 182,186 ---- PyObject *converters; PyObject *callable; ! SETFUNC setfunc; ffi_type *atypes[0]; } ffi_info; *************** *** 189,193 **** _CallPythonObject(resp, ! p->format, p->callable, p->converters, --- 194,198 ---- _CallPythonObject(resp, ! p->setfunc, p->callable, p->converters, *************** *** 223,226 **** --- 228,238 ---- PrepareResult(restype, &cResult); + { + StgDictObject *dict = PyType_stgdict(restype); + if (dict) + p->setfunc = dict->setfunc; + else + p->setfunc = getentry("i")->setfunc; + } cc = FFI_DEFAULT_ABI; *************** *** 246,299 **** } - switch (cResult.tag) { - /* "bBhHiIlLqQdfP" */ - case 'b': - case 'B': - p->format = "b"; - break; - case 'h': - case 'H': - p->format = "h"; - break; - case 'i': - case 'I': - p->format = "i"; - break; - case 'P': - if (sizeof(void *) == sizeof(int)) - p->format = "i"; - else if (sizeof(void *) == sizeof(long)) - p->format = "p"; - else { /* Hm, what now? */ - PyErr_Format(PyExc_TypeError, "unknown pointer size"); - return NULL; - } - break; - case 'l': - case 'L': - p->format = "l"; - break; - #ifdef HAVE_LONG_LONG - case 'q': - case 'Q': - p->format = "L"; - break; - #endif - case 'd': - p->format = "d"; - break; - case 'f': - p->format = "f"; - break; - case 'z': - p->format = "z"; - break; - case 'c': - p->format = "c"; - break; - default: - PyErr_Format(PyExc_TypeError, "invalid restype %c", cResult.tag); - return NULL; - } p->converters = converters; p->callable = callable; --- 258,261 ---- |
From: Thomas H. <th...@us...> - 2004-06-09 19:47:36
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2815 Modified Files: test_internals.py Log Message: The *_set() functions return an object which must be kept alive to keep the C compatible data type valid. For simple objects like integers this is not needed, so we better return Py_None. Index: test_internals.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_internals.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_internals.py 4 May 2004 09:21:16 -0000 1.3 --- test_internals.py 9 Jun 2004 19:47:25 -0000 1.4 *************** *** 4,7 **** --- 4,9 ---- from sys import getrefcount as grc + # XXX This test must be reviewed for correctness!!! + """ ctypes' types are container types. *************** *** 24,30 **** self.failUnlessEqual(3, grc(i)) ci = c_int(i) ! self.failUnlessEqual(4, grc(i)) ! self.failUnlessSame(i, ci._objects[0]) ! self.failUnlessEqual([i], ci._objects) def test_c_char_p(self): --- 26,31 ---- self.failUnlessEqual(3, grc(i)) ci = c_int(i) ! self.failUnlessEqual(3, grc(i)) ! self.failUnlessEqual([None], ci._objects) def test_c_char_p(self): *************** *** 46,51 **** x.a = a x.b = b ! self.failUnlessEqual(x._objects, [a, b]) ! self.failUnlessSame(x._objects[0], a) def test_embedded_structs(self): --- 47,51 ---- x.a = a x.b = b ! self.failUnlessEqual(x._objects, [None, None]) def test_embedded_structs(self): *************** *** 63,68 **** self.failUnlessEqual(y._objects, [[None, None], [None, None]]) x1.a, x2.b = 42, 93 ! self.failUnlessEqual(y._objects, [[42, None], [None, 93]]) ! ## self.failUnlessEqual(y.x._objects, [42, None]) def test_xxx(self): --- 63,68 ---- self.failUnlessEqual(y._objects, [[None, None], [None, None]]) x1.a, x2.b = 42, 93 ! self.failUnlessEqual(y._objects, [[None, None], [None, None]]) ! ## self.failUnlessEqual(y.x._objects, [None, None]) def test_xxx(self): *************** *** 94,98 **** A = c_int*4 a = A(11, 22, 33, 44) ! self.failUnlessEqual(a._objects, [11, 22, 33, 44]) x = X() --- 94,98 ---- A = c_int*4 a = A(11, 22, 33, 44) ! self.failUnlessEqual(a._objects, [None, None, None, None]) x = X() |
From: Thomas H. <th...@us...> - 2004-06-09 19:47:26
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2692 Modified Files: cfield.c Log Message: The *_set() functions return an object which must be kept alive to keep the C compatible data type valid. For simple objects like integers this is not needed, so we better return Py_None. Index: cfield.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/cfield.c,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** cfield.c 9 Jun 2004 14:54:21 -0000 1.33 --- cfield.c 9 Jun 2004 19:47:16 -0000 1.34 *************** *** 7,10 **** --- 7,11 ---- #include <windows.h> #endif + /******************************************************************/ /* *************** *** 334,339 **** } *(double *)ptr = x; ! Py_INCREF(value); ! return value; } --- 335,340 ---- } *(double *)ptr = x; ! Py_INCREF(Py_None); ! return Py_None; } *************** *** 357,362 **** } *(float *)ptr = x; ! Py_INCREF(value); ! return value; } --- 358,363 ---- } *(float *)ptr = x; ! Py_INCREF(Py_None); ! return Py_None; } *************** *** 375,380 **** return NULL; *(unsigned PY_LONG_LONG *)ptr = x; ! Py_INCREF(value); ! return value; } --- 376,381 ---- return NULL; *(unsigned PY_LONG_LONG *)ptr = x; ! Py_INCREF(Py_None); ! return Py_None; } *************** *** 392,397 **** return NULL; *(PY_LONG_LONG *)ptr = x; ! Py_INCREF(value); ! return value; } --- 393,398 ---- return NULL; *(PY_LONG_LONG *)ptr = x; ! Py_INCREF(Py_None); ! return Py_None; } *************** *** 411,416 **** return NULL; *(int *)ptr = (int)x; ! Py_INCREF(value); ! return value; } --- 412,417 ---- return NULL; *(int *)ptr = (int)x; ! Py_INCREF(Py_None); ! return Py_None; } *************** *** 429,434 **** return NULL; *(unsigned int *)ptr = (unsigned int)val; ! Py_INCREF(value); ! return value; } --- 430,435 ---- return NULL; *(unsigned int *)ptr = (unsigned int)val; ! Py_INCREF(Py_None); ! return Py_None; } *************** *** 447,452 **** return NULL; *(long *)ptr = x; ! Py_INCREF(value); ! return value; } --- 448,453 ---- return NULL; *(long *)ptr = x; ! Py_INCREF(Py_None); ! return Py_None; } *************** *** 465,470 **** return NULL; *(unsigned long *)ptr = val; ! Py_INCREF(value); ! return value; } --- 466,471 ---- return NULL; *(unsigned long *)ptr = val; ! Py_INCREF(Py_None); ! return Py_None; } *************** *** 488,493 **** } *(short *)ptr = (short)val; ! Py_INCREF(value); ! return value; } --- 489,494 ---- } *(short *)ptr = (short)val; ! Py_INCREF(Py_None); ! return Py_None; } *************** *** 511,516 **** } *(unsigned short *)ptr = (unsigned short)val; ! Py_INCREF(value); ! return value; } --- 512,517 ---- } *(unsigned short *)ptr = (unsigned short)val; ! Py_INCREF(Py_None); ! return Py_None; } *************** *** 534,539 **** } *(char *)ptr = (char)val; ! Py_INCREF(value); ! return value; } --- 535,540 ---- } *(char *)ptr = (char)val; ! Py_INCREF(Py_None); ! return Py_None; } *************** *** 557,562 **** } *(unsigned char *)ptr = (unsigned char)val; ! Py_INCREF(value); ! return value; } --- 558,563 ---- } *(unsigned char *)ptr = (unsigned char)val; ! Py_INCREF(Py_None); ! return Py_None; } *************** *** 577,582 **** } *(char *)ptr = PyString_AS_STRING(value)[0]; ! Py_INCREF(value); ! return value; } --- 578,583 ---- } *(char *)ptr = PyString_AS_STRING(value)[0]; ! Py_INCREF(Py_None); ! return Py_None; } *************** *** 621,625 **** } *(wchar_t *)ptr = p[0]; ! return value; } --- 622,629 ---- } *(wchar_t *)ptr = p[0]; ! Py_DECREF(value); ! ! Py_INCREF(Py_None); ! return Py_None; } *************** *** 734,739 **** /* Also copy the terminating NUL character */ memcpy((char *)ptr, data, size); ! Py_INCREF(value); ! return value; } --- 738,743 ---- /* Also copy the terminating NUL character */ memcpy((char *)ptr, data, size); ! Py_INCREF(Py_None); ! return Py_None; } *************** *** 886,891 **** } *(void **)ptr = v; ! Py_INCREF(value); ! return value; } --- 890,895 ---- } *(void **)ptr = v; ! Py_INCREF(Py_None); ! return Py_None; } |
From: Thomas H. <th...@us...> - 2004-06-09 15:56:07
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26499 Modified Files: stgdict.c Log Message: Set the elements member of ffi_type for FFI_TYPE_STRUCT. Index: stgdict.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/stgdict.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** stgdict.c 18 May 2004 12:06:30 -0000 1.11 --- stgdict.c 9 Jun 2004 15:55:57 -0000 1.12 *************** *** 25,28 **** --- 25,29 ---- { Py_XDECREF(self->proto); + PyMem_Free(self->ffi_type.elements); ((PyObject *)self)->ob_type->tp_free((PyObject *)self); } *************** *** 161,164 **** --- 162,169 ---- total_align = 1; + stgdict->ffi_type.type = FFI_TYPE_STRUCT; + stgdict->ffi_type.elements = PyMem_Malloc(sizeof(ffi_type *) * (len + 1)); + memset(stgdict->ffi_type.elements, 0, sizeof(ffi_type *) * (len + 1)); + #define realdict ((PyObject *)&stgdict->dict) for (i = 0; i < len; ++i) { *************** *** 166,169 **** --- 171,175 ---- PyObject *pair = PySequence_GetItem(fields, i); PyObject *prop; + StgDictObject *dict; if (!pair || !PyArg_Parse(pair, "(OO)", &name, &desc)) { *************** *** 173,176 **** --- 179,185 ---- return NULL; } + dict = PyType_stgdict(desc); + if (dict) + stgdict->ffi_type.elements[i] = &dict->ffi_type; if (isStruct) { prop = CField_FromDesc(desc, i, *************** *** 208,212 **** 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; --- 217,220 ---- |
From: Thomas H. <th...@us...> - 2004-06-09 15:40:42
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10849 Modified Files: callproc.c Log Message: Remove more unused code. Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -d -r1.76 -r1.77 *** callproc.c 9 Jun 2004 14:05:54 -0000 1.76 --- callproc.c 9 Jun 2004 15:40:30 -0000 1.77 *************** *** 765,768 **** --- 765,770 ---- StgDictObject *dict; + assert(restype); + if (restype == Py_None) { Py_INCREF(Py_None); *************** *** 770,776 **** } - if (restype == NULL) - return ToPython(&result->value, result->tag); - if (PointerTypeObject_Check(restype)) { CDataObject *pd; --- 772,775 ---- |
From: Thomas H. <th...@us...> - 2004-06-09 15:39:46
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9988 Modified Files: ctypes.h Log Message: Remove more unused code. Index: ctypes.h =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/ctypes.h,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** ctypes.h 14 May 2004 17:57:04 -0000 1.43 --- ctypes.h 9 Jun 2004 15:39:36 -0000 1.44 *************** *** 236,241 **** extern PyCArgObject *new_CArgObject(void); - extern PyObject *ToPython(void *, char tag); - extern PyObject * CData_get(PyObject *type, GETFUNC getfunc, PyObject *src, --- 236,239 ---- |
From: Thomas H. <th...@us...> - 2004-06-09 15:39:05
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9477 Modified Files: _ctypes.c Log Message: Remove more unused code. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.144 retrieving revision 1.145 diff -C2 -d -r1.144 -r1.145 *** _ctypes.c 27 May 2004 18:19:33 -0000 1.144 --- _ctypes.c 9 Jun 2004 15:38:55 -0000 1.145 *************** *** 3353,3370 **** /******************************************************************/ - PyObject * - ToPython(void *ptr, char tag) - { - struct fielddesc *fd = getentry(&tag); - if (!fd) { - PyErr_Format(PyExc_ValueError, - "invalid format char for restype '%c'", - tag); - return NULL; - } - return fd->getfunc(ptr, 0); - } - - /******************************************************************/ /* * Module initialization. --- 3353,3356 ---- |
From: Thomas H. <th...@us...> - 2004-06-09 14:59:48
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7055 Modified Files: test_cfuncs.py Log Message: Add a test where restype is a function. Index: test_cfuncs.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_cfuncs.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_cfuncs.py 27 May 2004 16:30:38 -0000 1.5 --- test_cfuncs.py 9 Jun 2004 14:59:40 -0000 1.6 *************** *** 88,91 **** --- 88,101 ---- self.failUnlessEqual(self.dll.tf_bd(0, 42), 42) + def test_callwithresult(self): + def process_result(result): + return result * 2 + self.dll.tf_i.restype = process_result + self.dll.tf_i.argtypes = (c_int,) + self.failUnlessEqual(self.dll.tf_i(42), 84) + self.failUnlessEqual(self.dll.tf_i(-42), -84) + + # The following repeates the above tests with stdcall functions (where + # they are available) try: WinDLL |
From: Thomas H. <th...@us...> - 2004-06-09 14:54:30
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1663 Modified Files: cfield.c Log Message: Remove other unused code. Index: cfield.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/cfield.c,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** cfield.c 2 Jun 2004 11:32:15 -0000 1.32 --- cfield.c 9 Jun 2004 14:54:21 -0000 1.33 *************** *** 738,772 **** } - - /* XXX Seems the S format is no longer used anywhere, remove after 0.6.0 release */ - #if 1 - static PyObject * - S_get(void *ptr, unsigned length) - { - return PyString_FromStringAndSize((char *)ptr, length); - } - - static PyObject * - S_set(void *ptr, PyObject *value, unsigned length) - { - char *data; - unsigned size; - - if (-1 == PyString_AsStringAndSize(value, &data, &size)) { - return NULL; - } - if (size > length) { - PyErr_Format(PyExc_ValueError, - "string too long (%d instead of at most than %d)", - size, length); - return NULL; - } - /* No terminating NUL character */ - memcpy((char *)ptr, data, size); - Py_INCREF(value); - return value; - } - #endif - static PyObject * z_set(void *ptr, PyObject *value, unsigned size) --- 738,741 ---- *************** *** 933,941 **** static struct fielddesc formattable[] = { { 's', s_set, s_get, &ffi_type_pointer}, - #if 1 - /* XXX This one seems unused */ - /* See comment above S_get() */ - { 'S', S_set, S_get, &ffi_type_schar}, - #endif { 'b', b_set, b_get, &ffi_type_schar}, { 'B', B_set, B_get, &ffi_type_uchar}, --- 902,905 ---- |
From: Thomas H. <th...@us...> - 2004-06-09 14:06:04
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15605 Modified Files: callproc.c callbacks.c Log Message: Sigh - there goes my code. Removed large amount of code by using libffi also on windows. Ya! Index: callbacks.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callbacks.c,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** callbacks.c 9 Jun 2004 11:56:02 -0000 1.49 --- callbacks.c 9 Jun 2004 14:05:54 -0000 1.50 *************** *** 8,13 **** #endif - #define USE_LIBFFI - /* For 2.3, use the PyGILState_ calls, see PEP 311 */ #if (PY_VERSION_HEX >= 0x02030000) --- 8,11 ---- *************** *** 55,67 **** - #ifndef USE_LIBFFI - staticforward THUNK AllocCallback(PyObject *callable, - int nArgBytes, - PyObject *converters, - DWORD RouterAddress, - int is_cdecl); - - #endif - static void PrintError(char *msg, ...) --- 53,56 ---- *************** *** 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); --- 117,121 ---- *************** *** 143,149 **** 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? */ --- 128,131 ---- *************** *** 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 { --- 140,144 ---- *************** *** 172,178 **** } /* XXX error handling! */ - #ifdef USE_LIBFFI pArgs++; - #endif } result = PyObject_CallObject(callable, arglist); --- 149,153 ---- *************** *** 197,481 **** } - #ifndef USE_LIBFFI - static int __stdcall z_CallPythonObject(PyObject *callable, - PyObject *converters, - void **pArgs) - { - PyCArgObject result; - _CallPythonObject(&result.value, "z", callable, converters, pArgs); - return result.value.p; - } - - static int __stdcall c_CallPythonObject(PyObject *callable, - PyObject *converters, - void **pArgs) - { - PyCArgObject result; - _CallPythonObject(&result.value, "c", callable, converters, pArgs); - return result.value.i; - } - - static int __stdcall i_CallPythonObject(PyObject *callable, - PyObject *converters, - void **pArgs) - { - PyCArgObject result; - _CallPythonObject(&result.value, "i", callable, converters, pArgs); - return result.value.i; - } - - static double __stdcall d_CallPythonObject(PyObject *callable, - PyObject *converters, - void **pArgs) - { - PyCArgObject result; - _CallPythonObject(&result.value, "d", callable, converters, pArgs); - return result.value.d; - } - - static float __stdcall f_CallPythonObject(PyObject *callable, - PyObject *converters, - void **pArgs) - { - PyCArgObject result; - _CallPythonObject(&result.value, "f", callable, converters, pArgs); - return result.value.f; - } - - #ifdef HAVE_LONG_LONG - static PY_LONG_LONG __stdcall q_CallPythonObject(PyObject *callable, - PyObject *converters, - void **pArgs) - { - PyCArgObject result; - _CallPythonObject(&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 */ - - /*****************************************************************************/ - - typedef struct { - BYTE *pStart; - BYTE *pEnd; - } CALLBACKINFO; - - static CALLBACKINFO ti; - - /* - * Allocate a callback and configure it - */ - static THUNK AllocCallback(PyObject *callable, int nArgBytes, - PyObject *converters, DWORD RouterAddress, - int is_cdecl) - { - BYTE *pCallback, *pNargBytes, *pConverters, *pCalladdr, *pRouter; - - pCallback = PyMem_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(PyObject *callable, - int nArgBytes, - PyObject *converters, - PyObject *restype, - int is_cdecl) - { - PyCArgObject result; - DWORD func; - PrepareResult(restype, &result); - switch (result.tag) { - case 'z': - func = (DWORD)z_CallPythonObject; - break; - case 'c': - func = (DWORD)c_CallPythonObject; - break; - /* "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_CallPythonObject; - break; - #ifdef HAVE_LONG_LONG - case 'q': - case 'Q': - func = (DWORD)q_CallPythonObject; - break; - #endif - case 'd': - func = (DWORD)d_CallPythonObject; - break; - case 'f': - func = (DWORD)f_CallPythonObject; - break; - default: - PyErr_Format(PyExc_TypeError, "invalid restype %c", result.tag); - return NULL; - } - /* XXX restype -> CallPythonObject */ - return AllocCallback(callable, - nArgBytes, - converters, - func, - is_cdecl); - } - #else /* USE_LIBFFI */ - typedef struct { ffi_closure cl; /* the C callable */ --- 172,175 ---- *************** *** 607,611 **** return (THUNK)p; } - #endif /* MS_WIN32 */ void FreeCallback(THUNK thunk) --- 301,304 ---- *************** *** 621,630 **** void init_callbacks_in_module(PyObject *m) { - #ifndef USE_LIBFFI - CALLBACKINFO (__stdcall *pFunc)(DWORD); - pFunc = (CALLBACKINFO (__stdcall *)(DWORD)) CallbackTemplate; - ti = pFunc(0); - #endif - if (PyType_Ready((PyTypeObject *)&PyType_Type) < 0) return; --- 314,317 ---- Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.75 retrieving revision 1.76 diff -C2 -d -r1.75 -r1.76 *** callproc.c 18 May 2004 12:41:07 -0000 1.75 --- callproc.c 9 Jun 2004 14:05:54 -0000 1.76 *************** *** 74,79 **** #endif - #define USE_LIBFFI - #ifdef MS_WIN32 #define alloca _alloca --- 74,77 ---- *************** *** 558,563 **** - #ifdef USE_LIBFFI - /* * libffi uses: --- 556,559 ---- *************** *** 677,907 **** return 0; } - #else /* USE_LIBFFI */ - #pragma optimize ("", off) - /* - * Can you figure out what this does? ;-) - */ - static void __stdcall push(void) - { - } - - static int _call_function_pointer(int flags, - PPROC pProc, - PyCArgObject **parms, - PyCArgObject *res, - int argcount) - { - int i; - DWORD dwExceptionCode; - EXCEPTION_RECORD record; - 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; - if (parms[i]->pffi_type == NULL) { - fprintf(stderr, "NO FFI_TYPE %c\n", parms[i]->tag); - #ifdef _DEBUG - _asm int 3; - #endif - } - 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': - /* 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 'X': /* BSTR */ - push(parms[i]->value.p); - argbytes += sizeof(void *); - break; - #ifdef CAN_PASS_BY_VALUE - case 'V': - { - int n; - int *p; - n = parms[i]->size; - if (n % sizeof(int)) - n += sizeof(int); - n /= sizeof(int); - n -= 1; - p = (int *)parms[i]->value.p; - while (n >= 0) { - push(p[n--]); - argbytes += sizeof(int); - } - } - break; - #endif - 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) - Py_BEGIN_ALLOW_THREADS - 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': - 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': - res->value.p = ((void *(*)())pProc)(); - break; - case 'v': - ((void(*)())pProc)(); - break; - default: - /* XXX Signal bug */ - res->tag |= 0x80; - break; - } - #ifndef DEBUG_EXCEPTIONS - } - __except (HandleException(GetExceptionInformation(), - &dwExceptionCode, &record)) { - ; - } - #endif - _asm sub new_esp, esp; - _asm mov esp, save_esp; - - Py_END_ALLOW_THREADS - - if (dwExceptionCode) { - SetException(dwExceptionCode, &record); - return -1; - } - if (res->tag & 0x80) { - PyErr_Format(PyExc_ValueError, - "BUG: Invalid format tag for restype '%c'", - res->tag & ~0x80); - return -1; - } - - if (flags & FUNCFLAG_CDECL) /* Clean up stack if needed */ - new_esp -= argbytes; - if (new_esp < 0) { - /* Try to give a better error message */ - if (flags & FUNCFLAG_CDECL) - PyErr_Format(PyExc_ValueError, - "Procedure called with not enough " - "arguments (%d bytes missing) " - "or wrong calling convention", - -new_esp); - else - PyErr_Format(PyExc_ValueError, - "Procedure probably called with not enough " - "arguments (%d bytes missing)", - -new_esp); - return -1; - } - if (new_esp > 0) { - PyErr_Format(PyExc_ValueError, - "Procedure probably called with too many " - "arguments (%d bytes in excess)", - new_esp); - return -1; - } - return 0; - } - #pragma optimize ("", on) - - #endif /* USE_LIBFFI */ #define RESULT_PASTE_INTO 1 --- 673,676 ---- |
From: Thomas H. <th...@us...> - 2004-06-09 11:56:20
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12080 Modified Files: callbacks.c Log Message: Make it work on platforms where sizeof(int) != sizeof(long). Index: callbacks.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callbacks.c,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** callbacks.c 25 May 2004 09:37:12 -0000 1.48 --- callbacks.c 9 Jun 2004 11:56:02 -0000 1.49 *************** *** 556,567 **** case 'b': case 'B': case 'h': case 'H': case 'i': case 'I': case 'l': case 'L': ! case 'P': ! p->format = "i"; break; #ifdef HAVE_LONG_LONG --- 556,582 ---- case 'b': case 'B': + p->format = "b"; + break; case 'h': case 'H': + p->format = "h"; + break; case 'i': case 'I': + p->format = "i"; + break; + case 'P': + if (sizeof(void *) == sizeof(int)) + p->format = "i"; + else if (sizeof(void *) == sizeof(long)) + p->format = "p"; + else { /* Hm, what now? */ + PyErr_Format(PyExc_TypeError, "unknown pointer size"); + return NULL; + } + break; case 'l': case 'L': ! p->format = "l"; break; #ifdef HAVE_LONG_LONG |
From: Thomas H. <th...@us...> - 2004-06-04 17:54:20
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8046 Modified Files: runtests.py Log Message: Fix a silly error. Index: runtests.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/runtests.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** runtests.py 2 Jun 2004 13:30:07 -0000 1.1 --- runtests.py 4 Jun 2004 17:53:59 -0000 1.2 *************** *** 41,45 **** if flag == "-q": verbosity -= 1 ! elif flag in "-v": verbosity += 1 if args: --- 41,45 ---- if flag == "-q": verbosity -= 1 ! elif flag == "-v": verbosity += 1 if args: |
From: Thomas H. <th...@us...> - 2004-06-04 17:43:02
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5447 Modified Files: setup.py Log Message: Add some apple-specific hacks, stolen from pyobjc. Index: setup.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/setup.py,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** setup.py 2 Jun 2004 17:55:16 -0000 1.50 --- setup.py 4 Jun 2004 17:42:53 -0000 1.51 *************** *** 82,85 **** --- 82,99 ---- ) ] + ################################################################ + # This section copied from the PyObjC project + if sys.platform == 'darwin': + # Apple has used build options that don't work with a 'normal' system. + # Remove '-arch i386' from the LDFLAGS. + import distutils.sysconfig + distutils.sysconfig.get_config_vars() + x = distutils.sysconfig._config_vars['LDSHARED'] + y = x.replace('-arch i386', '') + if y != x: + print "Fixing Apple strangeness in Python configuration" + distutils.sysconfig._config_vars['LDSHARED'] = y + + ################################################################ packages = ["ctypes"] |
From: Thomas H. <th...@us...> - 2004-06-02 17:55:25
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11646 Modified Files: setup.py Log Message: Use self.warn() instead of print. Index: setup.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/setup.py,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** setup.py 2 Jun 2004 12:47:43 -0000 1.49 --- setup.py 2 Jun 2004 17:55:16 -0000 1.50 *************** *** 166,171 **** mod = __import__(os.path.splitext(self.test_prefix + case)[0]) except Exception, detail: ! print "Could not import", self.test_prefix + case ! print "\t", detail continue for name in dir(mod): --- 166,170 ---- mod = __import__(os.path.splitext(self.test_prefix + case)[0]) except Exception, detail: ! self.warn("Could not import %s (%s)" % (self.test_prefix + case, detail)) continue for name in dir(mod): |
From: Thomas H. <th...@us...> - 2004-06-02 13:30:17
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24285 Added Files: runtests.py Log Message: A simple test driver. --- NEW FILE: runtests.py --- """Usage: runtests.py [-q] [-v] [mask] Run all tests found in this directory, and print a summary of the results. Command line flags: -v verbose mode: print the test currently executed -q quiet mode: don't prnt anything while the tests are running mask mask to select filenames containing testcases, wildcards allowed """ import glob, os, sys, unittest, getopt def get_suite(mask): if not mask.endswith(".py"): mask += ".py" test_suites = [] for fname in glob.glob(mask): try: mod = __import__(os.path.splitext(fname)[0]) except Exception, detail: print "Warning: could not import %s: %s" % (fname, detail) continue for name in dir(mod): if name.startswith("_"): continue o = getattr(mod, name) if type(o) is type(unittest.TestCase) and issubclass(o, unittest.TestCase): test_suites.append(unittest.makeSuite(o)) return unittest.TestSuite(test_suites) def usage(): print __doc__ return 1 def main(): verbosity = 1 mask = "test_*.py" try: opts, args = getopt.getopt(sys.argv[1:], "qv") except getopt.error: return usage() for flag, value in opts: if flag == "-q": verbosity -= 1 elif flag in "-v": verbosity += 1 if args: mask = args[0] suite = get_suite(mask) runner = unittest.TextTestRunner(verbosity=verbosity) return bool(runner.run(suite).errors) if __name__ == "__main__": sys.exit(main()) |
From: Thomas H. <th...@us...> - 2004-06-02 12:47:52
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16078 Modified Files: setup.py Log Message: Don't crash the setup script if a test module can not be imported. Index: setup.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/setup.py,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** setup.py 2 Jun 2004 08:28:24 -0000 1.48 --- setup.py 2 Jun 2004 12:47:43 -0000 1.49 *************** *** 163,167 **** test_suites = [] for case in self.test_suffixes: ! mod = __import__(os.path.splitext(self.test_prefix + case)[0]) for name in dir(mod): if name.startswith("_"): --- 163,172 ---- test_suites = [] for case in self.test_suffixes: ! try: ! mod = __import__(os.path.splitext(self.test_prefix + case)[0]) ! except Exception, detail: ! print "Could not import", self.test_prefix + case ! print "\t", detail ! continue for name in dir(mod): if name.startswith("_"): |
From: Thomas H. <th...@us...> - 2004-06-02 11:32:39
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3325 Modified Files: cfield.c Log Message: a C long may be 32 or 64 bit. Index: cfield.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/cfield.c,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** cfield.c 2 Jun 2004 08:28:33 -0000 1.31 --- cfield.c 2 Jun 2004 11:32:15 -0000 1.32 *************** *** 949,954 **** --- 949,961 ---- /* XXX Hm, sizeof(int) == sizeof(long) doesn't hold on every platform */ /* As soon as we can get rid of the type codes, this is no longer a problem */ + #if SIZEOF_LONG == 4 { 'l', l_set, l_get, &ffi_type_sint}, { 'L', L_set, L_get, &ffi_type_uint}, + #elif SIZEOF_LONG == 8 + { 'l', l_set, l_get, &ffi_type_slong}, + { 'L', L_set, L_get, &ffi_type_ulong}, + #else + # error + #endif #ifdef HAVE_LONG_LONG { 'q', q_set, q_get, &ffi_type_slong}, |
From: Thomas H. <th...@us...> - 2004-06-02 11:22:02
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1508 Modified Files: test_structures.py Log Message: failUnless -> failUnlessEqual Index: test_structures.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_structures.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** test_structures.py 4 May 2004 09:15:18 -0000 1.12 --- test_structures.py 2 Jun 2004 11:21:53 -0000 1.13 *************** *** 32,36 **** _fields_ = [("x", c_char), ("y", tp)] ! self.failUnless(sizeof(X) == calcsize("%c" % (code))) def test_struct_alignment(self): --- 32,37 ---- _fields_ = [("x", c_char), ("y", tp)] ! self.failUnlessEqual((sizeof(X), code), ! (calcsize("%c" % (code)), code)) def test_struct_alignment(self): |