Commit ebb99399 authored by Vladimír Čunát's avatar Vladimír Čunát Committed by Štěpán Balážik

lua sandbox: export the list of original names

That will allow us to discover the top-level symbols for completion.
For others we can e.g.: for n in pairs(net) do print(n); end
I must admit I fail to understand some of the related lua magic.
parent b27acd9f
......@@ -160,7 +160,14 @@ end
-- Make sandboxed environment
local function make_sandbox(defined)
local __protected = { modules = true, cache = true, net = true, trust_anchors = true }
return setmetatable({}, {
-- Compute and export the list of top-level names (hidden otherwise)
local nl = ""
for n in pairs(defined) do
nl = nl .. n .. "\n"
return setmetatable({ __orig_name_list = nl }, {
__index = defined,
__newindex = function (t, k, v)
if __protected[k] then
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment