update docs to Lua 5.2/5.3
This commit is contained in:
parent
d7ffde62e9
commit
4fbb2aca79
|
@ -21,9 +21,9 @@ function assert(v , message) end
|
||||||
-- want to control the step size you must experimentally tune the value of
|
-- want to control the step size you must experimentally tune the value of
|
||||||
-- * "arg". Returns true if the step finished a collection cycle.
|
-- * "arg". Returns true if the step finished a collection cycle.
|
||||||
-- * "setpause": sets `arg` as the new value for the *pause* of the collector
|
-- * "setpause": sets `arg` as the new value for the *pause* of the collector
|
||||||
-- (see §2.10). Returns the previous value for *pause*.
|
-- (see 2.10). Returns the previous value for *pause*.
|
||||||
-- * "setstepmul": sets `arg` as the new value for the *step multiplier*
|
-- * "setstepmul": sets `arg` as the new value for the *step multiplier*
|
||||||
-- of the collector (see §2.10). Returns the previous value for *step*.
|
-- of the collector (see 2.10). Returns the previous value for *step*.
|
||||||
--
|
--
|
||||||
function collectgarbage(opt , arg) end
|
function collectgarbage(opt , arg) end
|
||||||
|
|
||||||
|
@ -54,14 +54,6 @@ function error(message , level) end
|
||||||
-- function _G end
|
-- function _G end
|
||||||
-- * `_G._G`: _G._G
|
-- * `_G._G`: _G._G
|
||||||
|
|
||||||
---
|
|
||||||
-- Returns the current environment in use by the function.
|
|
||||||
-- `f` can be a Lua function or a number that specifies the function at that
|
|
||||||
-- stack level: Level 1 is the function calling `getfenv`. If the given
|
|
||||||
-- function is not a Lua function, or if `f` is 0, `getfenv` returns the
|
|
||||||
-- global environment. The default for `f` is 1.
|
|
||||||
function getfenv(f) end
|
|
||||||
|
|
||||||
---
|
---
|
||||||
-- If `object` does not have a metatable, returns nil. Otherwise, if the
|
-- If `object` does not have a metatable, returns nil. Otherwise, if the
|
||||||
-- object's metatable has a `"__metatable"` field, returns the associated
|
-- object's metatable has a `"__metatable"` field, returns the associated
|
||||||
|
@ -77,27 +69,26 @@ function getmetatable(object) end
|
||||||
function ipairs(t) end
|
function ipairs(t) end
|
||||||
|
|
||||||
---
|
---
|
||||||
-- Loads a chunk using function `func` to get its pieces. Each call to
|
-- Loads a chunk.
|
||||||
-- `func` must return a string that concatenates with previous results. A
|
-- If `ld` is a string, the chunk is this string.
|
||||||
-- return of an empty string, nil, or no value signals the end of the chunk.
|
-- If `ld` is a function, load calls it repeatedly to get the chunk pieces. Each call to `ld` must return a
|
||||||
-- If there are no errors, returns the compiled chunk as a function; otherwise,
|
-- string that concatenates with previous results. A return of an empty string, nil, or no value
|
||||||
-- returns nil plus the error message. The environment of the returned function
|
-- signals the end of the chunk.
|
||||||
-- is the global environment.
|
-- If there are no syntactic errors, returns the compiled chunk as a function;
|
||||||
-- `chunkname` is used as the chunk name for error messages and debug
|
-- otherwise, returns nil plus the error message.
|
||||||
-- information. When absent, it defaults to "`=(load)`".
|
-- If the resulting function has upvalues, the first upvalue is set to the value of the global environment or to `env`,
|
||||||
function load(func , chunkname) end
|
-- if that parameter is given. When loading main chunks, the first upvalue will be the`_ENV` variable (see 2.2).
|
||||||
|
-- `source` is used as the source of the chunk for error messages and debug information (see 4.9).
|
||||||
|
-- When absent, it defaults to `ld`, if `ld` is a string, or to "=(load)" otherwise.
|
||||||
|
-- The string `mode` controls whether the chunk can be text or binary (that is, a precompiled chunk).
|
||||||
|
-- It may be the string "b" (only binary chunks), "t" (only text chunks), or "bt" (both binary and text).
|
||||||
|
-- The default is "bt"
|
||||||
|
function load (ld [, source [, mode [, env]]]) end
|
||||||
|
|
||||||
---
|
---
|
||||||
-- Similar to `load`, but gets the chunk from file `filename` or from the
|
-- Similar to `load`, but gets the chunk from file `filename` or from the
|
||||||
-- standard input, if no file name is given.
|
-- standard input, if no file name is given.
|
||||||
function loadfile(filename) end
|
function loadfile ([filename [, mode [, env]]]) end
|
||||||
|
|
||||||
---
|
|
||||||
-- Similar to `load`, but gets the chunk from the given string.
|
|
||||||
-- To load and run a given string, use the idiom
|
|
||||||
-- assert(loadstring(s))()
|
|
||||||
-- When absent, `chunkname` defaults to the given string.
|
|
||||||
function loadstring(string , chunkname) end
|
|
||||||
|
|
||||||
---
|
---
|
||||||
-- Allows a program to traverse all fields of a table. Its first argument is
|
-- Allows a program to traverse all fields of a table. Its first argument is
|
||||||
|
@ -168,14 +159,6 @@ function rawset(table, index, value) end
|
||||||
-- the total number of extra arguments it received.
|
-- the total number of extra arguments it received.
|
||||||
function select(index, ...) end
|
function select(index, ...) end
|
||||||
|
|
||||||
---
|
|
||||||
-- Sets the environment to be used by the given function. `f` can be a Lua
|
|
||||||
-- function or a number that specifies the function at that stack level: Level
|
|
||||||
-- 1 is the function calling `setfenv`. `setfenv` returns the given function.
|
|
||||||
-- As a special case, when `f` is 0 `setfenv` changes the environment of the
|
|
||||||
-- running thread. In this case, `setfenv` returns no values.
|
|
||||||
function setfenv(f, table) end
|
|
||||||
|
|
||||||
---
|
---
|
||||||
-- Sets the metatable for the given table. (You cannot change the metatable
|
-- Sets the metatable for the given table. (You cannot change the metatable
|
||||||
-- of other types from Lua, only from C.) If `metatable` is nil, removes the
|
-- of other types from Lua, only from C.) If `metatable` is nil, removes the
|
||||||
|
@ -193,8 +176,8 @@ function setmetatable(table, metatable) end
|
||||||
-- letter '`A`' (in either upper or lower case) represents 10, '`B`' represents
|
-- letter '`A`' (in either upper or lower case) represents 10, '`B`' represents
|
||||||
-- 11, and so forth, with '`Z`' representing 35. In base 10 (the default),
|
-- 11, and so forth, with '`Z`' representing 35. In base 10 (the default),
|
||||||
-- the number can have a decimal part, as well as an optional exponent part
|
-- the number can have a decimal part, as well as an optional exponent part
|
||||||
-- (see §2.1). In other bases, only unsigned integers are accepted.
|
-- (see 2.1). In other bases, only unsigned integers are accepted.
|
||||||
function tonumber(e , base) end
|
function tonumber(e [, base]) end
|
||||||
|
|
||||||
---
|
---
|
||||||
-- Receives an argument of any type and converts it to a string in a
|
-- Receives an argument of any type and converts it to a string in a
|
||||||
|
@ -212,14 +195,6 @@ function tostring(e) end
|
||||||
-- "`table`", "`function`", "`thread`", and "`userdata`".
|
-- "`table`", "`function`", "`thread`", and "`userdata`".
|
||||||
function type(v) end
|
function type(v) end
|
||||||
|
|
||||||
---
|
|
||||||
-- Returns the elements from the given table. This function is equivalent to
|
|
||||||
-- return list[i], list[i+1], ..., list[j]
|
|
||||||
-- except that the above code can be written only for a fixed number of
|
|
||||||
-- elements. By default, `i` is 1 and `j` is the length of the list, as
|
|
||||||
-- defined by the length operator (see §2.5.5).
|
|
||||||
function unpack(list , i , j) end
|
|
||||||
|
|
||||||
---
|
---
|
||||||
-- A global variable (not a function) that holds a string containing the
|
-- A global variable (not a function) that holds a string containing the
|
||||||
-- current interpreter version. The current contents of this variable is
|
-- current interpreter version. The current contents of this variable is
|
||||||
|
@ -239,24 +214,6 @@ function unpack(list , i , j) end
|
||||||
-- of any error, `xpcall` returns false plus the result from `err`.
|
-- of any error, `xpcall` returns false plus the result from `err`.
|
||||||
function xpcall(f, err) end
|
function xpcall(f, err) end
|
||||||
|
|
||||||
---
|
|
||||||
-- Creates a module. If there is a table in `package.loaded[name]`,
|
|
||||||
-- this table is the module. Otherwise, if there is a global table `t`
|
|
||||||
-- with the given name, this table is the module. Otherwise creates a new
|
|
||||||
-- table `t` and sets it as the value of the global `name` and the value of
|
|
||||||
-- `package.loaded[name]`. This function also initializes `t._NAME` with the
|
|
||||||
-- given name, `t._M` with the module (`t` itself), and `t._PACKAGE` with the
|
|
||||||
-- package name (the full module name minus last component; see below). Finally,
|
|
||||||
-- `module` sets `t` as the new environment of the current function and the
|
|
||||||
-- new value of `package.loaded[name]`, so that `require` returns `t`.
|
|
||||||
-- If `name` is a compound name (that is, one with components separated by
|
|
||||||
-- dots), `module` creates (or reuses, if they already exist) tables for each
|
|
||||||
-- component. For instance, if `name` is `a.b.c`, then `module` stores the
|
|
||||||
-- module table in field `c` of field `b` of global `a`.
|
|
||||||
-- This function can receive optional *options* after the module name, where
|
|
||||||
-- each option is a function to be applied over the module.
|
|
||||||
function module(name , ...) end
|
|
||||||
|
|
||||||
---
|
---
|
||||||
-- Loads the given module. The function starts by looking into the
|
-- Loads the given module. The function starts by looking into the
|
||||||
-- `package.loaded` table to determine whether `modname` is already
|
-- `package.loaded` table to determine whether `modname` is already
|
||||||
|
|
|
@ -171,5 +171,21 @@ function string.sub(s, i , j) end
|
||||||
-- definition of what a lowercase letter is depends on the current locale.
|
-- definition of what a lowercase letter is depends on the current locale.
|
||||||
function string.upper(s) end
|
function string.upper(s) end
|
||||||
|
|
||||||
|
---
|
||||||
|
-- (5.3) Returns a binary string containing the values v1, v2, etc. packed (that is, serialized in binary form)
|
||||||
|
--- according to the format string fmt (see 6.4.2).
|
||||||
|
function string.pack (fmt, v1, v2, ···) end
|
||||||
|
|
||||||
|
---
|
||||||
|
-- (5.3) Returns the size of a string resulting from string.pack with the given format.
|
||||||
|
-- The format string cannot have the variable-length options 's' or 'z' (see 6.4.2).
|
||||||
|
function string.packsize (fmt) end
|
||||||
|
|
||||||
|
---
|
||||||
|
-- (5.3) Returns the values packed in string s (see string.pack) according to the format string fmt (see 6.4.2).
|
||||||
|
-- An optional pos marks where to start reading in s (default is 1)
|
||||||
|
-- After the read values, this function also returns the index of the first unread byte in s.
|
||||||
|
function string.unpack (fmt, s [, pos]) end
|
||||||
|
|
||||||
return string
|
return string
|
||||||
|
|
||||||
|
|
|
@ -18,12 +18,6 @@ function table.concat(table , sep , i , j) end
|
||||||
-- `table.insert(t,x)` inserts `x` at the end of table `t`.
|
-- `table.insert(t,x)` inserts `x` at the end of table `t`.
|
||||||
function table.insert(table, pos, value) end
|
function table.insert(table, pos, value) end
|
||||||
|
|
||||||
---
|
|
||||||
-- Returns the largest positive numerical index of the given table, or
|
|
||||||
-- zero if the table has no positive numerical indices. (To do its job this
|
|
||||||
-- function does a linear traversal of the whole table.)
|
|
||||||
function table.maxn(table) end
|
|
||||||
|
|
||||||
---
|
---
|
||||||
-- Removes from `table` the element at position `pos`, shifting down other
|
-- Removes from `table` the element at position `pos`, shifting down other
|
||||||
-- elements to close the space, if necessary. Returns the value of the removed
|
-- elements to close the space, if necessary. Returns the value of the removed
|
||||||
|
@ -32,6 +26,10 @@ function table.maxn(table) end
|
||||||
-- `t`.
|
-- `t`.
|
||||||
function table.remove(table , pos) end
|
function table.remove(table , pos) end
|
||||||
|
|
||||||
|
---
|
||||||
|
-- Returns a new table with all parameters stored into keys 1, 2, etc. and with a field "n" with
|
||||||
|
-- the total number of parameters. Note that the resulting table may not be a sequence.
|
||||||
|
function table.pack (···) end
|
||||||
---
|
---
|
||||||
-- Sorts table elements in a given order,
|
-- Sorts table elements in a given order,
|
||||||
-- *in-place*, from `table[1]` to `table[n]`, where `n` is the length of the
|
-- *in-place*, from `table[1]` to `table[n]`, where `n` is the length of the
|
||||||
|
@ -41,4 +39,12 @@ function table.remove(table , pos) end
|
||||||
-- is not given, then the '<' operator will be used.
|
-- is not given, then the '<' operator will be used.
|
||||||
function table.sort(table , comp) end
|
function table.sort(table , comp) end
|
||||||
|
|
||||||
|
---
|
||||||
|
-- Returns the elements from the given table. This function is equivalent to
|
||||||
|
-- return list[i], list[i+1], ..., list[j]
|
||||||
|
-- except that the above code can be written only for a fixed number of
|
||||||
|
-- elements. By default, `i` is 1 and `j` is the length of the list, as
|
||||||
|
-- defined by the length operator (see §2.5.5).
|
||||||
|
function unpack(list , i , j) end
|
||||||
|
|
||||||
return table
|
return table
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
--- This library provides basic support for UTF-8 encoding.
|
||||||
|
-- @module utf8
|
||||||
|
|
||||||
|
local utf8 = {}
|
||||||
|
|
||||||
|
---
|
||||||
|
-- Receives zero or more integers, converts each one to its corresponding UTF-8 byte sequence and returns
|
||||||
|
-- a string with the concatenation of all these sequences.
|
||||||
|
function utf8.char (...) end
|
||||||
|
|
||||||
|
---
|
||||||
|
-- The pattern "[\0-\x7F\xC2-\xF4][\x80-\xBF]*" , which matches exactly one
|
||||||
|
-- UTF-8 byte sequence, assuming that the subject is a valid UTF-8 string.
|
||||||
|
-- @field charpattern
|
||||||
|
|
||||||
|
---
|
||||||
|
-- Iterate over all characters in string.
|
||||||
|
--
|
||||||
|
-- for p, c in utf8.codes(s) do body end
|
||||||
|
--
|
||||||
|
-- will iterate over all characters in string s, with p being the position (in bytes) and c the code point
|
||||||
|
-- of each character. It raises an error if it meets any invalid byte sequence.
|
||||||
|
function utf8.codes (s) end
|
||||||
|
|
||||||
|
---
|
||||||
|
-- Returns the codepoints (as integers) from all characters in s that start between byte position i and j (both included).
|
||||||
|
-- The default for i is 1 and for j is i. It raises an error if it meets any invalid byte sequence.
|
||||||
|
function utf8.codepoint (s [, i [, j]]) end
|
||||||
|
|
||||||
|
---
|
||||||
|
-- Returns the number of UTF-8 characters in string s that start between positions i and j (both inclusive).
|
||||||
|
-- The default for i is 1 and for j is -1. If it finds any invalid byte sequence, returns a false value plus
|
||||||
|
-- the position of the first invalid byte.
|
||||||
|
function utf8.len (s [, i [, j]]) end
|
||||||
|
|
||||||
|
---
|
||||||
|
-- Returns the position (in bytes) where the encoding of the n-th character of s (counting from position i) starts.
|
||||||
|
-- A negative n gets characters before position i. The default for i is 1 when n is non-negative
|
||||||
|
-- and #s + 1 otherwise, so that utf8.offset(s, -n) gets the offset of the n-th character from the end
|
||||||
|
-- of the string.
|
||||||
|
-- If the specified character is neither in the subject nor right after its end, the function returns nil.
|
||||||
|
--
|
||||||
|
-- As a special case, when n is 0 the function returns the start of the encoding of the character that contains the i-th byte of s.
|
||||||
|
--
|
||||||
|
-- This function assumes that s is a valid UTF-8 string.
|
||||||
|
function utf8.offset (s, n [, i]) end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue