# HG changeset patch # User Myhailo Danylenko # Date 1469844275 -10800 # Node ID 8fba61f363a88dfc8e4bbef1cf7ca91c9c7c7f38 # Parent 0cf6c938ac030b06778630efba37e2fd6d27cfc6 lua: Change timer() argument to float diff -r 0cf6c938ac03 -r 8fba61f363a8 CMakeLists.txt --- a/CMakeLists.txt Mon Mar 21 02:04:02 2016 +0200 +++ b/CMakeLists.txt Sat Jul 30 05:04:35 2016 +0300 @@ -16,7 +16,7 @@ cmake_minimum_required(VERSION 2.6) project(lua C) -set(PROJECT_VERSION "0.0.5") +set(PROJECT_VERSION "0.0.6") ## User options option(DEBUG "Enable debugging output" ON) @@ -24,10 +24,10 @@ option(LLM_CONNECTION_ENABLE "Enable exposing of mcabber loudmouth connection to lua" ON) option(LLM_LOG_HANDLER "Enable registration of log messages handler for lua-loudmouth library's messages" ON) option(COMPAT_0_0_4 "Provide global 'main' as alias to 'mcabber' for compatibility with v0.0.4" ON) -set(ML_SOURCE_PRIORITY G_PRIORITY_HIGH_IDLE CACHE STRING "Glib event source priority for timeout and bgread") -set(ML_BGREAD_BUFFER 4096 CACHE STRING "Background pipe reading buffer size") -set(OPT_MLUA_RC "lua_init_filename" CACHE STRING "Mcabber option name to specify lua initialization file") -set(OPT_MLUA_LM_DEBUG "lua_lm_debug" CACHE STRING "Mcabber option name to enable/disable lua logging of LM messages") +set(ML_SOURCE_PRIORITY G_PRIORITY_DEFAULT_IDLE CACHE STRING "Glib event source priority for timeout and bgread") +set(ML_BGREAD_BUFFER 4096 CACHE STRING "Background pipe reading buffer size") +set(OPT_MLUA_RC "lua_init_filename" CACHE STRING "Mcabber option name to specify lua initialization file") +set(OPT_MLUA_LM_DEBUG "lua_lm_debug" CACHE STRING "Mcabber option name to enable/disable lua logging of LM messages") set(WANT_LUA "AUTO" CACHE STRING "Lua version to use (You'll have to define this with -DWANT_LUA=LUAX.X)") set_property(CACHE WANT_LUA PROPERTY STRINGS "AUTO" "LUA5.1" "LUA5.2" "LUA5.3") diff -r 0cf6c938ac03 -r 8fba61f363a8 docs/api.mdwn --- a/docs/api.mdwn Mon Mar 21 02:04:02 2016 +0200 +++ b/docs/api.mdwn Sat Jul 30 05:04:35 2016 +0300 @@ -259,7 +259,7 @@ ### mcabber.timer Creates new [timer function](#timer.function), that will be called periodically. -**Arguments:** integer (interval, seconds), [timer function](#timer.function) +**Arguments:** float (interval, seconds), [timer function](#timer.function) ### background reading function diff -r 0cf6c938ac03 -r 8fba61f363a8 lua.c --- a/lua.c Mon Mar 21 02:04:02 2016 +0200 +++ b/lua.c Sat Jul 30 05:04:35 2016 +0300 @@ -1210,10 +1210,10 @@ /// mcabber.timer /// Creates new timer function, that will be called periodically. -/// A: integer (interval, seconds), timer function +/// A: float (interval, seconds), timer function static int lua_main_timer (lua_State *L) { - int interval = luaL_checkinteger (L, 1); + lua_Number interval = luaL_checknumber (L, 1); guint source; lua_timer_callback_t *cb; luaL_argcheck (L, lua_isfunction (L, 2), 2, "function expected"); @@ -1222,7 +1222,11 @@ cb->reference = luaL_ref (L, LUA_REGISTRYINDEX); cb->L = L; - source = g_timeout_add_seconds_full (MLUA_SOURCE_PRIORITY, interval, (GSourceFunc) lua_timer_callback, cb, (GDestroyNotify) lua_timer_callback_destroy); + source = g_timeout_add_full (MLUA_SOURCE_PRIORITY, + (guint) ( interval*1000 ), + (GSourceFunc) lua_timer_callback, + cb, + (GDestroyNotify) lua_timer_callback_destroy); cb->source = source; lua_timers = g_slist_prepend (lua_timers, (gpointer) ((gsize) source));