proxygen
cpp.ast Namespace Reference

Classes

class  _GenericDeclaration
 
class  _NestedType
 
class  _NullDict
 
class  AstBuilder
 
class  Class
 
class  Define
 
class  Delete
 
class  Enum
 
class  Expr
 
class  Friend
 
class  Function
 
class  Goto
 
class  Include
 
class  Method
 
class  Node
 
class  Parameter
 
class  Return
 
class  Struct
 
class  Type
 
class  TypeConverter
 
class  Typedef
 
class  Union
 
class  Using
 
class  VariableDeclaration
 

Functions

def reversed (seq)
 
def next (obj)
 
def BuilderFromSource (source, filename)
 
def PrintIndentifiers (filename, should_print)
 
def PrintAllIndentifiers (filenames, should_print)
 
def main (argv)
 

Variables

string __author__ = 'nnorwitz@google.com (Neal Norwitz)'
 
int FUNCTION_NONE = 0x00
 
int FUNCTION_CONST = 0x01
 
int FUNCTION_VIRTUAL = 0x02
 
int FUNCTION_PURE_VIRTUAL = 0x04
 
int FUNCTION_CTOR = 0x08
 
int FUNCTION_DTOR = 0x10
 
int FUNCTION_ATTRIBUTE = 0x20
 
int FUNCTION_UNKNOWN_ANNOTATION = 0x40
 
int FUNCTION_THROW = 0x80
 
int FUNCTION_OVERRIDE = 0x100
 
string _INTERNAL_TOKEN = 'internal'
 
string _NAMESPACE_POP = 'ns-pop'
 

Function Documentation

def cpp.ast.BuilderFromSource (   source,
  filename 
)
Utility method that returns an AstBuilder from source code.

Args:
  source: 'C++ source code'
  filename: 'file1'

Returns:
  AstBuilder

Definition at line 1663 of file ast.py.

Referenced by cpp.ast.AstBuilder.handle_continue(), cpp.ast.main(), and cpp.ast.PrintIndentifiers().

1663 def BuilderFromSource(source, filename):
1664  """Utility method that returns an AstBuilder from source code.
1665 
1666  Args:
1667  source: 'C++ source code'
1668  filename: 'file1'
1669 
1670  Returns:
1671  AstBuilder
1672  """
1673  return AstBuilder(tokenize.GetTokens(source), filename)
1674 
1675 
def BuilderFromSource(source, filename)
Definition: ast.py:1663
def cpp.ast.main (   argv)

Definition at line 1711 of file ast.py.

References cpp.ast.BuilderFromSource(), and folly::pushmi::operators.filter.

Referenced by cpp.ast.AstBuilder.handle_continue().

1711 def main(argv):
1712  for filename in argv[1:]:
1713  source = utils.ReadFile(filename)
1714  if source is None:
1715  continue
1716 
1717  print('Processing %s' % filename)
1718  builder = BuilderFromSource(source, filename)
1719  try:
1720  entire_ast = filter(None, builder.Generate())
1721  except KeyboardInterrupt:
1722  return
1723  except:
1724  # Already printed a warning, print the traceback and continue.
1725  traceback.print_exc()
1726  else:
1727  if utils.DEBUG:
1728  for ast in entire_ast:
1729  print(ast)
1730 
1731 
PUSHMI_INLINE_VAR constexpr detail::filter_fn filter
Definition: filter.h:75
def BuilderFromSource(source, filename)
Definition: ast.py:1663
def main(argv)
Definition: ast.py:1711
def cpp.ast.next (   obj)

Definition at line 58 of file ast.py.

References folly::gen.range().

