Use luaL_check/optinteger instead of luaL_check/optnumber when getting integer arguments to functions. Resolves issue #1251.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2017-07-16 12:17:50 -03:00
parent abcade9421
commit 34ebe18f14
30 changed files with 127 additions and 127 deletions
+5 -5
View File
@@ -35,7 +35,7 @@ namespace sound
int w_newDecoder(lua_State *L)
{
love::filesystem::FileData *data = love::filesystem::luax_getfiledata(L, 1);
int bufferSize = (int) luaL_optnumber(L, 2, Decoder::DEFAULT_BUFFER_SIZE);
int bufferSize = (int) luaL_optinteger(L, 2, Decoder::DEFAULT_BUFFER_SIZE);
Decoder *t = nullptr;
luax_catchexcept(L,
@@ -57,10 +57,10 @@ int w_newSoundData(lua_State *L)
if (lua_isnumber(L, 1))
{
int samples = (int) luaL_checknumber(L, 1);
int sampleRate = (int) luaL_optnumber(L, 2, Decoder::DEFAULT_SAMPLE_RATE);
int bitDepth = (int) luaL_optnumber(L, 3, Decoder::DEFAULT_BIT_DEPTH);
int channels = (int) luaL_optnumber(L, 4, Decoder::DEFAULT_CHANNELS);
int samples = (int) luaL_checkinteger(L, 1);
int sampleRate = (int) luaL_optinteger(L, 2, Decoder::DEFAULT_SAMPLE_RATE);
int bitDepth = (int) luaL_optinteger(L, 3, Decoder::DEFAULT_BIT_DEPTH);
int channels = (int) luaL_optinteger(L, 4, Decoder::DEFAULT_CHANNELS);
luax_catchexcept(L, [&](){ t = instance()->newSoundData(samples, sampleRate, bitDepth, channels); });
}