1 """Instantiate a class and its members.""" 
    8                                                   instantiate_return_type,
 
   11                                                  InstantiatedStaticMethod)
 
   16     Instantiate the class defined in the interface file. 
   19     def __init__(self, original: parser.Class, instantiations=(), new_name=
''):
 
   22         Instantiations: [T1, U1] 
   34             assert len(original.template.typenames) == 
len(
 
   35                 instantiations), 
"Typenames and instantiations mismatch!" 
   39             original.name, instantiations) 
if not new_name 
else new_name
 
   44         typenames = self.
original.template.typenames 
if self.
original.template 
else []
 
   79         return "{virtual}Class {cpp_class} : {parent_class}\n"\
 
   80             "{ctors}\n{static_methods}\n{methods}\n{operators}".
format(
 
   84                ctors=
"\n".join([
repr(ctor) 
for ctor 
in self.
ctors]),
 
   85                static_methods=
"\n".join([
repr(m)
 
   93         Instantiate the inherited parent names. 
   96             typenames: List of template types to instantiate. 
   98         Return: List of constructors instantiated with provided template args. 
  104                 parser.Typename(self.namespaces())).typename
 
  110         Instantiate the class constructors. 
  113             typenames: List of template types to instantiate. 
  115         Return: List of constructors instantiated with provided template args. 
  119             instantiation_type=InstantiatedConstructor)
 
  121         instantiated_ctors = helper.multilevel_instantiation(
 
  122             self.
original.ctors, typenames, self)
 
  124         return instantiated_ctors
 
  128         Instantiate static methods in the class. 
  131             typenames: List of template types to instantiate. 
  133         Return: List of static methods instantiated with provided template args. 
  136             instantiation_type=InstantiatedStaticMethod)
 
  138         instantiated_static_methods = helper.multilevel_instantiation(
 
  139             self.
original.static_methods, typenames, self)
 
  141         return instantiated_static_methods
 
  145         Instantiate regular methods in the class. 
  148             typenames: List of template types to instantiate. 
  150         Return: List of methods instantiated with provided template args. 
  152         instantiated_methods = []
 
  156         instantiated_methods = helper.multilevel_instantiation(
 
  157             self.
original.methods, typenames, self)
 
  159         return instantiated_methods
 
  163         Instantiate the class-level template in the operator overload. 
  166             typenames: List of template types to instantiate. 
  168         Return: List of methods instantiated with provided template args on the class. 
  170         instantiated_operators = []
 
  171         for operator 
in self.
original.operators:
 
  173                 operator.args.list(),
 
  178             instantiated_operators.append(
 
  181                     operator=operator.operator,
 
  183                         operator.return_type,
 
  188                     args=parser.ArgumentList(instantiated_args),
 
  189                     is_const=operator.is_const,
 
  192         return instantiated_operators
 
  196         Instantiate the class properties. 
  199             typenames: List of template types to instantiate. 
  201         Return: List of properties instantiated with provided template args. 
  210         instantiated_properties = [
 
  211             parser.Variable(ctype=[arg.ctype],
 
  213                             default=arg.default) 
for arg 
in instantiated_
 
  215         return instantiated_properties
 
  219         Return a parser.Typename including namespaces and cpp name of this 
  228         namespaces_name = self.namespaces()
 
  229         namespaces_name.append(name)
 
  230         return parser.Typename(namespaces_name)
 
  233         """Generate the C++ code for wrapping."""