new interface for debug hooks

This commit is contained in:
Roberto Ierusalimschy
2002-07-08 15:21:33 -03:00
parent d2d24f0971
commit 39b2d58c39
10 changed files with 165 additions and 129 deletions

View File

@@ -1,5 +1,5 @@
/*
** $Id: luadebug.h,v 1.27 2002/04/04 17:21:31 roberto Exp roberto $
** $Id: luadebug.h,v 1.28 2002/06/18 17:10:43 roberto Exp roberto $
** Debugging API
** See Copyright Notice in lua.h
*/
@@ -11,6 +11,18 @@
#include "lua.h"
typedef enum lua_Hookevent {
LUA_HOOKCALL, LUA_HOOKRET, LUA_HOOKLINE, LUA_HOOKCOUNT
} lua_Hookevent;
#define LUA_MASKCALL (2 << LUA_HOOKCALL)
#define LUA_MASKRET (2 << LUA_HOOKRET)
#define LUA_MASKLINE (2 << LUA_HOOKLINE)
#define lua_maskcount(count) ((count) << (LUA_HOOKCOUNT+1))
#define lua_getmaskcount(mask) ((mask) >> (LUA_HOOKCOUNT+1))
#define LUA_MASKCOUNT (lua_maskcount(1))
typedef struct lua_Debug lua_Debug; /* activation record */
typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
@@ -21,14 +33,15 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);
LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n);
LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n);
LUA_API lua_Hook lua_setcallhook (lua_State *L, lua_Hook func);
LUA_API lua_Hook lua_setlinehook (lua_State *L, lua_Hook func);
LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask);
LUA_API lua_Hook lua_gethook (lua_State *L);
LUA_API int lua_gethookmask (lua_State *L);
#define LUA_IDSIZE 60
struct lua_Debug {
const char *event; /* `call', `return', `line' */
lua_Hookevent event;
const char *name; /* (n) */
const char *namewhat; /* (n) `global', `local', `field', `method' */
const char *what; /* (S) `Lua' function, `C' function, Lua `main' */