1 module('signalslot', package
.seeall
)
3 local print_slot_h
= fprint(assert(io
.open(module_name
.._src
..module_name
..'_slot.hpp', 'w')))
4 local print_slot_c
= fprint(assert(io
.open(module_name
.._src
..module_name
..'_slot.cpp', 'w')))
9 function copy_signals(functions
)
10 for f
in pairs(functions
) do
11 if f
.xarg
.signal
=='1' then
13 if f
.xarg
.access
== 'protected' then
14 f
.xarg
.access
= 'public'
20 function slots_for_signals()
21 for sig
in pairs(signals
) do
22 local args
, comma
= '(', ''
23 for i
, a
in ipairs(sig
.arguments
) do
24 args
= args
.. comma
.. a
.xarg
.type_name
.. ' arg'..i
28 local pushlines
, stack
= make_pushlines(sig
.arguments
)
30 if not slots
['void __slot '..args
] then
31 slots
['void __slot '..args
] = 'void LqtSlotAcceptor::__slot '..args
..[[ {
32 //int oldtop = lua_gettop(L);
33 //lua_getfield(L, -1, "__slot]]..string.gsub(args
, ' arg.', '')..[[");
34 //if (lua_isnil(L, -1)) {
36 //lua_getfield(L, -1, "__slot");
38 //if (!lua_isfunction(L, -1)) {
39 //lua_settop(L, oldtop);
44 if (lqtL_pcall(L, ]]..stack
..[[+1, 0, 0)) {
46 qDebug() << lua_tostring(L, -1);
49 //lua_settop(L, oldtop);
54 ignore(sig
.xarg
.fullname
, 'slot', stack
)
59 function print_slots(s
)
60 print_slot_h
'class LqtSlotAcceptor : public QObject {'
61 print_slot_h
' Q_OBJECT'
62 print_slot_h
' lua_State *L;'
63 print_slot_h
' public:'
64 print_slot_h(' LqtSlotAcceptor(lua_State *l, QObject *p=NULL) : QObject(p), L(l) { setObjectName("'..module_name
..'"); lqtL_register(L, this); }')
65 print_slot_h
' virtual ~LqtSlotAcceptor() { lqtL_unregister(L, this); }'
66 print_slot_h
' public slots:'
67 for p
, b
in pairs(s
) do
68 print_slot_h(' '..p
..';')
72 print_slot_h('\nextern LqtSlotAcceptor *lqtSlotAcceptor_'..module_name
..';')
73 print_slot_c('\nLqtSlotAcceptor *lqtSlotAcceptor_'..module_name
..';')
77 -------------------------------------------------------------------------------
79 function process(functions
)
80 copy_signals(functions
)
85 print_slot_h('#ifndef LQT_SLOT_'..module_name
)
86 print_slot_h('#define LQT_SLOT_'..module_name
)
87 print_slot_h(output_includes
)
88 print_slot_c('#include "'..module_name
..'_slot.hpp'..'"\n\n')
92 print_slot_h('#endif')