if cdef_flag:
if level not in ('module', 'module_pxd', 'function', 'c_class', 'c_class_pxd'):
s.error('cdef statement not allowed here')
+ s.level = level
return p_cdef_statement(s, level, visibility = visibility,
api = api, overridable = overridable)
# elif s.sy == 'cpdef':
elif s.sy == 'def':
if level not in ('module', 'class', 'c_class', 'property'):
s.error('def statement not allowed here')
+ s.level = level
return p_def_statement(s)
elif s.sy == 'class':
if level <> 'module':
not_none = 1
if s.sy == '=':
s.next()
- default = p_simple_expr(s)
+ if 'pxd' in s.level:
+ if s.sy not in ['*', '?']:
+ error(pos, "default values cannot be specified in pxd files, use ? or *")
+ default = 1
+ s.next()
+ else:
+ default = p_simple_expr(s)
return Nodes.CArgDeclNode(pos,
base_type = base_type,
declarator = declarator,
def p_cdef_statement(s, level, visibility = 'private', api = 0,
overridable = False):
pos = s.position()
-# if overridable and level not in ('c_class', 'c_class_pxd'):
-# error(pos, "Overridable cdef function not allowed here")
+ if overridable and level not in ('c_class', 'c_class_pxd'):
+ error(pos, "Overridable cdef function not allowed here")
visibility = p_visibility(s, visibility)
api = api or p_api(s)
if api: