mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
C++, add support for user-defined literals
This commit is contained in:
parent
c823ffbcf1
commit
1021f4cdd7
1
CHANGES
1
CHANGES
@ -70,6 +70,7 @@ Bugs fixed
|
||||
* C++, add support for final classes.
|
||||
* C++, fix parsing of types prefixed with 'enum'.
|
||||
* #2023: Dutch search support uses Danish stemming info
|
||||
* C++, add support for user-defined literals.
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
@ -821,6 +821,31 @@ class ASTOperatorType(ASTBase):
|
||||
signode += addnodes.desc_addname(identifier, identifier)
|
||||
|
||||
|
||||
class ASTOperatorLiteral(ASTBase):
|
||||
def __init__(self, identifier):
|
||||
self.identifier = identifier
|
||||
|
||||
def is_operator(self):
|
||||
return True
|
||||
|
||||
def get_id_v1(self):
|
||||
raise NoOldIdError()
|
||||
|
||||
def get_id_v2(self):
|
||||
return u'li' + self.identifier.get_id_v2()
|
||||
|
||||
def __unicode__(self):
|
||||
return u'operator""' + text_type(self.identifier)
|
||||
|
||||
def describe_signature(self, signode, mode, env, prefix, symbol):
|
||||
_verify_description_mode(mode)
|
||||
identifier = text_type(self)
|
||||
if mode == 'lastIsName':
|
||||
signode += addnodes.desc_name(identifier, identifier)
|
||||
else:
|
||||
signode += addnodes.desc_addname(identifier, identifier)
|
||||
|
||||
|
||||
class ASTTemplateArgConstant(ASTBase):
|
||||
def __init__(self, value):
|
||||
self.value = value
|
||||
@ -2525,6 +2550,14 @@ class DefinitionParser(object):
|
||||
op += '[]'
|
||||
return ASTOperatorBuildIn(op)
|
||||
|
||||
# user-defined literal?
|
||||
if self.skip_string('""'):
|
||||
self.skip_ws()
|
||||
if not self.match(_identifier_re):
|
||||
self.fail("Expected user-defined literal suffix.")
|
||||
identifier = ASTIdentifier(self.matched_text)
|
||||
return ASTOperatorLiteral(identifier)
|
||||
|
||||
# oh well, looks like a cast operator definition.
|
||||
# In that case, eat another type.
|
||||
type = self._parse_type(named=False, outer="operatorCast")
|
||||
|
@ -347,6 +347,9 @@ def test_operators():
|
||||
check('function', 'void operator ! ()',
|
||||
"not-operator", "ntv", output='void operator!()')
|
||||
|
||||
check('function', 'void operator "" _udl()',
|
||||
None, 'li4_udlv', output='void operator""_udl()')
|
||||
|
||||
#def test_print():
|
||||
# # used for getting all the ids out for checking
|
||||
# for a in ids:
|
||||
|
Loading…
Reference in New Issue
Block a user