Previous 199869 Revisions Next

r34375 Tuesday 13th January, 2015 at 17:44:26 UTC by Miodrag Milanović
Made all compile for Lua 5.3 (nw)
[/trunk]makefile
[3rdparty/lsqlite3]lsqlite3.c
[3rdparty/lua/src]lmathlib.c loslib.c
[src/emu]luaengine.c
[src/lib]lib.mak

trunk/3rdparty/lsqlite3/lsqlite3.c
r242886r242887
476476static int dbvm_bind_index(lua_State *L, sqlite3_stmt *vm, int index, int lindex) {
477477   switch (lua_type(L, lindex)) {
478478      case LUA_TSTRING:
479         return sqlite3_bind_text(vm, index, lua_tostring(L, lindex), lua_strlen(L, lindex), SQLITE_TRANSIENT);
479         return sqlite3_bind_text(vm, index, lua_tostring(L, lindex), lua_rawlen(L, lindex), SQLITE_TRANSIENT);
480480      case LUA_TNUMBER:
481481         return sqlite3_bind_double(vm, index, lua_tonumber(L, lindex));
482482      case LUA_TBOOLEAN:
r242886r242887
522522   sdb_vm *svm = lsqlite_checkvm(L, 1);
523523   int index = luaL_checkint(L, 2);
524524   const char *value = luaL_checkstring(L, 3);
525   int len = lua_strlen(L, 3);
525   int len = lua_rawlen(L, 3);
526526
527527   lua_pushnumber(L, sqlite3_bind_blob(svm->vm, index, value, len, SQLITE_TRANSIENT));
528528   return 1;
r242886r242887
797797         sqlite3_result_double(ctx->ctx, luaL_checknumber(L, 2));
798798         break;
799799      case LUA_TSTRING:
800         sqlite3_result_text(ctx->ctx, luaL_checkstring(L, 2), lua_strlen(L, 2), SQLITE_TRANSIENT);
800         sqlite3_result_text(ctx->ctx, luaL_checkstring(L, 2), lua_rawlen(L, 2), SQLITE_TRANSIENT);
801801         break;
802802      case LUA_TNIL:
803803      case LUA_TNONE:
r242886r242887
814814static int lcontext_result_blob(lua_State *L) {
815815   lcontext *ctx = lsqlite_checkcontext(L, 1);
816816   const char *blob = luaL_checkstring(L, 2);
817   int size = lua_strlen(L, 2);
817   int size = lua_rawlen(L, 2);
818818   sqlite3_result_blob(ctx->ctx, (const void*)blob, size, SQLITE_TRANSIENT);
819819   return 0;
820820}
r242886r242887
829829static int lcontext_result_error(lua_State *L) {
830830   lcontext *ctx = lsqlite_checkcontext(L, 1);
831831   const char *err = luaL_checkstring(L, 2);
832   int size = lua_strlen(L, 2);
832   int size = lua_rawlen(L, 2);
833833   sqlite3_result_error(ctx->ctx, err, size);
834834   return 0;
835835}
r242886r242887
850850static int lcontext_result_text(lua_State *L) {
851851   lcontext *ctx = lsqlite_checkcontext(L, 1);
852852   const char *text = luaL_checkstring(L, 2);
853   int size = lua_strlen(L, 2);
853   int size = lua_rawlen(L, 2);
854854   sqlite3_result_text(ctx->ctx, text, size, SQLITE_TRANSIENT);
855855   return 0;
856856}
r242886r242887
10011001
10021002   if (lua_pcall(L, argc + 1, 0, 0)) {
10031003      const char *errmsg = lua_tostring(L, -1);
1004      int size = lua_strlen(L, -1);
1004      int size = lua_rawlen(L, -1);
10051005      sqlite3_result_error(context, errmsg, size);
10061006   }
10071007
r242886r242887
16581658static int db_prepare(lua_State *L) {
16591659   sdb *db = lsqlite_checkdb(L, 1);
16601660   const char *sql = luaL_checkstring(L, 2);
1661   int sql_len = lua_strlen(L, 2);
1661   int sql_len = lua_rawlen(L, 2);
16621662   const char *sqltail;
16631663   sdb_vm *svm;
16641664   lua_settop(L,2); /* sql is on top of stack for call to newvm */
trunk/3rdparty/lua/src/lmathlib.c
r242886r242887
240240*/
241241static int math_random (lua_State *L) {
242242  lua_Integer low, up;
243  double r = (double)l_rand() * (1.0 / ((double)L_RANDMAX + 1.0));
243  double r = (double)(1.0 * l_rand()) * (1.0 / ((double)L_RANDMAX + 1.0));
244244  switch (lua_gettop(L)) {  /* check number of arguments */
245245    case 0: {  /* no arguments */
246246      lua_pushnumber(L, (lua_Number)r);  /* Number between 0 and 1 */
r242886r242887
269269
270270
271271static int math_randomseed (lua_State *L) {
272  l_srand((unsigned int)(lua_Integer)luaL_checknumber(L, 1));
272  lua_Number seed = (lua_Number)luaL_checknumber(L, 1);
273  l_srand((unsigned int)seed);
273274  (void)rand(); /* discard first value to avoid undesirable correlations */
274275  return 0;
275276}
trunk/3rdparty/lua/src/loslib.c
r242886r242887
152152
153153
154154static int os_clock (lua_State *L) {
155  lua_pushnumber(L, ((lua_Number)clock())/(lua_Number)CLOCKS_PER_SEC);
155  lua_pushnumber(L, ((lua_Number)(int)clock())/(lua_Number)CLOCKS_PER_SEC);
156156  return 1;
157157}
158158
trunk/makefile
r242886r242887
493493DEFS += -DMAME_DEBUG_FAST
494494endif
495495
496# To support casting in Lua 5.3
497DEFS += -DLUA_COMPAT_APIINTCASTS
498
496499#-------------------------------------------------
497500# compile flags
498501# CCOMFLAGS are common flags
trunk/src/emu/luaengine.c
r242886r242887
6868   {
6969      const char *msg = lua_tostring(m_lua_state, -1);
7070      if (msg == NULL) msg = "(error object is not a string)";
71      luai_writestringerror("%s\n", msg);
71      lua_writestringerror("%s\n", msg);
7272      lua_pop(m_lua_state, 1);
7373      /* force a complete garbage collection in case of errors */
7474      lua_gc(m_lua_state, LUA_GCCOLLECT, 0);
r242886r242887
360360   } else if (strcmp(hookname, "frame") == 0) {
361361      hook_frame_cb.set(L, 1);
362362   } else {
363      luai_writestringerror("%s", "Unknown hook name, aborting.\n");
363      lua_writestringerror("%s", "Unknown hook name, aborting.\n");
364364   }
365365}
366366
r242886r242887
948948         lua_getglobal(m_lua_state, "print");
949949         lua_insert(m_lua_state, 1);
950950         if (lua_pcall(m_lua_state, lua_gettop(m_lua_state) - 1, 0, 0) != LUA_OK)
951            luai_writestringerror("%s\n", lua_pushfstring(m_lua_state,
951            lua_writestringerror("%s\n", lua_pushfstring(m_lua_state,
952952            "error calling " LUA_QL("print") " (%s)",
953953            lua_tostring(m_lua_state, -1)));
954954      }
trunk/src/lib/lib.mak
r242886r242887
525525   $(LIBOBJ)/lua/ltablib.o \
526526   $(LIBOBJ)/lua/loadlib.o \
527527   $(LIBOBJ)/lua/linit.o \
528   $(LIBOBJ)/lua/lutf8lib.o \
528529   $(LIBOBJ)/lua/lsqlite3/lsqlite3.o \
529530
530531$(OBJ)/liblua.a: $(LUAOBJS)


Previous 199869 Revisions Next


© 1997-2024 The MAME Team