defining = self.body is not None)
self.return_type = type.return_type
- if 'overrideable' in self.modifiers or 'visible' in self.modifiers:
- if 'visible' in self.modifiers:
- self.modifiers.remove('visible')
+ if self.overridable:
import ExprNodes
arg_names = [arg.name for arg in self.type.args]
self_arg = ExprNodes.NameNode(self.pos, name=arg_names[0])
env.entries[name] = self.entry
if Options.intern_names:
self.py_func.interned_attr_cname = env.intern(self.py_func.entry.name)
- if 'overrideable' in self.modifiers:
- self.modifiers.remove('overrideable')
- self.override = OverrideCheckNode(self.pos, py_func = self.py_func)
- self.body.stats.insert(0, self.override)
+ self.override = OverrideCheckNode(self.pos, py_func = self.py_func)
+ self.body.stats.insert(0, self.override)
def declare_arguments(self, env):
return p_ctypedef_statement(s, level, visibility)
if s.sy == 'cdef':
cdef_flag = 1
+ overridable = 0
+ s.next()
+ if s.sy == 'rdef':
+ cdef_flag = 1
+ overridable = 1
s.next()
if cdef_flag:
if level not in ('module', 'module_pxd', 'function', 'c_class', 'c_class_pxd'):
s.error('cdef statement not allowed here')
- return p_cdef_statement(s, level, visibility)
+ return p_cdef_statement(s, level, visibility, overridable = overridable)
+# elif s.sy == 'rdef':
+# s.next()
+# return p_c_func_or_var_declaration(s, level, s.position(), visibility = visibility, overridable = True)
elif s.sy == 'def':
if level not in ('module', 'class', 'c_class', 'property'):
s.error('def statement not allowed here')
default = default,
kw_only = kw_only)
-def p_cdef_statement(s, level, visibility = 'private'):
+def p_cdef_statement(s, level, visibility = 'private', overridable = False):
pos = s.position()
+ if overridable and level not in ('c_class', 'c_class_pxd'):
+ error(pos, "Overridable cdef function not allowed here")
visibility = p_visibility(s, visibility)
if visibility == 'extern' and s.sy in ('from' ,':'):
return p_cdef_extern_block(s, level, pos)
s.expect_newline('Expected a newline')
return node
else:
- return p_c_func_or_var_declaration(s, level, pos, visibility)
+ return p_c_func_or_var_declaration(s, level, pos, visibility, overridable)
def p_cdef_extern_block(s, level, pos):
include_file = None
return visibility
def p_c_modifiers(s):
- if s.sy == 'IDENT' and s.systring in ('inline', 'visible', 'overrideable'):
+ if s.sy == 'IDENT' and s.systring in ('inline',):
modifier = s.systring
s.next()
return [modifier] + p_c_modifiers(s)
return []
-def p_c_func_or_var_declaration(s, level, pos, visibility = 'private'):
+def p_c_func_or_var_declaration(s, level, pos, visibility = 'private', overridable = False):
cmethod_flag = level in ('c_class', 'c_class_pxd')
modifiers = p_c_modifiers(s)
base_type = p_c_base_type(s)
base_type = base_type,
declarator = declarator,
body = suite,
- modifiers = modifiers)
+ modifiers = modifiers,
+ overridable = overridable)
else:
if level == 'module_pxd' and visibility <> 'extern':
error(pos,
"raise", "import", "exec", "try", "except", "finally",
"while", "if", "elif", "else", "for", "in", "assert",
"and", "or", "not", "is", "in", "lambda", "from",
- "NULL", "cimport", "by", "with"
+ "NULL", "cimport", "by", "with", "rdef"
]
function_contexts = [ # allowed arguments to the "with" option