Skip to content

Commit 5b8aac7

Browse files
committed
upgraded to lua 5.4
1 parent 62807e5 commit 5b8aac7

File tree

11 files changed

+211
-216
lines changed

11 files changed

+211
-216
lines changed

emulator/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ objects := $(patsubst %.cpp, obj/%.o, $(notdir $(sources)))
1414
_dummy := $(shell mkdir -p obj)
1515

1616
all: $(objects)
17-
g++ -L ./lib $(objects) -static-libgcc -static-libstdc++ -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -llua53 -lreadline -lhistory -ltermcap -Wl,-Bstatic -lstdc++ -lpthread -o casioemu.exe
17+
g++ -L ./lib $(objects) -static-libgcc -static-libstdc++ -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -llua54 -lreadline -lhistory -ltermcap -Wl,-Bstatic -lstdc++ -lpthread -o casioemu.exe
1818

1919
obj/%.o: %.cpp
2020
g++ -O2 -std=c++14 -Wall -Wextra -Werror -pedantic -I ./include -c $< -o $@

emulator/include/lauxlib.h

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** $Id: lauxlib.h,v 1.131.1.1 2017/04/19 17:20:42 roberto Exp $
2+
** $Id: lauxlib.h $
33
** Auxiliary functions for building Lua libraries
44
** See Copyright Notice in lua.h
55
*/
@@ -15,6 +15,12 @@
1515
#include "lua.h"
1616

1717

18+
/* global table */
19+
#define LUA_GNAME "_G"
20+
21+
22+
typedef struct luaL_Buffer luaL_Buffer;
23+
1824

1925
/* extra error code for 'luaL_loadfilex' */
2026
#define LUA_ERRFILE (LUA_ERRERR+1)
@@ -44,6 +50,7 @@ LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e);
4450
LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e);
4551
LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len);
4652
LUALIB_API int (luaL_argerror) (lua_State *L, int arg, const char *extramsg);
53+
LUALIB_API int (luaL_typeerror) (lua_State *L, int arg, const char *tname);
4754
LUALIB_API const char *(luaL_checklstring) (lua_State *L, int arg,
4855
size_t *l);
4956
LUALIB_API const char *(luaL_optlstring) (lua_State *L, int arg,
@@ -73,6 +80,7 @@ LUALIB_API int (luaL_checkoption) (lua_State *L, int arg, const char *def,
7380
LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname);
7481
LUALIB_API int (luaL_execresult) (lua_State *L, int stat);
7582

83+
7684
/* predefined references */
7785
#define LUA_NOREF (-2)
7886
#define LUA_REFNIL (-1)
@@ -93,8 +101,10 @@ LUALIB_API lua_State *(luaL_newstate) (void);
93101

94102
LUALIB_API lua_Integer (luaL_len) (lua_State *L, int idx);
95103

96-
LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p,
97-
const char *r);
104+
LUALIB_API void luaL_addgsub (luaL_Buffer *b, const char *s,
105+
const char *p, const char *r);
106+
LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s,
107+
const char *p, const char *r);
98108

99109
LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup);
100110

@@ -121,6 +131,10 @@ LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname,
121131

122132
#define luaL_argcheck(L, cond,arg,extramsg) \
123133
((void)((cond) || luaL_argerror(L, (arg), (extramsg))))
134+
135+
#define luaL_argexpected(L,cond,arg,tname) \
136+
((void)((cond) || luaL_typeerror(L, (arg), (tname))))
137+
124138
#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL))
125139
#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL))
126140

@@ -139,19 +153,30 @@ LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname,
139153
#define luaL_loadbuffer(L,s,sz,n) luaL_loadbufferx(L,s,sz,n,NULL)
140154

141155

156+
/* push the value used to represent failure/error */
157+
#define luaL_pushfail(L) lua_pushnil(L)
158+
159+
142160
/*
143161
** {======================================================
144162
** Generic Buffer manipulation
145163
** =======================================================
146164
*/
147165

148-
typedef struct luaL_Buffer {
166+
struct luaL_Buffer {
149167
char *b; /* buffer address */
150168
size_t size; /* buffer size */
151169
size_t n; /* number of characters in buffer */
152170
lua_State *L;
153-
char initb[LUAL_BUFFERSIZE]; /* initial buffer */
154-
} luaL_Buffer;
171+
union {
172+
LUAI_MAXALIGN; /* ensure maximum alignment for buffer */
173+
char b[LUAL_BUFFERSIZE]; /* initial buffer */
174+
} init;
175+
};
176+
177+
178+
#define luaL_bufflen(bf) ((bf)->n)
179+
#define luaL_buffaddr(bf) ((bf)->b)
155180

156181

