diff --git a/common/luaclass.c b/common/luaclass.c index f747ab41..6214c262 100644 --- a/common/luaclass.c +++ b/common/luaclass.c @@ -24,8 +24,8 @@ struct lua_class_property { - /** ID matching the property */ - awesome_token_t id; + /** Name of the property */ + const char *name; /** Callback function called when the property is found in object creation. */ lua_class_propfunc_t new; /** Callback function called when the property is found in object __index. */ @@ -142,21 +142,21 @@ static int lua_class_property_cmp(const void *a, const void *b) { const lua_class_property_t *x = a, *y = b; - return x->id > y->id ? 1 : (x->id < y->id ? -1 : 0); + return a_strcmp(x->name, y->name); } BARRAY_FUNCS(lua_class_property_t, lua_class_property, DO_NOTHING, lua_class_property_cmp) void luaA_class_add_property(lua_class_t *lua_class, - awesome_token_t token, + const char *name, lua_class_propfunc_t cb_new, lua_class_propfunc_t cb_index, lua_class_propfunc_t cb_newindex) { lua_class_property_array_insert(&lua_class->properties, (lua_class_property_t) { - .id = token, + .name = name, .new = cb_new, .index = cb_index, .newindex = cb_newindex @@ -327,10 +327,10 @@ luaA_usemetatable(lua_State *L, int idxobj, int idxfield) } static lua_class_property_t * -lua_class_property_array_getbyid(lua_class_property_array_t *arr, - awesome_token_t id) +lua_class_property_array_getbyname(lua_class_property_array_t *arr, + const char *name) { - lua_class_property_t lookup_prop = { .id = id }; + lua_class_property_t lookup_prop = { .name = name }; return lua_class_property_array_lookup(arr, &lookup_prop); } @@ -344,15 +344,13 @@ static lua_class_property_t * luaA_class_property_get(lua_State *L, lua_class_t *lua_class, int fieldidx) { /* Lookup the property using token */ - size_t len; - const char *attr = luaL_checklstring(L, fieldidx, &len); - awesome_token_t token = a_tokenize(attr, len); + const char *attr = luaL_checkstring(L, fieldidx); /* Look for the property in the class; if not found, go in the parent class. */ for(; lua_class; lua_class = lua_class->parent) { lua_class_property_t *prop = - lua_class_property_array_getbyid(&lua_class->properties, token); + lua_class_property_array_getbyname(&lua_class->properties, attr); if(prop) return prop; diff --git a/common/luaclass.h b/common/luaclass.h index 13ae0af6..49080458 100644 --- a/common/luaclass.h +++ b/common/luaclass.h @@ -85,7 +85,7 @@ void luaA_class_setup(lua_State *, lua_class_t *, const char *, lua_class_t *, lua_class_propfunc_t, lua_class_propfunc_t, const struct luaL_reg[], const struct luaL_reg[]); -void luaA_class_add_property(lua_class_t *, awesome_token_t, +void luaA_class_add_property(lua_class_t *, const char *, lua_class_propfunc_t, lua_class_propfunc_t, lua_class_propfunc_t); int luaA_usemetatable(lua_State *, int, int); diff --git a/objects/button.c b/objects/button.c index e5730ac5..31c8cd20 100644 --- a/objects/button.c +++ b/objects/button.c @@ -117,11 +117,11 @@ button_class_setup(lua_State *L) (lua_class_allocator_t) button_new, NULL, NULL, luaA_class_index_miss_property, luaA_class_newindex_miss_property, button_methods, button_meta); - luaA_class_add_property(&button_class, A_TK_BUTTON, + luaA_class_add_property(&button_class, "button", (lua_class_propfunc_t) luaA_button_set_button, (lua_class_propfunc_t) luaA_button_get_button, (lua_class_propfunc_t) luaA_button_set_button); - luaA_class_add_property(&button_class, A_TK_MODIFIERS, + luaA_class_add_property(&button_class, "modifiers", (lua_class_propfunc_t) luaA_button_set_modifiers, (lua_class_propfunc_t) luaA_button_get_modifiers, (lua_class_propfunc_t) luaA_button_set_modifiers); diff --git a/objects/client.c b/objects/client.c index bf6bc7a1..dc51cdc5 100644 --- a/objects/client.c +++ b/objects/client.c @@ -1765,119 +1765,119 @@ client_class_setup(lua_State *L) (lua_class_checker_t) client_checker, luaA_class_index_miss_property, luaA_class_newindex_miss_property, client_methods, client_meta); - luaA_class_add_property(&client_class, A_TK_NAME, + luaA_class_add_property(&client_class, "name", NULL, (lua_class_propfunc_t) luaA_client_get_name, NULL); - luaA_class_add_property(&client_class, A_TK_TRANSIENT_FOR, + luaA_class_add_property(&client_class, "transient_for", NULL, (lua_class_propfunc_t) luaA_client_get_transient_for, NULL); - luaA_class_add_property(&client_class, A_TK_SKIP_TASKBAR, + luaA_class_add_property(&client_class, "skip_taskbar", (lua_class_propfunc_t) luaA_client_set_skip_taskbar, (lua_class_propfunc_t) luaA_client_get_skip_taskbar, (lua_class_propfunc_t) luaA_client_set_skip_taskbar); - luaA_class_add_property(&client_class, A_TK_CONTENT, + luaA_class_add_property(&client_class, "content", NULL, (lua_class_propfunc_t) luaA_client_get_content, NULL); - luaA_class_add_property(&client_class, A_TK_TYPE, + luaA_class_add_property(&client_class, "type", NULL, (lua_class_propfunc_t) luaA_client_get_type, NULL); - luaA_class_add_property(&client_class, A_TK_CLASS, + luaA_class_add_property(&client_class, "class", NULL, (lua_class_propfunc_t) luaA_client_get_class, NULL); - luaA_class_add_property(&client_class, A_TK_INSTANCE, + luaA_class_add_property(&client_class, "instance", NULL, (lua_class_propfunc_t) luaA_client_get_instance, NULL); - luaA_class_add_property(&client_class, A_TK_ROLE, + luaA_class_add_property(&client_class, "role", NULL, (lua_class_propfunc_t) luaA_client_get_role, NULL); - luaA_class_add_property(&client_class, A_TK_PID, + luaA_class_add_property(&client_class, "pid", NULL, (lua_class_propfunc_t) luaA_client_get_pid, NULL); - luaA_class_add_property(&client_class, A_TK_LEADER_WINDOW, + luaA_class_add_property(&client_class, "leader_window", NULL, (lua_class_propfunc_t) luaA_client_get_leader_window, NULL); - luaA_class_add_property(&client_class, A_TK_MACHINE, + luaA_class_add_property(&client_class, "machine", NULL, (lua_class_propfunc_t) luaA_client_get_machine, NULL); - luaA_class_add_property(&client_class, A_TK_ICON_NAME, + luaA_class_add_property(&client_class, "icon_name", NULL, (lua_class_propfunc_t) luaA_client_get_icon_name, NULL); - luaA_class_add_property(&client_class, A_TK_SCREEN, + luaA_class_add_property(&client_class, "screen", NULL, (lua_class_propfunc_t) luaA_client_get_screen, (lua_class_propfunc_t) luaA_client_set_screen); - luaA_class_add_property(&client_class, A_TK_HIDDEN, + luaA_class_add_property(&client_class, "hidden", (lua_class_propfunc_t) luaA_client_set_hidden, (lua_class_propfunc_t) luaA_client_get_hidden, (lua_class_propfunc_t) luaA_client_set_hidden); - luaA_class_add_property(&client_class, A_TK_MINIMIZED, + luaA_class_add_property(&client_class, "minimized", (lua_class_propfunc_t) luaA_client_set_minimized, (lua_class_propfunc_t) luaA_client_get_minimized, (lua_class_propfunc_t) luaA_client_set_minimized); - luaA_class_add_property(&client_class, A_TK_FULLSCREEN, + luaA_class_add_property(&client_class, "fullscreen", (lua_class_propfunc_t) luaA_client_set_fullscreen, (lua_class_propfunc_t) luaA_client_get_fullscreen, (lua_class_propfunc_t) luaA_client_set_fullscreen); - luaA_class_add_property(&client_class, A_TK_MODAL, + luaA_class_add_property(&client_class, "modal", (lua_class_propfunc_t) luaA_client_set_modal, (lua_class_propfunc_t) luaA_client_get_modal, (lua_class_propfunc_t) luaA_client_set_modal); - luaA_class_add_property(&client_class, A_TK_GROUP_WINDOW, + luaA_class_add_property(&client_class, "group_window", NULL, (lua_class_propfunc_t) luaA_client_get_group_window, NULL); - luaA_class_add_property(&client_class, A_TK_MAXIMIZED_HORIZONTAL, + luaA_class_add_property(&client_class, "maximized_horizontal", (lua_class_propfunc_t) luaA_client_set_maximized_horizontal, (lua_class_propfunc_t) luaA_client_get_maximized_horizontal, (lua_class_propfunc_t) luaA_client_set_maximized_horizontal); - luaA_class_add_property(&client_class, A_TK_MAXIMIZED_VERTICAL, + luaA_class_add_property(&client_class, "maximized_vertical", (lua_class_propfunc_t) luaA_client_set_maximized_vertical, (lua_class_propfunc_t) luaA_client_get_maximized_vertical, (lua_class_propfunc_t) luaA_client_set_maximized_vertical); - luaA_class_add_property(&client_class, A_TK_ICON, + luaA_class_add_property(&client_class, "icon", (lua_class_propfunc_t) luaA_client_set_icon, (lua_class_propfunc_t) luaA_client_get_icon, (lua_class_propfunc_t) luaA_client_set_icon); - luaA_class_add_property(&client_class, A_TK_ONTOP, + luaA_class_add_property(&client_class, "ontop", (lua_class_propfunc_t) luaA_client_set_ontop, (lua_class_propfunc_t) luaA_client_get_ontop, (lua_class_propfunc_t) luaA_client_set_ontop); - luaA_class_add_property(&client_class, A_TK_ABOVE, + luaA_class_add_property(&client_class, "above", (lua_class_propfunc_t) luaA_client_set_above, (lua_class_propfunc_t) luaA_client_get_above, (lua_class_propfunc_t) luaA_client_set_above); - luaA_class_add_property(&client_class, A_TK_BELOW, + luaA_class_add_property(&client_class, "below", (lua_class_propfunc_t) luaA_client_set_below, (lua_class_propfunc_t) luaA_client_get_below, (lua_class_propfunc_t) luaA_client_set_below); - luaA_class_add_property(&client_class, A_TK_STICKY, + luaA_class_add_property(&client_class, "sticky", (lua_class_propfunc_t) luaA_client_set_sticky, (lua_class_propfunc_t) luaA_client_get_sticky, (lua_class_propfunc_t) luaA_client_set_sticky); - luaA_class_add_property(&client_class, A_TK_SIZE_HINTS_HONOR, + luaA_class_add_property(&client_class, "size_hints_honor", (lua_class_propfunc_t) luaA_client_set_size_hints_honor, (lua_class_propfunc_t) luaA_client_get_size_hints_honor, (lua_class_propfunc_t) luaA_client_set_size_hints_honor); - luaA_class_add_property(&client_class, A_TK_URGENT, + luaA_class_add_property(&client_class, "urgent", (lua_class_propfunc_t) luaA_client_set_urgent, (lua_class_propfunc_t) luaA_client_get_urgent, (lua_class_propfunc_t) luaA_client_set_urgent); - luaA_class_add_property(&client_class, A_TK_SIZE_HINTS, + luaA_class_add_property(&client_class, "size_hints", NULL, (lua_class_propfunc_t) luaA_client_get_size_hints, NULL); - luaA_class_add_property(&client_class, A_TK_FOCUSABLE, + luaA_class_add_property(&client_class, "focusable", NULL, (lua_class_propfunc_t) luaA_client_get_focusable, NULL); diff --git a/objects/image.c b/objects/image.c index ebefb24c..3f36c014 100644 --- a/objects/image.c +++ b/objects/image.c @@ -817,15 +817,15 @@ image_class_setup(lua_State *L) NULL, luaA_class_index_miss_property, luaA_class_newindex_miss_property, image_methods, image_meta); - luaA_class_add_property(&image_class, A_TK_WIDTH, + luaA_class_add_property(&image_class, "width", NULL, (lua_class_propfunc_t) luaA_image_get_width, NULL); - luaA_class_add_property(&image_class, A_TK_HEIGHT, + luaA_class_add_property(&image_class, "height", NULL, (lua_class_propfunc_t) luaA_image_get_height, NULL); - luaA_class_add_property(&image_class, A_TK_ALPHA, + luaA_class_add_property(&image_class, "alpha", NULL, (lua_class_propfunc_t) luaA_image_get_alpha, NULL); diff --git a/objects/key.c b/objects/key.c index 8193994a..4c2c80d9 100644 --- a/objects/key.c +++ b/objects/key.c @@ -222,15 +222,15 @@ key_class_setup(lua_State *L) (lua_class_allocator_t) key_new, NULL, NULL, luaA_class_index_miss_property, luaA_class_newindex_miss_property, key_methods, key_meta); - luaA_class_add_property(&key_class, A_TK_KEY, + luaA_class_add_property(&key_class, "key", (lua_class_propfunc_t) luaA_key_set_key, (lua_class_propfunc_t) luaA_key_get_key, (lua_class_propfunc_t) luaA_key_set_key); - luaA_class_add_property(&key_class, A_TK_KEYSYM, + luaA_class_add_property(&key_class, "keysym", NULL, (lua_class_propfunc_t) luaA_key_get_keysym, NULL); - luaA_class_add_property(&key_class, A_TK_MODIFIERS, + luaA_class_add_property(&key_class, "modifiers", (lua_class_propfunc_t) luaA_key_set_modifiers, (lua_class_propfunc_t) luaA_key_get_modifiers, (lua_class_propfunc_t) luaA_key_set_modifiers); diff --git a/objects/tag.c b/objects/tag.c index 3a478fe4..3b7dd63c 100644 --- a/objects/tag.c +++ b/objects/tag.c @@ -409,15 +409,15 @@ tag_class_setup(lua_State *L) NULL, luaA_class_index_miss_property, luaA_class_newindex_miss_property, tag_methods, tag_meta); - luaA_class_add_property(&tag_class, A_TK_NAME, + luaA_class_add_property(&tag_class, "name", (lua_class_propfunc_t) luaA_tag_set_name, (lua_class_propfunc_t) luaA_tag_get_name, (lua_class_propfunc_t) luaA_tag_set_name); - luaA_class_add_property(&tag_class, A_TK_SCREEN, + luaA_class_add_property(&tag_class, "screen", (lua_class_propfunc_t) NULL, (lua_class_propfunc_t) luaA_tag_get_screen, (lua_class_propfunc_t) luaA_tag_set_screen); - luaA_class_add_property(&tag_class, A_TK_SELECTED, + luaA_class_add_property(&tag_class, "selected", (lua_class_propfunc_t) luaA_tag_set_selected, (lua_class_propfunc_t) luaA_tag_get_selected, (lua_class_propfunc_t) luaA_tag_set_selected); diff --git a/objects/timer.c b/objects/timer.c index a6218790..e0476d6a 100644 --- a/objects/timer.c +++ b/objects/timer.c @@ -125,11 +125,11 @@ timer_class_setup(lua_State *L) (lua_class_allocator_t) timer_new, NULL, NULL, luaA_class_index_miss_property, luaA_class_newindex_miss_property, timer_methods, timer_meta); - luaA_class_add_property(&timer_class, A_TK_TIMEOUT, + luaA_class_add_property(&timer_class, "timeout", (lua_class_propfunc_t) luaA_timer_set_timeout, (lua_class_propfunc_t) luaA_timer_get_timeout, (lua_class_propfunc_t) luaA_timer_set_timeout); - luaA_class_add_property(&timer_class, A_TK_STARTED, + luaA_class_add_property(&timer_class, "started", NULL, (lua_class_propfunc_t) luaA_timer_get_started, NULL); diff --git a/objects/wibox.c b/objects/wibox.c index 0b4c8c52..c45c0ec3 100644 --- a/objects/wibox.c +++ b/objects/wibox.c @@ -1125,55 +1125,55 @@ wibox_class_setup(lua_State *L) NULL, luaA_class_index_miss_property, luaA_class_newindex_miss_property, wibox_methods, wibox_meta); - luaA_class_add_property(&wibox_class, A_TK_WIDGETS, + luaA_class_add_property(&wibox_class, "widgets", (lua_class_propfunc_t) luaA_wibox_set_widgets, (lua_class_propfunc_t) luaA_wibox_get_widgets, (lua_class_propfunc_t) luaA_wibox_set_widgets); - luaA_class_add_property(&wibox_class, A_TK_VISIBLE, + luaA_class_add_property(&wibox_class, "visible", (lua_class_propfunc_t) luaA_wibox_set_visible, (lua_class_propfunc_t) luaA_wibox_get_visible, (lua_class_propfunc_t) luaA_wibox_set_visible); - luaA_class_add_property(&wibox_class, A_TK_ORIENTATION, + luaA_class_add_property(&wibox_class, "orientation", (lua_class_propfunc_t) luaA_wibox_set_orientation, (lua_class_propfunc_t) luaA_wibox_get_orientation, (lua_class_propfunc_t) luaA_wibox_set_orientation); - luaA_class_add_property(&wibox_class, A_TK_ONTOP, + luaA_class_add_property(&wibox_class, "ontop", (lua_class_propfunc_t) luaA_wibox_set_ontop, (lua_class_propfunc_t) luaA_wibox_get_ontop, (lua_class_propfunc_t) luaA_wibox_set_ontop); - luaA_class_add_property(&wibox_class, A_TK_SCREEN, + luaA_class_add_property(&wibox_class, "screen", NULL, (lua_class_propfunc_t) luaA_wibox_get_screen, (lua_class_propfunc_t) luaA_wibox_set_screen); - luaA_class_add_property(&wibox_class, A_TK_CURSOR, + luaA_class_add_property(&wibox_class, "cursor", (lua_class_propfunc_t) luaA_wibox_set_cursor, (lua_class_propfunc_t) luaA_wibox_get_cursor, (lua_class_propfunc_t) luaA_wibox_set_cursor); - luaA_class_add_property(&wibox_class, A_TK_FG, + luaA_class_add_property(&wibox_class, "fg", (lua_class_propfunc_t) luaA_wibox_set_fg, (lua_class_propfunc_t) luaA_wibox_get_fg, (lua_class_propfunc_t) luaA_wibox_set_fg); - luaA_class_add_property(&wibox_class, A_TK_BG, + luaA_class_add_property(&wibox_class, "bg", (lua_class_propfunc_t) luaA_wibox_set_bg, (lua_class_propfunc_t) luaA_wibox_get_bg, (lua_class_propfunc_t) luaA_wibox_set_bg); - luaA_class_add_property(&wibox_class, A_TK_BG_IMAGE, + luaA_class_add_property(&wibox_class, "bg_image", (lua_class_propfunc_t) luaA_wibox_set_bg_image, (lua_class_propfunc_t) luaA_wibox_get_bg_image, (lua_class_propfunc_t) luaA_wibox_set_bg_image); - luaA_class_add_property(&wibox_class, A_TK_X, + luaA_class_add_property(&wibox_class, "x", (lua_class_propfunc_t) luaA_wibox_set_x, (lua_class_propfunc_t) luaA_wibox_get_x, (lua_class_propfunc_t) luaA_wibox_set_x); - luaA_class_add_property(&wibox_class, A_TK_Y, + luaA_class_add_property(&wibox_class, "y", (lua_class_propfunc_t) luaA_wibox_set_y, (lua_class_propfunc_t) luaA_wibox_get_y, (lua_class_propfunc_t) luaA_wibox_set_y); - luaA_class_add_property(&wibox_class, A_TK_WIDTH, + luaA_class_add_property(&wibox_class, "width", (lua_class_propfunc_t) luaA_wibox_set_width, (lua_class_propfunc_t) luaA_wibox_get_width, (lua_class_propfunc_t) luaA_wibox_set_width); - luaA_class_add_property(&wibox_class, A_TK_HEIGHT, + luaA_class_add_property(&wibox_class, "height", (lua_class_propfunc_t) luaA_wibox_set_height, (lua_class_propfunc_t) luaA_wibox_get_height, (lua_class_propfunc_t) luaA_wibox_set_height); diff --git a/objects/widget.c b/objects/widget.c index 564ede26..54e2eec2 100644 --- a/objects/widget.c +++ b/objects/widget.c @@ -576,11 +576,11 @@ widget_class_setup(lua_State *L) (lua_class_collector_t) widget_wipe, NULL, NULL, NULL, widget_methods, widget_meta); - luaA_class_add_property(&widget_class, A_TK_VISIBLE, + luaA_class_add_property(&widget_class, "visible", (lua_class_propfunc_t) luaA_widget_set_visible, (lua_class_propfunc_t) luaA_widget_get_visible, (lua_class_propfunc_t) luaA_widget_set_visible); - luaA_class_add_property(&widget_class, A_TK_TYPE, + luaA_class_add_property(&widget_class, "type", (lua_class_propfunc_t) luaA_widget_set_type, (lua_class_propfunc_t) luaA_widget_get_type, NULL); diff --git a/objects/window.c b/objects/window.c index 68acfb7c..0da60a9a 100644 --- a/objects/window.c +++ b/objects/window.c @@ -210,19 +210,19 @@ window_class_setup(lua_State *L) luaA_class_index_miss_property, luaA_class_newindex_miss_property, window_methods, window_meta); - luaA_class_add_property(&window_class, A_TK_WINDOW, + luaA_class_add_property(&window_class, "window", NULL, (lua_class_propfunc_t) luaA_window_get_window, NULL); - luaA_class_add_property(&window_class, A_TK_OPACITY, + luaA_class_add_property(&window_class, "opacity", (lua_class_propfunc_t) luaA_window_set_opacity, (lua_class_propfunc_t) luaA_window_get_opacity, (lua_class_propfunc_t) luaA_window_set_opacity); - luaA_class_add_property(&window_class, A_TK_BORDER_COLOR, + luaA_class_add_property(&window_class, "border_color", (lua_class_propfunc_t) luaA_window_set_border_color, (lua_class_propfunc_t) luaA_window_get_border_color, (lua_class_propfunc_t) luaA_window_set_border_color); - luaA_class_add_property(&window_class, A_TK_BORDER_WIDTH, + luaA_class_add_property(&window_class, "border_width", (lua_class_propfunc_t) luaA_window_set_border_width, (lua_class_propfunc_t) luaA_window_get_border_width, (lua_class_propfunc_t) luaA_window_set_border_width);