mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
C++, add support for 'extern' and 'thread_local'.
Thanks to michaeljones/breathe#243 for noticing the lack of 'extern' support.
This commit is contained in:
2
CHANGES
2
CHANGES
@@ -13,6 +13,8 @@ Translations
|
|||||||
Bugs fixed
|
Bugs fixed
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
- C++, added support for 'extern' and 'thread_local'.
|
||||||
|
|
||||||
|
|
||||||
Release 1.4 (released Mar 28, 2016)
|
Release 1.4 (released Mar 28, 2016)
|
||||||
===================================
|
===================================
|
||||||
|
|||||||
@@ -90,8 +90,13 @@ from sphinx.util.docfields import Field, GroupedField
|
|||||||
|
|
||||||
decl-specifier ->
|
decl-specifier ->
|
||||||
storage-class-specifier ->
|
storage-class-specifier ->
|
||||||
"static" (only for member_object and function_object)
|
( "static" (only for member_object and function_object)
|
||||||
| "register"
|
| "register"
|
||||||
|
| "extern" (only for member_object)
|
||||||
|
)
|
||||||
|
thread_local[opt] (only for member_object)
|
||||||
|
(it can also appear before the others)
|
||||||
|
|
||||||
| type-specifier -> trailing-type-specifier
|
| type-specifier -> trailing-type-specifier
|
||||||
| function-specifier -> "inline" | "virtual" | "explicit" (only
|
| function-specifier -> "inline" | "virtual" | "explicit" (only
|
||||||
for function_object)
|
for function_object)
|
||||||
@@ -1239,9 +1244,10 @@ class ASTParametersQualifiers(ASTBase):
|
|||||||
|
|
||||||
|
|
||||||
class ASTDeclSpecsSimple(ASTBase):
|
class ASTDeclSpecsSimple(ASTBase):
|
||||||
def __init__(self, storage, inline, virtual, explicit,
|
def __init__(self, storage, threadLocal, inline, virtual, explicit,
|
||||||
constexpr, volatile, const, friend):
|
constexpr, volatile, const, friend):
|
||||||
self.storage = storage
|
self.storage = storage
|
||||||
|
self.threadLocal = threadLocal
|
||||||
self.inline = inline
|
self.inline = inline
|
||||||
self.virtual = virtual
|
self.virtual = virtual
|
||||||
self.explicit = explicit
|
self.explicit = explicit
|
||||||
@@ -1254,6 +1260,7 @@ class ASTDeclSpecsSimple(ASTBase):
|
|||||||
if not other:
|
if not other:
|
||||||
return self
|
return self
|
||||||
return ASTDeclSpecsSimple(self.storage or other.storage,
|
return ASTDeclSpecsSimple(self.storage or other.storage,
|
||||||
|
self.threadLocal or other.threadLocal,
|
||||||
self.inline or other.inline,
|
self.inline or other.inline,
|
||||||
self.virtual or other.virtual,
|
self.virtual or other.virtual,
|
||||||
self.explicit or other.explicit,
|
self.explicit or other.explicit,
|
||||||
@@ -1266,6 +1273,8 @@ class ASTDeclSpecsSimple(ASTBase):
|
|||||||
res = []
|
res = []
|
||||||
if self.storage:
|
if self.storage:
|
||||||
res.append(self.storage)
|
res.append(self.storage)
|
||||||
|
if self.threadLocal:
|
||||||
|
res.append('thread_local')
|
||||||
if self.inline:
|
if self.inline:
|
||||||
res.append('inline')
|
res.append('inline')
|
||||||
if self.friend:
|
if self.friend:
|
||||||
@@ -1289,6 +1298,8 @@ class ASTDeclSpecsSimple(ASTBase):
|
|||||||
modifiers.append(addnodes.desc_annotation(text, text))
|
modifiers.append(addnodes.desc_annotation(text, text))
|
||||||
if self.storage:
|
if self.storage:
|
||||||
_add(modifiers, self.storage)
|
_add(modifiers, self.storage)
|
||||||
|
if self.threadLocal:
|
||||||
|
_add(modifiers, 'thread_local')
|
||||||
if self.inline:
|
if self.inline:
|
||||||
_add(modifiers, 'inline')
|
_add(modifiers, 'inline')
|
||||||
if self.friend:
|
if self.friend:
|
||||||
@@ -3039,6 +3050,7 @@ class DefinitionParser(object):
|
|||||||
def _parse_decl_specs_simple(self, outer, typed):
|
def _parse_decl_specs_simple(self, outer, typed):
|
||||||
"""Just parse the simple ones."""
|
"""Just parse the simple ones."""
|
||||||
storage = None
|
storage = None
|
||||||
|
threadLocal = None
|
||||||
inline = None
|
inline = None
|
||||||
virtual = None
|
virtual = None
|
||||||
explicit = None
|
explicit = None
|
||||||
@@ -3057,9 +3069,16 @@ class DefinitionParser(object):
|
|||||||
if self.skip_word('mutable'):
|
if self.skip_word('mutable'):
|
||||||
storage = 'mutable'
|
storage = 'mutable'
|
||||||
continue
|
continue
|
||||||
|
if self.skip_word('extern'):
|
||||||
|
storage = 'extern'
|
||||||
|
continue
|
||||||
if self.skip_word('register'):
|
if self.skip_word('register'):
|
||||||
storage = 'register'
|
storage = 'register'
|
||||||
continue
|
continue
|
||||||
|
if not threadLocal and outer == 'member':
|
||||||
|
threadLocal = self.skip_word('thread_local')
|
||||||
|
if threadLocal:
|
||||||
|
continue
|
||||||
|
|
||||||
if outer == 'function':
|
if outer == 'function':
|
||||||
# function-specifiers
|
# function-specifiers
|
||||||
@@ -3093,8 +3112,8 @@ class DefinitionParser(object):
|
|||||||
if const:
|
if const:
|
||||||
continue
|
continue
|
||||||
break
|
break
|
||||||
return ASTDeclSpecsSimple(storage, inline, virtual, explicit, constexpr,
|
return ASTDeclSpecsSimple(storage, threadLocal, inline, virtual,
|
||||||
volatile, const, friend)
|
explicit, constexpr, volatile, const, friend)
|
||||||
|
|
||||||
def _parse_decl_specs(self, outer, typed=True):
|
def _parse_decl_specs(self, outer, typed=True):
|
||||||
if outer:
|
if outer:
|
||||||
|
|||||||
@@ -145,6 +145,11 @@ def test_member_definitions():
|
|||||||
"4name", output='const std::vector<unsigned int, long> &name')
|
"4name", output='const std::vector<unsigned int, long> &name')
|
||||||
check('member', 'module::myclass foo[n]', "foo__module::myclassA", "3foo")
|
check('member', 'module::myclass foo[n]', "foo__module::myclassA", "3foo")
|
||||||
check('member', 'int *const p', 'p__iPC', '1p')
|
check('member', 'int *const p', 'p__iPC', '1p')
|
||||||
|
check('member', 'extern int myInt', 'myInt__i', '5myInt')
|
||||||
|
check('member', 'thread_local int myInt', 'myInt__i', '5myInt')
|
||||||
|
check('member', 'extern thread_local int myInt', 'myInt__i', '5myInt')
|
||||||
|
check('member', 'thread_local extern int myInt', 'myInt__i', '5myInt',
|
||||||
|
'extern thread_local int myInt')
|
||||||
|
|
||||||
|
|
||||||
def test_function_definitions():
|
def test_function_definitions():
|
||||||
|
|||||||
Reference in New Issue
Block a user