[Scummvm-cvs-logs] SF.net SVN: scummvm:[33316] residual/trunk/engine
aquadran at users.sourceforge.net
aquadran at users.sourceforge.net
Sat Jul 26 22:27:16 CEST 2008
Revision: 33316
http://scummvm.svn.sourceforge.net/scummvm/?rev=33316&view=rev
Author: aquadran
Date: 2008-07-26 20:27:15 +0000 (Sat, 26 Jul 2008)
Log Message:
-----------
remove unused lua iolib funcs
Modified Paths:
--------------
residual/trunk/engine/backend/driver.h
residual/trunk/engine/backend/sdl/driver_sdl.cpp
residual/trunk/engine/backend/sdl/driver_sdl.h
residual/trunk/engine/lua/liolib.cpp
Modified: residual/trunk/engine/backend/driver.h
===================================================================
--- residual/trunk/engine/backend/driver.h 2008-07-26 19:30:44 UTC (rev 33315)
+++ residual/trunk/engine/backend/driver.h 2008-07-26 20:27:15 UTC (rev 33316)
@@ -136,6 +136,8 @@
typedef unsigned int (*TimerProc)(unsigned int interval, void *param);
+ virtual void getTimeAndDate(struct tm &t) const = 0;
+
/**
* The types of events backends may generate.
* @see Event
Modified: residual/trunk/engine/backend/sdl/driver_sdl.cpp
===================================================================
--- residual/trunk/engine/backend/sdl/driver_sdl.cpp 2008-07-26 19:30:44 UTC (rev 33315)
+++ residual/trunk/engine/backend/sdl/driver_sdl.cpp 2008-07-26 20:27:15 UTC (rev 33316)
@@ -308,6 +308,11 @@
return _timer;
}
+void DriverSDL::getTimeAndDate(struct tm &t) const {
+ time_t curTime = time(0);
+ t = *localtime(&curTime);
+}
+
DriverSDL::DriverSDL() {
_mixer = NULL;
_timer = NULL;
Modified: residual/trunk/engine/backend/sdl/driver_sdl.h
===================================================================
--- residual/trunk/engine/backend/sdl/driver_sdl.h 2008-07-26 19:30:44 UTC (rev 33315)
+++ residual/trunk/engine/backend/sdl/driver_sdl.h 2008-07-26 20:27:15 UTC (rev 33316)
@@ -37,6 +37,8 @@
#include <SDL.h>
+#include <time.h>
+
// NOTE: This is not a complete driver, it needs to be subclassed
// to provide rendering functionality.
@@ -65,6 +67,7 @@
uint32 getMillis();
void delayMillis(uint msecs);
Common::TimerManager *getTimerManager();
+ void getTimeAndDate(struct tm &t) const;
MutexRef createMutex();
void lockMutex(MutexRef mutex);
Modified: residual/trunk/engine/lua/liolib.cpp
===================================================================
--- residual/trunk/engine/lua/liolib.cpp 2008-07-26 19:30:44 UTC (rev 33315)
+++ residual/trunk/engine/lua/liolib.cpp 2008-07-26 20:27:15 UTC (rev 33316)
@@ -10,11 +10,11 @@
#include "luadebug.h"
#include "lualib.h"
-#include <time.h>
-#include <errno.h>
-
#include "engine/resource.h"
+#include "engine/backend/driver.h"
+#include <errno.h>
+
#define CLOSEDTAG 2
#define IOTAG 1
@@ -255,88 +255,25 @@
}
-static void io_execute (void)
-{
- lua_pushnumber(system(luaL_check_string(1)));
-}
+static void io_date () {
+ tm t;
+ char b[BUFSIZ];
-
-static void io_remove (void)
-{
- pushresult(remove(luaL_check_string(1)) == 0);
-}
-
-
-static void io_rename (void)
-{
- pushresult(rename(luaL_check_string(1),
- luaL_check_string(2)) == 0);
-}
-
-
-static void io_tmpname (void)
-{
- lua_pushstring(tmpnam(NULL));
-}
-
-
-
-static void io_getenv (void)
-{
- lua_pushstring(getenv(luaL_check_string(1))); /* if NULL push nil */
-}
-
-
-static void io_clock (void) {
- lua_pushnumber(((double)clock())/CLOCKS_PER_SEC);
-}
-
-
-static void io_date (void)
-{
- time_t t;
- struct tm *tm;
- const char *s = luaL_opt_string(1, "%c");
- char b[BUFSIZ];
- time(&t); tm = localtime(&t);
- if (strftime(b,sizeof(b),s,tm))
+ g_driver->getTimeAndDate(t);
+ sprintf(b, "%02d.%02d.%d %02d:%02d.%02d", t.tm_mday, t.tm_mon + 1, 1900 + t.tm_year, t.tm_hour, t.tm_min, t.tm_sec);
lua_pushstring(b);
- else
- lua_error("invalid `date' format");
}
-static void setloc (void)
-{
- static int32 cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC,
- LC_TIME};
- static const char *catnames[] = {"all", "collate", "ctype", "monetary",
- "numeric", "time", NULL};
- int32 op = luaL_findstring(luaL_opt_string(2, "all"), catnames);
- luaL_arg_check(op != -1, 2, "invalid option");
- lua_pushstring(setlocale(cat[op], luaL_check_string(1)));
-}
-
-
static void io_exit (void)
{
+ // verify if it's really used
+ assert(0);
lua_Object o = lua_getparam(1);
exit((int)lua_isnumber(o) ? (int)lua_getnumber(o) : 1);
}
-static void io_debug (void)
-{
- while (1) {
- char buffer[250];
- fprintf(stderr, "lua_debug> ");
- if (fgets(buffer, sizeof(buffer), stdin) == 0) return;
- if (strcmp(buffer, "cont\n") == 0) return;
- lua_dostring(buffer);
- }
-}
-
-
static void lua_printstack (FILE *f)
{
int32 level = 1; /* skip level 0 (it's this function) */
@@ -383,16 +320,8 @@
static struct luaL_reg iolib[] = {
-{"setlocale", setloc},
-{"execute", io_execute},
-//{"remove", io_remove},
-{"rename", io_rename},
-{"tmpname", io_tmpname},
-{"getenv", io_getenv},
{"date", io_date},
-{"clock", io_clock},
{"exit", io_exit},
-{"debug", io_debug},
{"print_stack", errorfb}
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list