From 051d0de85fab3a176ab3b9df03fb5d69cdb58d9a Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 6 Feb 2016 13:46:46 +0100 Subject: [PATCH] Replace many pushnumber calls with pushinteger The only remaining calls are for a window's opacity and in the DBus type handling. Everything else wants integers, not something with a comma. Signed-off-by: Uli Schlachter --- common/luaclass.h | 2 +- dbus.c | 40 ++++++++++++++++++++-------------------- event.c | 18 +++++++++--------- luaa.c | 2 +- luaa.h | 8 ++++---- objects/button.c | 2 +- spawn.c | 8 ++++---- strut.c | 8 ++++---- xkb.c | 2 +- 9 files changed, 45 insertions(+), 45 deletions(-) diff --git a/common/luaclass.h b/common/luaclass.h index a057108a..23ad9363 100644 --- a/common/luaclass.h +++ b/common/luaclass.h @@ -150,7 +150,7 @@ luaA_checkudataornil(lua_State *L, int udx, lua_class_t *class) static inline int \ luaA_##prefix##_class_instances(lua_State *L) \ { \ - lua_pushnumber(L, (lua_class).instances); \ + lua_pushinteger(L, (lua_class).instances); \ return 1; \ } diff --git a/dbus.c b/dbus.c index d6323ace..bb7e7792 100644 --- a/dbus.c +++ b/dbus.c @@ -136,7 +136,7 @@ a_dbus_message_iter(lua_State *L, DBusMessageIter *iter) switch(array_type) { int datalen = 0; -#define DBUS_MSG_HANDLE_ARRAY_TYPE_NUMBER(type, dbustype) \ +#define DBUS_MSG_HANDLE_ARRAY_TYPE_NUMBER_OR_INT(type, dbustype, pusher) \ case dbustype: \ { \ const type *data; \ @@ -144,19 +144,19 @@ a_dbus_message_iter(lua_State *L, DBusMessageIter *iter) lua_createtable(L, datalen, 0); \ for(int i = 0; i < datalen; i++) \ { \ - lua_pushnumber(L, data[i]); \ + pusher(L, data[i]); \ lua_rawseti(L, -2, i + 1); \ } \ } \ break; - DBUS_MSG_HANDLE_ARRAY_TYPE_NUMBER(int16_t, DBUS_TYPE_INT16) - DBUS_MSG_HANDLE_ARRAY_TYPE_NUMBER(uint16_t, DBUS_TYPE_UINT16) - DBUS_MSG_HANDLE_ARRAY_TYPE_NUMBER(int32_t, DBUS_TYPE_INT32) - DBUS_MSG_HANDLE_ARRAY_TYPE_NUMBER(uint32_t, DBUS_TYPE_UINT32) - DBUS_MSG_HANDLE_ARRAY_TYPE_NUMBER(int64_t, DBUS_TYPE_INT64) - DBUS_MSG_HANDLE_ARRAY_TYPE_NUMBER(uint64_t, DBUS_TYPE_UINT64) - DBUS_MSG_HANDLE_ARRAY_TYPE_NUMBER(double, DBUS_TYPE_DOUBLE) -#undef DBUS_MSG_HANDLE_ARRAY_TYPE_NUMBER + DBUS_MSG_HANDLE_ARRAY_TYPE_NUMBER_OR_INT(int16_t, DBUS_TYPE_INT16, lua_pushinteger) + DBUS_MSG_HANDLE_ARRAY_TYPE_NUMBER_OR_INT(uint16_t, DBUS_TYPE_UINT16, lua_pushinteger) + DBUS_MSG_HANDLE_ARRAY_TYPE_NUMBER_OR_INT(int32_t, DBUS_TYPE_INT32, lua_pushinteger) + DBUS_MSG_HANDLE_ARRAY_TYPE_NUMBER_OR_INT(uint32_t, DBUS_TYPE_UINT32, lua_pushinteger) + DBUS_MSG_HANDLE_ARRAY_TYPE_NUMBER_OR_INT(int64_t, DBUS_TYPE_INT64, lua_pushinteger) + DBUS_MSG_HANDLE_ARRAY_TYPE_NUMBER_OR_INT(uint64_t, DBUS_TYPE_UINT64, lua_pushinteger) + DBUS_MSG_HANDLE_ARRAY_TYPE_NUMBER_OR_INT(double, DBUS_TYPE_DOUBLE, lua_pushnumber) +#undef DBUS_MSG_HANDLE_ARRAY_TYPE_NUMBER_OR_INT case DBUS_TYPE_BYTE: { const char *c; @@ -232,23 +232,23 @@ a_dbus_message_iter(lua_State *L, DBusMessageIter *iter) } nargs++; break; -#define DBUS_MSG_HANDLE_TYPE_NUMBER(type, dbustype) \ +#define DBUS_MSG_HANDLE_TYPE_NUMBER_OR_INT(type, dbustype, pusher) \ case dbustype: \ { \ type ui; \ dbus_message_iter_get_basic(iter, &ui); \ - lua_pushnumber(L, ui); \ + pusher(L, ui); \ } \ nargs++; \ break; - DBUS_MSG_HANDLE_TYPE_NUMBER(int16_t, DBUS_TYPE_INT16) - DBUS_MSG_HANDLE_TYPE_NUMBER(uint16_t, DBUS_TYPE_UINT16) - DBUS_MSG_HANDLE_TYPE_NUMBER(int32_t, DBUS_TYPE_INT32) - DBUS_MSG_HANDLE_TYPE_NUMBER(uint32_t, DBUS_TYPE_UINT32) - DBUS_MSG_HANDLE_TYPE_NUMBER(int64_t, DBUS_TYPE_INT64) - DBUS_MSG_HANDLE_TYPE_NUMBER(uint64_t, DBUS_TYPE_UINT64) - DBUS_MSG_HANDLE_TYPE_NUMBER(double, DBUS_TYPE_DOUBLE) -#undef DBUS_MSG_HANDLE_TYPE_NUMBER + DBUS_MSG_HANDLE_TYPE_NUMBER_OR_INT(int16_t, DBUS_TYPE_INT16, lua_pushinteger) + DBUS_MSG_HANDLE_TYPE_NUMBER_OR_INT(uint16_t, DBUS_TYPE_UINT16, lua_pushinteger) + DBUS_MSG_HANDLE_TYPE_NUMBER_OR_INT(int32_t, DBUS_TYPE_INT32, lua_pushinteger) + DBUS_MSG_HANDLE_TYPE_NUMBER_OR_INT(uint32_t, DBUS_TYPE_UINT32, lua_pushinteger) + DBUS_MSG_HANDLE_TYPE_NUMBER_OR_INT(int64_t, DBUS_TYPE_INT64, lua_pushinteger) + DBUS_MSG_HANDLE_TYPE_NUMBER_OR_INT(uint64_t, DBUS_TYPE_UINT64, lua_pushinteger) + DBUS_MSG_HANDLE_TYPE_NUMBER_OR_INT(double, DBUS_TYPE_DOUBLE, lua_pushnumber) +#undef DBUS_MSG_HANDLE_TYPE_NUMBER_OR_INT case DBUS_TYPE_STRING: { char *s; diff --git a/event.c b/event.c index 6a3b70c5..e2aeafd7 100644 --- a/event.c +++ b/event.c @@ -153,9 +153,9 @@ event_emit_button(lua_State *L, xcb_button_press_event_t *ev) } /* Push the event's info */ - lua_pushnumber(L, ev->event_x); - lua_pushnumber(L, ev->event_y); - lua_pushnumber(L, ev->detail); + lua_pushinteger(L, ev->event_x); + lua_pushinteger(L, ev->event_y); + lua_pushinteger(L, ev->detail); luaA_pushmodifiers(L, ev->state); /* And emit the signal */ luaA_object_emit_signal(L, -5, name, 4); @@ -480,8 +480,8 @@ event_handle_motionnotify(xcb_motion_notify_event_t *ev) if((c = client_getbyframewin(ev->event))) { luaA_object_push(L, c); - lua_pushnumber(L, ev->event_x); - lua_pushnumber(L, ev->event_y); + lua_pushinteger(L, ev->event_x); + lua_pushinteger(L, ev->event_y); luaA_object_emit_signal(L, -3, "mouse::move", 2); /* now check if a titlebar was "hit" */ @@ -491,8 +491,8 @@ event_handle_motionnotify(xcb_motion_notify_event_t *ev) { luaA_object_push_item(L, -1, d); event_drawable_under_mouse(L, -1); - lua_pushnumber(L, x); - lua_pushnumber(L, y); + lua_pushinteger(L, x); + lua_pushinteger(L, y); luaA_object_emit_signal(L, -3, "mouse::move", 2); lua_pop(L, 1); } @@ -504,8 +504,8 @@ event_handle_motionnotify(xcb_motion_notify_event_t *ev) luaA_object_push(L, w); luaA_object_push_item(L, -1, w->drawable); event_drawable_under_mouse(L, -1); - lua_pushnumber(L, ev->event_x); - lua_pushnumber(L, ev->event_y); + lua_pushinteger(L, ev->event_x); + lua_pushinteger(L, ev->event_y); luaA_object_emit_signal(L, -3, "mouse::move", 2); lua_pop(L, 2); } diff --git a/luaa.c b/luaa.c index c276e3cc..087f52d2 100644 --- a/luaa.c +++ b/luaa.c @@ -193,7 +193,7 @@ static int luaA_mbstrlen(lua_State *L) { const char *cmd = luaL_checkstring(L, 1); - lua_pushnumber(L, (ssize_t) mbstowcs(NULL, NONULL(cmd), 0)); + lua_pushinteger(L, (ssize_t) mbstowcs(NULL, NONULL(cmd), 0)); return 1; } diff --git a/luaa.h b/luaa.h index cf519cdd..42404eeb 100644 --- a/luaa.h +++ b/luaa.h @@ -175,13 +175,13 @@ static inline int luaA_pusharea(lua_State *L, area_t geometry) { lua_createtable(L, 0, 4); - lua_pushnumber(L, geometry.x); + lua_pushinteger(L, geometry.x); lua_setfield(L, -2, "x"); - lua_pushnumber(L, geometry.y); + lua_pushinteger(L, geometry.y); lua_setfield(L, -2, "y"); - lua_pushnumber(L, geometry.width); + lua_pushinteger(L, geometry.width); lua_setfield(L, -2, "width"); - lua_pushnumber(L, geometry.height); + lua_pushinteger(L, geometry.height); lua_setfield(L, -2, "height"); return 1; } diff --git a/objects/button.c b/objects/button.c index 29ec2a48..4420ec35 100644 --- a/objects/button.c +++ b/objects/button.c @@ -102,7 +102,7 @@ luaA_button_array_get(lua_State *L, int oidx, button_array_t *buttons) return 1; } -LUA_OBJECT_EXPORT_PROPERTY(button, button_t, button, lua_pushnumber); +LUA_OBJECT_EXPORT_PROPERTY(button, button_t, button, lua_pushinteger); LUA_OBJECT_EXPORT_PROPERTY(button, button_t, modifiers, luaA_pushmodifiers); static int diff --git a/spawn.c b/spawn.c index 659dd5f8..cbd4a004 100644 --- a/spawn.c +++ b/spawn.c @@ -151,7 +151,7 @@ spawn_monitor_event(SnMonitorEvent *event, void *data) lua_setfield(L, -2, "description"); } - lua_pushnumber(L, sn_startup_sequence_get_workspace(sequence)); + lua_pushinteger(L, sn_startup_sequence_get_workspace(sequence)); lua_setfield(L, -2, "workspace"); if((s = sn_startup_sequence_get_binary_name(sequence))) @@ -352,11 +352,11 @@ child_exit_callback(GPid pid, gint status, gpointer user_data) /* 'Decode' the exit status */ if (WIFEXITED(status)) { lua_pushliteral(L, "exit"); - lua_pushnumber(L, WEXITSTATUS(status)); + lua_pushinteger(L, WEXITSTATUS(status)); } else { assert(WIFSIGNALED(status)); lua_pushliteral(L, "signal"); - lua_pushnumber(L, WTERMSIG(status)); + lua_pushinteger(L, WTERMSIG(status)); } lua_rawgeti(L, LUA_REGISTRYINDEX, exit_callback); @@ -461,7 +461,7 @@ luaA_spawn(lua_State *L) } /* push pid on stack */ - lua_pushnumber(L, pid); + lua_pushinteger(L, pid); /* push sn on stack */ if (context) diff --git a/strut.c b/strut.c index 482dc04c..41849450 100644 --- a/strut.c +++ b/strut.c @@ -31,13 +31,13 @@ int luaA_pushstrut(lua_State *L, strut_t strut) { lua_createtable(L, 4, 0); - lua_pushnumber(L, strut.left); + lua_pushinteger(L, strut.left); lua_setfield(L, -2, "left"); - lua_pushnumber(L, strut.right); + lua_pushinteger(L, strut.right); lua_setfield(L, -2, "right"); - lua_pushnumber(L, strut.top); + lua_pushinteger(L, strut.top); lua_setfield(L, -2, "top"); - lua_pushnumber(L, strut.bottom); + lua_pushinteger(L, strut.bottom); lua_setfield(L, -2, "bottom"); return 1; } diff --git a/xkb.c b/xkb.c index faa80e48..c206e44f 100644 --- a/xkb.c +++ b/xkb.c @@ -247,7 +247,7 @@ event_handle_xkb_notify(xcb_generic_event_t* event) if (state_notify_event->changed & XCB_XKB_STATE_PART_GROUP_STATE) { - lua_pushnumber(L, state_notify_event->group); + lua_pushinteger(L, state_notify_event->group); signal_object_emit(L, &global_signals, "xkb::group_changed", 1); }