summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-05-02 11:20:21 +0200
committerBenoit Giannangeli <giann008@gmail.com>2017-05-02 11:23:56 +0200
commitb7d4f302dc4398b3a10906ae73e3ecc8c74a14cf (patch)
treeb22a5535374ef40061d0d33135b501cc2d71ef33
parentf2bb5dee9b90197185dd0367cee98b61b066ae70 (diff)
downloadfengari-b7d4f302dc4398b3a10906ae73e3ecc8c74a14cf.tar.gz
fengari-b7d4f302dc4398b3a10906ae73e3ecc8c74a14cf.tar.bz2
fengari-b7d4f302dc4398b3a10906ae73e3ecc8c74a14cf.zip
os.clock
-rw-r--r--README.md6
-rw-r--r--src/loslib.js8
2 files changed, 10 insertions, 4 deletions
diff --git a/README.md b/README.md
index c0fd4f3..fd9b4ee 100644
--- a/README.md
+++ b/README.md
@@ -24,6 +24,8 @@
- [x] utf8
- [ ] Package
- [ ] os
+ - [x] `os.clock()`
+ - [x] `os.difftime()`
- [x] `os.execute()`
- [x] `os.exit()`
- [x] `os.getenv()`
@@ -31,10 +33,8 @@
- [x] `os.rename()`
- [x] `os.time()`
- [x] `os.tmpname()`
- - [ ] `os.clock()`
- [ ] `os.date()`
- - [ ] `os.difftime()`
- - [ ] `os.setlocale()`
+ - [ ] ~~`os.setlocale()`~~
- [ ] io
- [ ] `io.stdin`
- [ ] `io.stdout`
diff --git a/src/loslib.js b/src/loslib.js
index 4c3331d..98686c4 100644
--- a/src/loslib.js
+++ b/src/loslib.js
@@ -80,7 +80,7 @@ const syslib = {
};
// Only with Node
-if (process && process.exit && process.env) {
+if (process && process.exit && process.env && process.uptime) {
const os_exit = function(L) {
let status;
if (lua.lua_isboolean(L, 1))
@@ -98,6 +98,12 @@ if (process && process.exit && process.env) {
return 1;
};
+ const os_clock = function(L) {
+ lua.lua_pushnumber(L, process.uptime());
+ return 1;
+ };
+
+ syslib.clock = os_clock;
syslib.exit = os_exit;
syslib.getenv = os_getenv;
}