diff options
author | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2013-01-24 14:05:23 +0000 |
---|---|---|
committer | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2013-01-24 14:05:23 +0000 |
commit | 6ed3868d92202ac3cec33907ddc21ed60bd033c0 (patch) | |
tree | 2111fdda7e0b2aa4b58a3ab8284837ff9858be35 | |
parent | 4a99b56ae4a9007a7067c6b2c2ecf2012c1322b6 (diff) | |
download | awall-6ed3868d92202ac3cec33907ddc21ed60bd033c0.tar.bz2 awall-6ed3868d92202ac3cec33907ddc21ed60bd033c0.tar.xz |
class loading function in main module
-rw-r--r-- | awall/init.lua | 15 | ||||
-rw-r--r-- | 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 |