diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-12-19 14:40:17 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-12-19 14:40:17 -0200 |
commit | 4dc0be950ad67e4385400aacd25e10325a2a6e59 (patch) | |
tree | 9d201a8d3725f7130740bb574f7e19d8ad3c4d96 /lstate.h | |
parent | 3153a41e330a624fccfb7b9ade576767619b4a6b (diff) | |
download | lua-4dc0be950ad67e4385400aacd25e10325a2a6e59.tar.gz lua-4dc0be950ad67e4385400aacd25e10325a2a6e59.tar.bz2 lua-4dc0be950ad67e4385400aacd25e10325a2a6e59.zip |
new macro 'isLuacode' (to distinguish regular Lua code from
hooks, where C code can run inside a Lua function).
Diffstat (limited to 'lstate.h')
-rw-r--r-- | lstate.h | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.h,v 2.151 2017/11/13 15:36:52 roberto Exp roberto $ | 2 | ** $Id: lstate.h,v 2.152 2017/11/23 16:35:54 roberto Exp roberto $ |
3 | ** Global State | 3 | ** Global State |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -112,7 +112,7 @@ typedef struct CallInfo { | |||
112 | ** Bits in CallInfo status | 112 | ** Bits in CallInfo status |
113 | */ | 113 | */ |
114 | #define CIST_OAH (1<<0) /* original value of 'allowhook' */ | 114 | #define CIST_OAH (1<<0) /* original value of 'allowhook' */ |
115 | #define CIST_LUA (1<<1) /* call is running a Lua function */ | 115 | #define CIST_C (1<<1) /* call is running a C function */ |
116 | #define CIST_HOOKED (1<<2) /* call is running a debug hook */ | 116 | #define CIST_HOOKED (1<<2) /* call is running a debug hook */ |
117 | #define CIST_YPCALL (1<<3) /* call is a yieldable protected call */ | 117 | #define CIST_YPCALL (1<<3) /* call is a yieldable protected call */ |
118 | #define CIST_TAIL (1<<4) /* call was tail called */ | 118 | #define CIST_TAIL (1<<4) /* call was tail called */ |
@@ -120,7 +120,11 @@ typedef struct CallInfo { | |||
120 | #define CIST_LEQ (1<<6) /* using __lt for __le */ | 120 | #define CIST_LEQ (1<<6) /* using __lt for __le */ |
121 | #define CIST_FIN (1<<7) /* call is running a finalizer */ | 121 | #define CIST_FIN (1<<7) /* call is running a finalizer */ |
122 | 122 | ||
123 | #define isLua(ci) ((ci)->callstatus & CIST_LUA) | 123 | /* active function is a Lua function */ |
124 | #define isLua(ci) (!((ci)->callstatus & CIST_C)) | ||
125 | |||
126 | /* call is running Lua code (not a hook) */ | ||
127 | #define isLuacode(ci) (!((ci)->callstatus & (CIST_C | CIST_HOOKED))) | ||
124 | 128 | ||
125 | /* assume that CIST_OAH has offset 0 and that 'v' is strictly 0/1 */ | 129 | /* assume that CIST_OAH has offset 0 and that 'v' is strictly 0/1 */ |
126 | #define setoah(st,v) ((st) = ((st) & ~CIST_OAH) | (v)) | 130 | #define setoah(st,v) ((st) = ((st) & ~CIST_OAH) | (v)) |