aboutsummaryrefslogtreecommitdiff
path: root/manual
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-12-28 15:42:34 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-12-28 15:42:34 -0200
commit437a5b07d415e1a74160ddfd804017171d6cc5cb (patch)
tree861f9a56ae175eaed91c163409c33ab85bee7ff9 /manual
parentba7da13ec5938f978c37d63aa40a3e340b301f79 (diff)
downloadlua-437a5b07d415e1a74160ddfd804017171d6cc5cb.tar.gz
lua-437a5b07d415e1a74160ddfd804017171d6cc5cb.tar.bz2
lua-437a5b07d415e1a74160ddfd804017171d6cc5cb.zip
Added a warning system to Lua
The warning system is just a way for Lua to emit warnings, messages to the programmer that do not interfere with the running program.
Diffstat (limited to 'manual')
-rw-r--r--manual/manual.of56
1 files changed, 48 insertions, 8 deletions
diff --git a/manual/manual.of b/manual/manual.of
index 044bd09c..196ea1ef 100644
--- a/manual/manual.of
+++ b/manual/manual.of
@@ -1795,7 +1795,7 @@ Functions with any detectable difference
1795(different behavior, different definition) are always different. 1795(different behavior, different definition) are always different.
1796Functions created at different times but with no detectable differences 1796Functions created at different times but with no detectable differences
1797may be classified as equal or not 1797may be classified as equal or not
1798(depending on internal cashing details). 1798(depending on internal caching details).
1799 1799
1800You can change the way that Lua compares tables and userdata 1800You can change the way that Lua compares tables and userdata
1801by using the @idx{__eq} metamethod @see{metatable}. 1801by using the @idx{__eq} metamethod @see{metatable}.
@@ -4033,6 +4033,16 @@ for the @Q{newindex} event @see{metatable}.
4033 4033
4034} 4034}
4035 4035
4036@APIEntry{int lua_setiuservalue (lua_State *L, int index, int n);|
4037@apii{1,0,-}
4038
4039Pops a value from the stack and sets it as
4040the new @id{n}-th user value associated to the
4041full userdata at the given index.
4042Returns 0 if the userdata does not have that value.
4043
4044}
4045
4036@APIEntry{void lua_setmetatable (lua_State *L, int index);| 4046@APIEntry{void lua_setmetatable (lua_State *L, int index);|
4037@apii{1,0,-} 4047@apii{1,0,-}
4038 4048
@@ -4066,13 +4076,13 @@ If @id{index} @N{is 0}, then all stack elements are removed.
4066 4076
4067} 4077}
4068 4078
4069@APIEntry{int lua_setiuservalue (lua_State *L, int index, int n);| 4079@APIEntry{void lua_setwarnf (lua_State *L, lua_WarnFunction f, void *ud);|
4070@apii{1,0,-} 4080@apii{0,0,-}
4071 4081
4072Pops a value from the stack and sets it as 4082Sets the @x{warning function} to be used by Lua to emit warnings
4073the new @id{n}-th user value associated to the 4083@see{lua_WarnFunction}.
4074full userdata at the given index. 4084The @id{ud} parameter initializes the slot @id{pud} passed to
4075Returns 0 if the userdata does not have that value. 4085the warning function.
4076 4086
4077} 4087}
4078 4088
@@ -4335,6 +4345,30 @@ Returns the version number of this core.
4335} 4345}
4336 4346
4337@APIEntry{ 4347@APIEntry{
4348typedef void (*lua_WarnFunction) (void **pud, const char *msg);|
4349
4350The type of @x{warning function}s, called by Lua to emit warnings.
4351The first parameter is the address of a writable slot,
4352constant for a given Lua state and
4353initialized by @Lid{lua_setwarnf}.
4354The second parameter is the warning message.
4355This function should assume that
4356a message not ending with an end-of-line will be
4357continued by the message in the next call.
4358
4359}
4360
4361@APIEntry{
4362void lua_warning (lua_State *L, const char *msg);|
4363@apii{0,0,-}
4364
4365Emits a warning with the given message.
4366A message not ending with an end-of-line should be
4367continued in another call to this function.
4368
4369}
4370
4371@APIEntry{
4338typedef int (*lua_Writer) (lua_State *L, 4372typedef int (*lua_Writer) (lua_State *L,
4339 const void* p, 4373 const void* p,
4340 size_t sz, 4374 size_t sz,
@@ -4345,7 +4379,7 @@ Every time it produces another piece of chunk,
4345@Lid{lua_dump} calls the writer, 4379@Lid{lua_dump} calls the writer,
4346passing along the buffer to be written (@id{p}), 4380passing along the buffer to be written (@id{p}),
4347its size (@id{sz}), 4381its size (@id{sz}),
4348and the @id{data} parameter supplied to @Lid{lua_dump}. 4382and the @id{ud} parameter supplied to @Lid{lua_dump}.
4349 4383
4350The writer returns an error code: 4384The writer returns an error code:
4351@N{0 means} no errors; 4385@N{0 means} no errors;
@@ -6261,6 +6295,12 @@ The current value of this variable is @St{Lua 5.4}.
6261 6295
6262} 6296}
6263 6297
6298@LibEntry{warn (message)|
6299
6300Emits a warning with the given message.
6301
6302}
6303
6264@LibEntry{xpcall (f, msgh [, arg1, @Cdots])| 6304@LibEntry{xpcall (f, msgh [, arg1, @Cdots])|
6265 6305
6266This function is similar to @Lid{pcall}, 6306This function is similar to @Lid{pcall},