Skip to content

Commit 7974eb8

Browse files
committed
Merge pull request #1209 from kmod/cpython_descr2
Switch to CPython's descrobject.c
2 parents c9cab0e + a11ffa7 commit 7974eb8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2068
-1284
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ nosearch_check_%: %.py pyston_dbg check-deps
856856
$(call make_search,check_%)
857857

858858
nosearch_dbgpy_% nosearch_pydbg_%: %.py ext_pythondbg
859-
export PYTHON_VERSION=$$(python2.7-dbg -V 2>&1 | awk '{print $$2}'); PYTHONPATH=test/test_extension/build/lib.linux-x86_64-2.7-pydebug $(GDB) --ex "dir $(DEPS_DIR)/python-src/python2.7-$$PYTHON_VERSION/debian" $(GDB_CMDS) --args python2.7-dbg $<
859+
export PYTHON_VERSION=$$(python2.7-dbg -V 2>&1 | awk '{print $$2}'); PYTHONPATH=test/test_extension/build/lib.linux-x86_64-2.7-pydebug $(GDB) --ex "dir $(DEPS_DIR)/python-src/python2.7-$$PYTHON_VERSION/debian" $(GDB_CMDS) --args python2.7-dbg $(ARGS) $<
860860
$(call make_search,dbgpy_%)
861861
$(call make_search,pydbg_%)
862862

from_cpython/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ file(GLOB_RECURSE STDOBJECT_SRCS Objects
8686
capsule.c
8787
cobject.c
8888
complexobject.c
89+
descrobject.c
8990
dictobject.c
90-
dictproxy.c
9191
errors.c
9292
exceptions.c
9393
floatobject.c

from_cpython/Include/descrobject.h

+15-16
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,16 @@ typedef PyObject *(*wrapperfunc)(PyObject *self, PyObject *args,
2424
typedef PyObject *(*wrapperfunc_kwds)(PyObject *self, PyObject *args,
2525
void *wrapped, PyObject *kwds);
2626

27+
// Pyston addition: faster CC
2728
typedef PyObject *(*wrapperfunc_1arg)(PyObject *self, void *wrapped);
29+
typedef PyObject *(*wrapperfunc_2arg)(PyObject *self, PyObject* arg, void *wrapped);
2830

2931
struct wrapperbase {
30-
char *name;
32+
const char *name;
3133
int offset;
3234
void *function;
3335
wrapperfunc wrapper;
34-
char *doc;
36+
const char *doc;
3537
int flags;
3638
PyObject *name_strobj;
3739
};
@@ -45,8 +47,6 @@ struct wrapperbase {
4547

4648
/* Various kinds of descriptor objects */
4749

48-
// Pyston change: these are not our object layouts
49-
#if 0
5050
#define PyDescr_COMMON \
5151
PyObject_HEAD \
5252
PyTypeObject *d_type; \
@@ -76,21 +76,11 @@ typedef struct {
7676
struct wrapperbase *d_base;
7777
void *d_wrapped; /* This can be any function pointer */
7878
} PyWrapperDescrObject;
79-
#endif
80-
// (Pyston TODO: add opaque definitions of those names)
8179

82-
// Pyston change: these are not static objects any more
83-
#if 0
8480
PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type;
8581
PyAPI_DATA(PyTypeObject) PyDictProxy_Type;
8682
PyAPI_DATA(PyTypeObject) PyGetSetDescr_Type;
8783
PyAPI_DATA(PyTypeObject) PyMemberDescr_Type;
88-
#else
89-
PyAPI_DATA(PyTypeObject) PyDictProxy_Type;
90-
#endif
91-
// (Pyston TODO: add #defines to our names)
92-
PyAPI_DATA(PyTypeObject*) wrapperdescr_cls;
93-
#define PyWrapperDescr_Type (*wrapperdescr_cls)
9484

9585
PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *) PYSTON_NOEXCEPT;
9686
PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *) PYSTON_NOEXCEPT;
@@ -106,8 +96,17 @@ PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *) PYSTON_NOEXCEPT;
10696
PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *) PYSTON_NOEXCEPT;
10797

10898

109-
// Pyston change: this is no longer a static object
110-
//PyAPI_DATA(PyTypeObject) PyProperty_Type;
99+
PyAPI_DATA(PyTypeObject) PyProperty_Type;
100+
101+
// Pyston change: exposed these
102+
typedef struct {
103+
PyObject_HEAD
104+
PyWrapperDescrObject *descr;
105+
PyObject *self;
106+
} wrapperobject;
107+
PyAPI_DATA(PyTypeObject) wrappertype;
108+
PyAPI_DATA(PyTypeObject) PyMethodDescr_Type;
109+
PyAPI_DATA(PyTypeObject) PyClassMethodDescr_Type;
111110

112111
#ifdef __cplusplus
113112
}

from_cpython/Include/structmember.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct memberlist {
3737

3838
typedef struct PyMemberDef {
3939
/* Current version, use this */
40-
char *name;
40+
const char *name;
4141
int type;
4242
Py_ssize_t offset;
4343
int flags;

0 commit comments

Comments
 (0)