comparison test/suite_aggrs/mk-cases.lua @ 438:b4ddad459690

suite_aggr; - made generator produce unique signatures - reduced dcNewStruct() calls to once only per sig - added missing free()s - cleanup: removal of unused decl, func renaming for clarity, static for tu-local symbols, ...
author Tassilo Philipp
date Wed, 26 Jan 2022 13:37:19 +0100
parents a29baee68340
children e59e381b4fca
comparison
equal deleted inserted replaced
437:135c7fb49c2f 438:b4ddad459690
159 end 159 end
160 io.write(table.concat(b,o[t+4]).."; };\n") 160 io.write(table.concat(b,o[t+4]).."; };\n")
161 end 161 end
162 162
163 -- convenient dcnewstruct helper funcs 163 -- convenient dcnewstruct helper funcs
164 io.write('DCstruct* f_newdcst'..v[2]..'() {\n\tDCstruct* st = dcNewStruct('..(#v[1]>>1)..', sizeof('..st..'), 0, 1);\n\t') 164 io.write('DCstruct* f_touchdcst'..v[2]..'() {\n\tstatic DCstruct* st = NULL;\n\tif(!st) {\n\t\tst = dcNewStruct('..(#v[1]>>1)..', sizeof('..st..'), DC_TRUE);\n\t\t')
165 for i = 1, #v[1], 2 do 165 for i = 1, #v[1], 2 do
166 if string.match(v[1][i], '^struct') then 166 if string.match(v[1][i], '^struct') then
167 io.write('dcStructField(st, DC_SIGCHAR_STRUCT, offsetof('..st..', '..v[1][i+1]..'), 1, f_newdcst'..v[1][i]:sub(8)..'());\n\t') 167 io.write('dcStructField(st, DC_SIGCHAR_STRUCT, offsetof('..st..', '..v[1][i+1]..'), 1, f_touchdcst'..v[1][i]:sub(8)..'());\n\t\t')
168 else 168 else
169 io.write("dcStructField(st, '"..v[1][i].."', offsetof("..st..', '..v[1][i+1]..'), 1);\n\t') 169 io.write("dcStructField(st, '"..v[1][i].."', offsetof("..st..', '..v[1][i+1]..'), 1);\n\t\t')
170 end 170 end
171 end 171 end
172 io.write("dcCloseStruct(st);\n\treturn st;\n};\n") 172 io.write("dcCloseStruct(st);\n\t}\n\treturn st;\n};\n")
173 end 173 end
174 174
175 -- make table.concat work 175 -- make table.concat work
176 if #agg_names > 0 then 176 if #agg_names > 0 then
177 table.insert(agg_names, 1, '') 177 table.insert(agg_names, 1, '')
180 io.write(cases) 180 io.write(cases)
181 io.write(mkfuntab(lineno)) 181 io.write(mkfuntab(lineno))
182 io.write(mksigtab(sigtab)) 182 io.write(mksigtab(sigtab))
183 io.write('const char* G_agg_sigs[] = {\n\t"'..table.concat(agg_sigs, '",\n\t"')..'"\n};\n') 183 io.write('const char* G_agg_sigs[] = {\n\t"'..table.concat(agg_sigs, '",\n\t"')..'"\n};\n')
184 io.write('int G_agg_sizes[] = {\n\t'..table.concat(agg_sizes, ',\n\t')..'\n};\n') 184 io.write('int G_agg_sizes[] = {\n\t'..table.concat(agg_sizes, ',\n\t')..'\n};\n')
185 io.write('funptr G_agg_newdcstfuncs[] = {'..string.sub(table.concat(agg_names, ',\n\t(funptr)&f_newdcst'),2)..'\n};\n') 185 io.write('funptr G_agg_touchdcstfuncs[] = {'..string.sub(table.concat(agg_names, ',\n\t(funptr)&f_touchdcst'),2)..'\n};\n')
186 io.write('funptr G_agg_cmpfuncs[] = {'..string.sub(table.concat(agg_names, ',\n\t(funptr)&f_cmp'),2)..'\n};\n') 186 io.write('funptr G_agg_cmpfuncs[] = {'..string.sub(table.concat(agg_names, ',\n\t(funptr)&f_cmp'),2)..'\n};\n')
187 io.write("int G_maxargs = "..maxargs..";\n") 187 io.write("int G_maxargs = "..maxargs..";\n")
188 end 188 end
189 189
190 mkall() 190 mkall()