Make debug::index::miss and newindex work on classes and all objects

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2014-03-23 19:09:11 +01:00
parent b47b0062f8
commit 53c19edae6
8 changed files with 29 additions and 4 deletions

2
dbus.c
View File

@ -797,6 +797,8 @@ const struct luaL_Reg awesome_dbus_lib[] =
{ "remove_match", luaA_dbus_remove_match }, { "remove_match", luaA_dbus_remove_match },
{ "connect_signal", luaA_dbus_connect_signal }, { "connect_signal", luaA_dbus_connect_signal },
{ "disconnect_signal", luaA_dbus_disconnect_signal }, { "disconnect_signal", luaA_dbus_disconnect_signal },
{ "__index", luaA_default_index },
{ "__newindex", luaA_default_newindex },
{ NULL, NULL } { NULL, NULL }
}; };

View File

@ -147,6 +147,8 @@ const struct luaL_Reg awesome_keygrabber_lib[] =
{ "run", luaA_keygrabber_run }, { "run", luaA_keygrabber_run },
{ "stop", luaA_keygrabber_stop }, { "stop", luaA_keygrabber_stop },
{ "isrunning", luaA_keygrabber_isrunning }, { "isrunning", luaA_keygrabber_isrunning },
{ "__index", luaA_default_index },
{ "__newindex", luaA_default_newindex },
{ NULL, NULL } { NULL, NULL }
}; };

15
luaa.c
View File

@ -254,7 +254,7 @@ luaA_awesome_index(lua_State *L)
return 1; return 1;
} }
return 0; return luaA_default_index(L);
} }
/** Add a global signal. /** Add a global signal.
@ -361,6 +361,7 @@ luaA_init(xdgHandle* xdg)
{ "set_xproperty", luaA_set_xproperty }, { "set_xproperty", luaA_set_xproperty },
{ "get_xproperty", luaA_get_xproperty }, { "get_xproperty", luaA_get_xproperty },
{ "__index", luaA_awesome_index }, { "__index", luaA_awesome_index },
{ "__newindex", luaA_default_newindex },
{ NULL, NULL } { NULL, NULL }
}; };
@ -597,4 +598,16 @@ luaA_emit_refresh()
signal_object_emit(globalconf.L, &global_signals, "refresh", 0); 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 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

2
luaa.h
View File

@ -210,6 +210,8 @@ signal_array_t global_signals;
int luaA_class_index_miss_property(lua_State *, lua_object_t *); int luaA_class_index_miss_property(lua_State *, lua_object_t *);
int luaA_class_newindex_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); void luaA_systray_invalidate(void);

View File

@ -106,7 +106,7 @@ luaA_mouse_index(lua_State *L)
/* attr is not "screen"?! */ /* attr is not "screen"?! */
if (A_STRNEQ(attr, "screen")) if (A_STRNEQ(attr, "screen"))
return 0; return luaA_default_index(L);
if (!mouse_query_pointer_root(&mouse_x, &mouse_y, NULL, NULL)) if (!mouse_query_pointer_root(&mouse_x, &mouse_y, NULL, NULL))
{ {
@ -137,7 +137,7 @@ luaA_mouse_newindex(lua_State *L)
int screen; int screen;
if (A_STRNEQ(attr, "screen")) if (A_STRNEQ(attr, "screen"))
return 0; return luaA_default_newindex(L);
screen = luaL_checknumber(L, 3) - 1; screen = luaL_checknumber(L, 3) - 1;
luaA_checkscreen(screen); luaA_checkscreen(screen);

View File

@ -140,6 +140,8 @@ const struct luaL_Reg awesome_mousegrabber_lib[] =
{ "run", luaA_mousegrabber_run }, { "run", luaA_mousegrabber_run },
{ "stop", luaA_mousegrabber_stop }, { "stop", luaA_mousegrabber_stop },
{ "isrunning", luaA_mousegrabber_isrunning }, { "isrunning", luaA_mousegrabber_isrunning },
{ "__index", luaA_default_index },
{ "__newindex", luaA_default_newindex },
{ NULL, NULL } { NULL, NULL }
}; };

2
root.c
View File

@ -433,6 +433,8 @@ const struct luaL_Reg awesome_root_lib[] =
{ "drawins", luaA_root_drawins }, { "drawins", luaA_root_drawins },
{ "wallpaper", luaA_root_wallpaper }, { "wallpaper", luaA_root_wallpaper },
{ "tags", luaA_root_tags }, { "tags", luaA_root_tags },
{ "__index", luaA_default_index },
{ "__newindex", luaA_default_newindex },
{ NULL, NULL } { NULL, NULL }
}; };

View File

@ -502,7 +502,7 @@ luaA_screen_index(lua_State *L)
return 1; return 1;
} }
return 0; return luaA_default_index(L);
} }
/** Add a signal to a screen. /** Add a signal to a screen.
@ -610,6 +610,7 @@ const struct luaL_Reg awesome_screen_methods[] =
{ {
{ "count", luaA_screen_count }, { "count", luaA_screen_count },
{ "__index", luaA_screen_module_index }, { "__index", luaA_screen_module_index },
{ "__newindex", luaA_default_newindex },
{ NULL, NULL } { NULL, NULL }
}; };
@ -620,6 +621,7 @@ const struct luaL_Reg awesome_screen_meta[] =
{ "disconnect_signal", luaA_screen_disconnect_signal }, { "disconnect_signal", luaA_screen_disconnect_signal },
{ "emit_signal", luaA_screen_emit_signal }, { "emit_signal", luaA_screen_emit_signal },
{ "__index", luaA_screen_index }, { "__index", luaA_screen_index },
{ "__newindex", luaA_default_newindex },
{ NULL, NULL } { NULL, NULL }
}; };