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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
f2ca7218
Commit
f2ca7218
authored
Apr 26, 2008
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no need to use yield for now
parent
d737fed4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
9 deletions
+14
-9
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+14
-9
No files found.
Cython/Compiler/Nodes.py
View file @
f2ca7218
...
@@ -63,7 +63,7 @@ def embed_position(pos, docstring):
...
@@ -63,7 +63,7 @@ def embed_position(pos, docstring):
doc
.
encoding
=
encoding
doc
.
encoding
=
encoding
return
doc
return
doc
class
AttributeAccessor
:
class
_AttributeAccessor
(
object
)
:
"""Used as the result of the Node.get_children_accessors() generator"""
"""Used as the result of the Node.get_children_accessors() generator"""
def
__init__
(
self
,
obj
,
attrname
):
def
__init__
(
self
,
obj
,
attrname
):
self
.
obj
=
obj
self
.
obj
=
obj
...
@@ -78,7 +78,18 @@ class AttributeAccessor:
...
@@ -78,7 +78,18 @@ class AttributeAccessor:
def
name
(
self
):
def
name
(
self
):
return
self
.
attrname
return
self
.
attrname
class
Node
:
class
_AttributeIterator
(
object
):
"""Used as the result of the Node.get_children_accessors() generator"""
def
__init__
(
self
,
obj
,
attrnames
):
self
.
obj
=
obj
self
.
attrnames
=
iter
(
attrnames
)
def
__iter__
(
self
):
return
self
def
__next__
(
self
):
return
_AttributeAccessor
(
self
.
obj
,
self
.
attrnames
.
next
())
next
=
__next__
class
Node
(
object
):
# pos (string, int, int) Source file position
# pos (string, int, int) Source file position
# is_name boolean Is a NameNode
# is_name boolean Is a NameNode
# is_literal boolean Is a ConstNode
# is_literal boolean Is a ConstNode
...
@@ -129,13 +140,7 @@ class Node:
...
@@ -129,13 +140,7 @@ class Node:
if
attrnames
is
None
:
if
attrnames
is
None
:
raise
InternalError
(
"Children access not implemented for %s"
%
\
raise
InternalError
(
"Children access not implemented for %s"
%
\
self
.
__class__
.
__name__
)
self
.
__class__
.
__name__
)
for
name
in
attrnames
:
return
_AttributeIterator
(
self
,
attrnames
)
a
=
AttributeAccessor
(
self
,
name
)
yield
a
# Not really needed, but one wants to enforce clients not to
# hold on to iterated objects, in case more advanced iteration
# is needed later
a
.
attrname
=
None
def
get_child_attrs
(
self
):
def
get_child_attrs
(
self
):
"""Utility method for more easily implementing get_child_accessors.
"""Utility method for more easily implementing get_child_accessors.
...
...
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