annotate Include/structmember.h @ 80661:94de77bd0b4b 2.7

Issue #16194: document imp.load_dynamic problems when read several extension modules from the same binary object file.
author Andrew Svetlov <andrew.svetlov@gmail.com>
date Thu, 29 Nov 2012 19:51:28 +0200
parents fd25030223b0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1329
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
1 #ifndef Py_STRUCTMEMBER_H
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
2 #define Py_STRUCTMEMBER_H
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
3 #ifdef __cplusplus
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
4 extern "C" {
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
5 #endif
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
6
145
853b736a6a9e Added copyright notice.
Guido van Rossum <guido@python.org>
parents: 86
diff changeset
7
86
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 /* Interface to map C struct members to Python object attributes */
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents:
diff changeset
9
1991
744265374450 include stddef.h
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
10 #include <stddef.h> /* For offsetof */
744265374450 include stddef.h
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
11
86
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 /* The offsetof() macro calculates the offset of a structure member
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 in its structure. Unfortunately this cannot be written down
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 portably, hence it is provided by a Standard C header file.
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 For pre-Standard C compilers, here is a version that usually works
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 (but watch out!): */
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents:
diff changeset
17
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 #ifndef offsetof
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 #define offsetof(type, member) ( (int) & ((type*)0) -> member )
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 #endif
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents:
diff changeset
21
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents:
diff changeset
22 /* An array of memberlist structures defines the name, type and offset
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 of selected members of a C structure. These can be read by
2129
05360cd616ae The great renaming, phase two: all header files have been updated to
Guido van Rossum <guido@python.org>
parents: 2058
diff changeset
24 PyMember_Get() and set by PyMember_Set() (except if their READONLY flag
86
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents:
diff changeset
25 is set). The array must be terminated with an entry whose name
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents:
diff changeset
26 pointer is NULL. */
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents:
diff changeset
27
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 struct memberlist {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
29 /* Obsolete version, for binary backwards compatibility */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
30 char *name;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
31 int type;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
32 int offset;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
33 int flags;
86
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents:
diff changeset
34 };
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents:
diff changeset
35
20012
3faabf54b8b8 Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents: 19942
diff changeset
36 typedef struct PyMemberDef {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
37 /* Current version, use this */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
38 char *name;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
39 int type;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
40 Py_ssize_t offset;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
41 int flags;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
42 char *doc;
20012
3faabf54b8b8 Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents: 19942
diff changeset
43 } PyMemberDef;
3faabf54b8b8 Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents: 19942
diff changeset
44
86
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents:
diff changeset
45 /* Types */
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
46 #define T_SHORT 0
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
47 #define T_INT 1
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
48 #define T_LONG 2
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
49 #define T_FLOAT 3
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
50 #define T_DOUBLE 4
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
51 #define T_STRING 5
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
52 #define T_OBJECT 6
889
181409141a18 added BYTE, CHAR and unsigned variants
Guido van Rossum <guido@python.org>
parents: 790
diff changeset
53 /* XXX the ordering here is weird for binary compatibility */
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
54 #define T_CHAR 7 /* 1-character string */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
55 #define T_BYTE 8 /* 8-bit signed int */
889
181409141a18 added BYTE, CHAR and unsigned variants
Guido van Rossum <guido@python.org>
parents: 790
diff changeset
56 /* unsigned variants: */
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
57 #define T_UBYTE 9
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
58 #define T_USHORT 10
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
59 #define T_UINT 11
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
60 #define T_ULONG 12
86
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents:
diff changeset
61
2023
3d431a521132 - Added ability to get at strings embedded in the struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 1991
diff changeset
62 /* Added by Jack: strings contained in the structure */
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
63 #define T_STRING_INPLACE 13
2023
3d431a521132 - Added ability to get at strings embedded in the struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 1991
diff changeset
64
44863
eb4b50f739f6 Patch #1720595: add T_BOOL to the range of structmember types.
Georg Brandl <georg@python.org>
parents: 43972
diff changeset
65 /* Added by Lillo: bools contained in the structure (assumed char) */
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
66 #define T_BOOL 14
44863
eb4b50f739f6 Patch #1720595: add T_BOOL to the range of structmember types.
Georg Brandl <georg@python.org>
parents: 43972
diff changeset
67
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
68 #define T_OBJECT_EX 16 /* Like T_OBJECT, but raises AttributeError
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
69 when the value is NULL, instead of
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
70 converting to None. */
34677
e9ffad6d8822 Patch #1115086: support PY_LONGLONG in structmember.
Martin v. Löwis <martin@v.loewis.de>
parents: 31504
diff changeset
71 #ifdef HAVE_LONG_LONG
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
72 #define T_LONGLONG 17
34677
e9ffad6d8822 Patch #1115086: support PY_LONGLONG in structmember.
Martin v. Löwis <martin@v.loewis.de>
parents: 31504
diff changeset
73 #define T_ULONGLONG 18
42424
723cb9e3fa50 Py_ssize_t is defined regardless of HAVE_LONG_LONG. Will backport
Neal Norwitz <nnorwitz@gmail.com>
parents: 42083
diff changeset
74 #endif /* HAVE_LONG_LONG */
723cb9e3fa50 Py_ssize_t is defined regardless of HAVE_LONG_LONG. Will backport
Neal Norwitz <nnorwitz@gmail.com>
parents: 42083
diff changeset
75
42083
37189e375ec7 Add T_PYSSIZET in structmember.h: This can be used for
Walter Dörwald <walter@livinglogic.de>
parents: 36516
diff changeset
76 #define T_PYSSIZET 19 /* Py_ssize_t */
42424
723cb9e3fa50 Py_ssize_t is defined regardless of HAVE_LONG_LONG. Will backport
Neal Norwitz <nnorwitz@gmail.com>
parents: 42083
diff changeset
77
21187
ef6f692c76e2 Fix SF bug #486144: Uninitialized __slot__ vrbl is None.
Guido van Rossum <guido@python.org>
parents: 20012
diff changeset
78
19942
8522b022f80a Add support for restricting access based on restricted execution mode.
Guido van Rossum <guido@python.org>
parents: 14375
diff changeset
79 /* Flags */
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
80 #define READONLY 1
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
81 #define RO READONLY /* Shorthand */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
82 #define READ_RESTRICTED 2
43972
a8dd8874ff2d Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents: 42424
diff changeset
83 #define PY_WRITE_RESTRICTED 4
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 44863
diff changeset
84 #define RESTRICTED (READ_RESTRICTED | PY_WRITE_RESTRICTED)
19942
8522b022f80a Add support for restricting access based on restricted execution mode.
Guido van Rossum <guido@python.org>
parents: 14375
diff changeset
85
86
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents:
diff changeset
86
20012
3faabf54b8b8 Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents: 19942
diff changeset
87 /* Obsolete API, for binary backwards compatibility */
36114
e9a10f74cf88 const poisoning, spreading to fix new const warnings
Tim Peters <tim.peters@gmail.com>
parents: 34677
diff changeset
88 PyAPI_FUNC(PyObject *) PyMember_Get(const char *, struct memberlist *, const char *);
e9a10f74cf88 const poisoning, spreading to fix new const warnings
Tim Peters <tim.peters@gmail.com>
parents: 34677
diff changeset
89 PyAPI_FUNC(int) PyMember_Set(char *, struct memberlist *, const char *, PyObject *);
1329
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
90
20012
3faabf54b8b8 Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents: 19942
diff changeset
91 /* Current API, use this */
36114
e9a10f74cf88 const poisoning, spreading to fix new const warnings
Tim Peters <tim.peters@gmail.com>
parents: 34677
diff changeset
92 PyAPI_FUNC(PyObject *) PyMember_GetOne(const char *, struct PyMemberDef *);
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 21187
diff changeset
93 PyAPI_FUNC(int) PyMember_SetOne(char *, struct PyMemberDef *, PyObject *);
20012
3faabf54b8b8 Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents: 19942
diff changeset
94
3faabf54b8b8 Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents: 19942
diff changeset
95
1329
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
96 #ifdef __cplusplus
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
97 }
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
98 #endif
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
99 #endif /* !Py_STRUCTMEMBER_H */