summaryrefslogtreecommitdiffstats
path: root/Doc/c-api/structures.rst
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-01-03 22:47:39 (GMT)
committerGeorg Brandl <georg@python.org>2009-01-03 22:47:39 (GMT)
commit1f01debe6f94d7f178e14ee7417786461b724e96 (patch)
treef092e467dbf9846ec29f59e626f4d50eb1b2b8c1 /Doc/c-api/structures.rst
parent814a2ca9e4b6360f1de37ed3d8d8d4313ab333bc (diff)
downloadcpython-1f01debe6f94d7f178e14ee7417786461b724e96.zip
cpython-1f01debe6f94d7f178e14ee7417786461b724e96.tar.gz
cpython-1f01debe6f94d7f178e14ee7417786461b724e96.tar.bz2
Merged revisions 68162,68166,68171,68176,68195-68196,68210,68232 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r68162 | ronald.oussoren | 2009-01-02 16:06:00 +0100 (Fri, 02 Jan 2009) | 3 lines Fix for issue 4472 is incompatible with Cygwin, this patch should fix that. ........ r68166 | benjamin.peterson | 2009-01-02 19:26:23 +0100 (Fri, 02 Jan 2009) | 1 line document PyMemberDef ........ r68171 | georg.brandl | 2009-01-02 21:25:14 +0100 (Fri, 02 Jan 2009) | 3 lines #4811: fix markup glitches (mostly remains of the conversion), found by Gabriel Genellina. ........ r68176 | andrew.kuchling | 2009-01-02 22:00:35 +0100 (Fri, 02 Jan 2009) | 1 line Add various items ........ r68195 | georg.brandl | 2009-01-03 14:45:15 +0100 (Sat, 03 Jan 2009) | 2 lines Remove useless string literal. ........ r68196 | georg.brandl | 2009-01-03 15:29:53 +0100 (Sat, 03 Jan 2009) | 2 lines Fix indentation. ........ r68210 | georg.brandl | 2009-01-03 20:10:12 +0100 (Sat, 03 Jan 2009) | 2 lines Set eol-style correctly for mp_distributing.py. ........ r68232 | georg.brandl | 2009-01-03 22:52:16 +0100 (Sat, 03 Jan 2009) | 2 lines Grammar fix. ........
Diffstat (limited to 'Doc/c-api/structures.rst')
-rw-r--r--Doc/c-api/structures.rst61
1 files changed, 61 insertions, 0 deletions
diff --git a/Doc/c-api/structures.rst b/Doc/c-api/structures.rst
index 04fe8f4..fdbd806 100644
--- a/Doc/c-api/structures.rst
+++ b/Doc/c-api/structures.rst
@@ -198,3 +198,64 @@ definition with the same method name.
object and will co-exist with the slot. This is helpful because calls to
PyCFunctions are optimized more than wrapper object calls.
+
+.. ctype:: PyMemberDef
+
+ Structure which describes an attribute of a type which corresponds to a C
+ struct member. Its fields are:
+
+ +------------------+-------------+-------------------------------+
+ | Field | C Type | Meaning |
+ +==================+=============+===============================+
+ | :attr:`name` | char \* | name of the member |
+ +------------------+-------------+-------------------------------+
+ | :attr:`type` | int | the type of the member in the |
+ | | | C struct |
+ +------------------+-------------+-------------------------------+
+ | :attr:`offset` | Py_ssize_t | the offset in bytes that the |
+ | | | member is located on the |
+ | | | type's object struct |
+ +------------------+-------------+-------------------------------+
+ | :attr:`flags` | int | flag bits indicating if the |
+ | | | field should be read-only or |
+ | | | writable |
+ +------------------+-------------+-------------------------------+
+ | :attr:`doc` | char \* | points to the contents of the |
+ | | | docstring |
+ +------------------+-------------+-------------------------------+
+
+ :attr:`type` can be one of many ``T_`` macros corresponding to various C
+ types. When the member is accessed in Python, it will be converted to the
+ equivalent Python type.
+
+ =============== ==================
+ Macro name C type
+ =============== ==================
+ T_SHORT short
+ T_INT int
+ T_LONG long
+ T_FLOAT float
+ T_DOUBLE double
+ T_STRING char \*
+ T_OBJECT PyObject \*
+ T_OBJECT_EX PyObject \*
+ T_CHAR char
+ T_BYTE char
+ T_UNBYTE unsigned char
+ T_UINT unsigned int
+ T_USHORT unsigned short
+ T_ULONG unsigned long
+ T_BOOL char
+ T_LONGLONG long long
+ T_ULONGLONG unsigned long long
+ T_PYSSIZET Py_ssize_t
+ =============== ==================
+
+ :cmacro:`T_OBJECT` and :cmacro:`T_OBJECT_EX` differ in that
+ :cmacro:`T_OBJECT` returns ``None`` if the member is *NULL* and
+ :cmacro:`T_OBJECT_EX` raises an :exc:`AttributeError`.
+
+ :attr:`flags` can be 0 for write and read access or :cmacro:`READONLY` for
+ read-only access. Using :cmacro:`T_STRING` for :attr:`type` implies
+ :cmacro:`READONLY`. Only :cmacro:`T_OBJECT` and :cmacro:`T_OBJECT_EX`
+ members can be deleted. (They are set to *NULL*).