diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-01-25 19:55:41 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-01-25 19:55:41 -0200 |
commit | a048cc9676f3572ebf5d6cc061f87cba85f5a249 (patch) | |
tree | a7a1fe7ebf6b0f1dab20eaf58176e46647e0ebc6 | |
parent | eb262bc61754670d45fb030432932c599cdef2d6 (diff) | |
download | lua-a048cc9676f3572ebf5d6cc061f87cba85f5a249.tar.gz lua-a048cc9676f3572ebf5d6cc061f87cba85f5a249.tar.bz2 lua-a048cc9676f3572ebf5d6cc061f87cba85f5a249.zip |
nil is a `valid' eventtable
-rw-r--r-- | lapi.c | 8 | ||||
-rw-r--r-- | lbaselib.c | 3 |
2 files changed, 7 insertions, 4 deletions
@@ -35,7 +35,7 @@ const char lua_ident[] = | |||
35 | 35 | ||
36 | #define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->ci->base)) | 36 | #define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->ci->base)) |
37 | 37 | ||
38 | #define api_incr_top(L) incr_top | 38 | #define api_incr_top(L) incr_top(L) |
39 | 39 | ||
40 | 40 | ||
41 | 41 | ||
@@ -81,7 +81,7 @@ static TObject *luaA_indexAcceptable (lua_State *L, int index) { | |||
81 | 81 | ||
82 | void luaA_pushobject (lua_State *L, const TObject *o) { | 82 | void luaA_pushobject (lua_State *L, const TObject *o) { |
83 | setobj(L->top, o); | 83 | setobj(L->top, o); |
84 | incr_top; | 84 | incr_top(L); |
85 | } | 85 | } |
86 | 86 | ||
87 | LUA_API int lua_stackspace (lua_State *L) { | 87 | 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) { | |||
335 | while (n--) | 335 | while (n--) |
336 | setobj(&cl->c.upvalue[n], L->top+n); | 336 | setobj(&cl->c.upvalue[n], L->top+n); |
337 | setclvalue(L->top, cl); | 337 | setclvalue(L->top, cl); |
338 | incr_top; | 338 | api_incr_top(L); |
339 | lua_unlock(L); | 339 | lua_unlock(L); |
340 | } | 340 | } |
341 | 341 | ||
@@ -494,6 +494,8 @@ LUA_API void lua_seteventtable (lua_State *L, int objindex) { | |||
494 | api_checknelems(L, 1); | 494 | api_checknelems(L, 1); |
495 | obj = luaA_indexAcceptable(L, objindex); | 495 | obj = luaA_indexAcceptable(L, objindex); |
496 | et = --L->top; | 496 | et = --L->top; |
497 | if (ttype(et) == LUA_TNIL) | ||
498 | et = defaultet(L); | ||
497 | api_check(L, ttype(et) == LUA_TTABLE); | 499 | api_check(L, ttype(et) == LUA_TTABLE); |
498 | switch (ttype(obj)) { | 500 | switch (ttype(obj)) { |
499 | case LUA_TTABLE: | 501 | case LUA_TTABLE: |
@@ -140,8 +140,9 @@ static int luaB_eventtable (lua_State *L) { | |||
140 | if (lua_isnone(L, 2)) | 140 | if (lua_isnone(L, 2)) |
141 | lua_geteventtable(L, 1); | 141 | lua_geteventtable(L, 1); |
142 | else { | 142 | else { |
143 | int t = lua_type(L, 2); | ||
144 | luaL_arg_check(L, t == LUA_TNIL || t == LUA_TTABLE, 2, "nil/table expected"); | ||
143 | lua_settop(L, 2); | 145 | lua_settop(L, 2); |
144 | luaL_check_type(L, 2, LUA_TTABLE); | ||
145 | lua_seteventtable(L, 1); | 146 | lua_seteventtable(L, 1); |
146 | } | 147 | } |
147 | return 1; | 148 | return 1; |