ctypes-commit Mailing List for ctypes (Page 97)
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-08-20 14:20:21
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12092 Modified Files: _ctypes.c Log Message: Move some comments where they belong. _SimpleCData type now accepts an 'O' typecode. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.152 retrieving revision 1.153 diff -C2 -d -r1.152 -r1.153 *** _ctypes.c 18 Aug 2004 13:30:13 -0000 1.152 --- _ctypes.c 20 Aug 2004 14:20:10 -0000 1.153 *************** *** 923,927 **** */ ! static char *SIMPLE_TYPE_CHARS = "cbBhHiIlLdfuzZqQPX"; static PyObject * --- 923,927 ---- */ ! static char *SIMPLE_TYPE_CHARS = "cbBhHiIlLdfuzZqQPXO"; static PyObject * *************** *** 2171,2184 **** }; - /* - CFuncPtr_new accepts different argument lists in addition to the standard - _basespec_ keyword arg: - - "i" - function address - "sO" - function name, dll object (with an integer handle) - "is" - vtable index, method name, creates COM method pointers - "O" - must be a callable, creates a C callable function - */ - #ifdef MS_WIN32 static PPROC FindAddress(void *handle, char *name, PyObject *type) --- 2171,2174 ---- *************** *** 2294,2297 **** --- 2284,2296 ---- #endif + /* + CFuncPtr_new accepts different argument lists in addition to the standard + _basespec_ keyword arg: + + "i" - function address + "sO" - function name, dll object (with an integer handle) + "is" - vtable index, method name, creates COM method pointers + "O" - must be a callable, creates a C callable function + */ static PyObject * CFuncPtr_new(PyTypeObject *type, PyObject *args, PyObject *kwds) *************** *** 2421,2429 **** #ifdef MS_WIN32 - /* It's a COM method */ if (self->index) { CDataObject *this; this = (CDataObject *)PyTuple_GetItem(args, 0); if (!this || !CDataObject_Check(this)) { PyErr_SetString(PyExc_TypeError, "wrong type for this arg"); --- 2420,2429 ---- #ifdef MS_WIN32 if (self->index) { + /* It's a COM method */ CDataObject *this; this = (CDataObject *)PyTuple_GetItem(args, 0); if (!this || !CDataObject_Check(this)) { + /* XXX Better error msg when this == NULL */ PyErr_SetString(PyExc_TypeError, "wrong type for this arg"); *************** *** 2434,2438 **** if (!this->b_ptr || *(void **)this->b_ptr == NULL) { PyErr_SetString(PyExc_ValueError, ! "NULL pointer access"); return NULL; } --- 2434,2438 ---- if (!this->b_ptr || *(void **)this->b_ptr == NULL) { PyErr_SetString(PyExc_ValueError, ! "NULL COM pointer access"); return NULL; } *************** *** 3721,3724 **** --- 3721,3725 ---- #endif PyModule_AddObject(m, "FUNCFLAG_CDECL", PyInt_FromLong(FUNCFLAG_CDECL)); + PyModule_AddObject(m, "FUNCFLAG_PYTHONAPI", PyInt_FromLong(FUNCFLAG_PYTHONAPI)); PyModule_AddStringConstant(m, "__version__", "0.9.1"); |
From: Thomas H. <th...@us...> - 2004-08-20 14:10:12
|
Update of /cvsroot/ctypes/ctypes/win32/com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9785 Modified Files: server.py Log Message: Print at least *something* when run with an empty command line. Index: server.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/win32/com/server.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** server.py 16 Jul 2004 15:59:16 -0000 1.19 --- server.py 20 Aug 2004 14:10:03 -0000 1.20 *************** *** 252,255 **** --- 252,256 ---- opts, args = w_getopt(sys.argv[1:], "regserver unregserver embedding".split()) if not opts: + sys.stderr.write("Usage: %s [-regserver] [-unregserver]\n" % sys.argv[0]) return 0 # nothing for us to do |
From: Thomas H. <th...@us...> - 2004-08-19 13:49:58
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7335 Modified Files: ChangeLog ANNOUNCE Log Message: Changes. Index: ANNOUNCE =================================================================== RCS file: /cvsroot/ctypes/ctypes/ANNOUNCE,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ANNOUNCE 19 Aug 2004 11:27:23 -0000 1.6 --- ANNOUNCE 19 Aug 2004 13:49:36 -0000 1.7 *************** *** 38,41 **** --- 38,44 ---- distribution. + The alignment function was not exported by the ctypes module. It + returns the alignment requirements in bytes of a type or instance. + ctypes.com changes Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** ChangeLog 19 Aug 2004 11:27:23 -0000 1.49 --- ChangeLog 19 Aug 2004 13:49:36 -0000 1.50 *************** *** 1,4 **** --- 1,8 ---- 2004-08-19 Thomas Heller <th...@py...> + * (Message): the alignment function was not exported by the ctypes + module. It returns the alignment requirements in bytes of a type + or instance. + * source/callproc.c: The _ctypes.call_function function, although private and deprecated, has been put back in - it is used by Gary |
From: Thomas H. <th...@us...> - 2004-08-19 11:37:54
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14974 Modified Files: callproc.c Log Message: Fix a doc string. Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.95 retrieving revision 1.96 diff -C2 -d -r1.95 -r1.96 *** callproc.c 19 Aug 2004 11:24:52 -0000 1.95 --- callproc.c 19 Aug 2004 11:37:42 -0000 1.96 *************** *** 1154,1158 **** static char alignment_doc[] = ! "addressof(C instance) -> integer\nReturn the address of the C instance"; static char sizeof_doc[] = "sizeof(C type) -> integer\n" --- 1154,1160 ---- static char alignment_doc[] = ! "alignment(C type) -> integer\n" ! "alignment(C instance) -> integer\n" ! "Return the alignment requirements of a C instance"; static char sizeof_doc[] = "sizeof(C type) -> integer\n" *************** *** 1162,1166 **** static char byref_doc[] = "byref(C instance) -> byref-object\n" ! "Return a pointer lookalike to the C instance, only usable\n" "as function argument"; static char addressof_doc[] = --- 1164,1168 ---- static char byref_doc[] = "byref(C instance) -> byref-object\n" ! "Return a pointer lookalike to a C instance, only usable\n" "as function argument"; static char addressof_doc[] = |
From: Thomas H. <th...@us...> - 2004-08-19 11:35:03
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14190 Modified Files: test_structures.py test_numbers.py Log Message: The _ctypes.alignment function is now exposed by the ctypes module. Index: test_numbers.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_numbers.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** test_numbers.py 23 Jul 2004 14:24:50 -0000 1.20 --- test_numbers.py 19 Aug 2004 11:34:52 -0000 1.21 *************** *** 120,124 **** def test_alignments(self): - from _ctypes import alignment for t in signed_types + unsigned_types + float_types: code = t._type_ # the typecode --- 120,123 ---- Index: test_structures.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_structures.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** test_structures.py 22 Jul 2004 17:59:39 -0000 1.16 --- test_structures.py 19 Aug 2004 11:34:52 -0000 1.17 *************** *** 36,40 **** def test_struct_alignment(self): - from _ctypes import alignment class X(Structure): _fields_ = [("x", c_char * 3)] --- 36,39 ---- *************** *** 68,72 **** def test_emtpy(self): - from _ctypes import alignment # I had problems with these # --- 67,70 ---- |
From: Thomas H. <th...@us...> - 2004-08-19 11:34:53
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14143 Modified Files: __init__.py Log Message: The _ctypes.alignment function is now exposed by the ctypes module. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/__init__.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** __init__.py 18 Aug 2004 13:29:51 -0000 1.27 --- __init__.py 19 Aug 2004 11:34:44 -0000 1.28 *************** *** 106,110 **** _FreeLibrary = None ! from _ctypes import sizeof, byref, addressof from _ctypes import _SimpleCData --- 106,110 ---- _FreeLibrary = None ! from _ctypes import sizeof, byref, addressof, alignment from _ctypes import _SimpleCData |
From: Thomas H. <th...@us...> - 2004-08-19 11:32:14
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13580 Modified Files: test_random_things.py Log Message: Test for call_function. Index: test_random_things.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_random_things.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_random_things.py 22 Jul 2004 08:31:24 -0000 1.5 --- test_random_things.py 19 Aug 2004 11:31:56 -0000 1.6 *************** *** 6,9 **** --- 6,23 ---- raise ValueError, arg + if sys.platform == "win32": + + class call_function_TestCase(unittest.TestCase): + # _ctypes.call_function is deprecated and private, but used by + # Gary Bishp's readline module. If we have it, we must test it as well. + + def test(self): + from _ctypes import call_function + hdll = windll.kernel32.LoadLibraryA("kernel32") + funcaddr = windll.kernel32.GetProcAddress(hdll, "GetModuleHandleA") + + self.failUnlessEqual(call_function(funcaddr, (None,)), + windll.kernel32.GetModuleHandleA(None)) + class CallbackTracbackTestCase(unittest.TestCase): # When an exception is raised in a ctypes callback function, the C |
From: Thomas H. <th...@us...> - 2004-08-19 11:27:34
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12700 Modified Files: ChangeLog ANNOUNCE Log Message: Changes. Index: ANNOUNCE =================================================================== RCS file: /cvsroot/ctypes/ctypes/ANNOUNCE,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ANNOUNCE 18 Aug 2004 12:34:33 -0000 1.5 --- ANNOUNCE 19 Aug 2004 11:27:23 -0000 1.6 *************** *** 1,13 **** ! NOT YET! ctypes 0.9.1 released ===================== Overview ! ctypes is a ffi (Foreign Function Interface) package for Python. ! It allows to call functions exposed from dlls/shared libraries and ! has extensive facilities to create, access and manipulate simpole ! and complicated C data types transparently from Python - in other ! words: wrap libraries in pure Python. ctypes runs on Windows, MacOS X, Linux, Solaris, FreeBSD. It may --- 1,15 ---- ! ctypes 0.9.1 released ===================== Overview ! ctypes is a ffi (Foreign Function Interface) package for Python ! 2.3 and higher. ! ctypes allows to call functions exposed from dlls/shared libraries ! and has extensive facilities to create, access and manipulate ! simple and complicated C data types in Python - in other words: ! wrap libraries in pure Python. It is even possible to implement C ! callback functions in pure Python. ctypes runs on Windows, MacOS X, Linux, Solaris, FreeBSD. It may *************** *** 15,53 **** platform. ! ! Changes in 0.9.1 ! ! Array and pointer instances now support slicing, for pointer only ! getslice is implemented (setslice is too dangerous, probably). ! Slices are accepted or returned as lists of the elements, except ! for character and unicode character pointer and arrays, where ! strings resp. unicode strings are used - much more convenient. ! ! ctypes 0.9.0 released ! ===================== ! Changes in 0.9.0 ! ctypes now requires Python 2.3 or higher, Python 2.2 is no longer ! supported. ! The big change is that ctypes now uses the same code base on all ! platforms, many, many bug should have been fixed this way on ! non-windows systems. The destribution now contains libffi, no ! need to find, download, build and install a compatible version. ! There have been lots of improvements and additions both to ctypes ! itself, and to the ctypes.com windows framework, too many to ! remember now and document here. ! Most prominent additions to ctypes.com are: ! A ctypes.com.client module supporting dynamic dispatch ! An internet explorer toolband sample - Many improvements to the stoplite sample Detailed changelogs are in CVS (well, sometimes I forget to update --- 17,50 ---- platform. ! On windows, ctypes contains a ctypes.com package which allows to ! descrive, call, and implement custom com interfaces. ! Changes in 0.9.1 ! ctypes changes ! The _ctypes.call_function function, although private and ! deprecated, has been put back in - it is used by Gary Bishop's ! readline module. ! Array and pointer instances now support slicing, for pointers only ! getslice is implemented (setslice is too dangerous, probably). ! Slices are represented as lists of the elements, except ! for character and unicode character pointer and arrays, where ! strings resp. unicode strings are used instead. ! On windows, the include files were missing from the source ! distribution. ! ctypes.com changes ! VARIANT does now handle the COM DATE type (VT_DATE) as Python ! datetime. ! VARIANT now handles integers and longs - if longs are too large ! they are stored as doubles (VT_R8). Integers are now stored as ! VT_I4 instead of VT_INT. Detailed changelogs are in CVS (well, sometimes I forget to update *************** *** 81,86 **** Binary windows installers, which contain compiled extension modules, are also available, be sure to download the correct one ! for the ! Python version you are using. --- 78,82 ---- Binary windows installers, which contain compiled extension modules, are also available, be sure to download the correct one ! for the Python version you are using. Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** ChangeLog 19 Aug 2004 08:59:44 -0000 1.48 --- ChangeLog 19 Aug 2004 11:27:23 -0000 1.49 *************** *** 1,2 **** --- 1,8 ---- + 2004-08-19 Thomas Heller <th...@py...> + + * source/callproc.c: The _ctypes.call_function function, although + private and deprecated, has been put back in - it is used by Gary + Bishop's readline module. + 2004-08-18 Thomas Heller <th...@py...> |
From: Thomas H. <th...@us...> - 2004-08-19 11:25:03
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12328 Modified Files: callproc.c Log Message: call_function and call_cdeclfunction are back again. The former is used by Gary Bishop's readline module. Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.94 retrieving revision 1.95 diff -C2 -d -r1.94 -r1.95 *** callproc.c 18 Aug 2004 12:16:51 -0000 1.94 --- callproc.c 19 Aug 2004 11:24:52 -0000 1.95 *************** *** 556,560 **** ffi_type *GetType(PyObject *obj) { ! StgDictObject *dict = PyType_stgdict(obj); if (dict == NULL) return &ffi_type_sint; --- 556,563 ---- ffi_type *GetType(PyObject *obj) { ! StgDictObject *dict; ! if (obj == NULL) ! return &ffi_type_sint; ! dict = PyType_stgdict(obj); if (dict == NULL) return &ffi_type_sint; *************** *** 700,703 **** --- 703,710 ---- StgDictObject *dict; + if (restype == NULL) { + return getentry("i")->getfunc(&result->value.l, sizeof(int)); + } + assert(restype); *************** *** 1089,1092 **** --- 1096,1156 ---- #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; + + #ifdef _DEBUG + _asm int 3; + #endif + 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; + } + static char alignment_doc[] = "addressof(C instance) -> integer\nReturn the address of the C instance"; *************** *** 1122,1125 **** --- 1186,1191 ---- {"byref", byref, METH_O, byref_doc}, {"addressof", addressof, METH_O, addressof_doc}, + {"call_function", call_function, METH_VARARGS }, + {"call_cdeclfunction", call_cdeclfunction, METH_VARARGS }, {NULL, NULL} /* Sentinel */ }; |
From: Thomas H. <th...@us...> - 2004-08-19 10:22:45
|
Update of /cvsroot/ctypes/ctypes/win32/com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2318 Modified Files: ChangeLog Log Message: Changes. Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/win32/com/ChangeLog,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ChangeLog 19 Aug 2004 08:59:53 -0000 1.5 --- ChangeLog 19 Aug 2004 10:22:33 -0000 1.6 *************** *** 1,4 **** --- 1,7 ---- 2004-08-19 Thomas Heller <th...@py...> + * com/automation.py: VARIANT does now handle the COM DATE type + VT_DATE as Python datetime. + * com/automation.py: Integers in a VARIANT use the VT_I4 typecode instead of VT_INT. Python longs are converted to ints if possible, |
From: Thomas H. <th...@us...> - 2004-08-19 10:21:42
|
Update of /cvsroot/ctypes/ctypes/win32/com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2123 Modified Files: automation.py Log Message: VARIANT does now handle the COM DATE type (VT_DATE) as Python datetime. Index: automation.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/win32/com/automation.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** automation.py 19 Aug 2004 08:53:31 -0000 1.18 --- automation.py 19 Aug 2004 10:21:32 -0000 1.19 *************** *** 1,2 **** --- 1,4 ---- + import datetime + from ctypes import * from ctypes.wintypes import DWORD, WORD, LPOLESTR, LPCOLESTR, LCID *************** *** 325,328 **** --- 327,333 ---- self.value = args[0] + # 30. December 1899, midnight. + _com_null_date = datetime.datetime(1899, 12, 31, 0, 0, 0) + def _set_value(self, value): oleaut32.VariantClear(byref(self)) *************** *** 360,363 **** --- 365,374 ---- CopyComPointer(value, byref(self._)) self.vt = VT_UNKNOWN + elif typ is datetime.datetime: + delta = value - self._com_null_date + # a day has 24 * 60 * 60 = 86400 seconds + com_days = delta.days + (delta.seconds + delta.microseconds * 1e-6) / 86400. + self.vt = VT_DATE + self._.VT_R8 = com_days else: raise TypeError, "don't know how to store %r in a VARIANT" % value *************** *** 423,426 **** --- 434,441 ---- elif self.vt == VT_NULL: return None + elif self.vt == VT_DATE: + days = self._.VT_R8 + return datetime.timedelta(days=days) + self._com_null_date + raise "NYI" else: raise TypeError, "don't know how to convert typecode %d" % self.vt |
From: Thomas H. <th...@us...> - 2004-08-19 10:21:34
|
Update of /cvsroot/ctypes/ctypes/unittests/com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2095 Modified Files: test_variant.py Log Message: VARIANT does now handle the COM DATE type (VT_DATE) as Python datetime. Index: test_variant.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/com/test_variant.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_variant.py 19 Aug 2004 08:53:22 -0000 1.2 --- test_variant.py 19 Aug 2004 10:21:22 -0000 1.3 *************** *** 79,88 **** self.failUnlessEqual(type(v.value), int) ! ## def test_datetime(self): ! ## import datetime ! ## now = datetime.datetime.now() ! ## v = VARIANT() ! ## v.value = now ################################################################ --- 79,91 ---- self.failUnlessEqual(type(v.value), int) ! def test_datetime(self): ! import datetime ! now = datetime.datetime.now() ! v = VARIANT() ! v.value = now ! from ctypes.com.automation import VT_DATE ! self.failUnlessEqual(v.vt, VT_DATE) ! self.failUnlessEqual(v.value, now) ################################################################ |
From: Thomas H. <th...@us...> - 2004-08-19 09:00:03
|
Update of /cvsroot/ctypes/ctypes/win32/com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22935 Modified Files: ChangeLog Log Message: Changes. Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/win32/com/ChangeLog,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ChangeLog 28 Jul 2004 13:34:54 -0000 1.4 --- ChangeLog 19 Aug 2004 08:59:53 -0000 1.5 *************** *** 1,2 **** --- 1,8 ---- + 2004-08-19 Thomas Heller <th...@py...> + + * com/automation.py: Integers in a VARIANT use the VT_I4 typecode + instead of VT_INT. Python longs are converted to ints if possible, + if not they are stored as VT_R8. + 2004-07-28 Thomas Heller <th...@py...> |
From: Thomas H. <th...@us...> - 2004-08-19 08:59:53
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22903 Modified Files: ChangeLog Log Message: Changes. Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** ChangeLog 18 Aug 2004 12:34:33 -0000 1.47 --- ChangeLog 19 Aug 2004 08:59:44 -0000 1.48 *************** *** 8,11 **** --- 8,13 ---- convenient. + * MANIFEST.windows.in: Added the include files which were missing + from the source distribution. 2004-07-28 Thomas Heller <th...@py...> |
From: Thomas H. <th...@us...> - 2004-08-19 08:53:55
|
Update of /cvsroot/ctypes/ctypes/win32/com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22111 Modified Files: automation.py Log Message: Integers in a VARIANT use the VT_I4 typecode instead of VT_INT. Python longs are converted to ints if possible, if not they are stored as VT_R8. Index: automation.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/win32/com/automation.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** automation.py 18 Aug 2004 12:28:24 -0000 1.17 --- automation.py 19 Aug 2004 08:53:31 -0000 1.18 *************** *** 328,337 **** oleaut32.VariantClear(byref(self)) typ = type(value) if typ is int: ! self.vt = VT_INT ! self._.VT_INT = value ! elif typ is float: self.vt = VT_R8 ! self._.VT_R8 = value elif typ is str: self.vt = VT_BSTR --- 328,342 ---- oleaut32.VariantClear(byref(self)) typ = type(value) + if typ is long: + # try to convert to int + value = int(value) + typ = type(value) + if typ is int: ! self.vt = VT_I4 ! self._.VT_I4 = value ! elif typ in (float, long): self.vt = VT_R8 ! self._.VT_R8 = float(value) elif typ is str: self.vt = VT_BSTR |
From: Thomas H. <th...@us...> - 2004-08-19 08:53:34
|
Update of /cvsroot/ctypes/ctypes/unittests/com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22077 Modified Files: test_variant.py Log Message: Integers in a VARIANT use the VT_I4 typecode instead of VT_INT. Python longs are converted to ints if possible, if not they are stored as VT_R8. Index: test_variant.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/com/test_variant.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_variant.py 22 Jul 2004 08:10:42 -0000 1.1 --- test_variant.py 19 Aug 2004 08:53:22 -0000 1.2 *************** *** 1,4 **** --- 1,6 ---- import unittest, os from ctypes import * + from ctypes.com import IUnknown, GUID + from ctypes.com.automation import VARIANT, LoadTypeLibEx, DISPPARAMS, LoadRegTypeLib def get_refcnt(comptr): *************** *** 9,74 **** return comptr.Release() ! if os.name == "nt": ! class VariantTestCase(unittest.TestCase): ! def __init__(self, *args): ! # We cannot import these at module level, but want these to be ! # available in the global namespace ! global IUnknown, VARIANT, LoadTypeLibEx, DISPPARAMS, LoadRegTypeLib, GUID ! from ctypes.com import IUnknown, GUID ! from ctypes.com.automation import VARIANT, LoadTypeLibEx, DISPPARAMS, LoadRegTypeLib ! unittest.TestCase.__init__(self, *args) ! def test_com_refcounts(self): ! # typelib for Internet Explorer ! tlb = LoadRegTypeLib(GUID("{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}"), 1, 1, 0) ! self.failUnlessEqual(get_refcnt(tlb), 1) ! p = POINTER(IUnknown)() ! tlb.QueryInterface(byref(IUnknown._iid_), byref(p)) ! self.failUnlessEqual(get_refcnt(tlb), 2) ! del p ! self.failUnlessEqual(get_refcnt(tlb), 1) ! def test_com_pointers(self): ! ## """Storing a COM interface pointer in a VARIANT increments the refcount, ! ## changing the variant to contain something else decrements it""" ! tlb = LoadRegTypeLib(GUID("{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}"), 1, 1, 0) ! self.failUnlessEqual(get_refcnt(tlb), 1) ! v = VARIANT(tlb) ! self.failUnlessEqual(get_refcnt(tlb), 2) ! p = v.value ! self.failUnlessEqual(get_refcnt(tlb), 3) ! del p ! self.failUnlessEqual(get_refcnt(tlb), 2) ! v.value = None ! self.failUnlessEqual(get_refcnt(tlb), 1) ! def test_null_com_pointers(self): ! p = POINTER(IUnknown)() ! self.failUnlessEqual(get_refcnt(p), 0) ! v = VARIANT(p) ! self.failUnlessEqual(get_refcnt(p), 0) ! def test_dispparams(self): ! # DISPPARAMS is a complex structure, well worth testing. ! d = DISPPARAMS() ! d.rgvarg = (VARIANT * 3)() ! # XXX The following line fails, which is a real bug in ctypes: ! # SystemError: ...\Objects\listobject.c:105: bad argument to internal function ! ## d.rgvarg[0].value = 1 ! def test_pythonobjects(self): ! objects = [None, 42, 3.14, True, False, "abc", u"abc"] ! for x in objects: ! v = VARIANT(x) ! self.failUnlessEqual(x, v.value) ################################################################ --- 11,88 ---- return comptr.Release() ! class VariantTestCase(unittest.TestCase): ! def test_com_refcounts(self): ! # typelib for Internet Explorer ! tlb = LoadRegTypeLib(GUID("{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}"), 1, 1, 0) ! self.failUnlessEqual(get_refcnt(tlb), 1) ! p = POINTER(IUnknown)() ! tlb.QueryInterface(byref(IUnknown._iid_), byref(p)) ! self.failUnlessEqual(get_refcnt(tlb), 2) ! del p ! self.failUnlessEqual(get_refcnt(tlb), 1) ! def test_com_pointers(self): ! # Storing a COM interface pointer in a VARIANT increments the refcount, ! # changing the variant to contain something else decrements it ! tlb = LoadRegTypeLib(GUID("{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}"), 1, 1, 0) ! self.failUnlessEqual(get_refcnt(tlb), 1) + v = VARIANT(tlb) + self.failUnlessEqual(get_refcnt(tlb), 2) ! p = v.value ! self.failUnlessEqual(get_refcnt(tlb), 3) ! del p ! self.failUnlessEqual(get_refcnt(tlb), 2) ! v.value = None ! self.failUnlessEqual(get_refcnt(tlb), 1) ! def test_null_com_pointers(self): ! p = POINTER(IUnknown)() ! self.failUnlessEqual(get_refcnt(p), 0) ! v = VARIANT(p) ! self.failUnlessEqual(get_refcnt(p), 0) + def test_dispparams(self): + # DISPPARAMS is a complex structure, well worth testing. + d = DISPPARAMS() + d.rgvarg = (VARIANT * 3)() + # XXX The following line fails, which is a real bug in ctypes: + # SystemError: ...\Objects\listobject.c:105: bad argument to internal function + ## d.rgvarg[0].value = 1 ! def test_pythonobjects(self): ! objects = [None, 42, 3.14, True, False, "abc", u"abc", 7L] ! for x in objects: ! v = VARIANT(x) ! self.failUnlessEqual(x, v.value) ! def test_integers(self): ! import sys ! v = VARIANT() ! v.value = sys.maxint ! self.failUnlessEqual(v.value, sys.maxint) ! self.failUnlessEqual(type(v.value), int) ! v.value += 1 ! self.failUnlessEqual(v.value, sys.maxint+1) ! self.failUnlessEqual(type(v.value), float) ! ! v.value = 1L ! self.failUnlessEqual(v.value, 1) ! self.failUnlessEqual(type(v.value), int) ! ! ## def test_datetime(self): ! ## import datetime ! ## now = datetime.datetime.now() ! ! ## v = VARIANT() ! ## v.value = now ################################################################ |
From: Thomas H. <th...@us...> - 2004-08-18 23:12:00
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28782 Modified Files: NEWS.txt ChangeLog ANNOUNCE Log Message: Record changes. Index: ANNOUNCE =================================================================== RCS file: /cvsroot/ctypes/ctypes/ANNOUNCE,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ANNOUNCE 23 Jul 2004 17:41:42 -0000 1.4 --- ANNOUNCE 18 Aug 2004 12:34:33 -0000 1.5 *************** *** 1,4 **** ! ! ctypes 0.9.0 released ===================== --- 1,3 ---- ! NOT YET! ctypes 0.9.1 released ===================== *************** *** 17,20 **** --- 16,32 ---- + Changes in 0.9.1 + + Array and pointer instances now support slicing, for pointer only + getslice is implemented (setslice is too dangerous, probably). + Slices are accepted or returned as lists of the elements, except + for character and unicode character pointer and arrays, where + strings resp. unicode strings are used - much more convenient. + + + + ctypes 0.9.0 released + ===================== + Changes in 0.9.0 Index: NEWS.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/NEWS.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NEWS.txt 7 Feb 2003 18:58:26 -0000 1.3 --- NEWS.txt 18 Aug 2004 12:34:33 -0000 1.4 *************** *** 1,4 **** --- 1,14 ---- ctypes News - http://starship.python.net/crew/theller/ctypes.html + Version 0.9.1 + + Array and POINTER instance now support slicing, for POINTER only + getslice is implemented (setslice is too dangerous, probably). + Slices are accepted or returned as lists of the elements, except + for character and unicode character pointer and arrays, where + strings resp. unicode strings are used - much more convenient. + + Other Versions: no news recorded in this file! + Version 0.4.0, 2003-02-07: Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** ChangeLog 28 Jul 2004 12:53:03 -0000 1.46 --- ChangeLog 18 Aug 2004 12:34:33 -0000 1.47 *************** *** 1,2 **** --- 1,12 ---- + 2004-08-18 Thomas Heller <th...@py...> + + * (Message): Array and POINTER instance now support slicing, for + POINTER only getslice is implemented (setslice is too dangerous, + probably). Slices are accepted or returned as lists of the + elements, except for character and unicode character pointer and + arrays, where strings resp. unicode strings are used - much more + convenient. + + 2004-07-28 Thomas Heller <th...@py...> |
From: Thomas H. <th...@us...> - 2004-08-18 13:47:44
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12556 Modified Files: MANIFEST.windows.in Log Message: The include files were missing in the (windows) source distro. Index: MANIFEST.windows.in =================================================================== RCS file: /cvsroot/ctypes/ctypes/MANIFEST.windows.in,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MANIFEST.windows.in 23 Jul 2004 13:39:17 -0000 1.3 --- MANIFEST.windows.in 18 Aug 2004 13:47:35 -0000 1.4 *************** *** 1,5 **** --- 1,7 ---- include MANIFEST MANIFEST.windows.in LICENSE.txt NEWS.txt README* include run_remote_test.py + include ctypes/.CTYPES_DEVEL + include source/ctypes.h source/libffi_msvc/*.h recursive-include unittests *.py |
From: Thomas H. <th...@us...> - 2004-08-18 13:30:23
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9453 Modified Files: _ctypes.c Log Message: Bump version number. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.151 retrieving revision 1.152 diff -C2 -d -r1.151 -r1.152 *** _ctypes.c 18 Aug 2004 12:23:18 -0000 1.151 --- _ctypes.c 18 Aug 2004 13:30:13 -0000 1.152 *************** *** 3721,3725 **** #endif PyModule_AddObject(m, "FUNCFLAG_CDECL", PyInt_FromLong(FUNCFLAG_CDECL)); ! PyModule_AddStringConstant(m, "__version__", "0.9.0"); /************************************************* --- 3721,3725 ---- #endif PyModule_AddObject(m, "FUNCFLAG_CDECL", PyInt_FromLong(FUNCFLAG_CDECL)); ! PyModule_AddStringConstant(m, "__version__", "0.9.1"); /************************************************* |
From: Thomas H. <th...@us...> - 2004-08-18 13:30:03
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9424 Modified Files: __init__.py Log Message: Bump version number. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/__init__.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** __init__.py 22 Jul 2004 13:47:53 -0000 1.26 --- __init__.py 18 Aug 2004 13:29:51 -0000 1.27 *************** *** 9,13 **** del os, _magicfile ! __version__ = "0.9.0" from _ctypes import Union, Structure, Array --- 9,13 ---- del os, _magicfile ! __version__ = "0.9.1" from _ctypes import Union, Structure, Array |
From: Thomas H. <th...@us...> - 2004-08-18 13:29:21
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9307 Modified Files: setup.py Log Message: Bump version number, remove unneeded __future__ import. Index: setup.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/setup.py,v retrieving revision 1.101 retrieving revision 1.102 diff -C2 -d -r1.101 -r1.102 *** setup.py 28 Jul 2004 12:46:32 -0000 1.101 --- setup.py 18 Aug 2004 13:29:12 -0000 1.102 *************** *** 10,18 **** """ - from __future__ import generators - LIBFFI_SOURCES='source/gcc/libffi' ! __version__ = "0.9.0" ################################################################ --- 10,16 ---- """ LIBFFI_SOURCES='source/gcc/libffi' ! __version__ = "0.9.1" ################################################################ |
From: Thomas H. <th...@us...> - 2004-08-18 12:58:42
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1772 Modified Files: test_slicing.py Log Message: Use functions in the test library, instead of msvcrt. Index: test_slicing.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_slicing.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_slicing.py 18 Aug 2004 12:48:12 -0000 1.1 --- test_slicing.py 18 Aug 2004 12:58:32 -0000 1.2 *************** *** 2,5 **** --- 2,16 ---- from ctypes import * + def find_test_dll(): + import sys, os + if os.name == "nt": + name = "_ctypes_test.pyd" + else: + name = "_ctypes_test.so" + for p in sys.path: + f = os.path.join(p, name) + if os.path.isfile(f): + return f + class SlicesTestCase(unittest.TestCase): def test_getslice_cint(self): *************** *** 36,41 **** s = "abcdefghijklmnopqrstuvwxyz\0" ! cdll.msvcrt._strdup.restype = POINTER(c_char) ! res = cdll.msvcrt._strdup(s) self.failUnlessEqual(res[:len(s)], s) --- 47,53 ---- s = "abcdefghijklmnopqrstuvwxyz\0" ! dll = CDLL(find_test_dll()) ! dll.my_strdup.restype = POINTER(c_char) ! res = dll.my_strdup(s) self.failUnlessEqual(res[:len(s)], s) *************** *** 44,49 **** res, 0, 5, u"abcde") ! cdll.msvcrt._strdup.restype = POINTER(c_byte) ! res = cdll.msvcrt._strdup(s) self.failUnlessEqual(res[:len(s)-1], range(ord("a"), ord("z")+1)) --- 56,61 ---- res, 0, 5, u"abcde") ! dll.my_strdup.restype = POINTER(c_byte) ! res = dll.my_strdup(s) self.failUnlessEqual(res[:len(s)-1], range(ord("a"), ord("z")+1)) *************** *** 63,68 **** s = u"abcdefghijklmnopqrstuvwxyz\0" ! cdll.msvcrt._wcsdup.restype = POINTER(c_wchar) ! res = cdll.msvcrt._wcsdup(s) self.failUnlessEqual(res[:len(s)], s) --- 75,81 ---- s = u"abcdefghijklmnopqrstuvwxyz\0" ! dll = CDLL(find_test_dll()) ! dll.my_wcsdup.restype = POINTER(c_wchar) ! res = dll.my_wcsdup(s) self.failUnlessEqual(res[:len(s)], s) *************** *** 71,76 **** res, 0, 5, u"abcde") ! cdll.msvcrt._wcsdup.restype = POINTER(c_short) ! res = cdll.msvcrt._wcsdup(s) self.failUnlessEqual(res[:len(s)-1], range(ord("a"), ord("z")+1)) --- 84,89 ---- res, 0, 5, u"abcde") ! dll.my_wcsdup.restype = POINTER(c_short) ! res = dll.my_wcsdup(s) self.failUnlessEqual(res[:len(s)-1], range(ord("a"), ord("z")+1)) |
From: Thomas H. <th...@us...> - 2004-08-18 12:58:03
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1573 Modified Files: _ctypes_test.c Log Message: strdup and wcsdup exported functions. Index: _ctypes_test.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes_test.c,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** _ctypes_test.c 23 Jun 2004 19:48:38 -0000 1.23 --- _ctypes_test.c 18 Aug 2004 12:57:45 -0000 1.24 *************** *** 58,61 **** --- 58,76 ---- } + EXPORT(char *) my_strdup(char *src) + { + char *dst = malloc(strlen(src)+1); + if (!dst) + return NULL; + strcpy(dst, src); + return dst; + } + + #ifdef MS_WIN32 + EXPORT(wchar_t *) my_wcsdup(wchar_t *src) + { + return _wcsdup(src); + } + #endif #ifndef MS_WIN32 |
From: Thomas H. <th...@us...> - 2004-08-18 12:48:21
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31865 Added Files: test_slicing.py Log Message: Tests for slicing. --- NEW FILE: test_slicing.py --- import unittest from ctypes import * class SlicesTestCase(unittest.TestCase): def test_getslice_cint(self): a = (c_int * 100)(*xrange(1100, 1200)) b = range(1100, 1200) self.failUnlessEqual(a[0:2], b[0:2]) self.failUnlessEqual(len(a), len(b)) self.failUnlessEqual(a[5:7], b[5:7]) self.failUnlessEqual(a[-1], b[-1]) self.failUnlessEqual(a[:], b[:]) a[0:5] = range(5, 10) self.failUnlessEqual(a[0:5], range(5, 10)) def test_setslice_cint(self): a = (c_int * 100)(*xrange(1100, 1200)) b = range(1100, 1200) a[32:47] = range(32, 47) self.failUnlessEqual(a[32:47], range(32, 47)) from operator import setslice # TypeError: int expected instead of str instance self.assertRaises(TypeError, setslice, a, 0, 5, "abcde") # TypeError: int expected instead of str instance self.assertRaises(TypeError, setslice, a, 0, 5, ["a", "b", "c", "d", "e"]) # TypeError: int expected instead of float instance self.assertRaises(TypeError, setslice, a, 0, 5, [1, 2, 3, 4, 3.14]) # ValueError: Can only assign sequence of same size self.assertRaises(ValueError, setslice, a, 0, 5, range(32)) def test_char_ptr(self): s = "abcdefghijklmnopqrstuvwxyz\0" cdll.msvcrt._strdup.restype = POINTER(c_char) res = cdll.msvcrt._strdup(s) self.failUnlessEqual(res[:len(s)], s) import operator self.assertRaises(TypeError, operator.setslice, res, 0, 5, u"abcde") cdll.msvcrt._strdup.restype = POINTER(c_byte) res = cdll.msvcrt._strdup(s) self.failUnlessEqual(res[:len(s)-1], range(ord("a"), ord("z")+1)) def test_char_array(self): s = "abcdefghijklmnopqrstuvwxyz\0" p = (c_char * 27)(*s) self.failUnlessEqual(p[:], s) try: c_wchar except NameError: pass else: def test_wchar_ptr(self): s = u"abcdefghijklmnopqrstuvwxyz\0" cdll.msvcrt._wcsdup.restype = POINTER(c_wchar) res = cdll.msvcrt._wcsdup(s) self.failUnlessEqual(res[:len(s)], s) import operator self.assertRaises(TypeError, operator.setslice, res, 0, 5, u"abcde") cdll.msvcrt._wcsdup.restype = POINTER(c_short) res = cdll.msvcrt._wcsdup(s) self.failUnlessEqual(res[:len(s)-1], range(ord("a"), ord("z")+1)) ################################################################ if __name__ == "__main__": unittest.main() |
From: Thomas H. <th...@us...> - 2004-08-18 12:28:44
|
Update of /cvsroot/ctypes/ctypes/win32/com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27649 Modified Files: automation.py Log Message: todo-style comments. Index: automation.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/win32/com/automation.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** automation.py 3 May 2004 15:05:50 -0000 1.16 --- automation.py 18 Aug 2004 12:28:24 -0000 1.17 *************** *** 430,436 **** return "<VARIANT 0x%X at %x>" % (self.vt, addressof(self)) ! # We must do this manually, BUT ONLY if we own the VARIANT ## def __del__(self, _clear = oleaut32.VariantClear): ! ## _clear(byref(self)) def optional(cls): --- 430,442 ---- return "<VARIANT 0x%X at %x>" % (self.vt, addressof(self)) ! ## _owned = True ! ! ## # We must do this manually, BUT ONLY if we own the VARIANT ## def __del__(self, _clear = oleaut32.VariantClear): ! ## if self._owned: ! ## _clear(byref(self)) ! ! ## def own(self, how): ! ## self._owned = how def optional(cls): |