[Stackless-checkins] CVS: slpdev/src/2.3/dev/Objects abstract.c, 1.13, 1.14 classobject.c, 1.18, 1.19 descrobject.c, 1.15, 1.16 funcobject.c, 1.11, 1.12 methodobject.c, 1.10, 1.11 typeobject.c, 1.15, 1.16

Christian Tismer tismer at centera.de
Thu Jun 3 01:03:45 CEST 2004


Update of /home/cvs/slpdev/src/2.3/dev/Objects
In directory centera.de:/tmp/cvs-serv3004/Objects

Modified Files:
	abstract.c classobject.c descrobject.c funcobject.c 
	methodobject.c typeobject.c 
Log Message:
Stackless 3.1 almost ready.
All tests are working, both Python and Stackless,
both soft and hard switching.

New features:
channels are working cross-thread!
Stack protection for eval_frame and pickling is complete.

A couple of smallish features are missing:
pickling of channels
refuse running tasklets from foreign threads
channel.transfer
scheduling strategy cross-thread
cframe pickling, get rid of invalid_exec funcs, instead use
the missing cframe owner-tasklet pointer!
add more tests!

Index: abstract.c
===================================================================
RCS file: /home/cvs/slpdev/src/2.3/dev/Objects/abstract.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** abstract.c	29 Apr 2004 17:58:58 -0000	1.13
--- abstract.c	2 Jun 2004 23:03:42 -0000	1.14
***************
*** 2202,2206 ****
  	/* we use the same flag here, since iterators are not callable */
  #endif
! 	STACKLESS_PROMOTE(iter);
  	result = (*iter->ob_type->tp_iternext)(iter);
  	STACKLESS_ASSERT();
--- 2202,2206 ----
  	/* we use the same flag here, since iterators are not callable */
  #endif
! 	STACKLESS_PROMOTE_METHOD(iter, tp_iternext);
  	result = (*iter->ob_type->tp_iternext)(iter);
  	STACKLESS_ASSERT();

Index: classobject.c
===================================================================
RCS file: /home/cvs/slpdev/src/2.3/dev/Objects/classobject.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** classobject.c	24 May 2004 23:45:14 -0000	1.18
--- classobject.c	2 Jun 2004 23:03:42 -0000	1.19
***************
*** 2071,2080 ****
  	(setattrofunc)instance_setattr,		/* tp_setattro */
  	0,					/* tp_as_buffer */
- #ifdef STACKLESS
- 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES |
- 		Py_TPFLAGS_HAVE_STACKLESS_CALL,	/*tp_flags*/
- #else
  	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES,/*tp_flags*/
- #endif
  	instance_doc,				/* tp_doc */
  	(traverseproc)instance_traverse,	/* tp_traverse */
--- 2071,2075 ----
***************
*** 2097,2100 ****
--- 2092,2096 ----
  };
  
+ STACKLESS_DECLARE_METHOD(&PyInstance_Type, tp_call)
  
  /* Instance method objects are used for two purposes:
***************
*** 2496,2505 ****
  	PyObject_GenericSetAttr,		/* tp_setattro */
  	0,					/* tp_as_buffer */
- #ifdef STACKLESS
- 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
- 		Py_TPFLAGS_HAVE_STACKLESS_CALL,	/* tp_flags */
- #else
  	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
- #endif
  	instancemethod_doc,			/* tp_doc */
  	(traverseproc)instancemethod_traverse,	/* tp_traverse */
--- 2492,2496 ----
***************
*** 2522,2525 ****
--- 2513,2518 ----
  };
  
+ STACKLESS_DECLARE_METHOD(&PyMethod_Type, tp_call)
+ 
  /* Clear out the free list */
  

Index: descrobject.c
===================================================================
RCS file: /home/cvs/slpdev/src/2.3/dev/Objects/descrobject.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** descrobject.c	24 May 2004 01:59:34 -0000	1.15
--- descrobject.c	2 Jun 2004 23:03:42 -0000	1.16
***************
*** 398,402 ****
--- 398,406 ----
  }
  
