Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions src/l52util.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,30 +58,6 @@ void lua_rawsetp (lua_State *L, int index, const void *p){
lua_rawset(L, index);
}

int luaL_getmetafield (lua_State *L, int obj, const char *event) {
if (!lua_getmetatable(L, obj)) /* no metatable? */
return 0;
lua_pushstring(L, event);
lua_rawget(L, -2);
if (lua_isnil(L, -1)) {
lua_pop(L, 2); /* remove metatable and metafield */
return 0;
}
else {
lua_remove(L, -2); /* remove only metatable */
return 1;
}
}

int luaL_callmeta (lua_State *L, int obj, const char *event) {
obj = lua_absindex(L, obj);
if (!luaL_getmetafield(L, obj, event)) /* no metafield? */
return 0;
lua_pushvalue(L, obj);
lua_call(L, 1, 1);
return 1;
}

#endif

int lutil_newmetatablep (lua_State *L, const void *p) {
Expand Down
5 changes: 1 addition & 4 deletions src/l52util.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void luaL_register (lua_State *L, const char *libname, const luaL_Reg *l);

#else /* Lua 5.1 */

/* functions form lua 5.2 */
/* functions from lua 5.2 */

# define lua_absindex(L, i) (((i)>0)?(i):((i)<=LUA_REGISTRYINDEX?(i):(lua_gettop(L)+(i)+1)))
# define lua_rawlen lua_objlen
Expand All @@ -67,9 +67,6 @@ void lua_rawgetp (lua_State *L, int index, const void *p);
void lua_rawsetp (lua_State *L, int index, const void *p);
void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup);

int luaL_getmetafield (lua_State *L, int obj, const char *event);
int luaL_callmeta (lua_State *L, int obj, const char *event);

#endif

int lutil_newmetatablep (lua_State *L, const void *p);
Expand Down
2 changes: 0 additions & 2 deletions src/lceasy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,6 @@ static int lcurl_easy_pause(lua_State *L){
}

static int lcurl_easy_setdata(lua_State *L){
lcurl_easy_t *p = lcurl_geteasy(L);
lua_settop(L, 2);
lua_pushvalue(L, 1);
lua_insert(L, 2);
Expand All @@ -1038,7 +1037,6 @@ static int lcurl_easy_setdata(lua_State *L){
}

static int lcurl_easy_getdata(lua_State *L){
lcurl_easy_t *p = lcurl_geteasy(L);
lua_settop(L, 1);
lua_rawget(L, LCURL_USERVALUES);
return 1;
Expand Down
2 changes: 0 additions & 2 deletions src/lcmulti.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,6 @@ static int lcurl_multi_setopt(lua_State *L){
}

static int lcurl_multi_setdata(lua_State *L){
lcurl_multi_t *p = lcurl_getmulti(L);
lua_settop(L, 2);
lua_pushvalue(L, 1);
lua_insert(L, 2);
Expand All @@ -471,7 +470,6 @@ static int lcurl_multi_setdata(lua_State *L){
}

static int lcurl_multi_getdata(lua_State *L){
lcurl_multi_t *p = lcurl_getmulti(L);
lua_settop(L, 1);
lua_rawget(L, LCURL_USERVALUES);
return 1;
Expand Down