Referenced by gdb.GetFiberXMethodWorker.__call__(), cpp.ast.AstBuilder._GetNextToken(), folly::UnboundedQueue< T, false, 6 >.advanceHead(), folly::UnboundedQueue< T, false, 6 >.advanceHeadToTicket(), folly::UnboundedQueue< T, false, 6 >.advanceTail(), folly::UnboundedQueue< T, false, 6 >.advanceTailToTicket(), folly::UnboundedQueue< T, false, 6 >.allocNextSegment(), folly::AsyncSocket::WriteRequest.append(), folly::hazptr_domain< DeterministicAtomic >.bulk_lookup_and_reclaim(), folly::UnboundedQueue< T, false, 6 >.casHead(), folly::UnboundedQueue< T, SingleProducer, SingleConsumer, MayBlock, LgSegmentSize, LgAlign, Atom >::Segment.casNextSegment(), folly::UnboundedQueue< T, false, 6 >.casTail(), folly::FlatCombining< FcSimpleExample< Mutex, Atom >, Mutex, Atom >.combiningPass(), folly::HazptrSWMRSet< T, Atom >.contains(), proxygen::GzipHeaderCodec.decode(), folly::threadlocal_detail::StaticMetaBase.destroy(), destruction_test(), folly::detail::distributed_mutex::DistributedMutex< Atomic, TimePublishing >::DistributedMutexStateProxy< Atomic, TimePublishing >.DistributedMutexStateProxy(), proxygen::HTTPMessage.doHeaderTokenCheck(), proxygen::HPACKQueue.drainQueue(), folly::exception_tracer::StackTraceStack.empty(), proxygen::StructuredHeadersEncoder.encodeDictionary(), proxygen::StructuredHeadersEncoder.encodeList(), proxygen::StructuredHeadersEncoder.encodeParameterisedList(), folly::detail::ConcurrentHashMapSegment< KeyType, ValueType, ShardBits, HashFn, KeyEqual, Allocator, Atom, Mutex >.erase_internal(), folly::for_each_detail.for_each_range_impl(), folly::detail::ThreadCachedLists< Tag >::ListHead.forEach(), folly::hazptr_domain< DeterministicAtomic >.free_hazptr_recs(), folly::UnboundedQueue< T, false, 6 >.getAllocNextSegment(), cpp.ast.AstBuilder.GetName(), folly::threadlocal_detail::ThreadEntryNode.getNext(), folly::AsyncSSLSocket.getRawBytesWritten(), folly::rcu_domain< Tag >.half_sync(), List< T, Atom >.hand_over_hand(), folly::detail::ConcurrentHashMapSegment< KeyType, ValueType, ShardBits, HashFn, KeyEqual, Allocator, Atom, Mutex >.insert_internal(), folly::IndexedMemPool< T, NumLocalLists_, LocalListLimit_, Atom, Traits >.localPop(), folly::detail::distributed_mutex::DistributedMutex< Atomic, TimePublishing >.lock(), folly::TDigest.merge(), folly::pushmi::detail::switch_on_error_fn::on_error_impl< ErrorSelector >.operator()(), folly::detail::ConcurrentHashMapSegment< KeyType, ValueType, ShardBits, HashFn, KeyEqual, Allocator, Atom, Mutex >::Iterator.operator++(), proxygen::GzipHeaderCodec.parseNameValues(), poolPutIOBuf(), folly::HazptrLockFreeLIFO< T, Atom >.pop(), folly::IOBuf.pop(), List< T, Atom >.protect_all(), NodeRC< Mutable, Atom >.push_links(), folly::hazptr_domain< DeterministicAtomic >.reclaim_all_objects(), folly::UnboundedQueue< T, false, 6 >.reclaimRemainingSegments(), folly::ThreadPoolExecutor::ThreadList.remove(), folly::symbolizer::Dwarf::Section.Section(), folly::FlatCombining< T, Mutex, Atom, Req >::Rec.setNext(), folly::compression::BitVectorReader< Encoder, Instructions, kUnchecked >.skip(), folly::compression::BitVectorReader< Encoder, Instructions, kUnchecked >.skipTo(), folly::compression::detail::UpperBitsReader< Encoder, Instructions, SizeType >.skipToNext(), folly::Range< unsigned char * >.split_step(), TEST(), fizz::test.TEST_F(), folly::sync_tests.testExchange(), folly::hazptr_domain< DeterministicAtomic >.try_acquire_existing_hprec(), folly::detail::distributed_mutex.tryWake(), u64ToAsciiClassic(), u64ToAsciiTable(), folly::detail::ConcurrentHashMapSegment< KeyType, ValueType, ShardBits, HashFn, KeyEqual, Allocator, Atom, Mutex >::Buckets.unlink_and_reclaim_nodes(), folly::detail::distributed_mutex::DistributedMutex< Atomic, TimePublishing >.unlock(), folly::detail::distributed_mutex.wake(), TestAsyncTransport.writeChain(), proxygen::GenericFilter< TesterInterface, TesterInterface::Callback,&TesterInterface::setCallback, Owned >.~GenericFilter(), folly::HazptrLockFreeLIFO< T, Atom >.~HazptrLockFreeLIFO(), folly::HazptrSWMRSet< T, Atom >.~HazptrSWMRSet(), and List< T, Atom >.~List().

