Mercurial > pub > dyncall > dyncall
annotate test/call_suite/mk-cases.lua @ 538:35498b479505
- Changelog
author | Tassilo Philipp |
---|---|
date | Sun, 24 Apr 2022 13:38:33 +0200 |
parents | 01f928eb9584 |
children |
rev | line source |
---|---|
0 | 1 require"math" |
514 | 2 |
3 -- use shared helpers to generate cases | |
4 package.path = '../common/?.lua;' .. package.path | |
5 require"mk-cases" | |
6 | |
7 | |
0 | 8 local max = math.max |
9 local maxargs = 0 | |
10 | |
11 function mkcase(id,sig) | |
12 local sig = trim(sig) | |
496
da5232da6270
- test code: rand-sig now spitting out dyncallish sigs (with ')' end delim and rettype at end), purely for consistency
Tassilo Philipp
parents:
430
diff
changeset
|
13 local h = { "/* ",id,":",sig," */ ",sig:sub(-1), " f", id,"(","" } |
430 | 14 local t = { "" } |
0 | 15 local pos = 0 |
496
da5232da6270
- test code: rand-sig now spitting out dyncallish sigs (with ')' end delim and rettype at end), purely for consistency
Tassilo Philipp
parents:
430
diff
changeset
|
16 maxargs = max(maxargs, #sig-2) |
da5232da6270
- test code: rand-sig now spitting out dyncallish sigs (with ')' end delim and rettype at end), purely for consistency
Tassilo Philipp
parents:
430
diff
changeset
|
17 for i = 1, #sig-2 do |
0 | 18 local name = "a"..pos |
19 local ch = sig:sub(i,i) | |
430 | 20 h[#h+1] = ch.." "..name |
0 | 21 h[#h+1] = "," |
430 | 22 t[#t+1] = "V_"..ch.."["..pos.."]="..name..";" |
511 | 23 pos = pos + 1 |
0 | 24 end |
25 h[#h] = "){" | |
496
da5232da6270
- test code: rand-sig now spitting out dyncallish sigs (with ')' end delim and rettype at end), purely for consistency
Tassilo Philipp
parents:
430
diff
changeset
|
26 t[#t+1] = "ret_"..sig:sub(-1).."("..pos..")}\n" |
0 | 27 return table.concat(h,"")..table.concat(t,"") |
28 end | |
29 | |
30 function mkall() | |
430 | 31 local lineno = 0 |
0 | 32 local sigtab = { } |
33 for line in io.lines() do | |
34 local sig = trim(line) | |
35 io.write(mkcase(lineno,sig)) | |
36 sigtab[#sigtab+1] = sig | |
37 lineno = lineno + 1 | |
38 end | |
512 | 39 io.write(mkfuntab(lineno, 'f', 'funptr', 'G_funtab', true)) |
40 io.write(mksigtab(sigtab, '', 'G_sigtab')) | |
0 | 41 io.write("int G_maxargs = "..maxargs..";\n") |
42 end | |
43 | |
44 mkall() | |
45 |