summaryrefslogtreecommitdiff
path: root/Cython/Compiler/ModuleNode.py
diff options
context:
space:
mode:
authorJeroen Demeyer <jdemeyer@cage.ugent.be>2017-10-06 17:30:50 +0200
committerJeroen Demeyer <jdemeyer@cage.ugent.be>2017-11-17 16:30:08 +0100
commit639feee7d7146c3f7cfab73935fb84e4941ce391 (patch)
tree68bc80cf61ffadf4250631a3bd27556422be7863 /Cython/Compiler/ModuleNode.py
parente40563556e8939ba867aff6859f03f0d40e6214e (diff)
downloadcython-639feee7d7146c3f7cfab73935fb84e4941ce391.tar.gz
Verbatim C code using docstring syntax.
Diffstat (limited to 'Cython/Compiler/ModuleNode.py')
-rw-r--r--Cython/Compiler/ModuleNode.py34
1 files changed, 14 insertions, 20 deletions
diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py
index 9bc0a014e..0602f6b80 100644
--- a/Cython/Compiler/ModuleNode.py
+++ b/Cython/Compiler/ModuleNode.py
@@ -28,7 +28,7 @@ from . import Pythran
from .Errors import error, warning
from .PyrexTypes import py_object_type
from ..Utils import open_new_file, replace_suffix, decode_filename
-from .Code import UtilityCode
+from .Code import UtilityCode, IncludeCode
from .StringEncoding import EncodedString
from .Pythran import has_np_pythran
@@ -86,16 +86,15 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
self.scope.utility_code_list.extend(scope.utility_code_list)
+ for inc in scope.c_includes.values():
+ self.scope.process_include(inc)
+
def extend_if_not_in(L1, L2):
for x in L2:
if x not in L1:
L1.append(x)
- extend_if_not_in(self.scope.include_files_early, scope.include_files_early)
- extend_if_not_in(self.scope.include_files_late, scope.include_files_late)
extend_if_not_in(self.scope.included_files, scope.included_files)
- extend_if_not_in(self.scope.python_include_files,
- scope.python_include_files)
if merge_scope:
# Ensure that we don't generate import code for these entries!
@@ -621,8 +620,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln("")
code.putln("#define PY_SSIZE_T_CLEAN")
- for filename in env.python_include_files:
- code.putln('#include "%s"' % filename)
+ for inc in sorted(env.c_includes.values(), key=IncludeCode.sortkey):
+ if inc.location == inc.INITIAL:
+ inc.write(code)
code.putln("#ifndef Py_PYTHON_H")
code.putln(" #error Python headers needed to compile C extensions, "
"please install development version of Python.")
@@ -739,19 +739,13 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
def generate_includes(self, env, cimported_modules, code, early=True, late=True):
includes = []
- if early:
- includes += env.include_files_early
- if late:
- includes += [include for include in env.include_files_late
- if include not in env.include_files_early]
- for filename in includes:
- byte_decoded_filenname = str(filename)
-
- if byte_decoded_filenname[0] == '<' and byte_decoded_filenname[-1] == '>':
- code.putln('#include %s' % byte_decoded_filenname)
- else:
- code.putln('#include "%s"' % byte_decoded_filenname)
-
+ for inc in sorted(env.c_includes.values(), key=IncludeCode.sortkey):
+ if inc.location == inc.EARLY:
+ if early:
+ inc.write(code)
+ elif inc.location == inc.LATE:
+ if late:
+ inc.write(code)
if early:
code.putln_openmp("#include <omp.h>")