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
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):
...
@@ -25,7 +25,7 @@ class AnnotationCCodeWriter(CCodeWriter):
self
.
last_pos
=
None
self
.
last_pos
=
None
self
.
code
=
{}
self
.
code
=
{}
else
:
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
.
annotation_buffer
=
create_from
.
annotation_buffer
self
.
annotations
=
create_from
.
annotations
self
.
annotations
=
create_from
.
annotations
self
.
code
=
create_from
.
code
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):
...
@@ -239,7 +239,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
=
Annotate
.
AnnotationCCodeWriter
()
code
=
Annotate
.
AnnotationCCodeWriter
()
else
:
else
:
code
=
Code
.
CCodeWriter
()
code
=
Code
.
CCodeWriter
()
h_code
=
code
.
fork
()
h_code
=
code
.
insertion_point
()
self
.
generate_module_preamble
(
env
,
modules
,
h_code
)
self
.
generate_module_preamble
(
env
,
modules
,
h_code
)
code
.
putln
(
""
)
code
.
putln
(
""
)
...
...
Cython/StringIOTree.py
View file @
b6f46a39
...
@@ -24,7 +24,7 @@ class StringIOTree(object):
...
@@ -24,7 +24,7 @@ class StringIOTree(object):
def
write
(
self
,
what
):
def
write
(
self
,
what
):
self
.
stream
.
write
(
what
)
self
.
stream
.
write
(
what
)
def
fork
(
self
):
def
insertion_point
(
self
):
# Save what we have written until now
# Save what we have written until now
# (would it be more efficient to check with len(self.stream.getvalue())?
# (would it be more efficient to check with len(self.stream.getvalue())?
# leaving it out for now)
# leaving it out for now)
...
@@ -36,30 +36,29 @@ class StringIOTree(object):
...
@@ -36,30 +36,29 @@ class StringIOTree(object):
return
other
return
other
__doc__
=
r"""
__doc__
=
r"""
Implements a forkable buffer. When you know you need to "get back" to a place
Implements a buffer with insertion points. When you know you need to
and write more later, simply call fork() at that spot and get a new
"get back" to a place and write more later, simply call insertion_point()
StringIOTree object that is "left behind", *behind* the object that is
at that spot and get a new StringIOTree object that is "left behind".
forked.
EXAMPLE:
EXAMPLE:
>>>
pyrex
= StringIOTree()
>>>
a
= StringIOTree()
>>>
pyrex
.write('first\n')
>>>
a
.write('first\n')
>>>
cython = pyrex.fork
()
>>>
b = a.insertion_point
()
>>>
pyrex
.write('third\n')
>>>
a
.write('third\n')
>>>
cython
.write('second\n')
>>>
b
.write('second\n')
>>> print
pyrex
.getvalue()
>>> print
a
.getvalue()
first
first
second
second
third
third
<BLANKLINE>
<BLANKLINE>
>>>
b = cython.fork
()
>>>
c = b.insertion_point
()
>>>
a = b.fork
()
>>>
d = c.insertion_point
()
>>>
a
.write('alpha\n')
>>>
d
.write('alpha\n')
>>>
cython
.write('gamma\n')
>>>
b
.write('gamma\n')
>>>
b
.write('beta\n')
>>>
c
.write('beta\n')
>>> print
cython
.getvalue()
>>> print
b
.getvalue()
second
second
alpha
alpha
beta
beta
...
@@ -67,7 +66,7 @@ gamma
...
@@ -67,7 +66,7 @@ gamma
<BLANKLINE>
<BLANKLINE>
>>> out = StringIO()
>>> out = StringIO()
>>>
pyrex
.copyto(out)
>>>
a
.copyto(out)
>>> print out.getvalue()
>>> print out.getvalue()
first
first
second
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