mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-05-05 21:48:31 +02:00
wplua: allow checking for a specific GType with isobject/isboxed
This commit is contained in:
parent
630a6f5e1c
commit
5edfc090c6
3 changed files with 9 additions and 7 deletions
|
|
@ -26,7 +26,7 @@ find_method_in_luaL_Reg (luaL_Reg *reg, const gchar *method)
|
|||
static int
|
||||
_wplua_gboxed___index (lua_State *L)
|
||||
{
|
||||
luaL_argcheck (L, wplua_isboxed (L, 1), 1,
|
||||
luaL_argcheck (L, wplua_isboxed (L, 1, G_TYPE_BOXED), 1,
|
||||
"expected userdata storing GValue<GBoxed>");
|
||||
GValue *obj_v = lua_touserdata (L, 1);
|
||||
const gchar *key = luaL_checkstring (L, 2);
|
||||
|
|
@ -100,7 +100,8 @@ wplua_checkboxed (lua_State *L, int idx, GType type)
|
|||
}
|
||||
|
||||
gboolean
|
||||
wplua_isboxed (lua_State *L, int idx)
|
||||
wplua_isboxed (lua_State *L, int idx, GType type)
|
||||
{
|
||||
return _wplua_isgvalue_userdata (L, idx, G_TYPE_BOXED);
|
||||
if (!g_type_is_a (type, G_TYPE_BOXED)) return FALSE;
|
||||
return _wplua_isgvalue_userdata (L, idx, type);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -218,7 +218,8 @@ wplua_checkobject (lua_State *L, int idx, GType type)
|
|||
}
|
||||
|
||||
gboolean
|
||||
wplua_isobject (lua_State *L, int idx)
|
||||
wplua_isobject (lua_State *L, int idx, GType type)
|
||||
{
|
||||
return _wplua_isgvalue_userdata (L, idx, G_TYPE_OBJECT);
|
||||
if (!g_type_is_a (type, G_TYPE_OBJECT)) return FALSE;
|
||||
return _wplua_isgvalue_userdata (L, idx, type);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,13 +52,13 @@ void wplua_register_type_methods (lua_State * L, GType type,
|
|||
void wplua_pushobject (lua_State * L, gpointer object);
|
||||
gpointer wplua_toobject (lua_State *L, int idx);
|
||||
gpointer wplua_checkobject (lua_State *L, int idx, GType type);
|
||||
gboolean wplua_isobject (lua_State *L, int idx);
|
||||
gboolean wplua_isobject (lua_State *L, int idx, GType type);
|
||||
|
||||
/* push -> transfer full; get -> transfer none */
|
||||
void wplua_pushboxed (lua_State * L, GType type, gpointer object);
|
||||
gpointer wplua_toboxed (lua_State *L, int idx);
|
||||
gpointer wplua_checkboxed (lua_State *L, int idx, GType type);
|
||||
gboolean wplua_isboxed (lua_State *L, int idx);
|
||||
gboolean wplua_isboxed (lua_State *L, int idx, GType type);
|
||||
|
||||
/* transfer floating */
|
||||
GClosure * wplua_function_to_closure (lua_State *L, int idx);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue