summaryrefslogtreecommitdiff
path: root/plugins/MirLua/src/m_json.h
blob: bb3a2e15689222385b27089071ae864d3c033daf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef _LUA_M_JSON_H_
#define _LUA_M_JSON_H_

#include <m_json.h>

struct JSON
{
	JSONNode *node;
	bool bDelete;

	JSON(JSONNode &refNode, bool bCopy = false)
		: node(bCopy ? json_copy(&refNode) : &refNode), bDelete(bCopy) { }
	JSON(JSONNode *n, bool bD = true)
		: node(n), bDelete(bD) { }
	~JSON()
	{
		if (bDelete)
			json_delete(node);
	}

	__inline void* operator new(size_t size, lua_State *L)
	{
		 return lua_newuserdata(L, size);
	}
};

#define MT_JSON "JSON"

#define MLUA_JSON	"m_json"
LUAMOD_API int (luaopen_m_json)(lua_State *L);

#endif //_LUA_M_PROTOCOLS_H_