luaobject: use object header and standard gc everywhere

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-06-16 16:24:58 +02:00
parent 6b24af7238
commit c95ba76d2f
14 changed files with 14 additions and 28 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -29,8 +29,7 @@
typedef struct
{
/** Lua references */
luaA_ref_array_t refs;
LUA_OBJECT_HEADER
/** Imlib2 image */
Imlib_Image image;
/** Image data */

3
key.c
View file

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

3
key.h
View file

@ -26,8 +26,7 @@
typedef struct keyb_t
{
/** Lua references */
luaA_ref_array_t refs;
LUA_OBJECT_HEADER
/** Key modifier */
uint16_t mod;
/** Keysym */

3
tag.c
View file

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

3
tag.h
View file

@ -27,8 +27,7 @@
/** Tag type */
struct tag
{
/** Lua references count */
luaA_ref_array_t refs;
LUA_OBJECT_HEADER
/** Tag name */
char *name;
/** Screen */

View file

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

View file

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

View file

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

View file

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