58  def next(obj):
59  return obj.next()
60 
61 
62 VISIBILITY_PUBLIC, VISIBILITY_PROTECTED, VISIBILITY_PRIVATE = range(3)
63 
Gen range(Value begin, Value end)
Definition: Base.h:467
def next(obj)
Definition: ast.py:58
def cpp.ast.PrintAllIndentifiers (   filenames,
  should_print 
)
Prints all identifiers for each C++ source file in filenames.

Args:
  filenames: ['file1', 'file2', ...]
  should_print: predicate with signature: bool Function(token)

Definition at line 1700 of file ast.py.

References cpp.ast.PrintIndentifiers().

Referenced by cpp.ast.AstBuilder.handle_continue().

1700 def PrintAllIndentifiers(filenames, should_print):
1701  """Prints all identifiers for each C++ source file in filenames.
1702 
1703  Args:
1704  filenames: ['file1', 'file2', ...]
1705  should_print: predicate with signature: bool Function(token)
1706  """
1707  for path in filenames:
1708  PrintIndentifiers(path, should_print)
1709 
1710 
def PrintAllIndentifiers(filenames, should_print)
Definition: ast.py:1700
def PrintIndentifiers(filename, should_print)
Definition: ast.py:1676
def cpp.ast.PrintIndentifiers (   filename,
  should_print 
)
Prints all identifiers for a C++ source file.

Args:
  filename: 'file1'
  should_print: predicate with signature: bool Function(token)

Definition at line 1676 of file ast.py.

References cpp.ast.BuilderFromSource().

Referenced by cpp.ast.AstBuilder.handle_continue(), and cpp.ast.PrintAllIndentifiers().

1676 def PrintIndentifiers(filename, should_print):
1677  """Prints all identifiers for a C++ source file.
1678 
1679  Args:
1680  filename: 'file1'
1681  should_print: predicate with signature: bool Function(token)
1682  """
1683  source = utils.ReadFile(filename, False)
1684  if source is None:
1685  sys.stderr.write('Unable to find: %s\n' % filename)
1686  return
1687 
1688  #print('Processing %s' % actual_filename)
1689  builder = BuilderFromSource(source, filename)
1690  try:
1691  for node in builder.Generate():
1692  if should_print(node):
1693  print(node.name)
1694  except KeyboardInterrupt:
1695  return
1696  except:
1697  pass
1698 
1699 
def BuilderFromSource(source, filename)
Definition: ast.py:1663
def PrintIndentifiers(filename, should_print)
Definition: ast.py:1676
def cpp.ast.reversed (   seq)

Definition at line 52 of file ast.py.

References folly::gen.range().

Referenced by cpp.ast.AstBuilder._AddBackTokens(), and cpp.ast.AstBuilder.HandleError().

52  def reversed(seq):
53  for i in range(len(seq)-1, -1, -1):
54  yield seq[i]
55 
Gen range(Value begin, Value end)
Definition: Base.h:467
def reversed(seq)
Definition: ast.py:52

Variable Documentation

string cpp.ast.__author__ = 'nnorwitz@google.com (Neal Norwitz)'
private

Definition at line 20 of file ast.py.

string cpp.ast._INTERNAL_TOKEN = 'internal'
private

Definition at line 97 of file ast.py.

string cpp.ast._NAMESPACE_POP = 'ns-pop'
private

Definition at line 98 of file ast.py.

int cpp.ast.FUNCTION_ATTRIBUTE = 0x20

Definition at line 70 of file ast.py.

int cpp.ast.FUNCTION_CONST = 0x01

Definition at line 65 of file ast.py.

int cpp.ast.FUNCTION_CTOR = 0x08

Definition at line 68 of file ast.py.

int cpp.ast.FUNCTION_DTOR = 0x10

Definition at line 69 of file ast.py.

int cpp.ast.FUNCTION_NONE = 0x00

Definition at line 64 of file ast.py.

int cpp.ast.FUNCTION_OVERRIDE = 0x100

Definition at line 73 of file ast.py.

int cpp.ast.FUNCTION_PURE_VIRTUAL = 0x04

Definition at line 67 of file ast.py.

int cpp.ast.FUNCTION_THROW = 0x80

Definition at line 72 of file ast.py.

int cpp.ast.FUNCTION_UNKNOWN_ANNOTATION = 0x40

Definition at line 71 of file ast.py.

int cpp.ast.FUNCTION_VIRTUAL = 0x02

Definition at line 66 of file ast.py.