9 if not os.path.exists(filepath):
12 with
open(filepath,
"r") as f:
13 return "".
join(f.readlines())
19 _generated_header_files = []
27 return cls._file_counter
35 cls._file_counter += 1
39 raise NotImplementedError()
43 raise NotImplementedError()
47 return cls.file_counter()
52 return os.path.join(self.
dirname, filename)
60 BaseGenerateFiles._generated_header_files.append(hpp_filename)
62 cpp_content = self._generate_cpp_content(chunk, hpp_filename, fileno)
63 hpp_content = self._generate_hpp_content(chunk, fileno)
68 if cpp_content == cpp_ec
and hpp_content == hpp_ec:
71 with
open(cpp_filename,
"w")
as f:
74 with
open(hpp_filename,
"w")
as f:
95 def __init__(self, dirname, stmts, header_file, kind):
96 assert kind
in (
"cpu",
"gpu")
100 GenerateTemplateFiles,
102 ).
__init__(dirname=dirname, kind=kind)
106 return "TableFunctionsFactory_init"
109 return "%s_%s_%s.%s" % (prefix, kind, fileno, ext)
113 for func
in cpp_functions:
114 header = func.split(
"{", 1)[0].rstrip() +
";"
121 This file is generated by %s. Do no edit!
128 content = textwrap.dedent(content)
129 funcs_formatted =
'\n'.
join(stmts)
130 return content % (sys.argv[0], hpp_filename, funcs_formatted)
135 This file is generated by %s. Do no edit!
141 content = textwrap.dedent(content)
145 return content % (sys.argv[0], self.
header_file, decls)
156 super(GenerateAddTableFunctionsFiles, self).
__init__(dirname=dirname, kind=
"")
160 return "TableFunctionsFactory_add"
163 return "%s_%s.%s" % (prefix, fileno, ext)
166 return len(self.
stmts) > 0
171 This file is generated by %s. Do no edit!
174 #include "QueryEngine/TableFunctions/TableFunctionsFactory.h"
177 namespace table_functions {
179 NO_OPT_ATTRIBUTE void add_table_functions_%d() {
185 content = textwrap.dedent(content)
186 chunk =
'\n '.
join(chunk)
187 return content % (sys.argv[0], hpp_filename, fileno, chunk)
192 This file is generated by %s. Do no edit!
195 #include "QueryEngine/TableFunctions/TableFunctionsFactory.h"
198 #if defined(__clang__)
199 #define NO_OPT_ATTRIBUTE __attribute__((optnone))
201 #elif defined(__GNUC__) || defined(__GNUG__)
202 #define NO_OPT_ATTRIBUTE __attribute((optimize("O0")))
204 #elif defined(_MSC_VER)
205 #define NO_OPT_ATTRIBUTE
209 namespace table_functions {
210 NO_OPT_ATTRIBUTE void add_table_functions_%s();
214 content = textwrap.dedent(content)
215 return content % (sys.argv[0], self.
header_file, fileno)
def should_generate_files
def should_generate_files
def generated_header_files
def increment_file_counter
def _generate_cpp_content
def _generate_hpp_content
def _split_stmts_into_chunks
def get_existing_file_content
int open(const char *path, int flags, int mode)
def _generate_cpp_content
list _generated_header_files
def _get_decl_from_cpp_functions
def get_num_generated_files
def _generate_hpp_content