4 readfile
= function(fn
) local f
= assert(io
.open(fn
)) local s
= f
:read'*a' f
:close() return s
end
7 local elements
= dofile'entities.lua'
8 assert_function
= function(f
)
9 assert(entities
.is_function(f
), 'argument is not a function')
13 local path
= string.match(arg
[0], '(.*/)[^%/]+') or ''
14 local xmlstream
, idindex
= dofile(path
..'xml.lua')(my
.readfile(filename
))
15 --local code = xmlstream[1]
17 local debug
= function(...)
18 for i
= 1, select('#',...) do
19 io
.stderr
:write((i
==1) and '' or '\t', tostring(select(i
,...)))
24 ----------------------------------------------------------------------------------
26 local copy_functions
= function(index
)
27 local ret
, copied
= {}, 0
28 for e
in pairs(index
) do
29 if e
.label
:match
'^Function' then
30 --[[and not (e.xarg.name:match'^[%a]*'=='operator'
31 or e.xarg.fullname:match'%b<>'
32 or e.xarg.name:match'_'
33 or e.xarg.name:match'[xX]11'
34 or e.xarg.fullname:match'QInternal'
35 or e.xarg.access=='private'
36 or e.xarg.access=='protected' -- FIXME
37 or e.xarg.fullname=='QVariant::canConvert') then --]]
42 --removed = removed + (e.label:match'^Function' and 1 or 0)
43 --removed = removed + 1
49 local fix_functions
= function(index
, all
)
51 for e
in pairs(all
or {}) do
52 if e
.xarg
.fullname
then fullnames
[e
.xarg
.fullname
] = true end
54 for f
in pairs(index
) do
56 for i
, a
in ipairs(f
) do
57 -- avoid bogus 'void' arguments
58 if a
.xarg
.type_name
=='void' and i
==1 and f
[2]==nil then break end
59 if a
.label
=='Argument' then
61 if a
.xarg
.default
=='1' and string.match(a
.xarg
.defaultvalue
, '%D') then
62 local dv
= a
.xarg
.defaultvalue
63 if not fullnames
[dv
] then
64 dv
= a
.xarg
.context
..'::'..dv
67 a
.xarg
.defaultvalue
= dv
70 a
.xarg
.defaultvalue
= nil
76 if elements
.is_constructor(f
) then
77 f
.xarg
.fullname
= '*new '..f
.xarg
.fullname
78 f
.return_type
= f
.xarg
.type_base
..'&'
80 elseif elements
.is_destructor(f
) or f
.xarg
.type_name
=='void' then
83 if false and f
.xarg
.access
=='protected' then
84 local shellname
= 'lqt_shell_'..string.gsub(f
.parent
.xarg
.fullname
, '::', '_LQT_')
85 f
.xarg
.fullname
= shellname
..'::'..f
.xarg
.name
86 if f
.xarg
.static
~='1' then
88 local newarg
= { label
='Argument', xarg
= {
89 type_name
= f
.xarg
.member_of_class
..'*',
91 table.insert(args
, newarg
, 1)
94 f
.return_type
= f
.xarg
.type_name
100 local copy_enums
= function(index
)
102 for e
in pairs(index
) do
104 and not string.match(e
.xarg
.fullname
, '%b<>')
105 and e
.xarg
.access
~='private' then
112 local fix_enums
= function(index
)
113 for e
in pairs(index
) do
115 for _
, v
in ipairs(e
) do
116 if v
.label
=='Enumerator' then
117 table.insert(values
, v
)
125 local copy_classes
= function(index
)
127 for e
in pairs(index
) do
129 and e
.xarg
.access
~='private'
130 and not (e
.xarg
.fullname
:match
'%b<>'
131 or e
.xarg
.fullname
=='QDebug::Stream'
132 or e
.xarg
.fullname
=='QForeachContainerBase'
133 or e
.xarg
.fullname
=='QByteArray::Data'
134 or e
.xarg
.fullname
=='QVariant::Private::Data'
135 or e
.xarg
.fullname
=='QRegion::QRegionData'
136 or e
.xarg
.fullname
=='QTextStreamManipulator'
137 or e
.xarg
.fullname
=='QString::Data'
138 or e
.xarg
.fullname
=='QThreadStorageData'
146 local fill_virtuals
= function(index
)
148 for c
in pairs(index
) do
149 classes
[c
.xarg
.fullname
] = c
152 get_virtuals
= function(c
)
154 for _
, f
in ipairs(c
) do
155 if f
.label
=='Function' and f
.xarg
.virtual
=='1' then
156 local n
= string.match(f
.xarg
.name
, '~') or f
.xarg
.name
157 if n
~='~' then ret
[n
] = f
end
160 for b
in string.gmatch(c
.xarg
.bases
or '', '([^;]+);') do
161 local base
= classes
[b
]
162 if type(base
)=='table' then
163 local bv
= get_virtuals(base
)
164 for n
, f
in pairs(bv
) do
165 if not ret
[n
] then ret
[n
] = f
end
169 for _
, f
in ipairs(c
) do
170 if f
.label
=='Function'
171 and f
.xarg
.access
~='private'
172 and (ret
[string.match(f
.xarg
.name
, '~') or f
.xarg
.name
]) then
174 local n
= string.match(f
.xarg
.name
, '~')or f
.xarg
.name
180 for c
in pairs(index
) do
181 c
.virtuals
= get_virtuals(c
)
182 for _
, f
in pairs(c
.virtuals
) do
183 if f
.xarg
.abstract
=='1' then c
.abstract
=true break end
189 local fill_special_methods
= function(index
)
190 for c
in pairs(index
) do
191 local construct
, destruct
, normal
= {}, nil, {}
192 local n
= c
.xarg
.name
193 local auto
, copy
= true, nil
194 for _
, f
in ipairs(c
) do
195 if n
==f
.xarg
.name
then
197 if #(f
.arguments
or {})==1 and
198 f
.arguments
[1].xarg
.type_name
==(c
.xarg
.fullname
..' const&') then
199 copy
= f
.xarg
.access
or 'PUBLIC?'
202 if n
==f
.xarg
.name
then
203 table.insert(construct
, f
)
204 elseif f
.xarg
.name
:match
'~' then
207 if (not string.match(f
.xarg
.name
, '^operator%W'))
208 and (not f
.xarg
.member_template_parameters
) then
209 table.insert(normal
, f
)
213 construct
.auto
= auto
214 construct
.copy
= (copy
==nil and 'auto' or copy
) -- FIXME: must try
215 c
.constructors
= construct
216 c
.destructor
= destruct
and (destruct
.xarg
.access
or 'PUBLIC?') or 'auto'
222 local fill_copy_constructor
= function(index
)
224 for c
in pairs(index
) do
225 classes
[c
.xarg
.name
] = c
229 if c
.destructor
=='auto' then
231 for b
in string.gmatch(c
.xarg
.bases
or '', '([^;]+);') do
232 local base
= classes
[b
]
233 if base
and destr(base
)=='private' then
234 c
.destructor
= 'private'
242 copy_constr
= function(c
)
243 if c
.constructors
.copy
=='auto' then
245 for b
in string.gmatch(c
.xarg
.bases
or '', '([^;]+);') do
246 local base
= classes
[b
]
247 if base
and copy_constr(base
)=='private' then
248 c
.constructors
.copy
= 'private'
253 return c
.constructors
.copy
255 for c
in pairs(index
) do
256 c
.constructors
.copy
= copy_constr(c
)
257 c
.destructor
= destr(c
)
258 --io.stderr:write(c.xarg.fullname, '\t', c.constructors.copy, '\n')
259 --io.stderr:write(c.xarg.fullname, '\t', c.destructor, '\n')
264 local fill_typesystem_with_enums
= function(enums
, types
)
266 for e
in pairs(enums
) do
267 if not types
[e
.xarg
.fullname
] then
269 types
[e
.xarg
.fullname
] = {
271 return 'lqtL_pushenum(L, '..n
..', "'..e
.xarg
.fullname
..'")', 1
274 return 'static_cast<'..e
.xarg
.fullname
..'>'
275 ..'(lqtL_toenum(L, '..n
..', "'..e
.xarg
.fullname
..'"))', 1
278 return 'lqtL_isenum(L, '..n
..', "'..e
.xarg
.fullname
..'")', 1
282 --io.stderr:write(e.xarg.fullname, ': already present\n')
288 local fill_typesystem_with_classes
= function(classes
, types
)
290 for c
in pairs(classes
) do
291 if not types
[c
.xarg
.fullname
] then
293 types
[c
.xarg
.fullname
..'*'] = {
294 -- the argument is a pointer to class
296 return 'lqtL_passudata(L, '..n
..', "'..c
.xarg
.fullname
..'*")', 1
299 return 'static_cast<'..c
.xarg
.fullname
..'*>'
300 ..'(lqtL_toudata(L, '..n
..', "'..c
.xarg
.fullname
..'*"))', 1
303 return 'lqtL_isudata(L, '..n
..', "'..c
.xarg
.fullname
..'*")', 1
306 types
[c
.xarg
.fullname
..' const*'] = {
307 -- the argument is a pointer to constant class instance
309 return 'lqtL_passudata(L, '..n
..', "'..c
.xarg
.fullname
..'*")', 1
312 return 'static_cast<'..c
.xarg
.fullname
..'*>'
313 ..'(lqtL_toudata(L, '..n
..', "'..c
.xarg
.fullname
..'*"))', 1
316 return 'lqtL_isudata(L, '..n
..', "'..c
.xarg
.fullname
..'*")', 1
319 types
[c
.xarg
.fullname
..'&'] = {
320 -- the argument is a reference to class
322 return 'lqtL_passudata(L, &'..n
..', "'..c
.xarg
.fullname
..'*")', 1
325 return '*static_cast<'..c
.xarg
.fullname
..'*>'
326 ..'(lqtL_toudata(L, '..n
..', "'..c
.xarg
.fullname
..'*"))', 1
329 return 'lqtL_isudata(L, '..n
..', "'..c
.xarg
.fullname
..'*")', 1
332 if c
.constructors
.copy
~='private' then -- and c.destructor~='private' then
333 local shellname
= 'lqt_shell_'..string.gsub(c
.xarg
.fullname
, '::', '_LQT_')
334 types
[c
.xarg
.fullname
] = {
335 -- the argument is the class itself
337 return 'lqtL_passudata(L, new '..shellname
338 ..'(L, '..n
..'), "'..c
.xarg
.fullname
..'*")', 1
341 return '*static_cast<'..c
.xarg
.fullname
..'*>'
342 ..'(lqtL_toudata(L, '..n
..', "'..c
.xarg
.fullname
..'*"))', 1
345 return 'lqtL_isudata(L, '..n
..', "'..c
.xarg
.fullname
..'*")', 1
348 types
[c
.xarg
.fullname
..' const&'] = {
349 -- the argument is a pointer to class
351 return 'lqtL_passudata(L, new '..shellname
352 ..'(L, '..n
..'), "'..c
.xarg
.fullname
..'*")', 1
355 return '*static_cast<'..c
.xarg
.fullname
..'*>'
356 ..'(lqtL_toudata(L, '..n
..', "'..c
.xarg
.fullname
..'*"))', 1
359 return 'lqtL_isudata(L, '..n
..', "'..c
.xarg
.fullname
..'*")', 1
363 --io.stderr:write(c.xarg.fullname, ': no copy constructor\n')
366 --io.stderr:write(c.xarg.fullname, ': already present\n')
372 local fill_wrapper_code
= function(f
, types
, debug
)
373 debug
= debug
or function()end
374 local stackn
, argn
= 1, 1
375 local wrap
, line
= '', ''
376 if f
.xarg
.member_of_class
and f
.xarg
.static
~='1' then
377 if not types
[f
.xarg
.member_of_class
..'*'] then return nil end -- print(f.xarg.member_of_class) return nil end
378 local sget
, sn
= types
[f
.xarg
.member_of_class
..'*'].get(stackn
)
379 wrap
= wrap
.. ' ' .. f
.xarg
.member_of_class
.. '* self = ' .. sget
.. ';\n'
383 lua_pushstring(L, "this pointer is NULL");
388 line
= 'self->'..f
.xarg
.fullname
..'('
390 line
= f
.xarg
.fullname
..'('
392 for i
, a
in ipairs(f
.arguments
) do
393 if not types
[a
.xarg
.type_name
] then debug(a
.xarg
.type_name
) return nil end -- print(a.xarg.type_name) return nil end
394 local aget
, an
= types
[a
.xarg
.type_name
].get(stackn
)
395 wrap
= wrap
.. ' ' .. a
.xarg
.type_name
.. ' arg' .. tostring(argn
) .. ' = '
396 if a
.xarg
.default
=='1' and an
>0 then
397 wrap
= wrap
.. 'lua_isnoneornil(L, '..stackn
..')'
398 for j
= stackn
+1,stackn
+an
-1 do
399 wrap
= wrap
.. ' && lua_isnoneornil(L, '..j
..')'
401 local dv
= a
.xarg
.defaultvalue
402 wrap
= wrap
.. ' ? ' .. dv
.. ' : '
404 wrap
= wrap
.. aget
.. ';\n'
405 line
= line
.. (argn
==1 and 'arg' or ', arg') .. argn
410 -- FIXME: hack follows for constructors
411 if f
.calling_line
then line
= f
.calling_line
end
412 if f
.return_type
then line
= f
.return_type
.. ' ret = ' .. line
end
413 wrap
= wrap
.. ' ' .. line
.. ';\n lua_settop(L, 0);\n' -- lua_pop(L, '..stackn..');\n'
414 if f
.return_type
then
415 if not types
[f
.return_type
] then return nil end
416 local rput
, rn
= types
[f
.return_type
].push
'ret'
417 wrap
= wrap
.. ' luaL_checkstack(L, '..rn
..', "cannot grow stack for return value");\n'
418 wrap
= wrap
.. ' '..rput
..';\n return '..rn
..';\n'
420 wrap
= wrap
.. ' return 0;\n'
422 f
.wrapper_code
= wrap
426 local fill_test_code
= function(f
, types
)
429 if f
.xarg
.member_of_class
and f
.xarg
.static
~='1' then
430 if not types
[f
.xarg
.member_of_class
..'*'] then return nil end -- print(f.xarg.member_of_class) return nil end
431 local stest
, sn
= types
[f
.xarg
.member_of_class
..'*'].test(stackn
)
432 test
= test
.. ' && ' .. stest
435 for i
, a
in ipairs(f
.arguments
) do
436 if not types
[a
.xarg
.type_name
] then return nil end -- print(a.xarg.type_name) return nil end
437 local atest
, an
= types
[a
.xarg
.type_name
].test(stackn
)
438 if a
.xarg
.default
=='1' and an
>0 then
439 test
= test
.. ' && (lqtL_missarg(L, ' .. stackn
.. ', ' .. an
.. ') || '
440 test
= test
.. atest
.. ')'
442 test
= test
.. ' && ' .. atest
446 -- can't make use of default values if I fix number of args
447 test
= '(lua_gettop(L)<' .. stackn
.. ')' .. test
452 local fill_wrappers
= function(functions
, types
)
454 for f
in pairs(functions
) do
455 f
= fill_wrapper_code(f
, types
)
457 f
= assert(fill_test_code(f
, types
), f
.xarg
.fullname
) -- MUST pass
459 local out
= 'extern "C" int lqt_bind'..f
.xarg
.id
..' (lua_State *L) {\n'
460 .. f
.wrapper_code
.. '}\n'
467 local argument_name
= function(tn
, an
)
469 if string.match(tn
, '%(%*%)') then
470 ret
= string.gsub(tn
, '%(%*%)', '(*'..an
..')', 1)
471 elseif string.match(tn
, '%[.*%]') then
472 ret
= string.gsub(tn
, '(%[.*%])', an
..'%1')
474 ret
= tn
.. ' ' .. an
479 local virtual_overload
= function(v
, types
)
481 if v
.virtual_overload
then return v
end
483 if v
.return_type
and not types
[v
.return_type
] then return nil end
484 local rget
, rn
= '', 0
485 if v
.return_type
then rget
, rn
= types
[v
.return_type
].get
'oldtop+1' end
486 local retget
= (v
.return_type
and argument_name(v
.return_type
, 'ret')
487 .. ' = ' .. rget
.. ';' or '') .. 'lua_settop(L, oldtop);return'
488 .. (v
.return_type
and ' ret' or '')
489 -- make argument push
490 local pushlines
, stack
= '', 0
491 for i
, a
in ipairs(v
.arguments
) do
492 if not types
[a
.xarg
.type_name
] then return nil end
493 local apush
, an
= types
[a
.xarg
.type_name
].push('arg'..i
)
494 pushlines
= pushlines
.. ' ' .. apush
.. ';\n'
498 local luacall
= 'lua_pcall(L, '..stack
..', '..rn
..', 0)'
499 -- make prototype and fallback
500 local proto
= (v
.return_type
or 'void')..' ;;'..v
.xarg
.name
..' ('
502 for i
, a
in ipairs(v
.arguments
) do
503 proto
= proto
.. (i
>1 and ', ' or '')
504 .. argument_name(a
.xarg
.type_name
, 'arg'..i
)
505 fallback
= fallback
.. (i
>1 and ', arg' or 'arg') .. i
507 proto
= proto
.. ')' .. (v
.xarg
.constant
=='1' and ' const' or '')
508 fallback
= (v
.return_type
and 'return this->' or 'this->')
509 .. v
.xarg
.fullname
.. '(' .. fallback
.. ');\n}\n'
511 int oldtop = lua_gettop(L);
512 lqtL_pushudata(L, this, "]]..v
.xarg
.member_of_class
..[[*");
513 lua_getfield(L, -1, "]]..v
.xarg
.name
..[[");
514 if (lua_isfunction(L, -1)) {
516 ]] .. pushlines
.. [[
517 if (]]..luacall
..[[) {
521 lua_settop(L, oldtop);
523 v
.virtual_overload
= ret
524 v
.virtual_proto
= string.gsub(proto
, ';;', '', 1)
528 local fill_shell_class
= function(c
, types
)
529 local shellname
= 'lqt_shell_'..string.gsub(c
.xarg
.fullname
, '::', '_LQT_')
530 local shell
= 'class ' .. shellname
.. ' : public ' .. c
.xarg
.fullname
.. ' {\npublic:\n'
531 shell
= shell
.. ' lua_State *L;\n'
532 for _
, constr
in ipairs(c
.constructors
) do
533 if constr
.xarg
.access
~='private' then
534 local cline
= ' '..shellname
..' (lua_State *l'
536 for i
, a
in ipairs(constr
.arguments
) do
537 cline
= cline
.. ', ' .. argument_name(a
.xarg
.type_name
, 'arg'..i
)
538 argline
= argline
.. (i
>1 and ', arg' or 'arg') .. i
540 cline
= cline
.. ') : ' .. c
.xarg
.fullname
.. '(' .. argline
.. '), L(l) {}\n'
541 shell
= shell
.. cline
544 if c
.constructors
.copy
=='auto' then
545 local cline
= ' '..shellname
..' (lua_State *l, '..c
.xarg
.fullname
..' const& arg1)'
546 cline
= cline
.. ' : ' .. c
.xarg
.fullname
.. '(arg1), L(l) {}\n'
547 shell
= shell
.. cline
549 for i
, v
in pairs(c
.virtuals
) do
550 if v
.xarg
.access
~='private' then
551 local vret
= virtual_overload(v
, types
)
552 if v
.virtual_proto
then shell
= shell
.. ' virtual ' .. v
.virtual_proto
.. ';\n' end
555 shell
= shell
.. '};\n'
556 c
.shell_class
= shell
560 local fill_shell_classes
= function(classes
, types
)
562 for c
in pairs(classes
) do
564 c
= fill_shell_class(c
, types
)
565 if c
then ret
[c
] = true print(c
.shell_class
)
567 io
.stderr
:write(c
.fullname
, '\n')
574 local print_virtual_overloads
= function(classes
, types
)
575 for c
in pairs(classes
) do
576 local shellname
= 'lqt_shell_'..string.gsub(c
.xarg
.fullname
, '::', '_LQT_')
577 for _
,v
in pairs(c
.virtuals
) do
578 if v
.virtual_overload
then
579 print((string.gsub(v
.virtual_overload
, ';;', shellname
..'::', 1)))
586 local print_wrappers
= function(index
)
587 for c
in pairs(index
) do
589 for _
, f
in ipairs(c
.methods
) do
590 if f
.wrapper_code
then
591 local out
= 'extern "C" int lqt_bind'..f
.xarg
.id
592 ..' (lua_State *L) {\n'.. f
.wrapper_code
.. '}\n'
593 if f
.xarg
.access
=='public' then
595 meta
[f
] = f
.xarg
.name
600 for _
, f
in ipairs(c
.constructors
) do
601 if f
.wrapper_code
then
602 local out
= 'extern "C" int lqt_bind'..f
.xarg
.id
603 ..' (lua_State *L) {\n'.. f
.wrapper_code
.. '}\n'
604 if f
.xarg
.access
=='public' then
616 local print_metatable
= function(c
)
618 for m
, n
in pairs(c
.meta
) do
619 methods
[n
] = methods
[n
] or {}
620 table.insert(methods
[n
], m
)
622 for n
, l
in pairs(methods
) do
623 local disp
= 'extern "C" int lqt_dispatcher_'..n
..c
.xarg
.id
..' (lua_State *L) {\n'
624 for _
, f
in ipairs(l
) do
625 disp
= disp
..' if ('..f
.test_code
..') return lqt_bind'..f
.xarg
.id
..'(L);\n'
627 disp
= disp
.. ' lua_settop(L, 0);\n'
628 disp
= disp
.. ' lua_pushstring(L, "incorrect or extra arguments");\n'
629 disp
= disp
.. ' return lua_error(L);\n}\n'
632 local metatable
= 'static luaL_Reg lqt_metatable'..c
.xarg
.id
..'[] = {\n'
633 for n
, l
in pairs(methods
) do
634 metatable
= metatable
.. ' { "'..n
..'", lqt_dispatcher_'..n
..c
.xarg
.id
..' },\n'
636 metatable
= metatable
.. ' { 0, 0 },\n};\n'
639 for b
in string.gmatch(c
.xarg
.bases
or '', '([^;]*);') do
640 bases
= bases
.. '{"' .. b
.. '*"}, '
642 bases
= 'static lqt_Base lqt_base'..c
.xarg
.id
..'[] = { '..bases
..'{NULL} };\n'
647 local print_metatables
= function(classes
)
648 for c
in pairs(classes
) do
654 local print_class_list
= function(classes
)
655 local list
= 'static lqt_Class lqt_class_list[] = {\n'
656 for c
in pairs(classes
) do
657 class
= '{ lqt_metatable'..c
.xarg
.id
..', lqt_base'..c
.xarg
.id
..', "'..c
.xarg
.fullname
..'*" },\n'
658 list
= list
.. ' ' .. class
660 list
= list
.. ' { 0, 0, 0 },\n};\n'
665 local fix_methods_wrappers
= function(classes
)
666 for c
in pairs(classes
) do
667 -- if class seems abstract but has a shell class
668 -- FIXME: destructor should not matter
669 if c
.abstract
and c
.destructor
~='private' then
670 -- is it really abstract?
672 for _
, f
in pairs(c
.virtuals
) do
673 -- if it is abstract but we cannot overload
674 if f
.xarg
.abstract
=='1' and not f
.virtual_overload
then a
= true break end
678 -- FIXME: destructor should not matter
679 c
.shell
= (not c
.abstract
) and (c
.destructor
~='private')
680 for _
, constr
in ipairs(c
.constructors
) do
681 local shellname
= 'lqt_shell_'..string.gsub(c
.xarg
.fullname
, '::', '_LQT_')
682 constr
.calling_line
= '*new '..shellname
..'(L'
683 for i
=1,#(constr
.arguments
) do
684 constr
.calling_line
= constr
.calling_line
.. ', arg' .. i
686 constr
.calling_line
= constr
.calling_line
.. ')'
692 local print_enum_tables
= function(enums
)
693 for e
in pairs(enums
) do
694 local table = 'static lqt_Enum lqt_enum'..e
.xarg
.id
..'[] = {\n'
695 --io.stderr:write(e.xarg.fullname, '\t', #e.values, '\n')
696 for _
,v
in pairs(e
.values
) do
697 table = table .. ' { "' .. v
.xarg
.name
698 .. '", static_cast<int>('..v
.xarg
.fullname
..') },\n'
700 table = table .. ' { 0, 0 }\n'
701 table = table .. '};\n'
707 local print_enum_creator
= function(enums
)
708 local out
= 'static lqt_Enumlist lqt_enum_list[] = {\n'
709 for e
in pairs(enums
) do
710 out
= out
..' { lqt_enum'..e
.xarg
.id
..', "'..e
.xarg
.fullname
..'" },\n'
712 out
= out
..' { 0, 0 },\n};\n'
713 out
= out
.. 'extern "C" int lqt_create_enums (lua_State *L) {\n'
714 out
= out
.. ' lqtL_createenumlist(L, lqt_enum_list); return 0;\n}\n'
719 local print_openmodule
= function(n
)
722 extern "C" int luaopen_]]..n
..[[ (lua_State *L) {
724 lqtL_createclasses(L, lqt_class_list);
730 local functions
= copy_functions(idindex
)
731 local functions
= fix_functions(functions
, idindex
)
733 local enums
= copy_enums(idindex
)
734 local enums
= fix_enums(enums
)
736 local classes
= copy_classes(idindex
)
737 local classes
= fill_virtuals(classes
)
738 local classes
= fill_special_methods(classes
)
739 local classes
= fill_copy_constructor(classes
)
740 local classes
= fix_methods_wrappers(classes
)
742 local ntable
= function(t
) local ret
=0 for _
in pairs(t
) do ret
=ret
+1 end return ret
end
745 local typesystem
= {}
747 local ts
= dofile'types.lua'
748 setmetatable(typesystem
, {
749 __newindex
= function(t
, k
, v
)
750 --debug('added type', k)
753 __index
= function(t
, k
)
755 --if not ret then debug("unknown type:", tostring(k), ret) end
761 --debug('funcs', ntable(functions))
762 --debug('enums', ntable(enums))
763 --debug('class', ntable(classes))
764 local enums
= fill_typesystem_with_enums(enums
, typesystem
)
765 local classes
= fill_typesystem_with_classes(classes
, typesystem
)
766 local functions
= fill_wrappers(functions
, typesystem
)
767 local classes
= fill_shell_classes(classes
, typesystem
)
768 local classes
= print_virtual_overloads(classes
, typesystem
)
769 local classes
= print_wrappers(classes
)
770 local enums
= print_enum_tables(enums
)
771 local enums
= print_enum_creator(enums
)
772 local classes
= print_metatables(classes
)
773 local classes
= print_class_list(classes
)
774 --debug('funcs', ntable(functions))
775 --debug('enums', ntable(enums))
776 --debug('class', ntable(classes))
777 print_openmodule
'src'
779 local print_virtuals
= function(index
)
780 for c
in pairs(index
) do
782 for n
, f
in pairs(c
.virtuals
) do debug(' '..n
, f
.xarg
.fullname
) end
787 for f
in pairs(idindex
) do
788 if f
.label
=='Function' and f
.xarg
.name
=='connect' then
789 --debug(f.xarg.fullname, f.xarg.wrapper_code and 'true' or 'false')
790 local w
= fill_wrapper_code(f
, typesystem
, debug
)
792 --print(k, v.get'INDEX')
793 elseif f
.label
=='Function' and f
.xarg
.name
=='QObject' then
794 --debug('==>', #f.arguments, f.wrapper_code and 'wrapped' or 'gone')
798 --print_virtuals(classes)
800 --print(copy_functions(idindex))