diff options
Diffstat (limited to 'src/compat.c')
-rw-r--r-- | src/compat.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/compat.c b/src/compat.c new file mode 100644 index 0000000..d763c56 --- /dev/null +++ b/src/compat.c | |||
@@ -0,0 +1,17 @@ | |||
1 | #include <lua.h> | ||
2 | #include <lauxlib.h> | ||
3 | |||
4 | #if LUA_VERSION_NUM == 501 | ||
5 | void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup) { | ||
6 | luaL_checkstack(L, nup+1, "too many upvalues"); | ||
7 | for (; l->name != NULL; l++) { /* fill the table with given functions */ | ||
8 | int i; | ||
9 | lua_pushstring(L, l->name); | ||
10 | for (i = 0; i < nup; i++) /* copy upvalues to the top */ | ||
11 | lua_pushvalue(L, -(nup+1)); | ||
12 | lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */ | ||
13 | lua_settable(L, -(nup + 3)); | ||
14 | } | ||
15 | lua_pop(L, nup); /* remove upvalues */ | ||
16 | } | ||
17 | #endif | ||