mirror of
https://github.com/holub/mame
synced 2025-04-19 15:11:37 +03:00
Made all compile for Lua 5.3 (nw)
This commit is contained in:
parent
d60dc40fe3
commit
fb4695be0a
16
3rdparty/lsqlite3/lsqlite3.c
vendored
16
3rdparty/lsqlite3/lsqlite3.c
vendored
@ -476,7 +476,7 @@ static int dbvm_get_named_types(lua_State *L) {
|
||||
static int dbvm_bind_index(lua_State *L, sqlite3_stmt *vm, int index, int lindex) {
|
||||
switch (lua_type(L, lindex)) {
|
||||
case LUA_TSTRING:
|
||||
return sqlite3_bind_text(vm, index, lua_tostring(L, lindex), lua_strlen(L, lindex), SQLITE_TRANSIENT);
|
||||
return sqlite3_bind_text(vm, index, lua_tostring(L, lindex), lua_rawlen(L, lindex), SQLITE_TRANSIENT);
|
||||
case LUA_TNUMBER:
|
||||
return sqlite3_bind_double(vm, index, lua_tonumber(L, lindex));
|
||||
case LUA_TBOOLEAN:
|
||||
@ -522,7 +522,7 @@ static int dbvm_bind_blob(lua_State *L) {
|
||||
sdb_vm *svm = lsqlite_checkvm(L, 1);
|
||||
int index = luaL_checkint(L, 2);
|
||||
const char *value = luaL_checkstring(L, 3);
|
||||
int len = lua_strlen(L, 3);
|
||||
int len = lua_rawlen(L, 3);
|
||||
|
||||
lua_pushnumber(L, sqlite3_bind_blob(svm->vm, index, value, len, SQLITE_TRANSIENT));
|
||||
return 1;
|
||||
@ -797,7 +797,7 @@ static int lcontext_result(lua_State *L) {
|
||||
sqlite3_result_double(ctx->ctx, luaL_checknumber(L, 2));
|
||||
break;
|
||||
case LUA_TSTRING:
|
||||
sqlite3_result_text(ctx->ctx, luaL_checkstring(L, 2), lua_strlen(L, 2), SQLITE_TRANSIENT);
|
||||
sqlite3_result_text(ctx->ctx, luaL_checkstring(L, 2), lua_rawlen(L, 2), SQLITE_TRANSIENT);
|
||||
break;
|
||||
case LUA_TNIL:
|
||||
case LUA_TNONE:
|
||||
@ -814,7 +814,7 @@ static int lcontext_result(lua_State *L) {
|
||||
static int lcontext_result_blob(lua_State *L) {
|
||||
lcontext *ctx = lsqlite_checkcontext(L, 1);
|
||||
const char *blob = luaL_checkstring(L, 2);
|
||||
int size = lua_strlen(L, 2);
|
||||
int size = lua_rawlen(L, 2);
|
||||
sqlite3_result_blob(ctx->ctx, (const void*)blob, size, SQLITE_TRANSIENT);
|
||||
return 0;
|
||||
}
|
||||
@ -829,7 +829,7 @@ static int lcontext_result_double(lua_State *L) {
|
||||
static int lcontext_result_error(lua_State *L) {
|
||||
lcontext *ctx = lsqlite_checkcontext(L, 1);
|
||||
const char *err = luaL_checkstring(L, 2);
|
||||
int size = lua_strlen(L, 2);
|
||||
int size = lua_rawlen(L, 2);
|
||||
sqlite3_result_error(ctx->ctx, err, size);
|
||||
return 0;
|
||||
}
|
||||
@ -850,7 +850,7 @@ static int lcontext_result_null(lua_State *L) {
|
||||
static int lcontext_result_text(lua_State *L) {
|
||||
lcontext *ctx = lsqlite_checkcontext(L, 1);
|
||||
const char *text = luaL_checkstring(L, 2);
|
||||
int size = lua_strlen(L, 2);
|
||||
int size = lua_rawlen(L, 2);
|
||||
sqlite3_result_text(ctx->ctx, text, size, SQLITE_TRANSIENT);
|
||||
return 0;
|
||||
}
|
||||
@ -1001,7 +1001,7 @@ static void db_sql_normal_function(sqlite3_context *context, int argc, sqlite3_v
|
||||
|
||||
if (lua_pcall(L, argc + 1, 0, 0)) {
|
||||
const char *errmsg = lua_tostring(L, -1);
|
||||
int size = lua_strlen(L, -1);
|
||||
int size = lua_rawlen(L, -1);
|
||||
sqlite3_result_error(context, errmsg, size);
|
||||
}
|
||||
|
||||
@ -1658,7 +1658,7 @@ static int db_exec(lua_State *L) {
|
||||
static int db_prepare(lua_State *L) {
|
||||
sdb *db = lsqlite_checkdb(L, 1);
|
||||
const char *sql = luaL_checkstring(L, 2);
|
||||
int sql_len = lua_strlen(L, 2);
|
||||
int sql_len = lua_rawlen(L, 2);
|
||||
const char *sqltail;
|
||||
sdb_vm *svm;
|
||||
lua_settop(L,2); /* sql is on top of stack for call to newvm */
|
||||
|
5
3rdparty/lua/src/lmathlib.c
vendored
5
3rdparty/lua/src/lmathlib.c
vendored
@ -240,7 +240,7 @@ static int math_max (lua_State *L) {
|
||||
*/
|
||||
static int math_random (lua_State *L) {
|
||||
lua_Integer low, up;
|
||||
double r = (double)l_rand() * (1.0 / ((double)L_RANDMAX + 1.0));
|
||||
double r = (double)(1.0 * l_rand()) * (1.0 / ((double)L_RANDMAX + 1.0));
|
||||
switch (lua_gettop(L)) { /* check number of arguments */
|
||||
case 0: { /* no arguments */
|
||||
lua_pushnumber(L, (lua_Number)r); /* Number between 0 and 1 */
|
||||
@ -269,7 +269,8 @@ static int math_random (lua_State *L) {
|
||||
|
||||
|
||||
static int math_randomseed (lua_State *L) {
|
||||
l_srand((unsigned int)(lua_Integer)luaL_checknumber(L, 1));
|
||||
lua_Number seed = (lua_Number)luaL_checknumber(L, 1);
|
||||
l_srand((unsigned int)seed);
|
||||
(void)rand(); /* discard first value to avoid undesirable correlations */
|
||||
return 0;
|
||||
}
|
||||
|
2
3rdparty/lua/src/loslib.c
vendored
2
3rdparty/lua/src/loslib.c
vendored
@ -152,7 +152,7 @@ static int os_getenv (lua_State *L) {
|
||||
|
||||
|
||||
static int os_clock (lua_State *L) {
|
||||
lua_pushnumber(L, ((lua_Number)clock())/(lua_Number)CLOCKS_PER_SEC);
|
||||
lua_pushnumber(L, ((lua_Number)(int)clock())/(lua_Number)CLOCKS_PER_SEC);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
3
makefile
3
makefile
@ -493,6 +493,9 @@ ifdef FASTDEBUG
|
||||
DEFS += -DMAME_DEBUG_FAST
|
||||
endif
|
||||
|
||||
# To support casting in Lua 5.3
|
||||
DEFS += -DLUA_COMPAT_APIINTCASTS
|
||||
|
||||
#-------------------------------------------------
|
||||
# compile flags
|
||||
# CCOMFLAGS are common flags
|
||||
|
@ -68,7 +68,7 @@ int lua_engine::report(int status) {
|
||||
{
|
||||
const char *msg = lua_tostring(m_lua_state, -1);
|
||||
if (msg == NULL) msg = "(error object is not a string)";
|
||||
luai_writestringerror("%s\n", msg);
|
||||
lua_writestringerror("%s\n", msg);
|
||||
lua_pop(m_lua_state, 1);
|
||||
/* force a complete garbage collection in case of errors */
|
||||
lua_gc(m_lua_state, LUA_GCCOLLECT, 0);
|
||||
@ -360,7 +360,7 @@ void lua_engine::emu_set_hook(lua_State *L)
|
||||
} else if (strcmp(hookname, "frame") == 0) {
|
||||
hook_frame_cb.set(L, 1);
|
||||
} else {
|
||||
luai_writestringerror("%s", "Unknown hook name, aborting.\n");
|
||||
lua_writestringerror("%s", "Unknown hook name, aborting.\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -948,7 +948,7 @@ void lua_engine::periodic_check()
|
||||
lua_getglobal(m_lua_state, "print");
|
||||
lua_insert(m_lua_state, 1);
|
||||
if (lua_pcall(m_lua_state, lua_gettop(m_lua_state) - 1, 0, 0) != LUA_OK)
|
||||
luai_writestringerror("%s\n", lua_pushfstring(m_lua_state,
|
||||
lua_writestringerror("%s\n", lua_pushfstring(m_lua_state,
|
||||
"error calling " LUA_QL("print") " (%s)",
|
||||
lua_tostring(m_lua_state, -1)));
|
||||
}
|
||||
|
@ -525,6 +525,7 @@ LUAOBJS = \
|
||||
$(LIBOBJ)/lua/ltablib.o \
|
||||
$(LIBOBJ)/lua/loadlib.o \
|
||||
$(LIBOBJ)/lua/linit.o \
|
||||
$(LIBOBJ)/lua/lutf8lib.o \
|
||||
$(LIBOBJ)/lua/lsqlite3/lsqlite3.o \
|
||||
|
||||
$(OBJ)/liblua.a: $(LUAOBJS)
|
||||
|
Loading…
Reference in New Issue
Block a user