Improved documentation for 'lua_getinfo'

This commit is contained in:
Roberto Ierusalimschy 2021-08-11 11:18:10 -03:00
parent 439e45a2f6
commit e2c07dcbf7
1 changed files with 24 additions and 18 deletions

View File

@ -4685,7 +4685,10 @@ information about a function or an activation record.
@Lid{lua_getstack} fills only the private part @Lid{lua_getstack} fills only the private part
of this structure, for later use. of this structure, for later use.
To fill the other fields of @Lid{lua_Debug} with useful information, To fill the other fields of @Lid{lua_Debug} with useful information,
you must call @Lid{lua_getinfo}. you must call @Lid{lua_getinfo} with an appropriate parameter.
(Specifically, to get a field,
you must add the letter between parentheses in the field's comment
to the parameter @id{what} of @Lid{lua_getinfo}.)
The fields of @Lid{lua_Debug} have the following meaning: The fields of @Lid{lua_Debug} have the following meaning:
@description{ @description{
@ -4838,10 +4841,24 @@ printf("%d\n", ar.linedefined);
Each character in the string @id{what} Each character in the string @id{what}
selects some fields of the structure @id{ar} to be filled or selects some fields of the structure @id{ar} to be filled or
a value to be pushed on the stack: a value to be pushed on the stack.
(These characters are also documented in the declaration of
the structure @Lid{lua_Debug},
between parentheses in the comments following each field.)
@description{ @description{
@item{@Char{n}| fills in the field @id{name} and @id{namewhat}; @item{@Char{f}|
pushes onto the stack the function that is
running at the given level;
}
@item{@Char{l}| fills in the field @id{currentline};
}
@item{@Char{n}| fills in the fields @id{name} and @id{namewhat};
}
@item{@Char{r}| fills in the fields @id{ftransfer} and @id{ntransfer};
} }
@item{@Char{S}| @item{@Char{S}|
@ -4849,9 +4866,6 @@ fills in the fields @id{source}, @id{short_src},
@id{linedefined}, @id{lastlinedefined}, and @id{what}; @id{linedefined}, @id{lastlinedefined}, and @id{what};
} }
@item{@Char{l}| fills in the field @id{currentline};
}
@item{@Char{t}| fills in the field @id{istailcall}; @item{@Char{t}| fills in the field @id{istailcall};
} }
@ -4859,21 +4873,13 @@ fills in the fields @id{source}, @id{short_src},
@id{nups}, @id{nparams}, and @id{isvararg}; @id{nups}, @id{nparams}, and @id{isvararg};
} }
@item{@Char{f}|
pushes onto the stack the function that is
running at the given level;
}
@item{@Char{L}| @item{@Char{L}|
pushes onto the stack a table whose indices are the pushes onto the stack a table whose indices are
numbers of the lines that are valid on the function. the lines on the function with some associated code,
(A @emph{valid line} is a line with some associated code, that is, the lines where you can put a break point.
that is, a line where you can put a break point. (Lines with no code include empty lines and comments.)
Non-valid lines include empty lines and comments.)
If this option is given together with option @Char{f}, If this option is given together with option @Char{f},
its table is pushed after the function. its table is pushed after the function.
This is the only option that can raise a memory error. This is the only option that can raise a memory error.
} }