summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/l-lua.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2017-02-17 10:31:56 +0100
committerContext Git Mirror Bot <phg42.2a@gmail.com>2017-02-17 10:31:56 +0100
commitb14f992ef5f4e868c9959b174278c86516d60dbc (patch)
tree28587bb46c025ea7b0d27ba93f09c93dcf53c73a /tex/context/base/mkiv/l-lua.lua
parent95a1799032dc61dbca4a11e495be34b4397c8fec (diff)
downloadcontext-b14f992ef5f4e868c9959b174278c86516d60dbc.tar.gz
2017-02-17 10:23:00
Diffstat (limited to 'tex/context/base/mkiv/l-lua.lua')
-rw-r--r--tex/context/base/mkiv/l-lua.lua84
1 files changed, 83 insertions, 1 deletions
diff --git a/tex/context/base/mkiv/l-lua.lua b/tex/context/base/mkiv/l-lua.lua
index 357153836..adc2c97a8 100644
--- a/tex/context/base/mkiv/l-lua.lua
+++ b/tex/context/base/mkiv/l-lua.lua
@@ -188,7 +188,7 @@ if lua then
lua.mask = load([[τεχ = 1]]) and "utf" or "ascii"
end
-local flush = io.flush
+local flush = io.flush
if flush then
@@ -199,3 +199,85 @@ if flush then
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
+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