From f1362652b7c45f05690369f2c9d3ef3d38ab2f7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 12 Nov 2020 17:42:10 +0800 Subject: =?UTF-8?q?=E6=9A=82=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- meta/template/builtin.lua | 1 - meta/template/debug.lua | 132 ++++++++++++++++++++++++++++++++++++++++++++-- meta/template/file.lua | 47 +++++++++++++++++ 3 files changed, 174 insertions(+), 6 deletions(-) create mode 100644 meta/template/file.lua (limited to 'meta') diff --git a/meta/template/builtin.lua b/meta/template/builtin.lua index 4f45b1ec..cd0080e2 100644 --- a/meta/template/builtin.lua +++ b/meta/template/builtin.lua @@ -9,7 +9,6 @@ ---#end ---@class thread: any ---@class table: any ----@class file: any ---@class string: any ---@class userdata: any ---@class lightuserdata: userdata diff --git a/meta/template/debug.lua b/meta/template/debug.lua index 8db01634..b957d948 100644 --- a/meta/template/debug.lua +++ b/meta/template/debug.lua @@ -1,6 +1,24 @@ ---@class debug debug = {} +---@class debuginfo +---@field name string +---@field namewhat string +---@field source string +---@field short_src string +---@field linedefined integer +---@field lastlinedefined integer +---@field what string +---@field currentline integer +---@field istailcall boolean +---@field nups integer +---@field nparams integer +---@field isvararg boolean +---@field func function +---@field ftransfer integer +---@field ntransfer integer +---@field activelines table + function debug.debug() end ---@param o any @@ -13,9 +31,113 @@ function debug.getfenv(o) end ---@return integer count function debug.gethook(co) end ----@alias infowhat '"nSltufL"' ----@alias finfo ----| '""' +---@alias infowhat string +---| '"n"' # `name` 和 `namewhat` +---| '"S"' # `source`,`short_src`,`linedefined`,`lastlinedefined`,和 `what` +---| '"l"' # `currentline` +---| '"t"' # `istailcall` +---| '"u"' # `nups`,`nparams` 和 `isvararg` +---| '"f"' # `func` +---| '"r"' # `ftransfer` 和 `ntransfer` +---| '"L"' # `activelines` + +---@overload fun(f: integer|function, what: infowhat?):debuginfo +---@param thread thread +---@param f integer|function +---@param what infowhat? +---@return debuginfo +function debug.getinfo(thread, f, what) end + +---@overload fun(f: integer|function, index: integer):string, any +---@param thread thread +---@param f integer|function +---@param index integer +---@return string name +---@return any value +function debug.getlocal(thread, f, index) end + +---@param object any +---@return table metatable +function debug.getmetatable(object) end + +---@return table +function debug.getregistry() end + +---@param f integer|function +---@param up integer +---@return string name +---@return any value +function debug.getupvalue(f, up) end + +---@param u userdata +---@param n integer +---@return any +---@return boolean +function debug.getuservalue(u, n) end + +---@deprecated +---@param limit integer +---@return integer|boolean +function debug.setcstacklimit(limit) end + +---@generic ANY +---@param object ANY +---@param env table +---@return ANY object +function debug.setfenv(object, env) end + +---@alias hookmask +---| '"c"' +---| '"r"' +---| '"l"' + +---@overload fun(hook: function, mask: hookmask, count: integer?) +---@param thread thread +---@param hook function +---@param mask hookmask +---@param count integer? +function debug.sethook(thread, hook, mask, count) end + +---@overload fun(level: integer, index: integer, value: any):string +---@param thread thread +---@param level integer +---@param index integer +---@param value any +---@return string name +function debug.setlocal(thread, level, index, value) end + +---@generic ANY +---@param value ANY +---@param meta table +---@return ANY value +function debug.setmetatable(value, meta) end + +---@param f function +---@param up integer +---@param value any +---@return string name +function debug.setupvalue(f, up, value) end + +---@generic USERDATA +---@param udata USERDATA +---@param value any +---@param n integer +---@return USERDATA udata +function debug.setuservalue(udata, value, n) end + +---@param thread thread +---@param message any? +---@param level integer? +---@return string message +function debug.traceback(thread, message, level) end + +---@param f function +---@param n integer +---@return lightuserdata id +function debug.upvalueid(f, n) end ----@overload fun(f: integer|function, what: infowhat?):finfo -function debug.getinfo1(thread, f, what) end +---@param f1 function +---@param n1 integer +---@param f2 function +---@param n2 integer +function debug.upvaluejoin(f1, n1, f2, n2) end diff --git a/meta/template/file.lua b/meta/template/file.lua new file mode 100644 index 00000000..8dd97cbc --- /dev/null +++ b/meta/template/file.lua @@ -0,0 +1,47 @@ +---@class file +local file = {} + +---@alias readmode number +---| '"n"' +---| '"a"' +---|>'"l"' +---| '"L"' + +---@return boolean suc? +---@return '"exit"'|'"signal"'? +---@return integer code? +function file:close() end + +function file:flush() end + +---@vararg readmode +---@return fun():string|number +function file:lines(...) end + +---@vararg readmode +---@return string|number +function file:read(...) end + +---@alias seekwhence +---| '"set"' +---|>'"cur"' +---| '"end"' + +---@param whence seekwhence? +---@param offset integer? +---@return integer offset +---@return string errmsg? +function file:seek(whence, offset) end + +---@alias vbuf +---| '"no"' +---| '"full"' +---| '"line"' +---@param mode vbuf +---@param size integer +function file:setvbuf(mode, size) end + +---@vararg string|number +---@return file? +---@return string errmsg? +function file:write(...) end -- cgit v1.2.3