4 readfile
= function(fn
) local f
= assert(io
.open(fn
)) local s
= f
:read'*a' f
:close() return s
end
9 local path
= string.match(arg
[0], '(.*/)[^%/]+') or ''
10 local xmlstream
= dofile(path
..'xml.lua')(my
.readfile(filename
))
11 local code
= xmlstream
[1]
13 local decompound
= function(n
)
14 -- test function pointer
15 local r
, a
= string.match(n
, '(.-) %(%*%) (%b())')
17 -- only single arguments are supported
18 return 'function', r
, string.match(a
, '%(([^,]*)%))')
24 local base_types
= dofile'types.lua'
26 -- this only works on resolved types (no typedefs) and no compound types
27 local types_desc
= setmetatable({}, {
28 __index
= function(t
, k
)
30 if rawget(base_types
, k
) then
31 t
[k
] = rawget(base_types
, k
)
32 return rawget(base_types
, k
)
35 if string.match(k
, '[<>]') then
36 return nil -- explicitly won't support templates yet
39 -- traverse namespace tree
41 local iter
= string.gmatch(k
, '[^:]+')
42 for n
in iter
do if space
.byname
and space
.byname
[n
] then
43 space
= space
.byname
[n
]
44 if type(space
)=='table' and space
.label
=='TypeAlias' then
45 print(space
.xarg
.fullname
, k
)
46 error'you should resolve aliases before calling this function'
48 else -- this name is not in this space
49 -- this is probably a template argument (at least in Qt) so we do not care for now
51 error(tostring(k
)..' '..tostring(space
.fullname
)..' '..tostring(n
) )
54 -- make use of final result
55 if type(space
)~='table' then
59 space
.on_stack
= 'userdata;'
66 for _
, v
in pairs(xmlstream
.byid
) do
67 if v
.xarg
.type_base
then
68 if not string.match(v
.xarg
.context
, '[<,]%s*'..v
.xarg
.type_base
..'%s*[>,]') then
69 local __
= types_desc
[v
.xarg
.type_base
]
77 --table.foreach(types_desc, function(i, j) t[j] = true end)
78 table.foreach(types_desc
, function(n
,d
) print(n
, d
.label
, d
.on_stack
) end)
81 bind_function
= function(f
)
82 if type(f
)~='table' or string.find(f
.label
, 'Function')~=1 then
83 error('this is NOT a function')
85 io
.write(f
.xarg
.type_name
.. ' ' .. f
.xarg
.fullname
..
86 (f
.xarg
.static
=='1' and ' [static]' or '')..
87 (f
.xarg
.virtual
=='1' and ' [virtual]' or '')..
88 ' [in ' .. tostring(f
.xarg
.member_of
) .. ']\n')
90 for _
, v
in pairs(xmlstream
.byid
) do
91 pcall(bind_function
, v
)