From d18a809b53e5376930c0a3953e831dbdfdc82f0f Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Sat, 30 Jan 2010 22:16:44 -0800 Subject: [PATCH] Cleanup filename listing. --- Cython/Compiler/Code.py | 7 +------ Cython/Compiler/ModuleNode.py | 16 ++-------------- Cython/Compiler/Naming.py | 2 -- 3 files changed, 3 insertions(+), 22 deletions(-) diff --git a/Cython/Compiler/Code.py b/Cython/Compiler/Code.py index 5d198835..83649323 100644 --- a/Cython/Compiler/Code.py +++ b/Cython/Compiler/Code.py @@ -407,6 +407,7 @@ class GlobalState(object): code_layout = [ 'h_code', + 'filename_table', 'utility_code_proto_before_types', 'numeric_typedefs', # Let these detailed individual parts stay!, 'complex_type_declarations', # as the proper solution is to make a full DAG... @@ -425,7 +426,6 @@ class GlobalState(object): 'cleanup_globals', 'cleanup_module', 'main_method', - 'filename_table', 'utility_code_def', 'end' ] @@ -484,11 +484,6 @@ class GlobalState(object): code.write('\n#line 1 "cython_utility"\n') code.putln("") code.putln("/* Runtime support code */") - code.putln("") - code.putln("static void %s(void) {" % Naming.fileinit_cname) - code.putln("%s = %s;" % - (Naming.filetable_cname, Naming.filenames_cname)) - code.putln("}") def finalize_main_c_code(self): self.close_global_decls() diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index d92cfdd1..a716d431 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -279,7 +279,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): code.mark_pos(None) self.generate_typeobj_definitions(env, code) self.generate_method_table(env, code) - self.generate_filename_init_prototype(code) if env.has_import_star: self.generate_import_star(env, code) self.generate_pymoduledef_struct(env, code) @@ -600,7 +599,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): code.putln('static int %s = 0;' % Naming.clineno_cname) code.putln('static const char * %s= %s;' % (Naming.cfilenm_cname, Naming.file_c_macro)) code.putln('static const char *%s;' % Naming.filename_cname) - code.putln('static const char **%s;' % Naming.filetable_cname) # XXX this is a mess for utility_code in PyrexTypes.c_int_from_py_function.specialize_list: @@ -624,13 +622,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): def generate_filename_table(self, code): code.putln("") - code.putln("static const char *%s[] = {" % Naming.filenames_cname) + code.putln("static const char *%s[] = {" % Naming.filetable_cname) if code.globalstate.filename_list: for source_desc in code.globalstate.filename_list: filename = os.path.basename(source_desc.get_filenametable_entry()) escaped_filename = filename.replace("\\", "\\\\").replace('"', r'\"') - code.putln('"%s",' % - escaped_filename) + code.putln('"%s",' % escaped_filename) else: # Some C compilers don't like an empty array code.putln("0") @@ -1581,10 +1578,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): code.putln( "};") - def generate_filename_init_prototype(self, code): - code.putln(""); - code.putln("static void %s(void); /*proto*/" % Naming.fileinit_cname) - def generate_import_star(self, env, code): env.use_utility_code(streq_utility_code) code.putln() @@ -1675,8 +1668,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): code.putln("__pyx_refnanny = __Pyx_RefNanny->SetupContext(\"%s\", __LINE__, __FILE__);"% header3) code.putln("#endif") - self.generate_filename_init_call(code) - code.putln("%s = PyTuple_New(0); %s" % (Naming.empty_tuple, code.error_goto_if_null(Naming.empty_tuple, self.pos))); code.putln("#if PY_MAJOR_VERSION < 3"); code.putln("%s = PyString_FromStringAndSize(\"\", 0); %s" % (Naming.empty_bytes, code.error_goto_if_null(Naming.empty_bytes, self.pos))); @@ -1816,9 +1807,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): module_is_main = "%s%s" % (Naming.module_is_main, self.full_module_name.replace('.', '__')) code.globalstate.use_utility_code(main_method.specialize(module_name=env.module_name, module_is_main=module_is_main)) - def generate_filename_init_call(self, code): - code.putln("%s();" % Naming.fileinit_cname) - def generate_pymoduledef_struct(self, env, code): if env.doc: doc = "__Pyx_DOCSTR(%s)" % code.get_string_const(env.doc) diff --git a/Cython/Compiler/Naming.py b/Cython/Compiler/Naming.py index 7c4e465f..f9f710f1 100644 --- a/Cython/Compiler/Naming.py +++ b/Cython/Compiler/Naming.py @@ -59,8 +59,6 @@ dummy_cname = pyrex_prefix + "dummy" filename_cname = pyrex_prefix + "filename" modulename_cname = pyrex_prefix + "modulename" filetable_cname = pyrex_prefix + "f" -filenames_cname = pyrex_prefix + "filenames" -fileinit_cname = pyrex_prefix + "init_filenames" intern_tab_cname = pyrex_prefix + "intern_tab" kwds_cname = pyrex_prefix + "kwds" lineno_cname = pyrex_prefix + "lineno" -- 2.26.2