template_instantiator/declaration.py
Go to the documentation of this file.
1 """Instantiate a forward declaration."""
2 
3 import gtwrap.interface_parser as parser
4 from gtwrap.template_instantiator.helpers import instantiate_name
5 
6 
7 class InstantiatedDeclaration(parser.ForwardDeclaration):
8  """
9  Instantiate typedefs of forward declarations.
10  This is useful when we wish to typedef a templated class
11  which is not defined in the current project.
12 
13  E.g.
14  class FactorFromAnotherMother;
15 
16  typedef FactorFromAnotherMother<gtsam::Pose3> FactorWeCanUse;
17  """
18  def __init__(self, original, instantiations=(), new_name=''):
19  super().__init__(original.typename,
20  original.parent_type,
21  original.is_virtual,
22  parent=original.parent)
23 
24  self.original = original
25  self.instantiations = instantiations
26  self.parent = original.parent
27 
29  original.name, instantiations) if not new_name else new_name
30 
31  def to_cpp(self):
32  """Generate the C++ code for wrapping."""
33  instantiated_names = [
34  inst.qualified_name() for inst in self.instantiations
35  ]
36  name = "{}<{}>".format(self.original.name,
37  ",".join(instantiated_names))
38  namespaces_name = self.namespaces()
39  namespaces_name.append(name)
40  # Leverage Typename to generate the fully qualified C++ name
41  return parser.Typename(namespaces_name).to_cpp()
42 
43  def __repr__(self):
44  return "Instantiated {}".format(
45  super(InstantiatedDeclaration, self).__repr__())
gtwrap.template_instantiator.declaration.InstantiatedDeclaration
Definition: template_instantiator/declaration.py:7
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.template_instantiator.declaration.InstantiatedDeclaration.__repr__
def __repr__(self)
Definition: template_instantiator/declaration.py:43
gtwrap.template_instantiator.declaration.InstantiatedDeclaration.instantiations
instantiations
Definition: template_instantiator/declaration.py:25
gtwrap.template_instantiator.declaration.InstantiatedDeclaration.__init__
def __init__(self, original, instantiations=(), new_name='')
Definition: template_instantiator/declaration.py:18
gtwrap.template_instantiator.helpers
Definition: helpers.py:1
gtwrap.template_instantiator.declaration.InstantiatedDeclaration.to_cpp
def to_cpp(self)
Definition: template_instantiator/declaration.py:31
gtwrap.template_instantiator.declaration.InstantiatedDeclaration.name
name
Definition: template_instantiator/declaration.py:28
gtwrap.template_instantiator.declaration.InstantiatedDeclaration.parent
parent
Definition: template_instantiator/declaration.py:26
gtwrap.template_instantiator.declaration.InstantiatedDeclaration.original
original
Definition: template_instantiator/declaration.py:24
gtwrap.template_instantiator.helpers.instantiate_name
def instantiate_name(str original_name, Sequence[parser.Typename] instantiations)
Definition: helpers.py:196
gtwrap.interface_parser
Definition: wrap/gtwrap/interface_parser/__init__.py:1


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:10