aboutsummaryrefslogtreecommitdiff
path: root/src/lauxlib.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-15 17:20:06 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-15 17:20:06 +1000
commitf7e5203a20ef41cf9bc59d339b4f85007a7f3764 (patch)
tree3c6f0907231588f528902eec3b2b1d09d19a53e1 /src/lauxlib.js
parent3947c2cb2fa6193645ac30898064e3d335a63545 (diff)
downloadfengari-f7e5203a20ef41cf9bc59d339b4f85007a7f3764.tar.gz
fengari-f7e5203a20ef41cf9bc59d339b4f85007a7f3764.tar.bz2
fengari-f7e5203a20ef41cf9bc59d339b4f85007a7f3764.zip
Separate ZIO and MBuffer data structures
- lua_load no longer takes a null reader function
Diffstat (limited to 'src/lauxlib.js')
-rw-r--r--src/lauxlib.js13
1 files changed, 2 insertions, 11 deletions
diff --git a/src/lauxlib.js b/src/lauxlib.js
index 3019bf3..c5a3b21 100644
--- a/src/lauxlib.js
+++ b/src/lauxlib.js
@@ -691,18 +691,9 @@ if (!WEB) {
this.f = null; /* file being read */
this.buff = new Buffer(1024); /* area for reading file */
this.pos = 0; /* current position in file */
- this.binary = false;
}
}
- const toDataView = function(buffer, bytes) {
- let ab = new ArrayBuffer(bytes);
- let au = new Uint8Array(ab);
- for (let i = 0; i < bytes; i++)
- au[i] = buffer[i];
- return new DataView(ab);
- };
-
const getF = function(L, ud) {
let lf = ud;
let bytes = 0;
@@ -715,7 +706,7 @@ if (!WEB) {
lf.pos += bytes;
}
if (bytes > 0)
- return lf.binary ? toDataView(lf.buff, bytes) : lf.buff.slice(0, bytes);
+ return lf.buff.slice(0, bytes); /* slice on a node.js Buffer is 'free' */
else return null;
};
@@ -794,7 +785,7 @@ if (!WEB) {
let com = skipcomment(lf);
/* check for signature first, as we don't want to add line number corrections in binary case */
if (com.c === lua.LUA_SIGNATURE.charCodeAt(0) && filename) { /* binary file? */
- lf.binary = true;
+ /* no need to re-open in node.js */
} else if (com.skipped) { /* read initial portion */
lf.buff[lf.n++] = '\n'.charCodeAt(0); /* add line to correct line numbers */
}