aboutsummaryrefslogtreecommitdiff
path: root/lauxlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'lauxlib.c')
-rw-r--r--lauxlib.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/lauxlib.c b/lauxlib.c
index 84d7feaa..3f863602 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.c,v 1.84 2002/08/30 20:00:59 roberto Exp roberto $ 2** $Id: lauxlib.c,v 1.85 2002/09/05 19:45:42 roberto Exp roberto $
3** Auxiliary functions for building Lua libraries 3** Auxiliary functions for building Lua libraries
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -147,7 +147,7 @@ LUALIB_API lua_Number luaL_opt_number (lua_State *L, int narg, lua_Number def) {
147} 147}
148 148
149 149
150LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) { 150LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) {
151 if (!lua_getmetatable(L, obj)) /* no metatable? */ 151 if (!lua_getmetatable(L, obj)) /* no metatable? */
152 return 0; 152 return 0;
153 lua_pushstring(L, event); 153 lua_pushstring(L, event);
@@ -156,6 +156,13 @@ LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) {
156 lua_pop(L, 2); /* remove metatable and metafield */ 156 lua_pop(L, 2); /* remove metatable and metafield */
157 return 0; 157 return 0;
158 } 158 }
159 return 1;
160}
161
162
163LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) {
164 if (!luaL_getmetafield(L, obj, event)) /* no metafield? */
165 return 0;
159 lua_pushvalue(L, obj); 166 lua_pushvalue(L, obj);
160 lua_call(L, 1, 1); 167 lua_call(L, 1, 1);
161 return 1; 168 return 1;