Commit eb1a531e authored by Robert Bradshaw's avatar Robert Bradshaw

Require cython: for compiler directives

parent 2a785d75
...@@ -13,7 +13,7 @@ class CythonScope(ModuleScope): ...@@ -13,7 +13,7 @@ class CythonScope(ModuleScope):
self.shape_entry = self.declare_cfunction('shape', self.shape_entry = self.declare_cfunction('shape',
shape_func_type, shape_func_type,
pos=None, pos=None,
visibility='extern', defining = 1,
cname='<error>') cname='<error>')
def create_cython_scope(context): def create_cython_scope(context):
......
...@@ -1272,6 +1272,7 @@ def p_include_statement(s, ctx): ...@@ -1272,6 +1272,7 @@ def p_include_statement(s, ctx):
f = Utils.open_source_file(include_file_path, mode="rU") f = Utils.open_source_file(include_file_path, mode="rU")
source_desc = FileSourceDescriptor(include_file_path) source_desc = FileSourceDescriptor(include_file_path)
s2 = PyrexScanner(f, source_desc, s, source_encoding=f.encoding) s2 = PyrexScanner(f, source_desc, s, source_encoding=f.encoding)
s2.parse_comments = s.parse_comments
try: try:
tree = p_statement_list(s2, ctx) tree = p_statement_list(s2, ctx)
finally: finally:
...@@ -2346,7 +2347,7 @@ def p_code(s, level=None): ...@@ -2346,7 +2347,7 @@ def p_code(s, level=None):
repr(s.sy), repr(s.systring))) repr(s.sy), repr(s.systring)))
return body return body
COMPILER_DIRECTIVE_COMMENT_RE = re.compile(r"^#\s*([a-z]+)\s*=(.*)$") COMPILER_DIRECTIVE_COMMENT_RE = re.compile(r"^#\s*cython:\s*([a-z]+)\s*=(.*)$")
def p_compiler_directive_comments(s): def p_compiler_directive_comments(s):
result = {} result = {}
......
# boundscheck = False # cython: boundscheck = False
# ignoreme = OK # cython: ignoreme = OK
# This testcase is most useful if you inspect the generated C file # This testcase is most useful if you inspect the generated C file
...@@ -17,7 +17,7 @@ def f(object[int, ndim=2] buf): ...@@ -17,7 +17,7 @@ def f(object[int, ndim=2] buf):
@cy.boundscheck(True) @cy.boundscheck(True)
def g(object[int, ndim=2] buf): def g(object[int, ndim=2] buf):
# The below line should have no meaning # The below line should have no meaning
# boundscheck = False # cython: boundscheck = False
# even if the above line doesn't follow indentation. # even if the above line doesn't follow indentation.
print buf[3, 2] # bc print buf[3, 2] # bc
......
# nonexistant = True # cython: nonexistant = True
# boundscheck = true # cython: boundscheck = true
# boundscheck = 9 # cython: boundscheck = 9
print 3 print 3
# Options should not be interpreted any longer: # Options should not be interpreted any longer:
# boundscheck = true # cython: boundscheck = true
_ERRORS = u""" _ERRORS = u"""
3:0: boundscheck directive must be set to True or False 3:0: boundscheck directive must be set to True or False
......
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