diff options
author | Mike Pall <mike> | 2012-09-24 17:52:32 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2012-09-24 17:52:32 +0200 |
commit | 125cc879884b19ffa9181b7a52d1b7b73759301e (patch) | |
tree | d087214ba37678ccfb6a941df89fe53b796b58f0 | |
parent | ca0bb4881f17838c9d84f0df310aa1d44da9298d (diff) | |
download | luajit-125cc879884b19ffa9181b7a52d1b7b73759301e.tar.gz luajit-125cc879884b19ffa9181b7a52d1b7b73759301e.tar.bz2 luajit-125cc879884b19ffa9181b7a52d1b7b73759301e.zip |
From Lua 5.2: Add debug.getuservalue() and debug.setuservalue().
Needs -DLUAJIT_ENABLE_LUA52COMPAT.
-rw-r--r-- | src/lib_debug.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/lib_debug.c b/src/lib_debug.c index ebe0691f..07b025af 100644 --- a/src/lib_debug.c +++ b/src/lib_debug.c | |||
@@ -256,6 +256,31 @@ LJLIB_CF(debug_upvaluejoin) | |||
256 | return 0; | 256 | return 0; |
257 | } | 257 | } |
258 | 258 | ||
259 | #if LJ_52 | ||
260 | LJLIB_CF(debug_getuservalue) | ||
261 | { | ||
262 | TValue *o = L->base; | ||
263 | if (o < L->top && tvisudata(o)) | ||
264 | settabV(L, o, tabref(udataV(o)->env)); | ||
265 | else | ||
266 | setnilV(o); | ||
267 | L->top = o+1; | ||
268 | return 1; | ||
269 | } | ||
270 | |||
271 | LJLIB_CF(debug_setuservalue) | ||
272 | { | ||
273 | TValue *o = L->base; | ||
274 | if (!(o < L->top && tvisudata(o))) | ||
275 | lj_err_argt(L, 1, LUA_TUSERDATA); | ||
276 | if (!(o+1 < L->top && tvistab(o+1))) | ||
277 | lj_err_argt(L, 2, LUA_TTABLE); | ||
278 | L->top = o+2; | ||
279 | lua_setfenv(L, 1); | ||
280 | return 1; | ||
281 | } | ||
282 | #endif | ||
283 | |||
259 | /* ------------------------------------------------------------------------ */ | 284 | /* ------------------------------------------------------------------------ */ |
260 | 285 | ||
261 | static const char KEY_HOOK = 'h'; | 286 | static const char KEY_HOOK = 'h'; |