seqlua
diff seqlua.c @ 54:92ce3958aca7
Reverted last two commits
author | jbe |
---|---|
date | Wed Aug 27 00:10:47 2014 +0200 (2014-08-27) |
parents | 3362ec36cb09 |
children | da4b9d6a5b7e |
line diff
1.1 --- a/seqlua.c Tue Aug 26 23:53:29 2014 +0200 1.2 +++ b/seqlua.c Wed Aug 27 00:10:47 2014 +0200 1.3 @@ -35,9 +35,6 @@ 1.4 } 1.5 1.6 static int seqlua_ipairs(lua_State *L) { 1.7 - const char *method; 1.8 - int generated = 0; 1.9 - seqlua_ipairs_repeat: 1.10 if (luaL_getmetafield(L, 1, "__ipairs")) { 1.11 lua_pushvalue(L, 1); 1.12 lua_call(L, 1, 3); 1.13 @@ -58,27 +55,13 @@ 1.14 } else { 1.15 int t = lua_type(L, 1); 1.16 if (t == LUA_TFUNCTION) { 1.17 - if (generated) goto seqlua_ipairs_call; 1.18 - method = lua_tostring(L, 2); 1.19 - if (method) { 1.20 - if (!strcmp(method, "call")) { 1.21 - seqlua_ipairs_call: 1.22 - lua_pushcfunction(L, seqlua_ipairsaux_call); 1.23 - goto seqlua_ipairs_finish; 1.24 - } else if (!strcmp(method, "generator")) { 1.25 - lua_settop(L, 1); 1.26 - lua_call(L, 0, 1); 1.27 - generated = 1; 1.28 - goto seqlua_ipairs_repeat; 1.29 - } 1.30 - } 1.31 + lua_pushcfunction(L, seqlua_ipairsaux_call); 1.32 } else if (luaL_getmetafield(L, 1, "__index")) { 1.33 lua_pushcfunction(L, seqlua_ipairsaux_index); 1.34 - goto seqlua_ipairs_finish; 1.35 + } else { 1.36 + luaL_checktype(L, 1, LUA_TTABLE); 1.37 + lua_pushcfunction(L, seqlua_ipairsaux_raw); 1.38 } 1.39 - luaL_checktype(L, 1, LUA_TTABLE); 1.40 - lua_pushcfunction(L, seqlua_ipairsaux_raw); 1.41 - seqlua_ipairs_finish: 1.42 lua_pushvalue(L, 1); 1.43 lua_pushinteger(L, 0); 1.44 } 1.45 @@ -94,7 +77,7 @@ 1.46 luaL_checkany(L, 2); 1.47 lua_settop(L, 3); 1.48 luaL_buffinit(L, &buf); 1.49 - seqlua_iterloop(L, &iter, SEQLUA_MODE_CALL, 2) { 1.50 + seqlua_iterloop(L, &iter, 2) { 1.51 lua_replace(L, 3); 1.52 if (seqlua_itercount(&iter) > 1) luaL_addlstring(&buf, sep, seplen); 1.53 luaL_tolstring(L, 3, NULL);