summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-03 10:50:56 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-03 10:50:56 +0800
commit3120b0b63155821074ffac185acd1170cdf7029c (patch)
treed7e8d6c053009b61053dc94461ede3042314acee
parent1d3b6f8c0194c5da4f80793da1828c034c4daeef (diff)
downloadlua-language-server-3120b0b63155821074ffac185acd1170cdf7029c.zip
去掉ffi
-rw-r--r--server/src/ffi/sleep.lua8
-rw-r--r--server/src/ffi/unicode.lua49
-rw-r--r--server/src/service.lua4
3 files changed, 2 insertions, 59 deletions
diff --git a/server/src/ffi/sleep.lua b/server/src/ffi/sleep.lua
deleted file mode 100644
index 5c4be639..00000000
--- a/server/src/ffi/sleep.lua
+++ /dev/null
@@ -1,8 +0,0 @@
-local ffi = require 'ffi'
-ffi.cdef[[
- void Sleep(unsigned long dwMilliseconds);
-]]
-
-return function (time)
- ffi.C.Sleep(time)
-end
diff --git a/server/src/ffi/unicode.lua b/server/src/ffi/unicode.lua
deleted file mode 100644
index 734b4679..00000000
--- a/server/src/ffi/unicode.lua
+++ /dev/null
@@ -1,49 +0,0 @@
-local ffi = require 'ffi'
-ffi.cdef[[
- int MultiByteToWideChar(unsigned int CodePage, unsigned long dwFlags, const char* lpMultiByteStr, int cbMultiByte, wchar_t* lpWideCharStr, int cchWideChar);
- int WideCharToMultiByte(unsigned int CodePage, unsigned long dwFlags, const wchar_t* lpWideCharStr, int cchWideChar, char* lpMultiByteStr, int cchMultiByte, const char* lpDefaultChar, int* pfUsedDefaultChar);
-]]
-
-local CP_UTF8 = 65001
-local CP_ACP = 0
-
-local function u2w(input)
- local wlen = ffi.C.MultiByteToWideChar(CP_UTF8, 0, input, #input, nil, 0)
- local wstr = ffi.new('wchar_t[?]', wlen+1)
- ffi.C.MultiByteToWideChar(CP_UTF8, 0, input, #input, wstr, wlen)
- return wstr, wlen
-end
-
-local function a2w(input)
- local wlen = ffi.C.MultiByteToWideChar(CP_ACP, 0, input, #input, nil, 0)
- local wstr = ffi.new('wchar_t[?]', wlen+1)
- ffi.C.MultiByteToWideChar(CP_ACP, 0, input, #input, wstr, wlen)
- return wstr, wlen
-end
-
-local function w2u(wstr, wlen)
- local len = ffi.C.WideCharToMultiByte(CP_UTF8, 0, wstr, wlen, nil, 0, nil, nil)
- local str = ffi.new('char[?]', len+1)
- ffi.C.WideCharToMultiByte(CP_UTF8, 0, wstr, wlen, str, len, nil, nil)
- return ffi.string(str)
-end
-
-local function w2a(wstr, wlen)
- local len = ffi.C.WideCharToMultiByte(CP_ACP, 0, wstr, wlen, nil, 0, nil, nil)
- local str = ffi.new('char[?]', len)
- ffi.C.WideCharToMultiByte(CP_ACP, 0, wstr, wlen, str, len, nil, nil)
- return ffi.string(str)
-end
-
-return {
- u2w = u2w,
- a2w = a2w,
- w2u = w2u,
- w2a = w2a,
- u2a = function (input)
- return w2a(u2w(input))
- end,
- a2u = function (input)
- return w2u(a2w(input))
- end,
-}
diff --git a/server/src/service.lua b/server/src/service.lua
index 9f05ad1b..9376e15a 100644
--- a/server/src/service.lua
+++ b/server/src/service.lua
@@ -1,5 +1,5 @@
-local sleep = require 'ffi.sleep'
local subprocess = require 'bee.subprocess'
+local thread = require 'bee.thread'
local lsp = require 'lsp'
local Method = require 'method'
local fs = require 'bee.filesystem'
@@ -78,7 +78,7 @@ local function listen(self, input, output)
while true do
session:runStep()
- sleep(1)
+ thread.sleep(0.001)
end
end