From bddaf98342a461f4e02389d4db390098fb423fbf Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Sat, 9 Aug 2014 19:23:48 -0700 Subject: Fixing even more warnings. --- src/BLua.cc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/BLua.cc') diff --git a/src/BLua.cc b/src/BLua.cc index b111218..5b3df8b 100644 --- a/src/BLua.cc +++ b/src/BLua.cc @@ -17,6 +17,8 @@ extern "C" { #include } +#undef max + #ifndef BUFFERSIZE #define BUFFERSIZE 2048 #endif @@ -68,7 +70,7 @@ int Balau::LuaStatics::hex(lua_State * __L) { if (((n != 1) && (n != 2)) || !L.isnumber(1) || ((n == 2) && !L.isstring(2))) L.error("Incorrect arguments to function `hex'"); - x = L.tonumber(1); + x = (int) L.tonumber(1); String fmt = n == 2 ? L.tostring() : "%02x"; r.set(fmt.to_charp(), x); @@ -1081,19 +1083,21 @@ Balau::LuaObjectBase * Balau::LuaObjectFactory::getMeInternal(Lua & L, int i) { return o; } -void Balau::LuaObjectFactory::pushMethod(Lua & L, const char * s, int strSize, lua_CFunction f, int upvalues) { +void Balau::LuaObjectFactory::pushMethod(Lua & L, const char * s, size_t strSize, lua_CFunction f, int upvalues) { + AAssert(strSize < std::numeric_limits::max(), "string size too large! (%zu)", strSize); if (upvalues == 0) { - L.push(s, strSize); + L.push(s, (int) strSize); L.push(f); } else { L.push(f, upvalues); - L.push(s, strSize); + L.push(s, (int) strSize); L.insert(-2); } L.settable(-3, true); } -void Balau::LuaObjectFactory::pushMeta(Lua & L, const char * s, int strSize, lua_CFunction f, int upvalues) { +void Balau::LuaObjectFactory::pushMeta(Lua & L, const char * s, size_t strSize, lua_CFunction f, int upvalues) { + AAssert(strSize < std::numeric_limits::max(), "string size too large! (%zu)", strSize); if (!L.getmetatable()) L.newtable(); if (upvalues == 0) { @@ -1101,7 +1105,7 @@ void Balau::LuaObjectFactory::pushMeta(Lua & L, const char * s, int strSize, lua L.push(f); } else { L.push(f, upvalues); - L.push(s, strSize); + L.push(s, (int) strSize); L.insert(-2); } L.settable(); -- cgit v1.2.3