Portable way to replace standards Lua funcs
Signed-off-by: Arvydas Sidorenko <asido4@gmail.com>
This commit is contained in:
parent
d612b922f3
commit
db0d23606d
15
luaa.c
15
luaa.c
|
@ -271,27 +271,22 @@ luaA_fixups(lua_State *L)
|
||||||
lua_setfield(L, -2, "wlen");
|
lua_setfield(L, -2, "wlen");
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
/* replace next */
|
/* replace next */
|
||||||
lua_pushliteral(L, "next");
|
|
||||||
lua_pushcfunction(L, luaAe_next);
|
lua_pushcfunction(L, luaAe_next);
|
||||||
lua_settable(L, LUA_GLOBALSINDEX);
|
lua_setglobal(L, "next");
|
||||||
/* replace pairs */
|
/* replace pairs */
|
||||||
lua_pushliteral(L, "pairs");
|
|
||||||
lua_pushcfunction(L, luaAe_next);
|
lua_pushcfunction(L, luaAe_next);
|
||||||
lua_pushcclosure(L, luaAe_pairs, 1); /* pairs get next as upvalue */
|
lua_pushcclosure(L, luaAe_pairs, 1); /* pairs get next as upvalue */
|
||||||
lua_settable(L, LUA_GLOBALSINDEX);
|
lua_setglobal(L, "pairs");
|
||||||
/* replace ipairs */
|
/* replace ipairs */
|
||||||
lua_pushliteral(L, "ipairs");
|
|
||||||
lua_pushcfunction(L, luaA_ipairs_aux);
|
lua_pushcfunction(L, luaA_ipairs_aux);
|
||||||
lua_pushcclosure(L, luaAe_ipairs, 1);
|
lua_pushcclosure(L, luaAe_ipairs, 1);
|
||||||
lua_settable(L, LUA_GLOBALSINDEX);
|
lua_setglobal(L, "ipairs");
|
||||||
/* replace type */
|
/* replace type */
|
||||||
lua_pushliteral(L, "type");
|
|
||||||
lua_pushcfunction(L, luaAe_type);
|
lua_pushcfunction(L, luaAe_type);
|
||||||
lua_settable(L, LUA_GLOBALSINDEX);
|
lua_setglobal(L, "type");
|
||||||
/* set selection */
|
/* set selection */
|
||||||
lua_pushliteral(L, "selection");
|
|
||||||
lua_pushcfunction(L, luaA_selection_get);
|
lua_pushcfunction(L, luaA_selection_get);
|
||||||
lua_settable(L, LUA_GLOBALSINDEX);
|
lua_setglobal(L, "selection");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Look for an item: table, function, etc.
|
/** Look for an item: table, function, etc.
|
||||||
|
|
Loading…
Reference in New Issue