Change generator body signature to PyObject* (*body)(PyObject *, Pyobject *)
authorVitja Makarov <vitja.makarov@gmail.com>
Fri, 10 Dec 2010 18:50:59 +0000 (21:50 +0300)
committerVitja Makarov <vitja.makarov@gmail.com>
Fri, 10 Dec 2010 18:50:59 +0000 (21:50 +0300)
Cython/Compiler/ExprNodes.py
Cython/Compiler/Naming.py
Cython/Compiler/Nodes.py

index fd1e66a5c1b4645e4ea2e0f439da32a698950928..c7e0adf8afbe9e468d94ac17b0a0b22906929b42 100755 (executable)
@@ -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,
index 0dd4af8e23e136e11bc0b1bfec76dc39a55378b4..052c1e34d30e0cdb3b3db89e6d164df5e2918a2a 100644 (file)
@@ -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"
index 48eb131bf76fdaea33c301eeb3f4db40e41b2deb..364083f9380694ab7ebbd55b86df52838d374fa5 100644 (file)
@@ -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,