Skip to content

Commit 1de65ee

Browse files
hazzard993ark120202
authored andcommitted
style: wrap comments by 80 columns (#8)
1 parent 3601992 commit 1de65ee

20 files changed

+1288
-415
lines changed

core/coroutine.d.ts

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,53 @@
33
/** @noSelfInFile */
44

55
/**
6-
* This library comprises the operations to manipulate coroutines, which come inside the table coroutine.
6+
* This library comprises the operations to manipulate coroutines, which come
7+
* inside the table coroutine.
78
*/
89
declare namespace coroutine {
910
/**
10-
* Creates a new coroutine, with body f. f must be a function. Returns this new coroutine, an object with type "thread".
11+
* Creates a new coroutine, with body f. f must be a function. Returns this
12+
* new coroutine, an object with type "thread".
1113
*/
1214
function create(f: (...args: any[]) => any): LuaThread;
1315

1416
/**
15-
* Starts or continues the execution of coroutine co. The first time you resume a coroutine, it starts running its body. The values val1, ... are passed as the arguments to the body function. If the coroutine has yielded, resume restarts it; the values val1, ... are passed as the results from the yield.
17+
* Starts or continues the execution of coroutine co. The first time you
18+
* resume a coroutine, it starts running its body. The values val1, ... are
19+
* passed as the arguments to the body function. If the coroutine has yielded,
20+
* resume restarts it; the values val1, ... are passed as the results from the
21+
* yield.
1622
*
17-
* If the coroutine runs without any errors, resume returns true plus any values passed to yield (when the coroutine yields) or any values returned by the body function (when the coroutine terminates). If there is any error, resume returns false plus the error message.
23+
* If the coroutine runs without any errors, resume returns true plus any
24+
* values passed to yield (when the coroutine yields) or any values returned
25+
* by the body function (when the coroutine terminates). If there is any
26+
* error, resume returns false plus the error message.
1827
* @tupleReturn
1928
*/
2029
function resume(co: LuaThread, ...val: any[]): [true, ...any[]] | [false, string];
2130

2231
/**
23-
* Returns the status of coroutine co, as a string: "running", if the coroutine is running (that is, it called status); "suspended", if the coroutine is suspended in a call to yield, or if it has not started running yet; "normal" if the coroutine is active but not running (that is, it has resumed another coroutine); and "dead" if the coroutine has finished its body function, or if it has stopped with an error.
32+
* Returns the status of coroutine co, as a string: "running", if the
33+
* coroutine is running (that is, it called status); "suspended", if the
34+
* coroutine is suspended in a call to yield, or if it has not started running
35+
* yet; "normal" if the coroutine is active but not running (that is, it has
36+
* resumed another coroutine); and "dead" if the coroutine has finished its
37+
* body function, or if it has stopped with an error.
2438
*/
2539
function status(co: LuaThread): 'running' | 'suspended' | 'normal' | 'dead';
2640

2741
/**
28-
* Creates a new coroutine, with body f. f must be a function. Returns a function that resumes the coroutine each time it is called. Any arguments passed to the function behave as the extra arguments to resume. Returns the same values returned by resume, except the first boolean. In case of error, propagates the error.
42+
* Creates a new coroutine, with body f. f must be a function. Returns a
43+
* function that resumes the coroutine each time it is called. Any arguments
44+
* passed to the function behave as the extra arguments to resume. Returns the
45+
* same values returned by resume, except the first boolean. In case of error,
46+
* propagates the error.
2947
*/
3048
function wrap(f: (...args: any[]) => any): /** @tupleReturn */ (...args: any[]) => any[];
3149

3250
/**
33-
* Suspends the execution of the calling coroutine. Any arguments to yield are passed as extra results to resume.
51+
* Suspends the execution of the calling coroutine. Any arguments to yield are
52+
* passed as extra results to resume.
3453
* @tupleReturn
3554
*/
3655
function yield(...args: any[]): any[];

core/debug.d.ts

Lines changed: 81 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,35 @@
33
/** @noSelfInFile */
44

55
/**
6-
* This library provides the functionality of the debug interface (§4.9) to Lua programs. You should exert care when using this library. Several of its functions violate basic assumptions about Lua code (e.g., that variables local to a function cannot be accessed from outside; that userdata metatables cannot be changed by Lua code; that Lua programs do not crash) and therefore can compromise otherwise secure code. Moreover, some functions in this library may be slow.
6+
* This library provides the functionality of the debug interface (§4.9) to Lua
7+
* programs. You should exert care when using this library. Several of its
8+
* functions violate basic assumptions about Lua code (e.g., that variables
9+
* local to a function cannot be accessed from outside; that userdata metatables
10+
* cannot be changed by Lua code; that Lua programs do not crash) and therefore
11+
* can compromise otherwise secure code. Moreover, some functions in this
12+
* library may be slow.
713
*
8-
* All functions in this library are provided inside the debug table. All functions that operate over a thread have an optional first argument which is the thread to operate over. The default is always the current thread.
14+
* All functions in this library are provided inside the debug table. All
15+
* functions that operate over a thread have an optional first argument which is
16+
* the thread to operate over. The default is always the current thread.
917
*/
1018
declare namespace debug {
1119
/**
12-
* Enters an interactive mode with the user, running each string that the user enters. Using simple commands and other debug facilities, the user can inspect global and local variables, change their values, evaluate expressions, and so on. A line containing only the word cont finishes this function, so that the caller continues its execution.
20+
* Enters an interactive mode with the user, running each string that the user
21+
* enters. Using simple commands and other debug facilities, the user can
22+
* inspect global and local variables, change their values, evaluate
23+
* expressions, and so on. A line containing only the word cont finishes this
24+
* function, so that the caller continues its execution.
1325
*
14-
* Note that commands for debug.debug are not lexically nested within any function and so have no direct access to local variables.
26+
* Note that commands for debug.debug are not lexically nested within any
27+
* function and so have no direct access to local variables.
1528
*/
1629
function debug(): void;
1730

1831
/**
19-
* Returns the current hook settings of the thread, as three values: the current hook function, the current hook mask, and the current hook count (as set by the debug.sethook function).
32+
* Returns the current hook settings of the thread, as three values: the
33+
* current hook function, the current hook mask, and the current hook count
34+
* (as set by the debug.sethook function).
2035
* @tupleReturn
2136
*/
2237
function gethook(thread?: LuaThread): [undefined, 0] | [Function, number, string?];
@@ -32,13 +47,15 @@ declare namespace debug {
3247
*/
3348
name?: string;
3449
/**
35-
* What the `name` field means. The empty string means that Lua did not find a name for the function.
50+
* What the `name` field means. The empty string means that Lua did not find
51+
* a name for the function.
3652
*/
3753
namewhat: 'global' | 'local' | 'method' | 'field' | '';
3854

3955
source: string;
4056
/**
41-
* A short version of source (up to 60 characters), useful for error messages.
57+
* A short version of source (up to 60 characters), useful for error
58+
* messages.
4259
*/
4360
short_src: string;
4461
linedefined: number;
@@ -57,11 +74,25 @@ declare namespace debug {
5774
}
5875

5976
/**
60-
* Returns a table with information about a function. You can give the function directly or you can give a number as the value of f, which means the function running at level f of the call stack of the given thread: level 0 is the current function (getinfo itself); level 1 is the function that called getinfo (except for tail calls, which do not count on the stack); and so on. If f is a number larger than the number of active functions, then getinfo returns nil.
77+
* Returns a table with information about a function. You can give the
78+
* function directly or you can give a number as the value of f, which means
79+
* the function running at level f of the call stack of the given thread:
80+
* level 0 is the current function (getinfo itself); level 1 is the function
81+
* that called getinfo (except for tail calls, which do not count on the
82+
* stack); and so on. If f is a number larger than the number of active
83+
* functions, then getinfo returns nil.
6184
*
62-
* The returned table can contain all the fields returned by lua_getinfo, with the string what describing which fields to fill in. The default for what is to get all information available, except the table of valid lines. If present, the option 'f' adds a field named func with the function itself. If present, the option 'L' adds a field named activelines with the table of valid lines.
85+
* The returned table can contain all the fields returned by lua_getinfo, with
86+
* the string what describing which fields to fill in. The default for what is
87+
* to get all information available, except the table of valid lines. If
88+
* present, the option 'f' adds a field named func with the function itself.
89+
* If present, the option 'L' adds a field named activelines with the table of
90+
* valid lines.
6391
*
64-
* For instance, the expression debug.getinfo(1,"n").name returns a name for the current function, if a reasonable name can be found, and the expression debug.getinfo(print) returns a table with all available information about the print function.
92+
* For instance, the expression debug.getinfo(1,"n").name returns a name for
93+
* the current function, if a reasonable name can be found, and the expression
94+
* debug.getinfo(print) returns a table with all available information about
95+
* the print function.
6596
*/
6697
function getinfo<T extends Function>(f: T): FunctionInfo<T>;
6798
function getinfo<T extends Function>(f: T, what: string): Partial<FunctionInfo<T>>;
@@ -77,7 +108,8 @@ declare namespace debug {
77108
function getinfo(thread: LuaThread, f: number, what: string): Partial<FunctionInfo> | undefined;
78109

79110
/**
80-
* Returns the metatable of the given value or nil if it does not have a metatable.
111+
* Returns the metatable of the given value or nil if it does not have a
112+
* metatable.
81113
*/
82114
function getmetatable<T extends any>(value: T): LuaMetatable<T> | undefined;
83115

@@ -87,30 +119,43 @@ declare namespace debug {
87119
function getregistry(): Record<string, any>;
88120

89121
/**
90-
* This function returns the name and the value of the upvalue with index up of the function f. The function returns nil if there is no upvalue with the given index.
122+
* This function returns the name and the value of the upvalue with index up
123+
* of the function f. The function returns nil if there is no upvalue with the
124+
* given index.
91125
*
92-
* Variable names starting with '(' (open parenthesis) represent variables with no known names (variables from chunks saved without debug information).
126+
* Variable names starting with '(' (open parenthesis) represent variables
127+
* with no known names (variables from chunks saved without debug
128+
* information).
93129
* @tupleReturn
94130
*/
95131
function getupvalue(f: Function, up: number): [string, any] | [];
96132

97133
/**
98-
* Returns the Lua value associated to u. If u is not a full userdata, returns nil.
134+
* Returns the Lua value associated to u. If u is not a full userdata, returns
135+
* nil.
99136
*/
100137
function getuservalue(u: LuaUserdata): any;
101138

102139
/**
103-
* Sets the given function as a hook. The string mask and the number count describe when the hook will be called. The string mask may have any combination of the following characters, with the given meaning:
140+
* Sets the given function as a hook. The string mask and the number count
141+
* describe when the hook will be called. The string mask may have any
142+
* combination of the following characters, with the given meaning:
104143
*
105144
* * 'c': the hook is called every time Lua calls a function;
106145
* * 'r': the hook is called every time Lua returns from a function;
107146
* * 'l': the hook is called every time Lua enters a new line of code.
108147
*
109-
* Moreover, with a count different from zero, the hook is called also after every count instructions.
148+
* Moreover, with a count different from zero, the hook is called also after
149+
* every count instructions.
110150
*
111151
* When called without arguments, debug.sethook turns off the hook.
112152
*
113-
* When the hook is called, its first parameter is a string describing the event that has triggered its call: "call" (or "tail call"), "return", "line", and "count". For line events, the hook also gets the new line number as its second parameter. Inside a hook, you can call getinfo with level 2 to get more information about the running function (level 0 is the getinfo function, and level 1 is the hook function).
153+
* When the hook is called, its first parameter is a string describing the
154+
* event that has triggered its call: "call" (or "tail call"), "return",
155+
* "line", and "count". For line events, the hook also gets the new line
156+
* number as its second parameter. Inside a hook, you can call getinfo with
157+
* level 2 to get more information about the running function (level 0 is the
158+
* getinfo function, and level 1 is the hook function).
114159
*/
115160
function sethook(): void;
116161
function sethook(
@@ -126,7 +171,12 @@ declare namespace debug {
126171
): void;
127172

128173
/**
129-
* This function assigns the value value to the local variable with index local of the function at level level of the stack. The function returns nil if there is no local variable with the given index, and raises an error when called with a level out of range. (You can call getinfo to check whether the level is valid.) Otherwise, it returns the name of the local variable.
174+
* This function assigns the value value to the local variable with index
175+
* local of the function at level level of the stack. The function returns nil
176+
* if there is no local variable with the given index, and raises an error
177+
* when called with a level out of range. (You can call getinfo to check
178+
* whether the level is valid.) Otherwise, it returns the name of the local
179+
* variable.
130180
*
131181
* See debug.getlocal for more information about variable indices and names.
132182
*/
@@ -139,24 +189,33 @@ declare namespace debug {
139189
): string | undefined;
140190

141191
/**
142-
* Sets the metatable for the given value to the given table (which can be nil). Returns value.
192+
* Sets the metatable for the given value to the given table (which can be
193+
* nil). Returns value.
143194
*/
144195
function setmetatable<T>(value: T, table: LuaMetatable<T> | null | undefined): T;
145196

146197
/**
147-
* This function assigns the value value to the upvalue with index up of the function f. The function returns nil if there is no upvalue with the given index. Otherwise, it returns the name of the upvalue.
198+
* This function assigns the value value to the upvalue with index up of the
199+
* function f. The function returns nil if there is no upvalue with the given
200+
* index. Otherwise, it returns the name of the upvalue.
148201
*/
149202
function setupvalue(f: Function, up: number, value: any): string | undefined;
150203

151204
/**
152-
* Sets the given value as the Lua value associated to the given udata. udata must be a full userdata.
205+
* Sets the given value as the Lua value associated to the given udata. udata
206+
* must be a full userdata.
153207
*
154208
* Returns udata.
155209
*/
156210
function setuservalue(udata: LuaUserdata, value: any): LuaUserdata;
157211

158212
/**
159-
* If message is present but is neither a string nor nil, this function returns message without further processing. Otherwise, it returns a string with a traceback of the call stack. The optional message string is appended at the beginning of the traceback. An optional level number tells at which level to start the traceback (default is 1, the function calling traceback).
213+
* If message is present but is neither a string nor nil, this function
214+
* returns message without further processing. Otherwise, it returns a string
215+
* with a traceback of the call stack. The optional message string is appended
216+
* at the beginning of the traceback. An optional level number tells at which
217+
* level to start the traceback (default is 1, the function calling
218+
* traceback).
160219
*/
161220
function traceback(message?: string | null, level?: number | null): string;
162221
function traceback(thread?: LuaThread, message?: string | null, level?: number | null): string;

0 commit comments

Comments
 (0)