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
859e52bb
Commit
859e52bb
authored
Jan 15, 2008
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Annotation work
parent
ad3415a3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
15 deletions
+26
-15
Cython/Compiler/Annotate.py
Cython/Compiler/Annotate.py
+20
-13
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+2
-0
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+4
-0
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+0
-2
No files found.
Cython/Compiler/Annotate.py
View file @
859e52bb
...
...
@@ -7,6 +7,10 @@ from StringIO import StringIO
from
Code
import
CCodeWriter
# need one-characters subsitutions (for now) so offsets aren't off
special_chars
=
[(
'<'
,
'
\
xF0
'
,
'<'
),
(
'>'
,
'
\
xF1
'
,
'>'
),
(
'&'
,
'
\
xF2
'
,
'&'
)]
class
AnnotationCCodeWriter
(
CCodeWriter
):
...
...
@@ -29,14 +33,13 @@ class AnnotationCCodeWriter(CCodeWriter):
# if pos is not None:
# CCodeWriter.mark_pos(self, pos)
# return
print
"marking"
,
pos
if
self
.
last_pos
:
try
:
code
=
self
.
code
[
self
.
last_pos
[
1
]]
except
KeyError
:
code
=
""
self
.
code
[
self
.
last_pos
[
1
]]
=
code
+
self
.
buffer
.
getvalue
()
self
.
buffer
=
StringIO
()
self
.
buffer
=
StringIO
()
self
.
last_pos
=
pos
def
annotate
(
self
,
pos
,
item
):
...
...
@@ -47,12 +50,10 @@ class AnnotationCCodeWriter(CCodeWriter):
f
=
open
(
filename
)
lines
=
f
.
readlines
()
for
k
in
range
(
len
(
lines
)):
# there has to be a better way to do this
lines
[
k
]
=
lines
[
k
].
replace
(
' '
,
'
\
t
'
)
lines
[
k
]
=
lines
[
k
].
replace
(
' '
,
'
\
t
\
t
'
)
# TODO: this is incorrect
lines
[
k
]
=
lines
[
k
].
replace
(
'<'
,
'~'
)
lines
[
k
]
=
lines
[
k
].
replace
(
'>'
,
'~'
)
line
=
lines
[
k
]
for
c
,
cc
,
html
in
special_chars
:
line
=
line
.
replace
(
c
,
cc
)
lines
[
k
]
=
line
f
.
close
()
all
=
[]
for
pos
,
item
in
self
.
annotations
:
...
...
@@ -86,6 +87,7 @@ body { font-family: courier; font-size: 12; }
.py_api { color: red; }
.pyx_api { color: #FF3000; }
.py_macro_api { color: #FF8000; }
.error_goto { color: #FF8000; }
.tag { }
...
...
@@ -97,6 +99,8 @@ body { font-family: courier; font-size: 12; }
.py_call { color: #FF0000; font-weight: bold; }
.c_call { color: #0000FF; }
.line { margin: 0em }
</style>
<script>
function toggleDiv(id) {
...
...
@@ -113,6 +117,7 @@ function toggleDiv(id) {
py_c_api
=
re
.
compile
(
'(Py[A-Z][a-z]+_[A-Z][a-z][A-Za-z_]+)'
)
pyx_api
=
re
.
compile
(
'(__Pyx[A-Za-z_]+)
\
(
'
)
py_marco_api = re.compile('
(
Py
[
A
-
Za
-
z
]
*
_
[
A
-
Z
][
A
-
Z_
]
+
)
')
error_goto = re.compile(r'
(
if
.
*
?
\
{
__pyx_filename
=
.
*
goto
__pyx_L
\
w
+
;
\
})
')
for line in lines:
...
...
@@ -125,16 +130,18 @@ function toggleDiv(id) {
code, c_api_calls = py_c_api.subn(r"<span class='
py_api
'>
\
1
</span>", code)
code, pyx_api_calls = pyx_api.subn(r"<span class='
pyx_api
'>
\
1
</span>(", code)
code, macro_api_calls = py_marco_api.subn(r"<span class='
py_macro_api
'>
\
1
</span>", code)
code, error_goto_calls = error_goto.subn(r"<span class='
error_goto
'>
\
1
</span>", code)
color = "FFFF%02x" % int(255/(1+(5*c_api_calls+2*pyx_api_calls+macro_api_calls)/10.0))
f.write("<
div
class='
line
' style='
background
-
color
:
#%s' onclick='toggleDiv(\"line%s\")'>" % (color, k))
f.write("<
pre
class='
line
' style='
background
-
color
:
#%s' onclick='toggleDiv(\"line%s\")'>" % (color, k))
f
.
write
(
" %d: "
%
k
)
line
=
line
.
replace
(
'
\
t
'
,
' '
)
f
.
write
(
line
)
for
c
,
cc
,
html
in
special_chars
:
line
=
line
.
replace
(
cc
,
html
)
f
.
write
(
line
.
rstrip
())
f
.
write
(
'</
div
>
\
n
'
)
f
.
write
(
"<
div id='line%s' class='code' style='background-color: #%s'>%s</div>"
%
(
k
,
color
,
code
.
replace
(
'
\
n
'
,
'
\
n
<br>'
)
))
f
.
write
(
'</
pre
>
\
n
'
)
f
.
write
(
"<
pre id='line%s' class='code' style='background-color: #%s'>%s</pre>"
%
(
k
,
color
,
code
))
f
.
write
(
'</body></html>
\
n
'
)
f
.
close
()
...
...
Cython/Compiler/Code.py
View file @
859e52bb
...
...
@@ -98,6 +98,8 @@ class CCodeWriter:
return
"0x%02X%02X%02X%02X"
%
(
tuple
(
pyversion
)
+
(
0
,
0
,
0
,
0
))[:
4
]
def
mark_pos
(
self
,
pos
):
if
pos
is
None
:
return
file
,
line
,
col
=
pos
contents
=
self
.
file_contents
(
file
)
...
...
Cython/Compiler/ModuleNode.py
View file @
859e52bb
...
...
@@ -217,12 +217,14 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
self
.
generate_py_string_decls
(
env
,
code
)
self
.
generate_cached_builtins_decls
(
env
,
code
)
self
.
body
.
generate_function_definitions
(
env
,
code
)
code
.
mark_pos
(
None
)
self
.
generate_interned_name_table
(
env
,
code
)
self
.
generate_py_string_table
(
env
,
code
)
self
.
generate_typeobj_definitions
(
env
,
code
)
self
.
generate_method_table
(
env
,
code
)
self
.
generate_filename_init_prototype
(
code
)
self
.
generate_module_init_func
(
modules
[:
-
1
],
env
,
code
)
code
.
mark_pos
(
None
)
self
.
generate_module_cleanup_func
(
env
,
code
)
self
.
generate_filename_table
(
code
)
self
.
generate_utility_functions
(
env
,
code
)
...
...
@@ -1196,6 +1198,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
"};"
)
def
generate_interned_name_table
(
self
,
env
,
code
):
code
.
mark_pos
(
None
)
items
=
env
.
intern_map
.
items
()
if
items
:
items
.
sort
()
...
...
@@ -1280,6 +1283,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
self
.
generate_type_import_code_for_module
(
module
,
env
,
code
)
code
.
putln
(
"/*--- Execution code ---*/"
)
code
.
mark_pos
(
None
)
self
.
body
.
generate_execution_code
(
code
)
if
Options
.
generate_cleanup_code
:
...
...
Cython/Compiler/Nodes.py
View file @
859e52bb
...
...
@@ -88,8 +88,6 @@ class Node:
# mro does the wrong thing
if
isinstance
(
self
,
BlockNode
):
self
.
body
.
annotate
(
code
)
else
:
print
"skipping"
,
self
class
BlockNode
:
...
...
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