Mercurial > pub > dyncall > dyncall
comparison test/callback_suite/mk-cases.lua @ 518:a0ff5dff090b
- callback_suite: generator simplification and removal of pointless lua local var declarations
author | Tassilo Philipp |
---|---|
date | Mon, 11 Apr 2022 15:06:44 +0200 |
parents | 1a813b706de4 |
children |
comparison
equal
deleted
inserted
replaced
517:f8856e29b512 | 518:a0ff5dff090b |
---|---|
16 break | 16 break |
17 end | 17 end |
18 if(c == '_') then -- filter out prefixes | 18 if(c == '_') then -- filter out prefixes |
19 i = i + 1 | 19 i = i + 1 |
20 else | 20 else |
21 args[#args+1] = c | 21 args[#args+1] = c |
22 end | 22 end |
23 i = i + 1 | 23 i = i + 1 |
24 end | 24 end |
25 return "F" .. (#args-1) .. "(f" .. id .. "," .. table.concat(args,',') .. ")\n" | 25 return "F" .. (#args-1) .. "(f" .. id .. "," .. table.concat(args,',') .. ")\n" |
26 end | 26 end |
27 | 27 |
28 function mkall() | 28 function mkall() |
29 -- case macros | 29 -- case macros |
30 local i | |
31 for i = minargs, maxargs do | 30 for i = minargs, maxargs do |
32 local line = "#define F" .. i .. "(ID,R" | 31 local line = "#define F" .. i .. "(ID,R" |
33 local argdef = "" | 32 local argdef = { } |
34 local argset = "" | 33 local argset = { } |
35 if i > 0 then | 34 if i > 0 then |
36 line = line .. "," | 35 line = line .. "," |
37 local j | |
38 for j = 0, i-1 do | 36 for j = 0, i-1 do |
39 if j > 0 then | 37 argdef[#argdef+1] = "M" .. j |
40 argdef = argdef .. "," | 38 argset[#argset+1] = "K_##M" .. j .. "[" .. j .. "]" |
41 argset = argset .. "," | |
42 end | |
43 argdef = argdef .. "M" .. j | |
44 argset = argset .. "K_##M" .. j .. "[" .. j .. "]" | |
45 end | 39 end |
46 end | 40 end |
47 line = line .. argdef .. ") void ID(void* addr) { write_V_##R(" .. i .. ", ((" .. api .. " R(*)(" .. argdef .. "))addr)(" .. argset .. "));}\n" | 41 line = line .. table.concat(argdef,",") .. ") void ID(void* addr) { write_V_##R(" .. i .. ", ((" .. api .. " R(*)(" .. table.concat(argdef,",") .. "))addr)(" .. table.concat(argset,",") .. "));}\n" |
48 io.write(line) | 42 io.write(line) |
49 end | 43 end |
50 | 44 |
51 -- cases | 45 -- cases |
52 local lineno = 0 | 46 local lineno = 0 |