luaobject: emit signal on new object

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-06-09 12:51:25 +02:00
parent 4003ef726f
commit c1d99f0960
15 changed files with 31 additions and 9 deletions

View File

@ -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 }
};

View File

@ -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

View File

@ -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 },

View File

@ -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 { \

View File

@ -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; \
} \
\

View File

@ -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 }

View File

@ -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 *);

1
key.c
View File

@ -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 }
};

3
key.h
View File

@ -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);

1
tag.c
View File

@ -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 }
};

3
tag.h
View File

@ -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

View File

@ -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 }
};

View File

@ -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

View File

@ -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 }
};

View File

@ -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
{