diff options
author | Etiene <Etiene@users.noreply.github.com> | 2014-03-14 13:16:53 -0300 |
---|---|---|
committer | Etiene <Etiene@users.noreply.github.com> | 2014-03-14 13:16:53 -0300 |
commit | 5c541c55c1a16469ef7ed1c34de2511f6916c6a3 (patch) | |
tree | ece004c0799cfdfe6f1fa5d43eae3bdb0767b05f | |
parent | aedd49c245416c1682c26820d77c31a3d1b98d67 (diff) | |
parent | 99d5e856f9831d6e999141e75584caaaa89ef50a (diff) | |
download | valua-5c541c55c1a16469ef7ed1c34de2511f6916c6a3.tar.gz valua-5c541c55c1a16469ef7ed1c34de2511f6916c6a3.tar.bz2 valua-5c541c55c1a16469ef7ed1c34de2511f6916c6a3.zip |
Merge pull request #4 from Tieske/master0.2.2
pack/unpack with 5.2 compat
-rw-r--r-- | valua.lua | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -23,6 +23,8 @@ local valua = {} local tinsert,setmetatable,len,match,tonumber = table.insert,setmetatable,string.len,string.match,tonumber local next,type,floor,ipairs = next,type,math.floor, ipairs +local unpack = unpack or table.unpack +local pack = table.pack or function(...) return { n = select('#', ...), ... } end -- CORE -- Caution, this is confusing @@ -35,9 +37,8 @@ function valua:new(obj) self.__index = function(t,k) --saves a function named _<index> with its args in a funcs table, to be used later when validating return function(...) - local args = {...} - local n = select("#", ...) - local f = function(value) return valua['_'..k](value, unpack(args, 1, n)) end + local args = pack(...) + local f = function(value) return valua['_'..k](value, unpack(args, 1, args.n)) end tinsert(t.funcs,f) return t end |