- [NEW] Ara usa Lua 5.5.0

- [NEW] Lua ara es una llibreria estàtica, pa no compilarlo cada vegada (Linux, falta en Windows)
- [FIX] Arreglats mig kilo de warnings
- [FIX] include <mutex> per a lua.debug
This commit is contained in:
2026-05-04 12:38:52 +02:00
parent 5bd290c95d
commit fe39cd6c60
64 changed files with 1232 additions and 23665 deletions

View File

@@ -52,6 +52,8 @@ typedef union Value {
lua_CFunction f; /* light C functions */
lua_Integer i; /* integer numbers */
lua_Number n; /* float numbers */
/* not used, but may avoid warnings for uninitialized value */
lu_byte ub;
} Value;
@@ -68,7 +70,7 @@ typedef struct TValue {
#define val_(o) ((o)->value_)
#define valraw(o) (&val_(o))
#define valraw(o) (val_(o))
/* raw type tag of a TValue */
@@ -112,7 +114,7 @@ typedef struct TValue {
#define settt_(o,t) ((o)->tt_=(t))
/* main macro to copy values (from 'obj1' to 'obj2') */
/* main macro to copy values (from 'obj2' to 'obj1') */
#define setobj(L,obj1,obj2) \
{ TValue *io1=(obj1); const TValue *io2=(obj2); \
io1->value_ = io2->value_; settt_(io1, io2->tt_); \
@@ -155,6 +157,17 @@ typedef union StackValue {
/* index to stack elements */
typedef StackValue *StkId;
/*
** When reallocating the stack, change all pointers to the stack into
** proper offsets.
*/
typedef union {
StkId p; /* actual pointer */
ptrdiff_t offset; /* used while the stack is being reallocated */
} StkIdRel;
/* convert a 'StackValue' to a 'TValue' */
#define s2v(o) (&(o)->val)
@@ -175,10 +188,21 @@ typedef StackValue *StkId;
/* Value returned for a key not found in a table (absent key) */
#define LUA_VABSTKEY makevariant(LUA_TNIL, 2)
/* Special variant to signal that a fast get is accessing a non-table */
#define LUA_VNOTABLE makevariant(LUA_TNIL, 3)
/* macro to test for (any kind of) nil */
#define ttisnil(v) checktype((v), LUA_TNIL)
/*
** Macro to test the result of a table access. Formally, it should
** distinguish between LUA_VEMPTY/LUA_VABSTKEY/LUA_VNOTABLE and
** other tags. As currently nil is equivalent to LUA_VEMPTY, it is
** simpler to just test whether the value is nil.
*/
#define tagisempty(tag) (novariant(tag) == LUA_TNIL)
/* macro to test for a standard nil */
#define ttisstrictnil(o) checktag((o), LUA_VNIL)
@@ -232,6 +256,8 @@ typedef StackValue *StkId;
#define l_isfalse(o) (ttisfalse(o) || ttisnil(o))
#define tagisfalse(t) ((t) == LUA_VFALSE || novariant(t) == LUA_TNIL)
#define setbfvalue(obj) settt_(obj, LUA_VFALSE)
@@ -367,37 +393,54 @@ typedef struct GCObject {
#define setsvalue2n setsvalue
/* Kinds of long strings (stored in 'shrlen') */
#define LSTRREG -1 /* regular long string */
#define LSTRFIX -2 /* fixed external long string */
#define LSTRMEM -3 /* external long string with deallocation */
/*
** Header for a string value.
*/
typedef struct TString {
CommonHeader;
lu_byte extra; /* reserved words for short strings; "has hash" for longs */
lu_byte shrlen; /* length for short strings */
ls_byte shrlen; /* length for short strings, negative for long strings */
unsigned int hash;
union {
size_t lnglen; /* length for long strings */
struct TString *hnext; /* linked list for hash table */
} u;
char contents[1];
char *contents; /* pointer to content in long strings */
lua_Alloc falloc; /* deallocation function for external strings */
void *ud; /* user data for external strings */
} TString;
#define strisshr(ts) ((ts)->shrlen >= 0)
#define isextstr(ts) (ttislngstring(ts) && tsvalue(ts)->shrlen != LSTRREG)
/*
** Get the actual string (array of bytes) from a 'TString'.
** Get the actual string (array of bytes) from a 'TString'. (Generic
** version and specialized versions for long and short strings.)
*/
#define getstr(ts) ((ts)->contents)
#define rawgetshrstr(ts) (cast_charp(&(ts)->contents))
#define getshrstr(ts) check_exp(strisshr(ts), rawgetshrstr(ts))
#define getlngstr(ts) check_exp(!strisshr(ts), (ts)->contents)
#define getstr(ts) (strisshr(ts) ? rawgetshrstr(ts) : (ts)->contents)
/* get the actual string (array of bytes) from a Lua value */
#define svalue(o) getstr(tsvalue(o))
/* get string length from 'TString *ts' */
#define tsslen(ts) \
(strisshr(ts) ? cast_sizet((ts)->shrlen) : (ts)->u.lnglen)
/* get string length from 'TString *s' */
#define tsslen(s) ((s)->tt == LUA_VSHRSTR ? (s)->shrlen : (s)->u.lnglen)
/* get string length from 'TValue *o' */
#define vslen(o) tsslen(tsvalue(o))
/*
** Get string and length */
#define getlstr(ts, len) \
(strisshr(ts) \
? (cast_void((len) = cast_sizet((ts)->shrlen)), rawgetshrstr(ts)) \
: (cast_void((len) = (ts)->u.lnglen), (ts)->contents))
/* }================================================================== */
@@ -475,8 +518,8 @@ typedef struct Udata0 {
/* compute the offset of the memory area of a userdata */
#define udatamemoffset(nuv) \
((nuv) == 0 ? offsetof(Udata0, bindata) \
: offsetof(Udata, uv) + (sizeof(UValue) * (nuv)))
((nuv) == 0 ? offsetof(Udata0, bindata) \
: offsetof(Udata, uv) + (sizeof(UValue) * (nuv)))
/* get the address of the memory block inside 'Udata' */
#define getudatamem(u) (cast_charp(u) + udatamemoffset((u)->nuvalue))
@@ -496,6 +539,9 @@ typedef struct Udata0 {
#define LUA_VPROTO makevariant(LUA_TPROTO, 0)
typedef l_uint32 Instruction;
/*
** Description of an upvalue for function prototypes
*/
@@ -533,13 +579,30 @@ typedef struct AbsLineInfo {
int line;
} AbsLineInfo;
/*
** Flags in Prototypes
*/
#define PF_VAHID 1 /* function has hidden vararg arguments */
#define PF_VATAB 2 /* function has vararg table */
#define PF_FIXED 4 /* prototype has parts in fixed memory */
/* a vararg function either has hidden args. or a vararg table */
#define isvararg(p) ((p)->flag & (PF_VAHID | PF_VATAB))
/*
** mark that a function needs a vararg table. (The flag PF_VAHID will
** be cleared later.)
*/
#define needvatab(p) ((p)->flag |= PF_VATAB)
/*
** Function Prototypes
*/
typedef struct Proto {
CommonHeader;
lu_byte numparams; /* number of fixed (named) parameters */
lu_byte is_vararg;
lu_byte flag;
lu_byte maxstacksize; /* number of registers needed by this function */
int sizeupvalues; /* size of 'upvalues' */
int sizek; /* size of 'k' */
@@ -615,8 +678,10 @@ typedef struct Proto {
*/
typedef struct UpVal {
CommonHeader;
lu_byte tbc; /* true if it represents a to-be-closed variable */
TValue *v; /* points to stack or to its own value */
union {
TValue *p; /* points to stack or to its own value */
ptrdiff_t offset; /* used while the stack is being reallocated */
} v;
union {
struct { /* (when open) */
struct UpVal *next; /* linked list */
@@ -695,10 +760,9 @@ typedef union Node {
/* copy a value into a key */
#define setnodekey(L,node,obj) \
#define setnodekey(node,obj) \
{ Node *n_=(node); const TValue *io_=(obj); \
n_->u.key_val = io_->value_; n_->u.key_tt = io_->tt_; \
checkliveness(L,io_); }
n_->u.key_val = io_->value_; n_->u.key_tt = io_->tt_; }
/* copy a value from a key */
@@ -708,27 +772,14 @@ typedef union Node {
checkliveness(L,io_); }
/*
** About 'alimit': if 'isrealasize(t)' is true, then 'alimit' is the
** real size of 'array'. Otherwise, the real size of 'array' is the
** smallest power of two not smaller than 'alimit' (or zero iff 'alimit'
** is zero); 'alimit' is then used as a hint for #t.
*/
#define BITRAS (1 << 7)
#define isrealasize(t) (!((t)->flags & BITRAS))
#define setrealasize(t) ((t)->flags &= cast_byte(~BITRAS))
#define setnorealasize(t) ((t)->flags |= BITRAS)
typedef struct Table {
CommonHeader;
lu_byte flags; /* 1<<p means tagmethod(p) is not present */
lu_byte lsizenode; /* log2 of size of 'node' array */
unsigned int alimit; /* "limit" of 'array' array */
TValue *array; /* array part */
lu_byte lsizenode; /* log2 of number of slots of 'node' array */
unsigned int asize; /* number of slots in 'array' array */
Value *array; /* array part */
Node *node;
Node *lastfree; /* any free position is before this position */
struct Table *metatable;
GCObject *gclist;
} Table;
@@ -771,24 +822,37 @@ typedef struct Table {
** 'module' operation for hashing (size is always a power of 2)
*/
#define lmod(s,size) \
(check_exp((size&(size-1))==0, (cast_int((s) & ((size)-1)))))
(check_exp((size&(size-1))==0, (cast_uint(s) & cast_uint((size)-1))))
#define twoto(x) (1<<(x))
#define twoto(x) (1u<<(x))
#define sizenode(t) (twoto((t)->lsizenode))
/* size of buffer for 'luaO_utf8esc' function */
#define UTF8BUFFSZ 8
LUAI_FUNC int luaO_utf8esc (char *buff, unsigned long x);
LUAI_FUNC int luaO_ceillog2 (unsigned int x);
/* macro to call 'luaO_pushvfstring' correctly */
#define pushvfstring(L, argp, fmt, msg) \
{ va_start(argp, fmt); \
msg = luaO_pushvfstring(L, fmt, argp); \
va_end(argp); \
if (msg == NULL) luaD_throw(L, LUA_ERRMEM); /* only after 'va_end' */ }
LUAI_FUNC int luaO_utf8esc (char *buff, l_uint32 x);
LUAI_FUNC lu_byte luaO_ceillog2 (unsigned int x);
LUAI_FUNC lu_byte luaO_codeparam (unsigned int p);
LUAI_FUNC l_mem luaO_applyparam (lu_byte p, l_mem x);
LUAI_FUNC int luaO_rawarith (lua_State *L, int op, const TValue *p1,
const TValue *p2, TValue *res);
LUAI_FUNC void luaO_arith (lua_State *L, int op, const TValue *p1,
const TValue *p2, StkId res);
LUAI_FUNC size_t luaO_str2num (const char *s, TValue *o);
LUAI_FUNC int luaO_hexavalue (int c);
LUAI_FUNC unsigned luaO_tostringbuff (const TValue *obj, char *buff);
LUAI_FUNC lu_byte luaO_hexavalue (int c);
LUAI_FUNC void luaO_tostring (lua_State *L, TValue *obj);
LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt,
va_list argp);