diff --git a/Objects/classobject.c b/Objects/classobject.c index 6b36243537f666..87165da331b216 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -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", @@ -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 */ @@ -373,8 +380,6 @@ PyTypeObject PyMethod_Type = { method_new, /* tp_new */ }; -STACKLESS_DECLARE_METHOD(&PyMethod_Type, tp_call) - /* Clear out the free list */ int diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 23262e61323e80..49e31508cc426a 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -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", @@ -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 */ @@ -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 = { @@ -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 */ @@ -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) @@ -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 */ @@ -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) @@ -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 */ @@ -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) diff --git a/Objects/funcobject.c b/Objects/funcobject.c index 958a4bd38ae2e5..8180a03f333fdf 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -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", @@ -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 */ @@ -642,7 +649,6 @@ PyTypeObject PyFunction_Type = { func_new, /* tp_new */ }; -STACKLESS_DECLARE_METHOD(&PyFunction_Type, tp_call) /* Class method object */ diff --git a/Objects/genobject.c b/Objects/genobject.c index d5aefa68926841..7404f560d2ab45 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -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 */ @@ -886,7 +892,7 @@ 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 */ @@ -894,7 +900,8 @@ PyTypeObject PyGen_Type = { 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 */ @@ -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) @@ -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 */ @@ -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) { @@ -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 */ @@ -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) diff --git a/Objects/methodobject.c b/Objects/methodobject.c index 2dfcb033e148c4..0b0a61c2bd12cb 100644 --- a/Objects/methodobject.c +++ b/Objects/methodobject.c @@ -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", @@ -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 */ @@ -304,8 +311,6 @@ PyTypeObject PyCFunction_Type = { 0, /* tp_dict */ }; -STACKLESS_DECLARE_METHOD(&PyCFunction_Type, tp_call) - /* Clear out the free list */ int diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 173e0f511f2cdf..30ab039c52ddc5 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -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 */ @@ -3603,7 +3609,7 @@ 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 */ @@ -3611,7 +3617,8 @@ PyTypeObject PyType_Type = { (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 */ @@ -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 diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index daff23c7cb1aea..4e8d05071a27eb 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -216,7 +216,6 @@ - diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters index 54ca84a9f04c58..87f27ed4ae788e 100644 --- a/PCbuild/pythoncore.vcxproj.filters +++ b/PCbuild/pythoncore.vcxproj.filters @@ -465,9 +465,6 @@ Stackless\core - - Stackless\core - Stackless\core diff --git a/Stackless/changelog.txt b/Stackless/changelog.txt index edd5bc9c43d943..d2c1dab90da40c 100644 --- a/Stackless/changelog.txt +++ b/Stackless/changelog.txt @@ -9,6 +9,10 @@ What's New in Stackless 3.X.X? *Release date: 20XX-XX-XX* +- https://github.com/stackless-dev/stackless/issues/202 + The private include file "stackless_methods.h" is obsolete and has been + removed. + - https://github.com/stackless-dev/stackless/issues/201 Enable stackless calls of "wrapper_descriptor" objects, if soft-switching is enabled. The code has been in Stackless forever, but was disabled for some diff --git a/Stackless/core/extract_slp_methods.py b/Stackless/core/extract_slp_methods.py deleted file mode 100644 index a80ed6bbb1b499..00000000000000 --- a/Stackless/core/extract_slp_methods.py +++ /dev/null @@ -1,83 +0,0 @@ -################################################################ -# -# extract_slp_methods.py -# -# scan all C sources for the STACKLESS_DECLARE_METHOD macro -# and create and include file for the module. -# -################################################################ - -import os - -srcname = "../.." -dstname = "stackless_methods.h" - -def cfiles(rootpath): - work = [rootpath] - while work: - path = work.pop(0) - for name in os.listdir(path): - fname = os.path.join(path, name) - if os.path.isdir(fname): - work.append(fname) - elif os.path.splitext(fname)[-1] == ".c": - yield fname - - -def parse(fname): - find = "STACKLESS_DECLARE_METHOD" - with open(fname, encoding="ISO-8859-1") as f: - txt = f.read() - if txt.find(find) < 0: - return - - lines = txt.split("\n") - res = [line for line in lines if line.startswith(find)] - return res - -def generate(): - f = open(dstname, "wt", encoding="UTF-8", newline="\n") - print("""\ -/* - * this file was generated from the Python(r) C sources using the script - * Stackless/core/extract_slp_methods.py . - * please don't edit this output, but work on the script. - */ - -typedef struct { - void *type; - size_t offset; -} _stackless_method; - -#define MFLAG_IND 0x8000 -#define MFLAG_OFS(meth) offsetof(PyMappingMethods, slpflags.meth) -#define MFLAG_OFS_IND(meth) MFLAG_OFS(meth) + MFLAG_IND - -static _stackless_method _stackless_methtable[] = {\ -""", file=f) - for fname in cfiles(srcname): - found = parse(fname); - if not found: - continue - name = os.path.split(fname)[-1] - print(" /* from %s */" % name, file=f) - for line in found: - typ, meth = line.split("(")[-1].split(")")[0].split(", ") - tabs = " " - lng = len(typ) + 2 - while lng < 24: - tabs += " " - lng += 4 - ind = "" - if not typ.startswith("&"): - # indirection flag - ind = "_IND" - typ = "&" + typ - print(" {%s,%sMFLAG_OFS%s(%s)}," % \ - (typ, tabs, ind, meth), file=f) - print(" {0, 0} /* sentinel */", file=f) - print("};", file=f) - f.close() - -if __name__ == "__main__": - generate() diff --git a/Stackless/core/stackless_impl.h b/Stackless/core/stackless_impl.h index 0483905a75d520..da83195b2acb1b 100644 --- a/Stackless/core/stackless_impl.h +++ b/Stackless/core/stackless_impl.h @@ -455,15 +455,18 @@ PyTaskletObject * slp_get_watchdog(PyThreadState *ts, int interrupt); #define STACKLESS_PROPOSE_ALL(tstate) _PyStackless_TRY_STACKLESS = STACKLESS_POSSIBLE(tstate) -/* this is just a tag to denote which methods are stackless */ - -#define STACKLESS_DECLARE_METHOD(type, meth) - /* This can be set to 1 to completely disable the augmentation of * type info with stackless property. For debugging. */ #define STACKLESS_NO_TYPEINFO 0 +#if !STACKLESS_NO_TYPEINFO +/* This macro changes to NULL, if STACKLESS is not defined. */ +#define SLP_TP_AS_MAPPING(tp_as_mapping) (&(tp_as_mapping)) +#else +#define SLP_TP_AS_MAPPING(tp_as_mapping) 0 +#endif + /* How this works: @@ -786,7 +789,7 @@ long slp_parse_thread_id(PyObject *thread_id, unsigned long *id); #define STACKLESS_RETVAL(tstate, obj) (obj) #define STACKLESS_ASSERT_UNWINDING_VALUE_IS_NOT(tstate, obj, val) assert(1) -#define STACKLESS_DECLARE_METHOD(type, meth) +#define SLP_TP_AS_MAPPING(tp_as_mapping) 0 #define slp_initialize(s) /* empty */ diff --git a/Stackless/core/stackless_methods.h b/Stackless/core/stackless_methods.h deleted file mode 100644 index 136531fb635271..00000000000000 --- a/Stackless/core/stackless_methods.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * this file was generated from the Python(r) C sources using the script - * Stackless/core/extract_slp_methods.py . - * please don't edit this output, but work on the script. - */ - -typedef struct { - void *type; - size_t offset; -} _stackless_method; - -#define MFLAG_IND 0x8000 -#define MFLAG_OFS(meth) offsetof(PyMappingMethods, slpflags.meth) -#define MFLAG_OFS_IND(meth) MFLAG_OFS(meth) + MFLAG_IND - -static _stackless_method _stackless_methtable[] = { - /* from classobject.c */ - {&PyMethod_Type, MFLAG_OFS(tp_call)}, - /* from descrobject.c */ - {&PyMethodDescr_Type, MFLAG_OFS(tp_call)}, - {&PyClassMethodDescr_Type, MFLAG_OFS(tp_call)}, - {&PyWrapperDescr_Type, MFLAG_OFS(tp_call)}, - {&_PyMethodWrapper_Type, MFLAG_OFS(tp_call)}, - /* from funcobject.c */ - {&PyFunction_Type, MFLAG_OFS(tp_call)}, - /* from genobject.c */ - {&PyGen_Type, MFLAG_OFS(tp_iternext)}, - {&_PyCoroWrapper_Type, MFLAG_OFS(tp_iternext)}, - {&_PyAsyncGenASend_Type, MFLAG_OFS(tp_iternext)}, - /* from methodobject.c */ - {&PyCFunction_Type, MFLAG_OFS(tp_call)}, - /* from typeobject.c */ - {&PyType_Type, MFLAG_OFS(tp_call)}, - /* from channelobject.c */ - {&PyChannel_Type, MFLAG_OFS(tp_iternext)}, - {0, 0} /* sentinel */ -}; diff --git a/Stackless/module/channelobject.c b/Stackless/module/channelobject.c index 06daa594f4aa0d..f0a904ad1281f5 100644 --- a/Stackless/module/channelobject.c +++ b/Stackless/module/channelobject.c @@ -1197,6 +1197,12 @@ By receiving from a channel, a tasklet that is waiting to send\n\ is resumed. If there is no waiting sender, the receiver is suspended.\ "); +#ifdef STACKLESS +static PyMappingMethods channel_as_mapping = { + .slpflags.tp_iternext = -1, +}; +#endif + PyTypeObject PyChannel_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "_stackless.channel", @@ -1210,7 +1216,7 @@ PyTypeObject PyChannel_Type = { 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ + SLP_TP_AS_MAPPING(channel_as_mapping), /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ @@ -1218,7 +1224,8 @@ PyTypeObject PyChannel_Type = { PyObject_GenericSetAttr, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ + Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_HAVE_STACKLESS_EXTENSION, /* tp_flags */ channel__doc__, /* tp_doc */ (traverseproc)channel_traverse, /* tp_traverse */ (inquiry) channel_clear, /* tp_clear */ @@ -1241,5 +1248,4 @@ PyTypeObject PyChannel_Type = { PyObject_GC_Del, /* tp_free */ }; -STACKLESS_DECLARE_METHOD(&PyChannel_Type, tp_iternext) #endif diff --git a/Stackless/module/stacklessmodule.c b/Stackless/module/stacklessmodule.c index dce9bd70b58e9f..9bac0466a4987e 100644 --- a/Stackless/module/stacklessmodule.c +++ b/Stackless/module/stacklessmodule.c @@ -10,8 +10,7 @@ #include "platf/slp_platformselect.h" #include "core/cframeobject.h" #include "pickling/prickelpit.h" -#include /* for offsetof(), required by core/stackless_methods.h */ -#include "core/stackless_methods.h" +#include /* for offsetof() */ /*[clinic input] module _stackless @@ -1708,39 +1707,12 @@ slp_prepare_slots(PyTypeObject * type) return 0; } -/* initial seeding of the stackless slot information into the types. - * it will then be propagated using slot copying - */ -static int init_stackless_methods(void) -{ -#if !STACKLESS_NO_TYPEINFO - _stackless_method *p = _stackless_methtable; - - for (; p->type != NULL; p++) { - PyTypeObject *t = p->type; - size_t ind = p->offset & MFLAG_IND; - size_t ofs = p->offset - ind; - - if (ind) - t = *((PyTypeObject **)t); - /* this type has stackless slot methods. Set the flag */ - if (slp_prepare_slots(t)) - return -1; - ((signed char *) t->tp_as_mapping)[ofs] = -1; - if (t->tp_as_mapping->slpflags.tp_call) - t->tp_flags |= Py_TPFLAGS_HAVE_STACKLESS_CALL; /* shortcut flag */ - } -#endif - return 0; -} - /* this one must be called very early, before modules are used */ int _PyStackless_InitTypes(void) { if (0 || slp_init_bombtype() - || init_stackless_methods() || PyType_Ready(&PyTasklet_Type) /* need this early for the main tasklet */ || slp_init_cframetype() ) diff --git a/Tools/c-globals/ignored-globals.txt b/Tools/c-globals/ignored-globals.txt index d0707579db5c23..8dde4cc6f51395 100644 --- a/Tools/c-globals/ignored-globals.txt +++ b/Tools/c-globals/ignored-globals.txt @@ -491,10 +491,6 @@ _PyStackless__TryStacklessPtr _PyExc_TaskletExit PyExc_TaskletExit -# Stackless/core/stackless_methods.h -# justification: constant -_stackless_methtable - # Stackless/core/stacklesseval.c # justification: constant singleton unwind_token diff --git a/Tools/msi/dev/dev_files.wxs b/Tools/msi/dev/dev_files.wxs index 670034d4ad4933..c3394080439c04 100644 --- a/Tools/msi/dev/dev_files.wxs +++ b/Tools/msi/dev/dev_files.wxs @@ -63,7 +63,7 @@ - +