From a3c090ce09c558aa84ec6a22a4478732ed6b962e Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 24 Oct 2021 09:35:12 -0700 Subject: get rid of LUAI_EXTRASPACE Lua's power may come from extensibility, but the indirections are currently in the way --- src/lstate.c | 6 +++--- src/luaconf.h | 9 --------- src/notes | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 src/notes diff --git a/src/lstate.c b/src/lstate.c index 4313b83..e9d8cae 100644 --- a/src/lstate.c +++ b/src/lstate.c @@ -24,9 +24,9 @@ #include "ltm.h" -#define state_size(x) (sizeof(x) + LUAI_EXTRASPACE) -#define fromstate(l) (cast(lu_byte *, (l)) - LUAI_EXTRASPACE) -#define tostate(l) (cast(lua_State *, cast(lu_byte *, l) + LUAI_EXTRASPACE)) +#define state_size(x) (sizeof(x)) +#define fromstate(l) (cast(lu_byte *, (l))) +#define tostate(l) (cast(lua_State *, cast(lu_byte *, l))) /* diff --git a/src/luaconf.h b/src/luaconf.h index bebefc4..f24ed0e 100644 --- a/src/luaconf.h +++ b/src/luaconf.h @@ -664,15 +664,6 @@ union luai_Cast { double l_d; long l_l; }; #endif -/* -@@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State -@* (the data goes just *before* the lua_State pointer). -** CHANGE (define) this if you really need that. This value must be -** a multiple of the maximum alignment required for your machine. -*/ -#define LUAI_EXTRASPACE 0 - - /* @@ luai_userstate* allow user-specific actions on threads. ** CHANGE them if you defined LUAI_EXTRASPACE and need to do something diff --git a/src/notes b/src/notes new file mode 100644 index 0000000..213bba7 --- /dev/null +++ b/src/notes @@ -0,0 +1,14 @@ +// Main thread combines a thread state and the global state +typedef struct LG { + lua_State l; + global_State g; +} LG; + +lua_State: + &{Value; int tt} stack, stack_last, base, top + +== todo stack +delete statesize/from_state/to_state +eradicate LUAI_EXTRASPACE +lua_newstate +lua_State's stack -- cgit 1.4.1-2-gfad0