Mercurial > prosody-hg
comparison util/multitable.lua @ 6777:5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 21 Feb 2015 10:36:37 +0100 |
| parents | bd0ff8ae98a8 |
| children | 5687788a2e4d |
comparison
equal
deleted
inserted
replaced
| 6774:3965662ae091 | 6777:5de6b93d0190 |
|---|---|
| 8 | 8 |
| 9 local select = select; | 9 local select = select; |
| 10 local t_insert = table.insert; | 10 local t_insert = table.insert; |
| 11 local unpack, pairs, next, type = unpack, pairs, next, type; | 11 local unpack, pairs, next, type = unpack, pairs, next, type; |
| 12 | 12 |
| 13 module "multitable" | 13 local _ENV = nil; |
| 14 | 14 |
| 15 local function get(self, ...) | 15 local function get(self, ...) |
| 16 local t = self.data; | 16 local t = self.data; |
| 17 for n = 1,select('#', ...) do | 17 for n = 1,select('#', ...) do |
| 18 t = t[select(n, ...)]; | 18 t = t[select(n, ...)]; |
| 124 end | 124 end |
| 125 s(self.data, 1, results, _end, ...); | 125 s(self.data, 1, results, _end, ...); |
| 126 return results; | 126 return results; |
| 127 end | 127 end |
| 128 | 128 |
| 129 function iter(self, ...) | 129 local function iter(self, ...) |
| 130 local query = { ... }; | 130 local query = { ... }; |
| 131 local maxdepth = select("#", ...); | 131 local maxdepth = select("#", ...); |
| 132 local stack = { self.data }; | 132 local stack = { self.data }; |
| 133 local keys = { }; | 133 local keys = { }; |
| 134 local function it(self) | 134 local function it(self) |
| 159 return it(self); | 159 return it(self); |
| 160 end; | 160 end; |
| 161 return it, self; | 161 return it, self; |
| 162 end | 162 end |
| 163 | 163 |
| 164 function new() | 164 local function new() |
| 165 return { | 165 return { |
| 166 data = {}; | 166 data = {}; |
| 167 get = get; | 167 get = get; |
| 168 add = add; | 168 add = add; |
| 169 set = set; | 169 set = set; |
| 172 search_add = search_add; | 172 search_add = search_add; |
| 173 iter = iter; | 173 iter = iter; |
| 174 }; | 174 }; |
| 175 end | 175 end |
| 176 | 176 |
| 177 return _M; | 177 return { |
| 178 iter = iter; | |
| 179 new = new; | |
| 180 }; |
