summaryrefslogtreecommitdiff
path: root/plugins/MirLua/src/m_json.h
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/MirLua/src/m_json.h')
-rw-r--r--plugins/MirLua/src/m_json.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/plugins/MirLua/src/m_json.h b/plugins/MirLua/src/m_json.h
new file mode 100644
index 0000000000..bb3a2e1568
--- /dev/null
+++ b/plugins/MirLua/src/m_json.h
@@ -0,0 +1,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_ \ No newline at end of file