luaobject: import __tostring as object meta function
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
a8f4a59efd
commit
047d04d438
5
button.c
5
button.c
|
@ -23,8 +23,6 @@
|
|||
|
||||
#include "common/tokenize.h"
|
||||
|
||||
DO_LUA_TOSTRING(button_t, button, "button")
|
||||
|
||||
/** Create a new mouse button bindings.
|
||||
* \param L The Lua VM state.
|
||||
* \return The number of elements pushed on stack.
|
||||
|
@ -150,11 +148,10 @@ const struct luaL_reg awesome_button_methods[] =
|
|||
};
|
||||
const struct luaL_reg awesome_button_meta[] =
|
||||
{
|
||||
LUA_OBJECT_META
|
||||
LUA_OBJECT_META(button)
|
||||
{ "__index", luaA_button_index },
|
||||
{ "__newindex", luaA_button_newindex },
|
||||
{ "__gc", luaA_object_gc },
|
||||
{ "__tostring", luaA_button_tostring },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
|
5
client.c
5
client.c
|
@ -32,8 +32,6 @@
|
|||
#include "common/atoms.h"
|
||||
#include "common/xutil.h"
|
||||
|
||||
DO_LUA_TOSTRING(client_t, client, "client")
|
||||
|
||||
client_t *
|
||||
luaA_client_checkudata(lua_State *L, int ud)
|
||||
{
|
||||
|
@ -1964,7 +1962,7 @@ const struct luaL_reg awesome_client_methods[] =
|
|||
};
|
||||
const struct luaL_reg awesome_client_meta[] =
|
||||
{
|
||||
LUA_OBJECT_META
|
||||
LUA_OBJECT_META(client)
|
||||
{ "isvisible", luaA_client_isvisible },
|
||||
{ "geometry", luaA_client_geometry },
|
||||
{ "struts", luaA_client_struts },
|
||||
|
@ -1978,7 +1976,6 @@ const struct luaL_reg awesome_client_meta[] =
|
|||
{ "__index", luaA_client_index },
|
||||
{ "__newindex", luaA_client_newindex },
|
||||
{ "__gc", luaA_client_gc },
|
||||
{ "__tostring", luaA_client_tostring },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
|
|
@ -191,6 +191,13 @@ int luaA_object_emit_signal_simple(lua_State *);
|
|||
luaA_object_push_item(L, -1, ref); \
|
||||
lua_remove(L, -2); \
|
||||
return 1; \
|
||||
} \
|
||||
\
|
||||
static inline int \
|
||||
luaA_##prefix##_tostring(lua_State *L) \
|
||||
{ \
|
||||
lua_pushfstring(L, lua_type ": %p", luaL_checkudata(L, 1, lua_type)); \
|
||||
return 1; \
|
||||
}
|
||||
|
||||
|
||||
|
@ -206,7 +213,8 @@ luaA_object_gc(lua_State *L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#define LUA_OBJECT_META \
|
||||
#define LUA_OBJECT_META(prefix) \
|
||||
{ "__tostring", luaA_##prefix##_tostring }, \
|
||||
{ "add_signal", luaA_object_add_signal_simple }, \
|
||||
{ "remove_signal", luaA_object_remove_signal_simple }, \
|
||||
{ "emit_signal", luaA_object_emit_signal_simple },
|
||||
|
|
5
image.c
5
image.c
|
@ -24,8 +24,6 @@
|
|||
#include "common/xutil.h"
|
||||
#include <xcb/xcb_image.h>
|
||||
|
||||
DO_LUA_TOSTRING(image_t, image, "image");
|
||||
|
||||
static int
|
||||
luaA_image_gc(lua_State *L)
|
||||
{
|
||||
|
@ -777,7 +775,7 @@ const struct luaL_reg awesome_image_methods[] =
|
|||
};
|
||||
const struct luaL_reg awesome_image_meta[] =
|
||||
{
|
||||
LUA_OBJECT_META
|
||||
LUA_OBJECT_META(image)
|
||||
{ "__index", luaA_image_index },
|
||||
{ "rotate", luaA_image_rotate },
|
||||
{ "orientate", luaA_image_orientate },
|
||||
|
@ -792,7 +790,6 @@ const struct luaL_reg awesome_image_meta[] =
|
|||
{ "draw_rectangle_gradient", luaA_image_draw_rectangle_gradient },
|
||||
{ "draw_circle", luaA_image_draw_circle },
|
||||
{ "__gc", luaA_image_gc },
|
||||
{ "__tostring", luaA_image_tostring },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
|
5
key.c
5
key.c
|
@ -31,8 +31,6 @@
|
|||
#include "common/xutil.h"
|
||||
#include "common/tokenize.h"
|
||||
|
||||
DO_LUA_TOSTRING(keyb_t, key, "key")
|
||||
|
||||
/** XCB equivalent of XLookupString which translate the keycode given
|
||||
* by PressEvent to a KeySym and a string
|
||||
* \todo use XKB!
|
||||
|
@ -1152,8 +1150,7 @@ const struct luaL_reg awesome_key_methods[] =
|
|||
};
|
||||
const struct luaL_reg awesome_key_meta[] =
|
||||
{
|
||||
LUA_OBJECT_META
|
||||
{ "__tostring", luaA_key_tostring },
|
||||
LUA_OBJECT_META(key)
|
||||
{ "__index", luaA_key_index },
|
||||
{ "__newindex", luaA_key_newindex },
|
||||
{ "__gc", luaA_object_gc },
|
||||
|
|
5
tag.c
5
tag.c
|
@ -25,8 +25,6 @@
|
|||
#include "ewmh.h"
|
||||
#include "widget.h"
|
||||
|
||||
DO_LUA_TOSTRING(tag_t, tag, "tag")
|
||||
|
||||
void
|
||||
tag_unref_simplified(tag_t **tag)
|
||||
{
|
||||
|
@ -411,12 +409,11 @@ const struct luaL_reg awesome_tag_methods[] =
|
|||
};
|
||||
const struct luaL_reg awesome_tag_meta[] =
|
||||
{
|
||||
LUA_OBJECT_META
|
||||
LUA_OBJECT_META(tag)
|
||||
{ "clients", luaA_tag_clients },
|
||||
{ "__index", luaA_tag_index },
|
||||
{ "__newindex", luaA_tag_newindex },
|
||||
{ "__gc", luaA_tag_gc },
|
||||
{ "__tostring", luaA_tag_tostring },
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
||||
|
|
5
wibox.c
5
wibox.c
|
@ -30,8 +30,6 @@
|
|||
#include "common/xcursor.h"
|
||||
#include "common/xutil.h"
|
||||
|
||||
DO_LUA_TOSTRING(wibox_t, wibox, "wibox")
|
||||
|
||||
/** Take care of garbage collecting a wibox.
|
||||
* \param L The Lua VM state.
|
||||
* \return The number of elements pushed on stack, 0!
|
||||
|
@ -1207,12 +1205,11 @@ const struct luaL_reg awesome_wibox_methods[] =
|
|||
};
|
||||
const struct luaL_reg awesome_wibox_meta[] =
|
||||
{
|
||||
LUA_OBJECT_META
|
||||
LUA_OBJECT_META(wibox)
|
||||
{ "geometry", luaA_wibox_geometry },
|
||||
{ "__index", luaA_wibox_index },
|
||||
{ "__newindex", luaA_wibox_newindex },
|
||||
{ "__gc", luaA_wibox_gc },
|
||||
{ "__tostring", luaA_wibox_tostring },
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
||||
|
|
5
widget.c
5
widget.c
|
@ -32,8 +32,6 @@
|
|||
#include "common/atoms.h"
|
||||
#include "common/xutil.h"
|
||||
|
||||
DO_LUA_TOSTRING(widget_t, widget, "widget")
|
||||
|
||||
/** Collect a widget structure.
|
||||
* \param L The Lua VM state.
|
||||
* \return 0
|
||||
|
@ -558,12 +556,11 @@ const struct luaL_reg awesome_widget_methods[] =
|
|||
};
|
||||
const struct luaL_reg awesome_widget_meta[] =
|
||||
{
|
||||
LUA_OBJECT_META
|
||||
LUA_OBJECT_META(widget)
|
||||
{ "extents", luaA_widget_extents },
|
||||
{ "__index", luaA_widget_index },
|
||||
{ "__newindex", luaA_widget_newindex },
|
||||
{ "__gc", luaA_widget_gc },
|
||||
{ "__tostring", luaA_widget_tostring },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue