summaryrefslogtreecommitdiff
path: root/server/src/json
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-06 18:07:10 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-06 18:07:10 +0800
commit979676be219b83c7295409824ee8280a3335cc5a (patch)
treee4928df884ddd961671d62876e84d2bec7c9ab19 /server/src/json
parentd119c1cefff8a6a2812ac10375297f033a8cf5f0 (diff)
downloadlua-language-server-979676be219b83c7295409824ee8280a3335cc5a.zip
枚举
Diffstat (limited to 'server/src/json')
-rw-r--r--server/src/json/init.lua1
-rw-r--r--server/src/json/table.lua62
2 files changed, 0 insertions, 63 deletions
diff --git a/server/src/json/init.lua b/server/src/json/init.lua
index db513678..c28e7aed 100644
--- a/server/src/json/init.lua
+++ b/server/src/json/init.lua
@@ -1,7 +1,6 @@
local api = {
decode = require 'json.decode',
encode = require 'json.encode',
- table = require 'json.table',
}
return api
diff --git a/server/src/json/table.lua b/server/src/json/table.lua
deleted file mode 100644
index 351bfe07..00000000
--- a/server/src/json/table.lua
+++ /dev/null
@@ -1,62 +0,0 @@
-
-local pairs = pairs
-local next = next
-local sort = table.sort
-local type = type
-local rawset = rawset
-local move = table.move
-local setmetatable = setmetatable
-
-local function sort_table(tbl)
- if not tbl then
- tbl = {}
- end
- local mt = {}
- local keys = {}
- local mark = {}
- local n = 0
- for key in next, tbl do
- n=n+1;keys[n] = key
- mark[key] = true
- end
- sort(keys)
- function mt:__newindex(key, value)
- rawset(self, key, value)
- n=n+1;keys[n] = key
- mark[key] = true
- if type(value) == 'table' then
- sort_table(value)
- end
- end
- function mt:__pairs()
- local list = {}
- local m = 0
- for key in next, self do
- if not mark[key] then
- m=m+1;list[m] = key
- end
- end
- if m > 0 then
- move(keys, 1, n, m+1)
- sort(list)
- for i = 1, m do
- local key = list[i]
- keys[i] = key
- mark[key] = true
- end
- n = n + m
- end
- local i = 0
- return function ()
- i = i + 1
- local key = keys[i]
- return key, self[key]
- end
- end
-
- return setmetatable(tbl, mt)
-end
-
-return function (tbl)
- return sort_table(tbl)
-end