comparison test/call_suite_aggrs/mk-cases.lua @ 526:93628a1eaed4

tests: integrate new tests into makefiles, some cleanups
author Tassilo Philipp
date Thu, 14 Apr 2022 10:06:58 +0200
parents f7fec6699e21
children ed8835abe05f
comparison
equal deleted inserted replaced
525:cc607f753178 526:93628a1eaed4
12 -- for nested aggrs, so sub-aggrs conveniently precede parents) 12 -- for nested aggrs, so sub-aggrs conveniently precede parents)
13 function mkcase(id, sig, aggrs, seen_aggrs) 13 function mkcase(id, sig, aggrs, seen_aggrs)
14 local sig = trim(sig) 14 local sig = trim(sig)
15 local fsig = put_sig_rtype_first(sig) 15 local fsig = put_sig_rtype_first(sig)
16 local h = { "/* ",id,":",sig," */ " } 16 local h = { "/* ",id,":",sig," */ " }
17 local t = { "" } 17 local t = { }
18 local pos = -1 18 local pos = -1
19 local n_nest = 0 19 local n_nest = 0
20 local aggr = { } 20 local aggr = { }
21 local aggr_sig = { } 21 local aggr_sig = { }
22 aggr[0] = { } -- non-sequential [0] collects all non-aggr types (not used, though) 22 aggr[0] = { } -- non-sequential [0] collects all non-aggr types (not used, though)
23 aggr_sig[0] = '' 23 aggr_sig[0] = ''
24 for i = 1, #fsig do 24 for i = 1, #fsig do
25 local name = "a"..pos 25 local name = "a"..pos
26 local ch = fsig:sub(i,i) 26 local ch = fsig:sub(i,i)
27
28 27
29 -- aggregate nest level change? 28 -- aggregate nest level change?
30 if ch == '{' or ch == '<' then 29 if ch == '{' or ch == '<' then
31 n_nest = n_nest + 1 30 n_nest = n_nest + 1
32 aggr[n_nest] = { } 31 aggr[n_nest] = { }
62 61
63 -- no nesting (= actual func args), generate case code 62 -- no nesting (= actual func args), generate case code
64 if n_nest == 0 then 63 if n_nest == 0 then
65 h[#h+1] = ch 64 h[#h+1] = ch
66 -- aggregate types have more than one char 65 -- aggregate types have more than one char
67 if #h[#h] > 1 then 66 if #ch > 1 then
68 if aggrcpsimple then 67 if aggrcpsimple then
69 t[#t+1] = '*('..h[#h]..'*)V_a['..pos.."]="..name..";" 68 t[#t+1] = '*('..ch..'*)V_a['..pos.."]="..name..";"
70 else 69 else
71 t[#t+1] = 'f_cp'..h[#h]:match('A.*')..'(V_a['..pos.."],&"..name..");" 70 t[#t+1] = 'f_cp'..ch:match('A.*')..'(V_a['..pos.."],&"..name..");"
72 end 71 end
73 if aggrmutabletest then 72 if aggrmutabletest then
74 t[#t] = t[#t]..'memset(&'..name..',0,sizeof('..name..'));' 73 t[#t] = t[#t]..'memset(&'..name..',0,sizeof('..name..'));'
75 end 74 end
76 else 75 else