annotate test/suite_aggrs/mk-cases.lua @ 433:45662241d9cd

suite_aggrs now handling struct by value return types, also still missing: nesting, unions, arrays note: this doesn't compile against this same checked in revision of dyncall, but only my working copy; a future checkin will catch up
author Tassilo Philipp
date Sat, 22 Jan 2022 16:07:57 +0100
parents 167faab0c0be
children 3d2c5d156d78
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
432
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
1 require"math"
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
2 local max = math.max
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
3 local maxargs = 0
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
4
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
5 local n_aggrs = 0
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
6 local seen_aggrs = { }
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
7
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
8
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
9 function trim(l) return l:gsub("^%s+",""):gsub("%s+$","") end
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
10 function mkcase(id,sig)
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
11 local sig = trim(sig)
433
45662241d9cd suite_aggrs now handling struct by value return types, also
Tassilo Philipp
parents: 432
diff changeset
12 local h = { "/* ",id,":",sig," */ " }
432
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
13 local t = { "" }
433
45662241d9cd suite_aggrs now handling struct by value return types, also
Tassilo Philipp
parents: 432
diff changeset
14 local pos = 0
432
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
15 local n_nest = 0
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
16 local aggr
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
17 local aggr_sig = ''
433
45662241d9cd suite_aggrs now handling struct by value return types, also
Tassilo Philipp
parents: 432
diff changeset
18 for i = 1, #sig do
432
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
19 local name = "a"..pos
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
20 local ch = sig:sub(i,i)
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
21
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
22 aggr_sig = aggr_sig..ch
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
23
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
24 -- aggregate nest level change?
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
25 if ch == '{' then
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
26 n_nest = n_nest + 1
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
27 aggr = { }
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
28 aggr_sig = ch -- @@@ handle nesting
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
29 else
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
30 if ch == '}' then -- @@@ handle nesting, here, by reusing structs
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
31 n_nest = n_nest - 1
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
32 -- aggr sig complete?
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
33 if n_nest == 0 then
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
34 -- register yet unseen aggregates, key is sig, val is body and name
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
35 if seen_aggrs[aggr_sig] == nil then
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
36 n_aggrs = n_aggrs + 1
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
37 ch = 'A'..n_aggrs
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
38 seen_aggrs[aggr_sig] = { aggr, ch }
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
39 end
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
40 ch = seen_aggrs[aggr_sig][2]
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
41 end
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
42 else
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
43 if n_nest > 0 then
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
44 aggr[#aggr+1] = ch
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
45 aggr[#aggr+1] = 'm'..(#aggr >> 1)
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
46 end
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
47 end
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
48 end
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
49
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
50 if n_nest == 0 then
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
51 -- struct types (more than one char) need copying via a func
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
52 if #ch > 1 then
433
45662241d9cd suite_aggrs now handling struct by value return types, also
Tassilo Philipp
parents: 432
diff changeset
53 h[#h+1] = 'struct '..ch
432
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
54 t[#t+1] = 'f_cp'..ch..'(V_a['..pos.."],&"..name..");"
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
55 else
433
45662241d9cd suite_aggrs now handling struct by value return types, also
Tassilo Philipp
parents: 432
diff changeset
56 h[#h+1] = ch
432
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
57 t[#t+1] = "V_"..ch.."["..pos.."]="..name..";"
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
58 end
433
45662241d9cd suite_aggrs now handling struct by value return types, also
Tassilo Philipp
parents: 432
diff changeset
59
45662241d9cd suite_aggrs now handling struct by value return types, also
Tassilo Philipp
parents: 432
diff changeset
60 -- is return type or func arg?
45662241d9cd suite_aggrs now handling struct by value return types, also
Tassilo Philipp
parents: 432
diff changeset
61 if pos == 0 then
45662241d9cd suite_aggrs now handling struct by value return types, also
Tassilo Philipp
parents: 432
diff changeset
62 h[#h+1] = " f"..id.."("
45662241d9cd suite_aggrs now handling struct by value return types, also
Tassilo Philipp
parents: 432
diff changeset
63 h[#h+1] = ''
45662241d9cd suite_aggrs now handling struct by value return types, also
Tassilo Philipp
parents: 432
diff changeset
64 t[#t] = '' -- clear; aggr return type handled explicitly
45662241d9cd suite_aggrs now handling struct by value return types, also
Tassilo Philipp
parents: 432
diff changeset
65 else
45662241d9cd suite_aggrs now handling struct by value return types, also
Tassilo Philipp
parents: 432
diff changeset
66 h[#h+1] = ' '..name
45662241d9cd suite_aggrs now handling struct by value return types, also
Tassilo Philipp
parents: 432
diff changeset
67 h[#h+1] = ","
45662241d9cd suite_aggrs now handling struct by value return types, also
Tassilo Philipp
parents: 432
diff changeset
68 end
432
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
69
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
70 pos = pos + 1
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
71 end
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
72 end
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
73 maxargs = max(maxargs, pos-1)
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
74 h[#h] = "){"
433
45662241d9cd suite_aggrs now handling struct by value return types, also
Tassilo Philipp
parents: 432
diff changeset
75 if #h[6] == 1 then
45662241d9cd suite_aggrs now handling struct by value return types, also
Tassilo Philipp
parents: 432
diff changeset
76 t[#t+1] = "ret_"..h[6].."("..(pos-1)..")}\n"
45662241d9cd suite_aggrs now handling struct by value return types, also
Tassilo Philipp
parents: 432
diff changeset
77 else
45662241d9cd suite_aggrs now handling struct by value return types, also
Tassilo Philipp
parents: 432
diff changeset
78 t[#t+1] = "ret_a("..(pos-1)..","..h[6]..")}\n"
45662241d9cd suite_aggrs now handling struct by value return types, also
Tassilo Philipp
parents: 432
diff changeset
79 end
432
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
80 return table.concat(h,"")..table.concat(t,"")
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
81 end
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
82
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
83 function mkfuntab(n)
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
84 local s = { "funptr G_funtab[] = {\n"}
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
85 for i = 0, n-1 do
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
86 s[#s+1] = "\t(funptr)&f"..i..",\n"
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
87 end
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
88 s[#s+1] = "};\n"
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
89 return table.concat(s,"")
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
90 end
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
91
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
92 function mksigtab(sigs)
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
93 local s = { "char const * G_sigtab[] = {\n"}
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
94 for k,v in pairs(sigs) do
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
95 s[#s+1] = '\t"'..v..'",\n'
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
96 end
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
97 s[#s+1] = "};\n"
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
98 return table.concat(s,"")
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
99 end
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
100
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
101 function mkall()
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
102 local lineno = 0
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
103 local sigtab = { }
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
104 local cases = ''
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
105 for line in io.lines() do
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
106 local sig = trim(line)
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
107 cases = cases..mkcase(lineno,sig)
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
108 sigtab[#sigtab+1] = sig
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
109 lineno = lineno + 1
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
110 end
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
111
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
112 agg_sizes = {}
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
113 agg_sigs = {}
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
114 agg_names = {}
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
115 for k, v in pairs(seen_aggrs) do
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
116 st = 'struct '..v[2]
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
117
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
118 agg_sizes[#agg_sizes + 1] = 'sizeof('..st..')'
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
119 agg_sigs [#agg_sigs + 1] = k
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
120 agg_names[#agg_names + 1] = v[2]
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
121
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
122 -- struct def
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
123 io.write('/* '..k..' */\n')
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
124 io.write(st..'{ ')
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
125 for i = 1, #v[1], 2 do
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
126 io.write(v[1][i]..' '..v[1][i+1]..'; ')
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
127 end
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
128 io.write("};\n")
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
129
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
130 -- struct cp and cmp funcs
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
131 s = {
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
132 'void f_cp'..v[2]..'('..st..' *x, const '..st..' *y) { ',
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
133 'int f_cmp'..v[2]..'(const '..st..' *x, const '..st..' *y) { return '
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
134 }
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
135 o = { '=', '==', '; ', ' && ' }
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
136 for t = 1, 2 do
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
137 io.write(s[t])
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
138 b = {}
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
139 for i = 1, #v[1], 2 do
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
140 b[#b+1] = 'x->'..v[1][i+1]..' '..o[t]..' y->'..v[1][i+1];
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
141 end
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
142 if #b == 0 then
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
143 b[1] = '1' -- to handle empty structs
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
144 end
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
145 io.write(table.concat(b,o[t+2]).."; };\n")
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
146 end
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
147
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
148 -- convenient dcnewstruct helper funcs
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
149 io.write('DCstruct* f_newdcst'..v[2]..'() { DCstruct* st = dcNewStruct('..(#v[1]>>1)..', sizeof('..st..'), 0, 1); ')
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
150 for i = 1, #v[1], 2 do
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
151 io.write("dcStructField(st, '"..v[1][i].."', offsetof("..st..', '..v[1][i+1]..'), 1); ')
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
152 end
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
153 io.write(" dcCloseStruct(st); return st; };\n")
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
154 end
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
155
433
45662241d9cd suite_aggrs now handling struct by value return types, also
Tassilo Philipp
parents: 432
diff changeset
156 -- make table.concat work
45662241d9cd suite_aggrs now handling struct by value return types, also
Tassilo Philipp
parents: 432
diff changeset
157 if #agg_names > 0 then
45662241d9cd suite_aggrs now handling struct by value return types, also
Tassilo Philipp
parents: 432
diff changeset
158 table.insert(agg_names, 1, '')
45662241d9cd suite_aggrs now handling struct by value return types, also
Tassilo Philipp
parents: 432
diff changeset
159 end
45662241d9cd suite_aggrs now handling struct by value return types, also
Tassilo Philipp
parents: 432
diff changeset
160
432
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
161 io.write(cases)
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
162 io.write(mkfuntab(lineno))
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
163 io.write(mksigtab(sigtab))
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
164 io.write('const char* G_agg_sigs[] = {\n\t"'..table.concat(agg_sigs, '",\n\t"')..'"\n};\n')
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
165 io.write('int G_agg_sizes[] = {\n\t'..table.concat(agg_sizes, ',\n\t')..'\n};\n')
433
45662241d9cd suite_aggrs now handling struct by value return types, also
Tassilo Philipp
parents: 432
diff changeset
166 io.write('funptr G_agg_newdcstfuncs[] = {'..string.sub(table.concat(agg_names, ',\n\t(funptr)&f_newdcst'),2)..'\n};\n')
45662241d9cd suite_aggrs now handling struct by value return types, also
Tassilo Philipp
parents: 432
diff changeset
167 io.write('funptr G_agg_cmpfuncs[] = {'..string.sub(table.concat(agg_names, ',\n\t(funptr)&f_cmp'),2)..'\n};\n')
432
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
168 io.write("int G_maxargs = "..maxargs..";\n")
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
169 end
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
170
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
171 mkall()
167faab0c0be first usable version of test suite for aggregates, handling only non-nested struct params, at the moment;
Tassilo Philipp
parents:
diff changeset
172