interface_parser/declaration.py
Go to the documentation of this file.
1 """
2 GTSAM Copyright 2010-2020, Georgia Tech Research Corporation,
3 Atlanta, Georgia 30332-0415
4 All Rights Reserved
5 
6 See LICENSE for the license information
7 
8 Classes and rules for declarations such as includes and forward declarations.
9 
10 Author: Duy Nguyen Ta, Fan Jiang, Matthew Sklar, Varun Agrawal, and Frank Dellaert
11 """
12 
13 from pyparsing import CharsNotIn, Optional # type: ignore
14 
15 from .tokens import (CLASS, COLON, INCLUDE, LOPBRACK, ROPBRACK, SEMI_COLON,
16  VIRTUAL)
17 from .type import Typename
18 from .utils import collect_namespaces
19 
20 
21 class Include:
22  """
23  Rule to parse #include directives.
24  """
25  rule = (INCLUDE + LOPBRACK + CharsNotIn('>')("header") +
26  ROPBRACK).setParseAction(lambda t: Include(t.header))
27 
28  def __init__(self, header: CharsNotIn, parent: str = ''):
29  self.header = header
30  self.parent = parent
31 
32  def __repr__(self) -> str:
33  return "#include <{}>".format(self.header)
34 
35 
37  """
38  Rule to parse forward declarations in the interface file.
39  """
40  rule = (Optional(VIRTUAL("is_virtual")) + CLASS + Typename.rule("name") +
41  Optional(COLON + Typename.rule("parent_type")) +
42  SEMI_COLON).setParseAction(lambda t: ForwardDeclaration(
43  t.name, t.parent_type, t.is_virtual))
44 
45  def __init__(self,
46  typename: Typename,
47  parent_type: str,
48  is_virtual: str,
49  parent: str = ''):
50  self.name = typename.name
51  self.typename = typename
52  if parent_type:
53  self.parent_type = parent_type
54  else:
55  self.parent_type = ''
56 
57  self.is_virtual = is_virtual
58  self.parent = parent
59 
60  def namespaces(self) -> list:
61  """Get the namespaces which this class is nested under as a list."""
62  return collect_namespaces(self)
63 
64  def __repr__(self) -> str:
65  return "ForwardDeclaration: {} {}".format(self.is_virtual, self.name)
gtwrap.interface_parser.declaration.ForwardDeclaration.parent
parent
Definition: interface_parser/declaration.py:54
gtwrap.interface_parser.declaration.ForwardDeclaration.is_virtual
is_virtual
Definition: interface_parser/declaration.py:53
format
std::string format(const std::string &str, const std::vector< std::string > &find, const std::vector< std::string > &replace)
Definition: openglsupport.cpp:226
gtwrap.interface_parser.declaration.ForwardDeclaration.namespaces
list namespaces(self)
Definition: interface_parser/declaration.py:60
gtwrap.interface_parser.declaration.Include.header
header
Definition: interface_parser/declaration.py:29
gtwrap.interface_parser.declaration.ForwardDeclaration.__init__
def __init__(self, Typename typename, str parent_type, str is_virtual, str parent='')
Definition: interface_parser/declaration.py:45
gtwrap.interface_parser.utils.collect_namespaces
def collect_namespaces(obj)
Definition: utils.py:14
gtwrap.interface_parser.declaration.Include
Definition: interface_parser/declaration.py:21
gtwrap.interface_parser.declaration.ForwardDeclaration.__repr__
str __repr__(self)
Definition: interface_parser/declaration.py:64
gtwrap.interface_parser.declaration.ForwardDeclaration.name
name
Definition: interface_parser/declaration.py:46
gtwrap.interface_parser.declaration.Include.__init__
def __init__(self, CharsNotIn header, str parent='')
Definition: interface_parser/declaration.py:28
gtwrap.interface_parser.declaration.ForwardDeclaration.parent_type
parent_type
Definition: interface_parser/declaration.py:49
gtwrap.interface_parser.declaration.Include.__repr__
str __repr__(self)
Definition: interface_parser/declaration.py:32
gtwrap.interface_parser.declaration.Include.parent
parent
Definition: interface_parser/declaration.py:30
gtwrap.interface_parser.declaration.ForwardDeclaration.typename
typename
Definition: interface_parser/declaration.py:47
gtwrap.interface_parser.declaration.ForwardDeclaration
Definition: interface_parser/declaration.py:36
gtwrap.interface_parser.tokens.VIRTUAL
VIRTUAL
Definition: tokens.py:42


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:32:23