Mercurial > cpython-lru_cache-weakref
annotate Include/structmember.h @ 27998:e27f58a50737 legacy-trunk
SF bug #690377: Dud footnote reference in distutils docs
| author | Raymond Hettinger <python@rcn.com> |
|---|---|
| date | Fri, 21 Feb 2003 02:47:09 +0000 |
| parents | c1eb668525e1 |
| children | 86fdf8fe7f17 |
| 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 #ifdef HAVE_STDDEF_H |
| 11 #include <stddef.h> /* For offsetof */ | |
| 12 #endif | |
| 13 | |
| 86 | 14 /* The offsetof() macro calculates the offset of a structure member |
| 15 in its structure. Unfortunately this cannot be written down | |
| 16 portably, hence it is provided by a Standard C header file. | |
| 17 For pre-Standard C compilers, here is a version that usually works | |
| 18 (but watch out!): */ | |
| 19 | |
| 20 #ifndef offsetof | |
| 21 #define offsetof(type, member) ( (int) & ((type*)0) -> member ) | |
| 22 #endif | |
| 23 | |
| 24 /* An array of memberlist structures defines the name, type and offset | |
| 25 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
|
26 PyMember_Get() and set by PyMember_Set() (except if their READONLY flag |
| 86 | 27 is set). The array must be terminated with an entry whose name |
| 28 pointer is NULL. */ | |
| 29 | |
| 30 struct memberlist { | |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
31 /* Obsolete version, for binary backwards compatibility */ |
| 86 | 32 char *name; |
| 33 int type; | |
| 34 int offset; | |
|
19942
8522b022f80a
Add support for restricting access based on restricted execution mode.
Guido van Rossum <guido@python.org>
parents:
14375
diff
changeset
|
35 int flags; |
| 86 | 36 }; |
| 37 | |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
38 typedef struct PyMemberDef { |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
39 /* Current version, use this */ |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
40 char *name; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
41 int type; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
42 int offset; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
43 int flags; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
44 char *doc; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
45 } PyMemberDef; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
46 |
| 86 | 47 /* Types */ |
| 48 #define T_SHORT 0 | |
| 49 #define T_INT 1 | |
| 50 #define T_LONG 2 | |
| 51 #define T_FLOAT 3 | |
| 52 #define T_DOUBLE 4 | |
| 53 #define T_STRING 5 | |
| 54 #define T_OBJECT 6 | |
|
889
181409141a18
added BYTE, CHAR and unsigned variants
Guido van Rossum <guido@python.org>
parents:
790
diff
changeset
|
55 /* 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
|
56 #define T_CHAR 7 /* 1-character string */ |
|
181409141a18
added BYTE, CHAR and unsigned variants
Guido van Rossum <guido@python.org>
parents:
790
diff
changeset
|
57 #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
|
58 /* unsigned variants: */ |
|
181409141a18
added BYTE, CHAR and unsigned variants
Guido van Rossum <guido@python.org>
parents:
790
diff
changeset
|
59 #define T_UBYTE 9 |
|
181409141a18
added BYTE, CHAR and unsigned variants
Guido van Rossum <guido@python.org>
parents:
790
diff
changeset
|
60 #define T_USHORT 10 |
|
181409141a18
added BYTE, CHAR and unsigned variants
Guido van Rossum <guido@python.org>
parents:
790
diff
changeset
|
61 #define T_UINT 11 |
|
181409141a18
added BYTE, CHAR and unsigned variants
Guido van Rossum <guido@python.org>
parents:
790
diff
changeset
|
62 #define T_ULONG 12 |
| 86 | 63 |
|
2023
3d431a521132
- Added ability to get at strings embedded in the struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
1991
diff
changeset
|
64 /* 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
|
65 #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
|
66 #ifdef macintosh |
|
3d431a521132
- Added ability to get at strings embedded in the struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
1991
diff
changeset
|
67 #define T_PSTRING 14 /* macintosh pascal-style counted string */ |
|
3d431a521132
- Added ability to get at strings embedded in the struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
1991
diff
changeset
|
68 #define T_PSTRING_INPLACE 15 |
|
3d431a521132
- Added ability to get at strings embedded in the struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
1991
diff
changeset
|
69 #endif /* macintosh */ |
|
3d431a521132
- Added ability to get at strings embedded in the struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
1991
diff
changeset
|
70 |
|
21187
ef6f692c76e2
Fix SF bug #486144: Uninitialized __slot__ vrbl is None.
Guido van Rossum <guido@python.org>
parents:
20012
diff
changeset
|
71 #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
|
72 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
|
73 converting to None. */ |
|
ef6f692c76e2
Fix SF bug #486144: Uninitialized __slot__ vrbl is None.
Guido van Rossum <guido@python.org>
parents:
20012
diff
changeset
|
74 |
|
19942
8522b022f80a
Add support for restricting access based on restricted execution mode.
Guido van Rossum <guido@python.org>
parents:
14375
diff
changeset
|
75 /* Flags */ |
| 86 | 76 #define READONLY 1 |
| 77 #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
|
78 #define READ_RESTRICTED 2 |
|
8522b022f80a
Add support for restricting access based on restricted execution mode.
Guido van Rossum <guido@python.org>
parents:
14375
diff
changeset
|
79 #define WRITE_RESTRICTED 4 |
|
8522b022f80a
Add support for restricting access based on restricted execution mode.
Guido van Rossum <guido@python.org>
parents:
14375
diff
changeset
|
80 #define RESTRICTED (READ_RESTRICTED | WRITE_RESTRICTED) |
|
8522b022f80a
Add support for restricting access based on restricted execution mode.
Guido van Rossum <guido@python.org>
parents:
14375
diff
changeset
|
81 |
| 86 | 82 |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
83 /* Obsolete API, for binary backwards compatibility */ |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
21187
diff
changeset
|
84 PyAPI_FUNC(PyObject *) PyMember_Get(char *, struct memberlist *, char *); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
21187
diff
changeset
|
85 PyAPI_FUNC(int) PyMember_Set(char *, struct memberlist *, char *, PyObject *); |
|
1329
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
86 |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
87 /* Current API, use this */ |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
21187
diff
changeset
|
88 PyAPI_FUNC(PyObject *) PyMember_GetOne(char *, struct PyMemberDef *); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
21187
diff
changeset
|
89 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
|
90 |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
91 |
|
1329
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
92 #ifdef __cplusplus |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
93 } |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
94 #endif |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
95 #endif /* !Py_STRUCTMEMBER_H */ |
