C++, yet more code cleanup

This commit is contained in:
Jakob Lykke Andersen 2015-09-06 16:08:37 +02:00
parent 45a8169184
commit 38db131ee9
2 changed files with 11 additions and 11 deletions

View File

@ -1867,10 +1867,6 @@ class ASTClass(ASTBase):
def get_id_v1(self, objectType, symbol): def get_id_v1(self, objectType, symbol):
return symbol.get_full_nested_name().get_id_v1() return symbol.get_full_nested_name().get_id_v1()
#name = _id_shortwords.get(self.name)
#if name is not None:
# return name
#return self.name.replace(u' ', u'-')
def get_id_v2(self, objectType, symbol): def get_id_v2(self, objectType, symbol):
return symbol.get_full_nested_name().get_id_v2() return symbol.get_full_nested_name().get_id_v2()
@ -3272,7 +3268,7 @@ class CPPObject(ObjectDescription):
names[name] = ast.symbol.docname names[name] = ast.symbol.docname
signode['names'].append(name) signode['names'].append(name)
else: else:
#print("[CPP] non-unique name:", name) # print("[CPP] non-unique name:", name)
pass pass
for id in ids: for id in ids:
if id: # is None when the element didn't exist in that version if id: # is None when the element didn't exist in that version
@ -3524,10 +3520,10 @@ class CPPDomain(Domain):
def process_doc(self, env, docname, document): def process_doc(self, env, docname, document):
# just for debugging # just for debugging
#print(self.data['rootSymbol'].dump(0)) # print(self.data['rootSymbol'].dump(0))
pass pass
#def merge_domaindata(self, docnames, otherdata): # def merge_domaindata(self, docnames, otherdata):
# # TODO: merge rootSymbol # # TODO: merge rootSymbol
def _resolve_xref_inner(self, env, fromdocname, builder, def _resolve_xref_inner(self, env, fromdocname, builder,

View File

@ -18,6 +18,7 @@ from sphinx.domains.cpp import Symbol
ids = [] ids = []
def parse(name, string): def parse(name, string):
parser = DefinitionParser(string, None) parser = DefinitionParser(string, None)
ast = parser.parse_declaration(name) ast = parser.parse_declaration(name)
@ -31,6 +32,7 @@ def parse(name, string):
ast.scoped = None # simulate unscoped enum ast.scoped = None # simulate unscoped enum
return ast return ast
def check(name, input, idv1output=None, idv2output=None, output=None): def check(name, input, idv1output=None, idv2output=None, output=None):
# first a simple check of the AST # first a simple check of the AST
if output is None: if output is None:
@ -50,12 +52,12 @@ def check(name, input, idv1output=None, idv2output=None, output=None):
idv2output = "_CPPv2" + idv2output idv2output = "_CPPv2" + idv2output
try: try:
idv1 = ast.get_id_v1() idv1 = ast.get_id_v1()
assert idv1 != None assert idv1 is not None
except NoOldIdError: except NoOldIdError:
idv1 = None idv1 = None
try: try:
idv2 = ast.get_id_v2() idv2 = ast.get_id_v2()
assert idv2 != None assert idv2 is not None
except NoOldIdError: except NoOldIdError:
idv2 = None idv2 = None
if idv1 != idv1output or idv2 != idv2output: if idv1 != idv1output or idv2 != idv2output:
@ -69,6 +71,7 @@ def check(name, input, idv1output=None, idv2output=None, output=None):
ids.append(ast.get_id_v2()) ids.append(ast.get_id_v2())
#print ".. %s:: %s" % (name, input) #print ".. %s:: %s" % (name, input)
def test_type_definitions(): def test_type_definitions():
check("type", "public bool b", "b", "1b", "bool b") check("type", "public bool b", "b", "1b", "bool b")
check("type", "bool A::b", "A::b", "N1A1bE") check("type", "bool A::b", "A::b", "N1A1bE")
@ -88,7 +91,7 @@ def test_type_definitions():
check("type", "std::function<R(A1, A2, A3)> F", "F", "1F") check("type", "std::function<R(A1, A2, A3)> F", "F", "1F")
check("type", "std::function<R(A1, A2, A3, As...)> F", "F", "1F") check("type", "std::function<R(A1, A2, A3, As...)> F", "F", "1F")
check("type", "MyContainer::const_iterator", check("type", "MyContainer::const_iterator",
"MyContainer::const_iterator","N11MyContainer14const_iteratorE") "MyContainer::const_iterator", "N11MyContainer14const_iteratorE")
check("type", check("type",
"public MyContainer::const_iterator", "public MyContainer::const_iterator",
"MyContainer::const_iterator", "N11MyContainer14const_iteratorE", "MyContainer::const_iterator", "N11MyContainer14const_iteratorE",
@ -231,6 +234,7 @@ def test_type_definitions():
check('enumerator', 'A = std::numeric_limits<unsigned long>::max()', check('enumerator', 'A = std::numeric_limits<unsigned long>::max()',
None, "1A") None, "1A")
def test_templates(): def test_templates():
check('class', "A<T>", None, "IE1AI1TE", output="template<> A<T>") check('class', "A<T>", None, "IE1AI1TE", output="template<> A<T>")
# first just check which objects support templating # first just check which objects support templating