From b10668ce74316c8965a5b19a8b4365c90f75e17f Mon Sep 17 00:00:00 2001 From: daurnimator Date: Tue, 16 May 2017 17:32:34 +1000 Subject: src/liolib.js: Add stubs for flush --- README.md | 4 ++-- src/liolib.js | 14 ++++++++++++++ 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 }; -- cgit v1.2.3-54-g00ecf