session-item: add _register and _remove API

Allows using object managers to listen for registered items
This commit is contained in:
Julian Bouzas
2021-03-18 13:17:27 -04:00
parent 120aab04ae
commit 3aef916d51
3 changed files with 60 additions and 0 deletions

View File

@@ -1088,9 +1088,27 @@ session_item_configure (lua_State *L)
return 1;
}
static int
session_item_register (lua_State *L)
{
WpSessionItem *si = wplua_checkobject (L, 1, WP_TYPE_SESSION_ITEM);
wp_session_item_register (g_object_ref (si));
return 0;
}
static int
session_item_remove (lua_State *L)
{
WpSessionItem *si = wplua_checkobject (L, 1, WP_TYPE_SESSION_ITEM);
wp_session_item_remove (si);
return 0;
}
static const luaL_Reg session_item_methods[] = {
{ "reset", session_item_reset },
{ "configure", session_item_configure },
{ "register", session_item_register },
{ "remove", session_item_remove },
{ NULL, NULL }
};