aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-16 17:32:34 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-16 17:37:31 +1000
commitb10668ce74316c8965a5b19a8b4365c90f75e17f (patch)
treeeeea1881e822678485fcd708cfdf4c610124a118
parenta553ac00a4119eb247df5e123df60d447e96c31a (diff)
downloadfengari-b10668ce74316c8965a5b19a8b4365c90f75e17f.tar.gz
fengari-b10668ce74316c8965a5b19a8b4365c90f75e17f.tar.bz2
fengari-b10668ce74316c8965a5b19a8b4365c90f75e17f.zip
src/liolib.js: Add stubs for flush
-rw-r--r--README.md4
-rw-r--r--src/liolib.js14
2 files changed, 16 insertions, 2 deletions
diff --git a/README.md b/README.md
index 6d94e2e..4b78239 100644
--- a/README.md
+++ b/README.md
@@ -29,6 +29,7 @@
- [x] Package
- [ ] io
- [x] `file:__tostring()`
+ - [x] `file:flush()`
- [x] `file:write()`
- [x] `io.close()`
- [x] `io.stderr`
@@ -36,7 +37,7 @@
- [x] `io.stdout`
- [x] `io.type()`
- [x] `io.write()`
- - [ ] `io.flush()`
+ - [x] `io.flush()`
- [ ] `io.input()`
- [ ] `io.lines()`
- [ ] `io.open()`
@@ -44,7 +45,6 @@
- [ ] `io.popen()`
- [ ] `io.read()`
- [ ] `io.tmpfile()`
- - [ ] `file:flush()`
- [ ] `file:lines()`
- [ ] `file:read()`
- [ ] `file:setvbuf()`
diff --git a/src/liolib.js b/src/liolib.js
index 575b3ec..6c7d945 100644
--- a/src/liolib.js
+++ b/src/liolib.js
@@ -105,14 +105,28 @@ const f_write = function(L) {
return g_write(L, f, 2);
};
+const io_flush = function (L) {
+ /* stub, as node doesn't have synchronized buffered IO */
+ getiofile(L, IO_OUTPUT);
+ return lauxlib.luaL_fileresult(L, true, null, null);
+};
+
+const f_flush = function (L) {
+ /* stub, as node doesn't have synchronized buffered IO */
+ tofile(L);
+ return lauxlib.luaL_fileresult(L, true, null, null);
+};
+
const iolib = {
"close": io_close,
+ "flush": io_flush,
"type": io_type,
"write": io_write
};
const flib = {
"close": io_close,
+ "flush": f_flush,
"write": f_write,
"__tostring": f_tostring
};