comparison test/suite_aggrs/mk-cases.lua @ 435:a29baee68340

- suite_aggrs: simplified nested struct handling given upcoming api simplification (still not in depo, though, so test is ahead)
author Tassilo Philipp
date Mon, 24 Jan 2022 12:41:27 +0100
parents 3d2c5d156d78
children b4ddad459690
comparison
equal deleted inserted replaced
434:3d2c5d156d78 435:a29baee68340
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('static int nfields'..v[2]..' = '..(#v[1]>>1)..';\n') 164 io.write('DCstruct* f_newdcst'..v[2]..'() {\n\tDCstruct* st = dcNewStruct('..(#v[1]>>1)..', sizeof('..st..'), 0, 1);\n\t')
165 io.write('DCstruct* f_newdcst'..v[2]..'(DCstruct* parent) {\n\tDCstruct* st = parent;\n\tif(!st) st = dcNewStruct(nfields'..v[2]..', sizeof('..st..'), 0, 1);\n\t')
166 for i = 1, #v[1], 2 do 165 for i = 1, #v[1], 2 do
167 if string.match(v[1][i], '^struct') then 166 if string.match(v[1][i], '^struct') then
168 io.write('dcSubStruct(st, nfields'..v[1][i]:sub(8)..', offsetof('..st..', '..v[1][i+1]..'), sizeof('..v[1][i]..'), 0, DC_TRUE, 1);\n\t') 167 io.write('dcStructField(st, DC_SIGCHAR_STRUCT, offsetof('..st..', '..v[1][i+1]..'), 1, f_newdcst'..v[1][i]:sub(8)..'());\n\t')
169 io.write("f_newdcst"..v[1][i]:sub(8)..'(st);\n\t')
170 else 168 else
171 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')
172 end 170 end
173 end 171 end
174 io.write("dcCloseStruct(st);\n\treturn st;\n};\n") 172 io.write("dcCloseStruct(st);\n\treturn st;\n};\n")