From a508e59114168f89d48b16a9c9c1da9c14df7802 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 15 Mar 2021 19:35:58 +0800 Subject: `file` should be a part of `io` --- meta/template/file.lua | 69 -------------------------------------------------- meta/template/io.lua | 68 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 69 deletions(-) delete mode 100644 meta/template/file.lua diff --git a/meta/template/file.lua b/meta/template/file.lua deleted file mode 100644 index e6fa8447..00000000 --- a/meta/template/file.lua +++ /dev/null @@ -1,69 +0,0 @@ ----@meta - ----#DES 'file' ----@class file* -local file = {} - ----@alias readmode number ----#if VERSION >= 5.3 then ----| '"n"' # ---#DESTAIL 'readmode.n' ----| '"a"' # ---#DESTAIL 'readmode.a' ----|>'"l"' # ---#DESTAIL 'readmode.l' ----| '"L"' # ---#DESTAIL 'readmode.L' ----#else ----| '"*n"' # ---#DESTAIL 'readmode.n' ----| '"*a"' # ---#DESTAIL 'readmode.a' ----|>'"*l"' # ---#DESTAIL 'readmode.l' ----#if JIT then ----| '"*L"' # ---#DESTAIL 'readmode.L' ----#end ----#end - ----@alias exitcode '"exit"'|'"signal"' - ----#DES 'file:close' ----@return boolean? suc ----@return exitcode? exitcode ----@return integer? code -function file:close() end - ----#DES 'file:flush' -function file:flush() end - ----#DES 'file:lines' ----@vararg readmode ----@return fun():string|number -function file:lines(...) end - ----#DES 'file:read' ----@vararg readmode ----@return string|number -function file:read(...) end - ----@alias seekwhence ----| '"set"' # ---#DESTAIL 'seekwhence.set' ----|>'"cur"' # ---#DESTAIL 'seekwhence.cur' ----| '"end"' # ---#DESTAIL 'seekwhence.end' - ----#DES 'file:seek' ----@param whence? seekwhence ----@param offset? integer ----@return integer offset ----@return string? errmsg -function file:seek(whence, offset) end - ----@alias vbuf ----| '"no"' # ---#DESTAIL 'vbuf.no' ----| '"full"' # ---#DESTAIL 'vbuf.full' ----| '"line"' # ---#DESTAIL 'vbuf.line' - ----#DES 'file:setvbuf' ----@param mode vbuf ----@param size integer -function file:setvbuf(mode, size) end - ----#DES 'file:write' ----@vararg string|number ----@return file*? ----@return string? errmsg -function file:write(...) end diff --git a/meta/template/io.lua b/meta/template/io.lua index bc47f56d..d31027af 100644 --- a/meta/template/io.lua +++ b/meta/template/io.lua @@ -93,4 +93,72 @@ function io.type(file) end ---@return string? errmsg function io.write(...) end +---#DES 'file' +---@class file* +local file = {} + +---@alias readmode number +---#if VERSION >= 5.3 then +---| '"n"' # ---#DESTAIL 'readmode.n' +---| '"a"' # ---#DESTAIL 'readmode.a' +---|>'"l"' # ---#DESTAIL 'readmode.l' +---| '"L"' # ---#DESTAIL 'readmode.L' +---#else +---| '"*n"' # ---#DESTAIL 'readmode.n' +---| '"*a"' # ---#DESTAIL 'readmode.a' +---|>'"*l"' # ---#DESTAIL 'readmode.l' +---#if JIT then +---| '"*L"' # ---#DESTAIL 'readmode.L' +---#end +---#end + +---@alias exitcode '"exit"'|'"signal"' + +---#DES 'file:close' +---@return boolean? suc +---@return exitcode? exitcode +---@return integer? code +function file:close() end + +---#DES 'file:flush' +function file:flush() end + +---#DES 'file:lines' +---@vararg readmode +---@return fun():string|number +function file:lines(...) end + +---#DES 'file:read' +---@vararg readmode +---@return string|number +function file:read(...) end + +---@alias seekwhence +---| '"set"' # ---#DESTAIL 'seekwhence.set' +---|>'"cur"' # ---#DESTAIL 'seekwhence.cur' +---| '"end"' # ---#DESTAIL 'seekwhence.end' + +---#DES 'file:seek' +---@param whence? seekwhence +---@param offset? integer +---@return integer offset +---@return string? errmsg +function file:seek(whence, offset) end + +---@alias vbuf +---| '"no"' # ---#DESTAIL 'vbuf.no' +---| '"full"' # ---#DESTAIL 'vbuf.full' +---| '"line"' # ---#DESTAIL 'vbuf.line' + +---#DES 'file:setvbuf' +---@param mode vbuf +---@param size integer +function file:setvbuf(mode, size) end + +---#DES 'file:write' +---@vararg string|number +---@return file*? +---@return string? errmsg +function file:write(...) end + return io -- cgit v1.2.3