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
Gwenaël Samain
cython
Commits
b592380b
Commit
b592380b
authored
Feb 12, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support Python string constants in utility code
parent
27b20d12
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
1 deletion
+12
-1
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+12
-1
No files found.
Cython/Compiler/Code.py
View file @
b592380b
...
...
@@ -372,6 +372,16 @@ class UtilityCode(UtilityCodeBase):
self
.
specialize_list
.
append
(
s
)
return
s
def
inject_string_constants
(
self
,
impl
,
output
):
"""Replace 'PYIDENT("xyz")' by a constant Python identifier cname.
"""
pystrings
=
re
.
findall
(
'(PYIDENT
\
(
"
([^"]+)"
\
))
'
, impl)
for ref, name in pystrings:
py_const = output.get_interned_identifier(
StringEncoding.EncodedString(name))
impl = impl.replace(ref, py_const.cname)
return impl
def put_code(self, output):
if self.requires:
for dependency in self.requires:
...
...
@@ -379,7 +389,8 @@ class UtilityCode(UtilityCodeBase):
if self.proto:
output[self.proto_block].put(self.format_code(self.proto))
if self.impl:
output
[
'utility_code_def'
].
put
(
self
.
format_code
(
self
.
impl
))
output['
utility_code_def
'].put(self.format_code(
self.inject_string_constants(self.impl, output)))
if self.init:
writer = output['
init_globals
']
writer.putln("/* %s.init */" % self.name)
...
...
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