George Kiagiadakis
bed43a481a
wplua: sort properties after transfering them from lua
2021-03-26 19:07:56 +02:00
George Kiagiadakis
e2d6e5b992
lua: enable loading scripts with a shebang
...
* skip the shebang before loading the file in the interpreter,
as # is not a valid lua comment
* allow loading scripts with a relative path in interactive mode
2021-02-18 13:47:34 +02:00
George Kiagiadakis
7c1fc1c567
wplua: table_to_properties: use luaL_tolstring to do string conversions
...
The advantage is that luaL_tolstring behaves the same as the native lua
tostring() function, while lua_tostring() does not. In particular, boolean
values are converted properly to "true" and "false" now, while they were
not converted with lua_tostring()
Add a unit test too
2021-02-16 16:53:22 +02:00
Raghavendra
c791ed3a62
m-lua-scripting: add WpPipewireObject api
2021-02-16 20:15:13 +05:30
George Kiagiadakis
e92351b23b
wplua: gvariant_to_lua: convert dictionary keys to integers if possible
...
When we convert from a lua table to a GVariant dictionary, it is not
possible to maintain the hybrid string & integer keys approach that Lua
has for tables, so we convert all keys to strings and a table becomes a{sv}
When we convert back from a{sv} to a table, it is desirable to get back
the integer keys wherever possible.
The use case is to pass "arrays" (i.e. tables with integer keys) from
the configuration files to the lua scripts, without losing the properties
of the "array"
2021-02-15 18:50:56 +02:00
George Kiagiadakis
b3ff7347cd
wplua: improve GVariant array conversion
...
* index array items from 1
* handle any kind of value, not just GVariant basic types
* unit test
2021-02-15 14:43:18 +02:00
George Kiagiadakis
dacf19d9c7
wplua: improve gvariant <-> lua conversion functions
...
* Add more generic lua -> gvariant conversion
* Cleanup the gvariant -> lua function and rename it
2021-02-15 14:43:18 +02:00
George Kiagiadakis
413ff73bab
wplua: remove VARDICT handling in gvariant->lua conversion
...
G_VARIANT_TYPE_DICTIONARY also catches the VARDICT case
2021-02-15 14:43:18 +02:00
Julian Bouzas
cbe90a5c75
wplua: handle more GVariant cases
2021-02-12 14:28:38 -05:00
Julian Bouzas
dc2ad1f25d
rename all foo_iterate APIs to foo_new_iterator
...
Avoids confusion with LUA iterate API
2021-02-05 11:33:23 -05:00
George Kiagiadakis
7b37b31af9
wplua: fix enum <-> lua conversion
...
Sometimes the GEnumClass is not instantiated, so _peek() doesn't work
We need to acquire a strong ref to make sure it is
2021-02-05 12:00:24 +02:00
Julian Bouzas
a634bf88fd
wplua: fix vtables lookup in boxed __index function
2021-02-05 08:47:27 +00:00
George Kiagiadakis
e0f1c8710f
daemon: add a mode to execute lua scripts from the command line
...
This can be useful for quick testing of scripts, or to build small
utilities that do something in pipewire utilizing our lua API
2021-02-04 16:44:56 +02:00
George Kiagiadakis
1c0f0b8684
wplua: pass SANDBOX_CONFIG as a script argument
...
avoids keeping it forever as a global
2021-02-03 17:16:51 +02:00
George Kiagiadakis
460ff6591d
wplua: allow exchanging arguments and results with scripts
2021-02-03 17:16:51 +02:00
George Kiagiadakis
81d6f055a0
wplua: add GVariant dictionary conversion functions
2021-02-03 17:16:51 +02:00
George Kiagiadakis
5647f0bf9e
wplua: allow loading relative paths from wplua_load_path()
...
convert them to absolute before creating the URI
2021-02-03 17:16:51 +02:00
George Kiagiadakis
84f1b4b484
wplua: add g_autoptr support to lua_State
2021-02-03 17:16:51 +02:00
George Kiagiadakis
94d527e187
wplua: add flags to modify the sandbox behavior
...
with ISOLATE_ENV, it isolates the global environment between scripts
just like it did before; without it, it uses a common environment
with MINIMAL_STD, it restricts even further the available library
functions; useful for configuration files that don't need to do
actual scripting, just to define some tables
2021-02-03 17:16:51 +02:00
George Kiagiadakis
997e2c7539
wplua: object: unset GValues used when calling action signals
2021-01-21 09:42:07 +02:00
George Kiagiadakis
86f97b17c6
wplua: expose table to/from properties conversion functions
2020-12-22 11:33:35 +02:00
George Kiagiadakis
d0d2f2a59e
wplua: use only the basename of the files for debug/error messages
2020-12-18 18:26:31 +02:00
George Kiagiadakis
067da200fc
wplua: use the error handler also when loading chunks
...
... and improve its output
2020-12-18 18:25:43 +02:00
George Kiagiadakis
0054559b91
wplua: implement __tostring for GObject
2020-12-18 18:24:27 +02:00
George Kiagiadakis
da375a7408
wplua: use the registry to store vtables & closures
2020-12-16 23:19:07 +02:00
George Kiagiadakis
70931969b4
wplua: remove TypeClass, push constructors as ClassName_new
2020-12-16 23:14:58 +02:00
George Kiagiadakis
5edfc090c6
wplua: allow checking for a specific GType with isobject/isboxed
2020-12-16 23:12:41 +02:00
George Kiagiadakis
65b817f6fc
wplua: add proper GError domain & error codes
2020-12-15 18:36:14 +02:00
George Kiagiadakis
8b4c5af49c
wplua: implement sandboxing of scripts
...
All loaded scripts can now be run in a protected environment
so that they cannot do any harm to the host or to each other
2020-12-15 18:28:28 +02:00
George Kiagiadakis
b9ca4e1425
wplua: convert WpProperties to table and vice versa
2020-12-15 10:27:40 +02:00
George Kiagiadakis
7d692e0246
wplua: new simple engine to integrate GObject with Lua
2020-12-11 17:07:20 +02:00