Mercurial > pub > dyncall > dyncall
comparison test/call_suite/mk-cases.lua @ 514:01f928eb9584
- more test code generator code sharing
author | Tassilo Philipp |
---|---|
date | Sun, 10 Apr 2022 16:18:28 +0200 |
parents | 4d0541bf9b38 |
children |
comparison
equal
deleted
inserted
replaced
513:95f6f43178ed | 514:01f928eb9584 |
---|---|
1 require"math" | 1 require"math" |
2 | |
3 -- use shared helpers to generate cases | |
4 package.path = '../common/?.lua;' .. package.path | |
5 require"mk-cases" | |
6 | |
7 | |
2 local max = math.max | 8 local max = math.max |
3 local maxargs = 0 | 9 local maxargs = 0 |
4 | 10 |
5 function trim(l) return l:gsub("^%s+",""):gsub("%s+$","") end | |
6 function mkcase(id,sig) | 11 function mkcase(id,sig) |
7 local sig = trim(sig) | 12 local sig = trim(sig) |
8 local h = { "/* ",id,":",sig," */ ",sig:sub(-1), " f", id,"(","" } | 13 local h = { "/* ",id,":",sig," */ ",sig:sub(-1), " f", id,"(","" } |
9 local t = { "" } | 14 local t = { "" } |
10 local pos = 0 | 15 local pos = 0 |
20 h[#h] = "){" | 25 h[#h] = "){" |
21 t[#t+1] = "ret_"..sig:sub(-1).."("..pos..")}\n" | 26 t[#t+1] = "ret_"..sig:sub(-1).."("..pos..")}\n" |
22 return table.concat(h,"")..table.concat(t,"") | 27 return table.concat(h,"")..table.concat(t,"") |
23 end | 28 end |
24 | 29 |
25 -- use shared helpers to generate cases | |
26 package.path = '../common/?.lua;' .. package.path | |
27 require"mk-cases" | |
28 | |
29 | |
30 function mkall() | 30 function mkall() |
31 local lineno = 0 | 31 local lineno = 0 |
32 local sigtab = { } | 32 local sigtab = { } |
33 for line in io.lines() do | 33 for line in io.lines() do |
34 local sig = trim(line) | 34 local sig = trim(line) |