+ #ifdef STACKLESS
+ PyTypeObject PyMethodDescr_Type = {
+ #else
  static PyTypeObject PyMethodDescr_Type = {
+ #endif
  	PyObject_HEAD_INIT(&PyType_Type)
  	0,
***************
*** 419,428 ****
  	0,					/* tp_setattro */
  	0,					/* tp_as_buffer */
- #ifdef STACKLESS
- 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
- 		Py_TPFLAGS_HAVE_STACKLESS_CALL, /* tp_flags */
- #else
  	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
- #endif
  	0,					/* tp_doc */
  	descr_traverse,				/* tp_traverse */
--- 423,427 ----
***************
*** 441,446 ****
--- 440,451 ----
  };
  
+ STACKLESS_DECLARE_METHOD(&PyMethodDescr_Type, tp_call)
+ 
  /* This is for METH_CLASS in C, not for "f = classmethod(f)" in Python! */
+ #ifdef STACKLESS
+ PyTypeObject PyClassMethodDescr_Type = {
+ #else
  static PyTypeObject PyClassMethodDescr_Type = {
+ #endif
  	PyObject_HEAD_INIT(&PyType_Type)
  	0,
***************
*** 463,472 ****
  	0,					/* tp_setattro */
  	0,					/* tp_as_buffer */
- #ifdef STACKLESS
- 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
- 		Py_TPFLAGS_HAVE_STACKLESS_CALL, /* tp_flags */
- #else
  	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
- #endif
  	0,					/* tp_doc */
  	descr_traverse,				/* tp_traverse */
--- 468,472 ----
***************
*** 485,488 ****
--- 485,490 ----
  };
  
+ STACKLESS_DECLARE_METHOD(&PyClassMethodDescr_Type, tp_call)
+ 
  static PyTypeObject PyMemberDescr_Type = {
  	PyObject_HEAD_INIT(&PyType_Type)
***************
*** 582,591 ****
  	0,					/* tp_setattro */
  	0,					/* tp_as_buffer */
- #ifdef STACKLESS
- 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
- 		Py_TPFLAGS_HAVE_STACKLESS_CALL, /* tp_flags */
- #else
  	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
- #endif
  	0,					/* tp_doc */
  	descr_traverse,				/* tp_traverse */
--- 584,588 ----
***************
*** 604,607 ****
--- 601,606 ----
  };
  
+ STACKLESS_DECLARE_METHOD(&PyWrapperDescr_Type, tp_call)
+ 
  static PyDescrObject *
  descr_new(PyTypeObject *descrtype, PyTypeObject *type, char *name)
***************
*** 680,683 ****
--- 679,685 ----
  		descr->d_base = base;
  		descr->d_wrapped = wrapped;
+ #ifdef STACKLESS
+ 		descr->d_slpmask = 0;
+ #endif
  	}
  	return (PyObject *)descr;
***************
*** 968,997 ****
  };
  
- #ifdef STACKLESS
- #define WRAP_RETURN(call) { \
- 	PyObject * retval; \
- 	STACKLESS_PROMOTE_FLAG( \
- 		wp->descr->d_base->flags & PyWrapperFlag_STACKLESS && \
- 		wp->descr->d_type->tp_flags & Py_TPFLAGS_HAVE_STACKLESS_CALL); \
- 	retval = (call); \
- 	STACKLESS_ASSERT(); \
- 	return retval; \
- }
- #else
- #define WRAP_RETURN(call) return (call);
- #endif
- 
  static PyObject *
  wrapper_call(wrapperobject *wp, PyObject *args, PyObject *kwds)
  {
- #ifdef STACKLESS
  	STACKLESS_GETARG();
- #endif
  	wrapperfunc wrapper = wp->descr->d_base->wrapper;
  	PyObject *self = wp->self;
  
  	if (wp->descr->d_base->flags & PyWrapperFlag_KEYWORDS) {
  		wrapperfunc_kwds wk = (wrapperfunc_kwds)wrapper;
! 		WRAP_RETURN( (*wk)(self, args, wp->descr->d_wrapped, kwds) )
  	}
  
--- 970,987 ----
  };
  
  static PyObject *
  wrapper_call(wrapperobject *wp, PyObject *args, PyObject *kwds)
  {
  	STACKLESS_GETARG();
  	wrapperfunc wrapper = wp->descr->d_base->wrapper;
  	PyObject *self = wp->self;
+ 	PyObject *ret;
  
  	if (wp->descr->d_base->flags & PyWrapperFlag_KEYWORDS) {
  		wrapperfunc_kwds wk = (wrapperfunc_kwds)wrapper;
! 		STACKLESS_PROMOTE_WRAPPER(wp);
! 		ret = (*wk)(self, args, wp->descr->d_wrapped, kwds);
! 		STACKLESS_ASSERT();
! 		return ret;
  	}
  
***************
*** 1002,1006 ****
  		return NULL;
  	}
