mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
C++, fix parsing of signed/unsigned char.
This commit is contained in:
1
CHANGES
1
CHANGES
@@ -64,6 +64,7 @@ Bugs fixed
|
||||
* #1994: More supporting non-standard parser (like recommonmark parser) for Translation and
|
||||
WebSupport feature. Now node.rawsource is fall backed to node.astext() during docutils
|
||||
transforming.
|
||||
* C++, fix parsing of 'signed char' and 'unsigned char' as types.
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
@@ -2575,7 +2575,6 @@ class DefinitionParser(object):
|
||||
|
||||
# TODO: this could/should be more strict
|
||||
elements = []
|
||||
self.skip_ws()
|
||||
if self.skip_word_and_ws('signed'):
|
||||
elements.append('signed')
|
||||
elif self.skip_word_and_ws('unsigned'):
|
||||
@@ -2587,7 +2586,9 @@ class DefinitionParser(object):
|
||||
elements.append('long')
|
||||
else:
|
||||
break
|
||||
if self.skip_word_and_ws('int'):
|
||||
if self.skip_word_and_ws('char'):
|
||||
elements.append('char')
|
||||
elif self.skip_word_and_ws('int'):
|
||||
elements.append('int')
|
||||
elif self.skip_word_and_ws('double'):
|
||||
elements.append('double')
|
||||
|
||||
@@ -15,6 +15,7 @@ from util import raises
|
||||
|
||||
from sphinx.domains.cpp import DefinitionParser, DefinitionError, NoOldIdError
|
||||
from sphinx.domains.cpp import Symbol
|
||||
import sphinx.domains.cpp as cppDomain
|
||||
|
||||
ids = []
|
||||
|
||||
@@ -236,6 +237,27 @@ def test_type_definitions():
|
||||
None, "1A")
|
||||
|
||||
|
||||
def test_fundamental_types():
|
||||
# see http://en.cppreference.com/w/cpp/language/types
|
||||
for t, id_v2 in cppDomain._id_fundamental_v2.items():
|
||||
if t == "decltype(auto)":
|
||||
continue
|
||||
|
||||
def makeIdV1():
|
||||
id = t.replace(" ", "-").replace("long", "l").replace("int", "i")
|
||||
id = id.replace("bool", "b").replace("char", "c")
|
||||
id = id.replace("wc_t", "wchar_t").replace("c16_t", "char16_t")
|
||||
id = id.replace("c32_t", "char32_t")
|
||||
return "f__%s" % id
|
||||
|
||||
def makeIdV2():
|
||||
id = id_v2
|
||||
if t == "std::nullptr_t":
|
||||
id = "NSt9nullptr_tE"
|
||||
return "1f%s" % id
|
||||
check("function", "void f(%s arg)" % t, makeIdV1(), makeIdV2())
|
||||
|
||||
|
||||
def test_templates():
|
||||
check('class', "A<T>", None, "IE1AI1TE", output="template<> A<T>")
|
||||
# first just check which objects support templating
|
||||
|
||||
Reference in New Issue
Block a user