Skip to content
Snippets Groups Projects
Commit 86f97b17 authored by George Kiagiadakis's avatar George Kiagiadakis
Browse files

wplua: expose table to/from properties conversion functions

parent b94e54c4
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment