2011-06-19 17:52:02 +02:00
|
|
|
-------
|
|
|
|
-- global functions and tables
|
|
|
|
local tools = require 'ldoc.tools'
|
2011-09-19 14:42:54 +02:00
|
|
|
local globals = {}
|
2012-03-13 09:37:07 +01:00
|
|
|
local lua52 = _VERSION:match '5.2'
|
2011-06-19 17:52:02 +02:00
|
|
|
|
|
|
|
|
2011-09-19 14:42:54 +02:00
|
|
|
globals.functions = {
|
2011-06-19 17:52:02 +02:00
|
|
|
assert = true,
|
|
|
|
collectgarbage = true,
|
|
|
|
dofile = true,
|
|
|
|
getmetatable = true,
|
|
|
|
setmetatable = true,
|
|
|
|
pairs = true,
|
|
|
|
ipairs = true,
|
|
|
|
load = true,
|
|
|
|
loadfile = true,
|
|
|
|
loadstring = true,
|
|
|
|
next = true,
|
|
|
|
pcall = true,
|
|
|
|
print = true,
|
|
|
|
rawequal = true,
|
|
|
|
rawget = true,
|
|
|
|
rawset = true,
|
|
|
|
select = true,
|
|
|
|
tonumber = true,
|
|
|
|
tostring = true,
|
|
|
|
type = true,
|
|
|
|
xpcall = true,
|
|
|
|
module = true,
|
|
|
|
require = true,
|
|
|
|
}
|
2011-09-19 14:42:54 +02:00
|
|
|
local functions = globals.functions
|
2011-06-19 17:52:02 +02:00
|
|
|
|
2012-03-13 09:37:07 +01:00
|
|
|
if not lua52 then
|
|
|
|
functions.setfenv = true
|
|
|
|
functions.getfenv = true
|
|
|
|
functions.unpack = true
|
|
|
|
else
|
|
|
|
functions.rawlen = true
|
|
|
|
end
|
2011-09-19 14:42:54 +02:00
|
|
|
|
|
|
|
local manual, fun_ref
|
2011-06-19 17:52:02 +02:00
|
|
|
|
2011-09-19 14:42:54 +02:00
|
|
|
function globals.set_manual_url(url)
|
2012-03-13 09:37:07 +01:00
|
|
|
manual = url .. '#'
|
|
|
|
fun_ref = manual..'pdf-'
|
2011-09-19 14:42:54 +02:00
|
|
|
end
|
2012-03-13 09:37:07 +01:00
|
|
|
|
|
|
|
if lua52 then
|
|
|
|
globals.tables = {
|
|
|
|
io = '6.8',
|
|
|
|
package = '6.3',
|
|
|
|
math = '6.6',
|
|
|
|
os = '6.9',
|
|
|
|
string = '6.4',
|
|
|
|
table = '6.5',
|
|
|
|
coroutine = '6.2',
|
|
|
|
debug = '6.10'
|
|
|
|
}
|
|
|
|
globals.set_manual_url 'http://www.lua.org/manual/5.2/manual.html'
|
|
|
|
else
|
|
|
|
globals.tables = {
|
|
|
|
io = '5.7',
|
|
|
|
package = '5.3',
|
|
|
|
math = '5.6',
|
|
|
|
os = '5.8',
|
|
|
|
string = '5.4',
|
|
|
|
table = '5.5',
|
|
|
|
coroutine = '5.2',
|
|
|
|
debug = '5.9'
|
|
|
|
}
|
|
|
|
globals.set_manual_url 'http://www.lua.org/manual/5.1/manual.html'
|
|
|
|
end
|
|
|
|
|
|
|
|
local tables = globals.tables
|
2011-06-19 17:52:02 +02:00
|
|
|
|
|
|
|
local function function_ref (name)
|
2011-07-05 18:19:49 +02:00
|
|
|
return {href = fun_ref..name, label = name}
|
2011-06-19 17:52:02 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
local function module_ref (name)
|
2011-07-05 18:19:49 +02:00
|
|
|
return {href = manual..tables[name], label = name}
|
2011-06-19 17:52:02 +02:00
|
|
|
end
|
|
|
|
|
2011-09-19 14:42:54 +02:00
|
|
|
function globals.lua_manual_ref (name)
|
2011-06-19 17:52:02 +02:00
|
|
|
local tbl,fname = tools.split_dotted_name(name)
|
|
|
|
if not tbl then -- plain symbol
|
|
|
|
if functions[name] then
|
|
|
|
return function_ref(name)
|
|
|
|
end
|
|
|
|
if tables[name] then
|
|
|
|
return module_ref(name)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if tables[tbl] then
|
|
|
|
return function_ref(name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
|
2011-09-19 14:42:54 +02:00
|
|
|
return globals
|