mirror of
https://github.com/lua/lua
synced 2025-04-11 07:22:53 +03:00
nil is a `valid' eventtable
This commit is contained in:
parent
eb262bc617
commit
a048cc9676
8
lapi.c
8
lapi.c
@ -35,7 +35,7 @@ const char lua_ident[] =
|
|||||||
|
|
||||||
#define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->ci->base))
|
#define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->ci->base))
|
||||||
|
|
||||||
#define api_incr_top(L) incr_top
|
#define api_incr_top(L) incr_top(L)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ static TObject *luaA_indexAcceptable (lua_State *L, int index) {
|
|||||||
|
|
||||||
void luaA_pushobject (lua_State *L, const TObject *o) {
|
void luaA_pushobject (lua_State *L, const TObject *o) {
|
||||||
setobj(L->top, o);
|
setobj(L->top, o);
|
||||||
incr_top;
|
incr_top(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
LUA_API int lua_stackspace (lua_State *L) {
|
LUA_API int lua_stackspace (lua_State *L) {
|
||||||
@ -335,7 +335,7 @@ LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
|
|||||||
while (n--)
|
while (n--)
|
||||||
setobj(&cl->c.upvalue[n], L->top+n);
|
setobj(&cl->c.upvalue[n], L->top+n);
|
||||||
setclvalue(L->top, cl);
|
setclvalue(L->top, cl);
|
||||||
incr_top;
|
api_incr_top(L);
|
||||||
lua_unlock(L);
|
lua_unlock(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -494,6 +494,8 @@ LUA_API void lua_seteventtable (lua_State *L, int objindex) {
|
|||||||
api_checknelems(L, 1);
|
api_checknelems(L, 1);
|
||||||
obj = luaA_indexAcceptable(L, objindex);
|
obj = luaA_indexAcceptable(L, objindex);
|
||||||
et = --L->top;
|
et = --L->top;
|
||||||
|
if (ttype(et) == LUA_TNIL)
|
||||||
|
et = defaultet(L);
|
||||||
api_check(L, ttype(et) == LUA_TTABLE);
|
api_check(L, ttype(et) == LUA_TTABLE);
|
||||||
switch (ttype(obj)) {
|
switch (ttype(obj)) {
|
||||||
case LUA_TTABLE:
|
case LUA_TTABLE:
|
||||||
|
@ -140,8 +140,9 @@ static int luaB_eventtable (lua_State *L) {
|
|||||||
if (lua_isnone(L, 2))
|
if (lua_isnone(L, 2))
|
||||||
lua_geteventtable(L, 1);
|
lua_geteventtable(L, 1);
|
||||||
else {
|
else {
|
||||||
|
int t = lua_type(L, 2);
|
||||||
|
luaL_arg_check(L, t == LUA_TNIL || t == LUA_TTABLE, 2, "nil/table expected");
|
||||||
lua_settop(L, 2);
|
lua_settop(L, 2);
|
||||||
luaL_check_type(L, 2, LUA_TTABLE);
|
|
||||||
lua_seteventtable(L, 1);
|
lua_seteventtable(L, 1);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user