aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
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 /lapi.c
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 '')
-rw-r--r--lapi.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/lapi.c b/lapi.c
index 2d10bb73..0f0166e5 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1267,6 +1267,24 @@ LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud) {
1267} 1267}
1268 1268
1269 1269
1270void lua_setwarnf (lua_State *L, lua_WarnFunction f, void *ud) {
1271 lua_lock(L);
1272 G(L)->ud_warn = ud;
1273 G(L)->warnf = f;
1274 lua_unlock(L);
1275}
1276
1277
1278void lua_warning (lua_State *L, const char *msg) {
1279 lua_WarnFunction wf = G(L)->warnf;
1280 lua_lock(L);
1281 if (wf != NULL)
1282 wf(&G(L)->ud_warn, msg);
1283 lua_unlock(L);
1284}
1285
1286
1287
1270LUA_API void *lua_newuserdatauv (lua_State *L, size_t size, int nuvalue) { 1288LUA_API void *lua_newuserdatauv (lua_State *L, size_t size, int nuvalue) {
1271 Udata *u; 1289 Udata *u;
1272 lua_lock(L); 1290 lua_lock(L);