mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user