def visit_FunctionDef(self, node): body = "\n".join([self.visit(n) for n in node.body]) if (self.use_catch_test_cases and is_void_function(node) and node.name.startswith("test")): return generate_catch_test_case(node, body) # is_void_function(node) or is_recursive(node): return generate_template_fun(node, body)
def generate_template_fun(node, body): params = [] for idx, arg in enumerate(node.args.args): params.append(("T" + str(idx + 1), arg.id)) typenames = ["typename " + arg[0] for arg in params] template = "inline " if len(typenames) > 0: template = "template <{0}>\n".format(", ".join(typenames)) params = ["{0} {1}".format(arg[0], arg[1]) for arg in params] return_type = "auto" if is_void_function(node): return_type = "void" funcdef = "{0}{1} {2}({3})".format(template, return_type, node.name, ", ".join(params)) return funcdef + " {\n" + body + "\n}"