summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Miodrag Milanovic <mmicko@gmail.com>2015-01-13 18:44:26 +0100
committer Miodrag Milanovic <mmicko@gmail.com>2015-01-13 18:44:26 +0100
commitfb4695be0ab380b3c53ea8f5f64b0cc4beacd2a1 (patch)
tree7b0c2d7943bbbaa4d0fa8a56ad66fafb6cfecfad
parentd60dc40fe37bbc90eecea9c0ebb1f932df38ab0b (diff)
Made all compile for Lua 5.3 (nw)
-rw-r--r--3rdparty/lsqlite3/lsqlite3.c16
-rw-r--r--3rdparty/lua/src/lmathlib.c5
-rw-r--r--3rdparty/lua/src/loslib.c2
-rw-r--r--makefile3
-rw-r--r--src/emu/luaengine.c6
-rw-r--r--src/lib/lib.mak1
6 files changed, 19 insertions, 14 deletions
diff --git a/3rdparty/lsqlite3/lsqlite3.c b/3rdparty/lsqlite3/lsqlite3.c
index 5c11aa31437..415e9d84776 100644
--- a/3rdparty/lsqlite3/lsqlite3.c
+++ b/3rdparty/lsqlite3/lsqlite3.c
@@ -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 */
diff --git a/3rdparty/lua/src/lmathlib.c b/3rdparty/lua/src/lmathlib.c
index 002c508bc46..f528f05d9f6 100644
--- a/3rdparty/lua/src/lmathlib.c
+++ b/3rdparty/lua/src/lmathlib.c
@@ -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;
}
diff --git a/3rdparty/lua/src/loslib.c b/3rdparty/lua/src/loslib.c
index 20359b24747..d78ff757df9 100644
--- a/3rdparty/lua/src/loslib.c
+++ b/3rdparty/lua/src/loslib.c
@@ -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;
}
diff --git a/makefile b/makefile
index 0f82b74bb23..99eaa8c1757 100644
--- a/makefile
+++ b/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
diff --git a/src/emu/luaengine.c b/src/emu/luaengine.c
index 8f22617e45d..f38a7386442 100644
--- a/src/emu/luaengine.c
+++ b/src/emu/luaengine.c
@@ -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)));
}
diff --git a/src/lib/lib.mak b/src/lib/lib.mak
index 5074643f06e..923e6aca196 100644
--- a/src/lib/lib.mak
+++ b/src/lib/lib.mak
@@ -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)