mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-07 09:56:59 +00:00
lua: use base::Chrono for os.clock() (which has more precision)
This commit is contained in:
parent
bc092b4512
commit
c5a5a7858c
@ -13,6 +13,7 @@
|
||||
#include "app/app.h"
|
||||
#include "app/console.h"
|
||||
#include "app/script/luacpp.h"
|
||||
#include "base/chrono.h"
|
||||
#include "base/fstream_path.h"
|
||||
#include "doc/color_mode.h"
|
||||
|
||||
@ -24,6 +25,9 @@ namespace script {
|
||||
|
||||
namespace {
|
||||
|
||||
// High precision clock.
|
||||
base::Chrono luaClock;
|
||||
|
||||
int print(lua_State* L)
|
||||
{
|
||||
std::string output;
|
||||
@ -52,6 +56,12 @@ int print(lua_State* L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int os_clock(lua_State* L)
|
||||
{
|
||||
lua_pushnumber(L, luaClock.elapsed());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int unsupported(lua_State* L)
|
||||
{
|
||||
// debug.getinfo(1, "n").name
|
||||
@ -105,6 +115,8 @@ Engine::Engine()
|
||||
lua_pushcfunction(L, unsupported);
|
||||
lua_setfield(L, -2, name);
|
||||
}
|
||||
lua_pushcfunction(L, os_clock);
|
||||
lua_setfield(L, -2, "clock");
|
||||
lua_pop(L, 1);
|
||||
|
||||
// Generic code used by metatables
|
||||
|
Loading…
Reference in New Issue
Block a user