diff options
Diffstat (limited to 'sphinx/domains/cpp.py')
-rw-r--r-- | sphinx/domains/cpp.py | 678 |
1 files changed, 338 insertions, 340 deletions
diff --git a/sphinx/domains/cpp.py b/sphinx/domains/cpp.py index 262d3f6d7..8269258b9 100644 --- a/sphinx/domains/cpp.py +++ b/sphinx/domains/cpp.py @@ -36,7 +36,6 @@ if False: from sphinx.builders import Builder # NOQA from sphinx.config import Config # NOQA from sphinx.environment import BuildEnvironment # NOQA - from sphinx.util.typing import unicode # NOQA logger = logging.getLogger(__name__) @@ -372,7 +371,7 @@ _id_fundamental_v1 = { 'signed long': 'l', 'unsigned long': 'L', 'bool': 'b' -} # type: Dict[unicode, unicode] +} _id_shorthands_v1 = { 'std::string': 'ss', 'std::ostream': 'os', @@ -380,7 +379,7 @@ _id_shorthands_v1 = { 'std::iostream': 'ios', 'std::vector': 'v', 'std::map': 'm' -} # type: Dict[unicode, unicode] +} _id_operator_v1 = { 'new': 'new-operator', 'new[]': 'new-array-operator', @@ -429,7 +428,7 @@ _id_operator_v1 = { '->': 'pointer-operator', '()': 'call-operator', '[]': 'subscript-operator' -} # type: Dict[unicode, unicode] +} # ------------------------------------------------------------------------------ # Id v > 1 constants @@ -474,7 +473,7 @@ _id_fundamental_v2 = { 'auto': 'Da', 'decltype(auto)': 'Dc', 'std::nullptr_t': 'Dn' -} # type: Dict[unicode, unicode] +} _id_operator_v2 = { 'new': 'nw', 'new[]': 'na', @@ -525,7 +524,7 @@ _id_operator_v2 = { '()': 'cl', '[]': 'ix', '.*': 'ds' # this one is not overloadable, but we need it for expressions -} # type: Dict[unicode, unicode] +} _id_operator_unary_v2 = { '++': 'pp_', '--': 'mm_', @@ -539,7 +538,7 @@ _id_operator_unary_v2 = { _id_char_from_prefix = { None: 'c', 'u8': 'c', 'u': 'Ds', 'U': 'Di', 'L': 'w' -} # type: Dict[unicode, unicode] +} # type: Dict[Any, str] # these are ordered by preceedence _expression_bin_ops = [ ['||'], @@ -568,21 +567,21 @@ _id_explicit_cast = { class NoOldIdError(UnicodeMixin, Exception): # Used to avoid implementing unneeded id generation for old id schmes. def __init__(self, description=""): - # type: (unicode) -> None + # type: (str) -> None self.description = description def __unicode__(self): - # type: () -> unicode + # type: () -> str return self.description class DefinitionError(UnicodeMixin, Exception): def __init__(self, description): - # type: (unicode) -> None + # type: (str) -> None self.description = description def __unicode__(self): - # type: () -> unicode + # type: () -> str return self.description @@ -595,7 +594,7 @@ class _DuplicateSymbolError(UnicodeMixin, Exception): self.declaration = declaration def __unicode__(self): - # type: () -> unicode + # type: () -> str return "Internal C++ duplicate symbol error:\n%s" % self.symbol.dump(0) @@ -620,15 +619,15 @@ class ASTBase(UnicodeMixin): return deepcopy(self) def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str raise NotImplementedError(repr(self)) def __unicode__(self): - # type: () -> unicode + # type: () -> str return self._stringify(lambda ast: text_type(ast)) def get_display_string(self): - # type: () -> unicode + # type: () -> str return self._stringify(lambda ast: ast.get_display_string()) def __repr__(self): @@ -637,7 +636,7 @@ class ASTBase(UnicodeMixin): def _verify_description_mode(mode): - # type: (unicode) -> None + # type: (str) -> None if mode not in ('lastIsName', 'noneIsName', 'markType', 'param'): raise Exception("Description mode '%s' is invalid." % mode) @@ -648,7 +647,7 @@ def _verify_description_mode(mode): class ASTCPPAttribute(ASTBase): def __init__(self, arg): - # type: (unicode) -> None + # type: (str) -> None self.arg = arg def _stringify(self, transform): @@ -662,13 +661,13 @@ class ASTCPPAttribute(ASTBase): class ASTGnuAttribute(ASTBase): def __init__(self, name, args): - # type: (unicode, Any) -> None + # type: (str, Any) -> None self.name = name self.args = args def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode - res = [self.name] # type: List[unicode] + # type: (Callable[[Any], str]) -> str + res = [self.name] if self.args: res.append('(') res.append(transform(self.args)) @@ -682,8 +681,8 @@ class ASTGnuAttributeList(ASTBase): self.attrs = attrs def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode - res = ['__attribute__(('] # type: List[unicode] + # type: (Callable[[Any], str]) -> str + res = ['__attribute__(('] first = True for attr in self.attrs: if not first: @@ -703,11 +702,11 @@ class ASTIdAttribute(ASTBase): """For simple attributes defined by the user.""" def __init__(self, id): - # type: (unicode) -> None + # type: (str) -> None self.id = id def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return self.id def describe_signature(self, signode): @@ -719,12 +718,12 @@ class ASTParenAttribute(ASTBase): """For paren attributes defined by the user.""" def __init__(self, id, arg): - # type: (unicode, unicode) -> None + # type: (str, str) -> None self.id = id self.arg = arg def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return self.id + '(' + self.arg + ')' def describe_signature(self, signode): @@ -739,11 +738,11 @@ class ASTParenAttribute(ASTBase): class ASTPointerLiteral(ASTBase): def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return u'nullptr' def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str return 'LDnE' def describe_signature(self, signode, mode, env, symbol): @@ -755,14 +754,14 @@ class ASTBooleanLiteral(ASTBase): self.value = value def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str if self.value: return u'true' else: return u'false' def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str if self.value: return 'L1E' else: @@ -774,15 +773,15 @@ class ASTBooleanLiteral(ASTBase): class ASTNumberLiteral(ASTBase): def __init__(self, data): - # type: (unicode) -> None + # type: (str) -> None self.data = data def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return self.data def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str return "L%sE" % self.data def describe_signature(self, signode, mode, env, symbol): @@ -797,7 +796,7 @@ class UnsupportedMultiCharacterCharLiteral(UnicodeMixin, Exception): class ASTCharLiteral(ASTBase): def __init__(self, prefix, data): - # type: (unicode, unicode) -> None + # type: (str, str) -> None self.prefix = prefix # may be None when no prefix self.data = data assert prefix in _id_char_from_prefix @@ -809,14 +808,14 @@ class ASTCharLiteral(ASTBase): raise UnsupportedMultiCharacterCharLiteral(decoded) def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str if self.prefix is None: return "'" + self.data + "'" else: return self.prefix + "'" + self.data + "'" def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str return self.type + str(self.value) def describe_signature(self, signode, mode, env, symbol): @@ -826,15 +825,15 @@ class ASTCharLiteral(ASTBase): class ASTStringLiteral(ASTBase): def __init__(self, data): - # type: (unicode) -> None + # type: (str) -> None self.data = data def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return self.data def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str # note: the length is not really correct with escaping return "LA%d_KcE" % (len(self.data) - 2) @@ -845,11 +844,11 @@ class ASTStringLiteral(ASTBase): class ASTThisLiteral(ASTBase): def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return "this" def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str return "fpT" def describe_signature(self, signode, mode, env, symbol): @@ -861,11 +860,11 @@ class ASTParenExpr(ASTBase): self.expr = expr def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return '(' + transform(self.expr) + ')' def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str return self.expr.get_id(version) def describe_signature(self, signode, mode, env, symbol): @@ -882,7 +881,7 @@ class ASTFoldExpr(ASTBase): self.rightExpr = rightExpr def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str res = [u'('] if self.leftExpr: res.append(transform(self.leftExpr)) @@ -899,7 +898,7 @@ class ASTFoldExpr(ASTBase): return u''.join(res) def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str assert version >= 3 if version == 3: return text_type(self) @@ -930,7 +929,7 @@ class ASTBinOpExpr(ASTBase): self.ops = ops def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str res = [] res.append(transform(self.exprs[0])) for i in range(1, len(self.exprs)): @@ -941,7 +940,7 @@ class ASTBinOpExpr(ASTBase): return u''.join(res) def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str assert version >= 2 res = [] for i in range(len(self.ops)): @@ -967,7 +966,7 @@ class ASTAssignmentExpr(ASTBase): self.ops = ops def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str res = [] res.append(transform(self.exprs[0])) for i in range(1, len(self.exprs)): @@ -978,7 +977,7 @@ class ASTAssignmentExpr(ASTBase): return u''.join(res) def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str res = [] for i in range(len(self.ops)): res.append(_id_operator_v2[self.ops[i]]) @@ -1001,7 +1000,7 @@ class ASTCastExpr(ASTBase): self.expr = expr def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str res = [u'('] res.append(transform(self.typ)) res.append(u')') @@ -1009,7 +1008,7 @@ class ASTCastExpr(ASTBase): return u''.join(res) def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str return 'cv' + self.typ.get_id(version) + self.expr.get_id(version) def describe_signature(self, signode, mode, env, symbol): @@ -1025,11 +1024,11 @@ class ASTUnaryOpExpr(ASTBase): self.expr = expr def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return transform(self.op) + transform(self.expr) def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str return _id_operator_unary_v2[self.op] + self.expr.get_id(version) def describe_signature(self, signode, mode, env, symbol): @@ -1042,11 +1041,11 @@ class ASTSizeofParamPack(ASTBase): self.identifier = identifier def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return "sizeof...(" + transform(self.identifier) + ")" def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str return 'sZ' + self.identifier.get_id(version) def describe_signature(self, signode, mode, env, symbol): @@ -1061,11 +1060,11 @@ class ASTSizeofType(ASTBase): self.typ = typ def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return "sizeof(" + transform(self.typ) + ")" def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str return 'st' + self.typ.get_id(version) def describe_signature(self, signode, mode, env, symbol): @@ -1079,11 +1078,11 @@ class ASTSizeofExpr(ASTBase): self.expr = expr def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return "sizeof " + transform(self.expr) def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str return 'sz' + self.expr.get_id(version) def describe_signature(self, signode, mode, env, symbol): @@ -1096,11 +1095,11 @@ class ASTAlignofExpr(ASTBase): self.typ = typ def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return "alignof(" + transform(self.typ) + ")" def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str return 'at' + self.typ.get_id(version) def describe_signature(self, signode, mode, env, symbol): @@ -1114,11 +1113,11 @@ class ASTNoexceptExpr(ASTBase): self.expr = expr def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return "noexcept(" + transform(self.expr) + ")" def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str return 'nx' + self.expr.get_id(version) def describe_signature(self, signode, mode, env, symbol): @@ -1129,7 +1128,7 @@ class ASTNoexceptExpr(ASTBase): class ASTNewExpr(ASTBase): def __init__(self, rooted, isNewTypeId, typ, initList, initType): - # type: (bool, bool, ASTType, List[Any], unicode) -> None + # type: (bool, bool, ASTType, List[Any], str) -> None self.rooted = rooted self.isNewTypeId = isNewTypeId self.typ = typ @@ -1139,8 +1138,8 @@ class ASTNewExpr(ASTBase): assert self.initType in ')}' def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode - res = [] # type: List[unicode] + # type: (Callable[[Any], str]) -> str + res = [] if self.rooted: res.append('::') res.append('new ') @@ -1162,9 +1161,9 @@ class ASTNewExpr(ASTBase): return u''.join(res) def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str # the array part will be in the type mangling, so na is not used - res = ['nw'] # type: List[unicode] + res = ['nw'] # TODO: placement res.append('_') res.append(self.typ.get_id(version)) @@ -1210,8 +1209,8 @@ class ASTDeleteExpr(ASTBase): self.expr = expr def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode - res = [] # type: List[unicode] + # type: (Callable[[Any], str]) -> str + res = [] if self.rooted: res.append('::') res.append('delete ') @@ -1221,7 +1220,7 @@ class ASTDeleteExpr(ASTBase): return u''.join(res) def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str if self.array: id = "da" else: @@ -1245,7 +1244,7 @@ class ASTExplicitCast(ASTBase): self.expr = expr def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str res = [self.cast] res.append('<') res.append(transform(self.typ)) @@ -1255,7 +1254,7 @@ class ASTExplicitCast(ASTBase): return u''.join(res) def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str return (_id_explicit_cast[self.cast] + self.typ.get_id(version) + self.expr.get_id(version)) @@ -1276,11 +1275,11 @@ class ASTTypeId(ASTBase): self.isType = isType def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return 'typeid(' + transform(self.typeOrExpr) + ')' def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str prefix = 'ti' if self.isType else 'te' return prefix + self.typeOrExpr.get_id(version) @@ -1296,7 +1295,7 @@ class ASTPostfixCallExpr(ASTBase): self.exprs = exprs def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str res = [u'('] first = True for e in self.exprs: @@ -1308,7 +1307,7 @@ class ASTPostfixCallExpr(ASTBase): return u''.join(res) def get_id(self, idPrefix, version): - # type: (unicode, int) -> unicode + # type: (str, int) -> str res = ['cl', idPrefix] for e in self.exprs: res.append(e.get_id(version)) @@ -1331,11 +1330,11 @@ class ASTPostfixArray(ASTBase): self.expr = expr def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return u'[' + transform(self.expr) + ']' def get_id(self, idPrefix, version): - # type: (unicode, int) -> unicode + # type: (str, int) -> str return 'ix' + idPrefix + self.expr.get_id(version) def describe_signature(self, signode, mode, env, symbol): @@ -1346,11 +1345,11 @@ class ASTPostfixArray(ASTBase): class ASTPostfixInc(ASTBase): def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return u'++' def get_id(self, idPrefix, version): - # type: (unicode, int) -> unicode + # type: (str, int) -> str return 'pp' + idPrefix def describe_signature(self, signode, mode, env, symbol): @@ -1359,11 +1358,11 @@ class ASTPostfixInc(ASTBase): class ASTPostfixDec(ASTBase): def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return u'--' def get_id(self, idPrefix, version): - # type: (unicode, int) -> unicode + # type: (str, int) -> str return 'mm' + idPrefix def describe_signature(self, signode, mode, env, symbol): @@ -1375,11 +1374,11 @@ class ASTPostfixMember(ASTBase): self.name = name def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return u'.' + transform(self.name) def get_id(self, idPrefix, version): - # type: (unicode, int) -> unicode + # type: (str, int) -> str return 'dt' + idPrefix + self.name.get_id(version) def describe_signature(self, signode, mode, env, symbol): @@ -1392,11 +1391,11 @@ class ASTPostfixMemberOfPointer(ASTBase): self.name = name def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return u'->' + transform(self.name) def get_id(self, idPrefix, version): - # type: (unicode, int) -> unicode + # type: (str, int) -> str return 'pt' + idPrefix + self.name.get_id(version) def describe_signature(self, signode, mode, env, symbol): @@ -1411,14 +1410,14 @@ class ASTPostfixExpr(ASTBase): self.postFixes = postFixes def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str res = [transform(self.prefix)] for p in self.postFixes: res.append(transform(p)) return u''.join(res) def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str id = self.prefix.get_id(version) for p in self.postFixes: id = p.get_id(id, version) @@ -1435,11 +1434,11 @@ class ASTPackExpansionExpr(ASTBase): self.expr = expr def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return transform(self.expr) + '...' def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str id = self.expr.get_id(version) return 'sp' + id @@ -1453,11 +1452,11 @@ class ASTFallbackExpr(ASTBase): self.expr = expr def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return self.expr def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str return text_type(self.expr) def describe_signature(self, signode, mode, env, symbol): @@ -1470,7 +1469,7 @@ class ASTFallbackExpr(ASTBase): class ASTIdentifier(ASTBase): def __init__(self, identifier): - # type: (unicode) -> None + # type: (str) -> None assert identifier is not None assert len(identifier) != 0 self.identifier = identifier @@ -1479,7 +1478,7 @@ class ASTIdentifier(ASTBase): return self.identifier[0] == '@' def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str if self.is_anon() and version < 3: raise NoOldIdError() if version == 1: @@ -1501,15 +1500,15 @@ class ASTIdentifier(ASTBase): # and this is where we finally make a difference between __unicode__ and the display string def __unicode__(self): - # type: () -> unicode + # type: () -> str return self.identifier def get_display_string(self): - # type: () -> unicode + # type: () -> str return u"[anonymous]" if self.is_anon() else self.identifier def describe_signature(self, signode, mode, env, prefix, templateArgs, symbol): - # type: (Any, unicode, BuildEnvironment, unicode, unicode, Symbol) -> None + # type: (Any, str, BuildEnvironment, str, str, Symbol) -> None _verify_description_mode(mode) if mode == 'markType': targetText = prefix + self.identifier + templateArgs @@ -1540,7 +1539,7 @@ class ASTIdentifier(ASTBase): class ASTTemplateKeyParamPackIdDefault(ASTBase): def __init__(self, key, identifier, parameterPack, default): - # type: (unicode, ASTIdentifier, bool, ASTType) -> None + # type: (str, ASTIdentifier, bool, ASTType) -> None assert key if parameterPack: assert default is None @@ -1554,7 +1553,7 @@ class ASTTemplateKeyParamPackIdDefault(ASTBase): return self.identifier def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str assert version >= 2 # this is not part of the normal name mangling in C++ res = [] @@ -1565,8 +1564,8 @@ class ASTTemplateKeyParamPackIdDefault(ASTBase): return ''.join(res) def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode - res = [self.key] # type: List[unicode] + # type: (Callable[[Any], str]) -> str + res = [self.key] if self.parameterPack: if self.identifier: res.append(' ') @@ -1581,7 +1580,7 @@ class ASTTemplateKeyParamPackIdDefault(ASTBase): return ''.join(res) def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None signode += nodes.Text(self.key) if self.parameterPack: if self.identifier: @@ -1618,7 +1617,7 @@ class ASTTemplateParamType(ASTBase): return self.data.get_identifier() def get_id(self, version, objectType=None, symbol=None): - # type: (int, unicode, Symbol) -> unicode + # type: (int, str, Symbol) -> str # this is not part of the normal name mangling in C++ assert version >= 2 if symbol: @@ -1628,11 +1627,11 @@ class ASTTemplateParamType(ASTBase): return self.data.get_id(version) def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return transform(self.data) def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None self.data.describe_signature(signode, mode, env, symbol) @@ -1654,7 +1653,7 @@ class ASTTemplateParamConstrainedTypeWithInit(ASTBase): return self.type.isPack def get_id(self, version, objectType=None, symbol=None): - # type: (int, unicode, Symbol) -> unicode + # type: (int, str, Symbol) -> str # this is not part of the normal name mangling in C++ assert version >= 2 if symbol: @@ -1664,7 +1663,7 @@ class ASTTemplateParamConstrainedTypeWithInit(ASTBase): return self.type.get_id(version) def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str res = transform(self.type) if self.init: res += " = " @@ -1672,7 +1671,7 @@ class ASTTemplateParamConstrainedTypeWithInit(ASTBase): return res def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None self.type.describe_signature(signode, mode, env, symbol) if self.init: signode += nodes.Text(" = ") @@ -1703,7 +1702,7 @@ class ASTTemplateParamTemplateType(ASTBase): return self.data.get_identifier() def get_id(self, version, objectType=None, symbol=None): - # type: (int, unicode, Symbol) -> unicode + # type: (int, str, Symbol) -> str assert version >= 2 # this is not part of the normal name mangling in C++ if symbol: @@ -1713,11 +1712,11 @@ class ASTTemplateParamTemplateType(ASTBase): return self.nestedParams.get_id(version) + self.data.get_id(version) def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return transform(self.nestedParams) + transform(self.data) def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None self.nestedParams.describe_signature(signode, 'noneIsName', env, symbol) signode += nodes.Text(' ') self.data.describe_signature(signode, mode, env, symbol) @@ -1752,7 +1751,7 @@ class ASTTemplateParamNonType(ASTBase): return None def get_id(self, version, objectType=None, symbol=None): - # type: (int, unicode, Symbol) -> unicode + # type: (int, str, Symbol) -> str assert version >= 2 # this is not part of the normal name mangling in C++ if symbol: @@ -1762,11 +1761,11 @@ class ASTTemplateParamNonType(ASTBase): return '_' + self.param.get_id(version) def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return transform(self.param) def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None self.param.describe_signature(signode, mode, env, symbol) @@ -1778,7 +1777,7 @@ class ASTTemplateParams(ASTBase): self.isNested = False # whether it's a template template param def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str assert version >= 2 res = [] res.append("I") @@ -1788,7 +1787,7 @@ class ASTTemplateParams(ASTBase): return ''.join(res) def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str res = [] res.append(u"template<") res.append(u", ".join(transform(a) for a in self.params)) @@ -1796,7 +1795,7 @@ class ASTTemplateParams(ASTBase): return ''.join(res) def describe_signature(self, parentNode, mode, env, symbol, lineSpec=None): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol, bool) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol, bool) -> None # 'lineSpec' is defaulted becuase of template template parameters def makeLine(parentNode=parentNode): signode = addnodes.desc_signature_line() @@ -1843,7 +1842,7 @@ class ASTTemplateIntroductionParameter(ASTBase): return self.identifier def get_id(self, version, objectType=None, symbol=None): - # type: (int, unicode, Symbol) -> unicode + # type: (int, str, Symbol) -> str assert version >= 2 # this is not part of the normal name mangling in C++ if symbol: @@ -1856,7 +1855,7 @@ class ASTTemplateIntroductionParameter(ASTBase): return '0' # we need to put something def get_id_as_arg(self, version): - # type: (int) -> unicode + # type: (int) -> str assert version >= 2 # used for the implicit requires clause res = self.identifier.get_id(version) @@ -1866,15 +1865,15 @@ class ASTTemplateIntroductionParameter(ASTBase): return res def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode - res = [] # type: List[unicode] + # type: (Callable[[Any], str]) -> str + res = [] if self.parameterPack: res.append('...') res.append(transform(self.identifier)) return ''.join(res) def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None if self.parameterPack: signode += nodes.Text('...') self.identifier.describe_signature(signode, mode, env, '', '', symbol) @@ -1888,7 +1887,7 @@ class ASTTemplateIntroduction(ASTBase): self.params = params def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str assert version >= 2 # first do the same as a normal template parameter list res = [] @@ -1907,7 +1906,7 @@ class ASTTemplateIntroduction(ASTBase): return ''.join(res) def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str res = [] res.append(transform(self.concept)) res.append('{') @@ -1916,7 +1915,7 @@ class ASTTemplateIntroduction(ASTBase): return ''.join(res) def describe_signature(self, parentNode, mode, env, symbol, lineSpec): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol, bool) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol, bool) -> None # Note: 'lineSpec' has no effect on template introductions. signode = addnodes.desc_signature_line() parentNode += signode @@ -1939,7 +1938,7 @@ class ASTTemplateDeclarationPrefix(ASTBase): self.templates = templates def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str assert version >= 2 # this is not part of a normal name mangling system res = [] @@ -1948,14 +1947,14 @@ class ASTTemplateDeclarationPrefix(ASTBase): return u''.join(res) def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str res = [] for t in self.templates: res.append(transform(t)) return u''.join(res) def describe_signature(self, signode, mode, env, symbol, lineSpec): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol, bool) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol, bool) -> None _verify_description_mode(mode) for t in self.templates: t.describe_signature(signode, 'lastIsName', env, symbol, lineSpec) @@ -1973,11 +1972,11 @@ class ASTOperator(ASTBase): return True def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str raise NotImplementedError() def describe_signature(self, signode, mode, env, prefix, templateArgs, symbol): - # type: (addnodes.desc_signature, unicode, Any, unicode, unicode, Symbol) -> None + # type: (addnodes.desc_signature, str, Any, str, str, Symbol) -> None _verify_description_mode(mode) identifier = text_type(self) if mode == 'lastIsName': @@ -1988,11 +1987,11 @@ class ASTOperator(ASTBase): class ASTOperatorBuildIn(ASTOperator): def __init__(self, op): - # type: (unicode) -> None + # type: (str) -> None self.op = op def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str if version == 1: ids = _id_operator_v1 else: @@ -2003,7 +2002,7 @@ class ASTOperatorBuildIn(ASTOperator): return ids[self.op] def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str if self.op in ('new', 'new[]', 'delete', 'delete[]'): return u'operator ' + self.op else: @@ -2016,18 +2015,18 @@ class ASTOperatorType(ASTOperator): self.type = type def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str if version == 1: return u'castto-%s-operator' % self.type.get_id(version) else: return u'cv' + self.type.get_id(version) def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return u''.join(['operator ', transform(self.type)]) def get_name_no_template(self): - # type: () -> unicode + # type: () -> str return text_type(self) @@ -2037,14 +2036,14 @@ class ASTOperatorLiteral(ASTOperator): self.identifier = identifier def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str if version == 1: raise NoOldIdError() else: return u'li' + self.identifier.get_id(version) def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return u'operator""' + transform(self.identifier) @@ -2057,11 +2056,11 @@ class ASTTemplateArgConstant(ASTBase): self.value = value def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return transform(self.value) def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str if version == 1: return text_type(self).replace(u' ', u'-') if version == 2: @@ -2069,7 +2068,7 @@ class ASTTemplateArgConstant(ASTBase): 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 + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None _verify_description_mode(mode) self.value.describe_signature(signode, mode, env, symbol) @@ -2081,9 +2080,9 @@ class ASTTemplateArgs(ASTBase): self.args = args def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str if version == 1: - res = [] # type: List[unicode] + res = [] res.append(':') res.append(u'.'.join(a.get_id(version) for a in self.args)) res.append(':') @@ -2097,12 +2096,12 @@ class ASTTemplateArgs(ASTBase): return u''.join(res) def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str res = ', '.join(transform(a) for a in self.args) return '<' + res + '>' def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None _verify_description_mode(mode) signode += nodes.Text('<') first = True @@ -2125,21 +2124,21 @@ class ASTNestedNameElement(ASTBase): return False def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str res = self.identOrOp.get_id(version) if self.templateArgs: res += self.templateArgs.get_id(version) return res def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str res = transform(self.identOrOp) if self.templateArgs: res += transform(self.templateArgs) return res def describe_signature(self, signode, mode, env, prefix, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, unicode, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, str, Symbol) -> None tArgs = text_type(self.templateArgs) if self.templateArgs is not None else '' self.identOrOp.describe_signature(signode, mode, env, prefix, tArgs, symbol) if self.templateArgs is not None: @@ -2171,14 +2170,14 @@ class ASTNestedName(ASTBase): return count def get_id(self, version, modifiers=''): - # type: (int, unicode) -> unicode + # type: (int, str) -> str if version == 1: tt = text_type(self) if tt in _id_shorthands_v1: return _id_shorthands_v1[tt] else: return u'::'.join(n.get_id(version) for n in self.names) - res = [] # type: List[unicode] + res = [] if len(self.names) > 1 or len(modifiers) > 0: res.append('N') res.append(modifiers) @@ -2189,8 +2188,8 @@ class ASTNestedName(ASTBase): return u''.join(res) def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode - res = [] # type: List[unicode] + # type: (Callable[[Any], str]) -> str + res = [] if self.rooted: res.append('') for i in range(len(self.names)): @@ -2203,7 +2202,7 @@ class ASTNestedName(ASTBase): return '::'.join(res) def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None _verify_description_mode(mode) # just print the name part, with template args, not template params if mode == 'noneIsName': @@ -2223,7 +2222,7 @@ class ASTNestedName(ASTBase): templateParams = symbol.declaration.templatePrefix.templates iTemplateParams = 0 templateParamsPrefix = u'' - prefix = '' # type: unicode + prefix = '' first = True names = self.names[:-1] if mode == 'lastIsName' else self.names # If lastIsName, then wrap all of the prefix in a desc_addname, @@ -2263,15 +2262,15 @@ class ASTNestedName(ASTBase): class ASTTrailingTypeSpecFundamental(ASTBase): def __init__(self, name): - # type: (unicode) -> None + # type: (str) -> None self.name = name def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return self.name def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str if version == 1: res = [] for a in self.name.split(' '): @@ -2289,13 +2288,13 @@ class ASTTrailingTypeSpecFundamental(ASTBase): return _id_fundamental_v2[self.name] def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None signode += nodes.Text(text_type(self.name)) class ASTTrailingTypeSpecName(ASTBase): def __init__(self, prefix, nestedName): - # type: (unicode, Any) -> None + # type: (str, Any) -> None self.prefix = prefix self.nestedName = nestedName @@ -2305,12 +2304,12 @@ class ASTTrailingTypeSpecName(ASTBase): return self.nestedName def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str return self.nestedName.get_id(version) def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode - res = [] # type: List[unicode] + # type: (Callable[[Any], str]) -> str + res = [] if self.prefix: res.append(self.prefix) res.append(' ') @@ -2318,7 +2317,7 @@ class ASTTrailingTypeSpecName(ASTBase): return u''.join(res) def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None if self.prefix: signode += addnodes.desc_annotation(self.prefix, self.prefix) signode += nodes.Text(' ') @@ -2327,17 +2326,17 @@ class ASTTrailingTypeSpecName(ASTBase): class ASTTrailingTypeSpecDecltypeAuto(ASTBase): def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return u'decltype(auto)' def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str if version == 1: raise NoOldIdError() return 'Dc' def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None signode.append(nodes.Text(text_type(self))) @@ -2346,17 +2345,17 @@ class ASTTrailingTypeSpecDecltype(ASTBase): self.expr = expr def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return u'decltype(' + transform(self.expr) + ')' def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str if version == 1: raise NoOldIdError() return 'DT' + self.expr.get_id(version) + "E" def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None signode.append(nodes.Text('decltype(')) self.expr.describe_signature(signode, mode, env, symbol) signode.append(nodes.Text(')')) @@ -2369,7 +2368,7 @@ class ASTFunctionParameter(ASTBase): self.ellipsis = ellipsis def get_id(self, version, objectType=None, symbol=None): - # type: (int, unicode, Symbol) -> unicode + # type: (int, str, Symbol) -> str # this is not part of the normal name mangling in C++ if symbol: # the anchor will be our parent @@ -2381,14 +2380,14 @@ class ASTFunctionParameter(ASTBase): return self.arg.get_id(version) def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str if self.ellipsis: return '...' else: return transform(self.arg) def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None _verify_description_mode(mode) if self.ellipsis: signode += nodes.Text('...') @@ -2399,7 +2398,7 @@ class ASTFunctionParameter(ASTBase): class ASTParametersQualifiers(ASTBase): def __init__(self, args, volatile, const, refQual, exceptionSpec, override, final, initializer): - # type: (List[Any], bool, bool, unicode, unicode, bool, bool, unicode) -> None + # type: (List[Any], bool, bool, str, str, bool, bool, str) -> None self.args = args self.volatile = volatile self.const = const @@ -2415,7 +2414,7 @@ class ASTParametersQualifiers(ASTBase): return self.args def get_modifiers_id(self, version): - # type: (int) -> unicode + # type: (int) -> str res = [] if self.volatile: res.append('V') @@ -2431,7 +2430,7 @@ class ASTParametersQualifiers(ASTBase): return u''.join(res) def get_param_id(self, version): - # type: (int) -> unicode + # type: (int) -> str if version == 1: if len(self.args) == 0: return '' @@ -2443,8 +2442,8 @@ class ASTParametersQualifiers(ASTBase): return u''.join(a.get_id(version) for a in self.args) def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode - res = [] # type: List[unicode] + # type: (Callable[[Any], str]) -> str + res = [] res.append('(') first = True for a in self.args: @@ -2473,7 +2472,7 @@ class ASTParametersQualifiers(ASTBase): return u''.join(res) def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None _verify_description_mode(mode) paramlist = addnodes.desc_parameterlist() for arg in self.args: @@ -2511,7 +2510,7 @@ class ASTParametersQualifiers(ASTBase): class ASTDeclSpecsSimple(ASTBase): def __init__(self, storage, threadLocal, inline, virtual, explicit, constexpr, volatile, const, friend, attrs): - # type: (unicode, bool, bool, bool, bool, bool, bool, bool, bool, List[Any]) -> None + # type: (str, bool, bool, bool, bool, bool, bool, bool, bool, List[Any]) -> None self.storage = storage self.threadLocal = threadLocal self.inline = inline @@ -2539,8 +2538,8 @@ class ASTDeclSpecsSimple(ASTBase): self.attrs + other.attrs) def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode - res = [] # type: List[unicode] + # type: (Callable[[Any], str]) -> str + res = [] # type: List[str] res.extend(transform(attr) for attr in self.attrs) if self.storage: res.append(self.storage) @@ -2608,7 +2607,7 @@ class ASTDeclSpecs(ASTBase): return self.trailingTypeSpec.name def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str if version == 1: res = [] res.append(self.trailingTypeSpec.get_id(version)) @@ -2626,8 +2625,8 @@ class ASTDeclSpecs(ASTBase): return u''.join(res) def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode - res = [] # type: List[unicode] + # type: (Callable[[Any], str]) -> str + res = [] # type: List[str] l = transform(self.leftSpecs) if len(l) > 0: if len(res) > 0: @@ -2645,7 +2644,7 @@ class ASTDeclSpecs(ASTBase): return "".join(res) def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None _verify_description_mode(mode) modifiers = [] # type: List[nodes.Node] @@ -2676,14 +2675,14 @@ class ASTArray(ASTBase): self.size = size def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str if self.size: return u'[' + transform(self.size) + ']' else: return u'[]' def get_id(self, version): - # type: (int) -> unicode + # type: (int) -> str if version == 1: return u'A' if version == 2: @@ -2729,8 +2728,8 @@ class ASTDeclaratorPtr(ASTBase): return True def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode - res = ['*'] # type: List[unicode] + # type: (Callable[[Any], str]) -> str + res = ['*'] for a in self.attrs: res.append(transform(a)) if len(self.attrs) > 0 and (self.volatile or self.const): @@ -2748,15 +2747,15 @@ class ASTDeclaratorPtr(ASTBase): return u''.join(res) def get_modifiers_id(self, version): - # type: (int) -> unicode + # type: (int) -> str return self.next.get_modifiers_id(version) def get_param_id(self, version): - # type: (int) -> unicode + # type: (int) -> str return self.next.get_param_id(version) def get_ptr_suffix_id(self, version): - # type: (int) -> unicode + # type: (int) -> str if version == 1: res = ['P'] if self.volatile: @@ -2775,9 +2774,9 @@ class ASTDeclaratorPtr(ASTBase): return u''.join(res) def get_type_id(self, version, returnTypeId): - # type: (int, unicode) -> unicode + # type: (int, str) -> str # ReturnType *next, so we are part of the return type of 'next - res = ['P'] # type: List[unicode] + res = ['P'] if self.volatile: res.append('V') if self.const: @@ -2790,7 +2789,7 @@ class ASTDeclaratorPtr(ASTBase): return self.next.is_function_type() def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None _verify_description_mode(mode) signode += nodes.Text("*") for a in self.attrs: @@ -2839,8 +2838,8 @@ class ASTDeclaratorRef(ASTBase): return self.next.require_space_after_declSpecs() def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode - res = ['&'] # type: List[unicode] + # type: (Callable[[Any], str]) -> str + res = ['&'] for a in self.attrs: res.append(transform(a)) if len(self.attrs) > 0 and self.next.require_space_after_declSpecs: @@ -2849,22 +2848,22 @@ class ASTDeclaratorRef(ASTBase): return u''.join(res) def get_modifiers_id(self, version): - # type: (int) -> unicode + # type: (int) -> str return self.next.get_modifiers_id(version) def get_param_id(self, version): # only the parameters (if any) - # type: (int) -> unicode + # type: (int) -> str return self.next.get_param_id(version) def get_ptr_suffix_id(self, version): - # type: (int) -> unicode + # type: (int) -> str if version == 1: return u'R' + self.next.get_ptr_suffix_id(version) else: return self.next.get_ptr_suffix_id(version) + u'R' def get_type_id(self, version, returnTypeId): - # type: (int, unicode) -> unicode + # type: (int, str) -> str assert version >= 2 # ReturnType &next, so we are part of the return type of 'next return self.next.get_type_id(version, returnTypeId=u'R' + returnTypeId) @@ -2874,7 +2873,7 @@ class ASTDeclaratorRef(ASTBase): return self.next.is_function_type() def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None _verify_description_mode(mode) signode += nodes.Text("&") for a in self.attrs: @@ -2905,29 +2904,29 @@ class ASTDeclaratorParamPack(ASTBase): return False def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str res = transform(self.next) if self.next.name: res = ' ' + res return '...' + res def get_modifiers_id(self, version): - # type: (int) -> unicode + # type: (int) -> str return self.next.get_modifiers_id(version) def get_param_id(self, version): # only the parameters (if any) - # type: (int) -> unicode + # type: (int) -> str return self.next.get_param_id(version) def get_ptr_suffix_id(self, version): - # type: (int) -> unicode + # type: (int) -> str if version == 1: return 'Dp' + self.next.get_ptr_suffix_id(version) else: return self.next.get_ptr_suffix_id(version) + u'Dp' def get_type_id(self, version, returnTypeId): - # type: (int, unicode) -> unicode + # type: (int, str) -> str assert version >= 2 # ReturnType... next, so we are part of the return type of 'next return self.next.get_type_id(version, returnTypeId=u'Dp' + returnTypeId) @@ -2937,7 +2936,7 @@ class ASTDeclaratorParamPack(ASTBase): return self.next.is_function_type() def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None _verify_description_mode(mode) signode += nodes.Text("...") if self.next.name: @@ -2970,7 +2969,7 @@ class ASTDeclaratorMemPtr(ASTBase): return True def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str res = [] res.append(transform(self.className)) res.append('::*') @@ -2984,21 +2983,21 @@ class ASTDeclaratorMemPtr(ASTBase): return ''.join(res) def get_modifiers_id(self, version): - # type: (int) -> unicode + # type: (int) -> str if version == 1: raise NoOldIdError() else: return self.next.get_modifiers_id(version) def get_param_id(self, version): # only the parameters (if any) - # type: (int) -> unicode + # type: (int) -> str if version == 1: raise NoOldIdError() else: return self.next.get_param_id(version) def get_ptr_suffix_id(self, version): - # type: (int) -> unicode + # type: (int) -> str if version == 1: raise NoOldIdError() else: @@ -3006,10 +3005,10 @@ class ASTDeclaratorMemPtr(ASTBase): return self.next.get_ptr_suffix_id(version) + u'Dp' def get_type_id(self, version, returnTypeId): - # type: (int, unicode) -> unicode + # type: (int, str) -> str assert version >= 2 # ReturnType name::* next, so we are part of the return type of next - nextReturnTypeId = '' # type: unicode + nextReturnTypeId = '' if self.volatile: nextReturnTypeId += 'V' if self.const: @@ -3024,7 +3023,7 @@ class ASTDeclaratorMemPtr(ASTBase): return self.next.is_function_type() def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None _verify_description_mode(mode) self.className.describe_signature(signode, mode, env, symbol) signode += nodes.Text('::*') @@ -3067,23 +3066,23 @@ class ASTDeclaratorParen(ASTBase): return True def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode - res = ['('] # type: List[unicode] + # type: (Callable[[Any], str]) -> str + res = ['('] res.append(transform(self.inner)) res.append(')') res.append(transform(self.next)) return ''.join(res) def get_modifiers_id(self, version): - # type: (int) -> unicode + # type: (int) -> str return self.inner.get_modifiers_id(version) def get_param_id(self, version): # only the parameters (if any) - # type: (int) -> unicode + # type: (int) -> str return self.inner.get_param_id(version) def get_ptr_suffix_id(self, version): - # type: (int) -> unicode + # type: (int) -> str if version == 1: raise NoOldIdError() # TODO: was this implemented before? return self.next.get_ptr_suffix_id(version) + \ @@ -3093,7 +3092,7 @@ class ASTDeclaratorParen(ASTBase): self.next.get_ptr_suffix_id(version) def get_type_id(self, version, returnTypeId): - # type: (int, unicode) -> unicode + # type: (int, str) -> str assert version >= 2 # ReturnType (inner)next, so 'inner' returns everything outside nextId = self.next.get_type_id(version, returnTypeId) @@ -3104,7 +3103,7 @@ class ASTDeclaratorParen(ASTBase): return self.inner.is_function_type() def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None _verify_description_mode(mode) signode += nodes.Text('(') self.inner.describe_signature(signode, mode, env, symbol) @@ -3135,7 +3134,7 @@ class ASTDeclaratorNameParamQual(ASTBase): return self.paramQual.function_params def get_modifiers_id(self, version): # only the modifiers for a function, e.g., - # type: (int) -> unicode + # type: (int) -> str # cv-qualifiers if self.paramQual: return self.paramQual.get_modifiers_id(version) @@ -3143,18 +3142,18 @@ class ASTDeclaratorNameParamQual(ASTBase): "This should only be called on a function: %s" % text_type(self)) def get_param_id(self, version): # only the parameters (if any) - # type: (int) -> unicode + # type: (int) -> str if self.paramQual: return self.paramQual.get_param_id(version) else: return '' def get_ptr_suffix_id(self, version): # only the array specifiers - # type: (int) -> unicode + # type: (int) -> str return u''.join(a.get_id(version) for a in self.arrayOps) def get_type_id(self, version, returnTypeId): - # type: (int, unicode) -> unicode + # type: (int, str) -> str assert version >= 2 res = [] # TOOD: can we actually have both array ops and paramQual? @@ -3180,7 +3179,7 @@ class ASTDeclaratorNameParamQual(ASTBase): return self.paramQual is not None def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str res = [] if self.declId: res.append(transform(self.declId)) @@ -3191,7 +3190,7 @@ class ASTDeclaratorNameParamQual(ASTBase): return u''.join(res) def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None _verify_description_mode(mode) if self.declId: self.declId.describe_signature(signode, mode, env, symbol) @@ -3206,11 +3205,11 @@ class ASTInitializer(ASTBase): self.value = value def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return u' = ' + transform(self.value) def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None _verify_description_mode(mode) signode.append(nodes.Text(' = ')) self.value.describe_signature(signode, 'markType', env, symbol) @@ -3240,7 +3239,7 @@ class ASTType(ASTBase): return self.decl.function_params def get_id(self, version, objectType=None, symbol=None): - # type: (int, unicode, Symbol) -> unicode + # type: (int, str, Symbol) -> str if version == 1: res = [] if objectType: # needs the name @@ -3285,7 +3284,7 @@ class ASTType(ASTBase): return u''.join(res) def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str res = [] declSpecs = transform(self.declSpecs) res.append(declSpecs) @@ -3295,14 +3294,14 @@ class ASTType(ASTBase): return u''.join(res) def get_type_declaration_prefix(self): - # type: () -> unicode + # type: () -> str if self.declSpecs.trailingTypeSpec: return 'typedef' else: return 'type' def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None _verify_description_mode(mode) self.declSpecs.describe_signature(signode, 'markType', env, symbol) if (self.decl.require_space_after_declSpecs() and @@ -3332,7 +3331,7 @@ class ASTTypeWithInit(ASTBase): return self.type.isPack def get_id(self, version, objectType=None, symbol=None): - # type: (int, unicode, Symbol) -> unicode + # type: (int, str, Symbol) -> str if objectType != 'member': return self.type.get_id(version, objectType) if version == 1: @@ -3341,7 +3340,7 @@ class ASTTypeWithInit(ASTBase): return symbol.get_full_nested_name().get_id(version) def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str res = [] res.append(transform(self.type)) if self.init: @@ -3349,7 +3348,7 @@ class ASTTypeWithInit(ASTBase): return u''.join(res) def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None _verify_description_mode(mode) self.type.describe_signature(signode, mode, env, symbol) if self.init: @@ -3363,13 +3362,13 @@ class ASTTypeUsing(ASTBase): self.type = type def get_id(self, version, objectType=None, symbol=None): - # type: (int, unicode, Symbol) -> unicode + # type: (int, str, Symbol) -> str if version == 1: raise NoOldIdError() return symbol.get_full_nested_name().get_id(version) def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str res = [] res.append(transform(self.name)) if self.type: @@ -3378,11 +3377,11 @@ class ASTTypeUsing(ASTBase): return u''.join(res) def get_type_declaration_prefix(self): - # type: () -> unicode + # type: () -> str return 'using' def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None _verify_description_mode(mode) self.name.describe_signature(signode, mode, env, symbol=symbol) if self.type: @@ -3402,20 +3401,20 @@ class ASTConcept(ASTBase): return self.nestedName def get_id(self, version, objectType=None, symbol=None): - # type: (int, unicode, Symbol) -> unicode + # type: (int, str, Symbol) -> str if version == 1: raise NoOldIdError() return symbol.get_full_nested_name().get_id(version) def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str res = transform(self.nestedName) if self.initializer: res += transform(self.initializer) return res def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None self.nestedName.describe_signature(signode, mode, env, symbol) if self.initializer: self.initializer.describe_signature(signode, mode, env, symbol) @@ -3423,15 +3422,15 @@ class ASTConcept(ASTBase): class ASTBaseClass(ASTBase): def __init__(self, name, visibility, virtual, pack): - # type: (Any, unicode, bool, bool) -> None + # type: (Any, str, bool, bool) -> None self.name = name self.visibility = visibility self.virtual = virtual self.pack = pack def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode - res = [] # type: List[unicode] + # type: (Callable[[Any], str]) -> str + res = [] if self.visibility != 'private': res.append(self.visibility) res.append(' ') @@ -3443,7 +3442,7 @@ class ASTBaseClass(ASTBase): return u''.join(res) def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None _verify_description_mode(mode) if self.visibility != 'private': signode += addnodes.desc_annotation(self.visibility, @@ -3465,11 +3464,11 @@ class ASTClass(ASTBase): self.bases = bases def get_id(self, version, objectType, symbol): - # type: (int, unicode, Symbol) -> unicode + # type: (int, str, Symbol) -> str return symbol.get_full_nested_name().get_id(version) def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str res = [] res.append(transform(self.name)) if self.final: @@ -3485,7 +3484,7 @@ class ASTClass(ASTBase): return u''.join(res) def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None _verify_description_mode(mode) self.name.describe_signature(signode, mode, env, symbol=symbol) if self.final: @@ -3505,37 +3504,37 @@ class ASTUnion(ASTBase): self.name = name def get_id(self, version, objectType, symbol): - # type: (int, unicode, Symbol) -> unicode + # type: (int, str, Symbol) -> str if version == 1: raise NoOldIdError() return symbol.get_full_nested_name().get_id(version) def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str return transform(self.name) def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None _verify_description_mode(mode) self.name.describe_signature(signode, mode, env, symbol=symbol) class ASTEnum(ASTBase): def __init__(self, name, scoped, underlyingType): - # type: (Any, unicode, Any) -> None + # type: (Any, str, Any) -> None self.name = name self.scoped = scoped self.underlyingType = underlyingType def get_id(self, version, objectType, symbol): - # type: (int, unicode, Symbol) -> unicode + # type: (int, str, Symbol) -> str if version == 1: raise NoOldIdError() return symbol.get_full_nested_name().get_id(version) def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode - res = [] # type: List[unicode] + # type: (Callable[[Any], str]) -> str + res = [] if self.scoped: res.append(self.scoped) res.append(' ') @@ -3546,7 +3545,7 @@ class ASTEnum(ASTBase): return u''.join(res) def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None _verify_description_mode(mode) # self.scoped has been done by the CPPEnumObject self.name.describe_signature(signode, mode, env, symbol=symbol) @@ -3563,13 +3562,13 @@ class ASTEnumerator(ASTBase): self.init = init def get_id(self, version, objectType, symbol): - # type: (int, unicode, Symbol) -> unicode + # type: (int, str, Symbol) -> str if version == 1: raise NoOldIdError() return symbol.get_full_nested_name().get_id(version) def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode + # type: (Callable[[Any], str]) -> str res = [] res.append(transform(self.name)) if self.init: @@ -3577,7 +3576,7 @@ class ASTEnumerator(ASTBase): return u''.join(res) def describe_signature(self, signode, mode, env, symbol): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Symbol) -> None _verify_description_mode(mode) self.name.describe_signature(signode, mode, env, symbol) if self.init: @@ -3586,7 +3585,7 @@ class ASTEnumerator(ASTBase): class ASTDeclaration(ASTBase): def __init__(self, objectType, visibility, templatePrefix, declaration): - # type: (unicode, unicode, Any, Any) -> None + # type: (str, str, Any, Any) -> None self.objectType = objectType self.visibility = visibility self.templatePrefix = templatePrefix @@ -3619,7 +3618,7 @@ class ASTDeclaration(ASTBase): return self.declaration.function_params def get_id(self, version, prefixed=True): - # type: (int, bool) -> unicode + # type: (int, bool) -> str if version == 1: if self.templatePrefix: raise NoOldIdError() @@ -3639,12 +3638,12 @@ class ASTDeclaration(ASTBase): return u''.join(res) def get_newest_id(self): - # type: () -> unicode + # type: () -> str return self.get_id(_max_id, True) def _stringify(self, transform): - # type: (Callable[[Any], unicode]) -> unicode - res = [] # type: List[unicode] + # type: (Callable[[Any], str]) -> str + res = [] if self.visibility and self.visibility != "public": res.append(self.visibility) res.append(u' ') @@ -3654,7 +3653,7 @@ class ASTDeclaration(ASTBase): return u''.join(res) def describe_signature(self, signode, mode, env, options): - # type: (addnodes.desc_signature, unicode, BuildEnvironment, Dict) -> None + # type: (addnodes.desc_signature, str, BuildEnvironment, Dict) -> None _verify_description_mode(mode) assert self.symbol # The caller of the domain added a desc_signature node. @@ -3745,7 +3744,7 @@ class Symbol: templateParams, # type: Any templateArgs, # type: Any declaration, # type: ASTDeclaration - docname # type: unicode + docname # type: str ): # type: (...) -> None self.parent = parent @@ -3770,7 +3769,7 @@ class Symbol: self._add_template_and_function_params() def _fill_empty(self, declaration, docname): - # type: (ASTDeclaration, unicode) -> None + # type: (ASTDeclaration, str) -> None self._assert_invariants() assert not self.declaration assert not self.docname @@ -3822,7 +3821,7 @@ class Symbol: self.parent = None def clear_doc(self, docname): - # type: (unicode) -> None + # type: (str) -> None newChildren = [] for sChild in self._children: sChild.clear_doc(docname) @@ -3845,9 +3844,8 @@ class Symbol: yield c if not c.identOrOp.is_anon(): continue - # TODO: change to 'yield from' when Python 2 support is dropped - for nested in c.children_recurse_anon: - yield nested + + yield from c.children_recurse_anon def get_lookup_key(self): # type: () -> List[Tuple[ASTNestedNameElement, Any]] @@ -3966,7 +3964,7 @@ class Symbol: onMissingQualifiedSymbol, # type: Callable[[Symbol, Union[ASTIdentifier, ASTOperator], Any, ASTTemplateArgs], Symbol] # NOQA strictTemplateParamArgLists, # type: bool - ancestorLookupType, # type: unicode + ancestorLookupType, # type: str templateShorthand, # type: bool matchSelf, # type: bool recurseInAnon, # type: bool @@ -4067,7 +4065,7 @@ class Symbol: identOrOp, templateParams, templateArgs) def _add_symbols(self, nestedName, templateDecls, declaration, docname): - # type: (ASTNestedName, List[Any], ASTDeclaration, unicode) -> Symbol + # type: (ASTNestedName, List[Any], ASTDeclaration, str) -> Symbol # Used for adding a whole path of symbols, where the last may or may not # be an actual declaration. @@ -4220,7 +4218,7 @@ class Symbol: return symbol def merge_with(self, other, docnames, env): - # type: (Symbol, List[unicode], BuildEnvironment) -> None + # type: (Symbol, List[str], BuildEnvironment) -> None assert other is not None for otherChild in other._children: ourChild = self._find_first_named_symbol( @@ -4261,7 +4259,7 @@ class Symbol: declaration=None, docname=None) def add_declaration(self, declaration, docname): - # type: (ASTDeclaration, unicode) -> Symbol + # type: (ASTDeclaration, str) -> Symbol assert declaration assert docname nestedName = declaration.name @@ -4299,7 +4297,7 @@ class Symbol: def find_name(self, nestedName, templateDecls, typ, templateShorthand, matchSelf, recurseInAnon): - # type: (ASTNestedName, List[Any], unicode, bool, bool, bool) -> Symbol + # type: (ASTNestedName, List[Any], str, bool, bool, bool) -> Symbol # templateShorthand: missing template parameter lists for templates is ok def onMissingQualifiedSymbol(parentSymbol, identOrOp, templateParams, templateArgs): @@ -4337,7 +4335,7 @@ class Symbol: def find_declaration(self, declaration, typ, templateShorthand, matchSelf, recurseInAnon): - # type: (ASTDeclaration, unicode, bool, bool, bool) -> Symbol + # type: (ASTDeclaration, str, bool, bool, bool) -> Symbol # templateShorthand: missing template parameter lists for templates is ok nestedName = declaration.name if declaration.templatePrefix: @@ -4381,8 +4379,8 @@ class Symbol: return None def to_string(self, indent): - # type: (int) -> unicode - res = ['\t' * indent] # type: List[unicode] + # type: (int) -> str + res = ['\t' * indent] if not self.parent: res.append('::') else: @@ -4407,7 +4405,7 @@ class Symbol: return ''.join(res) def dump(self, indent): - # type: (int) -> unicode + # type: (int) -> str res = [self.to_string(indent)] for c in self._children: res.append(c.dump(indent + 1)) @@ -4439,7 +4437,7 @@ class DefinitionParser: self.config = config def _make_multi_error(self, errors, header): - # type: (List[Any], unicode) -> DefinitionError + # type: (List[Any], str) -> DefinitionError if len(errors) == 1: if len(header) > 0: return DefinitionError(header + '\n' + errors[0][0].description) @@ -4462,13 +4460,13 @@ class DefinitionParser: return DefinitionError(''.join(result)) def status(self, msg): - # type: (unicode) -> None + # type: (str) -> None # for debugging indicator = '-' * self.pos + '^' print("%s\n%s\n%s" % (msg, self.definition, indicator)) def fail(self, msg): - # type: (unicode) -> None + # type: (str) -> None errors = [] indicator = '-' * self.pos + '^' exMain = DefinitionError( @@ -4481,7 +4479,7 @@ class DefinitionParser: raise self._make_multi_error(errors, '') def warn(self, msg): - # type: (unicode) -> None + # type: (str) -> None if self.warnEnv: self.warnEnv.warn(msg) else: @@ -4502,7 +4500,7 @@ class DefinitionParser: self.pos, self.last_match = self._previous_state def skip_string(self, string): - # type: (unicode) -> bool + # type: (str) -> bool strlen = len(string) if self.definition[self.pos:self.pos + strlen] == string: self.pos += strlen @@ -4510,7 +4508,7 @@ class DefinitionParser: return False def skip_word(self, word): - # type: (unicode) -> bool + # type: (str) -> bool return self.match(re.compile(r'\b%s\b' % re.escape(word))) def skip_ws(self): @@ -4518,14 +4516,14 @@ class DefinitionParser: return self.match(_whitespace_re) def skip_word_and_ws(self, word): - # type: (unicode) -> bool + # type: (str) -> bool if self.skip_word(word): self.skip_ws() return True return False def skip_string_and_ws(self, string): - # type: (unicode) -> bool + # type: (str) -> bool if self.skip_string(string): self.skip_ws() return True @@ -4538,7 +4536,7 @@ class DefinitionParser: @property def current_char(self): - # type: () -> unicode + # type: () -> str try: return self.definition[self.pos] except IndexError: @@ -4546,14 +4544,14 @@ class DefinitionParser: @property def matched_text(self): - # type: () -> unicode + # type: () -> str if self.last_match is not None: return self.last_match.group() else: return None def read_rest(self): - # type: () -> unicode + # type: () -> str rv = self.definition[self.pos:] self.pos = self.end return rv @@ -4584,11 +4582,11 @@ class DefinitionParser: return self.definition[startPos:self.pos] def _parse_balanced_token_seq(self, end): - # type: (List[unicode]) -> unicode + # type: (List[str]) -> str # TODO: add handling of string literals and similar - brackets = {'(': ')', '[': ']', '{': '}'} # type: Dict[unicode, unicode] + brackets = {'(': ')', '[': ']', '{': '}'} startPos = self.pos - symbols = [] # type: List[unicode] + symbols = [] # type: List[str] while not self.eof: if len(symbols) == 0 and self.current_char in end: break @@ -4754,7 +4752,7 @@ class DefinitionParser: return self._parse_nested_name() def _parse_expression_list_or_braced_init_list(self): - # type: () -> Tuple[List[Any], unicode] + # type: () -> Tuple[List[Any], str] self.skip_ws() if self.skip_string_and_ws('('): close = ')' @@ -5176,8 +5174,8 @@ class DefinitionParser: value = self.matched_text else: # TODO: add handling of more bracket-like things, and quote handling - brackets = {'(': ')', '[': ']', '<': '>'} # type: Dict[unicode, unicode] - symbols = [] # type: List[unicode] + brackets = {'(': ')', '[': ']', '<': '>'} + symbols = [] # type: List[str] while not self.eof: if (len(symbols) == 0 and self.current_char in end): break @@ -5379,7 +5377,7 @@ class DefinitionParser: return ASTTrailingTypeSpecName(prefix, nestedName) def _parse_parameters_and_qualifiers(self, paramMode): - # type: (unicode) -> ASTParametersQualifiers + # type: (str) -> ASTParametersQualifiers if paramMode == 'new': return None self.skip_ws() @@ -5471,7 +5469,7 @@ class DefinitionParser: initializer) def _parse_decl_specs_simple(self, outer, typed): - # type: (unicode, bool) -> ASTDeclSpecsSimple + # type: (str, bool) -> ASTDeclSpecsSimple """Just parse the simple ones.""" storage = None threadLocal = None @@ -5546,7 +5544,7 @@ class DefinitionParser: friend, attrs) def _parse_decl_specs(self, outer, typed=True): - # type: (unicode, bool) -> ASTDeclSpecs + # type: (str, bool) -> ASTDeclSpecs if outer: if outer not in ('type', 'member', 'function', 'templateParam'): raise Exception('Internal error, unknown outer "%s".' % outer) @@ -5574,7 +5572,7 @@ class DefinitionParser: return ASTDeclSpecs(outer, leftSpecs, rightSpecs, trailing) def _parse_declarator_name_param_qual(self, named, paramMode, typed): - # type: (Union[bool, unicode], unicode, bool) -> ASTDeclaratorNameParamQual + # type: (Union[bool, str], str, bool) -> ASTDeclaratorNameParamQual # now we should parse the name, and then suffixes if named == 'maybe': pos = self.pos @@ -5621,7 +5619,7 @@ class DefinitionParser: paramQual=paramQual) def _parse_declarator(self, named, paramMode, typed=True): - # type: (Union[bool, unicode], unicode, bool) -> Any + # type: (Union[bool, str], str, bool) -> Any # 'typed' here means 'parse return type stuff' if paramMode not in ('type', 'function', 'operatorCast', 'new'): raise Exception( @@ -5733,7 +5731,7 @@ class DefinitionParser: raise self._make_multi_error(prevErrors, header) def _parse_initializer(self, outer=None, allowFallback=True): - # type: (unicode, bool) -> ASTInitializer + # type: (str, bool) -> ASTInitializer self.skip_ws() # TODO: support paren and brace initialization for memberObject if not self.skip_string('='): @@ -5760,7 +5758,7 @@ class DefinitionParser: return ASTInitializer(value) def _parse_type(self, named, outer=None): - # type: (Union[bool, unicode], unicode) -> ASTType + # type: (Union[bool, str], str) -> ASTType """ named=False|'maybe'|True: 'maybe' is e.g., for function objects which doesn't need to name the arguments @@ -5843,7 +5841,7 @@ class DefinitionParser: return ASTType(declSpecs, decl) def _parse_type_with_init(self, named, outer): - # type: (Union[bool, unicode], unicode) -> Any + # type: (Union[bool, str], str) -> Any if outer: assert outer in ('type', 'member', 'function', 'templateParam') type = self._parse_type(outer=outer, named=named) @@ -5912,7 +5910,7 @@ class DefinitionParser: if self.skip_string(':'): while 1: self.skip_ws() - visibility = 'private' # type: unicode + visibility = 'private' virtual = False pack = False if self.skip_word_and_ws('virtual'): @@ -5940,7 +5938,7 @@ class DefinitionParser: def _parse_enum(self): # type: () -> ASTEnum - scoped = None # type: unicode # is set by CPPEnumObject + scoped = None # is set by CPPEnumObject self.skip_ws() name = self._parse_nested_name() self.skip_ws() @@ -6075,8 +6073,8 @@ class DefinitionParser: return ASTTemplateIntroduction(concept, params) def _parse_template_declaration_prefix(self, objectType): - # type: (unicode) -> ASTTemplateDeclarationPrefix - templates = [] # type: List + # type: (str) -> ASTTemplateDeclarationPrefix + templates = [] # type: List[str] while 1: self.skip_ws() # the saved position is only used to provide a better error message @@ -6131,7 +6129,7 @@ class DefinitionParser: msg = "Too many template argument lists compared to parameter" \ " lists. Argument lists: %d, Parameter lists: %d," \ " Extra empty parameters lists prepended: %d." \ - % (numArgs, numParams, numExtra) # type: unicode + % (numArgs, numParams, numExtra) msg += " Declaration:\n\t" if templatePrefix: msg += "%s\n\t" % text_type(templatePrefix) @@ -6147,7 +6145,7 @@ class DefinitionParser: return templatePrefix def parse_declaration(self, objectType): - # type: (unicode) -> ASTDeclaration + # type: (str) -> ASTDeclaration if objectType not in ('type', 'concept', 'member', 'function', 'class', 'union', 'enum', 'enumerator'): raise Exception('Internal error, unknown objectType "%s".' % objectType) @@ -6290,7 +6288,7 @@ class CPPObject(ObjectDescription): option_spec['tparam-line-spec'] = directives.flag def warn(self, msg): - # type: (unicode) -> None + # type: (str) -> None self.state_machine.reporter.warning(msg, line=self.lineno) def _add_enumerator_to_parent(self, ast): @@ -6336,7 +6334,7 @@ class CPPObject(ObjectDescription): docname=self.env.docname) def add_target_and_index(self, ast, sig, signode): - # type: (Any, unicode, addnodes.desc_signature) -> None + # type: (Any, str, addnodes.desc_signature) -> None # general note: name must be lstrip(':')'ed, to remove "::" ids = [] for i in range(1, _max_id + 1): @@ -6396,7 +6394,7 @@ class CPPObject(ObjectDescription): self.state.document.note_explicit_target(signode) def get_index_text(self, name): - # type: (unicode) -> unicode + # type: (str) -> str raise NotImplementedError() def parse_definition(self, parser): @@ -6437,7 +6435,7 @@ class CPPObject(ObjectDescription): return super(CPPObject, self).run() def handle_signature(self, sig, signode): - # type: (unicode, addnodes.desc_signature) -> Any + # type: (str, addnodes.desc_signature) -> Any parentSymbol = self.env.temp_data['cpp:parent_symbol'] parser = DefinitionParser(sig, self, self.env.config) @@ -6489,7 +6487,7 @@ class CPPObject(ObjectDescription): class CPPTypeObject(CPPObject): def get_index_text(self, name): - # type: (unicode) -> unicode + # type: (str) -> str return _('%s (C++ type)') % name def parse_definition(self, parser): @@ -6499,7 +6497,7 @@ class CPPTypeObject(CPPObject): class CPPConceptObject(CPPObject): def get_index_text(self, name): - # type: (unicode) -> unicode + # type: (str) -> str return _('%s (C++ concept)') % name def parse_definition(self, parser): @@ -6509,7 +6507,7 @@ class CPPConceptObject(CPPObject): class CPPMemberObject(CPPObject): def get_index_text(self, name): - # type: (unicode) -> unicode + # type: (str) -> str return _('%s (C++ member)') % name def parse_definition(self, parser): @@ -6519,7 +6517,7 @@ class CPPMemberObject(CPPObject): class CPPFunctionObject(CPPObject): def get_index_text(self, name): - # type: (unicode) -> unicode + # type: (str) -> str return _('%s (C++ function)') % name def parse_definition(self, parser): @@ -6529,7 +6527,7 @@ class CPPFunctionObject(CPPObject): class CPPClassObject(CPPObject): def get_index_text(self, name): - # type: (unicode) -> unicode + # type: (str) -> str return _('%s (C++ class)') % name def parse_definition(self, parser): @@ -6539,7 +6537,7 @@ class CPPClassObject(CPPObject): class CPPUnionObject(CPPObject): def get_index_text(self, name): - # type: (unicode) -> unicode + # type: (str) -> str return _('%s (C++ union)') % name def parse_definition(self, parser): @@ -6549,7 +6547,7 @@ class CPPUnionObject(CPPObject): class CPPEnumObject(CPPObject): def get_index_text(self, name): - # type: (unicode) -> unicode + # type: (str) -> str return _('%s (C++ enum)') % name def parse_definition(self, parser): @@ -6569,7 +6567,7 @@ class CPPEnumObject(CPPObject): class CPPEnumeratorObject(CPPObject): def get_index_text(self, name): - # type: (unicode) -> unicode + # type: (str) -> str return _('%s (C++ enumerator)') % name def parse_definition(self, parser): @@ -6590,7 +6588,7 @@ class CPPNamespaceObject(SphinxDirective): option_spec = {} # type: Dict def warn(self, msg): - # type: (unicode) -> None + # type: (str) -> None self.state_machine.reporter.warning(msg, line=self.lineno) def run(self): @@ -6624,7 +6622,7 @@ class CPPNamespacePushObject(SphinxDirective): option_spec = {} # type: Dict def warn(self, msg): - # type: (unicode) -> None + # type: (str) -> None self.state_machine.reporter.warning(msg, line=self.lineno) def run(self): @@ -6659,7 +6657,7 @@ class CPPNamespacePopObject(SphinxDirective): option_spec = {} # type: Dict def warn(self, msg): - # type: (unicode) -> None + # type: (str) -> None self.state_machine.reporter.warning(msg, line=self.lineno) def run(self): @@ -6682,7 +6680,7 @@ class CPPNamespacePopObject(SphinxDirective): class CPPXRefRole(XRefRole): def process_link(self, env, refnode, has_explicit_title, title, target): - # type: (BuildEnvironment, nodes.Element, bool, unicode, unicode) -> Tuple[unicode, unicode] # NOQA + # type: (BuildEnvironment, nodes.Element, bool, str, str) -> Tuple[str, str] refnode.attributes.update(env.ref_context) if not has_explicit_title: @@ -6798,7 +6796,7 @@ class CPPDomain(Domain): } def clear_doc(self, docname): - # type: (unicode) -> None + # type: (str) -> None rootSymbol = self.data['root_symbol'] rootSymbol.clear_doc(docname) for name, nDocname in list(self.data['names'].items()): @@ -6806,7 +6804,7 @@ class CPPDomain(Domain): del self.data['names'][name] def process_doc(self, env, docname, document): - # type: (BuildEnvironment, unicode, nodes.document) -> None + # type: (BuildEnvironment, str, nodes.document) -> None # just for debugging # print("process_doc:", docname) # print(self.data['root_symbol'].dump(0)) @@ -6817,7 +6815,7 @@ class CPPDomain(Domain): pnode.attributes.update(self.env.ref_context) def merge_domaindata(self, docnames, otherdata): - # type: (List[unicode], Dict) -> None + # type: (List[str], Dict) -> None # print("merge_domaindata:") # print("self") # print(self.data['root_symbol'].dump(0)) @@ -6839,7 +6837,7 @@ class CPPDomain(Domain): def _resolve_xref_inner(self, env, fromdocname, builder, typ, target, node, contnode, emitWarnings=True): - # type: (BuildEnvironment, unicode, Builder, unicode, unicode, addnodes.pending_xref, nodes.Element, bool) -> Tuple[nodes.Element, unicode] # NOQA + # type: (BuildEnvironment, str, Builder, str, str, addnodes.pending_xref, nodes.Element, bool) -> Tuple[nodes.Element, str] # NOQA class Warner: def warn(self, msg): if emitWarnings: @@ -6977,12 +6975,12 @@ class CPPDomain(Domain): ), declaration.objectType def resolve_xref(self, env, fromdocname, builder, typ, target, node, contnode): - # type: (BuildEnvironment, unicode, Builder, unicode, unicode, addnodes.pending_xref, nodes.Element) -> nodes.Element # NOQA + # type: (BuildEnvironment, str, Builder, str, str, addnodes.pending_xref, nodes.Element) -> nodes.Element # NOQA return self._resolve_xref_inner(env, fromdocname, builder, typ, target, node, contnode)[0] def resolve_any_xref(self, env, fromdocname, builder, target, node, contnode): - # type: (BuildEnvironment, unicode, Builder, unicode, addnodes.pending_xref, nodes.Element) -> List[Tuple[unicode, nodes.Element]] # NOQA + # type: (BuildEnvironment, str, Builder, str, addnodes.pending_xref, nodes.Element) -> List[Tuple[str, nodes.Element]] # NOQA retnode, objtype = self._resolve_xref_inner(env, fromdocname, builder, 'any', target, node, contnode, emitWarnings=False) @@ -6994,7 +6992,7 @@ class CPPDomain(Domain): return [] def get_objects(self): - # type: () -> Iterator[Tuple[unicode, unicode, unicode, unicode, unicode, int]] + # type: () -> Iterator[Tuple[str, str, str, str, str, int]] rootSymbol = self.data['root_symbol'] for symbol in rootSymbol.get_all_symbols(): if symbol.declaration is None: @@ -7009,7 +7007,7 @@ class CPPDomain(Domain): yield (name, dispname, objectType, docname, newestId, 1) def get_full_qualified_name(self, node): - # type: (nodes.Element) -> unicode + # type: (nodes.Element) -> str target = node.get('reftarget', None) if target is None: return None @@ -7024,7 +7022,7 @@ class CPPDomain(Domain): def setup(app): - # type: (Sphinx) -> Dict[unicode, Any] + # type: (Sphinx) -> Dict[str, Any] app.add_domain(CPPDomain) app.add_config_value("cpp_index_common_prefix", [], 'env') app.add_config_value("cpp_id_attributes", [], 'env') |