aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/lua/packet-lua.h
diff options
context:
space:
mode:
authorLuis Ontanon <luis.ontanon@gmail.com>2006-02-19 21:51:34 +0000
committerLuis Ontanon <luis.ontanon@gmail.com>2006-02-19 21:51:34 +0000
commitc3c7f8a0c3a9fdc2ffb7cc5d84b5c15a593c942d (patch)
treee3ca4a9a931f7b85df42b57da85befd12827facb /plugins/lua/packet-lua.h
parent97d857e20bd5365f244e3bbe7e2fb64110b4349d (diff)
- Use lua 5.1
- Compress *_register() functions svn path=/trunk/; revision=17354
Diffstat (limited to 'plugins/lua/packet-lua.h')
-rw-r--r--plugins/lua/packet-lua.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/plugins/lua/packet-lua.h b/plugins/lua/packet-lua.h
index 151b89570d..ac25ff932a 100644
--- a/plugins/lua/packet-lua.h
+++ b/plugins/lua/packet-lua.h
@@ -211,6 +211,48 @@ C shift##C(lua_State* L,int i) { \
} \
}
+
+#ifdef HAVE_LUA_5_1
+
+#define REGISTER_FULL_CLASS(CN,methods,meta) { \
+ luaL_register (L, CN, methods); \
+ luaL_newmetatable (L, CN); \
+ luaL_register (L, NULL, meta); \
+ lua_pushliteral(L, "__index"); \
+ lua_pushvalue(L, -3); \
+ lua_rawset(L, -3); \
+ lua_pushliteral(L, "__metatable"); \
+ lua_pushvalue(L, -3); \
+ lua_rawset(L, -3); \
+ lua_pop(L, 1); \
+}
+
+#define REGISTER_META(CN,meta) luaL_newmetatable (L, CN); luaL_register (L, NULL, meta);
+
+#define INIT_LUA(L) L = luaL_newstate(); luaL_openlibs(L);
+
+#else /* Lua 5.0 */
+
+#define REGISTER_FULL_CLASS(CN,methods,meta) { \
+ luaL_openlib(L, CN, methods, 0); \
+ luaL_newmetatable(L, CN); \
+ luaL_openlib(L, 0, meta, 0); \
+ lua_pushliteral(L, "__index"); \
+ lua_pushvalue(L, -3); \
+ lua_rawset(L, -3); \
+ lua_pushliteral(L, "__metatable"); \
+ lua_pushvalue(L, -3); \
+ lua_rawset(L, -3); \
+ lua_pop(L, 1); \
+}
+
+#define REGISTER_META(CN,meta) luaL_newmetatable (L, CN); luaL_openlib (L, NULL, meta, 0);
+
+#define INIT_LUA(L) L = lua_open(); luaopen_base(L); luaopen_table(L); luaopen_io(L); luaopen_string(L);
+
+#endif
+
+
extern packet_info* lua_pinfo;
extern proto_tree* lua_tree;
extern tvbuff_t* lua_tvb;