mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Add configurable extra data at the end of lua_State
This commit is contained in:
parent
6958716ccd
commit
ed6491a087
3 changed files with 11 additions and 0 deletions
|
@ -126,3 +126,6 @@
|
|||
#define LUA_VECTOR_SIZE 3 /* must be 3 or 4 */
|
||||
|
||||
#define LUA_EXTRA_SIZE LUA_VECTOR_SIZE - 2
|
||||
|
||||
/* size of optional extra data in bytes added at the end of lua_State. */
|
||||
#define LUA_STATE_EXTRA 0
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
#include "ldo.h"
|
||||
#include "ldebug.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
** Main thread combines a thread state and the global state
|
||||
*/
|
||||
|
@ -78,6 +80,9 @@ static void preinit_state(lua_State* L, global_State* g)
|
|||
L->stackstate = 0;
|
||||
L->activememcat = 0;
|
||||
L->userdata = NULL;
|
||||
#if LUA_STATE_EXTRA > 0
|
||||
memset(L->extra, 0, LUA_STATE_EXTRA);
|
||||
#endif
|
||||
setnilvalue(gt(L));
|
||||
}
|
||||
|
||||
|
|
|
@ -237,6 +237,9 @@ struct lua_State
|
|||
TString* namecall; /* when invoked from Luau using NAMECALL, what method do we need to invoke? */
|
||||
|
||||
void* userdata;
|
||||
#if LUA_STATE_EXTRA > 0
|
||||
char extra[LUA_STATE_EXTRA];
|
||||
#endif
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue