diff options
author | Benoit Giannangeli <giann008@gmail.com> | 2017-05-28 11:54:09 +0200 |
---|---|---|
committer | Benoit Giannangeli <giann008@gmail.com> | 2017-05-28 11:54:09 +0200 |
commit | 03fa39649de945d5a392f460fd592f815534f69a (patch) | |
tree | e574b099dd5058be94fc9a3f5ab0f8bf878ea853 /src/lapi.js | |
parent | 8173e639527cffc583c9c6ad6e7fc0d43429ab50 (diff) | |
download | fengari-03fa39649de945d5a392f460fd592f815534f69a.tar.gz fengari-03fa39649de945d5a392f460fd592f815534f69a.tar.bz2 fengari-03fa39649de945d5a392f460fd592f815534f69a.zip |
lua_tonumberx
lua_tonumber should return 0 if argument is not convertible to a number.
But luaL_checknumber uses lua_tonumberx and tests isnum.
-> lua_tonumberx return false if argument is not convertible to a
number.
Diffstat (limited to 'src/lapi.js')
-rw-r--r-- | src/lapi.js | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/lapi.js b/src/lapi.js index 1dfd112..90533f7 100644 --- a/src/lapi.js +++ b/src/lapi.js @@ -720,6 +720,10 @@ const lua_tonumber = function(L, idx) { return n === false ? 0 : n; }; +const lua_tonumberx = function(L, idx) { + return lvm.tonumber(index2addr(L, idx)); +}; + const lua_touserdata = function(L, idx) { let o = index2addr(L, idx); switch (o.ttnov()) { @@ -1224,6 +1228,7 @@ module.exports.lua_tojsstring = lua_tojsstring; module.exports.lua_toljsstring = lua_toljsstring; module.exports.lua_tolstring = lua_tolstring; module.exports.lua_tonumber = lua_tonumber; +module.exports.lua_tonumberx = lua_tonumberx; module.exports.lua_topointer = lua_topointer; module.exports.lua_toproxy = lua_toproxy; module.exports.lua_tostring = lua_tostring; |