From c95ba76d2fe7db00efffff4eb96c6cf88e1d775d Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 16 Jun 2009 16:24:58 +0200 Subject: [PATCH] luaobject: use object header and standard gc everywhere Signed-off-by: Julien Danjou --- button.c | 3 +-- button.h | 3 +-- client.c | 3 +-- client.h | 3 +-- image.c | 3 +-- image.h | 3 +-- key.c | 3 +-- key.h | 3 +-- tag.c | 3 +-- tag.h | 3 +-- wibox.c | 3 +-- wibox.h | 3 +-- widget.c | 3 +-- widget.h | 3 +-- 14 files changed, 14 insertions(+), 28 deletions(-) diff --git a/button.c b/button.c index f6fbf018a..0be4eadd3 100644 --- a/button.c +++ b/button.c @@ -40,10 +40,9 @@ static int luaA_button_gc(lua_State *L) { button_t *button = luaL_checkudata(L, 1, "button"); - luaA_ref_array_wipe(&button->refs); luaL_unref(globalconf.L, LUA_REGISTRYINDEX, button->press); luaL_unref(globalconf.L, LUA_REGISTRYINDEX, button->release); - return 0; + return luaA_object_gc(L); } /** Create a new mouse button bindings. diff --git a/button.h b/button.h index 9a7d4eef4..ef84c999f 100644 --- a/button.h +++ b/button.h @@ -27,8 +27,7 @@ /** Mouse buttons bindings */ struct button_t { - /** Lua references */ - luaA_ref_array_t refs; + LUA_OBJECT_HEADER /** Key modifiers */ uint16_t mod; /** Mouse button number */ diff --git a/client.c b/client.c index 8bd4e13da..0921f34be 100644 --- a/client.c +++ b/client.c @@ -51,7 +51,6 @@ static int luaA_client_gc(lua_State *L) { client_t *c = luaL_checkudata(L, 1, "client"); - luaA_ref_array_wipe(&c->refs); button_array_wipe(&c->buttons); image_unref(L, c->icon); p_delete(&c->class); @@ -59,7 +58,7 @@ luaA_client_gc(lua_State *L) p_delete(&c->instance); p_delete(&c->icon_name); p_delete(&c->name); - return 0; + return luaA_object_gc(L); } /** Change the clients urgency flag. diff --git a/client.h b/client.h index 1dd257c93..e7ac0e386 100644 --- a/client.h +++ b/client.h @@ -67,8 +67,7 @@ typedef struct /** client_t type */ struct client_t { - /** Lua reference counter */ - luaA_ref_array_t refs; + LUA_OBJECT_HEADER /** Valid, or not ? */ bool invalid; /** Client name */ diff --git a/image.c b/image.c index 680c52dd2..a71df33ea 100644 --- a/image.c +++ b/image.c @@ -28,11 +28,10 @@ static int luaA_image_gc(lua_State *L) { image_t *p = luaL_checkudata(L, 1, "image"); - luaA_ref_array_wipe(&p->refs); imlib_context_set_image(p->image); imlib_free_image(); p_delete(&p->data); - return 0; + return luaA_object_gc(L); } static const char * diff --git a/image.h b/image.h index 03d52be69..a9acd936b 100644 --- a/image.h +++ b/image.h @@ -29,8 +29,7 @@ typedef struct { - /** Lua references */ - luaA_ref_array_t refs; + LUA_OBJECT_HEADER /** Imlib2 image */ Imlib_Image image; /** Image data */ diff --git a/key.c b/key.c index 6460e38f3..3c774f59d 100644 --- a/key.c +++ b/key.c @@ -50,10 +50,9 @@ static int luaA_key_gc(lua_State *L) { keyb_t *kbp = luaL_checkudata(L, 1, "key"); - luaA_ref_array_wipe(&kbp->refs); luaL_unref(globalconf.L, LUA_REGISTRYINDEX, kbp->press); luaL_unref(globalconf.L, LUA_REGISTRYINDEX, kbp->release); - return 0; + return luaA_object_gc(L); } /** Grab key on a window. diff --git a/key.h b/key.h index 38dbd6995..010ae4625 100644 --- a/key.h +++ b/key.h @@ -26,8 +26,7 @@ typedef struct keyb_t { - /** Lua references */ - luaA_ref_array_t refs; + LUA_OBJECT_HEADER /** Key modifier */ uint16_t mod; /** Keysym */ diff --git a/tag.c b/tag.c index e5d9bbba6..92984b657 100644 --- a/tag.c +++ b/tag.c @@ -41,10 +41,9 @@ static int luaA_tag_gc(lua_State *L) { tag_t *tag = luaL_checkudata(L, 1, "tag"); - luaA_ref_array_wipe(&tag->refs); client_array_wipe(&tag->clients); p_delete(&tag->name); - return 0; + return luaA_object_gc(L); } /** View or unview a tag. diff --git a/tag.h b/tag.h index 5c4608a4b..1fd29143f 100644 --- a/tag.h +++ b/tag.h @@ -27,8 +27,7 @@ /** Tag type */ struct tag { - /** Lua references count */ - luaA_ref_array_t refs; + LUA_OBJECT_HEADER /** Tag name */ char *name; /** Screen */ diff --git a/wibox.c b/wibox.c index fcba4eb23..7a4d2b714 100644 --- a/wibox.c +++ b/wibox.c @@ -38,7 +38,6 @@ static int luaA_wibox_gc(lua_State *L) { wibox_t *wibox = luaL_checkudata(L, 1, "wibox"); - luaA_ref_array_wipe(&wibox->refs); p_delete(&wibox->cursor); simplewindow_wipe(&wibox->sw); button_array_wipe(&wibox->buttons); @@ -47,7 +46,7 @@ luaA_wibox_gc(lua_State *L) luaL_unref(L, LUA_REGISTRYINDEX, wibox->mouse_enter); luaL_unref(L, LUA_REGISTRYINDEX, wibox->mouse_leave); widget_node_array_wipe(&wibox->widgets); - return 0; + return luaA_object_gc(L); } void diff --git a/wibox.h b/wibox.h index d35205a33..5f548d0f0 100644 --- a/wibox.h +++ b/wibox.h @@ -35,8 +35,7 @@ typedef enum /** Wibox type */ struct wibox_t { - /** Lua references */ - luaA_ref_array_t refs; + LUA_OBJECT_HEADER /** Ontop */ bool ontop; /** Visible */ diff --git a/widget.c b/widget.c index 78a40c624..5d83a9ca8 100644 --- a/widget.c +++ b/widget.c @@ -44,13 +44,12 @@ static int luaA_widget_gc(lua_State *L) { widget_t *widget = luaL_checkudata(L, 1, "widget"); - luaA_ref_array_wipe(&widget->refs); if(widget->destructor) widget->destructor(widget); button_array_wipe(&widget->buttons); luaL_unref(globalconf.L, LUA_REGISTRYINDEX, widget->mouse_enter); luaL_unref(globalconf.L, LUA_REGISTRYINDEX, widget->mouse_leave); - return 0; + return luaA_object_gc(L); } /** Delete a widget node structure. diff --git a/widget.h b/widget.h index d424dd584..f2ca04822 100644 --- a/widget.h +++ b/widget.h @@ -31,8 +31,7 @@ typedef void (widget_destructor_t)(widget_t *); /** Widget */ struct widget_t { - /** Lua references */ - luaA_ref_array_t refs; + LUA_OBJECT_HEADER /** Widget type is constructor */ widget_constructor_t *type; /** Widget destructor */