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) luaA_button_gc(lua_State *L)
{ {
button_t *button = luaL_checkudata(L, 1, "button"); 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->press);
luaL_unref(globalconf.L, LUA_REGISTRYINDEX, button->release); luaL_unref(globalconf.L, LUA_REGISTRYINDEX, button->release);
return 0; return luaA_object_gc(L);
} }
/** Create a new mouse button bindings. /** Create a new mouse button bindings.

View File

@ -27,8 +27,7 @@
/** Mouse buttons bindings */ /** Mouse buttons bindings */
struct button_t struct button_t
{ {
/** Lua references */ LUA_OBJECT_HEADER
luaA_ref_array_t refs;
/** Key modifiers */ /** Key modifiers */
uint16_t mod; uint16_t mod;
/** Mouse button number */ /** Mouse button number */

View File

@ -51,7 +51,6 @@ static int
luaA_client_gc(lua_State *L) luaA_client_gc(lua_State *L)
{ {
client_t *c = luaL_checkudata(L, 1, "client"); client_t *c = luaL_checkudata(L, 1, "client");
luaA_ref_array_wipe(&c->refs);
button_array_wipe(&c->buttons); button_array_wipe(&c->buttons);
image_unref(L, c->icon); image_unref(L, c->icon);
p_delete(&c->class); p_delete(&c->class);
@ -59,7 +58,7 @@ luaA_client_gc(lua_State *L)
p_delete(&c->instance); p_delete(&c->instance);
p_delete(&c->icon_name); p_delete(&c->icon_name);
p_delete(&c->name); p_delete(&c->name);
return 0; return luaA_object_gc(L);
} }
/** Change the clients urgency flag. /** Change the clients urgency flag.

View File

@ -67,8 +67,7 @@ typedef struct
/** client_t type */ /** client_t type */
struct client_t struct client_t
{ {
/** Lua reference counter */ LUA_OBJECT_HEADER
luaA_ref_array_t refs;
/** Valid, or not ? */ /** Valid, or not ? */
bool invalid; bool invalid;
/** Client name */ /** Client name */

View File

@ -28,11 +28,10 @@ static int
luaA_image_gc(lua_State *L) luaA_image_gc(lua_State *L)
{ {
image_t *p = luaL_checkudata(L, 1, "image"); image_t *p = luaL_checkudata(L, 1, "image");
luaA_ref_array_wipe(&p->refs);
imlib_context_set_image(p->image); imlib_context_set_image(p->image);
imlib_free_image(); imlib_free_image();
p_delete(&p->data); p_delete(&p->data);
return 0; return luaA_object_gc(L);
} }
static const char * static const char *

View File

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

3
key.c
View File

@ -50,10 +50,9 @@ static int
luaA_key_gc(lua_State *L) luaA_key_gc(lua_State *L)
{ {
keyb_t *kbp = luaL_checkudata(L, 1, "key"); 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->press);
luaL_unref(globalconf.L, LUA_REGISTRYINDEX, kbp->release); luaL_unref(globalconf.L, LUA_REGISTRYINDEX, kbp->release);
return 0; return luaA_object_gc(L);
} }
/** Grab key on a window. /** Grab key on a window.

3
key.h
View File

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

3
tag.c
View File

@ -41,10 +41,9 @@ static int
luaA_tag_gc(lua_State *L) luaA_tag_gc(lua_State *L)
{ {
tag_t *tag = luaL_checkudata(L, 1, "tag"); tag_t *tag = luaL_checkudata(L, 1, "tag");
luaA_ref_array_wipe(&tag->refs);
client_array_wipe(&tag->clients); client_array_wipe(&tag->clients);
p_delete(&tag->name); p_delete(&tag->name);
return 0; return luaA_object_gc(L);
} }
/** View or unview a tag. /** View or unview a tag.

3
tag.h
View File

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

View File

@ -38,7 +38,6 @@ static int
luaA_wibox_gc(lua_State *L) luaA_wibox_gc(lua_State *L)
{ {
wibox_t *wibox = luaL_checkudata(L, 1, "wibox"); wibox_t *wibox = luaL_checkudata(L, 1, "wibox");
luaA_ref_array_wipe(&wibox->refs);
p_delete(&wibox->cursor); p_delete(&wibox->cursor);
simplewindow_wipe(&wibox->sw); simplewindow_wipe(&wibox->sw);
button_array_wipe(&wibox->buttons); 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_enter);
luaL_unref(L, LUA_REGISTRYINDEX, wibox->mouse_leave); luaL_unref(L, LUA_REGISTRYINDEX, wibox->mouse_leave);
widget_node_array_wipe(&wibox->widgets); widget_node_array_wipe(&wibox->widgets);
return 0; return luaA_object_gc(L);
} }
void void

View File

@ -35,8 +35,7 @@ typedef enum
/** Wibox type */ /** Wibox type */
struct wibox_t struct wibox_t
{ {
/** Lua references */ LUA_OBJECT_HEADER
luaA_ref_array_t refs;
/** Ontop */ /** Ontop */
bool ontop; bool ontop;
/** Visible */ /** Visible */

View File

@ -44,13 +44,12 @@ static int
luaA_widget_gc(lua_State *L) luaA_widget_gc(lua_State *L)
{ {
widget_t *widget = luaL_checkudata(L, 1, "widget"); widget_t *widget = luaL_checkudata(L, 1, "widget");
luaA_ref_array_wipe(&widget->refs);
if(widget->destructor) if(widget->destructor)
widget->destructor(widget); widget->destructor(widget);
button_array_wipe(&widget->buttons); button_array_wipe(&widget->buttons);
luaL_unref(globalconf.L, LUA_REGISTRYINDEX, widget->mouse_enter); luaL_unref(globalconf.L, LUA_REGISTRYINDEX, widget->mouse_enter);
luaL_unref(globalconf.L, LUA_REGISTRYINDEX, widget->mouse_leave); luaL_unref(globalconf.L, LUA_REGISTRYINDEX, widget->mouse_leave);
return 0; return luaA_object_gc(L);
} }
/** Delete a widget node structure. /** Delete a widget node structure.

View File

@ -31,8 +31,7 @@ typedef void (widget_destructor_t)(widget_t *);
/** Widget */ /** Widget */
struct widget_t struct widget_t
{ {
/** Lua references */ LUA_OBJECT_HEADER
luaA_ref_array_t refs;
/** Widget type is constructor */ /** Widget type is constructor */
widget_constructor_t *type; widget_constructor_t *type;
/** Widget destructor */ /** Widget destructor */