1 #ifndef Py_STRUCTMEMBER_H
2 #define Py_STRUCTMEMBER_H
8 /* Interface to map C struct members to Python object attributes */
10 #include <stddef.h> /* For offsetof */
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
19 #define offsetof(type, member) ( (int) & ((type*)0) -> member )
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
24 PyMember_Get() and set by PyMember_Set() (except if their READONLY flag
25 is set). The array must be terminated with an entry whose name
29 /* Obsolete version, for binary backwards compatibility */
36 typedef struct PyMemberDef
{
37 /* Current version, use this */
53 /* XXX the ordering here is weird for binary compatibility */
54 #define T_CHAR 7 /* 1-character string */
55 #define T_BYTE 8 /* 8-bit signed int */
56 /* unsigned variants: */
62 /* Added by Jack: strings contained in the structure */
63 #define T_STRING_INPLACE 13
65 /* Added by Lillo: bools contained in the structure (assumed char) */
68 #define T_OBJECT_EX 16 /* Like T_OBJECT, but raises AttributeError
69 when the value is NULL, instead of
70 converting to None. */
73 #define T_ULONGLONG 18
74 #endif /* HAVE_LONG_LONG */
76 #define T_PYSSIZET 19 /* Py_ssize_t */
81 #define RO READONLY /* Shorthand */
82 #define READ_RESTRICTED 2
83 #define PY_WRITE_RESTRICTED 4
84 #define RESTRICTED (READ_RESTRICTED | PY_WRITE_RESTRICTED)
87 /* Obsolete API, for binary backwards compatibility */
88 PyAPI_FUNC(PyObject
*) PyMember_Get(const char *, struct memberlist
*, const char *);
89 PyAPI_FUNC(int) PyMember_Set(char *, struct memberlist
*, const char *, PyObject
*);
91 /* Current API, use this */
92 PyAPI_FUNC(PyObject
*) PyMember_GetOne(const char *, struct PyMemberDef
*);
93 PyAPI_FUNC(int) PyMember_SetOne(char *, struct PyMemberDef
*, PyObject
*);
99 #endif /* !Py_STRUCTMEMBER_H */