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
Boxiang Sun
cython
Commits
b6f46a39
Commit
b6f46a39
authored
Jul 30, 2008
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed name from "fork" to "insertion_point" (codewriter), introduced func context
parent
ace9e7f1
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
149 additions
and
117 deletions
+149
-117
Cython/Compiler/Annotate.py
Cython/Compiler/Annotate.py
+1
-1
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+130
-97
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+1
-1
Cython/StringIOTree.py
Cython/StringIOTree.py
+17
-18
No files found.
Cython/Compiler/Annotate.py
View file @
b6f46a39
...
...
@@ -25,7 +25,7 @@ class AnnotationCCodeWriter(CCodeWriter):
self
.
last_pos
=
None
self
.
code
=
{}
else
:
# When
forking
, keep references to the same database
# When
creating an insertion point
, keep references to the same database
self
.
annotation_buffer
=
create_from
.
annotation_buffer
self
.
annotations
=
create_from
.
annotations
self
.
code
=
create_from
.
code
...
...
Cython/Compiler/Code.py
View file @
b6f46a39
This diff is collapsed.
Click to expand it.
Cython/Compiler/ModuleNode.py
View file @
b6f46a39
...
...
@@ -239,7 +239,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
=
Annotate
.
AnnotationCCodeWriter
()
else
:
code
=
Code
.
CCodeWriter
()
h_code
=
code
.
fork
()
h_code
=
code
.
insertion_point
()
self
.
generate_module_preamble
(
env
,
modules
,
h_code
)
code
.
putln
(
""
)
...
...
Cython/StringIOTree.py
View file @
b6f46a39
...
...
@@ -24,7 +24,7 @@ class StringIOTree(object):
def
write
(
self
,
what
):
self
.
stream
.
write
(
what
)
def
fork
(
self
):
def
insertion_point
(
self
):
# Save what we have written until now
# (would it be more efficient to check with len(self.stream.getvalue())?
# leaving it out for now)
...
...
@@ -36,30 +36,29 @@ class StringIOTree(object):
return
other
__doc__
=
r"""
Implements a forkable buffer. When you know you need to "get back" to a place
and write more later, simply call fork() at that spot and get a new
StringIOTree object that is "left behind", *behind* the object that is
forked.
Implements a buffer with insertion points. When you know you need to
"get back" to a place and write more later, simply call insertion_point()
at that spot and get a new StringIOTree object that is "left behind".
EXAMPLE:
>>>
pyrex
= StringIOTree()
>>>
pyrex
.write('first\n')
>>>
cython = pyrex.fork
()
>>>
pyrex
.write('third\n')
>>>
cython
.write('second\n')
>>> print
pyrex
.getvalue()
>>>
a
= StringIOTree()
>>>
a
.write('first\n')
>>>
b = a.insertion_point
()
>>>
a
.write('third\n')
>>>
b
.write('second\n')
>>> print
a
.getvalue()
first
second
third
<BLANKLINE>
>>>
b = cython.fork
()
>>>
a = b.fork
()
>>>
a
.write('alpha\n')
>>>
cython
.write('gamma\n')
>>>
b
.write('beta\n')
>>> print
cython
.getvalue()
>>>
c = b.insertion_point
()
>>>
d = c.insertion_point
()
>>>
d
.write('alpha\n')
>>>
b
.write('gamma\n')
>>>
c
.write('beta\n')
>>> print
b
.getvalue()
second
alpha
beta
...
...
@@ -67,7 +66,7 @@ gamma
<BLANKLINE>
>>> out = StringIO()
>>>
pyrex
.copyto(out)
>>>
a
.copyto(out)
>>> print out.getvalue()
first
second
...
...
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