From 6ed3868d92202ac3cec33907ddc21ed60bd033c0 Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Thu, 24 Jan 2013 14:05:23 +0000 Subject: class loading function in main module --- awall/init.lua | 15 +++++++-------- awall/model.lua | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/awall/init.lua b/awall/init.lua index a126872..80fdf7e 100644 --- a/awall/init.lua +++ b/awall/init.lua @@ -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]..')' diff --git a/awall/model.lua b/awall/model.lua index 5bd2811..452b148 100644 --- a/awall/model.lua +++ b/awall/model.lua @@ -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 -- cgit v1.2.3