get rid of LUAI_EXTRASPACE

Lua's power may come from extensibility, but the indirections are
currently in the way
This commit is contained in:
Kartik K. Agaram 2021-10-24 09:35:12 -07:00
parent c80bafed74
commit a3c090ce09
3 changed files with 17 additions and 12 deletions

View File

@ -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)))
/*

View File

@ -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

14
src/notes Normal file
View File

@ -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