mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2025-12-20 04:10:03 +01:00
m-lua-scripting: Add WpIterator API
We skip the fold() API as the same thing can be done just using Lua closures.
This commit is contained in:
parent
fb1738932b
commit
f188ddfb34
1 changed files with 24 additions and 0 deletions
|
|
@ -599,6 +599,28 @@ push_wpiterator (lua_State *L, WpIterator *it)
|
|||
return 2;
|
||||
}
|
||||
|
||||
static int
|
||||
iterator_reset (lua_State *L)
|
||||
{
|
||||
WpIterator *it = wplua_checkboxed (L, 1, WP_TYPE_ITERATOR);
|
||||
wp_iterator_reset (it);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
iterator_iterate (lua_State *L)
|
||||
{
|
||||
WpIterator *it = wplua_checkboxed (L, 1, WP_TYPE_ITERATOR);
|
||||
return push_wpiterator (L, wp_iterator_ref (it));
|
||||
}
|
||||
|
||||
static const luaL_Reg iterator_funcs[] = {
|
||||
{ "next", iterator_next },
|
||||
{ "reset", iterator_reset },
|
||||
{ "iterate", iterator_iterate },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
/* Settings WpIterator */
|
||||
|
||||
static int
|
||||
|
|
@ -2984,6 +3006,8 @@ wp_lua_scripting_api_init (lua_State *L)
|
|||
conf_new, conf_methods);
|
||||
wplua_register_type_methods (L, WP_TYPE_PROC_INFO,
|
||||
NULL, proc_info_funcs);
|
||||
wplua_register_type_methods (L, WP_TYPE_ITERATOR,
|
||||
NULL, iterator_funcs);
|
||||
|
||||
if (!wplua_load_uri (L, URI_API, &error) ||
|
||||
!wplua_pcall (L, 0, 0, &error)) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue