Functions that take a boolean argument now properly type-check for it.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2017-08-14 22:56:20 -03:00
parent fea9f82cfa
commit fee157b6b9
21 changed files with 50 additions and 42 deletions
+8 -12
View File
@@ -1168,9 +1168,8 @@ int w_newCanvas(lua_State *L)
lua_getfield(L, startidx, "readable");
if (!lua_isnoneornil(L, -1))
{
luaL_checktype(L, -1, LUA_TBOOLEAN);
settings.readable.hasValue = true;
settings.readable.value = luax_toboolean(L, -1);
settings.readable.value = luax_checkboolean(L, -1);
}
lua_pop(L, 1);
@@ -1327,8 +1326,7 @@ int w_newShader(lua_State *L)
int w_validateShader(lua_State *L)
{
luaL_checktype(L, 1, LUA_TBOOLEAN);
bool gles = luax_toboolean(L, 1);
bool gles = luax_checkboolean(L, 1);
Shader::ShaderSource source;
w_getShaderSource(L, 2, gles, source);
@@ -1712,10 +1710,10 @@ int w_setColorMask(lua_State *L)
}
else
{
mask.r = luax_toboolean(L, 1);
mask.g = luax_toboolean(L, 2);
mask.b = luax_toboolean(L, 3);
mask.a = luax_toboolean(L, 4);
mask.r = luax_checkboolean(L, 1);
mask.g = luax_checkboolean(L, 2);
mask.b = luax_checkboolean(L, 3);
mask.a = luax_checkboolean(L, 4);
}
instance()->setColorMask(mask);
@@ -1912,7 +1910,7 @@ int w_getPointSize(lua_State *L)
int w_setWireframe(lua_State *L)
{
instance()->setWireframe(luax_toboolean(L, 1));
instance()->setWireframe(luax_checkboolean(L, 1));
return 0;
}
@@ -2033,9 +2031,7 @@ int w_getCanvasFormats(lua_State *L)
if (!lua_isnoneornil(L, 1))
{
luaL_checktype(L, 1, LUA_TBOOLEAN);
if (luax_toboolean(L, 1))
if (luax_checkboolean(L, 1))
{
supported = [](PixelFormat format) -> bool
{
+1 -1
View File
@@ -315,7 +315,7 @@ int w_Mesh_setAttributeEnabled(lua_State *L)
{
Mesh *t = luax_checkmesh(L, 1);
const char *name = luaL_checkstring(L, 2);
bool enable = luax_toboolean(L, 3);
bool enable = luax_checkboolean(L, 3);
luax_catchexcept(L, [&](){ t->setAttributeEnabled(name, enable); });
return 0;
}
+2 -2
View File
@@ -251,7 +251,7 @@ int w_ParticleSystem_getAreaSpreadAngle(lua_State *L)
int w_ParticleSystem_setAreaSpreadIsRelativeDirection(lua_State *L)
{
ParticleSystem *t = luax_checkparticlesystem(L, 1);
bool arg1 = luax_toboolean(L, 2);
bool arg1 = luax_checkboolean(L, 2);
t->setAreaSpreadIsRelativeDirection(arg1);
return 0;
}
@@ -650,7 +650,7 @@ int w_ParticleSystem_getQuads(lua_State *L)
int w_ParticleSystem_setRelativeRotation(lua_State *L)
{
ParticleSystem *t = luax_checkparticlesystem(L, 1);
t->setRelativeRotation(luax_toboolean(L, 2));
t->setRelativeRotation(luax_checkboolean(L, 2));
return 0;
}
+1 -1
View File
@@ -159,7 +159,7 @@ int w_Shader_sendMatrices(lua_State *L, int startidx, Shader *shader, const Shad
if (lua_isboolean(L, startidx))
{
columnmajor = lua_toboolean(L, startidx);
columnmajor = luax_toboolean(L, startidx);
startidx++;
}