Codebase list lua-ldoc / 4fbb2ac
update docs to Lua 5.2/5.3 steve donovan 7 years ago
4 changed file(s) with 96 addition(s) and 69 deletion(s). Raw diff Collapse all Expand all
2020 -- want to control the step size you must experimentally tune the value of
2121 -- * "arg". Returns true if the step finished a collection cycle.
2222 -- * "setpause": sets `arg` as the new value for the *pause* of the collector
23 -- (see §2.10). Returns the previous value for *pause*.
23 -- (see 2.10). Returns the previous value for *pause*.
2424 -- * "setstepmul": sets `arg` as the new value for the *step multiplier*
25 -- of the collector (see §2.10). Returns the previous value for *step*.
25 -- of the collector (see 2.10). Returns the previous value for *step*.
2626 --
2727 function collectgarbage(opt , arg) end
2828
5454 -- * `_G._G`: _G._G
5555
5656 ---
57 -- Returns the current environment in use by the function.
58 -- `f` can be a Lua function or a number that specifies the function at that
59 -- stack level: Level 1 is the function calling `getfenv`. If the given
60 -- function is not a Lua function, or if `f` is 0, `getfenv` returns the
61 -- global environment. The default for `f` is 1.
62 function getfenv(f) end
63
64 ---
6557 -- If `object` does not have a metatable, returns nil. Otherwise, if the
6658 -- object's metatable has a `"__metatable"` field, returns the associated
6759 -- value. Otherwise, returns the metatable of the given object.
7668 function ipairs(t) end
7769
7870 ---
79 -- Loads a chunk using function `func` to get its pieces. Each call to
80 -- `func` must return a string that concatenates with previous results. A
81 -- return of an empty string, nil, or no value signals the end of the chunk.
82 -- If there are no errors, returns the compiled chunk as a function; otherwise,
83 -- returns nil plus the error message. The environment of the returned function
84 -- is the global environment.
85 -- `chunkname` is used as the chunk name for error messages and debug
86 -- information. When absent, it defaults to "`=(load)`".
87 function load(func , chunkname) end
71 -- Loads a chunk.
72 -- If `ld` is a string, the chunk is this string.
73 -- If `ld` is a function, load calls it repeatedly to get the chunk pieces. Each call to `ld` must return a
74 -- string that concatenates with previous results. A return of an empty string, nil, or no value
75 -- signals the end of the chunk.
76 -- If there are no syntactic errors, returns the compiled chunk as a function;
77 -- otherwise, returns nil plus the error message.
78 -- If the resulting function has upvalues, the first upvalue is set to the value of the global environment or to `env`,
79 -- if that parameter is given. When loading main chunks, the first upvalue will be the`_ENV` variable (see 2.2).
80 -- `source` is used as the source of the chunk for error messages and debug information (see 4.9).
81 -- When absent, it defaults to `ld`, if `ld` is a string, or to "=(load)" otherwise.
82 -- The string `mode` controls whether the chunk can be text or binary (that is, a precompiled chunk).
83 -- It may be the string "b" (only binary chunks), "t" (only text chunks), or "bt" (both binary and text).
84 -- The default is "bt"
85 function load (ld [, source [, mode [, env]]]) end
8886
8987 ---
9088 -- Similar to `load`, but gets the chunk from file `filename` or from the
9189 -- standard input, if no file name is given.
92 function loadfile(filename) end
93
94 ---
95 -- Similar to `load`, but gets the chunk from the given string.
96 -- To load and run a given string, use the idiom
97 -- assert(loadstring(s))()
98 -- When absent, `chunkname` defaults to the given string.
99 function loadstring(string , chunkname) end
90 function loadfile ([filename [, mode [, env]]]) end
10091
10192 ---
10293 -- Allows a program to traverse all fields of a table. Its first argument is
166157 -- `index`. Otherwise, `index` must be the string `"#"`, and `select` returns
167158 -- the total number of extra arguments it received.
168159 function select(index, ...) end
169
170 ---
171 -- Sets the environment to be used by the given function. `f` can be a Lua
172 -- function or a number that specifies the function at that stack level: Level
173 -- 1 is the function calling `setfenv`. `setfenv` returns the given function.
174 -- As a special case, when `f` is 0 `setfenv` changes the environment of the
175 -- running thread. In this case, `setfenv` returns no values.
176 function setfenv(f, table) end
177160
178161 ---
179162 -- Sets the metatable for the given table. (You cannot change the metatable
192175 -- letter '`A`' (in either upper or lower case) represents 10, '`B`' represents
193176 -- 11, and so forth, with '`Z`' representing 35. In base 10 (the default),
194177 -- the number can have a decimal part, as well as an optional exponent part
195 -- (see §2.1). In other bases, only unsigned integers are accepted.
196 function tonumber(e , base) end
178 -- (see 2.1). In other bases, only unsigned integers are accepted.
179 function tonumber(e [, base]) end
197180
198181 ---
199182 -- Receives an argument of any type and converts it to a string in a
210193 -- `nil`" (a string, not the value nil), "`number`", "`string`", "`boolean`",
211194 -- "`table`", "`function`", "`thread`", and "`userdata`".
212195 function type(v) end
213
214 ---
215 -- Returns the elements from the given table. This function is equivalent to
216 -- return list[i], list[i+1], ..., list[j]
217 -- except that the above code can be written only for a fixed number of
218 -- elements. By default, `i` is 1 and `j` is the length of the list, as
219 -- defined by the length operator (see §2.5.5).
220 function unpack(list , i , j) end
221196
222197 ---
223198 -- A global variable (not a function) that holds a string containing the
237212 -- also returns all results from the call, after this first result. In case
238213 -- of any error, `xpcall` returns false plus the result from `err`.
239214 function xpcall(f, err) end
240
241 ---
242 -- Creates a module. If there is a table in `package.loaded[name]`,
243 -- this table is the module. Otherwise, if there is a global table `t`
244 -- with the given name, this table is the module. Otherwise creates a new
245 -- table `t` and sets it as the value of the global `name` and the value of
246 -- `package.loaded[name]`. This function also initializes `t._NAME` with the
247 -- given name, `t._M` with the module (`t` itself), and `t._PACKAGE` with the
248 -- package name (the full module name minus last component; see below). Finally,
249 -- `module` sets `t` as the new environment of the current function and the
250 -- new value of `package.loaded[name]`, so that `require` returns `t`.
251 -- If `name` is a compound name (that is, one with components separated by
252 -- dots), `module` creates (or reuses, if they already exist) tables for each
253 -- component. For instance, if `name` is `a.b.c`, then `module` stores the
254 -- module table in field `c` of field `b` of global `a`.
255 -- This function can receive optional *options* after the module name, where
256 -- each option is a function to be applied over the module.
257 function module(name , ...) end
258215
259216 ---
260217 -- Loads the given module. The function starts by looking into the
170170 -- definition of what a lowercase letter is depends on the current locale.
171171 function string.upper(s) end
172172
173 ---
174 -- (5.3) Returns a binary string containing the values v1, v2, etc. packed (that is, serialized in binary form)
175 --- according to the format string fmt (see 6.4.2).
176 function string.pack (fmt, v1, v2, ···) end
177
178 ---
179 -- (5.3) Returns the size of a string resulting from string.pack with the given format.
180 -- The format string cannot have the variable-length options 's' or 'z' (see 6.4.2).
181 function string.packsize (fmt) end
182
183 ---
184 -- (5.3) Returns the values packed in string s (see string.pack) according to the format string fmt (see 6.4.2).
185 -- An optional pos marks where to start reading in s (default is 1)
186 -- After the read values, this function also returns the index of the first unread byte in s.
187 function string.unpack (fmt, s [, pos]) end
188
173189 return string
174190
1818 function table.insert(table, pos, value) end
1919
2020 ---
21 -- Returns the largest positive numerical index of the given table, or
22 -- zero if the table has no positive numerical indices. (To do its job this
23 -- function does a linear traversal of the whole table.)
24 function table.maxn(table) end
25
26 ---
2721 -- Removes from `table` the element at position `pos`, shifting down other
2822 -- elements to close the space, if necessary. Returns the value of the removed
2923 -- element. The default value for `pos` is `n`, where `n` is the length of the
3125 -- `t`.
3226 function table.remove(table , pos) end
3327
28 ---
29 -- Returns a new table with all parameters stored into keys 1, 2, etc. and with a field "n" with
30 -- the total number of parameters. Note that the resulting table may not be a sequence.
31 function table.pack (···) end
3432 ---
3533 -- Sorts table elements in a given order,
3634 -- *in-place*, from `table[1]` to `table[n]`, where `n` is the length of the
4038 -- is not given, then the '<' operator will be used.
4139 function table.sort(table , comp) end
4240
41 ---
42 -- Returns the elements from the given table. This function is equivalent to
43 -- return list[i], list[i+1], ..., list[j]
44 -- except that the above code can be written only for a fixed number of
45 -- elements. By default, `i` is 1 and `j` is the length of the list, as
46 -- defined by the length operator (see §2.5.5).
47 function unpack(list , i , j) end
48
4349 return table
0 --- This library provides basic support for UTF-8 encoding.
1 -- @module utf8
2
3 local utf8 = {}
4
5 ---
6 -- Receives zero or more integers, converts each one to its corresponding UTF-8 byte sequence and returns
7 -- a string with the concatenation of all these sequences.
8 function utf8.char (...) end
9
10 ---
11 -- The pattern "[\0-\x7F\xC2-\xF4][\x80-\xBF]*" , which matches exactly one
12 -- UTF-8 byte sequence, assuming that the subject is a valid UTF-8 string.
13 -- @field charpattern
14
15 ---
16 -- Iterate over all characters in string.
17 --
18 -- for p, c in utf8.codes(s) do body end
19 --
20 -- will iterate over all characters in string s, with p being the position (in bytes) and c the code point
21 -- of each character. It raises an error if it meets any invalid byte sequence.
22 function utf8.codes (s) end
23
24 ---
25 -- Returns the codepoints (as integers) from all characters in s that start between byte position i and j (both included).
26 -- The default for i is 1 and for j is i. It raises an error if it meets any invalid byte sequence.
27 function utf8.codepoint (s [, i [, j]]) end
28
29 ---
30 -- Returns the number of UTF-8 characters in string s that start between positions i and j (both inclusive).
31 -- The default for i is 1 and for j is -1. If it finds any invalid byte sequence, returns a false value plus
32 -- the position of the first invalid byte.
33 function utf8.len (s [, i [, j]]) end
34
35 ---
36 -- Returns the position (in bytes) where the encoding of the n-th character of s (counting from position i) starts.
37 -- A negative n gets characters before position i. The default for i is 1 when n is non-negative
38 -- and #s + 1 otherwise, so that utf8.offset(s, -n) gets the offset of the n-th character from the end
39 -- of the string.
40 -- If the specified character is neither in the subject nor right after its end, the function returns nil.
41 --
42 -- 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.
43 --
44 -- This function assumes that s is a valid UTF-8 string.
45 function utf8.offset (s, n [, i]) end
46
47