api: module: support loading arguments from file

This commit is contained in:
Dmitry Sharshakov
2023-07-16 16:26:06 +03:00
parent 92e53bb7ba
commit 2ae1b3cbd9
4 changed files with 84 additions and 3 deletions

View File

@@ -6,6 +6,7 @@
* SPDX-License-Identifier: MIT
*/
#include "lua.h"
#include <glib/gstdio.h>
#include <wp/wp.h>
#include <pipewire/pipewire.h>
@@ -1461,8 +1462,20 @@ impl_module_new (lua_State *L)
properties = wplua_table_to_properties (L, 3);
}
WpImplModule *m = wp_impl_module_load (get_wp_export_core (L),
name, args, properties);
bool load_file = false; // Load args as file path
if (lua_type (L, 4) != LUA_TNONE && lua_type (L, 4) != LUA_TNIL) {
luaL_checktype (L, 4, LUA_TBOOLEAN);
load_file = lua_toboolean(L, 4);
}
WpImplModule *m = NULL;
if (load_file) {
m = wp_impl_module_load_file (get_wp_export_core (L),
name, args, properties);
} else {
m = wp_impl_module_load (get_wp_export_core (L),
name, args, properties);
}
if (m) {
wplua_pushobject (L, m);