diff options
Diffstat (limited to 'src/compat.c')
-rw-r--r-- | src/compat.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/compat.c b/src/compat.c index c5e29f5..9f36090 100644 --- a/src/compat.c +++ b/src/compat.c | |||
@@ -4,6 +4,7 @@ | |||
4 | * ############################################################################################### | 4 | * ############################################################################################### |
5 | */ | 5 | */ |
6 | #include "compat.h" | 6 | #include "compat.h" |
7 | #include "macros_and_utils.h" | ||
7 | 8 | ||
8 | /* | 9 | /* |
9 | ** Copied from Lua 5.2 loadlib.c | 10 | ** Copied from Lua 5.2 loadlib.c |
@@ -42,3 +43,35 @@ void luaL_requiref (lua_State *L, const char *modname, lua_CFunction openf, int | |||
42 | } | 43 | } |
43 | #endif // LUA_VERSION_NUM | 44 | #endif // LUA_VERSION_NUM |
44 | 45 | ||
46 | #if LUA_VERSION_NUM < 504 | ||
47 | |||
48 | void* lua_newuserdatauv( lua_State* L, size_t sz, int nuvalue) | ||
49 | { | ||
50 | ASSERT_L( nuvalue <= 1); | ||
51 | return lua_newuserdata( L, sz); | ||
52 | } | ||
53 | |||
54 | int lua_getiuservalue( lua_State* L, int idx, int n) | ||
55 | { | ||
56 | if( n > 1) | ||
57 | { | ||
58 | lua_pushnil( L); | ||
59 | return LUA_TNONE; | ||
60 | } | ||
61 | lua_getuservalue( L, idx); | ||
62 | return lua_type( L, -1); | ||
63 | } | ||
64 | |||
65 | int lua_setiuservalue( lua_State* L, int idx, int n) | ||
66 | { | ||
67 | if( n > 1) | ||
68 | { | ||
69 | lua_pop( L, 1); | ||
70 | return 0; | ||
71 | } | ||
72 | (void) lua_setuservalue( L, idx); | ||
73 | return 1; // I guess anything non-0 is ok | ||
74 | } | ||
75 | |||
76 | #endif // LUA_VERSION_NUM | ||
77 | |||