From 88facb7f57f6512bc39efdad3cfa0fe1300dae86 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 23 Mar 2014 19:09:11 +0100 Subject: [PATCH] Make debug::index::miss and newindex work on classes and all objects Signed-off-by: Uli Schlachter --- dbus.c | 2 ++ keygrabber.c | 2 ++ luaa.c | 15 ++++++++++++++- luaa.h | 2 ++ mouse.c | 4 ++-- mousegrabber.c | 2 ++ root.c | 2 ++ screen.c | 4 +++- 8 files changed, 29 insertions(+), 4 deletions(-) diff --git a/dbus.c b/dbus.c index 5bc7e93b5..94b838647 100644 --- a/dbus.c +++ b/dbus.c @@ -797,6 +797,8 @@ const struct luaL_Reg awesome_dbus_lib[] = { "remove_match", luaA_dbus_remove_match }, { "connect_signal", luaA_dbus_connect_signal }, { "disconnect_signal", luaA_dbus_disconnect_signal }, + { "__index", luaA_default_index }, + { "__newindex", luaA_default_newindex }, { NULL, NULL } }; diff --git a/keygrabber.c b/keygrabber.c index ccf5bb454..c56bae6fb 100644 --- a/keygrabber.c +++ b/keygrabber.c @@ -147,6 +147,8 @@ const struct luaL_Reg awesome_keygrabber_lib[] = { "run", luaA_keygrabber_run }, { "stop", luaA_keygrabber_stop }, { "isrunning", luaA_keygrabber_isrunning }, + { "__index", luaA_default_index }, + { "__newindex", luaA_default_newindex }, { NULL, NULL } }; diff --git a/luaa.c b/luaa.c index 01b08d2fc..8af1dc011 100644 --- a/luaa.c +++ b/luaa.c @@ -254,7 +254,7 @@ luaA_awesome_index(lua_State *L) return 1; } - return 0; + return luaA_default_index(L); } /** Add a global signal. @@ -361,6 +361,7 @@ luaA_init(xdgHandle* xdg) { "set_xproperty", luaA_set_xproperty }, { "get_xproperty", luaA_get_xproperty }, { "__index", luaA_awesome_index }, + { "__newindex", luaA_default_newindex }, { NULL, NULL } }; @@ -597,4 +598,16 @@ luaA_emit_refresh() signal_object_emit(globalconf.L, &global_signals, "refresh", 0); } +int +luaA_default_index(lua_State *L) +{ + return luaA_class_index_miss_property(L, NULL); +} + +int +luaA_default_newindex(lua_State *L) +{ + return luaA_class_newindex_miss_property(L, NULL); +} + // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/luaa.h b/luaa.h index c92aa61f7..799279759 100644 --- a/luaa.h +++ b/luaa.h @@ -210,6 +210,8 @@ signal_array_t global_signals; int luaA_class_index_miss_property(lua_State *, lua_object_t *); int luaA_class_newindex_miss_property(lua_State *, lua_object_t *); +int luaA_default_index(lua_State *); +int luaA_default_newindex(lua_State *); void luaA_systray_invalidate(void); diff --git a/mouse.c b/mouse.c index a78fc7a46..8caf05dac 100644 --- a/mouse.c +++ b/mouse.c @@ -106,7 +106,7 @@ luaA_mouse_index(lua_State *L) /* attr is not "screen"?! */ if (A_STRNEQ(attr, "screen")) - return 0; + return luaA_default_index(L); if (!mouse_query_pointer_root(&mouse_x, &mouse_y, NULL, NULL)) { @@ -137,7 +137,7 @@ luaA_mouse_newindex(lua_State *L) int screen; if (A_STRNEQ(attr, "screen")) - return 0; + return luaA_default_newindex(L); screen = luaL_checknumber(L, 3) - 1; luaA_checkscreen(screen); diff --git a/mousegrabber.c b/mousegrabber.c index 35d87ddab..fd0a209dc 100644 --- a/mousegrabber.c +++ b/mousegrabber.c @@ -140,6 +140,8 @@ const struct luaL_Reg awesome_mousegrabber_lib[] = { "run", luaA_mousegrabber_run }, { "stop", luaA_mousegrabber_stop }, { "isrunning", luaA_mousegrabber_isrunning }, + { "__index", luaA_default_index }, + { "__newindex", luaA_default_newindex }, { NULL, NULL } }; diff --git a/root.c b/root.c index 2dea63496..d6258c3ad 100644 --- a/root.c +++ b/root.c @@ -433,6 +433,8 @@ const struct luaL_Reg awesome_root_lib[] = { "drawins", luaA_root_drawins }, { "wallpaper", luaA_root_wallpaper }, { "tags", luaA_root_tags }, + { "__index", luaA_default_index }, + { "__newindex", luaA_default_newindex }, { NULL, NULL } }; diff --git a/screen.c b/screen.c index e04e310b1..b5716267f 100644 --- a/screen.c +++ b/screen.c @@ -502,7 +502,7 @@ luaA_screen_index(lua_State *L) return 1; } - return 0; + return luaA_default_index(L); } /** Add a signal to a screen. @@ -610,6 +610,7 @@ const struct luaL_Reg awesome_screen_methods[] = { { "count", luaA_screen_count }, { "__index", luaA_screen_module_index }, + { "__newindex", luaA_default_newindex }, { NULL, NULL } }; @@ -620,6 +621,7 @@ const struct luaL_Reg awesome_screen_meta[] = { "disconnect_signal", luaA_screen_disconnect_signal }, { "emit_signal", luaA_screen_emit_signal }, { "__index", luaA_screen_index }, + { "__newindex", luaA_default_newindex }, { NULL, NULL } };