Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

WIP: Stackless issue #202: remove the STACKLESS_DECLARE_METHOD magic #202

Merged
merged 1 commit into from
Jan 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions Objects/classobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,12 @@ method_descr_get(PyObject *meth, PyObject *obj, PyObject *cls)
return PyMethod_New(PyMethod_GET_FUNCTION(meth), obj);
}

#ifdef STACKLESS
static PyMappingMethods method_as_mapping = {
.slpflags.tp_call = -1,
};
#endif

PyTypeObject PyMethod_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"method",
Expand All @@ -345,14 +351,15 @@ PyTypeObject PyMethod_Type = {
(reprfunc)method_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
SLP_TP_AS_MAPPING(method_as_mapping), /* tp_as_mapping */
(hashfunc)method_hash, /* tp_hash */
method_call, /* tp_call */
0, /* tp_str */
method_getattro, /* tp_getattro */
PyObject_GenericSetAttr, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
Py_TPFLAGS_HAVE_STACKLESS_EXTENSION, /* tp_flags */
method_doc, /* tp_doc */
(traverseproc)method_traverse, /* tp_traverse */
0, /* tp_clear */
Expand All @@ -373,8 +380,6 @@ PyTypeObject PyMethod_Type = {
method_new, /* tp_new */
};

STACKLESS_DECLARE_METHOD(&PyMethod_Type, tp_call)

/* Clear out the free list */

int
Expand Down
30 changes: 18 additions & 12 deletions Objects/descrobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,12 @@ descr_traverse(PyObject *self, visitproc visit, void *arg)
return 0;
}

#ifdef STACKLESS
static PyMappingMethods descr_as_mapping = {
.slpflags.tp_call = -1,
};
#endif

PyTypeObject PyMethodDescr_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"method_descriptor",
Expand All @@ -569,14 +575,15 @@ PyTypeObject PyMethodDescr_Type = {
(reprfunc)method_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
SLP_TP_AS_MAPPING(descr_as_mapping), /* tp_as_mapping */
0, /* tp_hash */
(ternaryfunc)methoddescr_call, /* tp_call */
0, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
Py_TPFLAGS_HAVE_STACKLESS_EXTENSION, /* tp_flags */
0, /* tp_doc */
descr_traverse, /* tp_traverse */
0, /* tp_clear */
Expand All @@ -593,7 +600,6 @@ PyTypeObject PyMethodDescr_Type = {
0, /* tp_descr_set */
};

STACKLESS_DECLARE_METHOD(&PyMethodDescr_Type, tp_call)

/* This is for METH_CLASS in C, not for "f = classmethod(f)" in Python! */
PyTypeObject PyClassMethodDescr_Type = {
Expand All @@ -609,14 +615,15 @@ PyTypeObject PyClassMethodDescr_Type = {
(reprfunc)method_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
SLP_TP_AS_MAPPING(descr_as_mapping), /* tp_as_mapping */
0, /* tp_hash */
(ternaryfunc)classmethoddescr_call, /* tp_call */
0, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
Py_TPFLAGS_HAVE_STACKLESS_EXTENSION, /* tp_flags */
0, /* tp_doc */
descr_traverse, /* tp_traverse */
0, /* tp_clear */
Expand All @@ -633,7 +640,6 @@ PyTypeObject PyClassMethodDescr_Type = {
0, /* tp_descr_set */
};

STACKLESS_DECLARE_METHOD(&PyClassMethodDescr_Type, tp_call)

PyTypeObject PyMemberDescr_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
Expand Down Expand Up @@ -722,14 +728,15 @@ PyTypeObject PyWrapperDescr_Type = {
(reprfunc)wrapperdescr_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
SLP_TP_AS_MAPPING(descr_as_mapping), /* tp_as_mapping */
0, /* tp_hash */
(ternaryfunc)wrapperdescr_call, /* tp_call */
0, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
Py_TPFLAGS_HAVE_STACKLESS_EXTENSION, /* tp_flags */
0, /* tp_doc */
descr_traverse, /* tp_traverse */
0, /* tp_clear */
Expand All @@ -746,7 +753,6 @@ PyTypeObject PyWrapperDescr_Type = {
0, /* tp_descr_set */
};

STACKLESS_DECLARE_METHOD(&PyWrapperDescr_Type, tp_call)

static PyDescrObject *
descr_new(PyTypeObject *descrtype, PyTypeObject *type, const char *name)
Expand Down Expand Up @@ -1210,14 +1216,15 @@ PyTypeObject _PyMethodWrapper_Type = {
(reprfunc)wrapper_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
SLP_TP_AS_MAPPING(descr_as_mapping), /* tp_as_mapping */
(hashfunc)wrapper_hash, /* tp_hash */
(ternaryfunc)wrapper_call, /* tp_call */
0, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
Py_TPFLAGS_HAVE_STACKLESS_EXTENSION, /* tp_flags */
0, /* tp_doc */
wrapper_traverse, /* tp_traverse */
0, /* tp_clear */
Expand All @@ -1234,7 +1241,6 @@ PyTypeObject _PyMethodWrapper_Type = {
0, /* tp_descr_set */
};

STACKLESS_DECLARE_METHOD(&_PyMethodWrapper_Type, tp_call)

PyObject *
PyWrapper_New(PyObject *d, PyObject *self)
Expand Down
12 changes: 9 additions & 3 deletions Objects/funcobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,12 @@ func_descr_get(PyObject *func, PyObject *obj, PyObject *type)
return PyMethod_New(func, obj);
}

#ifdef STACKLESS
static PyMappingMethods func_as_mapping = {
.slpflags.tp_call = -1,
};
#endif

PyTypeObject PyFunction_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"function",
Expand All @@ -614,14 +620,15 @@ PyTypeObject PyFunction_Type = {
(reprfunc)func_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
SLP_TP_AS_MAPPING(func_as_mapping), /* tp_as_mapping */
0, /* tp_hash */
function_call, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
Py_TPFLAGS_HAVE_STACKLESS_EXTENSION, /* tp_flags */
func_new__doc__, /* tp_doc */
(traverseproc)func_traverse, /* tp_traverse */
0, /* tp_clear */
Expand All @@ -642,7 +649,6 @@ PyTypeObject PyFunction_Type = {
func_new, /* tp_new */
};

STACKLESS_DECLARE_METHOD(&PyFunction_Type, tp_call)

/* Class method object */

Expand Down
27 changes: 15 additions & 12 deletions Objects/genobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,12 @@ static PyMethodDef gen_methods[] = {
{NULL, NULL} /* Sentinel */
};

#ifdef STACKLESS
static PyMappingMethods gen_as_mapping = {
.slpflags.tp_iternext = -1,
};
#endif

PyTypeObject PyGen_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"generator", /* tp_name */
Expand All @@ -886,15 +892,16 @@ PyTypeObject PyGen_Type = {
(reprfunc)gen_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
SLP_TP_AS_MAPPING(gen_as_mapping), /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
Py_TPFLAGS_HAVE_FINALIZE, /* tp_flags */
Py_TPFLAGS_HAVE_FINALIZE |
Py_TPFLAGS_HAVE_STACKLESS_EXTENSION, /* tp_flags */
0, /* tp_doc */
(traverseproc)gen_traverse, /* tp_traverse */
0, /* tp_clear */
Expand Down Expand Up @@ -926,8 +933,6 @@ PyTypeObject PyGen_Type = {
_PyGen_Finalize, /* tp_finalize */
};

STACKLESS_DECLARE_METHOD(&PyGen_Type, tp_iternext);

static PyObject *
gen_new_with_qualname(PyTypeObject *type, PyFrameObject *f,
PyObject *name, PyObject *qualname)
Expand Down Expand Up @@ -1243,14 +1248,15 @@ PyTypeObject _PyCoroWrapper_Type = {
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
SLP_TP_AS_MAPPING(gen_as_mapping), /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
Py_TPFLAGS_HAVE_STACKLESS_EXTENSION, /* tp_flags */
"A wrapper object implementing __await__ for coroutines.",
(traverseproc)coro_wrapper_traverse, /* tp_traverse */
0, /* tp_clear */
Expand All @@ -1272,8 +1278,6 @@ PyTypeObject _PyCoroWrapper_Type = {
0, /* tp_free */
};

STACKLESS_DECLARE_METHOD(&_PyCoroWrapper_Type, tp_iternext);

static PyObject *
compute_cr_origin(int origin_depth)
{
Expand Down Expand Up @@ -1812,14 +1816,15 @@ PyTypeObject _PyAsyncGenASend_Type = {
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
SLP_TP_AS_MAPPING(gen_as_mapping), /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
Py_TPFLAGS_HAVE_STACKLESS_EXTENSION, /* tp_flags */
0, /* tp_doc */
(traverseproc)async_gen_asend_traverse, /* tp_traverse */
0, /* tp_clear */
Expand All @@ -1840,8 +1845,6 @@ PyTypeObject _PyAsyncGenASend_Type = {
0, /* tp_new */
};

STACKLESS_DECLARE_METHOD(&_PyAsyncGenASend_Type, tp_iternext);


static PyObject *
async_gen_asend_new(PyAsyncGenObject *gen, PyObject *sendval)
Expand Down
13 changes: 9 additions & 4 deletions Objects/methodobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,12 @@ meth_hash(PyCFunctionObject *a)
}


#ifdef STACKLESS
static PyMappingMethods meth_as_mapping = {
.slpflags.tp_call = -1,
};
#endif

PyTypeObject PyCFunction_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"builtin_function_or_method",
Expand All @@ -282,14 +288,15 @@ PyTypeObject PyCFunction_Type = {
(reprfunc)meth_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
SLP_TP_AS_MAPPING(meth_as_mapping), /* tp_as_mapping */
(hashfunc)meth_hash, /* tp_hash */
PyCFunction_Call, /* tp_call */
0, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
Py_TPFLAGS_HAVE_STACKLESS_EXTENSION, /* tp_flags */
0, /* tp_doc */
(traverseproc)meth_traverse, /* tp_traverse */
0, /* tp_clear */
Expand All @@ -304,8 +311,6 @@ PyTypeObject PyCFunction_Type = {
0, /* tp_dict */
};

STACKLESS_DECLARE_METHOD(&PyCFunction_Type, tp_call)

/* Clear out the free list */

int
Expand Down
13 changes: 9 additions & 4 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -3590,6 +3590,12 @@ type_is_gc(PyTypeObject *type)
return type->tp_flags & Py_TPFLAGS_HEAPTYPE;
}

#ifdef STACKLESS
static PyMappingMethods type_as_mapping = {
.slpflags.tp_call = -1,
};
#endif

PyTypeObject PyType_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"type", /* tp_name */
Expand All @@ -3603,15 +3609,16 @@ PyTypeObject PyType_Type = {
(reprfunc)type_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
SLP_TP_AS_MAPPING(type_as_mapping), /* tp_as_mapping */
0, /* tp_hash */
(ternaryfunc)type_call, /* tp_call */
0, /* tp_str */
(getattrofunc)type_getattro, /* tp_getattro */
(setattrofunc)type_setattro, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
Py_TPFLAGS_BASETYPE | Py_TPFLAGS_TYPE_SUBCLASS, /* tp_flags */
Py_TPFLAGS_BASETYPE | Py_TPFLAGS_TYPE_SUBCLASS |
Py_TPFLAGS_HAVE_STACKLESS_EXTENSION, /* tp_flags */
type_doc, /* tp_doc */
(traverseproc)type_traverse, /* tp_traverse */
(inquiry)type_clear, /* tp_clear */
Expand All @@ -3634,8 +3641,6 @@ PyTypeObject PyType_Type = {
(inquiry)type_is_gc, /* tp_is_gc */
};

STACKLESS_DECLARE_METHOD(&PyType_Type, tp_call)

/* The base type of all types (eventually)... except itself. */

/* You may wonder why object.__new__() only complains about arguments
Expand Down
1 change: 0 additions & 1 deletion PCbuild/pythoncore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@
<ClInclude Include="..\Stackless\core\cframeobject.h" />
<ClInclude Include="..\Stackless\core\slp_exttype.h" />
<ClInclude Include="..\Stackless\core\stackless_impl.h" />
<ClInclude Include="..\Stackless\core\stackless_methods.h" />
<ClInclude Include="..\Stackless\core\stackless_structs.h" />
<ClInclude Include="..\Stackless\core\stackless_tstate.h" />
<ClInclude Include="..\Stackless\core\stackless_pystate.h" />
Expand Down
3 changes: 0 additions & 3 deletions PCbuild/pythoncore.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,6 @@
<ClInclude Include="..\Stackless\core\stackless_impl.h">
<Filter>Stackless\core</Filter>
</ClInclude>
<ClInclude Include="..\Stackless\core\stackless_methods.h">
<Filter>Stackless\core</Filter>
</ClInclude>
<ClInclude Include="..\Stackless\core\stackless_structs.h">
<Filter>Stackless\core</Filter>
</ClInclude>
Expand Down
Loading