Mercurial > cpython-lru_cache-weakref
annotate Include/structmember.h @ 58765:2ba7677bfa95 legacy-trunk
testCopysign was defined twice in test_math; combine the definitions
| author | Mark Dickinson <dickinsm@gmail.com> |
|---|---|
| date | Sat, 06 Feb 2010 23:11:25 +0000 |
| parents | eb4b50f739f6 |
| children | fd25030223b0 |
| 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 | 7 |
| 86 | 8 /* Interface to map C struct members to Python object attributes */ |
| 9 | |
| 1991 | 10 #include <stddef.h> /* For offsetof */ |
| 11 | |
| 86 | 12 /* The offsetof() macro calculates the offset of a structure member |
| 13 in its structure. Unfortunately this cannot be written down | |
| 14 portably, hence it is provided by a Standard C header file. | |
| 15 For pre-Standard C compilers, here is a version that usually works | |
| 16 (but watch out!): */ | |
| 17 | |
| 18 #ifndef offsetof | |
| 19 #define offsetof(type, member) ( (int) & ((type*)0) -> member ) | |
| 20 #endif | |
| 21 | |
| 22 /* An array of memberlist structures defines the name, type and offset | |
| 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 | 25 is set). The array must be terminated with an entry whose name |
| 26 pointer is NULL. */ | |
| 27 | |
| 28 struct memberlist { | |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
29 /* Obsolete version, for binary backwards compatibility */ |
| 86 | 30 char *name; |
| 31 int type; | |
| 32 int offset; | |
|
19942
8522b022f80a
Add support for restricting access based on restricted execution mode.
Guido van Rossum <guido@python.org>
parents:
14375
diff
changeset
|
33 int flags; |
| 86 | 34 }; |
| 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 { |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
37 /* Current version, use this */ |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
38 char *name; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
39 int type; |
|
36516
7dc1fe77713f
Allow for ssize_t field offsets.
Martin v. Löwis <martin@v.loewis.de>
parents:
36114
diff
changeset
|
40 Py_ssize_t offset; |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
41 int flags; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
42 char *doc; |
|
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 | 45 /* Types */ |
| 46 #define T_SHORT 0 | |
| 47 #define T_INT 1 | |
| 48 #define T_LONG 2 | |
| 49 #define T_FLOAT 3 | |
| 50 #define T_DOUBLE 4 | |
| 51 #define T_STRING 5 | |
| 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 */ |
|
181409141a18
added BYTE, CHAR and unsigned variants
Guido van Rossum <guido@python.org>
parents:
790
diff
changeset
|
54 #define T_CHAR 7 /* 1-character string */ |
|
181409141a18
added BYTE, CHAR and unsigned variants
Guido van Rossum <guido@python.org>
parents:
790
diff
changeset
|
55 #define T_BYTE 8 /* 8-bit signed int */ |
|
181409141a18
added BYTE, CHAR and unsigned variants
Guido van Rossum <guido@python.org>
parents:
790
diff
changeset
|
56 /* unsigned variants: */ |
|
181409141a18
added BYTE, CHAR and unsigned variants
Guido van Rossum <guido@python.org>
parents:
790
diff
changeset
|
57 #define T_UBYTE 9 |
|
181409141a18
added BYTE, CHAR and unsigned variants
Guido van Rossum <guido@python.org>
parents:
790
diff
changeset
|
58 #define T_USHORT 10 |
|
181409141a18
added BYTE, CHAR and unsigned variants
Guido van Rossum <guido@python.org>
parents:
790
diff
changeset
|
59 #define T_UINT 11 |
|
181409141a18
added BYTE, CHAR and unsigned variants
Guido van Rossum <guido@python.org>
parents:
790
diff
changeset
|
60 #define T_ULONG 12 |
| 86 | 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 */ |
|
3d431a521132
- Added ability to get at strings embedded in the struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
1991
diff
changeset
|
63 #define T_STRING_INPLACE 13 |
|
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) */ |
|
eb4b50f739f6
Patch #1720595: add T_BOOL to the range of structmember types.
Georg Brandl <georg@python.org>
parents:
43972
diff
changeset
|
66 #define T_BOOL 14 |
|
eb4b50f739f6
Patch #1720595: add T_BOOL to the range of structmember types.
Georg Brandl <georg@python.org>
parents:
43972
diff
changeset
|
67 |
|
21187
ef6f692c76e2
Fix SF bug #486144: Uninitialized __slot__ vrbl is None.
Guido van Rossum <guido@python.org>
parents:
20012
diff
changeset
|
68 #define T_OBJECT_EX 16 /* Like T_OBJECT, but raises AttributeError |
|
ef6f692c76e2
Fix SF bug #486144: Uninitialized __slot__ vrbl is None.
Guido van Rossum <guido@python.org>
parents:
20012
diff
changeset
|
69 when the value is NULL, instead of |
|
ef6f692c76e2
Fix SF bug #486144: Uninitialized __slot__ vrbl is None.
Guido van Rossum <guido@python.org>
parents:
20012
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 |
|
e9ffad6d8822
Patch #1115086: support PY_LONGLONG in structmember.
Martin v. Löwis <martin@v.loewis.de>
parents:
31504
diff
changeset
|
72 #define T_LONGLONG 17 |
|
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 */ |
| 86 | 80 #define READONLY 1 |
| 81 #define RO READONLY /* Shorthand */ | |
|
19942
8522b022f80a
Add support for restricting access based on restricted execution mode.
Guido van Rossum <guido@python.org>
parents:
14375
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 |
|
a8dd8874ff2d
Backport of the PCbuild9 directory from the py3k branch.
Christian Heimes <christian@cheimes.de>
parents:
42424
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 | 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 */ |
