4 #include "lqt_common.hpp"
5 #include "lqt_function.hpp"
6 #include "lqt_bind_QAbstractScrollArea.hpp"
7 #include "lqt_bind_QAction.hpp"
8 #include "lqt_bind_QApplication.hpp"
9 #include "lqt_bind_QCoreApplication.hpp"
10 #include "lqt_bind_QColor.hpp"
11 #include "lqt_bind_QEvent.hpp"
12 #include "lqt_bind_QFileDialog.hpp"
13 #include "lqt_bind_QFrame.hpp"
14 #include "lqt_bind_QFont.hpp"
15 #include "lqt_bind_QIcon.hpp"
16 #include "lqt_bind_QInputEvent.hpp"
17 #include "lqt_bind_QKeyEvent.hpp"
18 #include "lqt_bind_QKeySequence.hpp"
19 #include "lqt_bind_QLabel.hpp"
20 #include "lqt_bind_QLineEdit.hpp"
21 #include "lqt_bind_QMainWindow.hpp"
22 #include "lqt_bind_QMessageBox.hpp"
23 #include "lqt_bind_QMenu.hpp"
24 #include "lqt_bind_QMenuBar.hpp"
25 #include "lqt_bind_QObject.hpp"
26 #include "lqt_bind_QPaintDevice.hpp"
27 #include "lqt_bind_QShortcut.hpp"
28 #include "lqt_bind_QSize.hpp"
29 #include "lqt_bind_QSyntaxHighlighter.hpp"
30 #include "lqt_bind_QTextBlockUserData.hpp"
31 #include "lqt_bind_QTextCharFormat.hpp"
32 #include "lqt_bind_QTextCursor.hpp"
33 #include "lqt_bind_QTextDocument.hpp"
34 #include "lqt_bind_QTextEdit.hpp"
35 #include "lqt_bind_QToolBar.hpp"
36 #include "lqt_bind_QWidget.hpp"
37 #include "lqt_bind_QVBoxLayout.hpp"
38 #include "lqt_bind_QBoxLayout.hpp"
39 #include "lqt_bind_QLayoutItem.hpp"
40 #include "lqt_bind_QLayout.hpp"
41 #include "lqt_bind_Qt.hpp"
42 #include "lqt_bind_QGraphicsView.hpp"
43 #include "lqt_bind_QGraphicsScene.hpp"
44 #include "lqt_bind_QGraphicsItem.hpp"
46 static int qt_connect (lua_State
*L
) {
48 static_cast<QObject
*>(lqtL_toudata(L
, 1, "QObject*")),
50 static_cast<QObject
*>(lqtL_toudata(L
, 3, "QObject*")),
54 static int qt_slot (lua_State
*L
) {
55 lua_pushstring(L
, "1");
61 static int qt_signal (lua_State
*L
) {
62 lua_pushstring(L
, "2");
68 static int retriever (lua_State
*L
) {
69 lua_pushvalue(L
, lua_upvalueindex(1));
72 static int derive (lua_State
*L
) {
73 if (!lua_isuserdata(L
, 1) || !lua_getmetatable(L
, 1)) {
75 lua_pushstring(L
, "no userdata or no metatable given");
78 lua_getfield(L
, -1, "__qtype");
79 if (!lua_isstring(L
, -1)) {
81 lua_pushstring(L
, "not a Qt type");
90 lua_setfield(L
, -2, "__base");
91 lua_pushcfunction(L
, lqtL_index
);
92 lua_setfield(L
, -2, "__index");
93 lua_pushcfunction(L
, lqtL_newindex
);
94 lua_setfield(L
, -2, "__newindex");
95 lua_setmetatable(L
, 1);
99 static int slot_from_function (lua_State
*L
) {
101 LuaFunction
*f
= new LuaFunction(L
);
103 lua_pushstring(L
, "1function()");
107 void push_relevant (lua_State
*L
) {
108 lua_pushcfunction(L
, derive
);
109 lua_setglobal(L
, "derive");
111 lua_pushcfunction(L
, slot_from_function
);
112 lua_setglobal(L
, "slot_from_function");
114 lua_pushcfunction(L
, qt_signal
);
115 lua_setglobal(L
, "signal");
117 lua_pushcfunction(L
, qt_slot
);
118 lua_setglobal(L
, "slot");
120 lua_pushcfunction(L
, qt_connect
);
121 lua_setglobal(L
, "connect");
126 int main(int argc
, char **argv
) {
128 //QApplication *app = new QApplication(argc, argv);
130 lua_State
*L
= lua_open();
135 luaopen_QGraphicsView(L
);
136 luaopen_QGraphicsItem(L
);
137 luaopen_QGraphicsScene(L
);
138 luaopen_QAbstractScrollArea(L
);
141 luaopen_QVBoxLayout(L
);
142 luaopen_QBoxLayout(L
);
143 luaopen_QApplication(L
);
144 luaopen_QCoreApplication(L
);
148 luaopen_QFileDialog(L
);
151 luaopen_QInputEvent(L
);
152 luaopen_QKeyEvent(L
);
153 luaopen_QKeySequence(L
);
155 luaopen_QLineEdit(L
);
156 luaopen_QMainWindow(L
);
157 luaopen_QMessageBox(L
);
161 luaopen_QPaintDevice(L
);
162 luaopen_QShortcut(L
);
164 luaopen_QSyntaxHighlighter(L
);
166 luaopen_QTextBlockUserData(L
);
167 luaopen_QTextCursor(L
);
168 luaopen_QTextCharFormat(L
);
169 luaopen_QTextDocument(L
);
170 luaopen_QTextEdit(L
);
174 luaL_getmetatable(L
, "QAbstractScrollArea*");
175 lua_setglobal(L
, "QAbstractScrollArea");
176 luaL_getmetatable(L
, "QLayout*");
177 lua_setglobal(L
, "QLayout");
178 luaL_getmetatable(L
, "QVBoxLayout*");
179 lua_setglobal(L
, "QVBoxLayout");
180 luaL_getmetatable(L
, "QBoxLayout*");
181 lua_setglobal(L
, "QBoxLayout");
182 luaL_getmetatable(L
, "QApplication*");
183 lua_setglobal(L
, "QApplication");
184 luaL_getmetatable(L
, "QCoreApplication*");
185 lua_setglobal(L
, "QCoreApplication");
186 luaL_getmetatable(L
, "QEvent*");
187 lua_setglobal(L
, "QEvent");
188 luaL_getmetatable(L
, "QFrame*");
189 lua_setglobal(L
, "QFrame");
190 luaL_getmetatable(L
, "QFont*");
191 lua_setglobal(L
, "QFont");
192 luaL_getmetatable(L
, "QInputEvent*");
193 lua_setglobal(L
, "QInputEvent");
194 luaL_getmetatable(L
, "QKeyEvent*");
195 lua_setglobal(L
, "QKeyEvent");
196 luaL_getmetatable(L
, "QKeySequence*");
197 lua_setglobal(L
, "QKeySequence");
198 luaL_getmetatable(L
, "QLabel*");
199 lua_setglobal(L
, "QLabel");
200 luaL_getmetatable(L
, "QLineEdit*");
201 lua_setglobal(L
, "QLineEdit");
202 luaL_getmetatable(L
, "QMainWindow*");
203 lua_setglobal(L
, "QMainWindow");
204 luaL_getmetatable(L
, "QObject*");
205 lua_setglobal(L
, "QObject");
206 luaL_getmetatable(L
, "QPaintDevice*");
207 lua_setglobal(L
, "QPaintDevice");
208 luaL_getmetatable(L
, "QShortcut*");
209 lua_setglobal(L
, "QShortcut");
210 luaL_getmetatable(L
, "QTextCursor*");
211 lua_setglobal(L
, "QTextCursor");
212 luaL_getmetatable(L
, "QTextDocument*");
213 lua_setglobal(L
, "QTextDocument");
214 luaL_getmetatable(L
, "QTextEdit*");
215 lua_setglobal(L
, "QTextEdit");
216 luaL_getmetatable(L
, "QWidget*");
217 lua_setglobal(L
, "QWidget");
219 if (luaL_dofile(L
, "editor.lua")) {
220 std::cerr
<< lua_tostring(L
, 1) << std::endl
;
224 //if (status==0) status = app->exec();