cname = ctx.namespace + "::" + class_name
if s.sy == '.':
error(pos, "Qualified class name not allowed C++ class")
- templates = None
if s.sy == '[':
s.next()
- templates = []
- templates.append(s.systring)
- s.next()
+ templates = [p_ident(s)]
while s.sy == ',':
s.next()
- templates.append(s.systring)
- s.next()
+ templates.append(p_ident(s))
s.expect(']')
- base_classes = []
+ else:
+ templates = None
if s.sy == '(':
- base_class = True
- while (base_class):
+ s.next()
+ base_classes = [p_dotted_name(s, False)[2]]
+ while s.sy == ',':
s.next()
- base_class_path = [p_ident(s)]
- base_class = False
- while s.sy == '.':
- s.next()
- base_class_path.append(p_ident(s))
- base_classes.append(base_class_path)
- if s.sy == ',':
- base_class = True
- base_class_path = []
+ base_classes.append(p_dotted_name(s, False)[2])
s.expect(')')
- base_classes = [".".join(path) for path in base_classes]
+ else:
+ base_classes = []
if s.sy == '[':
error(s.position(), "Name options not allowed for C++ class")
if s.sy == ':':
if visibility == 'extern':
warning(pos, "'%s' redeclared " % name, 0)
elif visibility != 'ignore':
- pass
- #error(pos, "'%s' redeclared " % name)
+ error(pos, "'%s' redeclared " % name)
entry = Entry(name, cname, type, pos = pos)
entry.in_cinclude = self.in_cinclude
if name:
if visibility != 'private' and visibility != entry.visibility:
warning(pos, "Function '%s' previously declared as '%s'" % (name, entry.visibility), 1)
if not entry.type.same_as(type):
- #if visibility == 'extern' and entry.visibility == 'extern':
- #warning(pos, "Function signature does not match previous declaration", 1)
- #entry.type = type
- temp = self.add_cfunction(name, type, pos, cname, visibility, modifiers)
- entry.overloaded_alternatives.append(temp)
- entry = temp
- #else:
- #error(pos, "Function signature does not match previous declaration")
+ if visibility == 'extern' and entry.visibility == 'extern':
+ if self.is_cpp():
+ temp = self.add_cfunction(name, type, pos, cname, visibility, modifiers)
+ entry.overloaded_alternatives.append(temp)
+ entry = temp
+ else:
+ warning(pos, "Function signature does not match previous declaration", 1)
+ entry.type = type
+ else:
+ error(pos, "Function signature does not match previous declaration")
else:
entry = self.add_cfunction(name, type, pos, cname, visibility, modifiers)
entry.func_cname = cname
entry.is_implemented = True
if modifiers:
entry.func_modifiers = modifiers
- #try:
- # print entry.name, entry.type, entry.overloaded_alternatives
- #except:
- # pass
- #if len(entry.overloaded_alternatives) > 0:
- # print entry.name, entry.type, entry.overloaded_alternatives[0].type
return entry
def add_cfunction(self, name, type, pos, cname, visibility, modifiers):