From b525c305b524f5b3ffaba3187ccc828d332aa835 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Mon, 22 May 2017 23:11:34 +1000 Subject: src/luaconf.js: Implement lua_integer2str and lua_number2str --- src/luaconf.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/luaconf.js b/src/luaconf.js index 3d0d18f..c272178 100644 --- a/src/luaconf.js +++ b/src/luaconf.js @@ -2,6 +2,7 @@ "use strict"; const llimit = require('./llimit.js'); +const sprintf = require('sprintf-js').sprintf; /* @@ LUAI_MAXSTACK limits the size of the Lua stack. @@ -18,6 +19,14 @@ const LUAI_MAXSTACK = 1000000; */ const LUA_IDSIZE = 60; +const lua_integer2str = function(n) { + return sprintf(LUA_INTEGER_FMT, n); +}; + +const lua_number2str = function(n) { + return sprintf(LUA_NUMBER_FMT, n); +}; + const lua_numbertointeger = function(n) { return n >= llimit.MIN_INT && n < -llimit.MIN_INT ? n : false; }; @@ -64,4 +73,6 @@ module.exports.LUA_INTEGER_FRMLEN = LUA_INTEGER_FRMLEN; module.exports.LUA_NUMBER_FMT = LUA_NUMBER_FMT; module.exports.LUA_NUMBER_FRMLEN = LUA_NUMBER_FRMLEN; module.exports.lua_getlocaledecpoint = lua_getlocaledecpoint; +module.exports.lua_integer2str = lua_integer2str; +module.exports.lua_number2str = lua_number2str; module.exports.lua_numbertointeger = lua_numbertointeger; -- cgit v1.2.3-70-g09d2