! 	WRAP_RETURN( (*wrapper)(self, args, wp->descr->d_wrapped) )
  }
  
--- 992,999 ----
  		return NULL;
  	}
! 	STACKLESS_PROMOTE_WRAPPER(wp);
! 	ret = (*wrapper)(self, args, wp->descr->d_wrapped);
! 	STACKLESS_ASSERT();
! 	return ret;
  }
  
***************
*** 1051,1060 ****
  	0,					/* tp_setattro */
  	0,					/* tp_as_buffer */
- #ifdef STACKLESS
- 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
- 		Py_TPFLAGS_HAVE_STACKLESS_CALL, /* tp_flags */
- #else
  	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
- #endif
   	0,					/* tp_doc */
  	wrapper_traverse,			/* tp_traverse */
--- 1044,1048 ----
***************
*** 1073,1076 ****
--- 1061,1066 ----
  };
  
+ STACKLESS_DECLARE_METHOD(&PyMethodWrapper_Type, tp_call)
+ 
  PyObject *
  PyWrapper_New(PyObject *d, PyObject *self)

Index: funcobject.c
===================================================================
RCS file: /home/cvs/slpdev/src/2.3/dev/Objects/funcobject.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** funcobject.c	29 Apr 2004 17:58:58 -0000	1.11
--- funcobject.c	2 Jun 2004 23:03:42 -0000	1.12
***************
*** 549,558 ****
  	PyObject_GenericSetAttr,		/* tp_setattro */
  	0,					/* tp_as_buffer */
- #ifdef STACKLESS
- 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
- 		Py_TPFLAGS_HAVE_STACKLESS_CALL,/* tp_flags */
- #else
  	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
- #endif
  	func_doc,				/* tp_doc */
  	(traverseproc)func_traverse,		/* tp_traverse */
--- 549,553 ----
***************
*** 575,578 ****
--- 570,574 ----
  };
  
+ STACKLESS_DECLARE_METHOD(&PyFunction_Type, tp_call)
  
  /* Class method object */

Index: methodobject.c
===================================================================
RCS file: /home/cvs/slpdev/src/2.3/dev/Objects/methodobject.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** methodobject.c	2 May 2004 15:07:06 -0000	1.10
--- methodobject.c	2 Jun 2004 23:03:42 -0000	1.11
***************
*** 281,290 ****
  	0,					/* tp_setattro */
  	0,					/* tp_as_buffer */
- #ifdef STACKLESS
- 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
- 		Py_TPFLAGS_HAVE_STACKLESS_CALL, /* tp_flags */
- #else
  	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
- #endif
   	0,					/* tp_doc */
   	(traverseproc)meth_traverse,		/* tp_traverse */
--- 281,285 ----
***************
*** 301,304 ****
--- 296,301 ----
  };
  
+ STACKLESS_DECLARE_METHOD(&PyCFunction_Type, tp_call)
+ 
  /* List all methods in a chain -- helper for findmethodinchain */
  

Index: typeobject.c
===================================================================
RCS file: /home/cvs/slpdev/src/2.3/dev/Objects/typeobject.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** typeobject.c	24 May 2004 23:45:14 -0000	1.15
--- typeobject.c	2 Jun 2004 23:03:42 -0000	1.16
***************
*** 2977,2980 ****
--- 2977,2998 ----
  	 (basebase == NULL || base->SLOT != basebase->SLOT))
  
