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
e6fe63d9
Commit
e6fe63d9
authored
May 21, 2009
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UtilityCode put_code protocol
parent
9875327a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
27 deletions
+29
-27
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+21
-19
Cython/Compiler/DebugFlags.py
Cython/Compiler/DebugFlags.py
+1
-1
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+2
-2
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+5
-5
No files found.
Cython/Compiler/Code.py
View file @
e6fe63d9
...
...
@@ -68,6 +68,18 @@ class UtilityCode(object):
self
.
specialize_list
.
append
(
s
)
return
s
def
put_code
(
self
,
output
):
if
self
.
requires
:
for
dependency
in
self
.
requires
:
output
.
use_utility_code
(
dependency
)
if
self
.
proto
:
output
[
'utility_code_proto'
].
put
(
self
.
proto
)
if
self
.
impl
:
output
[
'utility_code_def'
].
put
(
self
.
impl
)
self
.
write_init_code
(
output
.
initwriter
,
output
.
module_pos
)
self
.
write_cleanup_code
(
output
.
cleanupwriter
,
output
.
module_pos
)
class
FunctionState
(
object
):
# return_label string function return point label
# error_label string error catch point label
...
...
@@ -691,28 +703,18 @@ class GlobalState(object):
# Utility code state
#
def use_utility_code(self, utility_code
, name=None
):
def use_utility_code(self, utility_code):
"""
Adds
the given utility code to the C file if needed.
codetup should unpack into one prototype code part and one
definition code part, both strings inserted directly in C.
Adds
code to the C file. utility_code should
a) implement __eq__/__hash__ for the purpose of knowing whether the same
code has already been included
b) implement put_code, which takes a globalstate instance
If name is provided, it is used as an identifier to avoid inserting
code twice. Otherwise, id(codetup) is used as such an identifier.
See UtilityCode.
"""
if name is None: name = id(utility_code)
if name not in self.utility_codes:
self.utility_codes.add(name)
if utility_code.requires:
for dependency in utility_code.requires:
self.use_utility_code(dependency)
if utility_code.proto:
self.parts['utility_code_proto'].put(utility_code.proto)
if utility_code.impl:
self.parts['utility_code_def'].put(utility_code.impl)
utility_code.write_init_code(self.initwriter, self.module_pos)
utility_code.write_cleanup_code(self.cleanupwriter, self.module_pos)
if utility_code not in self.utility_codes:
self.utility_codes.add(utility_code)
utility_code.put_code(self)
def funccontext_property(name):
...
...
Cython/Compiler/DebugFlags.py
View file @
e6fe63d9
...
...
@@ -10,7 +10,7 @@ debug_temp_code_comments = 0
debug_trace_code_generation
=
0
# Do not replace exceptions with user-friendly error messages
debug_no_exception_intercept
=
0
debug_no_exception_intercept
=
1
# Print a message each time a new stage in the pipeline is entered
debug_verbose_pipeline
=
0
Cython/Compiler/ModuleNode.py
View file @
e6fe63d9
...
...
@@ -285,8 +285,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
self
.
generate_declarations_for_modules
(
env
,
modules
,
globalstate
)
h_code
.
write
(
'
\
n
'
)
for
codetup
,
nam
e
in
env
.
utility_code_list
:
globalstate
.
use_utility_code
(
codetup
,
nam
e
)
for
utilcod
e
in
env
.
utility_code_list
:
globalstate
.
use_utility_code
(
utilcod
e
)
globalstate
.
finalize_main_c_code
()
f
=
open_new_file
(
result
.
c_file
)
...
...
Cython/Compiler/Symtab.py
View file @
e6fe63d9
...
...
@@ -527,8 +527,8 @@ class Scope(object):
if entry and entry.is_type:
return entry.type
def use_utility_code(self, new_code
, name=None
):
self.global_scope().use_utility_code(new_code
, name
)
def use_utility_code(self, new_code):
self.global_scope().use_utility_code(new_code)
def generate_library_function_declarations(self, code):
# Generate extern decls for C library funcs used.
...
...
@@ -654,7 +654,7 @@ class ModuleScope(Scope):
# method_table_cname string C name of method table
# doc string Module doc string
# doc_cname string C name of module doc string
# utility_code_list [
(UtilityCode, string)]
Queuing utility codes for forwarding to Code.py
# utility_code_list [
UtilityCode]
Queuing utility codes for forwarding to Code.py
# python_include_files [string] Standard Python headers to be included
# include_files [string] Other C headers to be included
# string_to_entry {string : Entry} Map string const to entry
...
...
@@ -829,9 +829,9 @@ class ModuleScope(Scope):
if not entry:
self.declare_var(name, py_object_type, pos)
def use_utility_code(self, new_code
, name=None
):
def use_utility_code(self, new_code):
if new_code is not None:
self.utility_code_list.append(
(new_code, name)
)
self.utility_code_list.append(
new_code
)
def declare_c_class(self, name, pos, defining = 0, implementing = 0,
module_name = None, base_type = None, objstruct_cname = None,
...
...
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