diff --git a/button.c b/button.c index 0b398827..359e9ce1 100644 --- a/button.c +++ b/button.c @@ -144,6 +144,7 @@ luaA_button_newindex(lua_State *L) const struct luaL_reg awesome_button_methods[] = { + LUA_CLASS_METHODS(button) { "__call", luaA_button_new }, { NULL, NULL } }; diff --git a/button.h b/button.h index 572b3dd2..a89749b3 100644 --- a/button.h +++ b/button.h @@ -38,7 +38,8 @@ struct button_t void *release; }; -LUA_OBJECT_FUNCS(button_t, button, "button") +lua_class_t button_class; +LUA_OBJECT_FUNCS(button_class, button_t, button, "button") #endif // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/client.c b/client.c index 55f717a9..a83ec847 100644 --- a/client.c +++ b/client.c @@ -1956,6 +1956,7 @@ luaA_client_module_newindex(lua_State *L) const struct luaL_reg awesome_client_methods[] = { + LUA_CLASS_METHODS(client) { "get", luaA_client_get }, { "__index", luaA_client_module_index }, { "__newindex", luaA_client_module_newindex }, diff --git a/client.h b/client.h index a7cb5cf3..16142e83 100644 --- a/client.h +++ b/client.h @@ -24,6 +24,7 @@ #include "mouse.h" #include "stack.h" +#include "common/luaclass.h" #define CLIENT_SELECT_INPUT_EVENT_MASK (XCB_EVENT_MASK_STRUCTURE_NOTIFY \ | XCB_EVENT_MASK_PROPERTY_CHANGE \ @@ -154,7 +155,11 @@ struct client_t client_t * luaA_client_checkudata(lua_State *, int); ARRAY_FUNCS(client_t *, client, DO_NOTHING) -LUA_OBJECT_FUNCS(client_t, client, "client") + +/** Client class */ +lua_class_t client_class; + +LUA_OBJECT_FUNCS(client_class, client_t, client, "client") #define client_need_reban(c) \ do { \ diff --git a/common/luaobject.h b/common/luaobject.h index e2cdc0d0..8d11c122 100644 --- a/common/luaobject.h +++ b/common/luaobject.h @@ -22,7 +22,7 @@ #ifndef AWESOME_COMMON_LUAOBJECT #define AWESOME_COMMON_LUAOBJECT -#include "common/signal.h" +#include "common/luaclass.h" static inline int luaA_settype(lua_State *L, const char *type) @@ -160,7 +160,8 @@ typedef struct LUA_OBJECT_HEADER } lua_object_t; -#define LUA_OBJECT_FUNCS(type, prefix, lua_type) \ +#define LUA_OBJECT_FUNCS(lua_class, type, prefix, lua_type) \ + LUA_CLASS_FUNCS(prefix, lua_class) \ static inline type * \ prefix##_new(lua_State *L) \ { \ @@ -171,6 +172,8 @@ typedef struct lua_newtable(L); \ lua_setmetatable(L, -2); \ lua_setfenv(L, -2); \ + lua_pushvalue(L, -1); \ + luaA_class_emit_signal(L, &(lua_class), "new", 1); \ return p; \ } \ \ diff --git a/image.c b/image.c index a4fb713e..8bdcc43d 100644 --- a/image.c +++ b/image.c @@ -770,6 +770,7 @@ luaA_image_index(lua_State *L) const struct luaL_reg awesome_image_methods[] = { + LUA_CLASS_METHODS(image) { "__call", luaA_image_new }, { "argb32", luaA_image_argb32_new }, { NULL, NULL } diff --git a/image.h b/image.h index 1df544ce..82b69e00 100644 --- a/image.h +++ b/image.h @@ -26,6 +26,7 @@ #include "common/util.h" #include "common/luaobject.h" +#include "common/luaclass.h" typedef struct { @@ -39,7 +40,8 @@ typedef struct bool isupdated; } image_t; -LUA_OBJECT_FUNCS(image_t, image, "image") +lua_class_t image_class; +LUA_OBJECT_FUNCS(image_class, image_t, image, "image") int image_new_from_argb32(int, int, uint32_t *); uint8_t * image_getdata(image_t *); diff --git a/key.c b/key.c index a4f07369..0598dbef 100644 --- a/key.c +++ b/key.c @@ -1146,6 +1146,7 @@ luaA_key_newindex(lua_State *L) const struct luaL_reg awesome_key_methods[] = { + LUA_CLASS_METHODS(key) { "__call", luaA_key_new }, { NULL, NULL } }; diff --git a/key.h b/key.h index 49efcbf1..40a53461 100644 --- a/key.h +++ b/key.h @@ -39,7 +39,8 @@ typedef struct keyb_t void *release; } keyb_t; -LUA_OBJECT_FUNCS(keyb_t, key, "key") +lua_class_t key_class; +LUA_OBJECT_FUNCS(key_class, keyb_t, key, "key") bool key_press_lookup_string(xcb_keysym_t, char *, ssize_t); xcb_keysym_t key_getkeysym(xcb_keycode_t, uint16_t); diff --git a/tag.c b/tag.c index e24b0c0e..842a2c7b 100644 --- a/tag.c +++ b/tag.c @@ -405,6 +405,7 @@ luaA_tag_newindex(lua_State *L) const struct luaL_reg awesome_tag_methods[] = { + LUA_CLASS_METHODS(tag) { "__call", luaA_tag_new }, { NULL, NULL } }; diff --git a/tag.h b/tag.h index 1fd29143..b5178255 100644 --- a/tag.h +++ b/tag.h @@ -47,7 +47,8 @@ void tag_append_to_screen(screen_t *); void tag_unref_simplified(tag_t **); ARRAY_FUNCS(tag_t *, tag, tag_unref_simplified) -LUA_OBJECT_FUNCS(tag_t, tag, "tag") +lua_class_t tag_class; +LUA_OBJECT_FUNCS(tag_class, tag_t, tag, "tag") #endif // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/wibox.c b/wibox.c index c7afd6a2..2e4dbe17 100644 --- a/wibox.c +++ b/wibox.c @@ -1201,6 +1201,7 @@ luaA_wibox_newindex(lua_State *L) const struct luaL_reg awesome_wibox_methods[] = { + LUA_CLASS_METHODS(wibox) { "__call", luaA_wibox_new }, { NULL, NULL } }; diff --git a/wibox.h b/wibox.h index d62779b8..f6666704 100644 --- a/wibox.h +++ b/wibox.h @@ -116,7 +116,8 @@ void wibox_border_width_set(wibox_t *, uint32_t); void wibox_border_color_set(wibox_t *, const xcolor_t *); void wibox_orientation_set(wibox_t *, orientation_t); -LUA_OBJECT_FUNCS(wibox_t, wibox, "wibox") +lua_class_t wibox_class; +LUA_OBJECT_FUNCS(wibox_class, wibox_t, wibox, "wibox") #endif // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/widget.c b/widget.c index 0ba65104..df4144ed 100644 --- a/widget.c +++ b/widget.c @@ -552,6 +552,7 @@ luaA_widget_extents(lua_State *L) const struct luaL_reg awesome_widget_methods[] = { + LUA_CLASS_METHODS(widget) { "__call", luaA_widget_new }, { NULL, NULL } }; diff --git a/widget.h b/widget.h index aa8f5d29..f0d5261a 100644 --- a/widget.h +++ b/widget.h @@ -56,7 +56,8 @@ struct widget_t bool isvisible; }; -LUA_OBJECT_FUNCS(widget_t, widget, "widget"); +lua_class_t widget_class; +LUA_OBJECT_FUNCS(widget_class, widget_t, widget, "widget"); struct widget_node_t {