+ #ifdef STACKLESS
+ 
+ #define COPYSLOT2(SLOT, SLPSLOT) \
+ 	if (!type->SLOT && SLOTDEFINED(SLOT)) { \
+ 		type->SLOT = base->SLOT; \
+ 		if (type->tp_flags & base->tp_flags & \
+ 			Py_TPFLAGS_HAVE_STACKLESS_EXTENSION) \
+ 			type->slpflags.SLPSLOT = base->slpflags.SLPSLOT; \
+ 	}
+ 
+ #define COPYSLOT(SLOT) COPYSLOT2(SLOT, SLOT)
+ 
+ #define COPYNUM(SLOT) COPYSLOT2(tp_as_number->SLOT, SLOT)
+ #define COPYSEQ(SLOT) COPYSLOT2(tp_as_sequence->SLOT, SLOT)
+ #define COPYMAP(SLOT) COPYSLOT2(tp_as_mapping->SLOT, SLOT)
+ #define COPYBUF(SLOT) COPYSLOT2(tp_as_buffer->SLOT, SLOT)
+ 
+ #else
  #define COPYSLOT(SLOT) \
  	if (!type->SLOT && SLOTDEFINED(SLOT)) type->SLOT = base->SLOT
***************
*** 2985,2988 ****
--- 3003,3008 ----
  #define COPYBUF(SLOT) COPYSLOT(tp_as_buffer->SLOT)
  
+ #endif
+ 
  	/* This won't inherit indirect slots (from tp_as_number etc.)
  	   if type doesn't provide the space. */
***************
*** 3148,3151 ****
--- 3168,3181 ----
  	type->tp_flags |= Py_TPFLAGS_READYING;
  
+ #ifdef STACKLESS
+ 	/* extract/spread the stackless call flag */
+ 	if (type->tp_flags & Py_TPFLAGS_HAVE_STACKLESS_EXTENSION) {
+ 		if (type->slpflags.tp_call)
+ 			type->tp_flags |= Py_TPFLAGS_HAVE_STACKLESS_CALL;
+ 		else if (type->tp_flags & Py_TPFLAGS_HAVE_STACKLESS_CALL)
+ 			type->slpflags.tp_call = -1;
+ 	}
+ #endif
+ 
  #ifdef Py_TRACE_REFS
  	/* PyType_Ready is the closest thing we have to a choke point
***************
*** 4427,4430 ****
--- 4457,4461 ----
  slot_tp_repr(PyObject *self)
  {
+ 	STACKLESS_GETARG();
  	PyObject *func, *res;
  	static PyObject *repr_str;
***************
*** 4432,4436 ****
--- 4463,4469 ----
  	func = lookup_method(self, "__repr__", &repr_str);
  	if (func != NULL) {
+ 		STACKLESS_PROMOTE_ALL();
  		res = PyEval_CallObject(func, NULL);
+ 		STACKLESS_ASSERT();
  		Py_DECREF(func);
  		return res;
***************
*** 4444,4447 ****
--- 4477,4481 ----
  slot_tp_str(PyObject *self)
  {
+ 	STACKLESS_GETARG();
  	PyObject *func, *res;
  	static PyObject *str_str;
***************
*** 4449,4453 ****
--- 4483,4489 ----
  	func = lookup_method(self, "__str__", &str_str);
  	if (func != NULL) {
+ 		STACKLESS_PROMOTE_ALL();
  		res = PyEval_CallObject(func, NULL);
+ 		STACKLESS_ASSERT();
  		Py_DECREF(func);
  		return res;
***************
*** 4455,4459 ****
  	else {
  		PyErr_Clear();
! 		return slot_tp_repr(self);
  	}
  }
--- 4491,4498 ----
  	else {
  		PyErr_Clear();
! 		STACKLESS_PROMOTE_ALL();
! 		res = slot_tp_repr(self);
! 		STACKLESS_ASSERT();
! 		return res;
  	}
  }
***************
*** 4462,4465 ****
--- 4501,4505 ----
  slot_tp_hash(PyObject *self)
  {
+ 	STACKLESS_GETARG(); /* not supported */
  	PyObject *func;
  	static PyObject *hash_str, *eq_str, *cmp_str;
***************
*** 4527,4533 ****
  slot_tp_getattro(PyObject *self, PyObject *name)
  {
  	static PyObject *getattribute_str = NULL;
! 	return call_method(self, "__getattribute__", &getattribute_str,
  			   "(O)", name);
  }
  
--- 4567,4579 ----
  slot_tp_getattro(PyObject *self, PyObject *name)
  {
+ 	STACKLESS_GETARG();
  	static PyObject *getattribute_str = NULL;
! 	PyObject *ret;
! 
! 	STACKLESS_PROMOTE_ALL();
! 	ret = call_method(self, "__getattribute__", &getattribute_str,
  			   "(O)", name);
+ 	STACKLESS_ASSERT();
+ 	return ret;
  }
  
