1 /* Descriptors */
2 #ifndef Py_DESCROBJECT_H
3 #define Py_DESCROBJECT_H
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
8 typedef PyObject *(*getter)(PyObject *, void *);
9 typedef int (*setter)(PyObject *, PyObject *, void *);
10
11 struct PyGetSetDef {
12 const char *name;
13 getter get;
14 setter set;
15 const char *doc;
16 void *closure;
17 };
18
19 PyAPI_DATA(PyTypeObject) PyClassMethodDescr_Type;
20 PyAPI_DATA(PyTypeObject) PyGetSetDescr_Type;
21 PyAPI_DATA(PyTypeObject) PyMemberDescr_Type;
22 PyAPI_DATA(PyTypeObject) PyMethodDescr_Type;
23 PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type;
24 PyAPI_DATA(PyTypeObject) PyDictProxy_Type;
25 PyAPI_DATA(PyTypeObject) PyProperty_Type;
26
27 PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *);
28 PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *);
29 PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *, PyMemberDef *);
30 PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *, PyGetSetDef *);
31
32 PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *);
33 PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *);
34
35
36 /* An array of PyMemberDef structures defines the name, type and offset
37 of selected members of a C structure. These can be read by
38 PyMember_GetOne() and set by PyMember_SetOne() (except if their READONLY
39 flag is set). The array must be terminated with an entry whose name
40 pointer is NULL. */
41 struct PyMemberDef {
42 const char *name;
43 int type;
44 Py_ssize_t offset;
45 int flags;
46 const char *doc;
47 };
48
49 // These constants used to be in structmember.h, not prefixed by Py_.
50 // (structmember.h now has aliases to the new names.)
51
52 /* Types */
53 #define Py_T_SHORT 0
54 #define Py_T_INT 1
55 #define Py_T_LONG 2
56 #define Py_T_FLOAT 3
57 #define Py_T_DOUBLE 4
58 #define Py_T_STRING 5
59 #define _Py_T_OBJECT 6 // Deprecated, use Py_T_OBJECT_EX instead
60 /* the ordering here is weird for binary compatibility */
61 #define Py_T_CHAR 7 /* 1-character string */
62 #define Py_T_BYTE 8 /* 8-bit signed int */
63 /* unsigned variants: */
64 #define Py_T_UBYTE 9
65 #define Py_T_USHORT 10
66 #define Py_T_UINT 11
67 #define Py_T_ULONG 12
68
69 /* Added by Jack: strings contained in the structure */
70 #define Py_T_STRING_INPLACE 13
71
72 /* Added by Lillo: bools contained in the structure (assumed char) */
73 #define Py_T_BOOL 14
74
75 #define Py_T_OBJECT_EX 16
76 #define Py_T_LONGLONG 17
77 #define Py_T_ULONGLONG 18
78
79 #define Py_T_PYSSIZET 19 /* Py_ssize_t */
80 #define _Py_T_NONE 20 // Deprecated. Value is always None.
81
82 /* Flags */
83 #define Py_READONLY 1
84 #define Py_AUDIT_READ 2 // Added in 3.10, harmless no-op before that
85 #define _Py_WRITE_RESTRICTED 4 // Deprecated, no-op. Do not reuse the value.
86 #define Py_RELATIVE_OFFSET 8
87
88 PyAPI_FUNC(PyObject *) PyMember_GetOne(const char *, PyMemberDef *);
89 PyAPI_FUNC(int) PyMember_SetOne(char *, PyMemberDef *, PyObject *);
90
91 #ifndef Py_LIMITED_API
92 # define Py_CPYTHON_DESCROBJECT_H
93 # include "cpython/descrobject.h"
94 # undef Py_CPYTHON_DESCROBJECT_H
95 #endif
96
97 #ifdef __cplusplus
98 }
99 #endif
100 #endif /* !Py_DESCROBJECT_H */