summaryrefslogtreecommitdiffhomepage
path: root/libs/uvl/luasrc/uvl.lua
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2008-09-05 16:46:51 +0000
committerJo-Philipp Wich <jow@openwrt.org>2008-09-05 16:46:51 +0000
commit3315203f2f3e9ff5a76e788e9873e84e171ae876 (patch)
tree8649b2273e1a6402467e4925f962df20a66ae397 /libs/uvl/luasrc/uvl.lua
parent8af9060efd8f47966e898cd12e0515da3b097203 (diff)
* luci/libs/uvl:
- implement bytecode loading in luci.uvl.read_scheme() - add "uvlc" executable to byte-compile arbitary schemes - add lib/uci/schema/bytecode/ directory
Diffstat (limited to 'libs/uvl/luasrc/uvl.lua')
-rw-r--r--libs/uvl/luasrc/uvl.lua45
1 files changed, 28 insertions, 17 deletions
diff --git a/libs/uvl/luasrc/uvl.lua b/libs/uvl/luasrc/uvl.lua
index 680581d22..1b430af10 100644
--- a/libs/uvl/luasrc/uvl.lua
+++ b/libs/uvl/luasrc/uvl.lua
@@ -355,32 +355,43 @@ end
function UVL.read_scheme( self, scheme, alias )
local so = luci.uvl.scheme( self, scheme )
+ local bc = "%s/bytecode/%s.lua" %{ self.schemedir, scheme }
- local schemes = { }
- local files = luci.fs.glob(self.schemedir .. '/*/' .. scheme)
+ if not luci.fs.access(bc) then
+ local schemes = { }
+ local files = luci.fs.glob(self.schemedir .. '/*/' .. scheme)
- if files then
- for i, file in ipairs( files ) do
- if not luci.fs.access(file) then
- return so:error(ERR.SME_READ(so,file))
- end
+ if files then
+ for i, file in ipairs( files ) do
+ if not luci.fs.access(file) then
+ return false, so:error(ERR.SME_READ(so,file))
+ end
- local uci = luci.model.uci.cursor( luci.fs.dirname(file), default_savedir )
+ local uci = luci.model.uci.cursor( luci.fs.dirname(file), default_savedir )
- local sd, err = uci:get_all( luci.fs.basename(file) )
+ local sd, err = uci:get_all( luci.fs.basename(file) )
+
+ if not sd then
+ return false, ERR.UCILOAD(so, err)
+ end
- if not sd then
- return false, ERR.UCILOAD(so, err)
+ table.insert( schemes, sd )
end
- table.insert( schemes, sd )
+ local ok, err = self:_read_scheme_parts( so, schemes )
+ if ok and alias then self.packages[alias] = self.packages[scheme] end
+ return ok, err
+ else
+ return false, so:error(ERR.SME_FIND(so, self.schemedir))
end
-
- local ok, err = self:_read_scheme_parts( so, schemes )
- if ok and alias then self.packages[alias] = self.packages[scheme] end
- return ok, err
else
- return false, so:error(ERR.SME_FIND(so, self.schemedir))
+ local sc = loadfile(bc)
+ if sc then
+ self.packages[scheme] = sc()
+ return true
+ else
+ return false, so:error(ERR.SME_READ(so,file))
+ end
end
end