1 #ifndef Py_STRUCTMEMBER_H
2 #define Py_STRUCTMEMBER_H
8 /* Interface to map C struct members to Python object attributes */
11 #include <stddef.h> /* For offsetof */
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
21 #define offsetof(type, member) ( (int) & ((type*)0) -> member )
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
26 PyMember_Get() and set by PyMember_Set() (except if their READONLY flag
27 is set). The array must be terminated with an entry whose name
31 /* Obsolete version, for binary backwards compatibility */
38 typedef struct PyMemberDef
{
39 /* Current version, use this */
55 /* XXX the ordering here is weird for binary compatibility */
56 #define T_CHAR 7 /* 1-character string */
57 #define T_BYTE 8 /* 8-bit signed int */
58 /* unsigned variants: */
64 /* Added by Jack: strings contained in the structure */
65 #define T_STRING_INPLACE 13
67 #define T_PSTRING 14 /* macintosh pascal-style counted string */
68 #define T_PSTRING_INPLACE 15
69 #endif /* macintosh */
71 #define T_OBJECT_EX 16 /* Like T_OBJECT, but raises AttributeError
72 when the value is NULL, instead of
73 converting to None. */
77 #define RO READONLY /* Shorthand */
78 #define READ_RESTRICTED 2
79 #define WRITE_RESTRICTED 4
80 #define RESTRICTED (READ_RESTRICTED | WRITE_RESTRICTED)
83 /* Obsolete API, for binary backwards compatibility */
84 PyAPI_FUNC(PyObject
*) PyMember_Get(char *, struct memberlist
*, char *);
85 PyAPI_FUNC(int) PyMember_Set(char *, struct memberlist
*, char *, PyObject
*);
87 /* Current API, use this */
88 PyAPI_FUNC(PyObject
*) PyMember_GetOne(char *, struct PyMemberDef
*);
89 PyAPI_FUNC(int) PyMember_SetOne(char *, struct PyMemberDef
*, PyObject
*);
95 #endif /* !Py_STRUCTMEMBER_H */