Commit graph

13 commits

Author SHA1 Message Date
George Kiagiadakis
bed43a481a wplua: sort properties after transfering them from lua 2021-03-26 19:07:56 +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
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
George Kiagiadakis
81d6f055a0 wplua: add GVariant dictionary conversion functions 2021-02-03 17:16:51 +02:00
George Kiagiadakis
86f97b17c6 wplua: expose table to/from properties conversion functions 2020-12-22 11:33:35 +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