mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
long double exists.
This commit is contained in:
parent
8e4311099a
commit
71a985c06c
@ -386,11 +386,12 @@ class MemberObjDefExpr(NamedDefExpr):
|
|||||||
|
|
||||||
class FuncDefExpr(NamedDefExpr):
|
class FuncDefExpr(NamedDefExpr):
|
||||||
|
|
||||||
def __init__(self, name, visibility, static, rv, signature,
|
def __init__(self, name, visibility, static, explicit, rv,
|
||||||
const, pure_virtual):
|
signature, const, pure_virtual):
|
||||||
NamedDefExpr.__init__(self, name, visibility, static)
|
NamedDefExpr.__init__(self, name, visibility, static)
|
||||||
self.rv = rv
|
self.rv = rv
|
||||||
self.signature = signature
|
self.signature = signature
|
||||||
|
self.explicit = explicit
|
||||||
self.const = const
|
self.const = const
|
||||||
self.pure_virtual = pure_virtual
|
self.pure_virtual = pure_virtual
|
||||||
|
|
||||||
@ -404,6 +405,8 @@ class FuncDefExpr(NamedDefExpr):
|
|||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
buf = self.get_modifiers()
|
buf = self.get_modifiers()
|
||||||
|
if self.explicit:
|
||||||
|
buf.append(u'explicit')
|
||||||
if self.rv is not None:
|
if self.rv is not None:
|
||||||
buf.append(unicode(self.rv))
|
buf.append(unicode(self.rv))
|
||||||
buf.append(u'%s(%s)' % (self.name, u', '.join(
|
buf.append(u'%s(%s)' % (self.name, u', '.join(
|
||||||
@ -444,7 +447,7 @@ class DefinitionParser(object):
|
|||||||
'unsigned': set(('char', 'int', 'long')),
|
'unsigned': set(('char', 'int', 'long')),
|
||||||
'signed': set(('char', 'int', 'long')),
|
'signed': set(('char', 'int', 'long')),
|
||||||
'short': set(('int', 'short')),
|
'short': set(('int', 'short')),
|
||||||
'long': set(('int', 'long'))
|
'long': set(('int', 'long', 'double'))
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, definition):
|
def __init__(self, definition):
|
||||||
@ -755,6 +758,11 @@ class DefinitionParser(object):
|
|||||||
|
|
||||||
def parse_function(self):
|
def parse_function(self):
|
||||||
visibility, static = self._parse_visibility_static()
|
visibility, static = self._parse_visibility_static()
|
||||||
|
if self.skip_word('explicit'):
|
||||||
|
explicit = True
|
||||||
|
self.skip_ws()
|
||||||
|
else:
|
||||||
|
explicit = False
|
||||||
rv = self._parse_type()
|
rv = self._parse_type()
|
||||||
self.skip_ws()
|
self.skip_ws()
|
||||||
# some things just don't have return values
|
# some things just don't have return values
|
||||||
@ -763,7 +771,7 @@ class DefinitionParser(object):
|
|||||||
rv = None
|
rv = None
|
||||||
else:
|
else:
|
||||||
name = self._parse_type()
|
name = self._parse_type()
|
||||||
return FuncDefExpr(name, visibility, static, rv,
|
return FuncDefExpr(name, visibility, static, explicit, rv,
|
||||||
*self._parse_signature())
|
*self._parse_signature())
|
||||||
|
|
||||||
def parse_class(self):
|
def parse_class(self):
|
||||||
@ -959,6 +967,9 @@ class CPPFunctionObject(CPPObject):
|
|||||||
|
|
||||||
def describe_signature(self, signode, func):
|
def describe_signature(self, signode, func):
|
||||||
self.attach_modifiers(signode, func)
|
self.attach_modifiers(signode, func)
|
||||||
|
if func.explicit:
|
||||||
|
signode += addnodes.desc_annotation('explicit', 'explicit')
|
||||||
|
signode += nodes.Text(' ')
|
||||||
# return value is None for things with a reverse return value
|
# return value is None for things with a reverse return value
|
||||||
# such as casting operator definitions or constructors
|
# such as casting operator definitions or constructors
|
||||||
# and destructors.
|
# and destructors.
|
||||||
|
@ -34,6 +34,8 @@ def test_type_definitions():
|
|||||||
|
|
||||||
x = 'module::myclass::operator std::vector<std::string>()'
|
x = 'module::myclass::operator std::vector<std::string>()'
|
||||||
assert unicode(parse('function', x)) == x
|
assert unicode(parse('function', x)) == x
|
||||||
|
x = 'explicit module::myclass::foo::foo()'
|
||||||
|
assert unicode(parse('function', x)) == x
|
||||||
|
|
||||||
x = 'std::vector<std::pair<std::string, long long>> module::blah'
|
x = 'std::vector<std::pair<std::string, long long>> module::blah'
|
||||||
assert unicode(parse('type_object', x)) == x
|
assert unicode(parse('type_object', x)) == x
|
||||||
@ -44,3 +46,10 @@ def test_type_definitions():
|
|||||||
def test_operators():
|
def test_operators():
|
||||||
x = parse('function', 'void operator new [ ] ()')
|
x = parse('function', 'void operator new [ ] ()')
|
||||||
assert unicode(x) == 'void operator new[]()'
|
assert unicode(x) == 'void operator new[]()'
|
||||||
|
|
||||||
|
x = parse('function', 'void operator delete ()')
|
||||||
|
assert unicode(x) == 'void operator delete()'
|
||||||
|
|
||||||
|
for op in '*-+=/%!':
|
||||||
|
x = parse('function', 'void operator %s ()' % op)
|
||||||
|
assert unicode(x) == 'void operator%s()' % op
|
||||||
|
Loading…
Reference in New Issue
Block a user