***************
*** 4535,4538 ****
--- 4581,4585 ----
  slot_tp_getattr_hook(PyObject *self, PyObject *name)
  {
+ 	STACKLESS_GETARG(); /* partially supported */
  	PyTypeObject *tp = self->ob_type;
  	PyObject *getattr, *getattribute, *res;
***************
*** 4552,4559 ****
  	}
  	getattr = _PyType_Lookup(tp, getattr_str);
  	if (getattr == NULL) {
  		/* No __getattr__ hook: use a simpler dispatcher */
  		tp->tp_getattro = slot_tp_getattro;
! 		return slot_tp_getattro(self, name);
  	}
  	getattribute = _PyType_Lookup(tp, getattribute_str);
--- 4599,4609 ----
  	}
  	getattr = _PyType_Lookup(tp, getattr_str);
+ 	STACKLESS_PROMOTE_ALL();
  	if (getattr == NULL) {
  		/* No __getattr__ hook: use a simpler dispatcher */
  		tp->tp_getattro = slot_tp_getattro;
! 		res = slot_tp_getattro(self, name);
! 		STACKLESS_ASSERT();
! 		return res;
  	}
  	getattribute = _PyType_Lookup(tp, getattribute_str);
***************
*** 4567,4572 ****
--- 4617,4624 ----
  	if (res == NULL && PyErr_ExceptionMatches(PyExc_AttributeError)) {
  		PyErr_Clear();
+ 		STACKLESS_PROMOTE_ALL();
  		res = PyObject_CallFunction(getattr, "OO", self, name);
  	}
+ 	STACKLESS_ASSERT();
  	return res;
  }
