bpo-35134: Add Include/cpython/descrobject.h (GH-30923) · wrongnull/cpython@d4a85f1 · GitHub
Skip to content

Commit d4a85f1

Browse files
authored
bpo-35134: Add Include/cpython/descrobject.h (pythonGH-30923)
Move Include/descrobject.h non-limited API to a new Include/cpython/descrobject.h header file.
1 parent 3eb3b4f commit d4a85f1

5 files changed

Lines changed: 78 additions & 69 deletions

File tree

Include/cpython/descrobject.h

Lines changed: 64 additions & 0 deletions

Include/descrobject.h

Lines changed: 8 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -16,93 +16,33 @@ typedef struct PyGetSetDef {
1616
void *closure;
1717
} PyGetSetDef;
1818

19-
#ifndef Py_LIMITED_API
20-
typedef PyObject *(*wrapperfunc)(PyObject *self, PyObject *args,
21-
void *wrapped);
22-
23-
typedef PyObject *(*wrapperfunc_kwds)(PyObject *self, PyObject *args,
24-
void *wrapped, PyObject *kwds);
25-
26-
struct wrapperbase {
27-
const char *name;
28-
int offset;
29-
void *function;
30-
wrapperfunc wrapper;
31-
const char *doc;
32-
int flags;
33-
PyObject *name_strobj;
34-
};
35-
36-
/* Flags for above struct */
37-
#define PyWrapperFlag_KEYWORDS 1 /* wrapper function takes keyword args */
38-
39-
/* Various kinds of descriptor objects */
40-
41-
typedef struct {
42-
PyObject_HEAD
43-
PyTypeObject *d_type;
44-
PyObject *d_name;
45-
PyObject *d_qualname;
46-
} PyDescrObject;
47-
48-
#define PyDescr_COMMON PyDescrObject d_common
49-
50-
#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type)
51-
#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name)
52-
53-
typedef struct {
54-
PyDescr_COMMON;
55-
PyMethodDef *d_method;
56-
vectorcallfunc vectorcall;
57-
} PyMethodDescrObject;
58-
59-
typedef struct {
60-
PyDescr_COMMON;
61-
struct PyMemberDef *d_member;
62-
} PyMemberDescrObject;
63-
64-
typedef struct {
65-
PyDescr_COMMON;
66-
PyGetSetDef *d_getset;
67-
} PyGetSetDescrObject;
68-
69-
typedef struct {
70-
PyDescr_COMMON;
71-
struct wrapperbase *d_base;
72-
void *d_wrapped; /* This can be any function pointer */
73-
} PyWrapperDescrObject;
74-
#endif /* Py_LIMITED_API */
75-
7619
PyAPI_DATA(PyTypeObject) PyClassMethodDescr_Type;
7720
PyAPI_DATA(PyTypeObject) PyGetSetDescr_Type;
7821
PyAPI_DATA(PyTypeObject) PyMemberDescr_Type;
7922
PyAPI_DATA(PyTypeObject) PyMethodDescr_Type;
8023
PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type;
8124
PyAPI_DATA(PyTypeObject) PyDictProxy_Type;
82-
#ifndef Py_LIMITED_API
83-
PyAPI_DATA(PyTypeObject) _PyMethodWrapper_Type;
84-
#endif /* Py_LIMITED_API */
25+
PyAPI_DATA(PyTypeObject) PyProperty_Type;
26+
// Forward declaration for following prototype
27+
struct PyMemberDef;
8528

8629
PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *);
8730
PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *);
88-
struct PyMemberDef; /* forward declaration for following prototype */
8931
PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *,
9032
struct PyMemberDef *);
9133
PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *,
9234
struct PyGetSetDef *);
93-
#ifndef Py_LIMITED_API
94-
PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *,
95-
struct wrapperbase *, void *);
96-
PyAPI_FUNC(int) PyDescr_IsData(PyObject *);
97-
#endif
9835

9936
PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *);
10037
PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *);
10138

39+
#ifndef Py_LIMITED_API
40+
# define Py_CPYTHON_DESCROBJECT_H
41+
# include "cpython/descrobject.h"
42+
# undef Py_CPYTHON_DESCROBJECT_H
43+
#endif
10244

103-
PyAPI_DATA(PyTypeObject) PyProperty_Type;
10445
#ifdef __cplusplus
10546
}
10647
#endif
10748
#endif /* !Py_DESCROBJECT_H */
108-

Makefile.pre.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,7 @@ PYTHON_HEADERS= \
15051505
$(srcdir)/Include/cpython/code.h \
15061506
$(srcdir)/Include/cpython/compile.h \
15071507
$(srcdir)/Include/cpython/context.h \
1508+
$(srcdir)/Include/cpython/descrobject.h \
15081509
$(srcdir)/Include/cpython/dictobject.h \
15091510
$(srcdir)/Include/cpython/fileobject.h \
15101511
$(srcdir)/Include/cpython/fileutils.h \

PCbuild/pythoncore.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
<ClInclude Include="..\Include\cpython\code.h" />
143143
<ClInclude Include="..\Include\cpython\compile.h" />
144144
<ClInclude Include="..\Include\cpython\context.h" />
145+
<ClInclude Include="..\Include\cpython\descrobject.h" />
145146
<ClInclude Include="..\Include\cpython\dictobject.h" />
146147
<ClInclude Include="..\Include\cpython\fileobject.h" />
147148
<ClInclude Include="..\Include\cpython\fileutils.h" />

PCbuild/pythoncore.vcxproj.filters

Lines changed: 4 additions & 1 deletion

0 commit comments

Comments
 (0)