| OLD | NEW |
| 1 :mod:`ctypes` --- A foreign function library for Python | 1 :mod:`ctypes` --- A foreign function library for Python |
| 2 ======================================================= | 2 ======================================================= |
| 3 | 3 |
| 4 .. module:: ctypes | 4 .. module:: ctypes |
| 5 :synopsis: A foreign function library for Python. | 5 :synopsis: A foreign function library for Python. |
| 6 .. moduleauthor:: Thomas Heller <theller@python.net> | 6 .. moduleauthor:: Thomas Heller <theller@python.net> |
| 7 | 7 |
| 8 | 8 |
| 9 :mod:`ctypes` is a foreign function library for Python. It provides C compatibl
e | 9 :mod:`ctypes` is a foreign function library for Python. It provides C compatibl
e |
| 10 data types, and allows calling functions in DLLs or shared libraries. It can be | 10 data types, and allows calling functions in DLLs or shared libraries. It can be |
| (...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 | 858 |
| 859 Incomplete Types | 859 Incomplete Types |
| 860 ^^^^^^^^^^^^^^^^ | 860 ^^^^^^^^^^^^^^^^ |
| 861 | 861 |
| 862 *Incomplete Types* are structures, unions or arrays whose members are not yet | 862 *Incomplete Types* are structures, unions or arrays whose members are not yet |
| 863 specified. In C, they are specified by forward declarations, which are defined | 863 specified. In C, they are specified by forward declarations, which are defined |
| 864 later:: | 864 later:: |
| 865 | 865 |
| 866 struct cell; /* forward declaration */ | 866 struct cell; /* forward declaration */ |
| 867 | 867 |
| 868 struct cell { | 868 struct { |
| 869 char *name; | 869 char *name; |
| 870 struct cell *next; | 870 struct cell *next; |
| 871 }; | 871 } cell; |
| 872 | 872 |
| 873 The straightforward translation into ctypes code would be this, but it does not | 873 The straightforward translation into ctypes code would be this, but it does not |
| 874 work:: | 874 work:: |
| 875 | 875 |
| 876 >>> class cell(Structure): | 876 >>> class cell(Structure): |
| 877 ... _fields_ = [("name", c_char_p), | 877 ... _fields_ = [("name", c_char_p), |
| 878 ... ("next", POINTER(cell))] | 878 ... ("next", POINTER(cell))] |
| 879 ... | 879 ... |
| 880 Traceback (most recent call last): | 880 Traceback (most recent call last): |
| 881 File "<stdin>", line 1, in ? | 881 File "<stdin>", line 1, in ? |
| (...skipping 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2431 | 2431 |
| 2432 | 2432 |
| 2433 .. _ctypes-arrays-pointers: | 2433 .. _ctypes-arrays-pointers: |
| 2434 | 2434 |
| 2435 Arrays and pointers | 2435 Arrays and pointers |
| 2436 ^^^^^^^^^^^^^^^^^^^ | 2436 ^^^^^^^^^^^^^^^^^^^ |
| 2437 | 2437 |
| 2438 Not yet written - please see the sections :ref:`ctypes-pointers` and section | 2438 Not yet written - please see the sections :ref:`ctypes-pointers` and section |
| 2439 :ref:`ctypes-arrays` in the tutorial. | 2439 :ref:`ctypes-arrays` in the tutorial. |
| 2440 | 2440 |
| OLD | NEW |