CLuaInstMisc: Add getTimeOfDay() script function

- Set Lua api version to 1.39


Origin commit data
------------------
Branch: ni/coolstream
Commit: cb7895d981
Author: Michael Liebmann <tuxcode.bbg@gmail.com>
Date: 2016-01-21 (Thu, 21 Jan 2016)



------------------
This commit was generated by Migit
This commit is contained in:
Michael Liebmann
2016-01-21 09:09:33 +01:00
parent 2b49e84c77
commit b0ca9a30cd
3 changed files with 17 additions and 1 deletions

View File

@@ -4,4 +4,4 @@
* to luainstance.h changes
*/
#define LUA_API_VERSION_MAJOR 1
#define LUA_API_VERSION_MINOR 38
#define LUA_API_VERSION_MINOR 39

View File

@@ -71,6 +71,7 @@ void CLuaInstMisc::LuaMiscRegister(lua_State *L)
{ "GetRevision", CLuaInstMisc::GetRevision },
{ "checkVersion", CLuaInstMisc::checkVersion },
{ "postMsg", CLuaInstMisc::postMsg },
{ "getTimeOfDay", CLuaInstMisc::getTimeOfDay },
{ "__gc", CLuaInstMisc::MiscDelete },
{ NULL, NULL }
};
@@ -338,6 +339,20 @@ int CLuaInstMisc::postMsg(lua_State *L)
return 0;
}
int CLuaInstMisc::getTimeOfDay(lua_State *L)
{
CLuaMisc *D = MiscCheckData(L, 1);
if (!D) return 0;
struct timeval t1;
double dt;
gettimeofday(&t1, NULL);
dt = (double)t1.tv_sec + ((double)t1.tv_usec)/1000000ULL;
lua_pushnumber(L, (lua_Number)dt);
return 1;
}
int CLuaInstMisc::MiscDelete(lua_State *L)
{
CLuaMisc *D = MiscCheckData(L, 1);

View File

@@ -63,6 +63,7 @@ class CLuaInstMisc
static int GetRevision(lua_State *L);
static int checkVersion(lua_State *L);
static int postMsg(lua_State *L);
static int getTimeOfDay(lua_State *L);
static int MiscDelete(lua_State *L);
static void miscFunctionDeprecated(lua_State *L, std::string oldFunc);