157182
#define luaL_addchar(B,c) \
@@ -160,6 +185,8 @@ typedef struct luaL_Buffer {
160185

161186
#define luaL_addsize(B,s) ((B)->n += (s))
162187

188+
#define luaL_buffsub(B,s) ((B)->n -= (s))
189+
163190
LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B);
164191
LUALIB_API char *(luaL_prepbuffsize) (luaL_Buffer *B, size_t sz);
165192
LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l);
@@ -197,21 +224,6 @@ typedef struct luaL_Stream {
197224

198225
/* }====================================================== */
199226

200-
201-
202-
/* compatibility with old module system */
203-
#if defined(LUA_COMPAT_MODULE)
204-
205-
LUALIB_API void (luaL_pushmodule) (lua_State *L, const char *modname,
206-
int sizehint);
207-
LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname,
208-
const luaL_Reg *l, int nup);
209-
210-
#define luaL_register(L,n,l) (luaL_openlib(L,(n),(l),0))
211-
212-
#endif
213-
214-
215227
/*
216228
** {==================================================================
217229
** "Abstraction Layer" for basic report of messages and errors

emulator/include/lua.h

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/*
2+
** $Id: lua.h $
23
** Lua - A Scripting Language
34
** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
45
** See Copyright Notice at the end of this file
@@ -16,9 +17,11 @@
1617

1718

1819
#define LUA_VERSION_MAJOR "5"
19-
#define LUA_VERSION_MINOR "3"
20-
#define LUA_VERSION_NUM 503
21-
#define LUA_VERSION_RELEASE "6"
20+
#define LUA_VERSION_MINOR "4"
21+
#define LUA_VERSION_RELEASE "2"
22+
23+
#define LUA_VERSION_NUM 504
24+
#define LUA_VERSION_RELEASE_NUM (LUA_VERSION_NUM * 100 + 0)
2225

2326
#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
2427
#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE
@@ -48,8 +51,7 @@
4851
#define LUA_ERRRUN 2
4952
#define LUA_ERRSYNTAX 3
5053
#define LUA_ERRMEM 4
51-
#define LUA_ERRGCMM 5
52-
#define LUA_ERRERR 6
54+
#define LUA_ERRERR 5
5355

5456

5557
typedef struct lua_State lua_State;
@@ -70,7 +72,7 @@ typedef struct lua_State lua_State;
7072
#define LUA_TUSERDATA 7
7173
#define LUA_TTHREAD 8
7274

73-
#define LUA_NUMTAGS 9
75+
#define LUA_NUMTYPES 9
7476

7577

7678

@@ -123,6 +125,13 @@ typedef int (*lua_Writer) (lua_State *L, const void *p, size_t sz, void *ud);
123125
typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
124126

125127

128+
/*
129+
** Type for warning functions
130+
*/
131+
typedef void (*lua_WarnFunction) (void *ud, const char *msg, int tocont);
132+
133+
134+
126135

127136
/*
128137
** generic extra include file
@@ -144,11 +153,12 @@ extern const char lua_ident[];
144153
LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);
145154
LUA_API void (lua_close) (lua_State *L);
146155
LUA_API lua_State *(lua_newthread) (lua_State *L);
156+
LUA_API int (lua_resetthread) (lua_State *L);
147157

148158
LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);
149159

150160

151-
LUA_API const lua_Number *(lua_version) (lua_State *L);
161+
LUA_API lua_Number (lua_version) (lua_State *L);
152162

153163

154164
/*
@@ -181,7 +191,7 @@ LUA_API lua_Number (lua_tonumberx) (lua_State *L, int idx, int *isnum);
181191
LUA_API lua_Integer (lua_tointegerx) (lua_State *L, int idx, int *isnum);
182192
LUA_API int (lua_toboolean) (lua_State *L, int idx);
183193
LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len);
184-
LUA_API size_t (lua_rawlen) (lua_State *L, int idx);
194+
LUA_API lua_Unsigned (lua_rawlen) (lua_State *L, int idx);
185195
LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx);
186196
LUA_API void *(lua_touserdata) (lua_State *L, int idx);
187197
LUA_API lua_State *(lua_tothread) (lua_State *L, int idx);
@@ -246,9 +256,9 @@ LUA_API int (lua_rawgeti) (lua_State *L, int idx, lua_Integer n);
246256
LUA_API int (lua_rawgetp) (lua_State *L, int idx, const void *p);
247257

248258
LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec);
249-
LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz);
259+
LUA_API void *(lua_newuserdatauv) (lua_State *L, size_t sz, int nuvalue);
250260
LUA_API int (lua_getmetatable) (lua_State *L, int objindex);
251-
LUA_API int (lua_getuservalue) (lua_State *L, int idx);
261+
LUA_API int (lua_getiuservalue) (lua_State *L, int idx, int n);
252262

253263

254264
/*
@@ -262,7 +272,7 @@ LUA_API void (lua_rawset) (lua_State *L, int idx);
262272
LUA_API void (lua_rawseti) (lua_State *L, int idx, lua_Integer n);
263273
LUA_API void (lua_rawsetp) (lua_State *L, int idx, const void *p);
264274
LUA_API int (lua_setmetatable) (lua_State *L, int objindex);
265-
LUA_API void (lua_setuservalue) (lua_State *L, int idx);
275+
LUA_API int (lua_setiuservalue) (lua_State *L, int idx, int n);
266276

267277

268278
/*
@@ -287,13 +297,21 @@ LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data, int strip);
287297
*/
288298
LUA_API int (lua_yieldk) (lua_State *L, int nresults, lua_KContext ctx,
289299
lua_KFunction k);
290-
LUA_API int (lua_resume) (lua_State *L, lua_State *from, int narg);
300+
LUA_API int (lua_resume) (lua_State *L, lua_State *from, int narg,
301+
int *nres);
291302
LUA_API int (lua_status) (lua_State *L);
292303
LUA_API int (lua_isyieldable) (lua_State *L);
293304

