--- /dev/null
+
+cdef class UtilityCode:
+ cdef public object proto
+ cdef public object impl
+ cdef public object init
+ cdef public object cleanup
+ cdef public object requires
+ cdef public dict _cache
+ cdef public list specialize_list
+ cdef public object proto_block
+
+ cpdef put_code(self, dict output)
+
+cdef class FunctionState:
+ cdef public set names_taken
+ cdef public object owner
+
+ cdef public object error_label
+ cdef public Py_ssize_t label_counter
+ cdef public set labels_used
+ cdef public object return_label
+ cdef public object continue_label
+ cdef public object break_label
+
+ cdef public object return_from_error_cleanup_label # not used in __init__ ?
+
+ cdef public bint in_try_finally
+ cdef public object exc_vars
+
+ cdef public list temps_allocated
+ cdef public dict temps_free
+ cdef public dict temps_used_type
+ cdef public Py_ssize_t temp_counter
+
+ cpdef tuple get_loop_labels(self)
+ cpdef set_loop_labels(self, labels)
+ cpdef tuple get_all_labels(self)
+ cpdef set_all_labels(self, labels)
+
+ cpdef list temps_in_use(self)
+
+cdef class IntConst:
+ cdef public object cname
+ cdef public object value
+ cdef public bint is_long
+
+cdef class PyObjectConst:
+ cdef public object cname
+ cdef public object type
+
+cdef class StringConst:
+ cdef public object cname
+ cdef public object text
+ cdef public object escaped_value
+ cdef public dict py_strings
+
+## cdef class PyStringConst:
+## cdef public object cname
+## cdef public object encoding
+## cdef public bint is_str
+## cdef public bint is_unicode
+## cdef public bint intern
+
+#class GlobalState(object):
+
+#def funccontext_property(name):
+
+#class CCodeWriter(object):
+
+cdef class PyrexCodeWriter:
+ cdef public object f
+ cdef public Py_ssize_t level
+# cython: language_level = 3
#
# Pyrex - Code output module
#
+import cython
+cython.declare(re=object, Naming=object, Options=object, StringEncoding=object,
+ Utils=object, SourceDescriptor=object, StringIOTree=object,
+ DebugFlags=object, none_or_sub=object)
+
import re
import Naming
import Options
from Cython import Utils
from Scanning import SourceDescriptor
from Cython.StringIOTree import StringIOTree
-try:
- set
-except NameError:
- from sets import Set as set
import DebugFlags
from Cython.Utils import none_or_sub
+try:
+ basestring
+except NameError:
+ basestring = str
class UtilityCode(object):
# Stores utility code to add during code generation.
# exc_vars (string * 3) exception variables for reraise, or None
# Not used for now, perhaps later
- def __init__(self, owner, names_taken=set()):
+ def __init__(self, owner, names_taken=cython.set()):
self.names_taken = names_taken
self.owner = owner
self.error_label = None
self.label_counter = 0
- self.labels_used = {}
+ self.labels_used = cython.set()
self.return_label = self.new_label()
self.new_error_label()
self.continue_label = None
return old_labels
def use_label(self, lbl):
- self.labels_used[lbl] = 1
+ self.labels_used.add(lbl)
def label_used(self, lbl):
return lbl in self.labels_used
error case.
"""
return [(cname, type)
- for (type, manage_ref), freelist in self.temps_free.iteritems()
+ for (type, manage_ref), freelist in self.temps_free.items()
if manage_ref
for cname in freelist]
self.filename_table = {}
self.filename_list = []
self.input_file_contents = {}
- self.utility_codes = set()
+ self.utility_codes = cython.set()
self.declared_cnames = {}
self.in_utility_code_generation = False
self.emit_linenums = emit_linenums
def generate_string_constants(self):
c_consts = [ (len(c.cname), c.cname, c)
- for c in self.string_const_index.itervalues() ]
+ for c in self.string_const_index.values() ]
c_consts.sort()
py_strings = []
decls_writer.putln('static char %s[] = "%s";' % (
cname, StringEncoding.split_string_literal(c.escaped_value)))
if c.py_strings is not None:
- for py_string in c.py_strings.itervalues():
+ for py_string in c.py_strings.values():
py_strings.append((c.cname, len(py_string.cname), py_string))
if py_strings:
def generate_int_constants(self):
consts = [ (len(c.value), c.value, c.is_long, c)
- for c in self.int_const_index.itervalues() ]
+ for c in self.int_const_index.values() ]
consts.sort()
decls_writer = self.parts['decls']
for _, value, longness, c in consts: