This commit is contained in:
Jakob Lykke Andersen 2015-02-24 09:49:43 +01:00
parent 89c53d5a2b
commit b8e324fb2f
2 changed files with 23 additions and 4 deletions

View File

@ -527,6 +527,22 @@ class ASTTemplateArgConstant(ASTBase):
signode += nodes.Text(text_type(self)) signode += nodes.Text(text_type(self))
class ASTNestedNameElementEmpty(ASTBase):
"""Used if a nested name starts with ::"""
def get_id_v1(self):
return u''
def get_id_v2(self):
return u''
def __unicode__(self):
return u''
def describe_signature(self, signode, mode, env, prefix):
pass
class ASTNestedNameElement(ASTBase): class ASTNestedNameElement(ASTBase):
def __init__(self, identifier, templateArgs): def __init__(self, identifier, templateArgs):
self.identifier = identifier self.identifier = identifier
@ -607,8 +623,6 @@ class ASTNestedNameElement(ASTBase):
class ASTNestedName(ASTBase): class ASTNestedName(ASTBase):
def __init__(self, names): def __init__(self, names):
"""Use an empty string as the first name if it should start with '::'
"""
self.names = names self.names = names
@property @property
@ -621,7 +635,10 @@ class ASTNestedName(ASTBase):
return _id_shorthands_v1[tt] return _id_shorthands_v1[tt]
else: else:
res = [] res = []
for n in self.names: id = self.names[0].get_id_v1()
if len(id) > 0:
res.append(id)
for n in self.names[1:]:
res.append(n.get_id_v1()) res.append(n.get_id_v1())
return u'::'.join(res) return u'::'.join(res)
@ -1555,7 +1572,7 @@ class DefinitionParser(object):
self.skip_ws() self.skip_ws()
if self.skip_string('::'): if self.skip_string('::'):
names.append(u'') names.append(ASTNestedNameElementEmpty())
while 1: while 1:
self.skip_ws() self.skip_ws()
# TODO: parse the "template" keyword # TODO: parse the "template" keyword

View File

@ -133,6 +133,8 @@ def test_type_definitions():
raises(DefinitionError, parse, 'function', 'int foo(D d=x(a') raises(DefinitionError, parse, 'function', 'int foo(D d=x(a')
check('function', 'int foo(const A&... a)') check('function', 'int foo(const A&... a)')
check('function', 'virtual void f()') check('function', 'virtual void f()')
# test for ::nestedName, from issue 1738
check("function", "result(int val, ::std::error_category const &cat)")
check('class', 'public A', 'A') check('class', 'public A', 'A')
check('class', 'private A') check('class', 'private A')