diff options
author | 2011-12-15 11:16:50 -0500 | |
---|---|---|
committer | 2011-12-15 11:16:50 -0500 | |
commit | 83eabf083b695a296556b35b30be052afd76ee0c (patch) | |
tree | 7bee81144b0cd57d96496a50e55d13cc5114ebd7 /core/compat.lua | |
parent | 4379015de5be80ac8a4ec280390960fe7f249c11 (diff) | |
download | textadept-83eabf083b695a296556b35b30be052afd76ee0c.tar.gz textadept-83eabf083b695a296556b35b30be052afd76ee0c.zip |
Add support for compiling with LuaJIT.
Diffstat (limited to 'core/compat.lua')
-rw-r--r-- | core/compat.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/core/compat.lua b/core/compat.lua new file mode 100644 index 00000000..245233b3 --- /dev/null +++ b/core/compat.lua @@ -0,0 +1,19 @@ +-- Copyright 2007-2011 Mitchell mitchell<att>caladbolg.net. See LICENSE. + +-- When using LuaJIT try to retain backwards compatibility (Lua 5.1). +-- LuaJIT is compiled with LUAJIT_ENABLE_LUA52COMPAT for some Lua 5.2 features. + +-- In Lua 5.1, `xpcall` did not accept function arguments. +local xpcall51 = xpcall +function xpcall(f, error, ...) + local args = {...} + return xpcall51(function() f(unpack(args)) end, error) +end + +-- In Lua 5.1, `load` did not take mode and environment parameters. +local load51 = load +function load(ld, source, mode, env) + local f, err = load51(ld, source) + if f and env then return setfenv(f, env) end + return f, err +end |