From Matt Briggs via bug 3062: Keep Lua from doing rude things to

the stack.

svn path=/trunk/; revision=27139
This commit is contained in:
Gerald Combs 2008-12-31 01:20:20 +00:00
parent bc740b7822
commit 80e2a01fae
1 changed files with 9 additions and 4 deletions

View File

@ -235,7 +235,6 @@ typedef tvbparse_action_t* Shortcut;
typedef struct _wslua_main* WireShark;
typedef struct _wslua_dir* Dir;
/*
* toXxx(L,idx) gets a Xxx from an index (Lua Error if fails)
* checkXxx(L,idx) gets a Xxx from an index after calling check_code (No Lua Error if it fails)
@ -259,7 +258,9 @@ C check##C(lua_State* L, int index) { \
return p ? *p : NULL; \
} \
C* push##C(lua_State* L, C v) { \
C* p = lua_newuserdata(L,sizeof(C)); *p = v; \
C* p; \
luaL_checkstack(L,2,"Unable to grow stack\n"); \
p = lua_newuserdata(L,sizeof(C)); *p = v; \
luaL_getmetatable(L, #C); lua_setmetatable(L, -2); \
push_code; \
return p; \
@ -297,10 +298,14 @@ typedef int dummy##C
lua_pushliteral(L, "__metatable"); \
lua_pushvalue(L, -3); \
lua_rawset(L, -3); \
lua_pop(L, 1); \
lua_pop(L, 2); \
}
#define WSLUA_REGISTER_META(C) luaL_newmetatable (L, #C); luaL_register (L, NULL, C ## _meta);
#define WSLUA_REGISTER_META(C) { \
luaL_newmetatable (L, #C); \
luaL_register (L, NULL, C ## _meta); \
lua_pop(L,1); \
}
#define WSLUA_INIT(L) \
luaL_openlibs(L); \