From ebc68023a79a22ba637023502bd18ac063f28bfc Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Fri, 20 Feb 2015 01:20:08 -0400 Subject: [PATCH] Fix many warnings about implicit integer conversions when compiling for 64 bits. --HG-- branch : minor --- .../xcode/liblove.xcodeproj/project.pbxproj | 3 --- src/common/runtime.cpp | 9 ++++--- src/modules/audio/openal/Pool.cpp | 2 +- src/modules/audio/openal/Source.cpp | 2 +- src/modules/filesystem/physfs/Filesystem.cpp | 2 +- src/modules/font/BMFontRasterizer.cpp | 4 +-- src/modules/font/Font.cpp | 2 +- .../font/freetype/TrueTypeRasterizer.cpp | 12 ++++----- src/modules/graphics/opengl/Canvas.cpp | 8 +++--- src/modules/graphics/opengl/Font.cpp | 2 +- src/modules/graphics/opengl/Graphics.cpp | 2 +- src/modules/graphics/opengl/Mesh.cpp | 4 +-- src/modules/graphics/opengl/OpenGL.cpp | 2 +- .../graphics/opengl/ParticleSystem.cpp | 4 +-- src/modules/graphics/opengl/Polyline.cpp | 8 +++--- src/modules/graphics/opengl/Shader.cpp | 6 ++--- src/modules/graphics/opengl/SpriteBatch.cpp | 2 +- src/modules/graphics/opengl/VertexBuffer.cpp | 12 ++++----- src/modules/graphics/opengl/wrap_Font.cpp | 2 +- src/modules/graphics/opengl/wrap_Graphics.cpp | 8 +++--- src/modules/graphics/opengl/wrap_Mesh.cpp | 14 +++++----- .../graphics/opengl/wrap_ParticleSystem.cpp | 18 ++++++------- src/modules/graphics/opengl/wrap_Shader.cpp | 16 ++++++------ .../graphics/opengl/wrap_SpriteBatch.cpp | 2 +- src/modules/image/CompressedData.cpp | 2 +- src/modules/image/magpie/ImageIOHandler.cpp | 4 +-- src/modules/image/wrap_CompressedData.cpp | 6 ++--- src/modules/joystick/sdl/JoystickModule.cpp | 4 +-- src/modules/math/BezierCurve.cpp | 2 +- src/modules/math/BezierCurve.h | 2 +- src/modules/math/wrap_BezierCurve.cpp | 12 ++++----- src/modules/math/wrap_Math.cpp | 26 +++++++++---------- src/modules/physics/box2d/Physics.cpp | 6 ++--- src/modules/sound/SoundData.cpp | 2 +- src/modules/sound/lullaby/VorbisDecoder.cpp | 6 ++--- src/modules/sound/lullaby/WaveDecoder.cpp | 2 +- src/modules/thread/Channel.cpp | 2 +- src/modules/touch/wrap_Touch.cpp | 2 +- src/modules/window/wrap_Window.cpp | 4 +-- 39 files changed, 114 insertions(+), 114 deletions(-) diff --git a/platform/xcode/liblove.xcodeproj/project.pbxproj b/platform/xcode/liblove.xcodeproj/project.pbxproj index 885c9922f..5fa532eef 100644 --- a/platform/xcode/liblove.xcodeproj/project.pbxproj +++ b/platform/xcode/liblove.xcodeproj/project.pbxproj @@ -3802,7 +3802,6 @@ LOVE_NOMPG123, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; HEADER_SEARCH_PATHS = ( "$(inherited)", ios/include, @@ -3844,7 +3843,6 @@ LOVE_NO_MODPLUG, LOVE_NOMPG123, ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; HEADER_SEARCH_PATHS = ( "$(inherited)", ios/include, @@ -3887,7 +3885,6 @@ LOVE_NO_MODPLUG, LOVE_NOMPG123, ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; HEADER_SEARCH_PATHS = ( "$(inherited)", ios/include, diff --git a/src/common/runtime.cpp b/src/common/runtime.cpp index 809c969a4..aca046b76 100644 --- a/src/common/runtime.cpp +++ b/src/common/runtime.cpp @@ -330,19 +330,22 @@ int luax_table_insert(lua_State *L, int tindex, int vindex, int pos) tindex = lua_gettop(L)+1+tindex; if (vindex < 0) vindex = lua_gettop(L)+1+vindex; + if (pos == -1) { lua_pushvalue(L, vindex); - lua_rawseti(L, tindex, lua_objlen(L, tindex)+1); + lua_rawseti(L, tindex, (int) lua_objlen(L, tindex)+1); return 0; } else if (pos < 0) - pos = lua_objlen(L, tindex)+1+pos; - for (int i = lua_objlen(L, tindex)+1; i > pos; i--) + pos = (int) lua_objlen(L, tindex)+1+pos; + + for (int i = (int) lua_objlen(L, tindex)+1; i > pos; i--) { lua_rawgeti(L, tindex, i-1); lua_rawseti(L, tindex, i); } + lua_pushvalue(L, vindex); lua_rawseti(L, tindex, pos); return 0; diff --git a/src/modules/audio/openal/Pool.cpp b/src/modules/audio/openal/Pool.cpp index 1704490fe..858e6079b 100644 --- a/src/modules/audio/openal/Pool.cpp +++ b/src/modules/audio/openal/Pool.cpp @@ -128,7 +128,7 @@ void Pool::update() int Pool::getSourceCount() const { - return playing.size(); + return (int) playing.size(); } int Pool::getMaxSources() const diff --git a/src/modules/audio/openal/Source.cpp b/src/modules/audio/openal/Source.cpp index 6a1a03499..79acb43f2 100644 --- a/src/modules/audio/openal/Source.cpp +++ b/src/modules/audio/openal/Source.cpp @@ -102,7 +102,7 @@ Source::Source(Pool *pool, love::sound::SoundData *soundData) if (fmt == 0) throw InvalidFormatException(soundData->getChannels(), soundData->getBitDepth()); - staticBuffer.set(new StaticDataBuffer(fmt, soundData->getData(), soundData->getSize(), soundData->getSampleRate())); + staticBuffer.set(new StaticDataBuffer(fmt, soundData->getData(), (ALsizei) soundData->getSize(), soundData->getSampleRate())); // The buffer has a +2 retain count right now, but we want it to have +1. staticBuffer->release(); diff --git a/src/modules/filesystem/physfs/Filesystem.cpp b/src/modules/filesystem/physfs/Filesystem.cpp index b480365f2..9592f204f 100644 --- a/src/modules/filesystem/physfs/Filesystem.cpp +++ b/src/modules/filesystem/physfs/Filesystem.cpp @@ -373,7 +373,7 @@ FileData *Filesystem::newFileData(void *data, unsigned int size, const char *fil FileData *Filesystem::newFileData(const char *b64, const char *filename) const { - int size = strlen(b64); + int size = (int) strlen(b64); int outsize = 0; char *dst = b64_decode(b64, size, outsize); FileData *fd = new FileData(outsize, std::string(filename)); diff --git a/src/modules/font/BMFontRasterizer.cpp b/src/modules/font/BMFontRasterizer.cpp index 992ffc826..3056017dd 100644 --- a/src/modules/font/BMFontRasterizer.cpp +++ b/src/modules/font/BMFontRasterizer.cpp @@ -143,7 +143,7 @@ BMFontRasterizer::BMFontRasterizer(love::filesystem::FileData *fontdef, const st fontFolder = filename.substr(0, separatorpos); // The parseConfig function will try to load any missing page images. - for (size_t i = 0; i < imagelist.size(); i++) + for (int i = 0; i < (int) imagelist.size(); i++) images[i] = imagelist[i]; std::string configtext((const char *) fontdef->getData(), fontdef->getSize()); @@ -178,7 +178,7 @@ void BMFontRasterizer::parseConfig(const std::string &configtext) } else if (tag == "page") { - size_t pageindex = (size_t) cline.getAttributeInt("id"); + int pageindex = cline.getAttributeInt("id"); std::string filename = cline.getAttributeString("file"); // The file name is relative to the font file's folder. diff --git a/src/modules/font/Font.cpp b/src/modules/font/Font.cpp index 159abe983..fe22d903c 100644 --- a/src/modules/font/Font.cpp +++ b/src/modules/font/Font.cpp @@ -73,7 +73,7 @@ Rasterizer *Font::newImageRasterizer(love::image::ImageData *data, const std::st throw love::Exception("UTF-8 decoding error: %s", e.what()); } - return newImageRasterizer(data, &glyphs[0], glyphs.size()); + return newImageRasterizer(data, &glyphs[0], (int) glyphs.size()); } Rasterizer *Font::newImageRasterizer(love::image::ImageData *data, uint32 *glyphs, int numglyphs) diff --git a/src/modules/font/freetype/TrueTypeRasterizer.cpp b/src/modules/font/freetype/TrueTypeRasterizer.cpp index c6104ee1e..6bd1abeb6 100644 --- a/src/modules/font/freetype/TrueTypeRasterizer.cpp +++ b/src/modules/font/freetype/TrueTypeRasterizer.cpp @@ -53,10 +53,10 @@ TrueTypeRasterizer::TrueTypeRasterizer(FT_Library library, love::Data *data, int // Set global metrics FT_Size_Metrics s = face->size->metrics; - metrics.advance = s.max_advance >> 6; - metrics.ascent = s.ascender >> 6; - metrics.descent = s.descender >> 6; - metrics.height = s.height >> 6; + metrics.advance = (int) (s.max_advance >> 6); + metrics.ascent = (int) (s.ascender >> 6); + metrics.descent = (int) (s.descender >> 6); + metrics.height = (int) (s.height >> 6); } TrueTypeRasterizer::~TrueTypeRasterizer() @@ -100,7 +100,7 @@ GlyphData *TrueTypeRasterizer::getGlyphData(uint32 glyph) const glyphMetrics.bearingY = bitmap_glyph->top; glyphMetrics.height = bitmap.rows; glyphMetrics.width = bitmap.width; - glyphMetrics.advance = ftglyph->advance.x >> 16; + glyphMetrics.advance = (int) (ftglyph->advance.x >> 16); GlyphData *glyphData = new GlyphData(glyph, glyphMetrics, GlyphData::FORMAT_LUMINANCE_ALPHA); @@ -151,7 +151,7 @@ GlyphData *TrueTypeRasterizer::getGlyphData(uint32 glyph) const int TrueTypeRasterizer::getGlyphCount() const { - return face->num_glyphs; + return (int) face->num_glyphs; } bool TrueTypeRasterizer::hasGlyph(uint32 glyph) const diff --git a/src/modules/graphics/opengl/Canvas.cpp b/src/modules/graphics/opengl/Canvas.cpp index fa4d65df4..3f3c23ff9 100644 --- a/src/modules/graphics/opengl/Canvas.cpp +++ b/src/modules/graphics/opengl/Canvas.cpp @@ -206,7 +206,7 @@ struct FramebufferStrategyCorePacked : public FramebufferStrategy drawbuffers.push_back(GL_COLOR_ATTACHMENT0); // Attach the canvas textures to the currently bound framebuffer. - for (size_t i = 0; i < canvases.size(); i++) + for (int i = 0; i < (int) canvases.size(); i++) { glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1 + i, GL_TEXTURE_2D, canvases[i]->getGLTexture(), 0); @@ -214,7 +214,7 @@ struct FramebufferStrategyCorePacked : public FramebufferStrategy } // set up multiple render targets - glDrawBuffers(drawbuffers.size(), &drawbuffers[0]); + glDrawBuffers((int) drawbuffers.size(), &drawbuffers[0]); } }; @@ -364,7 +364,7 @@ struct FramebufferStrategyPackedEXT : public FramebufferStrategy drawbuffers.push_back(GL_COLOR_ATTACHMENT0_EXT); // Attach the canvas textures to the currently bound framebuffer. - for (size_t i = 0; i < canvases.size(); i++) + for (int i = 0; i < (int) canvases.size(); i++) { glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1_EXT + i, GL_TEXTURE_2D, canvases[i]->getGLTexture(), 0); @@ -372,7 +372,7 @@ struct FramebufferStrategyPackedEXT : public FramebufferStrategy } // set up multiple render targets - glDrawBuffers(drawbuffers.size(), &drawbuffers[0]); + glDrawBuffers((int) drawbuffers.size(), &drawbuffers[0]); } }; diff --git a/src/modules/graphics/opengl/Font.cpp b/src/modules/graphics/opengl/Font.cpp index 46d212c55..331747443 100644 --- a/src/modules/graphics/opengl/Font.cpp +++ b/src/modules/graphics/opengl/Font.cpp @@ -457,7 +457,7 @@ std::vector Font::generateVerticesFormatted(const std::string offset.x = floorf((wrap - width) / 2.0f); break; case ALIGN_JUSTIFY: - numspaces = std::count(line.begin(), line.end(), ' '); + numspaces = (int) std::count(line.begin(), line.end(), ' '); if (wrappedlines[i] && numspaces >= 1) extraspacing = (wrap - width) / float(numspaces); else diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index 02095f001..5f3ef8094 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -1150,7 +1150,7 @@ void Graphics::polygon(DrawMode mode, const float *coords, size_t count) gl.bindTexture(gl.getDefaultTexture()); glEnableVertexAttribArray(ATTRIB_POS); glVertexAttribPointer(ATTRIB_POS, 2, GL_FLOAT, GL_FALSE, 0, coords); - gl.drawArrays(GL_TRIANGLE_FAN, 0, count/2-1); // opengl will close the polygon for us + gl.drawArrays(GL_TRIANGLE_FAN, 0, (int)count/2-1); // opengl will close the polygon for us glDisableVertexAttribArray(ATTRIB_POS); } } diff --git a/src/modules/graphics/opengl/Mesh.cpp b/src/modules/graphics/opengl/Mesh.cpp index 00ad09dcc..e1aa28db0 100644 --- a/src/modules/graphics/opengl/Mesh.cpp +++ b/src/modules/graphics/opengl/Mesh.cpp @@ -358,7 +358,7 @@ void Mesh::draw(float x, float y, float angle, float sx, float sy, float ox, flo // Make sure the index buffer isn't mapped (sends data to GPU if needed.) ibo->unmap(); - int max = element_count - 1; + int max = (int) element_count - 1; if (range_max >= 0) max = std::min(range_max, max); @@ -373,7 +373,7 @@ void Mesh::draw(float x, float y, float angle, float sx, float sy, float ox, flo } else { - int max = vertex_count - 1; + int max = (int) vertex_count - 1; if (range_max >= 0) max = std::min(range_max, max); diff --git a/src/modules/graphics/opengl/OpenGL.cpp b/src/modules/graphics/opengl/OpenGL.cpp index 1609c6e5e..8db55a1f5 100644 --- a/src/modules/graphics/opengl/OpenGL.cpp +++ b/src/modules/graphics/opengl/OpenGL.cpp @@ -116,7 +116,7 @@ void OpenGL::setupContext() state.curTextureUnit = (int) curgltextureunit - GL_TEXTURE0; // Retrieve currently bound textures for each texture unit. - for (size_t i = 0; i < state.textureUnits.size(); i++) + for (int i = 0; i < (int) state.textureUnits.size(); i++) { glActiveTexture(GL_TEXTURE0 + i); glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint *) &state.textureUnits[i]); diff --git a/src/modules/graphics/opengl/ParticleSystem.cpp b/src/modules/graphics/opengl/ParticleSystem.cpp index 48ed8c2a1..d353f303a 100644 --- a/src/modules/graphics/opengl/ParticleSystem.cpp +++ b/src/modules/graphics/opengl/ParticleSystem.cpp @@ -889,7 +889,7 @@ void ParticleSystem::draw(float x, float y, float angle, float sx, float sy, flo { VertexBuffer::Bind ibo_bind(*ibo.getVertexBuffer()); - gl.drawElements(GL_TRIANGLES, ibo.getIndexCount(pCount), ibo.getType(), ibo.getPointer(0)); + gl.drawElements(GL_TRIANGLES, (GLsizei) ibo.getIndexCount(pCount), ibo.getType(), ibo.getPointer(0)); } glDisableVertexAttribArray(ATTRIB_TEXCOORD); @@ -990,7 +990,7 @@ void ParticleSystem::update(float dt) { s = t * (float) k; // [0:numquads-1] (clamped below) i = (s > 0.0f) ? (size_t) s : 0; - p->quadIndex = (i < k) ? i : k - 1; + p->quadIndex = (int) ((i < k) ? i : k - 1); } // Next particle. diff --git a/src/modules/graphics/opengl/Polyline.cpp b/src/modules/graphics/opengl/Polyline.cpp index 86f70fbaa..79dd312b6 100644 --- a/src/modules/graphics/opengl/Polyline.cpp +++ b/src/modules/graphics/opengl/Polyline.cpp @@ -369,9 +369,9 @@ void Polyline::draw() glVertexAttribPointer(ATTRIB_POS, 2, GL_FLOAT, GL_FALSE, 0, vertices); if (use_quad_indices) - gl.drawElements(draw_mode, (vertex_count / 4) * 6, GL_UNSIGNED_SHORT, indices); + gl.drawElements(draw_mode, (int) (vertex_count / 4) * 6, GL_UNSIGNED_SHORT, indices); else - gl.drawArrays(draw_mode, 0, vertex_count); + gl.drawArrays(draw_mode, 0, (int) vertex_count); if (overdraw) { @@ -385,9 +385,9 @@ void Polyline::draw() glVertexAttribPointer(ATTRIB_POS, 2, GL_FLOAT, GL_FALSE, 0, overdraw); if (use_quad_indices) - gl.drawElements(draw_mode, (overdraw_vertex_count / 4) * 6, GL_UNSIGNED_SHORT, indices); + gl.drawElements(draw_mode, (int) (overdraw_vertex_count / 4) * 6, GL_UNSIGNED_SHORT, indices); else - gl.drawArrays(draw_mode, 0, overdraw_vertex_count); + gl.drawArrays(draw_mode, 0, (int) overdraw_vertex_count); glDisableVertexAttribArray(ATTRIB_COLOR); diff --git a/src/modules/graphics/opengl/Shader.cpp b/src/modules/graphics/opengl/Shader.cpp index a509c851a..5ef199f14 100644 --- a/src/modules/graphics/opengl/Shader.cpp +++ b/src/modules/graphics/opengl/Shader.cpp @@ -401,7 +401,7 @@ void Shader::attach(bool temporary) for (size_t i = 0; i < activeTexUnits.size(); ++i) { if (activeTexUnits[i] > 0) - gl.bindTextureToUnit(activeTexUnits[i], i + 1, false); + gl.bindTextureToUnit(activeTexUnits[i], (int) i + 1, false); } // We always want to use texture unit 0 for everyhing else. @@ -589,7 +589,7 @@ int Shader::getTextureUnit(const std::string &name) if (freeunit_it != textureCounters.end()) { // we don't want to use unit 0 - texunit = std::distance(textureCounters.begin(), freeunit_it) + 1; + texunit = (int) std::distance(textureCounters.begin(), freeunit_it) + 1; } else { @@ -600,7 +600,7 @@ int Shader::getTextureUnit(const std::string &name) throw love::Exception("No more texture units available for shader."); // we don't want to use unit 0 - texunit = std::distance(activeTexUnits.begin(), nextunit_it) + 1; + texunit = (int) std::distance(activeTexUnits.begin(), nextunit_it) + 1; } texUnitPool[name] = texunit; diff --git a/src/modules/graphics/opengl/SpriteBatch.cpp b/src/modules/graphics/opengl/SpriteBatch.cpp index 4e0c4d14c..010788cb2 100644 --- a/src/modules/graphics/opengl/SpriteBatch.cpp +++ b/src/modules/graphics/opengl/SpriteBatch.cpp @@ -263,7 +263,7 @@ void SpriteBatch::draw(float x, float y, float angle, float sx, float sy, float glVertexAttribPointer(ATTRIB_TEXCOORD, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), array_buf->getPointer(texel_offset)); gl.prepareDraw(); - gl.drawElements(GL_TRIANGLES, element_buf.getIndexCount(next), element_buf.getType(), element_buf.getPointer(0)); + gl.drawElements(GL_TRIANGLES, (GLsizei) element_buf.getIndexCount(next), element_buf.getType(), element_buf.getPointer(0)); glDisableVertexAttribArray(ATTRIB_TEXCOORD); glDisableVertexAttribArray(ATTRIB_POS); diff --git a/src/modules/graphics/opengl/VertexBuffer.cpp b/src/modules/graphics/opengl/VertexBuffer.cpp index 857f97292..26a2d0bb7 100644 --- a/src/modules/graphics/opengl/VertexBuffer.cpp +++ b/src/modules/graphics/opengl/VertexBuffer.cpp @@ -365,13 +365,13 @@ void VertexIndex::fill() for (size_t i = 0; i < maxSize; ++i) { - indices[i*6+0] = i * 4 + 0; - indices[i*6+1] = i * 4 + 1; - indices[i*6+2] = i * 4 + 2; + indices[i*6+0] = T(i * 4 + 0); + indices[i*6+1] = T(i * 4 + 1); + indices[i*6+2] = T(i * 4 + 2); - indices[i*6+3] = i * 4 + 0; - indices[i*6+4] = i * 4 + 2; - indices[i*6+5] = i * 4 + 3; + indices[i*6+3] = T(i * 4 + 0); + indices[i*6+4] = T(i * 4 + 2); + indices[i*6+5] = T(i * 4 + 3); } } diff --git a/src/modules/graphics/opengl/wrap_Font.cpp b/src/modules/graphics/opengl/wrap_Font.cpp index 9fba381e9..acec9c16e 100644 --- a/src/modules/graphics/opengl/wrap_Font.cpp +++ b/src/modules/graphics/opengl/wrap_Font.cpp @@ -60,7 +60,7 @@ int w_Font_getWrap(lua_State *L) luax_catchexcept(L, [&]() { t->getWrap(str, wrap, lines, &widths); - numlines = lines.size(); + numlines = (int) lines.size(); }); for (int width : widths) diff --git a/src/modules/graphics/opengl/wrap_Graphics.cpp b/src/modules/graphics/opengl/wrap_Graphics.cpp index fd50702a9..9fb8bfd63 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.cpp +++ b/src/modules/graphics/opengl/wrap_Graphics.cpp @@ -526,7 +526,7 @@ int w_newMesh(lua_State *L) // Get the vertices from the table. for (size_t i = 1; i <= vertex_count; i++) { - lua_rawgeti(L, 1, i); + lua_rawgeti(L, 1, (int) i); if (lua_type(L, -1) != LUA_TTABLE) return luax_typerror(L, 1, "table of tables"); @@ -923,7 +923,7 @@ int w_setCanvas(lua_State *L) if (is_table) { - for (size_t i = 1; i <= lua_objlen(L, 1); i++) + for (int i = 1; i <= (int) lua_objlen(L, 1); i++) { lua_rawgeti(L, 1, i); canvases.push_back(luax_checkcanvas(L, -1)); @@ -1259,7 +1259,7 @@ int w_line(lua_State *L) bool is_table = false; if (args == 1 && lua_istable(L, 1)) { - args = lua_objlen(L, 1); + args = (int) lua_objlen(L, 1); is_table = true; } @@ -1360,7 +1360,7 @@ int w_polygon(lua_State *L) float *coords; if (args == 1 && lua_istable(L, 2)) { - args = lua_objlen(L, 2); + args = (int) lua_objlen(L, 2); is_table = true; } diff --git a/src/modules/graphics/opengl/wrap_Mesh.cpp b/src/modules/graphics/opengl/wrap_Mesh.cpp index f3aa207ef..3b9c267f3 100644 --- a/src/modules/graphics/opengl/wrap_Mesh.cpp +++ b/src/modules/graphics/opengl/wrap_Mesh.cpp @@ -102,12 +102,12 @@ int w_Mesh_setVertices(lua_State *L) { Mesh *t = luax_checkmesh(L, 1); - size_t vertex_count = lua_objlen(L, 2); + int vertex_count = (int) lua_objlen(L, 2); std::vector vertices; vertices.reserve(vertex_count); // Get the vertices from the table. - for (size_t i = 1; i <= vertex_count; i++) + for (int i = 1; i <= vertex_count; i++) { lua_rawgeti(L, 2, i); @@ -144,13 +144,13 @@ int w_Mesh_getVertices(lua_State *L) const Vertex *vertices = t->getVertices(); - size_t count = t->getVertexCount(); + int count = (int) t->getVertexCount(); lua_createtable(L, count, 0); if (count == 0 || vertices == nullptr) return 1; - for (size_t i = 0; i < count; i++) + for (int i = 0; i < count; i++) { // Create vertex table. lua_createtable(L, 8, 0); @@ -199,7 +199,7 @@ int w_Mesh_setVertexMap(lua_State *L) Mesh *t = luax_checkmesh(L, 1); bool is_table = lua_istable(L, 2); - int nargs = is_table ? lua_objlen(L, 2) : lua_gettop(L) - 1; + int nargs = is_table ? (int) lua_objlen(L, 2) : lua_gettop(L) - 1; std::vector vertexmap; vertexmap.reserve(nargs); @@ -227,11 +227,11 @@ int w_Mesh_getVertexMap(lua_State *L) std::vector vertex_map; luax_catchexcept(L, [&](){ t->getVertexMap(vertex_map); }); - size_t element_count = vertex_map.size(); + int element_count = (int) vertex_map.size(); lua_createtable(L, element_count, 0); - for (size_t i = 0; i < element_count; i++) + for (int i = 0; i < element_count; i++) { lua_pushinteger(L, lua_Integer(vertex_map[i]) + 1); lua_rawseti(L, -2, i + 1); diff --git a/src/modules/graphics/opengl/wrap_ParticleSystem.cpp b/src/modules/graphics/opengl/wrap_ParticleSystem.cpp index 5dabd336b..19fc2767e 100644 --- a/src/modules/graphics/opengl/wrap_ParticleSystem.cpp +++ b/src/modules/graphics/opengl/wrap_ParticleSystem.cpp @@ -381,7 +381,7 @@ int w_ParticleSystem_setSizes(lua_State *L) { std::vector sizes(nSizes); for (size_t i = 0; i < nSizes; ++i) - sizes[i] = luax_checkfloat(L, 1 + i + 1); + sizes[i] = luax_checkfloat(L, (int) (1 + i + 1)); t->setSizes(sizes); } @@ -396,7 +396,7 @@ int w_ParticleSystem_getSizes(lua_State *L) for (size_t i = 0; i < sizes.size(); i++) lua_pushnumber(L, sizes[i]); - return sizes.size(); + return (int) sizes.size(); } int w_ParticleSystem_setSizeVariation(lua_State *L) @@ -494,14 +494,14 @@ int w_ParticleSystem_setColors(lua_State *L) if (lua_istable(L, 2)) // setColors({r,g,b,a}, {r,g,b,a}, ...) { - size_t nColors = lua_gettop(L) - 1; + int nColors = (int) lua_gettop(L) - 1; if (nColors > 8) return luaL_error(L, "At most eight (8) colors may be used."); std::vector colors(nColors); - for (size_t i = 0; i < nColors; i++) + for (int i = 0; i < nColors; i++) { luaL_checktype(L, i + 2, LUA_TTABLE); @@ -528,7 +528,7 @@ int w_ParticleSystem_setColors(lua_State *L) else // setColors(r,g,b,a, r,g,b,a, ...) { int cargs = lua_gettop(L) - 1; - size_t nColors = (cargs + 3) / 4; // nColors = ceil(color_args / 4) + int nColors = (cargs + 3) / 4; // nColors = ceil(color_args / 4) if (cargs != 3 && (cargs % 4 != 0 || cargs == 0)) return luaL_error(L, "Expected red, green, blue, and alpha. Only got %d of 4 components.", cargs % 4); @@ -547,7 +547,7 @@ int w_ParticleSystem_setColors(lua_State *L) else { std::vector colors(nColors); - for (size_t i = 0; i < nColors; ++i) + for (int i = 0; i < nColors; ++i) { unsigned char r = (unsigned char) luaL_checkinteger(L, 1 + i*4 + 1); unsigned char g = (unsigned char) luaL_checkinteger(L, 1 + i*4 + 2); @@ -582,7 +582,7 @@ int w_ParticleSystem_getColors(lua_State *L) lua_rawseti(L, -2, 4); } - return colors.size(); + return (int) colors.size(); } int w_ParticleSystem_setQuads(lua_State *L) @@ -592,7 +592,7 @@ int w_ParticleSystem_setQuads(lua_State *L) if (lua_istable(L, 2)) { - for (size_t i = 1; i <= lua_objlen(L, 2); i++) + for (int i = 1; i <= (int) lua_objlen(L, 2); i++) { lua_rawgeti(L, 2, i); @@ -622,7 +622,7 @@ int w_ParticleSystem_getQuads(lua_State *L) lua_createtable(L, (int) quads.size(), 0); - for (size_t i = 0; i < quads.size(); i++) + for (int i = 0; i < (int) quads.size(); i++) { luax_pushtype(L, "Quad", GRAPHICS_QUAD_T, quads[i]); lua_rawseti(L, -2, i + 1); diff --git a/src/modules/graphics/opengl/wrap_Shader.cpp b/src/modules/graphics/opengl/wrap_Shader.cpp index 66f968373..1050ea5f6 100644 --- a/src/modules/graphics/opengl/wrap_Shader.cpp +++ b/src/modules/graphics/opengl/wrap_Shader.cpp @@ -87,7 +87,7 @@ static T *_getVectors(lua_State *L, int count, size_t &dimension) return 0; } - for (size_t k = 1; k <= dimension; ++k) + for (int k = 1; k <= (int) dimension; ++k) { lua_rawgeti(L, 3 + i, k); if (lua_isnumber(L, -1)) @@ -132,7 +132,7 @@ int w_Shader_sendInt(lua_State *L) bool should_error = false; try { - shader->sendInt(name, dimension, values, count); + shader->sendInt(name, (int) dimension, values, count); } catch (love::Exception &e) { @@ -173,7 +173,7 @@ int w_Shader_sendFloat(lua_State *L) bool should_error = false; try { - shader->sendFloat(name, dimension, values, count); + shader->sendFloat(name, (int) dimension, values, count); } catch (love::Exception &e) { @@ -199,7 +199,7 @@ int w_Shader_sendMatrix(lua_State *L) return luax_typerror(L, 3, "matrix table"); lua_getfield(L, 3, "dimension"); - int dimension = lua_tointeger(L, -1); + int dimension = (int) lua_tointeger(L, -1); lua_pop(L, 1); if (dimension < 2 || dimension > 4) @@ -217,7 +217,7 @@ int w_Shader_sendMatrix(lua_State *L) // a dimension of mind. You're moving into a land of both shadow // and substance, of things and ideas. You've just crossed over // into... the Twilight Zone. - int other_dimension = lua_tointeger(L, -1); + int other_dimension = (int) lua_tointeger(L, -1); delete[] values; return luaL_error(L, "Invalid matrix size at argument %d: Expected size %dx%d, got %dx%d.", 3+i, dimension, dimension, other_dimension, other_dimension); @@ -258,19 +258,19 @@ static void w_convertMatrices(lua_State *L, int idx) for (int matrix = idx; matrix < idx + matrixcount; matrix++) { luaL_checktype(L, matrix, LUA_TTABLE); - int dimension = lua_objlen(L, matrix); + int dimension = (int) lua_objlen(L, matrix); int newi = 1; lua_createtable(L, dimension * dimension, 0); // Collapse {{a,b,c}, {d,e,f}, ...} to {a,b,c, d,e,f, ...} - for (size_t i = 1; i <= lua_objlen(L, matrix); i++) + for (int i = 1; i <= (int) lua_objlen(L, matrix); i++) { // Push args[matrix][i] onto the stack. lua_rawgeti(L, matrix, i); luaL_checktype(L, -1, LUA_TTABLE); - for (size_t j = 1; j <= lua_objlen(L, -1); j++) + for (int j = 1; j <= (int) lua_objlen(L, -1); j++) { // Push args[matrix[i][j] onto the stack. lua_rawgeti(L, -1, j); diff --git a/src/modules/graphics/opengl/wrap_SpriteBatch.cpp b/src/modules/graphics/opengl/wrap_SpriteBatch.cpp index 5240c04dd..2436686af 100644 --- a/src/modules/graphics/opengl/wrap_SpriteBatch.cpp +++ b/src/modules/graphics/opengl/wrap_SpriteBatch.cpp @@ -78,7 +78,7 @@ int w_SpriteBatch_add(lua_State *L) int w_SpriteBatch_set(lua_State *L) { SpriteBatch *t = luax_checkspritebatch(L, 1); - int id = luaL_checkinteger(L, 2); + int id = luaL_checkint(L, 2); Quad *quad = nullptr; int startidx = 3; diff --git a/src/modules/image/CompressedData.cpp b/src/modules/image/CompressedData.cpp index d0055bd12..5be769d7c 100644 --- a/src/modules/image/CompressedData.cpp +++ b/src/modules/image/CompressedData.cpp @@ -49,7 +49,7 @@ void *CompressedData::getData() const int CompressedData::getMipmapCount() const { - return dataImages.size(); + return (int) dataImages.size(); } size_t CompressedData::getSize(int miplevel) const diff --git a/src/modules/image/magpie/ImageIOHandler.cpp b/src/modules/image/magpie/ImageIOHandler.cpp index c4a867570..771357d8c 100644 --- a/src/modules/image/magpie/ImageIOHandler.cpp +++ b/src/modules/image/magpie/ImageIOHandler.cpp @@ -129,8 +129,8 @@ ImageIOHandler::DecodedImage ImageIOHandler::decode(love::filesystem::FileData * if (!image) throw love::Exception("Could not decode image!"); - img.width = CGImageGetWidth(image); - img.height = CGImageGetHeight(image); + img.width = (int) CGImageGetWidth(image); + img.height = (int) CGImageGetHeight(image); CGImageAlphaInfo alphainfo = CGImageGetAlphaInfo(image); diff --git a/src/modules/image/wrap_CompressedData.cpp b/src/modules/image/wrap_CompressedData.cpp index 884d042a3..dda360968 100644 --- a/src/modules/image/wrap_CompressedData.cpp +++ b/src/modules/image/wrap_CompressedData.cpp @@ -34,7 +34,7 @@ CompressedData *luax_checkcompresseddata(lua_State *L, int idx) int w_CompressedData_getWidth(lua_State *L) { CompressedData *t = luax_checkcompresseddata(L, 1); - int miplevel = luaL_optinteger(L, 2, 1); + int miplevel = luaL_optint(L, 2, 1); int width = 0; luax_catchexcept(L, [&](){ width = t->getWidth(miplevel - 1); }); @@ -46,7 +46,7 @@ int w_CompressedData_getWidth(lua_State *L) int w_CompressedData_getHeight(lua_State *L) { CompressedData *t = luax_checkcompresseddata(L, 1); - int miplevel = luaL_optinteger(L, 2, 1); + int miplevel = luaL_optint(L, 2, 1); int height = 0; luax_catchexcept(L, [&](){ height = t->getHeight(miplevel - 1); }); @@ -58,7 +58,7 @@ int w_CompressedData_getHeight(lua_State *L) int w_CompressedData_getDimensions(lua_State *L) { CompressedData *t = luax_checkcompresseddata(L, 1); - int miplevel = luaL_optinteger(L, 2, 1); + int miplevel = luaL_optint(L, 2, 1); int width = 0, height = 0; luax_catchexcept(L, [&]() diff --git a/src/modules/joystick/sdl/JoystickModule.cpp b/src/modules/joystick/sdl/JoystickModule.cpp index de8fbe352..f2628eb18 100644 --- a/src/modules/joystick/sdl/JoystickModule.cpp +++ b/src/modules/joystick/sdl/JoystickModule.cpp @@ -84,7 +84,7 @@ love::joystick::Joystick *JoystickModule::getJoystick(int joyindex) int JoystickModule::getIndex(const love::joystick::Joystick *joystick) { - for (size_t i = 0; i < activeSticks.size(); i++) + for (int i = 0; i < (int) activeSticks.size(); i++) { if (activeSticks[i] == joystick) return i; @@ -132,7 +132,7 @@ love::joystick::Joystick *JoystickModule::addJoystick(int deviceindex) if (!joystick) { - joystick = new Joystick(joysticks.size()); + joystick = new Joystick((int) joysticks.size()); joysticks.push_back(joystick); } diff --git a/src/modules/math/BezierCurve.cpp b/src/modules/math/BezierCurve.cpp index 3c1f7685a..04a0c4ff2 100644 --- a/src/modules/math/BezierCurve.cpp +++ b/src/modules/math/BezierCurve.cpp @@ -174,7 +174,7 @@ Vector BezierCurve::evaluate(double t) const return points[0]; } -vector BezierCurve::render(size_t accuracy) const +vector BezierCurve::render(int accuracy) const { if (controlPoints.size() < 2) throw Exception("Invalid Bezier curve: Not enough control points."); diff --git a/src/modules/math/BezierCurve.h b/src/modules/math/BezierCurve.h index 7c06bf6ed..29dc589bf 100644 --- a/src/modules/math/BezierCurve.h +++ b/src/modules/math/BezierCurve.h @@ -112,7 +112,7 @@ public: * @param accuracy The 'fineness' of the curve. * @returns A polygon chain that approximates the bezier curve. **/ - std::vector render(size_t accuracy = 4) const; + std::vector render(int accuracy = 4) const; private: std::vector controlPoints; diff --git a/src/modules/math/wrap_BezierCurve.cpp b/src/modules/math/wrap_BezierCurve.cpp index 0104d8311..5415e5d01 100644 --- a/src/modules/math/wrap_BezierCurve.cpp +++ b/src/modules/math/wrap_BezierCurve.cpp @@ -52,7 +52,7 @@ int w_BezierCurve_getDerivative(lua_State *L) int w_BezierCurve_getControlPoint(lua_State *L) { BezierCurve *curve = luax_checkbeziercurve(L, 1); - int idx = luaL_checkinteger(L, 2); + int idx = luaL_checkint(L, 2); if (idx > 0) // 1-indexing idx--; @@ -69,7 +69,7 @@ int w_BezierCurve_getControlPoint(lua_State *L) int w_BezierCurve_setControlPoint(lua_State *L) { BezierCurve *curve = luax_checkbeziercurve(L, 1); - int idx = luaL_checkinteger(L, 2); + int idx = luaL_checkint(L, 2); float vx = (float) luaL_checknumber(L, 3); float vy = (float) luaL_checknumber(L, 4); @@ -85,7 +85,7 @@ int w_BezierCurve_insertControlPoint(lua_State *L) BezierCurve *curve = luax_checkbeziercurve(L, 1); float vx = (float) luaL_checknumber(L, 2); float vy = (float) luaL_checknumber(L, 3); - int idx = luaL_optinteger(L, 4, -1); + int idx = luaL_optint(L, 4, -1); if (idx > 0) // 1-indexing idx--; @@ -148,13 +148,13 @@ int w_BezierCurve_evaluate(lua_State *L) int w_BezierCurve_render(lua_State *L) { BezierCurve *curve = luax_checkbeziercurve(L, 1); - int accuracy = luaL_optinteger(L, 2, 5); + int accuracy = luaL_optint(L, 2, 5); std::vector points; luax_catchexcept(L, [&](){ points = curve->render(accuracy); }); - lua_createtable(L, points.size()*2, 0); - for (size_t i = 0; i < points.size(); ++i) + lua_createtable(L, (int) points.size() * 2, 0); + for (int i = 0; i < (int) points.size(); ++i) { lua_pushnumber(L, points[i].x); lua_rawseti(L, -2, 2*i+1); diff --git a/src/modules/math/wrap_Math.cpp b/src/modules/math/wrap_Math.cpp index 047699865..ffbe817ba 100644 --- a/src/modules/math/wrap_Math.cpp +++ b/src/modules/math/wrap_Math.cpp @@ -110,9 +110,9 @@ int w_newBezierCurve(lua_State *L) std::vector points; if (lua_istable(L, 1)) { - size_t top = lua_objlen(L, 1); + int top = (int) lua_objlen(L, 1); points.reserve(top / 2); - for (size_t i = 1; i <= top; i += 2) + for (int i = 1; i <= top; i += 2) { lua_rawgeti(L, 1, i); lua_rawgeti(L, 1, i+1); @@ -127,9 +127,9 @@ int w_newBezierCurve(lua_State *L) } else { - size_t top = lua_gettop(L); + int top = (int) lua_gettop(L); points.reserve(top / 2); - for (size_t i = 1; i <= top; i += 2) + for (int i = 1; i <= top; i += 2) { Vector v; v.x = (float) luaL_checknumber(L, i); @@ -149,9 +149,9 @@ int w_triangulate(lua_State *L) std::vector vertices; if (lua_istable(L, 1)) { - size_t top = lua_objlen(L, 1); + int top = (int) lua_objlen(L, 1); vertices.reserve(top / 2); - for (size_t i = 1; i <= top; i += 2) + for (int i = 1; i <= top; i += 2) { lua_rawgeti(L, 1, i); lua_rawgeti(L, 1, i+1); @@ -166,9 +166,9 @@ int w_triangulate(lua_State *L) } else { - size_t top = lua_gettop(L); + int top = (int) lua_gettop(L); vertices.reserve(top / 2); - for (size_t i = 1; i <= top; i += 2) + for (int i = 1; i <= top; i += 2) { Vertex v; v.x = (float) luaL_checknumber(L, i); @@ -189,8 +189,8 @@ int w_triangulate(lua_State *L) triangles = Math::instance.triangulate(vertices); }); - lua_createtable(L, triangles.size(), 0); - for (size_t i = 0; i < triangles.size(); ++i) + lua_createtable(L, (int) triangles.size(), 0); + for (int i = 0; i < (int) triangles.size(); ++i) { const Triangle &tri = triangles[i]; @@ -219,9 +219,9 @@ int w_isConvex(lua_State *L) std::vector vertices; if (lua_istable(L, 1)) { - size_t top = lua_objlen(L, 1); + int top = (int) lua_objlen(L, 1); vertices.reserve(top / 2); - for (size_t i = 1; i <= top; i += 2) + for (int i = 1; i <= top; i += 2) { lua_rawgeti(L, 1, i); lua_rawgeti(L, 1, i+1); @@ -257,7 +257,7 @@ static int getGammaArgs(lua_State *L, float color[4]) if (lua_istable(L, 1)) { - int n = lua_objlen(L, 1); + int n = (int) lua_objlen(L, 1); for (int i = 1; i <= n && i <= 4; i++) { lua_rawgeti(L, 1, i); diff --git a/src/modules/physics/box2d/Physics.cpp b/src/modules/physics/box2d/Physics.cpp index 7e404496d..33bfdcd9d 100644 --- a/src/modules/physics/box2d/Physics.cpp +++ b/src/modules/physics/box2d/Physics.cpp @@ -97,7 +97,7 @@ int Physics::newPolygonShape(lua_State *L) bool istable = lua_istable(L, 1); if (istable) - argc = lua_objlen(L, 1); + argc = (int) lua_objlen(L, 1); if (argc % 2 != 0) return luaL_error(L, "Number of vertex components must be a multiple of two."); @@ -158,12 +158,12 @@ int Physics::newChainShape(lua_State *L) bool istable = lua_istable(L, 2); if (istable) - argc = lua_objlen(L, 2); + argc = (int) lua_objlen(L, 2); if (argc % 2 != 0) return luaL_error(L, "Number of vertex components must be a multiple of two."); - int vcount = (int)argc/2; + int vcount = argc/2; bool loop = luax_toboolean(L, 1); b2Vec2 *vecs = new b2Vec2[vcount]; diff --git a/src/modules/sound/SoundData.cpp b/src/modules/sound/SoundData.cpp index 91aedb791..5a6ff8aa5 100644 --- a/src/modules/sound/SoundData.cpp +++ b/src/modules/sound/SoundData.cpp @@ -176,7 +176,7 @@ int SoundData::getSampleRate() const int SoundData::getSampleCount() const { - return (size/channels)/(bitDepth/8); + return (int) ((size/channels)/(bitDepth/8)); } float SoundData::getDuration() const diff --git a/src/modules/sound/lullaby/VorbisDecoder.cpp b/src/modules/sound/lullaby/VorbisDecoder.cpp index 20f32c3c6..ef0653a54 100644 --- a/src/modules/sound/lullaby/VorbisDecoder.cpp +++ b/src/modules/sound/lullaby/VorbisDecoder.cpp @@ -144,7 +144,7 @@ VorbisDecoder::VorbisDecoder(Data *data, const std::string &ext, int bufferSize) // Initialize OGG file oggFile.dataPtr = (char *) data->getData(); - oggFile.dataSize = data->getSize(); + oggFile.dataSize = (int) data->getSize(); oggFile.dataRead = 0; // Open Vorbis handle @@ -188,7 +188,7 @@ int VorbisDecoder::decode() while (size < bufferSize) { - int result = ov_read(&handle, (char *) buffer + size, bufferSize - size, endian, (getBitDepth() == 16 ? 2 : 1), 1, 0); + long result = ov_read(&handle, (char *) buffer + size, bufferSize - size, endian, (getBitDepth() == 16 ? 2 : 1), 1, 0); if (result == OV_HOLE) continue; @@ -250,7 +250,7 @@ int VorbisDecoder::getBitDepth() const int VorbisDecoder::getSampleRate() const { - return vorbisInfo->rate; + return (int) vorbisInfo->rate; } } // lullaby diff --git a/src/modules/sound/lullaby/WaveDecoder.cpp b/src/modules/sound/lullaby/WaveDecoder.cpp index b04ec12b3..6d5a00b2b 100644 --- a/src/modules/sound/lullaby/WaveDecoder.cpp +++ b/src/modules/sound/lullaby/WaveDecoder.cpp @@ -140,7 +140,7 @@ int WaveDecoder::decode() size += bytes; } - return size; + return (int) size; } bool WaveDecoder::seek(float s) diff --git a/src/modules/thread/Channel.cpp b/src/modules/thread/Channel.cpp index 18fd5f190..94180b1d2 100644 --- a/src/modules/thread/Channel.cpp +++ b/src/modules/thread/Channel.cpp @@ -176,7 +176,7 @@ Variant *Channel::peek() int Channel::getCount() { Lock l(mutex); - return queue.size(); + return (int) queue.size(); } void Channel::clear() diff --git a/src/modules/touch/wrap_Touch.cpp b/src/modules/touch/wrap_Touch.cpp index 148046325..213eca1d3 100644 --- a/src/modules/touch/wrap_Touch.cpp +++ b/src/modules/touch/wrap_Touch.cpp @@ -47,7 +47,7 @@ int w_getTouchIDs(lua_State *L) // We use lightuserdata instead of a lua_Number (double) because doubles // can't represent all possible id values on 64-bit systems. lua_pushlightuserdata(L, (void *) (intptr_t) ids[i]); - lua_rawseti(L, -2, i + 1); + lua_rawseti(L, -2, (int) i + 1); } return 1; diff --git a/src/modules/window/wrap_Window.cpp b/src/modules/window/wrap_Window.cpp index 3c3e07bda..4765c68d0 100644 --- a/src/modules/window/wrap_Window.cpp +++ b/src/modules/window/wrap_Window.cpp @@ -196,7 +196,7 @@ int w_getFullscreenModes(lua_State *L) std::vector modes = instance()->getFullscreenSizes(displayindex); - lua_createtable(L, modes.size(), 0); + lua_createtable(L, (int) modes.size(), 0); for (size_t i = 0; i < modes.size(); i++) { @@ -417,7 +417,7 @@ int w_showMessageBox(lua_State *L) // Array of button names. for (size_t i = 0; i < numbuttons; i++) { - lua_rawgeti(L, 3, i + 1); + lua_rawgeti(L, 3, (int) i + 1); data.buttons.push_back(luax_checkstring(L, -1)); lua_pop(L, 1); }