lua: allow the Log api to debug boxed objects (useful for pods)
This commit is contained in:
@@ -7,40 +7,45 @@ Debug Logging
|
|||||||
|
|
||||||
Logs a warning message, like :c:macro:`wp_warning_object`
|
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
|
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
|
:param string message: the warning message to log
|
||||||
|
|
||||||
.. function:: Log.message(object, message)
|
.. function:: Log.message(object, message)
|
||||||
|
|
||||||
Logs a normal message, like :c:macro:`wp_message_object`
|
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
|
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
|
:param string message: the normal message to log
|
||||||
|
|
||||||
.. function:: Log.info(object, message)
|
.. function:: Log.info(object, message)
|
||||||
|
|
||||||
Logs a info message, like :c:macro:`wp_info_object`
|
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
|
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
|
:param string message: the info message to log
|
||||||
|
|
||||||
.. function:: Log.debug(object, message)
|
.. function:: Log.debug(object, message)
|
||||||
|
|
||||||
Logs a debug message, like :c:macro:`wp_debug_object`
|
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
|
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
|
:param string message: the debug message to log
|
||||||
|
|
||||||
.. function:: Log.trace(object, message)
|
.. function:: Log.trace(object, message)
|
||||||
|
|
||||||
Logs a trace message, like :c:macro:`wp_trace_object`
|
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
|
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
|
:param string message: the trace message to log
|
||||||
|
|
||||||
.. function:: Debug.dump_table(t)
|
.. function:: Debug.dump_table(t)
|
||||||
|
@@ -36,6 +36,21 @@ _wplua_isgvalue_userdata (lua_State *L, int idx, GType type)
|
|||||||
return TRUE;
|
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
|
int
|
||||||
_wplua_gvalue_userdata___gc (lua_State *L)
|
_wplua_gvalue_userdata___gc (lua_State *L)
|
||||||
{
|
{
|
||||||
|
@@ -56,6 +56,8 @@ void wplua_enable_sandbox (lua_State * L, WpLuaSandboxFlags flags);
|
|||||||
void wplua_register_type_methods (lua_State * L, GType type,
|
void wplua_register_type_methods (lua_State * L, GType type,
|
||||||
lua_CFunction constructor, const luaL_Reg * methods);
|
lua_CFunction constructor, const luaL_Reg * methods);
|
||||||
|
|
||||||
|
GType wplua_gvalue_userdata_type (lua_State *L, int idx);
|
||||||
|
|
||||||
/* push -> transfer full; get -> transfer none */
|
/* push -> transfer full; get -> transfer none */
|
||||||
void wplua_pushobject (lua_State * L, gpointer object);
|
void wplua_pushobject (lua_State * L, gpointer object);
|
||||||
gpointer wplua_toobject (lua_State *L, int idx);
|
gpointer wplua_toobject (lua_State *L, int idx);
|
||||||
|
@@ -226,6 +226,11 @@ log_log (lua_State *L, GLogLevelFlags lvl)
|
|||||||
type = G_TYPE_FROM_INSTANCE (instance);
|
type = G_TYPE_FROM_INSTANCE (instance);
|
||||||
index++;
|
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);
|
message = luaL_checkstring (L, index);
|
||||||
tmp = g_strrstr (ar.source, ".lua");
|
tmp = g_strrstr (ar.source, ".lua");
|
||||||
|
Reference in New Issue
Block a user