Add support for "flat" tables to Variant.

This means you can now use Variants (used by Channels and love.event, for instance) to send tables as long as they only contain keys and values supported by Variant, AND they are not tables themselves.
This commit is contained in:
Bart van Strien
2013-07-15 11:53:24 +02:00
parent 67353d4de7
commit 98d92d3e1f
2 changed files with 78 additions and 3 deletions
+7 -2
View File
@@ -25,6 +25,8 @@
#include "common/Object.h"
#include <cstring>
#include <vector>
#include <utility>
namespace love
{
@@ -40,9 +42,10 @@ public:
Variant(char c);
Variant(void *userdata);
Variant(love::Type udatatype, void *userdata);
Variant(std::vector<std::pair<Variant*, Variant*> > *table);
virtual ~Variant();
static Variant *fromLua(lua_State *L, int n);
static Variant *fromLua(lua_State *L, int n, bool allowTables = true);
void toLua(lua_State *L);
private:
@@ -55,7 +58,8 @@ private:
STRING,
LUSERDATA,
FUSERDATA,
NIL
NIL,
TABLE
} type;
union
{
@@ -68,6 +72,7 @@ private:
size_t len;
} string;
void *userdata;
std::vector<std::pair<Variant*, Variant*> > *table;
} data;
love::Type udatatype;
bits flags;