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 @@ ...@@ -10,8 +10,8 @@
#include "private.h" #include "private.h"
#include <wp/wp.h> #include <wp/wp.h>
static WpProperties * WpProperties *
table_to_properties (lua_State *L, int idx) wplua_table_to_properties (lua_State *L, int idx)
{ {
WpProperties *p = wp_properties_new_empty (); WpProperties *p = wp_properties_new_empty ();
const gchar *key, *value; const gchar *key, *value;
...@@ -29,8 +29,8 @@ table_to_properties (lua_State *L, int idx) ...@@ -29,8 +29,8 @@ table_to_properties (lua_State *L, int idx)
return p; return p;
} }
static void void
properties_to_table (lua_State *L, WpProperties *p) wplua_properties_to_table (lua_State *L, WpProperties *p)
{ {
lua_newtable (L); lua_newtable (L);
if (p) { if (p) {
...@@ -101,7 +101,7 @@ wplua_lua_to_gvalue (lua_State *L, int idx, GValue *v) ...@@ -101,7 +101,7 @@ wplua_lua_to_gvalue (lua_State *L, int idx, GValue *v)
g_value_set_boxed (v, wplua_toboxed (L, idx)); g_value_set_boxed (v, wplua_toboxed (L, idx));
/* table -> WpProperties */ /* table -> WpProperties */
else if (lua_istable (L, idx) && G_VALUE_TYPE (v) == WP_TYPE_PROPERTIES) 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; break;
case G_TYPE_OBJECT: case G_TYPE_OBJECT:
case G_TYPE_INTERFACE: case G_TYPE_INTERFACE:
...@@ -171,7 +171,7 @@ wplua_gvalue_to_lua (lua_State *L, const GValue *v) ...@@ -171,7 +171,7 @@ wplua_gvalue_to_lua (lua_State *L, const GValue *v)
break; break;
case G_TYPE_BOXED: case G_TYPE_BOXED:
if (G_VALUE_TYPE (v) == WP_TYPE_PROPERTIES) 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 else
wplua_pushboxed (L, G_VALUE_TYPE (v), g_value_dup_boxed (v)); wplua_pushboxed (L, G_VALUE_TYPE (v), g_value_dup_boxed (v));
break; break;
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#ifndef __WPLUA_H__ #ifndef __WPLUA_H__
#define __WPLUA_H__ #define __WPLUA_H__
#include <glib-object.h> #include <wp/wp.h>
#include <lua.h> #include <lua.h>
#include <lauxlib.h> #include <lauxlib.h>
...@@ -65,6 +65,9 @@ GClosure * wplua_function_to_closure (lua_State *L, int idx); ...@@ -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); void wplua_lua_to_gvalue (lua_State *L, int idx, GValue *v);
int wplua_gvalue_to_lua (lua_State *L, const 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, gboolean wplua_load_buffer (lua_State * L, const gchar *buf, gsize size,
GError **error); GError **error);
gboolean wplua_load_uri (lua_State * L, const gchar *uri, 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