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 []
76 return "{virtual}Class {cpp_class} : {parent_class}\n"\
77 "{ctors}\n{static_methods}\n{methods}\n{operators}".
format(
81 ctors=
"\n".join([
repr(ctor)
for ctor
in self.
ctors]),
82 static_methods=
"\n".join([
repr(m)
90 Instantiate the inherited parent names. 93 typenames: List of template types to instantiate. 95 Return: List of constructors instantiated with provided template args. 101 parser.Typename(self.namespaces())).typename
107 Instantiate the class constructors. 110 typenames: List of template types to instantiate. 112 Return: List of constructors instantiated with provided template args. 116 instantiation_type=InstantiatedConstructor)
118 instantiated_ctors = helper.multilevel_instantiation(
119 self.
original.ctors, typenames, self)
121 return instantiated_ctors
125 Instantiate static methods in the class. 128 typenames: List of template types to instantiate. 130 Return: List of static methods instantiated with provided template args. 133 instantiation_type=InstantiatedStaticMethod)
135 instantiated_static_methods = helper.multilevel_instantiation(
136 self.
original.static_methods, typenames, self)
138 return instantiated_static_methods
142 Instantiate regular methods in the class. 145 typenames: List of template types to instantiate. 147 Return: List of methods instantiated with provided template args. 149 instantiated_methods = []
153 instantiated_methods = helper.multilevel_instantiation(
154 self.
original.methods, typenames, self)
156 return instantiated_methods
160 Instantiate the class-level template in the operator overload. 163 typenames: List of template types to instantiate. 165 Return: List of methods instantiated with provided template args on the class. 167 instantiated_operators = []
168 for operator
in self.
original.operators:
170 operator.args.list(),
175 instantiated_operators.append(
178 operator=operator.operator,
180 operator.return_type,
185 args=parser.ArgumentList(instantiated_args),
186 is_const=operator.is_const,
189 return instantiated_operators
193 Instantiate the class properties. 196 typenames: List of template types to instantiate. 198 Return: List of properties instantiated with provided template args. 207 instantiated_properties = [
208 parser.Variable(ctype=[arg.ctype],
210 default=arg.default)
for arg
in instantiated_
212 return instantiated_properties
216 Return a parser.Typename including namespaces and cpp name of this 225 namespaces_name = self.namespaces()
226 namespaces_name.append(name)
227 return parser.Typename(namespaces_name)
230 """Generate the C++ code for wrapping."""
def instantiate_args_list
bool isinstance(handle obj)
def instantiate_properties(self, typenames)
def instantiate_static_methods(self, typenames)
def instantiate_parent_class(self, typenames)
def instantiate_methods(self, typenames)
def instantiate_ctors(self, typenames)
std::string format(const std::string &str, const std::vector< std::string > &find, const std::vector< std::string > &replace)
def instantiate_operators(self, typenames)
def instantiate_return_type
size_t len(handle h)
Get the length of a Python object.