1 """Instantiate a namespace.""" 13 Instantiate the classes and other elements in the `namespace` content and 14 assign it back to the namespace content attribute. 16 @param[in/out] namespace The namespace whose content will be replaced with 17 the instantiated content. 19 instantiated_content = []
22 for element
in namespace.content:
24 original_class = element
25 if not original_class.template:
26 instantiated_content.append(
33 for instantiations
in itertools.product(
34 *original_class.template.instantiations):
35 instantiated_content.append(
37 list(instantiations)))
39 elif isinstance(element, parser.GlobalFunction):
40 original_func = element
41 if not original_func.template:
42 instantiated_content.append(
47 for instantiations
in itertools.product(
48 *original_func.template.instantiations):
49 instantiated_content.append(
51 list(instantiations)))
53 elif isinstance(element, parser.TypedefTemplateInstantiation):
56 typedef_inst = element
57 top_level = namespace.top_level()
58 original_element = top_level.find_class_or_function(
59 typedef_inst.typename)
64 typedef_content.append(
66 typedef_inst.typename.instantiations,
67 typedef_inst.new_name))
68 elif isinstance(original_element, parser.GlobalFunction):
69 typedef_content.append(
71 original_element, typedef_inst.typename.instantiations,
72 typedef_inst.new_name))
73 elif isinstance(original_element, parser.ForwardDeclaration):
74 typedef_content.append(
76 original_element, typedef_inst.typename.instantiations,
77 typedef_inst.new_name))
81 instantiated_content.append(element)
83 instantiated_content.append(element)
85 instantiated_content.extend(typedef_content)
86 namespace.content = instantiated_content
bool isinstance(handle obj)
def instantiate_namespace(namespace)