ctypes-commit Mailing List for ctypes (Page 81)
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-12-02 19:53:46
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15717 Modified Files: test_functions.py Log Message: Structures as function return types work now, except for small ones returned in registers by MSVC. Index: test_functions.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_functions.py,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** test_functions.py 2 Dec 2004 16:03:17 -0000 1.43 --- test_functions.py 2 Dec 2004 19:53:37 -0000 1.44 *************** *** 349,353 **** dll.ret_8i_func.restype = S8I s8i = dll.ret_8i_func() ! self.failUnlessEqual((s8i.a, s8i.b, s8i.c, s8i.d, s8i.e, s8i.f, s8i.g), (1, 2, 3, 4, 5, 6, 7, 8)) --- 349,353 ---- dll.ret_8i_func.restype = S8I s8i = dll.ret_8i_func() ! self.failUnlessEqual((s8i.a, s8i.b, s8i.c, s8i.d, s8i.e, s8i.f, s8i.g, s8i.h), (1, 2, 3, 4, 5, 6, 7, 8)) |
From: Thomas H. <th...@us...> - 2004-12-02 19:53:40
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15667 Modified Files: callproc.c Log Message: Structures as function return types work now, except for small ones returned in registers by MSVC. Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.120 retrieving revision 1.121 diff -C2 -d -r1.120 -r1.121 *** callproc.c 2 Dec 2004 19:12:28 -0000 1.120 --- callproc.c 2 Dec 2004 19:53:21 -0000 1.121 *************** *** 703,707 **** * Convert the C value in result into an instance described by restype */ ! static PyObject *GetResult(PyObject *restype, ffi_type *ffi_type, void *result) { StgDictObject *dict; --- 703,707 ---- * Convert the C value in result into an instance described by restype */ ! static PyObject *GetResult(PyObject *restype, void *result) { StgDictObject *dict; *************** *** 735,738 **** --- 735,755 ---- } + if (StructTypeObject_Check(restype)) { + CDataObject *pd; + + pd = (CDataObject *)PyObject_CallFunctionObjArgs(restype, NULL); + if (!pd) + return NULL; + if (!CDataObject_Check(pd)) { + Py_DECREF(pd); + PyErr_SetString(PyExc_TypeError, + "BUG: restype call did not return a CDataObject"); + return NULL; + } + /* Even better would be to use the buffer interface */ + memcpy(pd->b_ptr, result, pd->b_size); + return (PyObject *)pd; + } + dict = PyType_stgdict(restype); if (dict && dict->getfunc) { *************** *** 848,854 **** { int i, n, argcount, argtype_count; ! struct argument result; struct argument *args, *pa; ffi_type **atypes; void **avalues; PyObject *retval = NULL; --- 865,872 ---- { int i, n, argcount, argtype_count; ! void *resbuf; struct argument *args, *pa; ffi_type **atypes; + ffi_type *rtype; void **avalues; PyObject *retval = NULL; *************** *** 907,917 **** } ! /* XXX If we have a structure as return value, the storage area that ! 'result.value' provides may not be large enough. We should ! probably create the result value (an instance of the structure ! type) before the call, and use the instance's memory buffer as the ! storage area. ! */ ! result.ffi_type = GetType(restype); avalues = (void **)alloca(sizeof(void *) * argcount); --- 925,930 ---- } ! rtype = GetType(restype); ! resbuf = alloca(max(rtype->size, sizeof(ffi_arg))); avalues = (void **)alloca(sizeof(void *) * argcount); *************** *** 926,941 **** if (-1 == _call_function_pointer(flags, pProc, avalues, atypes, ! result.ffi_type, &result.value, argcount)) goto cleanup; #ifdef MS_WIN32 if (flags & FUNCFLAG_HRESULT) { ! if (result.value.i & 0x80000000) ! retval = PyErr_SetFromWindowsErr(result.value.i); else ! retval = PyInt_FromLong(result.value.i); } else #endif ! retval = GetResult(restype, result.ffi_type, &result.value); cleanup: for (i = 0; i < argcount; ++i) --- 939,954 ---- if (-1 == _call_function_pointer(flags, pProc, avalues, atypes, ! rtype, resbuf, argcount)) goto cleanup; #ifdef MS_WIN32 if (flags & FUNCFLAG_HRESULT) { ! if (*(int *)resbuf & 0x80000000) ! retval = PyErr_SetFromWindowsErr(*(int *)resbuf); else ! retval = PyInt_FromLong(*(int *)resbuf); } else #endif ! retval = GetResult(restype, resbuf); cleanup: for (i = 0; i < argcount; ++i) |
From: Thomas H. <th...@us...> - 2004-12-02 19:51:42
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14880 Modified Files: ctypes.h _ctypes.c Log Message: Make StructType_Type global, and provide a type check macro. Index: ctypes.h =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/ctypes.h,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** ctypes.h 30 Nov 2004 16:40:25 -0000 1.64 --- ctypes.h 2 Dec 2004 19:51:32 -0000 1.65 *************** *** 99,102 **** --- 99,103 ---- extern PyTypeObject CFuncPtr_Type; extern PyTypeObject CFuncPtrType_Type; + extern PyTypeObject StructType_Type; #define ArrayTypeObject_Check(v) PyObject_TypeCheck(v, &ArrayType_Type) *************** *** 106,109 **** --- 107,111 ---- #define CFuncPtrObject_Check(v) PyObject_TypeCheck(v, &CFuncPtr_Type) #define CFuncPtrTypeObject_Check(v) PyObject_TypeCheck(v, &CFuncPtrType_Type) + #define StructTypeObject_Check(v) PyObject_TypeCheck(v, &StructType_Type) extern PyObject * Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.191 retrieving revision 1.192 diff -C2 -d -r1.191 -r1.192 *** _ctypes.c 2 Dec 2004 10:22:21 -0000 1.191 --- _ctypes.c 2 Dec 2004 19:51:32 -0000 1.192 *************** *** 355,359 **** ! static PyTypeObject StructType_Type = { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ --- 355,359 ---- ! PyTypeObject StructType_Type = { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ |
From: Thomas H. <th...@us...> - 2004-12-02 19:12:51
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5914 Modified Files: callproc.c Log Message: More refactoring Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.119 retrieving revision 1.120 diff -C2 -d -r1.119 -r1.120 *** callproc.c 2 Dec 2004 19:02:44 -0000 1.119 --- callproc.c 2 Dec 2004 19:12:28 -0000 1.120 *************** *** 703,712 **** * Convert the C value in result into an instance described by restype */ ! static PyObject *GetResult(PyObject *restype, ffi_type *ffi_type, union result *result) { StgDictObject *dict; if (restype == NULL) { ! return getentry("i")->getfunc(&result->l, sizeof(int)); } --- 703,712 ---- * Convert the C value in result into an instance described by restype */ ! static PyObject *GetResult(PyObject *restype, ffi_type *ffi_type, void *result) { StgDictObject *dict; if (restype == NULL) { ! return getentry("i")->getfunc(result, sizeof(int)); } *************** *** 749,766 **** switch (dict->size) { case 1: ! c = (char)result->l; retval = dict->getfunc(&c, dict->size); break; case SIZEOF_SHORT: ! s = (short)result->l; retval = dict->getfunc(&s, dict->size); break; case SIZEOF_INT: ! i = (int)result->l; retval = dict->getfunc(&i, dict->size); break; #if (SIZEOF_LONG != SIZEOF_INT) case SIZEOF_LONG: ! l = (long)result->l; retval = dict->getfunc(&l, dict->size); break; --- 749,766 ---- switch (dict->size) { case 1: ! c = (char)*(long *)result; retval = dict->getfunc(&c, dict->size); break; case SIZEOF_SHORT: ! s = (short)*(long *)result; retval = dict->getfunc(&s, dict->size); break; case SIZEOF_INT: ! i = (int)*(long *)result; retval = dict->getfunc(&i, dict->size); break; #if (SIZEOF_LONG != SIZEOF_INT) case SIZEOF_LONG: ! l = (long)*(long *)result; retval = dict->getfunc(&l, dict->size); break; *************** *** 784,788 **** if (PyCallable_Check(restype)) return PyObject_CallFunction(restype, "i", ! result->i); PyErr_SetString(PyExc_TypeError, "Bug: cannot convert result"); --- 784,788 ---- if (PyCallable_Check(restype)) return PyObject_CallFunction(restype, "i", ! *(int *)result); PyErr_SetString(PyExc_TypeError, "Bug: cannot convert result"); |
From: Thomas H. <th...@us...> - 2004-12-02 19:02:54
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2803 Modified Files: callproc.c Log Message: More refactoring - change the signature of GetResult(). Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.118 retrieving revision 1.119 diff -C2 -d -r1.118 -r1.119 *** callproc.c 2 Dec 2004 18:26:21 -0000 1.118 --- callproc.c 2 Dec 2004 19:02:44 -0000 1.119 *************** *** 435,454 **** */ struct argument { ffi_type *ffi_type; PyObject *keep; ! union { ! char c; ! char b; ! short h; ! int i; ! long l; ! #ifdef HAVE_LONG_LONG ! PY_LONG_LONG q; ! #endif ! double d; ! float f; ! void *p; ! } value; }; --- 435,456 ---- */ + union result { + char c; + char b; + short h; + int i; + long l; + #ifdef HAVE_LONG_LONG + PY_LONG_LONG q; + #endif + double d; + float f; + void *p; + }; + struct argument { ffi_type *ffi_type; PyObject *keep; ! union result value; }; *************** *** 701,714 **** * Convert the C value in result into an instance described by restype */ ! static PyObject *GetResult(PyObject *restype, struct argument *result) { StgDictObject *dict; if (restype == NULL) { ! return getentry("i")->getfunc(&result->value.l, sizeof(int)); } - assert(restype); - if (restype == Py_None) { Py_INCREF(Py_None); --- 703,714 ---- * Convert the C value in result into an instance described by restype */ ! static PyObject *GetResult(PyObject *restype, ffi_type *ffi_type, union result *result) { StgDictObject *dict; if (restype == NULL) { ! return getentry("i")->getfunc(&result->l, sizeof(int)); } if (restype == Py_None) { Py_INCREF(Py_None); *************** *** 731,735 **** } /* Even better would be to use the buffer interface */ ! memcpy(pd->b_ptr, &result->value, pd->b_size); return (PyObject *)pd; } --- 731,735 ---- } /* Even better would be to use the buffer interface */ ! memcpy(pd->b_ptr, result, pd->b_size); return (PyObject *)pd; } *************** *** 749,771 **** switch (dict->size) { case 1: ! c = (char)result->value.l; retval = dict->getfunc(&c, dict->size); break; case SIZEOF_SHORT: ! s = (short)result->value.l; retval = dict->getfunc(&s, dict->size); break; case SIZEOF_INT: ! i = (int)result->value.l; retval = dict->getfunc(&i, dict->size); break; #if (SIZEOF_LONG != SIZEOF_INT) case SIZEOF_LONG: ! l = (long)result->value.l; retval = dict->getfunc(&l, dict->size); break; #endif default: ! retval = dict->getfunc(&result->value, dict->size); break; } --- 749,771 ---- switch (dict->size) { case 1: ! c = (char)result->l; retval = dict->getfunc(&c, dict->size); break; case SIZEOF_SHORT: ! s = (short)result->l; retval = dict->getfunc(&s, dict->size); break; case SIZEOF_INT: ! i = (int)result->l; retval = dict->getfunc(&i, dict->size); break; #if (SIZEOF_LONG != SIZEOF_INT) case SIZEOF_LONG: ! l = (long)result->l; retval = dict->getfunc(&l, dict->size); break; #endif default: ! retval = dict->getfunc(result, dict->size); break; } *************** *** 784,788 **** if (PyCallable_Check(restype)) return PyObject_CallFunction(restype, "i", ! result->value.i); PyErr_SetString(PyExc_TypeError, "Bug: cannot convert result"); --- 784,788 ---- if (PyCallable_Check(restype)) return PyObject_CallFunction(restype, "i", ! result->i); PyErr_SetString(PyExc_TypeError, "Bug: cannot convert result"); *************** *** 937,941 **** } else #endif ! retval = GetResult(restype, &result); cleanup: for (i = 0; i < argcount; ++i) --- 937,941 ---- } else #endif ! retval = GetResult(restype, result.ffi_type, &result.value); cleanup: for (i = 0; i < argcount; ++i) |
From: Thomas H. <th...@us...> - 2004-12-02 18:26:29
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22987 Modified Files: callproc.c Log Message: Refactoring. Change the signature of _call_function_pointer to not require a 'struct argument' arg for the result any more. Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.117 retrieving revision 1.118 diff -C2 -d -r1.117 -r1.118 *** callproc.c 2 Dec 2004 17:27:19 -0000 1.117 --- callproc.c 2 Dec 2004 18:26:21 -0000 1.118 *************** *** 609,613 **** void **avalues, ffi_type **atypes, ! struct argument *res, int argcount) { --- 609,614 ---- void **avalues, ffi_type **atypes, ! ffi_type *restype, ! void *resmem, int argcount) { *************** *** 621,625 **** #endif /* XXX check before here */ ! if (res->ffi_type == NULL) { PyErr_SetString(PyExc_RuntimeError, "No ffi_type for result"); --- 622,626 ---- #endif /* XXX check before here */ ! if (restype == NULL) { PyErr_SetString(PyExc_RuntimeError, "No ffi_type for result"); *************** *** 636,640 **** cc, argcount, ! res->ffi_type, atypes)) { PyErr_SetString(PyExc_RuntimeError, --- 637,641 ---- cc, argcount, ! restype, atypes)) { PyErr_SetString(PyExc_RuntimeError, *************** *** 651,655 **** delta = #endif ! ffi_call(&cif, (void *)pProc, &res->value, avalues); #ifdef MS_WIN32 #ifndef DEBUG_EXCEPTIONS --- 652,656 ---- delta = #endif ! ffi_call(&cif, (void *)pProc, resmem, avalues); #ifdef MS_WIN32 #ifndef DEBUG_EXCEPTIONS *************** *** 906,909 **** --- 907,916 ---- } + /* XXX If we have a structure as return value, the storage area that + 'result.value' provides may not be large enough. We should + probably create the result value (an instance of the structure + type) before the call, and use the instance's memory buffer as the + storage area. + */ result.ffi_type = GetType(restype); *************** *** 918,922 **** } ! if (-1 == _call_function_pointer(flags, pProc, avalues, atypes, &result, argcount)) goto cleanup; --- 925,930 ---- } ! if (-1 == _call_function_pointer(flags, pProc, avalues, atypes, ! result.ffi_type, &result.value, argcount)) goto cleanup; |
From: Thomas H. <th...@us...> - 2004-12-02 17:27:35
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9772 Modified Files: callproc.c Log Message: Removed unused PrepareResult function. Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.116 retrieving revision 1.117 diff -C2 -d -r1.116 -r1.117 *** callproc.c 4 Nov 2004 10:35:10 -0000 1.116 --- callproc.c 2 Dec 2004 17:27:19 -0000 1.117 *************** *** 16,19 **** --- 16,21 ---- How are functions called, and how are parameters converted to C ? + XXX to be rewritten..., no longer what happens! + 1. (in CFuncPtr_call) restype and converters are got from self or stgdict. 2. If it's a COM method, the COM pointer is retrieved from the argument list. *************** *** 696,730 **** /* - * Fill out the format field of 'result', depending on 'restype'. - */ - void PrepareResult(PyObject *restype, PyCArgObject *result) - { - StgDictObject *dict; - - if (restype == NULL) { - result->pffi_type = &ffi_type_sint; - return; - } - - dict = PyType_stgdict(restype); - if (dict && dict->getfunc) { - result->pffi_type = &dict->ffi_type; - return; - } - - if (PyCallable_Check(restype)) { - result->pffi_type = &ffi_type_sint; - return; - } - - if (restype == Py_None) { - result->pffi_type = &ffi_type_void; - return; - } - /* should not occurr */ - result->pffi_type = &ffi_type_sint; - } - - /* * Convert the C value in result into an instance described by restype */ --- 698,701 ---- |
From: Thomas H. <th...@us...> - 2004-12-02 16:03:30
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20970 Modified Files: test_functions.py Log Message: Fix a copy and paste error. Index: test_functions.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_functions.py,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** test_functions.py 2 Dec 2004 16:00:53 -0000 1.42 --- test_functions.py 2 Dec 2004 16:03:17 -0000 1.43 *************** *** 337,341 **** self.failUnlessEqual((s2h.x, s2h.y), (42, 24)) ! def test_struct_return_2H(self): class S8I(Structure): _fields_ = [("a", c_int), --- 337,341 ---- self.failUnlessEqual((s2h.x, s2h.y), (42, 24)) ! def test_struct_return_8H(self): class S8I(Structure): _fields_ = [("a", c_int), |
From: Thomas H. <th...@us...> - 2004-12-02 16:01:04
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20407 Modified Files: test_functions.py Log Message: Another test function which returns a structure, and a unittest for it. Currently fails on windows, at least. Index: test_functions.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_functions.py,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** test_functions.py 2 Dec 2004 15:53:47 -0000 1.41 --- test_functions.py 2 Dec 2004 16:00:53 -0000 1.42 *************** *** 329,333 **** self.failUnlessEqual(got, expected) ! def test_struct_return(self): class S2H(Structure): _fields_ = [("x", c_short), --- 329,333 ---- self.failUnlessEqual(got, expected) ! def test_struct_return_2H(self): class S2H(Structure): _fields_ = [("x", c_short), *************** *** 337,340 **** --- 337,355 ---- self.failUnlessEqual((s2h.x, s2h.y), (42, 24)) + def test_struct_return_2H(self): + class S8I(Structure): + _fields_ = [("a", c_int), + ("b", c_int), + ("c", c_int), + ("d", c_int), + ("e", c_int), + ("f", c_int), + ("g", c_int), + ("h", c_int)] + dll.ret_8i_func.restype = S8I + s8i = dll.ret_8i_func() + self.failUnlessEqual((s8i.a, s8i.b, s8i.c, s8i.d, s8i.e, s8i.f, s8i.g), + (1, 2, 3, 4, 5, 6, 7, 8)) + if __name__ == '__main__': unittest.main() |
From: Thomas H. <th...@us...> - 2004-12-02 16:00:53
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20331 Modified Files: _ctypes_test.c Log Message: Another test function which returns a structure, and a unittest for it. Currently fails on windows, at least. Index: _ctypes_test.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes_test.c,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** _ctypes_test.c 2 Dec 2004 15:53:35 -0000 1.38 --- _ctypes_test.c 2 Dec 2004 16:00:44 -0000 1.39 *************** *** 460,463 **** --- 460,473 ---- } + typedef struct { + int a, b, c, d, e, f, g, h; + } S8I; + + EXPORT(S8I) ret_8i_func(void) + { + S8I s8i = {1, 2, 3, 4, 5, 6, 7, 8}; + return s8i; + } + DL_EXPORT(void) init_ctypes_test(void) |
From: Thomas H. <th...@us...> - 2004-12-02 15:53:58
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18765 Modified Files: test_functions.py Log Message: Added a test function which returns a structure, and a unittest for it. Currently fails on windows, at least. Index: test_functions.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_functions.py,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** test_functions.py 2 Dec 2004 10:15:52 -0000 1.40 --- test_functions.py 2 Dec 2004 15:53:47 -0000 1.41 *************** *** 329,332 **** --- 329,340 ---- self.failUnlessEqual(got, expected) + def test_struct_return(self): + class S2H(Structure): + _fields_ = [("x", c_short), + ("y", c_short)] + dll.ret_2h_func.restype = S2H + s2h = dll.ret_2h_func() + self.failUnlessEqual((s2h.x, s2h.y), (42, 24)) + if __name__ == '__main__': unittest.main() |
From: Thomas H. <th...@us...> - 2004-12-02 15:53:44
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18716 Modified Files: _ctypes_test.c Log Message: Added a test function which returns a structure, and a unittest for it. Currently fails on windows, at least. Index: _ctypes_test.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes_test.c,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** _ctypes_test.c 28 Oct 2004 18:44:15 -0000 1.37 --- _ctypes_test.c 2 Dec 2004 15:53:35 -0000 1.38 *************** *** 446,449 **** --- 446,463 ---- } + typedef struct { + short x; + short y; + } S2H; + + EXPORT(S2H) ret_2h_func(void) + { + S2H s2h; + s2h.x = 42; + s2h.y = 24; + + return s2h; + } + DL_EXPORT(void) init_ctypes_test(void) |
From: Thomas H. <th...@us...> - 2004-12-02 13:11:40
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14253 Modified Files: test_structures.py Log Message: Add structure size test for delayed fields assignment. Index: test_structures.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_structures.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** test_structures.py 2 Dec 2004 08:05:05 -0000 1.28 --- test_structures.py 2 Dec 2004 13:11:30 -0000 1.29 *************** *** 17,25 **** self.failUnlessEqual(sizeof(Y), sizeof(c_int)*2) self.failUnlessEqual(sizeof(Z), sizeof(c_int)) - self.failUnlessEqual(X._fields_, [("a", c_int)]) - self.failUnlessEqual(Y._fields_, [("b", c_int)]) self.failUnlessEqual(Z._fields_, [("a", c_int)]) --- 17,43 ---- self.failUnlessEqual(sizeof(Y), sizeof(c_int)*2) self.failUnlessEqual(sizeof(Z), sizeof(c_int)) self.failUnlessEqual(X._fields_, [("a", c_int)]) self.failUnlessEqual(Y._fields_, [("b", c_int)]) + self.failUnlessEqual(Z._fields_, [("a", c_int)]) + + def test_subclass_delayed(self): + class X(Structure): + pass + self.failUnlessEqual(sizeof(X), 0) + X._fields_ = [("a", c_int)] + + class Y(X): + pass + self.failUnlessEqual(sizeof(Y), sizeof(X)) + Y._fields_ = [("b", c_int)] + + class Z(X): + pass + self.failUnlessEqual(sizeof(X), sizeof(c_int)) + self.failUnlessEqual(sizeof(Y), sizeof(c_int)*2) + self.failUnlessEqual(sizeof(Z), sizeof(c_int)) + self.failUnlessEqual(X._fields_, [("a", c_int)]) + self.failUnlessEqual(Y._fields_, [("b", c_int)]) self.failUnlessEqual(Z._fields_, [("a", c_int)]) |
From: Thomas H. <th...@us...> - 2004-12-02 12:56:27
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10876 Modified Files: xml2py.py Log Message: Added --dll and --windows-dlls options. Index: xml2py.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/xml2py.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** xml2py.py 23 Nov 2004 20:05:57 -0000 1.1 --- xml2py.py 2 Dec 2004 12:56:16 -0000 1.2 *************** *** 6,13 **** ################################################################ ! def main(): from optparse import OptionParser parser = OptionParser("usage: %prog [options] xmlfile") parser.add_option("-s", dest="symbols", --- 6,26 ---- ################################################################ ! def main(args=None): ! if args is None: ! args = sys.argv from optparse import OptionParser + def windows_dlls(option, opt, value, parser): + parser.values.dlls.extend("kernel32 gdi32 user32".split()) + parser = OptionParser("usage: %prog [options] xmlfile") + parser.add_option("--windows-dlls", + action="callback", + callback=windows_dlls, + help="add all standard windows dlls") + parser.add_option("--dll", + dest="dlls", + action="append", + default=[]) parser.add_option("-s", dest="symbols", *************** *** 16,31 **** default=None) parser.add_option("-o", ! dest="python_file", help="output filename (if not specified, standard output will be used)", default="-") ! options, files = parser.parse_args() if len(files) != 1: ! parser.error("Only one input file can be specified") ! if options.python_file == "-": stream = sys.stdout else: ! stream = open(options.python_file, "w") generate_code(files[0], stream, symbols=options.symbols) --- 29,44 ---- default=None) parser.add_option("-o", ! dest="output", help="output filename (if not specified, standard output will be used)", default="-") ! options, files = parser.parse_args(args[1:]) if len(files) != 1: ! parser.error("Exactly one input file must be specified") ! if options.output == "-": stream = sys.stdout else: ! stream = open(options.output, "w") generate_code(files[0], stream, symbols=options.symbols) *************** *** 33,42 **** if __name__ == "__main__": ! import sys ! if len(sys.argv) == 1: ! ## sys.argv.append("win32.xml") ! ## sys.argv.append("-sCoCreateInstance") ! sys.argv.append("win32.xml") ! sys.argv.append("-sCLSIDFromString,StringFromGUID2,IsEqualGUID") ! ## sys.argv.append("-owin32.py") ! main() --- 46,48 ---- if __name__ == "__main__": ! sys.exit(main()) |
From: Thomas H. <th...@us...> - 2004-12-02 12:55:47
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10697 Modified Files: h2xml.py Log Message: Add -I option. Index: h2xml.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/h2xml.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** h2xml.py 23 Nov 2004 20:05:57 -0000 1.1 --- h2xml.py 2 Dec 2004 12:55:36 -0000 1.2 *************** *** 66,69 **** --- 66,70 ---- action="store_true", default=False) + parser.add_option("-D", type="string", *************** *** 80,83 **** --- 81,93 ---- help="macros to undefine", metavar="defines") + + parser.add_option("-I", + type="string", + action="callback", + callback=add_option, + dest="gccxml_options", + help="include directories", + metavar="defines") + parser.add_option("-o", dest="xml_file", |
From: Thomas H. <th...@us...> - 2004-12-02 12:55:03
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10563 Modified Files: codegenerator.py Log Message: Better formatting for statistics output. Index: codegenerator.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/codegenerator.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** codegenerator.py 25 Nov 2004 09:05:25 -0000 1.2 --- codegenerator.py 2 Dec 2004 12:54:50 -0000 1.3 *************** *** 420,438 **** def print_stats(self, stream): ! print >> stream, "######################" print >> stream, "# Symbols defined:" print >> stream, "#" ! print >> stream, "# Struct/Unions: %5d" % self._structures ! print >> stream, "# Functions: %5d" % self._functiontypes ! print >> stream, "# Enums: %5d" % self._enumtypes ! print >> stream, "# Typedefs: %5d" % self._typedefs ! print >> stream, "# Pointertypes: %5d" % self._pointertypes ! print >> stream, "# Arraytypes: %5d" % self._arraytypes ! print >> stream, "# Functions not located: %5d" % self._notfound_functiontypes print >> stream, "#" total = self._structures + self._functiontypes + self._enumtypes + self._typedefs +\ self._pointertypes + self._arraytypes print >> stream, "# Total symbols: %5d" % total ! print >> stream, "######################" ################################################################ --- 420,438 ---- def print_stats(self, stream): ! print >> stream, "###########################" print >> stream, "# Symbols defined:" print >> stream, "#" ! print >> stream, "# Struct/Unions: %5d" % self._structures ! print >> stream, "# Functions: %5d" % self._functiontypes ! print >> stream, "# Enums: %5d" % self._enumtypes ! print >> stream, "# Typedefs: %5d" % self._typedefs ! print >> stream, "# Pointertypes: %5d" % self._pointertypes ! print >> stream, "# Arraytypes: %5d" % self._arraytypes ! print >> stream, "# unknown functions: %5d" % self._notfound_functiontypes print >> stream, "#" total = self._structures + self._functiontypes + self._enumtypes + self._typedefs +\ self._pointertypes + self._arraytypes print >> stream, "# Total symbols: %5d" % total ! print >> stream, "###########################" ################################################################ |
From: Thomas H. <th...@us...> - 2004-12-02 12:53:59
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10330 Modified Files: _support.py Log Message: Preserve the docstring when decorating a function. Index: _support.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/_support.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** _support.py 12 Nov 2004 07:57:15 -0000 1.3 --- _support.py 2 Dec 2004 12:53:46 -0000 1.4 *************** *** 41,51 **** d = {} exec code_string in d ! func = d[func.func_name] func_globals = {"_api_": call_api} ! func_globals.update(func.func_globals) ! return new.function(func.func_code, ! func_globals, ! func.func_name, ! func.func_defaults) def STDCALL(dllname, restype, funcname, argtypes): --- 41,55 ---- d = {} exec code_string in d ! wrapped_func = d[func.func_name] ! else: ! wrapped_func = func func_globals = {"_api_": call_api} ! func_globals.update(wrapped_func.func_globals) ! f = new.function(wrapped_func.func_code, ! func_globals, ! wrapped_func.func_name, ! wrapped_func.func_defaults) ! f.__doc__ = func.func_doc ! return f def STDCALL(dllname, restype, funcname, argtypes): |
From: Thomas H. <th...@us...> - 2004-12-02 10:22:48
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6503 Modified Files: _ctypes.c Log Message: Add explicit braces to avoid a gcc compiler warning. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.190 retrieving revision 1.191 diff -C2 -d -r1.190 -r1.191 *** _ctypes.c 1 Dec 2004 12:35:06 -0000 1.190 --- _ctypes.c 2 Dec 2004 10:22:21 -0000 1.191 *************** *** 1582,1586 **** while (self->b_base) self = self->b_base; ! if (self->b_objects == NULL) if (self->b_length) { self->b_objects = PyDict_New(); --- 1582,1586 ---- while (self->b_base) self = self->b_base; ! if (self->b_objects == NULL) { if (self->b_length) { self->b_objects = PyDict_New(); *************** *** 1589,1592 **** --- 1589,1593 ---- self->b_objects = Py_None; } + } return self; } |
From: Thomas H. <th...@us...> - 2004-12-02 10:16:04
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5311 Modified Files: test_functions.py Log Message: *** empty log message *** Index: test_functions.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_functions.py,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** test_functions.py 22 Oct 2004 19:33:52 -0000 1.39 --- test_functions.py 2 Dec 2004 10:15:52 -0000 1.40 *************** *** 146,150 **** result = f(1, 2, 3, 4, 5.0, 6.0) self.failUnlessEqual(result, 21) - self.failUnlessEqual(type(result), long) f = dll._testfunc_q_bhilfdq --- 146,149 ---- *************** *** 153,157 **** result = f(1, 2, 3, 4, 5.0, 6.0, 21) self.failUnlessEqual(result, 42) - self.failUnlessEqual(type(result), long) def test_stringresult(self): --- 152,155 ---- *************** *** 292,296 **** def callback(value): ! self.failUnlessEqual(type(value), long) return value & 0x7FFFFFFF --- 290,294 ---- def callback(value): ! self.failUnless(isinstance(value, (int, long))) return value & 0x7FFFFFFF |
From: Thomas H. <th...@us...> - 2004-12-02 09:54:13
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv591 Modified Files: test_parameters.py test_bitfields.py Log Message: Make c_int/c_uint aliases for c_long/c_ulong, and c_longlong/c_ulonglong for c_long/c_ulong where appropriate. Index: test_parameters.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_parameters.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** test_parameters.py 12 Oct 2004 13:57:54 -0000 1.26 --- test_parameters.py 2 Dec 2004 09:53:48 -0000 1.27 *************** *** 72,76 **** self.failUnlessEqual(LPINT.from_param(None), 0) ! self.assertRaises(TypeError, LPINT.from_param, pointer(c_long(42))) self.assertRaises(TypeError, LPINT.from_param, pointer(c_uint(42))) self.assertRaises(TypeError, LPINT.from_param, pointer(c_short(42))) --- 72,77 ---- self.failUnlessEqual(LPINT.from_param(None), 0) ! if c_int != c_long: ! self.assertRaises(TypeError, LPINT.from_param, pointer(c_long(42))) self.assertRaises(TypeError, LPINT.from_param, pointer(c_uint(42))) self.assertRaises(TypeError, LPINT.from_param, pointer(c_short(42))) *************** *** 85,89 **** self.assertRaises(TypeError, LPINT.from_param, byref(c_short(22))) ! self.assertRaises(TypeError, LPINT.from_param, byref(c_long(22))) self.assertRaises(TypeError, LPINT.from_param, byref(c_uint(22))) --- 86,91 ---- self.assertRaises(TypeError, LPINT.from_param, byref(c_short(22))) ! if c_int != c_long: ! self.assertRaises(TypeError, LPINT.from_param, byref(c_long(22))) self.assertRaises(TypeError, LPINT.from_param, byref(c_uint(22))) *************** *** 96,100 **** self.assertRaises(TypeError, LPLPINT.from_param, byref(pointer(c_short(22)))) ! self.assertRaises(TypeError, LPLPINT.from_param, byref(pointer(c_long(22)))) self.assertRaises(TypeError, LPLPINT.from_param, byref(pointer(c_uint(22)))) --- 98,103 ---- self.assertRaises(TypeError, LPLPINT.from_param, byref(pointer(c_short(22)))) ! if c_int != c_long: ! self.assertRaises(TypeError, LPLPINT.from_param, byref(pointer(c_long(22)))) self.assertRaises(TypeError, LPLPINT.from_param, byref(pointer(c_uint(22)))) Index: test_bitfields.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_bitfields.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_bitfields.py 19 Oct 2004 15:09:57 -0000 1.6 --- test_bitfields.py 2 Dec 2004 09:53:48 -0000 1.7 *************** *** 121,126 **** self.failUnlessEqual(result, (TypeError, 'bit fields not allowed for type c_void_p')) ! result = self.fail_fields(("a", POINTER(c_int), 1)) ! self.failUnlessEqual(result, (TypeError, 'bit fields not allowed for type LP_c_int')) result = self.fail_fields(("a", c_char, 1)) --- 121,127 ---- self.failUnlessEqual(result, (TypeError, 'bit fields not allowed for type c_void_p')) ! if c_int != c_long: ! result = self.fail_fields(("a", POINTER(c_int), 1)) ! self.failUnlessEqual(result, (TypeError, 'bit fields not allowed for type LP_c_int')) result = self.fail_fields(("a", c_char, 1)) |
From: Thomas H. <th...@us...> - 2004-12-02 09:53:52
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv562 Modified Files: __init__.py Log Message: Make c_int/c_uint aliases for c_long/c_ulong, and c_longlong/c_ulonglong for c_long/c_ulong where appropriate. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/__init__.py,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** __init__.py 29 Oct 2004 19:08:03 -0000 1.48 --- __init__.py 2 Dec 2004 09:53:39 -0000 1.49 *************** *** 18,21 **** --- 18,23 ---- from _ctypes import ArgumentError + from struct import calcsize as _calcsize + if __version__ != _ctypes_version: raise Exception, ("Version number mismatch", __version__, _ctypes_version) *************** *** 114,127 **** return "c_ushort(%d)" % self.value - class c_int(_SimpleCData): - _type_ = "i" - def __repr__(self): - return "c_int(%d)" % self.value - - class c_uint(_SimpleCData): - _type_ = "I" - def __repr__(self): - return "c_uint(%d)" % self.value - class c_long(_SimpleCData): _type_ = "l" --- 116,119 ---- *************** *** 134,137 **** --- 126,144 ---- return "c_ulong(%d)" % self.value + if _calcsize("i") == _calcsize("l"): + # if int and long have the same size, make c_int an alias for c_long + c_int = c_long + c_uint = c_ulong + else: + class c_int(_SimpleCData): + _type_ = "i" + def __repr__(self): + return "c_int(%d)" % self.value + + class c_uint(_SimpleCData): + _type_ = "I" + def __repr__(self): + return "c_uint(%d)" % self.value + class c_float(_SimpleCData): _type_ = "f" *************** *** 143,159 **** def __repr__(self): return "%s(%f)" % (self.__class__.__name__, self.value) - - class c_longlong(_SimpleCData): - _type_ = "q" - def __repr__(self): - return "c_longlong(%s)" % self.value ! class c_ulonglong(_SimpleCData): ! _type_ = "Q" ! def __repr__(self): ! return "c_ulonglong(%s)" % self.value ! ## def from_param(cls, val): ! ## return ('d', float(val), val) ! ## from_param = classmethod(from_param) class c_ubyte(_SimpleCData): --- 150,171 ---- def __repr__(self): return "%s(%f)" % (self.__class__.__name__, self.value) ! if _calcsize("l") == _calcsize("q"): ! # if long and long long have the same size, make c_longlong an alias for c_long ! c_longlong = c_long ! c_ulonglong = c_ulong ! else: ! class c_longlong(_SimpleCData): ! _type_ = "q" ! def __repr__(self): ! return "c_longlong(%s)" % self.value ! ! class c_ulonglong(_SimpleCData): ! _type_ = "Q" ! def __repr__(self): ! return "c_ulonglong(%s)" % self.value ! ## def from_param(cls, val): ! ## return ('d', float(val), val) ! ## from_param = classmethod(from_param) class c_ubyte(_SimpleCData): |
From: Thomas H. <th...@us...> - 2004-12-02 09:53:40
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv530 Modified Files: ChangeLog Log Message: Make c_int/c_uint aliases for c_long/c_ulong, and c_longlong/c_ulonglong for c_long/c_ulong where appropriate. Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** ChangeLog 2 Dec 2004 08:06:57 -0000 1.72 --- ChangeLog 2 Dec 2004 09:53:30 -0000 1.73 *************** *** 3,7 **** * (Message): The _fields_ attribute is now handled correctly in Structure sub-subclasses. It is extended instead of replaced. ! 2004-12-01 Thomas Heller <th...@py...> --- 3,12 ---- * (Message): The _fields_ attribute is now handled correctly in Structure sub-subclasses. It is extended instead of replaced. ! ! if 'sizeof(int) == sizeof(long)', c_int/c_uint are now aliases for ! c_long/c_ulong, and if 'sizeof(long) == sizeof(long long)', ! c_longlong/c_ulonglong are now aliases now for c_long/c_ulong. ! ! 2004-12-01 Thomas Heller <th...@py...> |
From: Thomas H. <th...@us...> - 2004-12-02 09:13:48
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24220 Modified Files: stgdict.c Log Message: Simplified and fixed the use_broken_old_ctypes_semantics hack. Index: stgdict.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/stgdict.c,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** stgdict.c 2 Dec 2004 08:00:00 -0000 1.27 --- stgdict.c 2 Dec 2004 09:13:38 -0000 1.28 *************** *** 183,198 **** */ int use_broken_old_ctypes_semantics; - PyObject *py_use_broken_old_ctypes_semantics; if (fields == NULL) return 0; ! py_use_broken_old_ctypes_semantics = \ ! PyObject_GetAttrString(type, "_use_broken_old_ctypes_structure_semantics_"); ! if (py_use_broken_old_ctypes_semantics) { ! use_broken_old_ctypes_semantics = 1; ! Py_DECREF(py_use_broken_old_ctypes_semantics); ! } else ! PyErr_Clear(); isPacked = PyObject_GetAttrString(type, "_pack_"); --- 183,192 ---- */ int use_broken_old_ctypes_semantics; if (fields == NULL) return 0; ! use_broken_old_ctypes_semantics = \ ! PyObject_HasAttrString(type, "_use_broken_old_ctypes_structure_semantics_"); isPacked = PyObject_GetAttrString(type, "_pack_"); |
From: Thomas H. <th...@us...> - 2004-12-02 08:07:06
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9008 Modified Files: ChangeLog Log Message: Inheritance of the _fields_ attribute now works correctly: It is possible to extend, but not replace the _fields_ attribute in Structure sub-subclasses. Added a strange hack to be able to still have the old behaviour. Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** ChangeLog 25 Nov 2004 11:04:27 -0000 1.71 --- ChangeLog 2 Dec 2004 08:06:57 -0000 1.72 *************** *** 1,2 **** --- 1,11 ---- + 2004-12-02 Thomas Heller <th...@py...> + + * (Message): The _fields_ attribute is now handled correctly in + Structure sub-subclasses. It is extended instead of replaced. + + 2004-12-01 Thomas Heller <th...@py...> + + * The annoying pointer bug has been fixed. + 2004-11-19 Thomas Heller <th...@py...> |
From: Thomas H. <th...@us...> - 2004-12-02 08:05:22
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8688 Modified Files: test_structures.py Log Message: Inheritance of the _fields_ attribute now works correctly: It is possible to extend, but not replace the _fields_ attribute in Structure sub-subclasses. Added a strange hack to be able to still have the old behaviour. Index: test_structures.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_structures.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** test_structures.py 30 Nov 2004 19:38:19 -0000 1.27 --- test_structures.py 2 Dec 2004 08:05:05 -0000 1.28 *************** *** 9,13 **** class Y(X): ! _fields_ = X._fields_ + [("b", c_int)] class Z(X): --- 9,13 ---- class Y(X): ! _fields_ = [("b", c_int)] class Z(X): *************** *** 18,29 **** self.failUnlessEqual(sizeof(Z), sizeof(c_int)) ! self.failUnlessEqual(X._fields_, ! [("a", c_int)]) ! self.failUnlessEqual(Y._fields_, ! [("a", c_int), ("b", c_int)]) ! self.failUnlessEqual(Z._fields_, ! [("a", c_int)]) class StructureTestCase(unittest.TestCase): --- 18,26 ---- self.failUnlessEqual(sizeof(Z), sizeof(c_int)) ! self.failUnlessEqual(X._fields_, [("a", c_int)]) ! self.failUnlessEqual(Y._fields_, [("b", c_int)]) ! self.failUnlessEqual(Z._fields_, [("a", c_int)]) class StructureTestCase(unittest.TestCase): |