***************
*** 4575,4578 ****
--- 4627,4631 ----
  slot_tp_setattro(PyObject *self, PyObject *name, PyObject *value)
  {
+ 	STACKLESS_GETARG(); /* not supported */
  	PyObject *res;
  	static PyObject *delattr_str, *setattr_str;
***************
*** 4603,4606 ****
--- 4656,4660 ----
  half_richcompare(PyObject *self, PyObject *other, int op)
  {
+ 	STACKLESS_GETARG();
  	PyObject *func, *args, *res;
  	static PyObject *op_str[6];
***************
*** 4616,4620 ****
--- 4670,4676 ----
  		res = NULL;
  	else {
+ 		STACKLESS_PROMOTE_ALL();
  		res = PyObject_Call(func, args, NULL);
+ 		STACKLESS_ASSERT();
  		Py_DECREF(args);
  	}
***************
*** 4629,4636 ****
--- 4685,4695 ----
  slot_tp_richcompare(PyObject *self, PyObject *other, int op)
  {
+ 	STACKLESS_GETARG();
  	PyObject *res;
  
  	if (self->ob_type->tp_richcompare == slot_tp_richcompare) {
+ 		STACKLESS_PROMOTE_ALL();
  		res = half_richcompare(self, other, op);
+ 		STACKLESS_ASSERT();
  		if (res != Py_NotImplemented)
  			return res;
***************
*** 4638,4642 ****
--- 4697,4703 ----
  	}
  	if (other->ob_type->tp_richcompare == slot_tp_richcompare) {
+ 		STACKLESS_PROMOTE_ALL();
  		res = half_richcompare(other, self, swapped_op[op]);
+ 		STACKLESS_ASSERT();
  		if (res != Py_NotImplemented) {
  			return res;
***************
*** 4651,4654 ****
--- 4712,4716 ----
  slot_tp_iter(PyObject *self)
  {
+ 	STACKLESS_GETARG();
  	PyObject *func, *res;
  	static PyObject *iter_str, *getitem_str;
***************
*** 4659,4663 ****
--- 4721,4727 ----
  		args = res = PyTuple_New(0);
  		if (args != NULL) {
+ 			STACKLESS_PROMOTE_ALL();
  			res = PyObject_Call(func, args, NULL);
+ 			STACKLESS_ASSERT();
  			Py_DECREF(args);
  		}
***************
*** 4679,4684 ****
  slot_tp_iternext(PyObject *self)
  {
  	static PyObject *next_str;
! 	return call_method(self, "next", &next_str, "()");
  }
  
--- 4743,4754 ----
  slot_tp_iternext(PyObject *self)
  {
+ 	STACKLESS_GETARG();
  	static PyObject *next_str;
! 	PyObject *ret;
! 
! 	STACKLESS_PROMOTE_ALL();
! 	ret = call_method(self, "next", &next_str, "()");
! 	STACKLESS_ASSERT();
! 	return ret;
  }
  
***************
*** 4686,4692 ****
--- 4756,4764 ----
  slot_tp_descr_get(PyObject *self, PyObject *obj, PyObject *type)
  {
+ 	STACKLESS_GETARG();
  	PyTypeObject *tp = self->ob_type;
  	PyObject *get;
  	static PyObject *get_str = NULL;
+ 	PyObject *ret;
  
  	if (get_str == NULL) {
***************
*** 4707,4711 ****
  	if (type == NULL)
  		type = Py_None;
! 	return PyObject_CallFunction(get, "OOO", self, obj, type);
  }
  
--- 4779,4786 ----
  	if (type == NULL)
  		type = Py_None;
! 	STACKLESS_PROMOTE_ALL();
! 	ret = PyObject_CallFunction(get, "OOO", self, obj, type);
! 	STACKLESS_ASSERT();
! 	return ret;
  }
  
***************
*** 4713,4716 ****
--- 4788,4792 ----
  slot_tp_descr_set(PyObject *self, PyObject *target, PyObject *value)
  {
+ 	STACKLESS_GETARG(); /* not supported */
  	PyObject *res;
  	static PyObject *del_str, *set_str;
***************
*** 4731,4734 ****
--- 4807,4811 ----
  slot_tp_init(PyObject *self, PyObject *args, PyObject *kwds)
  {
+ 	STACKLESS_GETARG(); /* not yet supported */
  	static PyObject *init_str;
  	PyObject *meth = lookup_method(self, "__init__", &init_str);
***************
*** 4748,4751 ****
--- 4825,4829 ----
  slot_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
  {
+ 	STACKLESS_GETARG();
  	static PyObject *new_str;
  	PyObject *func;
***************
*** 4773,4777 ****
--- 4851,4857 ----
  		PyTuple_SET_ITEM(newargs, i+1, x);
  	}
+ 	STACKLESS_PROMOTE_ALL();
  	x = PyObject_Call(func, newargs, kwds);
+ 	STACKLESS_ASSERT();
  	Py_DECREF(newargs);
  	Py_DECREF(func);
***************
*** 4782,4785 ****
--- 4862,4866 ----
  slot_tp_del(PyObject *self)
  {
+ 	STACKLESS_GETARG(); /* not supported */
  	static PyObject *del_str = NULL;
  	PyObject *del, *res;
***************
*** 4862,4865 ****
--- 4943,4981 ----
  #undef RBINSLOT
  
+ #ifdef STACKLESS
+ 
+ #define HEAPOFF(x) offsetof(PyHeapTypeObject, slpflags.x)
+ 
+ #define TPSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \
+ 	{NAME, offsetof(PyTypeObject, SLOT), (void *)(FUNCTION), WRAPPER, \
+ 	 PyDoc_STR(DOC), HEAPOFF(SLOT)}
+ #define FLSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC, FLAGS) \
+ 	{NAME, offsetof(PyTypeObject, SLOT), (void *)(FUNCTION), WRAPPER, \
+ 	 PyDoc_STR(DOC), HEAPOFF(SLOT), FLAGS}
+ #define ETSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC, SLPSLOT) \
+ 	{NAME, offsetof(PyHeapTypeObject, SLOT), (void *)(FUNCTION), WRAPPER, \
+ 	 PyDoc_STR(DOC), HEAPOFF(SLPSLOT)}
+ 
+ #define SQSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \
+ 	ETSLOT(NAME, as_sequence.SLOT, FUNCTION, WRAPPER, DOC, SLOT)
+ #define MPSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \
+ 	ETSLOT(NAME, as_mapping.SLOT, FUNCTION, WRAPPER, DOC, SLOT)
+ #define NBSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \
+ 	ETSLOT(NAME, as_number.SLOT, FUNCTION, WRAPPER, DOC, SLOT)
+ #define UNSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \
+ 	ETSLOT(NAME, as_number.SLOT, FUNCTION, WRAPPER, \
+ 	       "x." NAME "() <==> " DOC, SLOT)
+ #define IBSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \
+ 	ETSLOT(NAME, as_number.SLOT, FUNCTION, WRAPPER, \
+ 	       "x." NAME "(y) <==> x" DOC "y", SLOT)
+ #define BINSLOT(NAME, SLOT, FUNCTION, DOC) \
+ 	ETSLOT(NAME, as_number.SLOT, FUNCTION, wrap_binaryfunc_l, \
+ 	       "x." NAME "(y) <==> x" DOC "y", SLOT)
+ #define RBINSLOT(NAME, SLOT, FUNCTION, DOC) \
+ 	ETSLOT(NAME, as_number.SLOT, FUNCTION, wrap_binaryfunc_r, \
+ 	       "x." NAME "(y) <==> y" DOC "x", SLOT)
+ 
+ #else
+ 
  #define TPSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \
  	{NAME, offsetof(PyTypeObject, SLOT), (void *)(FUNCTION), WRAPPER, \
***************
*** 4871,4874 ****
--- 4987,4991 ----
  	{NAME, offsetof(PyHeapTypeObject, SLOT), (void *)(FUNCTION), WRAPPER, \
  	 PyDoc_STR(DOC)}
+ 
  #define SQSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \
  	ETSLOT(NAME, as_sequence.SLOT, FUNCTION, WRAPPER, DOC)
***************
*** 4890,4893 ****
--- 5007,5012 ----
  	       "x." NAME "(y) <==> y" DOC "x")
  
+ #endif
+ 
  static slotdef slotdefs[] = {
  	SQSLOT("__len__", sq_length, slot_sq_length, wrap_inquiry,
***************
*** 5035,5046 ****
  	TPSLOT("__hash__", tp_hash, slot_tp_hash, wrap_hashfunc,
  	       "x.__hash__() <==> hash(x)"),
- #ifdef STACKLESS
- 	FLSLOT("__call__", tp_call, slot_tp_call, (wrapperfunc)wrap_call,
- 	       "x.__call__(...) <==> x(...)",
- 	       PyWrapperFlag_KEYWORDS | PyWrapperFlag_STACKLESS),
- #else
  	FLSLOT("__call__", tp_call, slot_tp_call, (wrapperfunc)wrap_call,
  	       "x.__call__(...) <==> x(...)", PyWrapperFlag_KEYWORDS),
- #endif
  	TPSLOT("__getattribute__", tp_getattro, slot_tp_getattr_hook,
  	       wrap_binaryfunc, "x.__getattribute__('name') <==> x.name"),
--- 5154,5159 ----
***************
*** 5068,5079 ****
  	TPSLOT("__iter__", tp_iter, slot_tp_iter, wrap_unaryfunc,
  	       "x.__iter__() <==> iter(x)"),
- #ifdef STACKLESS
- 	FLSLOT("next", tp_iternext, slot_tp_iternext, wrap_next,
- 	       "x.next() -> the next value, or raise StopIteration",
- 		   PyWrapperFlag_STACKLESS),
- #else
  	TPSLOT("next", tp_iternext, slot_tp_iternext, wrap_next,
  	       "x.next() -> the next value, or raise StopIteration"),
- #endif
  	TPSLOT("__get__", tp_descr_get, slot_tp_descr_get, wrap_descr_get,
  	       "descr.__get__(obj[, type]) -> value"),
--- 5181,5186 ----
***************
*** 5438,5441 ****
--- 5545,5555 ----
  		if (descr == NULL)
  			return -1;
+ #ifdef STACKLESS
+ 		if (type->tp_flags & Py_TPFLAGS_HAVE_STACKLESS_EXTENSION) {
+ 			PyWrapperDescrObject * d =
+ 				(PyWrapperDescrObject *) descr;
+ 			d->d_slpmask = ((signed char *) type)[p->slp_offset];
+ 		}
+ #endif
  		if (PyDict_SetItem(dict, p->name_strobj, descr) < 0)
  			return -1;


_______________________________________________
Stackless-checkins mailing list
Stackless-checkins at stackless.com
http://www.stackless.com/mailman/listinfo/stackless-checkins



More information about the Stackless-checkins mailing list