def build_value(self, builder, function): begin = "{}({}".format(self.build(builder), builder.get_name(function)) variables = sorted_variables(function.get_variables()) if variables: return "{}({}))".format(begin, ",".join(v.build(builder) for v in variables)) return "{})".format(begin)
def build_function(self, function, prefix=""): function_name = self.get_name(function) variables = sorted_variables(function.get_variables()) if variables: v = ",".join(prefix + v.build(self) for v in variables) return "({}({}))".format(function_name, v) else: return "{}".format(function_name)
def build_functor(self, function): function_name = self.get_autoname(function) variables = sorted_variables(function.get_variables()) if variables: v = ",".join(v.build(self) for v in variables) return "({}({}))".format(function_name, v) else: return "{}()".format(function_name)
def declare_function(self, function): if self.check_declaration_key(function): return function_name = self.get_name(function) variables = function.get_variables() if function.is_external(): self.include_filename(self.env.get_function_filename(function)) if not variables: decl = function.build_declaration(self, function_name) self.writer.line("{}", decl) self.writer.block_begin() function.write_code(self) self.writer.block_end() self.writer.emptyline() return variables = sorted_variables(variables) self.writer.class_begin(function_name) self.writer.line("public:") variables = sorted_variables(variables) self.writer.line("{}({}) : {} {{}}", function_name, ",".join("const {} &{}".format(v.type.build(self), v.build(self)) for v in variables), ",".join("{0}({0})".format(v.build(self)) for v in variables)) self.writer.line("{}", function.build_declaration(self, "operator()")) self.writer.block_begin() function.write_code(self) self.writer.block_end() for variable in variables: self.writer.line("const {} &{};", variable.type.build(self), variable.build(self)); self.writer.class_end() self.writer.emptyline()
def declare_function(self, function): if self.check_declaration_key(function): return if function.is_external(): self.include_filename(self.env.get_function_filename(function)) function_name = self.get_autoname(function) self.writer.class_begin(function_name) self.writer.line("public:") variables = function.get_variables() if variables: variables = sorted_variables(variables) self.writer.line("{}({}) : {} {{}}", function_name, ",".join("const {} &{}".format(v.type.build(self), v.name) for v in variables), ",".join("{0}({0})".format(v.name) for v in variables)) params = [ p.type.build_param(self, p.name, p.const) for p in function.params ] self.writer.line("{} operator()({})", function.return_type.build(self) if function.return_type else "void", ",".join(params)) self.writer.block_begin() function.write_code(self) self.writer.block_end() for variable in variables: self.writer.line("const {} &{};", variable.type.build(self), variable.name); self.writer.class_end()