1 #include "lqt_qt_utils.hpp"
2 #include "lqt_function.hpp"
4 static int qt_slot_from_string (lua_State
*L
) {
5 lua_pushstring(L
, "1");
11 static int qt_signal (lua_State
*L
) {
12 lua_pushstring(L
, "2");
18 static int qt_derive (lua_State
*L
) {
19 if (!lua_isuserdata(L
, 1) || !lua_getmetatable(L
, 1)) {
21 lua_pushstring(L
, "no userdata or no metatable given");
24 lua_getfield(L
, -1, "__qtype");
25 if (!lua_isstring(L
, -1)) {
27 lua_pushstring(L
, "not a Qt type");
36 lua_setfield(L
, -2, "__base");
37 lua_pushcfunction(L
, lqtL_index
);
38 lua_setfield(L
, -2, "__index");
39 lua_pushcfunction(L
, lqtL_newindex
);
40 lua_setfield(L
, -2, "__newindex");
41 lua_setmetatable(L
, 1);
45 static int qt_slot_from_function (lua_State
*L
) {
47 LuaFunction
*f
= new LuaFunction(L
);
49 lua_pushstring(L
, "1function()");
53 static int qt_slot (lua_State
*L
) {
55 if (lua_type(L
, 1)==LUA_TSTRING
) {
56 ret
= qt_slot_from_string(L
);
57 } else if (lua_type(L
, 1)==LUA_TFUNCTION
) {
58 ret
= qt_slot_from_function(L
);
63 static luaL_Reg libqt
[] = {
65 { "signal", qt_signal
},
66 { "derive", qt_derive
},
70 int luaopen_qt (lua_State
*L
) {
71 luaL_register(L
, "qt", libqt
);