294305
#define lua_yield(L,n) lua_yieldk(L, (n), 0, NULL)
295306

296307

308+
/*
309+
** Warning-related functions
310+
*/
311+
LUA_API void (lua_setwarnf) (lua_State *L, lua_WarnFunction f, void *ud);
312+
LUA_API void (lua_warning) (lua_State *L, const char *msg, int tocont);
313+
314+
297315
/*
298316
** garbage-collection function and options
299317
*/
@@ -307,8 +325,10 @@ LUA_API int (lua_isyieldable) (lua_State *L);
307325
#define LUA_GCSETPAUSE 6
308326
#define LUA_GCSETSTEPMUL 7
309327
#define LUA_GCISRUNNING 9
328+
#define LUA_GCGEN 10
329+
#define LUA_GCINC 11
310330

311-
LUA_API int (lua_gc) (lua_State *L, int what, int data);
331+
LUA_API int (lua_gc) (lua_State *L, int what, ...);
312332

313333

314334
/*
@@ -327,6 +347,7 @@ LUA_API size_t (lua_stringtonumber) (lua_State *L, const char *s);
327347
LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud);
328348
LUA_API void (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud);
329349

350+
LUA_API void (lua_toclose) (lua_State *L, int idx);
330351

331352

332353
/*
@@ -376,7 +397,7 @@ LUA_API void (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud);
376397

377398
/*
378399
** {==============================================================
379-
** compatibility macros for unsigned conversions
400+
** compatibility macros
380401
** ===============================================================
381402
*/
382403
#if defined(LUA_COMPAT_APIINTCASTS)
@@ -386,6 +407,13 @@ LUA_API void (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud);
386407
#define lua_tounsigned(L,i) lua_tounsignedx(L,(i),NULL)
387408

388409
#endif
410+
411+
#define lua_newuserdata(L,s) lua_newuserdatauv(L,s,1)
412+
#define lua_getuservalue(L,idx) lua_getiuservalue(L,idx,1)
413+
#define lua_setuservalue(L,idx) lua_setiuservalue(L,idx,1)
414+
415+
#define LUA_NUMTAGS LUA_NUMTYPES
416+
389417
/* }============================================================== */
390418

391419
/*
@@ -436,20 +464,24 @@ LUA_API lua_Hook (lua_gethook) (lua_State *L);
436464
LUA_API int (lua_gethookmask) (lua_State *L);
437465
LUA_API int (lua_gethookcount) (lua_State *L);
438466

467+
LUA_API int (lua_setcstacklimit) (lua_State *L, unsigned int limit);
439468

440469
struct lua_Debug {
441470
int event;
442471
const char *name; /* (n) */
443472
const char *namewhat; /* (n) 'global', 'local', 'field', 'method' */
444473
const char *what; /* (S) 'Lua', 'C', 'main', 'tail' */
445474
const char *source; /* (S) */
475+
size_t srclen; /* (S) */
446476
int currentline; /* (l) */
447477
int linedefined; /* (S) */
448478
int lastlinedefined; /* (S) */
449479
unsigned char nups; /* (u) number of upvalues */
450480
unsigned char nparams;/* (u) number of parameters */
451481
char isvararg; /* (u) */
452482
char istailcall; /* (t) */
483+
unsigned short ftransfer; /* (r) index of first value transferred */
484+
unsigned short ntransfer; /* (r) number of transferred values */
453485
char short_src[LUA_IDSIZE]; /* (S) */
454486
/* private part */
455487
struct CallInfo *i_ci; /* active function */

0 commit comments

Comments
 (0)