docs: add static getters for wrapped variables

This commit is contained in:
Daniel Kolesa 2016-08-15 14:41:59 +01:00
parent f43b8e24cc
commit c98df1c586
2 changed files with 52 additions and 2 deletions

View File

@ -559,6 +559,56 @@ M.Variable = Node:clone {
nspaces_get = function(self, root)
return M.Node.nspaces_get(self, self:type_str_get(), root)
end,
-- static getters
all_globals_get = function()
local ret = {}
for v in eolian.variable_all_globals_get() do
ret[#ret + 1] = v
end
return ret
end,
all_constants_get = function()
local ret = {}
for v in eolian.variable_all_constants_get() do
ret[#ret + 1] = v
end
return ret
end,
globals_by_file_get = function(fn)
local ret = {}
for v in eolian.variable_globals_get_by_file(fn) do
ret[#ret + 1] = v
end
return ret
end,
constants_by_file_get = function(fn)
local ret = {}
for v in eolian.variable_constants_get_by_file(fn) do
ret[#ret + 1] = v
end
return ret
end,
global_by_name_get = function(vn)
local v = eolian.variable_global_get_by_name(vn)
if not v then
return nil
end
return M.Variable(v)
end,
constant_by_name_get = function(vn)
local v = eolian.variable_constant_get_by_name(vn)
if not v then
return nil
end
return M.Variable(v)
end
}

View File

@ -847,11 +847,11 @@ local build_typedecls = function()
end
local build_variables = function()
for v in eolian.variable_all_constants_get() do
for i, v in ipairs(dtree.Variable.all_constants_get()) do
build_variable(v, true)
end
for v in eolian.variable_all_globals_get() do
for i, v in ipairs(dtree.Variable.all_globals_get()) do
build_variable(v, false)
end
end