ctypes-commit Mailing List for ctypes (Page 8)
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...> - 2006-06-08 18:40:53
|
Update of /cvsroot/ctypes/ctypes/codegen/ctypes_codegen In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv30581/ctypes_codegen Log Message: Directory /cvsroot/ctypes/ctypes/codegen/ctypes_codegen added to the repository |
From: Thomas H. <th...@us...> - 2006-06-08 18:39:01
|
Update of /cvsroot/ctypes/ctypes/codegen In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv29684/codegen Log Message: Directory /cvsroot/ctypes/ctypes/codegen added to the repository |
From: Thomas H. <th...@us...> - 2006-06-08 15:09:19
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv29165 Modified Files: ChangeLog Log Message: *** empty log message *** Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.134 retrieving revision 1.135 diff -C2 -d -r1.134 -r1.135 *** ChangeLog 2 Jun 2006 21:24:33 -0000 1.134 --- ChangeLog 8 Jun 2006 15:09:13 -0000 1.135 *************** *** 1,2 **** --- 1,7 ---- + 2006-06-08 Thomas Heller <th...@py...> + + * Merged in changes done in Python trunk: Fixes for 64-bit big + endian machines. + 2006-06-02 Thomas Heller <th...@py...> |
From: Thomas H. <th...@us...> - 2006-06-08 15:01:33
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv25764 Modified Files: test_pointers.py Log Message: Cosmetics. Index: test_pointers.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_pointers.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_pointers.py 12 May 2006 20:06:09 -0000 1.6 --- test_pointers.py 8 Jun 2006 15:01:27 -0000 1.7 *************** *** 134,138 **** self.failUnlessEqual(p.contents.value, 42) ! def test_charpp( self ): """Test that a character pointer-to-pointer is correctly passed""" dll = CDLL(_ctypes_test.__file__) --- 134,138 ---- self.failUnlessEqual(p.contents.value, 42) ! def test_charpp(self): """Test that a character pointer-to-pointer is correctly passed""" dll = CDLL(_ctypes_test.__file__) |
From: Thomas H. <th...@us...> - 2006-06-08 14:50:49
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv21233 Modified Files: test_structures.py Log Message: Merge in changes done in Python SVN trunk: Adapt the tests to changes. Index: test_structures.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_structures.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_structures.py 14 Mar 2006 19:09:21 -0000 1.4 --- test_structures.py 8 Jun 2006 14:50:43 -0000 1.5 *************** *** 139,144 **** # readonly ! self.assertRaises(TypeError, setattr, X.x, "offset", 92) ! self.assertRaises(TypeError, setattr, X.x, "size", 92) class X(Union): --- 139,144 ---- # readonly ! self.assertRaises((TypeError, AttributeError), setattr, X.x, "offset", 92) ! self.assertRaises((TypeError, AttributeError), setattr, X.x, "size", 92) class X(Union): *************** *** 153,158 **** # readonly ! self.assertRaises(TypeError, setattr, X.x, "offset", 92) ! self.assertRaises(TypeError, setattr, X.x, "size", 92) # XXX Should we check nested data types also? --- 153,158 ---- # readonly ! self.assertRaises((TypeError, AttributeError), setattr, X.x, "offset", 92) ! self.assertRaises((TypeError, AttributeError), setattr, X.x, "size", 92) # XXX Should we check nested data types also? *************** *** 295,299 **** if issubclass(Exception, object): self.failUnlessEqual(msg, ! "(Phone) <class 'exceptions.TypeError'>: " "expected string or Unicode object, int found") else: --- 295,299 ---- if issubclass(Exception, object): self.failUnlessEqual(msg, ! "(Phone) <type 'exceptions.TypeError'>: " "expected string or Unicode object, int found") else: *************** *** 306,310 **** if issubclass(Exception, object): self.failUnlessEqual(msg, ! "(Phone) <class 'exceptions.ValueError'>: too many initializers") else: self.failUnlessEqual(msg, "(Phone) exceptions.ValueError: too many initializers") --- 306,310 ---- if issubclass(Exception, object): self.failUnlessEqual(msg, ! "(Phone) <type 'exceptions.ValueError'>: too many initializers") else: self.failUnlessEqual(msg, "(Phone) exceptions.ValueError: too many initializers") |
From: Thomas H. <th...@us...> - 2006-06-08 14:47:45
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv19966 Modified Files: test_cfuncs.py Log Message: Merge in changes done in Python SVN trunk: Specify argtypes for all test functions. Maybe that helps on strange ;-) architectures. Index: test_cfuncs.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_cfuncs.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_cfuncs.py 13 Apr 2006 18:42:30 -0000 1.6 --- test_cfuncs.py 8 Jun 2006 14:47:23 -0000 1.7 *************** *** 41,44 **** --- 41,45 ---- def test_short(self): self._dll.tf_h.restype = c_short + self._dll.tf_h.argtypes = (c_short,) self.failUnlessEqual(self._dll.tf_h(-32766), -10922) self.failUnlessEqual(self.S(), -32766) *************** *** 46,49 **** --- 47,51 ---- def test_short_plus(self): self._dll.tf_bh.restype = c_short + self._dll.tf_bh.argtypes = (c_byte, c_short) self.failUnlessEqual(self._dll.tf_bh(0, -32766), -10922) self.failUnlessEqual(self.S(), -32766) *************** *** 51,54 **** --- 53,57 ---- def test_ushort(self): self._dll.tf_H.restype = c_ushort + self._dll.tf_H.argtypes = (c_ushort,) self.failUnlessEqual(self._dll.tf_H(65535), 21845) self.failUnlessEqual(self.U(), 65535) *************** *** 56,59 **** --- 59,63 ---- def test_ushort_plus(self): self._dll.tf_bH.restype = c_ushort + self._dll.tf_bH.argtypes = (c_byte, c_ushort) self.failUnlessEqual(self._dll.tf_bH(0, 65535), 21845) self.failUnlessEqual(self.U(), 65535) *************** *** 61,64 **** --- 65,69 ---- def test_int(self): self._dll.tf_i.restype = c_int + self._dll.tf_i.argtypes = (c_int,) self.failUnlessEqual(self._dll.tf_i(-2147483646), -715827882) self.failUnlessEqual(self.S(), -2147483646) *************** *** 66,69 **** --- 71,75 ---- def test_int_plus(self): self._dll.tf_bi.restype = c_int + self._dll.tf_bi.argtypes = (c_byte, c_int) self.failUnlessEqual(self._dll.tf_bi(0, -2147483646), -715827882) self.failUnlessEqual(self.S(), -2147483646) *************** *** 71,74 **** --- 77,81 ---- def test_uint(self): self._dll.tf_I.restype = c_uint + self._dll.tf_I.argtypes = (c_uint,) self.failUnlessEqual(self._dll.tf_I(4294967295), 1431655765) self.failUnlessEqual(self.U(), 4294967295) *************** *** 76,79 **** --- 83,87 ---- def test_uint_plus(self): self._dll.tf_bI.restype = c_uint + self._dll.tf_bI.argtypes = (c_byte, c_uint) self.failUnlessEqual(self._dll.tf_bI(0, 4294967295), 1431655765) self.failUnlessEqual(self.U(), 4294967295) |
From: Thomas H. <th...@us...> - 2006-06-08 14:45:22
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv19134 Modified Files: _ctypes.c Log Message: MSVC does not understand the 'z' printf width specifier. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.334 retrieving revision 1.335 diff -C2 -d -r1.334 -r1.335 *** _ctypes.c 2 Jun 2006 21:14:35 -0000 1.334 --- _ctypes.c 8 Jun 2006 14:45:19 -0000 1.335 *************** *** 1828,1833 **** --- 1828,1838 ---- cp += sprintf(cp, "%x", index); #else + #ifdef MS_WIN32 + /* MSVC does not understand the 'z' size specifier */ + cp += sprintf(cp, "%Ix", index); + #else cp += sprintf(cp, "%zx", index); #endif + #endif while (target->b_base) { bytes_left = sizeof(string) - (cp - string) - 1; *************** *** 1839,1845 **** } #if (PY_VERSION_HEX < 0x02050000) ! cp += sprintf(cp, ":%x", target->b_index); #else ! cp += sprintf(cp, ":%zx", target->b_index); #endif target = target->b_base; --- 1844,1854 ---- } #if (PY_VERSION_HEX < 0x02050000) ! cp += sprintf(cp, ":%x", (int)target->b_index); #else ! #ifdef MS_WIN32 ! cp += sprintf(cp, ":%Ix", (size_t)target->b_index); ! #else ! cp += sprintf(cp, ":%zx", (size_t)target->b_index); ! #endif #endif target = target->b_base; |
From: Thomas H. <th...@us...> - 2006-06-08 13:27:29
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv17467 Modified Files: callproc.c Log Message: Merge in changes done in Python SVN trunk: Fix for foreign functions returning floats or small structures on 64-bit big endian machines. Thanks to Matthias Klose for providing access to a machine to debug and test this. Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.166 retrieving revision 1.167 diff -C2 -d -r1.166 -r1.167 *** callproc.c 18 May 2006 20:09:46 -0000 1.166 --- callproc.c 8 Jun 2006 13:27:21 -0000 1.167 *************** *** 965,969 **** adjust the pointer value: */ ! if (rtype->size < sizeof(ffi_arg)) resbuf = (char *)resbuf + sizeof(ffi_arg) - rtype->size; #endif --- 965,976 ---- adjust the pointer value: */ ! /* ! XXX I should find out and clarify why this is needed at all, ! especially why adjusting for ffi_type_float must be avoided on ! 64-bit platforms. ! */ ! if (rtype->type != FFI_TYPE_FLOAT ! && rtype->type != FFI_TYPE_STRUCT ! && rtype->size < sizeof(ffi_arg)) resbuf = (char *)resbuf + sizeof(ffi_arg) - rtype->size; #endif |
From: Thomas H. <th...@us...> - 2006-06-08 13:24:51
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv16126 Modified Files: callbacks.c Log Message: Merge in changes done in Python SVN trunk: Use the same big-endian hack as in _ctypes/callproc.c for callback functions. This fixes callback function tests that return float, on a 64-bit big endian machine. Index: callbacks.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callbacks.c,v retrieving revision 1.84 retrieving revision 1.85 diff -C2 -d -r1.84 -r1.85 *** callbacks.c 18 Apr 2006 20:18:31 -0000 1.84 --- callbacks.c 8 Jun 2006 13:24:44 -0000 1.85 *************** *** 200,242 **** result = PyObject_CallObject(callable, arglist); CHECK("'calling callback function'", result); ! if ((restype != &ffi_type_void) ! && result && result != Py_None) { /* XXX What is returned for Py_None ? */ ! /* another big endian hack */ ! union { ! char c; ! short s; ! int i; ! long l; ! } r; PyObject *keep; assert(setfunc); ! switch (restype->size) { ! case 1: ! keep = setfunc(&r, result, 0); ! CHECK("'converting callback result'", keep); ! *(ffi_arg *)mem = r.c; ! break; ! case SIZEOF_SHORT: ! keep = setfunc(&r, result, 0); ! CHECK("'converting callback result'", keep); ! *(ffi_arg *)mem = r.s; ! break; ! case SIZEOF_INT: ! keep = setfunc(&r, result, 0); ! CHECK("'converting callback result'", keep); ! *(ffi_arg *)mem = r.i; ! break; ! #if (SIZEOF_LONG != SIZEOF_INT) ! case SIZEOF_LONG: ! keep = setfunc(&r, result, 0); ! CHECK("'converting callback result'", keep); ! *(ffi_arg *)mem = r.l; ! break; #endif ! default: ! keep = setfunc(mem, result, 0); ! CHECK("'converting callback result'", keep); ! break; ! } /* keep is an object we have to keep alive so that the result stays valid. If there is no such object, the setfunc will --- 200,213 ---- result = PyObject_CallObject(callable, arglist); CHECK("'calling callback function'", result); ! if ((restype != &ffi_type_void) && result && result != Py_None) { PyObject *keep; assert(setfunc); ! #ifdef WORDS_BIGENDIAN ! /* See the corresponding code in callproc.c, around line 961 */ ! if (restype->type != FFI_TYPE_FLOAT && restype->size < sizeof(ffi_arg)) ! mem = (char *)mem + sizeof(ffi_arg) - restype->size; #endif ! keep = setfunc(mem, result, 0); ! CHECK("'converting callback result'", keep); /* keep is an object we have to keep alive so that the result stays valid. If there is no such object, the setfunc will |
From: Thomas H. <th...@us...> - 2006-06-08 13:23:14
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv15567 Modified Files: cfield.c Log Message: Merge in changes done in Python SVN trunk: Convert CFieldObject tp_members to tp_getset, since there is no structmember typecode for Py_ssize_t fields. This fixes some errors on the 64-bit big endian machines. Index: cfield.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/cfield.c,v retrieving revision 1.119 retrieving revision 1.120 diff -C2 -d -r1.119 -r1.120 *** cfield.c 6 Apr 2006 11:35:31 -0000 1.119 --- cfield.c 8 Jun 2006 13:23:07 -0000 1.120 *************** *** 1,4 **** #include "Python.h" - #include "structmember.h" #include <ffi.h> --- 1,3 ---- *************** *** 209,220 **** } ! static PyMemberDef CField_members[] = { ! { "offset", T_UINT, ! offsetof(CFieldObject, offset), READONLY, ! "offset in bytes of this field"}, ! { "size", T_UINT, ! offsetof(CFieldObject, size), READONLY, ! "size in bytes of this field"}, ! { NULL }, }; --- 208,235 ---- } ! static PyObject * ! CField_get_offset(PyObject *self, void *data) ! { ! #if (PY_VERSION_HEX < 0x02050000) ! return PyInt_FromLong(((CFieldObject *)self)->offset); ! #else ! return PyInt_FromSsize_t(((CFieldObject *)self)->offset); ! #endif ! } ! ! static PyObject * ! CField_get_size(PyObject *self, void *data) ! { ! #if (PY_VERSION_HEX < 0x02050000) ! return PyInt_FromLong(((CFieldObject *)self)->size); ! #else ! return PyInt_FromSsize_t(((CFieldObject *)self)->size); ! #endif ! } ! ! static PyGetSetDef CField_getset[] = { ! { "offset", CField_get_offset, NULL, "offset in bytes of this field" }, ! { "size", CField_get_size, NULL, "size in bytes of this field" }, ! { NULL, NULL, NULL, NULL }, }; *************** *** 299,304 **** 0, /* tp_iternext */ 0, /* tp_methods */ ! CField_members, /* tp_members */ ! 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ --- 314,319 ---- 0, /* tp_iternext */ 0, /* tp_methods */ ! 0, /* tp_members */ ! CField_getset, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ |
From: Thomas H. <th...@us...> - 2006-06-02 22:02:16
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv1736 Modified Files: reference.txt Log Message: *** empty log message *** Index: reference.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/reference.txt,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** reference.txt 2 Jun 2006 21:44:49 -0000 1.20 --- reference.txt 2 Jun 2006 22:02:07 -0000 1.21 *************** *** 2,6 **** ================ ! loading shared libraries ------------------------ --- 2,6 ---- ================ ! Loading shared libraries ------------------------ *************** *** 47,57 **** XXX ! foreign functions ----------------- The ultimate goal of ``ctypes`` is to call functions in shared libraries, aka as foreign functions. Foreign function instances can ! be created by accessing them as attributes of loaded shared libraries, ! or by instantiating a *function prototype*. Function prototypes are created by factory functions. --- 47,60 ---- XXX ! Foreign functions ----------------- The ultimate goal of ``ctypes`` is to call functions in shared libraries, aka as foreign functions. Foreign function instances can ! be created by retrieving them as attributes of loaded shared ! libraries, or by instantiating a *function prototype*. ! ! By default, functions got as attributes of loaded shared libraries ! accept any arguments, and have a return type of ``c_int``. Function prototypes are created by factory functions. *************** *** 88,93 **** ! helper functions ! ---------------- ``addressof(obj)`` : funcdesc --- 91,96 ---- ! Utility functions ! ----------------- ``addressof(obj)`` : funcdesc *************** *** 234,244 **** ``_CData`` : classdesc* ! This non-public class is the base class of all ctypes data types. ! Among other things, all ctypes type instances contain a memory ! block that hold C compatible data; the address of the memory block ! is returned by the ``addressof()`` helper function. Another ! instance variable is exposed as ``_objects``; this contains other ! Python objects that need to be kept alive in case the memory block ! contains pointers. Common methods of ctypes data types, these are all class methods (to --- 237,247 ---- ``_CData`` : classdesc* ! This non-public class is the common base class of all ctypes data ! types. Among other things, all ctypes type instances contain a ! memory block that hold C compatible data; the address of the ! memory block is returned by the ``addressof()`` helper function. ! Another instance variable is exposed as ``_objects``; this ! contains other Python objects that need to be kept alive in case ! the memory block contains pointers. Common methods of ctypes data types, these are all class methods (to *************** *** 282,287 **** data types. It is mentioned here because it contains the common attributes of the fundamental ctypes data types. ``_SimpleCData`` ! is a subclass of ``_CData``, so it inherits the methods and ! attributes of that. Instances have a single attribute: --- 285,290 ---- data types. It is mentioned here because it contains the common attributes of the fundamental ctypes data types. ``_SimpleCData`` ! is a subclass of ``_CData``, so it inherits their methods and ! attributes. Instances have a single attribute: *************** *** 299,307 **** instances. ! Fundamental data types, whether returned as result of foreign function ! calls, or, for example, by retrieving structure field members, are ! transparently converted to native Python types. In other words, if a ! foreign function has a ``restype`` of ``c_char_p``, you will always ! receive a Python string, *not* a ``c_char_p`` instance. Subclasses of fundamental data types do *not* inherit this behaviour. --- 302,311 ---- instances. ! Fundamental data types, when returned as foreign function call ! results, or, for example, by retrieving structure field members or ! array items, are transparently converted to native Python types. In ! other words, if a foreign function has a ``restype`` of ``c_char_p``, ! you will always receive a Python string, *not* a ``c_char_p`` ! instance. Subclasses of fundamental data types do *not* inherit this behaviour. *************** *** 432,436 **** or error information for a function or method call. ! structured data types --------------------- --- 436,440 ---- or error information for a function or method call. ! Structured data types --------------------- *************** *** 542,543 **** --- 546,552 ---- separate``_fields_`` variable, the fields specified in this are appended to the fields of the base class. + + Arrays and pointers + ------------------- + + XXX |
From: Thomas H. <th...@us...> - 2006-06-02 21:44:54
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv26530 Modified Files: reference.txt Log Message: *** empty log message *** Index: reference.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/reference.txt,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** reference.txt 2 Jun 2006 21:26:02 -0000 1.19 --- reference.txt 2 Jun 2006 21:44:49 -0000 1.20 *************** *** 439,457 **** ``BigEndianStructure(*args, **kw)`` : classdesc ! Abstract base class for structures in big endian byte order. ``LittleEndianStructure(*args, **kw)`` : classdesc ! Abstract base class for structures in little endian byte order. ``Structure(*args, **kw)`` : classdesc ! Abstract base class for structures in native byte order. Concrete structure and union types must be created by subclassing one of these types, and at least define a ``_fields_`` class variable. ``ctypes`` will create descriptors which allow reading and writing the ! fields by direct attribute accesses. ! ! Structures with non-native byte order cannot contain pointer type ! fields, or any other data types containing pointer type fields. ``_fields_`` : memberdesc --- 439,457 ---- ``BigEndianStructure(*args, **kw)`` : classdesc ! Abstract base class for structures in *big endian* byte order. ``LittleEndianStructure(*args, **kw)`` : classdesc ! Abstract base class for structures in *little endian* byte order. ! ! Structures with non-native byte order cannot contain pointer type ! fields, or any other data types containing pointer type fields. ``Structure(*args, **kw)`` : classdesc ! Abstract base class for structures in *native* byte order. Concrete structure and union types must be created by subclassing one of these types, and at least define a ``_fields_`` class variable. ``ctypes`` will create descriptors which allow reading and writing the ! fields by direct attribute accesses. These are the ``_fields_`` : memberdesc *************** *** 461,471 **** ctypes data type. ! The third item is optional, and only allowed for integer field ! types. It allows to define structures containing bit fields, it ! must be a small positive integer specifying the width of the bit field. Field names must be unique within one structure or union. This is ! not checked. It is possible to define the ``_fields_`` class variable *after* --- 461,471 ---- ctypes data type. ! For integer type fields, a third optional item can be given. It ! must be a small positive integer defining the bit width of the field. Field names must be unique within one structure or union. This is ! not checked, only one field can be accessed when names are ! repeated. It is possible to define the ``_fields_`` class variable *after* *************** *** 485,498 **** class variable will raise an AttributeError. ! Structure and union subclass constructors accept both ``_pack_`` : memberdesc An optional small integer that allows to override the alignment of ! structure fields in the instance. ``_pack_`` must be defined when ! ``_fields_`` is assigned, otherwise it will have no effect. ``_anonymous_`` : memberdesc An optional sequence that lists the names of unnamed (anonymous) ! fields. The fields listed in this variable must be structure or union type --- 485,509 ---- class variable will raise an AttributeError. ! Structure and union subclass constructors accept both positional ! and named arguments. Positional arguments are used to initialize ! the fields in the same order as they appear in the ``_fields_`` ! definition, named arguments are used to initialize the fields with ! the corresponding name. ! ! It is possible to defined sub-subclasses of structure types, they ! inherit the fields of the base class plus the ``_fields_`` defined ! in the sub-subclass, if any. ! ``_pack_`` : memberdesc An optional small integer that allows to override the alignment of ! structure fields in the instance. ``_pack_`` must already be ! defined when ``_fields_`` is assigned, otherwise it will have no ! effect. ``_anonymous_`` : memberdesc An optional sequence that lists the names of unnamed (anonymous) ! fields. ``_anonymous_`` must be already defined when ``_fields_`` ! is assigned, otherwise it will have no effect. The fields listed in this variable must be structure or union type *************** *** 526,527 **** --- 537,543 ---- td.lptdesc = POINTER(some_type) td.u.lptdesc = POINTER(some_type) + + It is possible to defined sub-subclasses of structures, they inherit + the fields of the base class. If the subclass definition has a + separate``_fields_`` variable, the fields specified in this are + appended to the fields of the base class. |
From: Thomas H. <th...@us...> - 2006-06-02 21:26:05
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv16469 Modified Files: reference.txt Log Message: *** empty log message *** Index: reference.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/reference.txt,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** reference.txt 1 Jun 2006 07:16:25 -0000 1.18 --- reference.txt 2 Jun 2006 21:26:02 -0000 1.19 *************** *** 11,15 **** Load a shared library. ! ``CDLL(name, mode=RTLD_LOCAL, handle=None)`` : classdesc* XXX --- 11,15 ---- Load a shared library. ! ``CDLL(name, mode=RTLD_LOCAL, handle=None)`` : classdesc XXX *************** *** 435,459 **** --------------------- ! ``Union`` : classdesc* Abstract base class for unions in native byte order. ! ``BigEndianStructure`` : classdesc* Abstract base class for structures in big endian byte order. ! ``LittleEndianStructure`` : classdesc* Abstract base class for structures in little endian byte order. ! ``Structure`` : classdesc* Abstract base class for structures in native byte order. ! Structure and union types must be created by subclassing, and at least ! defining a ``_fields_`` class variable. ``ctypes`` will create ! descriptors which allow read/write access to the fields. ``_fields_`` : memberdesc A sequence defining the structure fields. The items must be ! 2-tuples or 3-tuples. The first tuple item is the name of the ! field, the second item specifies the type of the field; it must be ! any ctypes data type. The third item is optional, and only allowed for integer field --- 435,463 ---- --------------------- ! ``Union(*args, **kw)`` : classdesc Abstract base class for unions in native byte order. ! ``BigEndianStructure(*args, **kw)`` : classdesc Abstract base class for structures in big endian byte order. ! ``LittleEndianStructure(*args, **kw)`` : classdesc Abstract base class for structures in little endian byte order. ! ``Structure(*args, **kw)`` : classdesc Abstract base class for structures in native byte order. ! Concrete structure and union types must be created by subclassing one ! of these types, and at least define a ``_fields_`` class variable. ! ``ctypes`` will create descriptors which allow reading and writing the ! fields by direct attribute accesses. ! ! Structures with non-native byte order cannot contain pointer type ! fields, or any other data types containing pointer type fields. ``_fields_`` : memberdesc A sequence defining the structure fields. The items must be ! 2-tuples or 3-tuples. The first item is the name of the field, ! the second item specifies the type of the field; it can be any ! ctypes data type. The third item is optional, and only allowed for integer field *************** *** 462,468 **** field. It is possible to define the ``_fields_`` class variable *after* the class statement that defines the Structure subclass, this ! allows to create data types that directly or indirectly references themselves:: --- 466,475 ---- field. + Field names must be unique within one structure or union. This is + not checked. + It is possible to define the ``_fields_`` class variable *after* the class statement that defines the Structure subclass, this ! allows to create data types that directly or indirectly reference themselves:: *************** *** 478,481 **** --- 485,490 ---- class variable will raise an AttributeError. + Structure and union subclass constructors accept both + ``_pack_`` : memberdesc An optional small integer that allows to override the alignment of |
From: Thomas H. <th...@us...> - 2006-06-02 21:24:41
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv15949 Modified Files: ChangeLog Log Message: Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.133 retrieving revision 1.134 diff -C2 -d -r1.133 -r1.134 *** ChangeLog 23 May 2006 20:13:26 -0000 1.133 --- ChangeLog 2 Jun 2006 21:24:33 -0000 1.134 *************** *** 1,2 **** --- 1,17 ---- + 2006-06-02 Thomas Heller <th...@py...> + + * Fixed slice assignment to variable-sized arrays, with test. + + 2006-06-01 Thomas Heller <th...@py...> + + * Added support for unnamed structure fields, they must be listed + in the '_anonymous_' class variable. + + 2006-05-31 Thomas Heller <th...@py...> + + * Merged in changes done in Python trunk, by Bob Ippolito and + Ronald Oussuren: enable darwin/x86 support for libffi and hence + ctypes (doesn't yet support --enable-universalsdk) + 2006-05-23 Thomas Heller <th...@py...> |
From: Thomas H. <th...@us...> - 2006-06-02 21:14:38
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv10607 Modified Files: _ctypes.c Log Message: Fix slice assigment to variable-sized arrays. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.333 retrieving revision 1.334 diff -C2 -d -r1.333 -r1.334 *** _ctypes.c 31 May 2006 11:35:06 -0000 1.333 --- _ctypes.c 2 Jun 2006 21:14:35 -0000 1.334 *************** *** 3679,3683 **** len = PySequence_Length(value); ! if (len != ihigh - ilow) { PyErr_SetString(PyExc_ValueError, "Can only assign sequence of same size"); --- 3679,3683 ---- len = PySequence_Length(value); ! if (self->b_length != 1 && len != ihigh - ilow) { PyErr_SetString(PyExc_ValueError, "Can only assign sequence of same size"); |
From: Thomas H. <th...@us...> - 2006-06-02 21:14:34
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv10591 Modified Files: test_varsize_struct.py Log Message: Fix slice assigment to variable-sized arrays. Index: test_varsize_struct.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_varsize_struct.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_varsize_struct.py 19 May 2006 15:50:56 -0000 1.2 --- test_varsize_struct.py 2 Jun 2006 21:14:29 -0000 1.3 *************** *** 99,102 **** --- 99,115 ---- self.failUnlessEqual(varsize_array[1:9], range(1001, 1009)) + def test_vararray_is_sane(self): + array = (c_int * 15)(20, 21, 22, 23, 24, 25, 26, 27, 28, 29) + + varsize_array = (c_int * 1).from_address(addressof(array)) + varsize_array[:] = [1, 2, 3, 4, 5] + + self.failUnlessEqual(array[:], [1, 2, 3, 4, 5, 25, 26, 27, 28, 29, 0, 0, 0, 0, 0]) + self.failUnlessEqual(varsize_array[0:10], [1, 2, 3, 4, 5, 25, 26, 27, 28, 29]) + + array[:5] = [10, 11, 12, 13, 14] + self.failUnlessEqual(array[:], [10, 11, 12, 13, 14, 25, 26, 27, 28, 29, 0, 0, 0, 0, 0]) + self.failUnlessEqual(varsize_array[0:10], [10, 11, 12, 13, 14, 25, 26, 27, 28, 29]) + if __name__ == "__main__": unittest.main() |
From: Thomas H. <th...@us...> - 2006-06-02 21:13:14
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv10147 Modified Files: stgdict.c Log Message: Fix compiler warning. Index: stgdict.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/stgdict.c,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** stgdict.c 1 Jun 2006 06:59:30 -0000 1.38 --- stgdict.c 2 Jun 2006 21:13:09 -0000 1.39 *************** *** 200,204 **** Py_DECREF(fdescr); ! if (-1 == PyObject_SetAttr(type, fname, new_descr)) { Py_DECREF(fieldlist); Py_DECREF(new_descr); --- 200,204 ---- Py_DECREF(fdescr); ! if (-1 == PyObject_SetAttr(type, fname, (PyObject *)new_descr)) { Py_DECREF(fieldlist); Py_DECREF(new_descr); |
From: Thomas H. <th...@us...> - 2006-06-02 15:45:18
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv7466 Modified Files: mkpydoc.py Log Message: Newest version from docutils sandbox: svn rev 4590. Index: mkpydoc.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/mkpydoc.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** mkpydoc.py 31 May 2006 17:54:51 -0000 1.13 --- mkpydoc.py 2 Jun 2006 15:45:03 -0000 1.14 *************** *** 295,308 **** def anydesc_title(self, title): """Returns the title for xxxdesc environments.""" ! if self.in_anydesc in ('ctypedesc','memberdesc','memberdescni',): ! # TODO [tag_or_type] {name} ! return '%s' % title ! elif self.in_anydesc in ('cvardesc','excclassdesc', 'funcdesc','funcdescni'): # "funcname(arguments)" to "{funcname}{arguments}" # "funcname([arguments])" to "{funcname}{\optional{arguments}}" ! t = '{'+title.replace('(','}{').replace(')','}') ! return t.replace('[','\\optional{').replace(']','}') ! # 'datadesc','datadescni', 'excdesc','classdesc*','csimplemacrodesc' return "{%s}" % title --- 295,332 ---- def anydesc_title(self, title): """Returns the title for xxxdesc environments.""" ! def markup_optional_parameters(s): ! return s.replace('[','\\optional{').replace(']','}') ! def with_params(s): ! return markup_optional_parameters( ! '{%s}' % s.replace('(','}{').replace(')','')) ! def with_tag_or_typename(s, braces): ! # "name", "tag name", "name(params)", "type name(params)" ! param_pos = s.find("(") ! blank_pos = s.find(" ") ! if ((blank_pos>0 and param_pos<0) ! or (blank_pos>0 and blank_pos<param_pos)): ! (tag,rest) = s.split(None,1) ! return braces[0] + tag + braces[1] + with_params(rest) ! return with_params(s) ! # ! if self.in_anydesc in ('datadesc','datadescni','excdesc','classdesc*', ! 'csimplemacrodesc'): ! # \begin{xdesc}{name} ! return '{%s}' % title ! elif self.in_anydesc in ('ctypedesc','memberdesc','memberdescni',): ! # \begin{ctypedesc} [tag]{name} ! return with_tag_or_typename(title, '[]') ! elif self.in_anydesc in ('classdesc', 'cvardesc','excclassdesc', 'funcdesc','funcdescni'): # "funcname(arguments)" to "{funcname}{arguments}" # "funcname([arguments])" to "{funcname}{\optional{arguments}}" ! return with_params(title) ! elif self.in_anydesc in ('methoddesc','methoddescni'): ! # \begin{methoddesc} [type name]{name}{parameters} ! return with_tag_or_typename(title, '[]') ! elif self.in_anydesc in ('cmemberdesc','cfuncdesc'): ! # \begin{cmemberdesc} {container}{type}{name} ! return with_tag_or_typename(title, '{}') ! # fallback return "{%s}" % title |
From: Thomas H. <th...@us...> - 2006-06-01 07:16:28
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv27065 Modified Files: reference.txt Log Message: Correct markup (?). Index: reference.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/reference.txt,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** reference.txt 1 Jun 2006 06:58:48 -0000 1.17 --- reference.txt 1 Jun 2006 07:16:25 -0000 1.18 *************** *** 452,456 **** ``_fields_`` : memberdesc - A sequence defining the structure fields. The items must be 2-tuples or 3-tuples. The first tuple item is the name of the --- 452,455 ---- *************** *** 480,484 **** ``_pack_`` : memberdesc - An optional small integer that allows to override the alignment of structure fields in the instance. ``_pack_`` must be defined when --- 479,482 ---- *************** *** 486,491 **** ``_anonymous_`` : memberdesc ! ! An optional sequence that lists the names of anonymous fields. The fields listed in this variable must be structure or union type --- 484,489 ---- ``_anonymous_`` : memberdesc ! An optional sequence that lists the names of unnamed (anonymous) ! fields. The fields listed in this variable must be structure or union type |
From: Thomas H. <th...@us...> - 2006-06-01 07:00:58
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv21185 Added Files: test_anon.py Log Message: Tests for structures containing anonymous fields. --- NEW FILE: test_anon.py --- import unittest from ctypes import * class AnonTest(unittest.TestCase): def test_anon(self): class ANON(Union): _fields_ = [("a", c_int), ("b", c_int)] class Y(Structure): _fields_ = [("x", c_int), ("_", ANON), ("y", c_int)] _anonymous_ = ["_"] self.failUnlessEqual(Y.a.offset, sizeof(c_int)) self.failUnlessEqual(Y.b.offset, sizeof(c_int)) self.failUnlessEqual(ANON.a.offset, 0) self.failUnlessEqual(ANON.b.offset, 0) def test_anon_nonseq(self): # TypeError: _anonymous_ must be a sequence self.failUnlessRaises(TypeError, lambda: type(Structure)("Name", (Structure,), {"_fields_": [], "_anonymous_": 42})) def test_anon_nonmember(self): # AttributeError: type object 'Name' has no attribute 'x' self.failUnlessRaises(AttributeError, lambda: type(Structure)("Name", (Structure,), {"_fields_": [], "_anonymous_": ["x"]})) if __name__ == "__main__": unittest.main() |
From: Thomas H. <th...@us...> - 2006-06-01 06:59:33
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv20776 Modified Files: stgdict.c Log Message: Add support for anonymous structure fields. Index: stgdict.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/stgdict.c,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** stgdict.c 18 Apr 2006 20:18:31 -0000 1.37 --- stgdict.c 1 Jun 2006 06:59:30 -0000 1.38 *************** *** 143,170 **** } ! #if 0 ! /* work in progress: anonymous structure fields */ ! int ! GetFields(PyObject *desc, int *pindex, int *psize, int *poffset, int *palign, int pack); { ! int i; ! PyObject *tuples = PyObject_GetAttrString(desc, "_fields_"); ! if (tuples == NULL) return -1; ! if (!PyTuple_Check(tuples)) ! return -1; /* leak */ ! for (i = 0; i < PyTuple_GET_SIZE(tuples); ++i) { ! char *fname; ! PyObject *dummy; ! CFieldObject *field; ! PyObject *pair = PyTuple_GET_ITEM(tuples, i); ! if (!PyArg_ParseTuple(pair, "sO", &fname, &dummy)) ! return -1; /* leak */ ! field = PyObject_GetAttrString(desc, fname); ! Py_DECREF(field); } } - #endif /* --- 143,253 ---- } ! /* descr is the descriptor for a field marked as anonymous. Get all the ! _fields_ descriptors from descr->proto, create new descriptors with offset ! and index adjusted, and stuff them into type. ! */ ! static int ! MakeFields(PyObject *type, CFieldObject *descr) ! { ! Py_ssize_t i; ! PyObject *fields; ! PyObject *fieldlist; ! ! fields = PyObject_GetAttrString(descr->proto, "_fields_"); ! if (fields == NULL) ! return -1; ! fieldlist = PySequence_Fast(fields, "_fields_ must be a sequence"); ! Py_DECREF(fields); ! if (fieldlist == NULL) ! return -1; ! ! for (i = 0; i < PySequence_Fast_GET_SIZE(fieldlist); ++i) { ! PyObject *pair = PySequence_Fast_GET_ITEM(fieldlist, i); /* borrowed */ ! PyObject *fname, *ftype; ! CFieldObject *fdescr; ! CFieldObject *new_descr; ! // Convert to PyArg_UnpackTuple... ! if (!PyArg_ParseTuple(pair, "OO", &fname, &ftype)) { ! Py_DECREF(fieldlist); ! return -1; ! } ! fdescr = (CFieldObject *)PyObject_GetAttr(descr->proto, fname); ! if (fdescr == NULL) { ! Py_DECREF(fieldlist); ! return -1; ! } ! if (fdescr->ob_type != &CField_Type) { ! PyErr_SetString(PyExc_TypeError, "unexpected type"); ! Py_DECREF(fdescr); ! Py_DECREF(fieldlist); ! return -1; ! } ! new_descr = (CFieldObject *)PyObject_CallObject((PyObject *)&CField_Type, NULL); ! assert(new_descr->ob_type == &CField_Type); ! if (new_descr == NULL) { ! Py_DECREF(fdescr); ! Py_DECREF(fieldlist); ! return -1; ! } ! new_descr->size = fdescr->size; ! new_descr->offset = fdescr->offset + descr->offset; ! new_descr->index = fdescr->index + descr->index; ! new_descr->proto = fdescr->proto; ! Py_XINCREF(new_descr->proto); ! new_descr->getfunc = fdescr->getfunc; ! new_descr->setfunc = fdescr->setfunc; + Py_DECREF(fdescr); + + if (-1 == PyObject_SetAttr(type, fname, new_descr)) { + Py_DECREF(fieldlist); + Py_DECREF(new_descr); + return -1; + } + Py_DECREF(new_descr); + } + Py_DECREF(fieldlist); + return 0; + } + + /* Iterate over the names in the type's _anonymous_ attribute, if present, + */ + static int + MakeAnonFields(PyObject *type) { ! PyObject *anon; ! PyObject *anon_names; ! Py_ssize_t i; ! ! anon = PyObject_GetAttrString(type, "_anonymous_"); ! if (anon == NULL) { ! PyErr_Clear(); ! return 0; ! } ! anon_names = PySequence_Fast(anon, "_anonymous_ must be a sequence"); ! Py_DECREF(anon); ! if (anon_names == NULL) return -1; ! ! for (i = 0; i < PySequence_Fast_GET_SIZE(anon_names); ++i) { ! PyObject *fname = PySequence_Fast_GET_ITEM(anon_names, i); /* borrowed */ ! PyObject *descr = PyObject_GetAttr(type, fname); ! if (descr == NULL) { ! Py_DECREF(anon_names); ! return -1; ! } ! assert(descr->ob_type == &CField_Type); ! /* descr is in the field descriptor. */ ! if (-1 == MakeFields(type, (CFieldObject *)descr)) { ! Py_DECREF(descr); ! Py_DECREF(anon_names); ! return -1; ! } ! Py_DECREF(descr); } + + Py_DECREF(anon_names); + return 0; } /* *************** *** 369,372 **** stgdict->align = total_align; stgdict->length = len; /* ADD ffi_ofs? */ ! return 0; } --- 452,455 ---- stgdict->align = total_align; stgdict->length = len; /* ADD ffi_ofs? */ ! return MakeAnonFields(type); } |
From: Thomas H. <th...@us...> - 2006-06-01 06:58:53
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv20442 Modified Files: reference.txt Log Message: Move pythonapi to where it belongs. Index: reference.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/reference.txt,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** reference.txt 31 May 2006 18:28:27 -0000 1.16 --- reference.txt 1 Jun 2006 06:58:48 -0000 1.17 *************** *** 44,47 **** --- 44,50 ---- XXX + ``pythonapi()`` : vardesc + XXX + foreign functions ----------------- *************** *** 185,191 **** function call, you should use ``byref(obj)`` which is much faster. - ``pythonapi()`` : funcdesc - XXX Not a function. - ``resize(obj, size)`` : funcdesc This function resizes the internal memory buffer of obj, which --- 188,191 ---- |
From: Thomas H. <th...@us...> - 2006-05-31 18:28:32
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv8359 Modified Files: reference.txt Log Message: Index: reference.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/reference.txt,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** reference.txt 31 May 2006 18:02:31 -0000 1.15 --- reference.txt 31 May 2006 18:28:27 -0000 1.16 *************** *** 230,240 **** ! data types ---------- ``_CData`` : classdesc* This non-public class is the base class of all ctypes data types. ! Among other things, a ctypes type instance contains a memory block ! that contains C compatible data. Common methods of ctypes data types, these are all class methods (to --- 230,244 ---- ! Data types ---------- ``_CData`` : classdesc* This non-public class is the base class of all ctypes data types. ! Among other things, all ctypes type instances contain a memory ! block that hold C compatible data; the address of the memory block ! is returned by the ``addressof()`` helper function. Another ! instance variable is exposed as ``_objects``; this contains other ! Python objects that need to be kept alive in case the memory block ! contains pointers. Common methods of ctypes data types, these are all class methods (to *************** *** 250,255 **** ``in_dll(name, library)`` : methoddesc This method returns a ctypes type instance exported by a shared ! library. name is the name of the symbol that exports the data, ! library is the loaded shared library. Fundamental data types --- 254,277 ---- ``in_dll(name, library)`` : methoddesc This method returns a ctypes type instance exported by a shared ! library. ``name`` is the name of the symbol that exports the data, ! ``library`` is the loaded shared library. ! ! Common instance variables of ctypes data types: ! ! ``_b_base_`` : memberdesc ! Sometimes ctypes data instances do not own the memory block they ! contain, instead they share part of the memory block of a base ! object. The ``_b_base_`` readonly member is the root ctypes ! object that owns the memory block. ! ! ``_b_needsfree_`` : memberdesc ! This readonly variable is true when the ctypes data instance has ! allocated the memory block itself, false otherwise. ! ! ``_objects`` : memberdesc ! This member is either ``None`` or a dictionary containing Python ! objects that need to be kept alive so that the memory block ! contents is kept valid. This object is only exposed for ! debugging; never modify the contents of this dictionary. Fundamental data types *************** *** 259,263 **** This non-public class is the base class of all fundamental ctypes data types. It is mentioned here because it contains the common ! attributes of the ctypes data types. Instances have a single attribute: --- 281,287 ---- This non-public class is the base class of all fundamental ctypes data types. It is mentioned here because it contains the common ! attributes of the fundamental ctypes data types. ``_SimpleCData`` ! is a subclass of ``_CData``, so it inherits the methods and ! attributes of that. Instances have a single attribute: *************** *** 265,269 **** ``value`` : memberdesc This attribute contains the actual value of the instance. For ! integer types, it is an integer. These are the fundamental ctypes data types: --- 289,313 ---- ``value`` : memberdesc This attribute contains the actual value of the instance. For ! integer and pointer types, it is an integer, for character types, ! it is a single character string, for character pointer types it ! is a Python string or unicode string. ! ! When the ``value`` attribute is retrieved from a ctypes instance, ! usually a new object is returned each time. ``ctypes`` does *not* ! implement original object return, always a new object is ! constructed. The same is true for all other ctypes object ! instances. ! ! Fundamental data types, whether returned as result of foreign function ! calls, or, for example, by retrieving structure field members, are ! transparently converted to native Python types. In other words, if a ! foreign function has a ``restype`` of ``c_char_p``, you will always ! receive a Python string, *not* a ``c_char_p`` instance. ! ! Subclasses of fundamental data types do *not* inherit this behaviour. ! So, if a foreign functions ``restype`` is a subclass of ``c_void_p``, ! you will receive an instance of this subclass from the function call. ! Of course, you can get the value of the pointer by accessing the ! ``value`` attribute. These are the fundamental ctypes data types: *************** *** 298,301 **** --- 342,349 ---- ``c_long``. + ``c_int8`` : classdesc* + Represents the C 8-bit ``signed int`` datatype. Usually an alias for + ``c_byte``. + ``c_int16`` : classdesc* Represents the C 16-bit signed int datatype. Usually an alias for *************** *** 310,317 **** for ``c_longlong``. - ``c_int8`` : classdesc* - Represents the C 8-bit ``signed int`` datatype. Usually an alias for - ``c_byte``. - ``c_long`` : classdesc* Represents the C ``signed long`` datatype. The constructor accepts an --- 358,361 ---- *************** *** 340,343 **** --- 384,391 ---- ``c_ulong``. + ``c_uint8`` : classdesc* + Represents the C 8-bit unsigned int datatype. Usually an alias for + ``c_ubyte``. + ``c_uint16`` : classdesc* Represents the C 16-bit unsigned int datatype. Usually an alias for *************** *** 352,374 **** ``c_ulonglong``. - ``c_uint8`` : classdesc* - Represents the C 8-bit unsigned int datatype. Usually an alias for - ``c_ubyte``. - ``c_ulong`` : classdesc* ! Represents the C unsigned long datatype. The constructor accepts an optional integer initializer; no overflow checking is done. ``c_ulonglong`` : classdesc* ! Represents the C unsigned long long datatype. The constructor accepts an optional integer initializer; no overflow checking is done. ``c_ushort`` : classdesc* ! Represents the C unsigned short datatype. The constructor accepts an optional integer initializer; no overflow checking is done. ``c_void_p`` : classdesc* ! Represents the C void * type. The value is represented as integer. The constructor accepts an optional integer initializer. --- 400,418 ---- ``c_ulonglong``. ``c_ulong`` : classdesc* ! Represents the C ``unsigned long`` datatype. The constructor accepts an optional integer initializer; no overflow checking is done. ``c_ulonglong`` : classdesc* ! Represents the C ``unsigned long long`` datatype. The constructor accepts an optional integer initializer; no overflow checking is done. ``c_ushort`` : classdesc* ! Represents the C ``unsigned short`` datatype. The constructor accepts an optional integer initializer; no overflow checking is done. ``c_void_p`` : classdesc* ! Represents the C ``void *`` type. The value is represented as integer. The constructor accepts an optional integer initializer. *************** *** 385,389 **** ``HRESULT`` : classdesc* ! Windows only: Represents a HRESULT value, which contains success or error information for a function or method call. --- 429,433 ---- ``HRESULT`` : classdesc* ! Windows only: Represents a ``HRESULT`` value, which contains success or error information for a function or method call. |
From: Thomas H. <th...@us...> - 2006-05-31 18:02:36
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv31235 Modified Files: tutorial.txt reference.txt Log Message: Rename 'simple data types' into 'fundamental data types'. Index: tutorial.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/tutorial.txt,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** tutorial.txt 26 May 2006 10:28:33 -0000 1.30 --- tutorial.txt 31 May 2006 18:02:31 -0000 1.31 *************** *** 173,178 **** have to learn more about ``ctypes`` data types. ! Simple data types ! ----------------- ``ctypes`` defines a number of primitive C compatible data types : --- 173,178 ---- have to learn more about ``ctypes`` data types. ! Fundamental data types ! ---------------------- ``ctypes`` defines a number of primitive C compatible data types : Index: reference.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/reference.txt,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** reference.txt 30 May 2006 20:07:48 -0000 1.14 --- reference.txt 31 May 2006 18:02:31 -0000 1.15 *************** *** 47,56 **** ----------------- ! The ultimate goal (so to say) of ``ctypes`` is to call functions in ! shared libraries, aka as foreign functions. ! There are several ways to access foreign functions. ! XXX as attributes of loaded libraries. ``CFUNCTYPE(restype, *argtypes)`` : funcdesc --- 47,58 ---- ----------------- ! The ultimate goal of ``ctypes`` is to call functions in shared ! libraries, aka as foreign functions. Foreign function instances can ! be created by accessing them as attributes of loaded shared libraries, ! or by instantiating a *function prototype*. ! Function prototypes are created by factory functions. ! They are created by calling one of the following factory functions: ``CFUNCTYPE(restype, *argtypes)`` : funcdesc *************** *** 251,260 **** library is the loaded shared library. ! simple data types ! ----------------- ``_SimpleCData`` : classdesc* ! This non-public class is the base class of all simple ctypes data ! types. It is mentioned here because it contains the common attributes of the ctypes data types. --- 253,262 ---- library is the loaded shared library. ! Fundamental data types ! ---------------------- ``_SimpleCData`` : classdesc* ! This non-public class is the base class of all fundamental ctypes ! data types. It is mentioned here because it contains the common attributes of the ctypes data types. *************** *** 265,269 **** integer types, it is an integer. ! These are the simple ctypes data types: ``c_byte`` : classdesc* --- 267,271 ---- integer types, it is an integer. ! These are the fundamental ctypes data types: ``c_byte`` : classdesc* |
From: Thomas H. <th...@us...> - 2006-05-31 18:01:49
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv30841 Removed Files: utilities.txt table.txt struct_union.txt simple_types.txt manual.txt libraries.txt libctypes.txt functions.txt docs.txt callbacks.txt Log Message: Remove now-unused files. --- functions.txt DELETED --- --- libraries.txt DELETED --- --- docs.txt DELETED --- --- libctypes.txt DELETED --- --- callbacks.txt DELETED --- --- manual.txt DELETED --- --- utilities.txt DELETED --- --- struct_union.txt DELETED --- --- simple_types.txt DELETED --- --- table.txt DELETED --- |