mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
C++, turn on version 3 mangling
This commit is contained in:
@@ -327,8 +327,8 @@ _keywords = [
|
||||
'while', 'xor', 'xor_eq'
|
||||
]
|
||||
|
||||
_max_id = 2
|
||||
_id_prefix = [None, '', '_CPPv2']
|
||||
_max_id = 3
|
||||
_id_prefix = [None, '', '_CPPv2', '_CPPv3']
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Id v1 constants
|
||||
@@ -719,7 +719,7 @@ class ASTPointerLiteral(ASTBase):
|
||||
def __unicode__(self):
|
||||
return u'nullptr'
|
||||
|
||||
def get_id_v2(self):
|
||||
def get_id(self, version):
|
||||
return 'LDnE'
|
||||
|
||||
def describe_signature(self, signode, mode, env, symbol):
|
||||
@@ -736,7 +736,7 @@ class ASTBooleanLiteral(ASTBase):
|
||||
else:
|
||||
return u'false'
|
||||
|
||||
def get_id_v2(self):
|
||||
def get_id(self, version):
|
||||
if self.value:
|
||||
return 'L1E'
|
||||
else:
|
||||
@@ -754,7 +754,7 @@ class ASTNumberLiteral(ASTBase):
|
||||
def __unicode__(self):
|
||||
return self.data
|
||||
|
||||
def get_id_v2(self):
|
||||
def get_id(self, version):
|
||||
return "L%sE" % self.data
|
||||
|
||||
def describe_signature(self, signode, mode, env, symbol):
|
||||
@@ -770,7 +770,7 @@ class ASTStringLiteral(ASTBase):
|
||||
def __unicode__(self):
|
||||
return self.data
|
||||
|
||||
def get_id_v2(self):
|
||||
def get_id(self, version):
|
||||
# note: the length is not really correct with escaping
|
||||
return "LA%d_KcE" % (len(self.data) - 2)
|
||||
|
||||
@@ -786,8 +786,8 @@ class ASTParenExpr(ASTBase):
|
||||
def __unicode__(self):
|
||||
return '(' + text_type(self.expr) + ')'
|
||||
|
||||
def get_id_v2(self):
|
||||
return self.expr.get_id_v2()
|
||||
def get_id(self, version):
|
||||
return self.expr.get_id(version)
|
||||
|
||||
def describe_signature(self, signode, mode, env, symbol):
|
||||
signode.append(nodes.Text('(', '('))
|
||||
@@ -818,9 +818,12 @@ class ASTFoldExpr(ASTBase):
|
||||
res.append(')')
|
||||
return u''.join(res)
|
||||
|
||||
def get_id_v2(self):
|
||||
def get_id(self, version):
|
||||
assert version >= 3
|
||||
if version == 3:
|
||||
return text_type(self)
|
||||
# TODO: find the right mangling scheme
|
||||
return text_type(self)
|
||||
assert False
|
||||
|
||||
def describe_signature(self, signode, mode, env, symbol):
|
||||
signode.append(nodes.Text('('))
|
||||
@@ -855,12 +858,13 @@ class ASTBinOpExpr(ASTBase):
|
||||
res.append(text_type(self.exprs[i]))
|
||||
return u''.join(res)
|
||||
|
||||
def get_id_v2(self):
|
||||
def get_id(self, version):
|
||||
assert version >= 2
|
||||
res = []
|
||||
for i in range(len(self.ops)):
|
||||
res.append(_id_operator_v2[self.ops[i]])
|
||||
res.append(self.exprs[i].get_id_v2())
|
||||
res.append(self.exprs[-1].get_id_v2())
|
||||
res.append(self.exprs[i].get_id(version))
|
||||
res.append(self.exprs[-1].get_id(version))
|
||||
return u''.join(res)
|
||||
|
||||
def describe_signature(self, signode, mode, env, symbol):
|
||||
@@ -936,8 +940,8 @@ class ASTUnaryOpExpr(ASTBase):
|
||||
def __unicode__(self):
|
||||
return text_type(self.op) + text_type(self.expr)
|
||||
|
||||
def get_id_v2(self):
|
||||
return _id_operator_unary_v2[self.op] + self.expr.get_id_v2()
|
||||
def get_id(self, version):
|
||||
return _id_operator_unary_v2[self.op] + self.expr.get_id(version)
|
||||
|
||||
def describe_signature(self, signode, mode, env, symbol):
|
||||
signode.append(nodes.Text(self.op))
|
||||
@@ -959,10 +963,10 @@ class ASTPostfixCallExpr(ASTBase):
|
||||
res.append(')')
|
||||
return u''.join(res)
|
||||
|
||||
def get_id_v2(self, idPrefix):
|
||||
def get_id(self, idPrefix, version):
|
||||
res = ['cl', idPrefix]
|
||||
for e in self.exprs:
|
||||
res.append(e.get_id_v2())
|
||||
res.append(e.get_id(version))
|
||||
res.append('E')
|
||||
return u''.join(res)
|
||||
|
||||
@@ -984,8 +988,8 @@ class ASTPostfixArray(ASTBase):
|
||||
def __unicode__(self):
|
||||
return u'[' + text_type(self.expr) + ']'
|
||||
|
||||
def get_id_v2(self, idPrefix):
|
||||
return 'ix' + idPrefix + self.expr.get_id_v2()
|
||||
def get_id(self, idPrefix, version):
|
||||
return 'ix' + idPrefix + self.expr.get_id(version)
|
||||
|
||||
def describe_signature(self, signode, mode, env, symbol):
|
||||
signode.append(nodes.Text('['))
|
||||
@@ -1057,10 +1061,10 @@ class ASTPostfixExpr(ASTBase):
|
||||
res.append(text_type(p))
|
||||
return u''.join(res)
|
||||
|
||||
def get_id_v2(self):
|
||||
id = self.prefix.get_id_v2()
|
||||
def get_id(self, version):
|
||||
id = self.prefix.get_id(version)
|
||||
for p in self.postFixes:
|
||||
id = p.get_id_v2(id)
|
||||
id = p.get_id(id, version)
|
||||
return id
|
||||
|
||||
def describe_signature(self, signode, mode, env, symbol):
|
||||
@@ -1591,7 +1595,7 @@ class ASTTemplateArgConstant(ASTBase):
|
||||
return text_type(self).replace(u' ', u'-')
|
||||
if version == 2:
|
||||
return u'X' + text_type(self) + u'E'
|
||||
return u'X' + self.value.get_id_v2() + u'E'
|
||||
return u'X' + self.value.get_id(version) + u'E'
|
||||
|
||||
def describe_signature(self, signode, mode, env, symbol):
|
||||
# type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None
|
||||
@@ -2157,7 +2161,7 @@ class ASTArray(ASTBase):
|
||||
else:
|
||||
return u'A_'
|
||||
if self.size:
|
||||
return u'A' + self.size.get_id_v2() + u'_'
|
||||
return u'A' + self.size.get_id(version) + u'_'
|
||||
else:
|
||||
return u'A_'
|
||||
|
||||
|
||||
@@ -184,7 +184,7 @@ def test_expressions():
|
||||
exprCheck('A < 42', 'lt1AL42E')
|
||||
check('function', 'template<> void f(A<B, 2> &v)',
|
||||
{2:"IE1fR1AI1BX2EE", 3:"IE1fR1AI1BXL2EEE"})
|
||||
exprCheck('A<1>::value', {2:'N1AIXL1EEE5valueE'})
|
||||
exprCheck('A<1>::value', 'N1AIXL1EEE5valueE')
|
||||
check('class', "template<int T = 42> A", {2:"I_iE1A"})
|
||||
check('enumerator', 'A = std::numeric_limits<unsigned long>::max()', {2:"1A"})
|
||||
|
||||
@@ -293,11 +293,13 @@ def test_function_definitions():
|
||||
check('function',
|
||||
'void operator()(const boost::array<VertexID, 2> &v) const',
|
||||
{1:"call-operator__boost::array:VertexID.2:CRC",
|
||||
2:"NKclERKN5boost5arrayI8VertexIDX2EEE"})
|
||||
2:"NKclERKN5boost5arrayI8VertexIDX2EEE",
|
||||
3:"NKclERKN5boost5arrayI8VertexIDXL2EEEE"})
|
||||
check('function',
|
||||
'void operator()(const boost::array<VertexID, 2, "foo, bar"> &v) const',
|
||||
{1:'call-operator__boost::array:VertexID.2."foo,--bar":CRC',
|
||||
2:'NKclERKN5boost5arrayI8VertexIDX2EX"foo, bar"EEE'})
|
||||
2:'NKclERKN5boost5arrayI8VertexIDX2EX"foo, bar"EEE',
|
||||
3:'NKclERKN5boost5arrayI8VertexIDXL2EEXLA9_KcEEEE'})
|
||||
check('function', 'MyClass::MyClass(MyClass::MyClass&&)',
|
||||
{1:"MyClass::MyClass__MyClass::MyClassRR",
|
||||
2:"N7MyClass7MyClassERRN7MyClass7MyClassE"})
|
||||
@@ -340,7 +342,8 @@ def test_function_definitions():
|
||||
x = 'std::vector<std::pair<std::string, int>> &module::test(register int ' \
|
||||
'foo, bar[n], std::string baz = "foobar, blah, bleh") const = 0'
|
||||
check('function', x, {1:"module::test__i.barA.ssC",
|
||||
2:"NK6module4testEiAn_3barNSt6stringE"})
|
||||
2:"NK6module4testEiAn_3barNSt6stringE",
|
||||
3:"NK6module4testEiA1n_3barNSt6stringE"})
|
||||
check('function',
|
||||
'int foo(Foo f = Foo(double(), std::make_pair(int(2), double(3.4))))',
|
||||
{1:"foo__Foo", 2:"3foo3Foo"})
|
||||
@@ -358,8 +361,8 @@ def test_function_definitions():
|
||||
{1:"result__i.std::error_categoryCR", 2:"6resultiRNSt14error_categoryE"})
|
||||
check("function", "int *f()", {1:"f", 2:"1fv"})
|
||||
# tests derived from issue #1753 (skip to keep sanity)
|
||||
check("function", "f(int (&array)[10])", {2:"1fRA10_i"})
|
||||
check("function", "void f(int (&array)[10])", {2:"1fRA10_i"})
|
||||
check("function", "f(int (&array)[10])", {2:"1fRA10_i", 3:"1fRAL10E_i"})
|
||||
check("function", "void f(int (&array)[10])", {2:"1fRA10_i", 3:"1fRAL10E_i"})
|
||||
check("function", "void f(float *q(double))", {2:"1fFPfdE"})
|
||||
check("function", "void f(float *(*q)(double))", {2:"1fPFPfdE"})
|
||||
check("function", "void f(float (*q)(double))", {2:"1fPFfdE"})
|
||||
@@ -539,7 +542,8 @@ def test_template_args():
|
||||
check('function',
|
||||
"template<typename F> "
|
||||
"void allow(F *f, typename func<F, B, G != 1>::type tt)",
|
||||
{2:"I0E5allowP1FN4funcI1F1BXG != 1EE4typeE"})
|
||||
{2:"I0E5allowP1FN4funcI1F1BXG != 1EE4typeE",
|
||||
3:"I0E5allowP1FN4funcI1F1BXne1GL1EEE4typeE"})
|
||||
# from #3542
|
||||
check('type', "template<typename T> "
|
||||
"enable_if_not_array_t = std::enable_if_t<!is_array<T>::value, int>",
|
||||
|
||||
Reference in New Issue
Block a user