|
def | __init__ (self, namespace_stack) |
|
def | ToType (self, tokens) |
|
def | DeclarationToParts (self, parts, needs_name_removed) |
|
def | ToParameters (self, tokens) |
|
def | CreateReturnType (self, return_type_seq) |
|
def | GetTemplateIndices (self, names) |
|
def | __init__ (self, namespace_stack) |
|
def | ToType (self, tokens) |
|
def | DeclarationToParts (self, parts, needs_name_removed) |
|
def | ToParameters (self, tokens) |
|
def | CreateReturnType (self, return_type_seq) |
|
def | GetTemplateIndices (self, names) |
|
def | __init__ (self, namespace_stack) |
|
def | ToType (self, tokens) |
|
def | DeclarationToParts (self, parts, needs_name_removed) |
|
def | ToParameters (self, tokens) |
|
def | CreateReturnType (self, return_type_seq) |
|
def | GetTemplateIndices (self, names) |
|
Definition at line 458 of file ast.py.
def cpp.ast.TypeConverter.__init__ |
( |
|
self, |
|
|
|
namespace_stack |
|
) |
| |
def cpp.ast.TypeConverter.__init__ |
( |
|
self, |
|
|
|
namespace_stack |
|
) |
| |
def cpp.ast.TypeConverter.__init__ |
( |
|
self, |
|
|
|
namespace_stack |
|
) |
| |
def cpp.ast.TypeConverter._GetTemplateEnd |
( |
|
self, |
|
|
|
tokens, |
|
|
|
start |
|
) |
| |
|
private |
def cpp.ast.TypeConverter._GetTemplateEnd |
( |
|
self, |
|
|
|
tokens, |
|
|
|
start |
|
) |
| |
|
private |
def cpp.ast.TypeConverter._GetTemplateEnd |
( |
|
self, |
|
|
|
tokens, |
|
|
|
start |
|
) |
| |
|
private |
def cpp.ast.TypeConverter.CreateReturnType |
( |
|
self, |
|
|
|
return_type_seq |
|
) |
| |
Definition at line 652 of file ast.py.
References cpp.ast.TypeConverter.DeclarationToParts().
Referenced by cpp.ast.TypeConverter.CreateReturnType().
653 if not return_type_seq:
655 start = return_type_seq[0].start
656 end = return_type_seq[-1].end
657 _, name, templated_types, modifiers, default, other_tokens = \
659 names = [n.name
for n
in other_tokens]
660 reference =
'&' in names
661 pointer =
'*' in names
663 return Type(start, end, name, templated_types, modifiers,
664 reference, pointer, array)
def CreateReturnType(self, return_type_seq)
def DeclarationToParts(self, parts, needs_name_removed)
def cpp.ast.TypeConverter.CreateReturnType |
( |
|
self, |
|
|
|
return_type_seq |
|
) |
| |
Definition at line 652 of file ast.py.
References cpp.ast.TypeConverter.CreateReturnType(), and cpp.ast.TypeConverter.DeclarationToParts().
653 if not return_type_seq:
655 start = return_type_seq[0].start
656 end = return_type_seq[-1].end
657 _, name, templated_types, modifiers, default, other_tokens = \
659 names = [n.name
for n
in other_tokens]
660 reference =
'&' in names
661 pointer =
'*' in names
663 return Type(start, end, name, templated_types, modifiers,
664 reference, pointer, array)
def CreateReturnType(self, return_type_seq)
def DeclarationToParts(self, parts, needs_name_removed)
def cpp.ast.TypeConverter.CreateReturnType |
( |
|
self, |
|
|
|
return_type_seq |
|
) |
| |
Definition at line 652 of file ast.py.
References cpp.ast.TypeConverter.CreateReturnType(), and cpp.ast.TypeConverter.DeclarationToParts().
653 if not return_type_seq:
655 start = return_type_seq[0].start
656 end = return_type_seq[-1].end
657 _, name, templated_types, modifiers, default, other_tokens = \
659 names = [n.name
for n
in other_tokens]
660 reference =
'&' in names
661 pointer =
'*' in names
663 return Type(start, end, name, templated_types, modifiers,
664 reference, pointer, array)
def CreateReturnType(self, return_type_seq)
def DeclarationToParts(self, parts, needs_name_removed)
def cpp.ast.TypeConverter.DeclarationToParts |
( |
|
self, |
|
|
|
parts, |
|
|
|
needs_name_removed |
|
) |
| |
Definition at line 536 of file ast.py.
References cpp.ast.TypeConverter._GetTemplateEnd(), cpp.ast.TypeConverter.DeclarationToParts(), folly.enumerate(), join, and cpp.ast.TypeConverter.ToType().
539 if needs_name_removed:
543 default = parts[i+1:]
544 name = parts[i-1].name
545 if name ==
']' and parts[i-2].name ==
'[':
546 name = parts[i-3].name
551 if parts[-1].token_type == tokenize.NAME:
552 name = parts.pop().name
566 if keywords.IsKeyword(p.name):
567 modifiers.append(p.name)
570 templated_types = self.
ToType(templated_tokens)
574 if next_index < end
and parts[next_index].name ==
'::':
576 elif p.name
in (
'[',
']',
'='):
578 other_tokens.append(p)
579 elif p.name
not in (
'*',
'&',
'>'):
581 if (type_name
and type_name[-1].token_type == tokenize.NAME
and 582 p.token_type == tokenize.NAME):
586 other_tokens.append(p)
588 type_name =
''.
join([t.name
for t
in type_name])
589 return name, type_name, templated_types, modifiers, default, other_tokens
def _GetTemplateEnd(self, tokens, start)
detail::RangeEnumerator< Range > enumerate(Range &&r)
def DeclarationToParts(self, parts, needs_name_removed)
def cpp.ast.TypeConverter.DeclarationToParts |
( |
|
self, |
|
|
|
parts, |
|
|
|
needs_name_removed |
|
) |
| |
Definition at line 536 of file ast.py.
References cpp.ast.TypeConverter._GetTemplateEnd(), folly.enumerate(), join, and cpp.ast.TypeConverter.ToType().
Referenced by cpp.ast.TypeConverter.CreateReturnType(), cpp.ast.TypeConverter.DeclarationToParts(), and cpp.ast.TypeConverter.ToParameters().
539 if needs_name_removed:
543 default = parts[i+1:]
544 name = parts[i-1].name
545 if name ==
']' and parts[i-2].name ==
'[':
546 name = parts[i-3].name
551 if parts[-1].token_type == tokenize.NAME:
552 name = parts.pop().name
566 if keywords.IsKeyword(p.name):
567 modifiers.append(p.name)
570 templated_types = self.
ToType(templated_tokens)
574 if next_index < end
and parts[next_index].name ==
'::':
576 elif p.name
in (
'[',
']',
'='):
578 other_tokens.append(p)
579 elif p.name
not in (
'*',
'&',
'>'):
581 if (type_name
and type_name[-1].token_type == tokenize.NAME
and 582 p.token_type == tokenize.NAME):
586 other_tokens.append(p)
588 type_name =
''.
join([t.name
for t
in type_name])
589 return name, type_name, templated_types, modifiers, default, other_tokens
def _GetTemplateEnd(self, tokens, start)
detail::RangeEnumerator< Range > enumerate(Range &&r)
def DeclarationToParts(self, parts, needs_name_removed)
def cpp.ast.TypeConverter.DeclarationToParts |
( |
|
self, |
|
|
|
parts, |
|
|
|
needs_name_removed |
|
) |
| |
Definition at line 536 of file ast.py.
References cpp.ast.TypeConverter._GetTemplateEnd(), cpp.ast.TypeConverter.DeclarationToParts(), folly.enumerate(), join, and cpp.ast.TypeConverter.ToType().
539 if needs_name_removed:
543 default = parts[i+1:]
544 name = parts[i-1].name
545 if name ==
']' and parts[i-2].name ==
'[':
546 name = parts[i-3].name
551 if parts[-1].token_type == tokenize.NAME:
552 name = parts.pop().name
566 if keywords.IsKeyword(p.name):
567 modifiers.append(p.name)
570 templated_types = self.
ToType(templated_tokens)
574 if next_index < end
and parts[next_index].name ==
'::':
576 elif p.name
in (
'[',
']',
'='):
578 other_tokens.append(p)
579 elif p.name
not in (
'*',
'&',
'>'):
581 if (type_name
and type_name[-1].token_type == tokenize.NAME
and 582 p.token_type == tokenize.NAME):
586 other_tokens.append(p)
588 type_name =
''.
join([t.name
for t
in type_name])
589 return name, type_name, templated_types, modifiers, default, other_tokens
def _GetTemplateEnd(self, tokens, start)
detail::RangeEnumerator< Range > enumerate(Range &&r)
def DeclarationToParts(self, parts, needs_name_removed)
def cpp.ast.TypeConverter.GetTemplateIndices |
( |
|
self, |
|
|
|
names |
|
) |
| |
def cpp.ast.TypeConverter.GetTemplateIndices |
( |
|
self, |
|
|
|
names |
|
) |
| |
def cpp.ast.TypeConverter.GetTemplateIndices |
( |
|
self, |
|
|
|
names |
|
) |
| |
def cpp.ast.TypeConverter.ToParameters |
( |
|
self, |
|
|
|
tokens |
|
) |
| |
Definition at line 591 of file ast.py.
References cpp.ast.TypeConverter.DeclarationToParts(), and cpp.ast.TypeConverter.ToParameters().
596 name = type_name =
'' 598 pointer = reference = array =
False 602 def AddParameter(end):
606 (name, type_name, templated_types, modifiers,
607 unused_default, unused_other_tokens) = parts
608 parameter_type =
Type(first_token.start, first_token.end,
609 type_name, templated_types, modifiers,
610 reference, pointer, array)
611 p =
Parameter(first_token.start, end, name,
612 parameter_type, default)
623 if template_count > 0:
624 type_modifiers.append(s)
628 AddParameter(s.start)
629 name = type_name =
'' 631 pointer = reference = array =
False 648 type_modifiers.append(s)
649 AddParameter(tokens[-1].end)
def ToParameters(self, tokens)
def DeclarationToParts(self, parts, needs_name_removed)
def cpp.ast.TypeConverter.ToParameters |
( |
|
self, |
|
|
|
tokens |
|
) |
| |
Definition at line 591 of file ast.py.
References cpp.ast.TypeConverter.DeclarationToParts(), and cpp.ast.TypeConverter.ToParameters().
596 name = type_name =
'' 598 pointer = reference = array =
False 602 def AddParameter(end):
606 (name, type_name, templated_types, modifiers,
607 unused_default, unused_other_tokens) = parts
608 parameter_type =
Type(first_token.start, first_token.end,
609 type_name, templated_types, modifiers,
610 reference, pointer, array)
611 p =
Parameter(first_token.start, end, name,
612 parameter_type, default)
623 if template_count > 0:
624 type_modifiers.append(s)
628 AddParameter(s.start)
629 name = type_name =
'' 631 pointer = reference = array =
False 648 type_modifiers.append(s)
649 AddParameter(tokens[-1].end)
def ToParameters(self, tokens)
def DeclarationToParts(self, parts, needs_name_removed)
def cpp.ast.TypeConverter.ToParameters |
( |
|
self, |
|
|
|
tokens |
|
) |
| |
Definition at line 591 of file ast.py.
References cpp.ast.TypeConverter.DeclarationToParts().
Referenced by cpp.ast.TypeConverter.ToParameters().
596 name = type_name =
'' 598 pointer = reference = array =
False 602 def AddParameter(end):
606 (name, type_name, templated_types, modifiers,
607 unused_default, unused_other_tokens) = parts
608 parameter_type =
Type(first_token.start, first_token.end,
609 type_name, templated_types, modifiers,
610 reference, pointer, array)
611 p =
Parameter(first_token.start, end, name,
612 parameter_type, default)
623 if template_count > 0:
624 type_modifiers.append(s)
628 AddParameter(s.start)
629 name = type_name =
'' 631 pointer = reference = array =
False 648 type_modifiers.append(s)
649 AddParameter(tokens[-1].end)
def ToParameters(self, tokens)
def DeclarationToParts(self, parts, needs_name_removed)
def cpp.ast.TypeConverter.ToType |
( |
|
self, |
|
|
|
tokens |
|
) |
| |
Convert [Token,...] to [Class(...), ] useful for base classes.
For example, code like class Foo : public Bar<x, y> { ... };
the "Bar<x, y>" portion gets converted to an AST.
Returns:
[Class(...), ...]
Definition at line 477 of file ast.py.
References cpp.ast.TypeConverter._GetTemplateEnd(), join, and cpp.ast.TypeConverter.ToType().
478 """Convert [Token,...] to [Class(...), ] useful for base classes. 479 For example, code like class Foo : public Bar<x, y> { ... }; 480 the "Bar<x, y>" portion gets converted to an AST. 487 reference = pointer = array =
False 489 def AddType(templated_types):
493 for t
in name_tokens:
494 if keywords.IsKeyword(t.name):
495 modifiers.append(t.name)
498 name =
''.
join(names)
500 result.append(
Type(name_tokens[0].start, name_tokens[-1].end,
501 name, templated_types, modifiers,
502 reference, pointer, array))
509 if token.name ==
'<':
511 AddType(self.
ToType(new_tokens))
515 reference = pointer = array =
False 516 elif token.name ==
',':
518 reference = pointer = array =
False 519 elif token.name ==
'*':
521 elif token.name ==
'&':
523 elif token.name ==
'[':
525 elif token.name ==
']':
528 name_tokens.append(token)
def _GetTemplateEnd(self, tokens, start)
def cpp.ast.TypeConverter.ToType |
( |
|
self, |
|
|
|
tokens |
|
) |
| |
Convert [Token,...] to [Class(...), ] useful for base classes.
For example, code like class Foo : public Bar<x, y> { ... };
the "Bar<x, y>" portion gets converted to an AST.
Returns:
[Class(...), ...]
Definition at line 477 of file ast.py.
References cpp.ast.TypeConverter._GetTemplateEnd(), join, and cpp.ast.TypeConverter.ToType().
Referenced by cpp.ast.TypeConverter.DeclarationToParts(), and cpp.ast.TypeConverter.ToType().
478 """Convert [Token,...] to [Class(...), ] useful for base classes. 479 For example, code like class Foo : public Bar<x, y> { ... }; 480 the "Bar<x, y>" portion gets converted to an AST. 487 reference = pointer = array =
False 489 def AddType(templated_types):
493 for t
in name_tokens:
494 if keywords.IsKeyword(t.name):
495 modifiers.append(t.name)
498 name =
''.
join(names)
500 result.append(
Type(name_tokens[0].start, name_tokens[-1].end,
501 name, templated_types, modifiers,
502 reference, pointer, array))
509 if token.name ==
'<':
511 AddType(self.
ToType(new_tokens))
515 reference = pointer = array =
False 516 elif token.name ==
',':
518 reference = pointer = array =
False 519 elif token.name ==
'*':
521 elif token.name ==
'&':
523 elif token.name ==
'[':
525 elif token.name ==
']':
528 name_tokens.append(token)
def _GetTemplateEnd(self, tokens, start)
def cpp.ast.TypeConverter.ToType |
( |
|
self, |
|
|
|
tokens |
|
) |
| |
Convert [Token,...] to [Class(...), ] useful for base classes.
For example, code like class Foo : public Bar<x, y> { ... };
the "Bar<x, y>" portion gets converted to an AST.
Returns:
[Class(...), ...]
Definition at line 477 of file ast.py.
References cpp.ast.TypeConverter._GetTemplateEnd(), join, and cpp.ast.TypeConverter.ToType().
478 """Convert [Token,...] to [Class(...), ] useful for base classes. 479 For example, code like class Foo : public Bar<x, y> { ... }; 480 the "Bar<x, y>" portion gets converted to an AST. 487 reference = pointer = array =
False 489 def AddType(templated_types):
493 for t
in name_tokens:
494 if keywords.IsKeyword(t.name):
495 modifiers.append(t.name)
498 name =
''.
join(names)
500 result.append(
Type(name_tokens[0].start, name_tokens[-1].end,
501 name, templated_types, modifiers,
502 reference, pointer, array))
509 if token.name ==
'<':
511 AddType(self.
ToType(new_tokens))
515 reference = pointer = array =
False 516 elif token.name ==
',':
518 reference = pointer = array =
False 519 elif token.name ==
'*':
521 elif token.name ==
'&':
523 elif token.name ==
'[':
525 elif token.name ==
']':
528 name_tokens.append(token)
def _GetTemplateEnd(self, tokens, start)
cpp.ast.TypeConverter.namespace_stack |
The documentation for this class was generated from the following file:
- proxygen/fizz/build_/gtest/src/gtest/googlemock/scripts/generator/cpp/ast.py