From 86f97b17c6deaf7833847f486295e9b20e7acdde Mon Sep 17 00:00:00 2001 From: George Kiagiadakis <george.kiagiadakis@collabora.com> Date: Tue, 22 Dec 2020 11:33:35 +0200 Subject: [PATCH] wplua: expose table to/from properties conversion functions --- lib/wplua/value.c | 12 ++++++------ lib/wplua/wplua.h | 5 ++++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/wplua/value.c b/lib/wplua/value.c index c33a0759..52f9015f 100644 --- a/lib/wplua/value.c +++ b/lib/wplua/value.c @@ -10,8 +10,8 @@ #include "private.h" #include <wp/wp.h> -static WpProperties * -table_to_properties (lua_State *L, int idx) +WpProperties * +wplua_table_to_properties (lua_State *L, int idx) { WpProperties *p = wp_properties_new_empty (); const gchar *key, *value; @@ -29,8 +29,8 @@ table_to_properties (lua_State *L, int idx) return p; } -static void -properties_to_table (lua_State *L, WpProperties *p) +void +wplua_properties_to_table (lua_State *L, WpProperties *p) { lua_newtable (L); if (p) { @@ -101,7 +101,7 @@ wplua_lua_to_gvalue (lua_State *L, int idx, GValue *v) g_value_set_boxed (v, wplua_toboxed (L, idx)); /* table -> WpProperties */ else if (lua_istable (L, idx) && G_VALUE_TYPE (v) == WP_TYPE_PROPERTIES) - g_value_take_boxed (v, table_to_properties (L, idx)); + g_value_take_boxed (v, wplua_table_to_properties (L, idx)); break; case G_TYPE_OBJECT: case G_TYPE_INTERFACE: @@ -171,7 +171,7 @@ wplua_gvalue_to_lua (lua_State *L, const GValue *v) break; case G_TYPE_BOXED: if (G_VALUE_TYPE (v) == WP_TYPE_PROPERTIES) - properties_to_table (L, g_value_get_boxed (v)); + wplua_properties_to_table (L, g_value_get_boxed (v)); else wplua_pushboxed (L, G_VALUE_TYPE (v), g_value_dup_boxed (v)); break; diff --git a/lib/wplua/wplua.h b/lib/wplua/wplua.h index 07597792..821b4fdb 100644 --- a/lib/wplua/wplua.h +++ b/lib/wplua/wplua.h @@ -9,7 +9,7 @@ #ifndef __WPLUA_H__ #define __WPLUA_H__ -#include <glib-object.h> +#include <wp/wp.h> #include <lua.h> #include <lauxlib.h> @@ -65,6 +65,9 @@ GClosure * wplua_function_to_closure (lua_State *L, int idx); void wplua_lua_to_gvalue (lua_State *L, int idx, GValue *v); int wplua_gvalue_to_lua (lua_State *L, const GValue *v); +WpProperties * wplua_table_to_properties (lua_State *L, int idx); +void wplua_properties_to_table (lua_State *L, WpProperties *p); + gboolean wplua_load_buffer (lua_State * L, const gchar *buf, gsize size, GError **error); gboolean wplua_load_uri (lua_State * L, const gchar *uri, GError **error); -- GitLab