diff options
author | Hans Hagen <pragma@wxs.nl> | 2017-02-18 13:39:16 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2017-02-18 13:39:16 +0100 |
commit | 601e63e757d4cf40d5923cee4b6b3debff57364c (patch) | |
tree | 90d3a5f505508efd67ca33b3c157c59d797bb989 /tex/context/base/mkiv/l-lua.lua | |
parent | fcd7cdd22ff42dab791f9f825b642caa3cc63300 (diff) | |
download | context-601e63e757d4cf40d5923cee4b6b3debff57364c.tar.gz |
2017-02-18 11:52:00
Diffstat (limited to 'tex/context/base/mkiv/l-lua.lua')
-rw-r--r-- | tex/context/base/mkiv/l-lua.lua | 95 |
1 files changed, 17 insertions, 78 deletions
diff --git a/tex/context/base/mkiv/l-lua.lua b/tex/context/base/mkiv/l-lua.lua index adc2c97a8..88cde6d1e 100644 --- a/tex/context/base/mkiv/l-lua.lua +++ b/tex/context/base/mkiv/l-lua.lua @@ -201,83 +201,22 @@ end -- new -if ffi and ffi.number then - -- already loaded -else - local okay - - okay, ffi = pcall(require,"ffi") - - if not ffi then - -- an old version - elseif ffi.os == "" or ffi.arch == "" then - -- no ffi support - ffi = nil - elseif ffi.number then - -- luatex - else - -- luajittex - ffi.number = tonumber - end +FFISUPPORTED = type(ffi) == "table" and ffi.os ~= "" and ffi.arch ~= "" and ffi.load + +if not FFISUPPORTED then + + -- Maybe we should check for LUATEXENGINE but that's also a bti tricky as we still + -- can have a weird ffi library laying around. Checking for presence of 'jit' is + -- also not robust. So for now we hope for the best. + + local okay ; okay, ffi = pcall(require,"ffi") + + FFISUPPORTED = type(ffi) == "table" and ffi.os ~= "" and ffi.arch ~= "" and ffi.load + end --- done differently in context --- --- if ffi then --- local load = ffi.load --- local select = select --- local type = type --- local next = next --- local sort = table.sort --- local gmatch = string.gmatch --- local okay = true --- local control = { } --- function ffi.load(name,...) --- if okay == true or okay[name] then --- return load(name,...) --- else --- return nil --- end --- end --- function control.permit(...) --- if okay == true then --- okay = { } --- end --- for i=1,select("#",...) do --- local n = select(i,...) --- local t = type(n) --- if t == "table" then --- for i=1,#n do --- control.permit(n[i]) --- end --- elseif t == "string" then --- for s in gmatch(n,"[^,%s]+") do --- okay[n] = true --- end --- end --- end --- end --- function control.freeze(none) --- control.permit = function() end --- control.freeze = function() end --- if none then --- okay = { } --- end --- end --- function control.permitted(name) --- if okay == true then --- return true --- elseif type(name) == "string" then --- return okay[name] or false --- else --- -- no helpers yet --- local t = { } --- for k, v in next, okay do --- t[#t+1] = k --- end --- sort(t) --- return t --- end --- end --- ffi.control = control --- end +if not FFISUPPORTED then + ffi = nil +elseif not ffi.number then + ffi.number = tonumber +end |