diff --git a/docs/rst/lua_api/lua_log_api.rst b/docs/rst/lua_api/lua_log_api.rst index 6f792723..32916039 100644 --- a/docs/rst/lua_api/lua_log_api.rst +++ b/docs/rst/lua_api/lua_log_api.rst @@ -7,40 +7,45 @@ Debug Logging Logs a warning message, like :c:macro:`wp_warning_object` - :param GObject object: optional object to associate the message with; you + :param object: optional object to associate the message with; you may skip this and just start with the *message* as the first parameter + :type object: GObject or GBoxed :param string message: the warning message to log .. function:: Log.message(object, message) Logs a normal message, like :c:macro:`wp_message_object` - :param GObject object: optional object to associate the message with; you + :param object: optional object to associate the message with; you may skip this and just start with the *message* as the first parameter + :type object: GObject or GBoxed :param string message: the normal message to log .. function:: Log.info(object, message) Logs a info message, like :c:macro:`wp_info_object` - :param GObject object: optional object to associate the message with; you + :param object: optional object to associate the message with; you may skip this and just start with the *message* as the first parameter + :type object: GObject or GBoxed :param string message: the info message to log .. function:: Log.debug(object, message) Logs a debug message, like :c:macro:`wp_debug_object` - :param GObject object: optional object to associate the message with; you + :param object: optional object to associate the message with; you may skip this and just start with the *message* as the first parameter + :type object: GObject or GBoxed :param string message: the debug message to log .. function:: Log.trace(object, message) Logs a trace message, like :c:macro:`wp_trace_object` - :param GObject object: optional object to associate the message with; you + :param object: optional object to associate the message with; you may skip this and just start with the *message* as the first parameter + :type object: GObject or GBoxed :param string message: the trace message to log .. function:: Debug.dump_table(t) diff --git a/lib/wplua/userdata.c b/lib/wplua/userdata.c index 6820af07..f99fdac9 100644 --- a/lib/wplua/userdata.c +++ b/lib/wplua/userdata.c @@ -36,6 +36,21 @@ _wplua_isgvalue_userdata (lua_State *L, int idx, GType type) return TRUE; } +GType +wplua_gvalue_userdata_type (lua_State *L, int idx) +{ + GValue *v; + + if (!lua_isuserdata (L, idx)) + return G_TYPE_INVALID; + if (lua_rawlen (L, idx) != sizeof (GValue)) + return G_TYPE_INVALID; + if (!(v = lua_touserdata (L, idx))) + return G_TYPE_INVALID; + + return G_VALUE_TYPE (v); +} + int _wplua_gvalue_userdata___gc (lua_State *L) { diff --git a/lib/wplua/wplua.h b/lib/wplua/wplua.h index 1d8a0082..13d20d2f 100644 --- a/lib/wplua/wplua.h +++ b/lib/wplua/wplua.h @@ -56,6 +56,8 @@ void wplua_enable_sandbox (lua_State * L, WpLuaSandboxFlags flags); void wplua_register_type_methods (lua_State * L, GType type, lua_CFunction constructor, const luaL_Reg * methods); +GType wplua_gvalue_userdata_type (lua_State *L, int idx); + /* push -> transfer full; get -> transfer none */ void wplua_pushobject (lua_State * L, gpointer object); gpointer wplua_toobject (lua_State *L, int idx); diff --git a/modules/module-lua-scripting/api.c b/modules/module-lua-scripting/api.c index 21286311..928abb2b 100644 --- a/modules/module-lua-scripting/api.c +++ b/modules/module-lua-scripting/api.c @@ -226,6 +226,11 @@ log_log (lua_State *L, GLogLevelFlags lvl) type = G_TYPE_FROM_INSTANCE (instance); index++; } + else if (wplua_isboxed (L, 1, G_TYPE_BOXED)) { + instance = wplua_toboxed (L, 1); + type = wplua_gvalue_userdata_type (L, 1); + index++; + } message = luaL_checkstring (L, index); tmp = g_strrstr (ar.source, ".lua");