Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
940d2711
Commit
940d2711
authored
Dec 10, 2010
by
Vitja Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change generator body signature to PyObject* (*body)(PyObject *, Pyobject *)
parent
299a9977
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
11 deletions
+13
-11
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+9
-8
Cython/Compiler/Naming.py
Cython/Compiler/Naming.py
+1
-0
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+3
-3
No files found.
Cython/Compiler/ExprNodes.py
View file @
940d2711
...
@@ -5019,8 +5019,9 @@ class YieldExprNode(ExprNode):
...
@@ -5019,8 +5019,9 @@ class YieldExprNode(ExprNode):
code
.
putln
(
'%s = %s->%s;'
%
(
cname
,
Naming
.
cur_scope_cname
,
save_cname
))
code
.
putln
(
'%s = %s->%s;'
%
(
cname
,
Naming
.
cur_scope_cname
,
save_cname
))
if
type
.
is_pyobject
:
if
type
.
is_pyobject
:
code
.
putln
(
'%s->%s = 0;'
%
(
Naming
.
cur_scope_cname
,
save_cname
))
code
.
putln
(
'%s->%s = 0;'
%
(
Naming
.
cur_scope_cname
,
save_cname
))
code
.
putln
(
'%s = __pyx_send_value; %s'
%
code
.
putln
(
'%s = %s; %s'
%
(
self
.
result
(),
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
(
self
.
result
(),
Naming
.
sent_value_cname
,
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_incref
(
self
.
result
(),
py_object_type
)
code
.
put_incref
(
self
.
result
(),
py_object_type
)
class
StopIterationNode
(
Node
):
class
StopIterationNode
(
Node
):
...
@@ -8308,10 +8309,10 @@ proto="""
...
@@ -8308,10 +8309,10 @@ proto="""
static PyObject *__CyGenerator_Next(PyObject *self);
static PyObject *__CyGenerator_Next(PyObject *self);
static PyObject *__CyGenerator_Send(PyObject *self, PyObject *value);
static PyObject *__CyGenerator_Send(PyObject *self, PyObject *value);
static PyObject *__CyGenerator_Close(PyObject *self);
static PyObject *__CyGenerator_Close(PyObject *self);
typedef PyObject *(*__cygenerator_body_t)(PyObject *, PyObject *
, int
);
typedef PyObject *(*__cygenerator_body_t)(PyObject *, PyObject *);
"""
,
"""
,
impl
=
"""
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;
PyObject *retval;
...
@@ -8336,7 +8337,7 @@ static CYTHON_INLINE PyObject *__CyGenerator_SendEx(struct __CyGenerator *self,
...
@@ -8336,7 +8337,7 @@ static CYTHON_INLINE PyObject *__CyGenerator_SendEx(struct __CyGenerator *self,
}
}
self->is_running = 1;
self->is_running = 1;
retval = self->body((PyObject *) self, value
, is_exc
);
retval = self->body((PyObject *) self, value);
self->is_running = 0;
self->is_running = 0;
return retval;
return retval;
...
@@ -8348,14 +8349,14 @@ static PyObject *__CyGenerator_Next(PyObject *self)
...
@@ -8348,14 +8349,14 @@ static PyObject *__CyGenerator_Next(PyObject *self)
PyObject *retval;
PyObject *retval;
Py_INCREF(Py_None);
Py_INCREF(Py_None);
retval = __CyGenerator_SendEx(generator, Py_None
, 0
);
retval = __CyGenerator_SendEx(generator, Py_None);
Py_DECREF(Py_None);
Py_DECREF(Py_None);
return retval;
return retval;
}
}
static PyObject *__CyGenerator_Send(PyObject *self, PyObject *value)
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)
static PyObject *__CyGenerator_Close(PyObject *self)
...
@@ -8363,7 +8364,7 @@ static PyObject *__CyGenerator_Close(PyObject *self)
...
@@ -8363,7 +8364,7 @@ static PyObject *__CyGenerator_Close(PyObject *self)
struct __CyGenerator *generator = (struct __CyGenerator *) self;
struct __CyGenerator *generator = (struct __CyGenerator *) self;
PyObject *retval;
PyObject *retval;
PyErr_SetNone(PyExc_GeneratorExit);
PyErr_SetNone(PyExc_GeneratorExit);
retval = __CyGenerator_SendEx(generator, NULL
, 0
);
retval = __CyGenerator_SendEx(generator, NULL);
if (retval) {
if (retval) {
Py_DECREF(retval);
Py_DECREF(retval);
PyErr_SetString(PyExc_RuntimeError,
PyErr_SetString(PyExc_RuntimeError,
...
...
Cython/Compiler/Naming.py
View file @
940d2711
...
@@ -52,6 +52,7 @@ lambda_func_prefix = pyrex_prefix + "lambda_"
...
@@ -52,6 +52,7 @@ lambda_func_prefix = pyrex_prefix + "lambda_"
module_is_main
=
pyrex_prefix
+
"module_is_main_"
module_is_main
=
pyrex_prefix
+
"module_is_main_"
args_cname
=
pyrex_prefix
+
"args"
args_cname
=
pyrex_prefix
+
"args"
sent_value_cname
=
pyrex_prefix
+
"sent_value"
pykwdlist_cname
=
pyrex_prefix
+
"pyargnames"
pykwdlist_cname
=
pyrex_prefix
+
"pyargnames"
obj_base_cname
=
pyrex_prefix
+
"base"
obj_base_cname
=
pyrex_prefix
+
"base"
builtins_cname
=
pyrex_prefix
+
"b"
builtins_cname
=
pyrex_prefix
+
"b"
...
...
Cython/Compiler/Nodes.py
View file @
940d2711
...
@@ -1363,7 +1363,7 @@ class FuncDefNode(StatNode, BlockNode):
...
@@ -1363,7 +1363,7 @@ class FuncDefNode(StatNode, BlockNode):
code
.
use_label
(
first_run_label
)
code
.
use_label
(
first_run_label
)
code
.
put_label
(
first_run_label
)
code
.
put_label
(
first_run_label
)
code
.
putln
(
'%s'
%
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
:
if
not
self
.
is_generator
:
self
.
generate_argument_parsing_code
(
env
,
code
)
self
.
generate_argument_parsing_code
(
env
,
code
)
# If an argument is assigned to in the body, we must
# If an argument is assigned to in the body, we must
...
@@ -2395,8 +2395,8 @@ class DefNode(FuncDefNode):
...
@@ -2395,8 +2395,8 @@ class DefNode(FuncDefNode):
self
.
entry
.
pymethdef_cname
)
self
.
entry
.
pymethdef_cname
)
code
.
put_pymethoddef
(
self
.
entry
,
";"
,
allow_skip
=
False
)
code
.
put_pymethoddef
(
self
.
entry
,
";"
,
allow_skip
=
False
)
if
self
.
is_generator
:
if
self
.
is_generator
:
code
.
putln
(
"static PyObject *%s(PyObject *%s, PyObject *
__pyx_send_value, int __pyx_is_exc
) /* generator body */
\
n
{"
%
code
.
putln
(
"static PyObject *%s(PyObject *%s, PyObject *
%s
) /* generator body */
\
n
{"
%
(
self
.
generator_body_cname
,
Naming
.
self_cname
))
(
self
.
generator_body_cname
,
Naming
.
self_cname
,
Naming
.
sent_value_cname
))
self
.
generator
=
GeneratorWrapperNode
(
self
,
self
.
generator
=
GeneratorWrapperNode
(
self
,
func_cname
=
self
.
entry
.
func_cname
,
func_cname
=
self
.
entry
.
func_cname
,
body_cname
=
self
.
generator_body_cname
,
body_cname
=
self
.
generator_body_cname
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment