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
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
Show 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):
doc
.
encoding
=
encoding
return
doc
class
AttributeAccessor
:
class
_AttributeAccessor
(
object
)
:
"""Used as the result of the Node.get_children_accessors() generator"""
def
__init__
(
self
,
obj
,
attrname
):
self
.
obj
=
obj
...
...
@@ -78,7 +78,18 @@ class AttributeAccessor:
def
name
(
self
):
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
# is_name boolean Is a NameNode
# is_literal boolean Is a ConstNode
...
...
@@ -129,13 +140,7 @@ class Node:
if
attrnames
is
None
:
raise
InternalError
(
"Children access not implemented for %s"
%
\
self
.
__class__
.
__name__
)
for
name
in
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
return
_AttributeIterator
(
self
,
attrnames
)
def
get_child_attrs
(
self
):
"""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