6 function NOINSTANCE(b
, name
)
7 b
.types_from_stack
[name
] = function(i
) error('cannot copy '..name
) end
8 b
.types_test
[name
] = function(i
) error('cannot copy '..name
) end
9 b
.types_to_stack
[name
] = function(i
) error('cannot copy '..name
) end
11 b
.types_from_stack
[(name
..' *')] = function(i
) return '*static_cast<'..name
..'**>(lqtL_toudata(L, '..tostring(i
)..', "'..name
..'"))' end
12 b
.types_test
[(name
..' *')] = function(i
) return 'lqtL_testudata(L, '..tostring(i
)..', "'..name
..'*")' end
13 b
.types_to_stack
[(name
..' *')] = function(i
) return 'lqtL_pushudata(L, '..tostring(i
)..', "'..name
..'*")' end
16 function cp_file(src
, dst
)
17 src
= (type(src
)=='string') and io
.open(src
, 'r') or src
18 dst
= (type(dst
)=='string') and io
.open(dst
, 'w') or dst
19 local content
= src
:read('*a')
27 local h
, c
= B
:make_namespace(n
, n
)
28 print(n
..': writing definition file')
29 f
= io
.open('src/lqt_bind_'..n
..'.cpp', 'w')
33 print(n
..': writing prototypes file')
34 f
= io
.open('src/lqt_bind_'..n
..'.hpp', 'w')
39 function make_standard_qt(B
, classlist
)
41 cp_file('lqt_common.hpp', 'src/lqt_common.hpp')
42 cp_file('lqt_common.cpp', 'src/lqt_common.cpp')
46 for s
in string.gmatch(classlist
, '([%u%l%d]+)') do
52 local tmpfile
='tmp/auto'
54 f
= io
.open(tmpfile
..'.cpp', 'w')
55 for n
in pairs(classlist
) do
56 f
:write('#include <'..n
..'>\n')
59 for n
in pairs(classlist
) do
60 f
:write(' '..n
..' *'..string.lower(n
)..';\n')
65 --os.execute'gccxml -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -fxml=auto.xml auto.cpp'
66 os
.execute('gccxml `pkg-config QtGui QtCore --cflags` -fxml='..tmpfile
..'.xml '..tmpfile
..'.cpp')
70 B
:init(tmpfile
..'.xml')
72 B
.filter
= function (m
)
73 local n
= type(m
)=='table' and type(m
.attr
)=='table' and m
.attr
.name
74 if n
and string.match(n
, "[_%w]*[xX]11[_%w]*$") then
75 return true, 'it is X11 specific'
77 if n
and string.match(n
, "[_%w]*_[_%w]*$") then
78 return true, 'it is meant to be internal'
84 NOINSTANCE(B
, 'QCoreApplication')
87 B
.types_from_stack
['QString'] = function(i
) return 'QString::fromAscii(lua_tostring(L, '..tostring(i
)..'), lua_objlen(L, '..tostring(i
)..'))' end
88 B
.types_test
['QString'] = function(i
) return '(lua_type(L, ' .. tostring(i
) .. ')==LUA_TSTRING)' end
89 B
.types_to_stack
['QString'] = function(i
) return 'lua_pushlstring(L, '..tostring(i
)..'.toAscii().data(), '..tostring(i
)..'.toAscii().size())' end
91 B
.types_from_stack
['QByteArray'] = function(i
) return 'QByteArray(lua_tostring(L, '..tostring(i
)..'), lua_objlen(L, '..tostring(i
)..'))' end
92 B
.types_test
['QByteArray'] = function(i
) return '(lua_type(L, ' .. tostring(i
) .. ')==LUA_TSTRING)' end
93 B
.types_to_stack
['QByteArray'] = function(i
) return 'lua_pushlstring(L, '..tostring(i
)..'.data(), '..tostring(i
)..'.size())' end
98 for n
in pairs(classlist
) do
99 local c
= B
:find_name(n
)
100 clist
= B
.set_union(clist
, B
:tree_of_bases(c
))
102 classlist
= B
.set_union(classlist
, clist
)
105 for n
in pairs(classlist
) do
110 make_standard_qt(B
, [[