Commit 6ed3868d authored by Kaarle Ritvanen's avatar Kaarle Ritvanen

class loading function in main module

parent 4a99b56a
......@@ -27,16 +27,10 @@ local achains
function loadmodules(path)
events = {}
classmap = {}
achains = {}
local function readmetadata(mod)
for name, target in pairs(mod.export or {}) do
events[name] = target
if string.sub(name, 1, 1) ~= '%' then
classmap[name] = target.class
end
end
for name, target in pairs(mod.export or {}) do events[name] = target end
for name, opts in pairs(mod.achains or {}) do
assert(not achains[name])
achains[name] = opts
......@@ -67,6 +61,11 @@ function loadmodules(path)
procorder = awall.dependency.order(events)
end
function loadclass(path)
assert(string.sub(path, 1, 1) ~= '%')
return events[path] and events[path].class
end
PolicySet = policy.PolicySet
......@@ -103,7 +102,7 @@ function Config:init(policyconfig)
local objs = self.objects[path]
if objs then
for k, v in pairs(objs) do
objs[k] = classmap[path].morph(
objs[k] = events[path].class.morph(
v,
self,
path..' '..k..' ('..policyconfig.source[path][k]..')'
......
......@@ -35,7 +35,7 @@ end
function ConfigObject:create(cls, params)
if type(cls) == 'string' then
local name = cls
cls = awall.classmap[cls]
cls = awall.loadclass(cls)
if not cls then
self:error('Support for '..name..' objects not installed')
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment