From 4dc0be950ad67e4385400aacd25e10325a2a6e59 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 19 Dec 2017 14:40:17 -0200 Subject: new macro 'isLuacode' (to distinguish regular Lua code from hooks, where C code can run inside a Lua function). --- lstate.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lstate.h') diff --git a/lstate.h b/lstate.h index fad54634..bc4df4e5 100644 --- a/lstate.h +++ b/lstate.h @@ -1,5 +1,5 @@ /* -** $Id: lstate.h,v 2.151 2017/11/13 15:36:52 roberto Exp roberto $ +** $Id: lstate.h,v 2.152 2017/11/23 16:35:54 roberto Exp roberto $ ** Global State ** See Copyright Notice in lua.h */ @@ -112,7 +112,7 @@ typedef struct CallInfo { ** Bits in CallInfo status */ #define CIST_OAH (1<<0) /* original value of 'allowhook' */ -#define CIST_LUA (1<<1) /* call is running a Lua function */ +#define CIST_C (1<<1) /* call is running a C function */ #define CIST_HOOKED (1<<2) /* call is running a debug hook */ #define CIST_YPCALL (1<<3) /* call is a yieldable protected call */ #define CIST_TAIL (1<<4) /* call was tail called */ @@ -120,7 +120,11 @@ typedef struct CallInfo { #define CIST_LEQ (1<<6) /* using __lt for __le */ #define CIST_FIN (1<<7) /* call is running a finalizer */ -#define isLua(ci) ((ci)->callstatus & CIST_LUA) +/* active function is a Lua function */ +#define isLua(ci) (!((ci)->callstatus & CIST_C)) + +/* call is running Lua code (not a hook) */ +#define isLuacode(ci) (!((ci)->callstatus & (CIST_C | CIST_HOOKED))) /* assume that CIST_OAH has offset 0 and that 'v' is strictly 0/1 */ #define setoah(st,v) ((st) = ((st) & ~CIST_OAH) | (v)) -- cgit v1.2.3-55-g6feb