Commit 7b9b3153 authored by Dag Sverre Seljebotn's avatar Dag Sverre Seljebotn

Change command-line directive behaviour for 0.12

parent 422a77f8
...@@ -39,12 +39,12 @@ Options: ...@@ -39,12 +39,12 @@ Options:
--line-directives Produce #line directives pointing to the .pyx source --line-directives Produce #line directives pointing to the .pyx source
--cplus Output a c++ rather than c file. --cplus Output a c++ rather than c file.
--embed Embed the Python interpreter in a main() method. --embed Embed the Python interpreter in a main() method.
--directive <name>=<value>[,<name=value,...] Overrides a compiler directive -X, --directive <name>=<value>[,<name=value,...] Overrides a compiler directive
""" """
#The following experimental options are supported only on MacOSX: #The following experimental options are supported only on MacOSX:
# -C, --compile Compile generated .c file to .o file # -C, --compile Compile generated .c file to .o file
# -X, --link Link .o file to produce extension module (implies -C) # --link Link .o file to produce extension module (implies -C)
# -+, --cplus Use C++ compiler for compiling and linking # -+, --cplus Use C++ compiler for compiling and linking
# Additional .o files to link may be supplied when using -X.""" # Additional .o files to link may be supplied when using -X."""
...@@ -81,11 +81,7 @@ def parse_command_line(args): ...@@ -81,11 +81,7 @@ def parse_command_line(args):
options.use_listing_file = 1 options.use_listing_file = 1
elif option in ("-C", "--compile"): elif option in ("-C", "--compile"):
options.c_only = 0 options.c_only = 0
elif option in ("-X", "--link"): elif option in ("--link"):
if option == "-X":
print >>sys.stderr, "Deprecation warning: The -X command line switch will be changed to a"
print >>sys.stderr, "shorthand for --directive in Cython 0.12. Please use --link instead."
print >>sys.stderr
options.c_only = 0 options.c_only = 0
options.obj_only = 0 options.obj_only = 0
elif option in ("-+", "--cplus"): elif option in ("-+", "--cplus"):
......
...@@ -330,11 +330,11 @@ class InterpretCompilerDirectives(CythonTransform, SkipDeclarations): ...@@ -330,11 +330,11 @@ class InterpretCompilerDirectives(CythonTransform, SkipDeclarations):
""" """
special_methods = set(['declare', 'union', 'struct', 'typedef', 'sizeof', 'typeof', 'cast', 'address', 'pointer', 'compiled', 'NULL']) special_methods = set(['declare', 'union', 'struct', 'typedef', 'sizeof', 'typeof', 'cast', 'address', 'pointer', 'compiled', 'NULL'])
def __init__(self, context, compilation_directive_overrides): def __init__(self, context, compilation_directive_defaults):
super(InterpretCompilerDirectives, self).__init__(context) super(InterpretCompilerDirectives, self).__init__(context)
self.compilation_directive_overrides = {} self.compilation_directive_defaults = {}
for key, value in compilation_directive_overrides.iteritems(): for key, value in compilation_directive_defaults.iteritems():
self.compilation_directive_overrides[unicode(key)] = value self.compilation_directive_defaults[unicode(key)] = value
self.cython_module_names = set() self.cython_module_names = set()
self.directive_names = {} self.directive_names = {}
...@@ -349,17 +349,14 @@ class InterpretCompilerDirectives(CythonTransform, SkipDeclarations): ...@@ -349,17 +349,14 @@ class InterpretCompilerDirectives(CythonTransform, SkipDeclarations):
# Set up processing and handle the cython: comments. # Set up processing and handle the cython: comments.
def visit_ModuleNode(self, node): def visit_ModuleNode(self, node):
directives = copy.copy(Options.directive_defaults) for key, value in node.directive_comments.iteritems():
for key, value in self.compilation_directive_overrides.iteritems():
if not self.check_directive_scope(node.pos, key, 'module'): if not self.check_directive_scope(node.pos, key, 'module'):
self.wrong_scope_error(node.pos, key, 'module') self.wrong_scope_error(node.pos, key, 'module')
del self.compilation_directive_overrides[key] del node.directive_comments[key]
continue
if key in node.directive_comments and node.directive_comments[key] != value: directives = copy.copy(Options.directive_defaults)
warning(node.pos, "Compiler directive differs between environment and file header; this will change " directives.update(self.compilation_directive_defaults)
"in Cython 0.12. See http://article.gmane.org/gmane.comp.python.cython.devel/5233", 2)
directives.update(node.directive_comments) directives.update(node.directive_comments)
directives.update(self.compilation_directive_overrides)
self.directives = directives self.directives = directives
node.directives = directives node.directives = directives
self.visitchildren(node) self.visitchildren(node)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment