Commit 940d2711 authored by Vitja Makarov's avatar Vitja Makarov

Change generator body signature to PyObject* (*body)(PyObject *, Pyobject *)

parent 299a9977
......@@ -5019,8 +5019,9 @@ class YieldExprNode(ExprNode):
code.putln('%s = %s->%s;' % (cname, Naming.cur_scope_cname, save_cname))
if type.is_pyobject:
code.putln('%s->%s = 0;' % (Naming.cur_scope_cname, save_cname))
code.putln('%s = __pyx_send_value; %s' %
(self.result(), code.error_goto_if_null(self.result(), self.pos)))
code.putln('%s = %s; %s' %
(self.result(), Naming.sent_value_cname,
code.error_goto_if_null(self.result(), self.pos)))
code.put_incref(self.result(), py_object_type)
class StopIterationNode(Node):
......@@ -8308,10 +8309,10 @@ proto="""
static PyObject *__CyGenerator_Next(PyObject *self);
static PyObject *__CyGenerator_Send(PyObject *self, PyObject *value);
static PyObject *__CyGenerator_Close(PyObject *self);
typedef PyObject *(*__cygenerator_body_t)(PyObject *, PyObject *, int);
typedef PyObject *(*__cygenerator_body_t)(PyObject *, PyObject *);
""",
impl="""
static CYTHON_INLINE PyObject *__CyGenerator_SendEx(struct __CyGenerator *self, PyObject *value, int is_exc)
static CYTHON_INLINE PyObject *__CyGenerator_SendEx(struct __CyGenerator *self, PyObject *value)
{
PyObject *retval;
......@@ -8336,7 +8337,7 @@ static CYTHON_INLINE PyObject *__CyGenerator_SendEx(struct __CyGenerator *self,
}
self->is_running = 1;
retval = self->body((PyObject *) self, value, is_exc);
retval = self->body((PyObject *) self, value);
self->is_running = 0;
return retval;
......@@ -8348,14 +8349,14 @@ static PyObject *__CyGenerator_Next(PyObject *self)
PyObject *retval;
Py_INCREF(Py_None);
retval = __CyGenerator_SendEx(generator, Py_None, 0);
retval = __CyGenerator_SendEx(generator, Py_None);
Py_DECREF(Py_None);
return retval;
}
static PyObject *__CyGenerator_Send(PyObject *self, PyObject *value)
{
return __CyGenerator_SendEx((struct __CyGenerator *) self, value, 0);
return __CyGenerator_SendEx((struct __CyGenerator *) self, value);
}
static PyObject *__CyGenerator_Close(PyObject *self)
......@@ -8363,7 +8364,7 @@ static PyObject *__CyGenerator_Close(PyObject *self)
struct __CyGenerator *generator = (struct __CyGenerator *) self;
PyObject *retval;
PyErr_SetNone(PyExc_GeneratorExit);
retval = __CyGenerator_SendEx(generator, NULL, 0);
retval = __CyGenerator_SendEx(generator, NULL);
if (retval) {
Py_DECREF(retval);
PyErr_SetString(PyExc_RuntimeError,
......
......@@ -52,6 +52,7 @@ lambda_func_prefix = pyrex_prefix + "lambda_"
module_is_main = pyrex_prefix + "module_is_main_"
args_cname = pyrex_prefix + "args"
sent_value_cname = pyrex_prefix + "sent_value"
pykwdlist_cname = pyrex_prefix + "pyargnames"
obj_base_cname = pyrex_prefix + "base"
builtins_cname = pyrex_prefix + "b"
......
......@@ -1363,7 +1363,7 @@ class FuncDefNode(StatNode, BlockNode):
code.use_label(first_run_label)
code.put_label(first_run_label)
code.putln('%s' %
(code.error_goto_if_null('__pyx_send_value', self.pos)))
(code.error_goto_if_null(Naming.sent_value_cname, self.pos)))
if not self.is_generator:
self.generate_argument_parsing_code(env, code)
# If an argument is assigned to in the body, we must
......@@ -2395,8 +2395,8 @@ class DefNode(FuncDefNode):
self.entry.pymethdef_cname)
code.put_pymethoddef(self.entry, ";", allow_skip=False)
if self.is_generator:
code.putln("static PyObject *%s(PyObject *%s, PyObject *__pyx_send_value, int __pyx_is_exc) /* generator body */\n{" %
(self.generator_body_cname, Naming.self_cname))
code.putln("static PyObject *%s(PyObject *%s, PyObject *%s) /* generator body */\n{" %
(self.generator_body_cname, Naming.self_cname, Naming.sent_value_cname))
self.generator = GeneratorWrapperNode(self,
func_cname=self.entry.func_cname,
body_cname=self.generator_body_cname,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment