Browse Source

Address some compiler warnings about implicit integer conversions.

--HG--
branch : minor
Alex Szpakowski 8 years ago
parent
commit
0653ec9564

+ 1 - 1
src/modules/audio/Source.h

@@ -103,7 +103,7 @@ public:
 	virtual int getChannels() const = 0;
 	virtual int getChannels() const = 0;
 
 
 	virtual int getFreeBufferCount() const = 0;
 	virtual int getFreeBufferCount() const = 0;
-	virtual bool queue(void *data, int length, int dataSampleRate, int dataBitDepth, int dataChannels) = 0;
+	virtual bool queue(void *data, size_t length, int dataSampleRate, int dataBitDepth, int dataChannels) = 0;
 
 
 	virtual Type getType() const;
 	virtual Type getType() const;
 
 

+ 1 - 1
src/modules/audio/null/Source.cpp

@@ -222,7 +222,7 @@ int Source::getFreeBufferCount() const
 	return 0;
 	return 0;
 }
 }
 
 
-bool Source::queue(void *, int, int, int, int)
+bool Source::queue(void *, size_t, int, int, int)
 {
 {
 	return false;
 	return false;
 }
 }

+ 1 - 1
src/modules/audio/null/Source.h

@@ -77,7 +77,7 @@ public:
 	virtual int getChannels() const;
 	virtual int getChannels() const;
 
 
 	virtual int getFreeBufferCount() const;
 	virtual int getFreeBufferCount() const;
-	virtual bool queue(void *data, int length, int dataSampleRate, int dataBitDepth, int dataChannels);
+	virtual bool queue(void *data, size_t length, int dataSampleRate, int dataBitDepth, int dataChannels);
 
 
 private:
 private:
 
 

+ 4 - 4
src/modules/audio/openal/Source.cpp

@@ -663,7 +663,7 @@ bool Source::isLooping() const
 	return looping;
 	return looping;
 }
 }
 
 
-bool Source::queue(void *data, int length, int dataSampleRate, int dataBitDepth, int dataChannels)
+bool Source::queue(void *data, size_t length, int dataSampleRate, int dataBitDepth, int dataChannels)
 {
 {
 	if (type != TYPE_QUEUE)
 	if (type != TYPE_QUEUE)
 		throw QueueTypeMismatchException();
 		throw QueueTypeMismatchException();
@@ -883,7 +883,7 @@ bool Source::playAtomic(const std::vector<love::audio::Source*> &sources, const
 	}
 	}
 
 
 	alGetError();
 	alGetError();
-	alSourcePlayv(toPlay.size(), &toPlay[0]);
+	alSourcePlayv((ALsizei) toPlay.size(), &toPlay[0]);
 	bool success = alGetError() == AL_NO_ERROR;
 	bool success = alGetError() == AL_NO_ERROR;
 
 
 	for (auto &_source : sources)
 	for (auto &_source : sources)
@@ -912,7 +912,7 @@ void Source::stopAtomic(const std::vector<love::audio::Source*> &sources)
 			sourceIds.push_back(source->source);
 			sourceIds.push_back(source->source);
 	}
 	}
 
 
-	alSourceStopv(sources.size(), &sourceIds[0]);
+	alSourceStopv((ALsizei) sources.size(), &sourceIds[0]);
 
 
 	for (auto &_source : sources)
 	for (auto &_source : sources)
 	{
 	{
@@ -936,7 +936,7 @@ void Source::pauseAtomic(const std::vector<love::audio::Source*> &sources)
 			sourceIds.push_back(source->source);
 			sourceIds.push_back(source->source);
 	}
 	}
 
 
-	alSourcePausev(sources.size(), &sourceIds[0]);
+	alSourcePausev((ALsizei) sources.size(), &sourceIds[0]);
 }
 }
 
 
 void Source::reset()
 void Source::reset()

+ 1 - 1
src/modules/audio/openal/Source.h

@@ -142,7 +142,7 @@ public:
 	virtual int getChannels() const;
 	virtual int getChannels() const;
 
 
 	virtual int getFreeBufferCount() const;
 	virtual int getFreeBufferCount() const;
-	virtual bool queue(void *data, int length, int dataSampleRate, int dataBitDepth, int dataChannels);
+	virtual bool queue(void *data, size_t length, int dataSampleRate, int dataBitDepth, int dataChannels);
 	virtual bool queueAtomic(void *data, ALsizei length);
 	virtual bool queueAtomic(void *data, ALsizei length);
 
 
 	void prepareAtomic();
 	void prepareAtomic();

+ 4 - 4
src/modules/audio/wrap_Audio.cpp

@@ -101,10 +101,10 @@ static std::vector<Source*> readSourceList(lua_State *L, int n)
 	if (n < 0)
 	if (n < 0)
 		n += lua_gettop(L) + 1;
 		n += lua_gettop(L) + 1;
 
 
-	size_t items = lua_objlen(L, n);
+	int items = (int) lua_objlen(L, n);
 	std::vector<Source*> sources(items);
 	std::vector<Source*> sources(items);
 
 
-	for (size_t i = 0; i < items; i++)
+	for (int i = 0; i < items; i++)
 	{
 	{
 		lua_rawgeti(L, n, i+1);
 		lua_rawgeti(L, n, i+1);
 		sources[i] = luax_checksource(L, -1);
 		sources[i] = luax_checksource(L, -1);
@@ -147,8 +147,8 @@ int w_pause(lua_State *L)
 	{
 	{
 		auto sources = instance()->pause();
 		auto sources = instance()->pause();
 
 
-		lua_createtable(L, sources.size(), 0);
-		for (size_t i = 0; i < sources.size(); i++)
+		lua_createtable(L, (int) sources.size(), 0);
+		for (int i = 0; i < (int) sources.size(); i++)
 		{
 		{
 			luax_pushtype(L, AUDIO_SOURCE_ID, sources[i]);
 			luax_pushtype(L, AUDIO_SOURCE_ID, sources[i]);
 			lua_rawseti(L, -2, i+1);
 			lua_rawseti(L, -2, i+1);

+ 5 - 5
src/modules/audio/wrap_Source.cpp

@@ -344,10 +344,10 @@ int w_Source_queue(lua_State *L)
 
 
 	if (luax_istype(L, 2, SOUND_SOUND_DATA_ID))
 	if (luax_istype(L, 2, SOUND_SOUND_DATA_ID))
 	{
 	{
-		love::sound::SoundData *s = luax_totype<love::sound::SoundData>(L, 2, SOUND_SOUND_DATA_ID);
+		auto s = luax_totype<love::sound::SoundData>(L, 2, SOUND_SOUND_DATA_ID);
 
 
 		int offset = 0;
 		int offset = 0;
-		int length = s->getSize();
+		size_t length = s->getSize();
 
 
 		if (lua_gettop(L) == 4)
 		if (lua_gettop(L) == 4)
 		{
 		{
@@ -357,12 +357,12 @@ int w_Source_queue(lua_State *L)
 		else if (lua_gettop(L) == 3)
 		else if (lua_gettop(L) == 3)
 			length = luaL_checknumber(L, 3);
 			length = luaL_checknumber(L, 3);
 
 
-		if (length > (int)s->getSize() - offset || offset < 0 || length < 0)
+		if (offset < 0 || length > s->getSize() - offset)
 			return luaL_error(L, "Data region out of bounds.");
 			return luaL_error(L, "Data region out of bounds.");
 
 
 		luax_catchexcept(L, [&]() {
 		luax_catchexcept(L, [&]() {
-			success = t->queue((void*)((uintptr_t)s->getData() + (uintptr_t)offset), 
-				length, s->getSampleRate(), s->getBitDepth(), s->getChannels());
+			success = t->queue((unsigned char *)s->getData() + offset, length,
+			            s->getSampleRate(), s->getBitDepth(), s->getChannels());
 		});
 		});
 	}
 	}
 	else if (lua_islightuserdata(L, 2))
 	else if (lua_islightuserdata(L, 2))

+ 2 - 2
src/modules/font/freetype/TrueTypeRasterizer.cpp

@@ -76,7 +76,7 @@ GlyphData *TrueTypeRasterizer::getGlyphData(uint32 glyph) const
 	FT_Glyph ftglyph;
 	FT_Glyph ftglyph;
 
 
 	FT_Error err = FT_Err_Ok;
 	FT_Error err = FT_Err_Ok;
-	FT_ULong loadoption = hintingToLoadOption(hinting);
+	FT_UInt loadoption = hintingToLoadOption(hinting);
 
 
 	// Initialize
 	// Initialize
 	err = FT_Load_Glyph(face, FT_Get_Char_Index(face, glyph), FT_LOAD_DEFAULT | loadoption);
 	err = FT_Load_Glyph(face, FT_Get_Char_Index(face, glyph), FT_LOAD_DEFAULT | loadoption);
@@ -185,7 +185,7 @@ bool TrueTypeRasterizer::accepts(FT_Library library, love::Data *data)
 	return FT_New_Memory_Face(library, fbase, fsize, -1, nullptr) == 0;
 	return FT_New_Memory_Face(library, fbase, fsize, -1, nullptr) == 0;
 }
 }
 
 
-FT_ULong TrueTypeRasterizer::hintingToLoadOption(Hinting hint)
+FT_UInt TrueTypeRasterizer::hintingToLoadOption(Hinting hint)
 {
 {
 	switch (hint)
 	switch (hint)
 	{
 	{

+ 1 - 1
src/modules/font/freetype/TrueTypeRasterizer.h

@@ -58,7 +58,7 @@ public:
 
 
 private:
 private:
 
 
-	static FT_ULong hintingToLoadOption(Hinting hinting);
+	static FT_UInt hintingToLoadOption(Hinting hinting);
 
 
 	// TrueType face
 	// TrueType face
 	FT_Face face;
 	FT_Face face;

+ 1 - 1
src/modules/graphics/opengl/Canvas.cpp

@@ -629,7 +629,7 @@ love::image::ImageData *Canvas::newImageData(love::image::Image *image, int x, i
 		break;
 		break;
 	}
 	}
 
 
-	int size = w * h * image::ImageData::getPixelSize(imageformat);
+	size_t size = w * h * image::ImageData::getPixelSize(imageformat);
 	uint8 *pixels = nullptr;
 	uint8 *pixels = nullptr;
 	try
 	try
 	{
 	{

+ 1 - 1
src/modules/graphics/opengl/Graphics.cpp

@@ -1299,7 +1299,7 @@ void Graphics::points(const float *coords, const uint8 *colors, size_t numpoints
 	}
 	}
 
 
 	gl.useVertexAttribArrays(attribflags);
 	gl.useVertexAttribArrays(attribflags);
-	gl.drawArrays(GL_POINTS, 0, numpoints);
+	gl.drawArrays(GL_POINTS, 0, (GLsizei) numpoints);
 }
 }
 
 
 void Graphics::polyline(const float *coords, size_t count)
 void Graphics::polyline(const float *coords, size_t count)

+ 1 - 1
src/modules/graphics/opengl/Mesh.cpp

@@ -569,7 +569,7 @@ int Mesh::bindAttributeToShaderInput(int attributeindex, const std::string &inpu
 	GLenum datatype = getGLDataType(format.type);
 	GLenum datatype = getGLDataType(format.type);
 	GLboolean normalized = (datatype == GL_UNSIGNED_BYTE);
 	GLboolean normalized = (datatype == GL_UNSIGNED_BYTE);
 
 
-	glVertexAttribPointer(attriblocation, format.components, datatype, normalized, vertexStride, gloffset);
+	glVertexAttribPointer(attriblocation, format.components, datatype, normalized, (GLsizei) vertexStride, gloffset);
 
 
 	return attriblocation;
 	return attriblocation;
 }
 }

+ 1 - 1
src/modules/graphics/opengl/Shader.cpp

@@ -420,7 +420,7 @@ void Shader::attach(bool temporary)
 		{
 		{
 			// make sure all sent textures are properly bound to their respective texture units
 			// make sure all sent textures are properly bound to their respective texture units
 			// note: list potentially contains texture ids of deleted/invalid textures!
 			// note: list potentially contains texture ids of deleted/invalid textures!
-			for (size_t i = 0; i < activeTexUnits.size(); ++i)
+			for (int i = 0; i < (int) activeTexUnits.size(); ++i)
 			{
 			{
 				if (activeTexUnits[i] > 0)
 				if (activeTexUnits[i] > 0)
 					gl.bindTextureToUnit(activeTexUnits[i], i + 1, false);
 					gl.bindTextureToUnit(activeTexUnits[i], i + 1, false);

+ 2 - 2
src/modules/graphics/opengl/wrap_Mesh.cpp

@@ -131,7 +131,7 @@ int w_Mesh_setVertices(lua_State *L)
 	}
 	}
 
 
 	luaL_checktype(L, 2, LUA_TTABLE);
 	luaL_checktype(L, 2, LUA_TTABLE);
-	size_t nvertices = luax_objlen(L, 2);
+	int nvertices = (int) luax_objlen(L, 2);
 
 
 	if (vertoffset + nvertices > t->getVertexCount())
 	if (vertoffset + nvertices > t->getVertexCount())
 		return luaL_error(L, "Too many vertices (expected at most %d, got %d)", (int) t->getVertexCount() - (int) vertoffset, (int) nvertices);
 		return luaL_error(L, "Too many vertices (expected at most %d, got %d)", (int) t->getVertexCount() - (int) vertoffset, (int) nvertices);
@@ -144,7 +144,7 @@ int w_Mesh_setVertices(lua_State *L)
 
 
 	char *data = (char *) t->mapVertexData() + byteoffset;
 	char *data = (char *) t->mapVertexData() + byteoffset;
 
 
-	for (size_t i = 0; i < nvertices; i++)
+	for (int i = 0; i < nvertices; i++)
 	{
 	{
 		// get vertices[vertindex]
 		// get vertices[vertindex]
 		lua_rawgeti(L, 2, i + 1);
 		lua_rawgeti(L, 2, i + 1);

+ 1 - 1
src/modules/graphics/opengl/wrap_Text.cpp

@@ -39,7 +39,7 @@ void luax_checkcoloredstring(lua_State *L, int idx, std::vector<Font::ColoredStr
 
 
 	if (lua_istable(L, idx))
 	if (lua_istable(L, idx))
 	{
 	{
-		int len = luax_objlen(L, idx);
+		int len = (int) luax_objlen(L, idx);
 
 
 		for (int i = 1; i <= len; i++)
 		for (int i = 1; i <= len; i++)
 		{
 		{

+ 1 - 1
src/modules/math/BezierCurve.cpp

@@ -233,7 +233,7 @@ vector<Vector> BezierCurve::render(int accuracy) const
 	return vertices;
 	return vertices;
 }
 }
 
 
-vector<Vector> BezierCurve::renderSegment(double start, double end, size_t accuracy) const
+vector<Vector> BezierCurve::renderSegment(double start, double end, int accuracy) const
 {
 {
 	if (controlPoints.size() < 2)
 	if (controlPoints.size() < 2)
 		throw Exception("Invalid Bezier curve: Not enough control points.");
 		throw Exception("Invalid Bezier curve: Not enough control points.");

+ 1 - 1
src/modules/math/BezierCurve.h

@@ -136,7 +136,7 @@ public:
 	 * @param accuracy The 'fineness' of the curve.
 	 * @param accuracy The 'fineness' of the curve.
 	 * @returns A polygon chain that approximates the segment along the curve
 	 * @returns A polygon chain that approximates the segment along the curve
 	 **/
 	 **/
-	std::vector<Vector> renderSegment(double start, double end, size_t accuracy = 4) const;
+	std::vector<Vector> renderSegment(double start, double end, int accuracy = 4) const;
 
 
 private:
 private:
 	std::vector<Vector> controlPoints;
 	std::vector<Vector> controlPoints;

+ 1 - 1
src/modules/math/Compressor.cpp

@@ -146,7 +146,7 @@ public:
 		{
 		{
 			// Account for our custom header's size in the decompress arguments.
 			// Account for our custom header's size in the decompress arguments.
 			int result = LZ4_decompress_safe(data + headersize, rawbytes,
 			int result = LZ4_decompress_safe(data + headersize, rawbytes,
-			                                 dataSize - headersize, rawsize);
+			                                 (int) (dataSize - headersize), rawsize);
 
 
 			if (result < 0)
 			if (result < 0)
 			{
 			{

+ 3 - 3
src/modules/math/wrap_BezierCurve.cpp

@@ -196,13 +196,13 @@ int w_BezierCurve_renderSegment(lua_State *L)
 	BezierCurve *curve = luax_checkbeziercurve(L, 1);
 	BezierCurve *curve = luax_checkbeziercurve(L, 1);
 	double start = luaL_checknumber(L, 2);
 	double start = luaL_checknumber(L, 2);
 	double end = luaL_checknumber(L, 3);
 	double end = luaL_checknumber(L, 3);
-	int accuracy = luaL_optinteger(L, 4, 5);
+	int accuracy = (int) luaL_optnumber(L, 4, 5);
 
 
 	std::vector<Vector> points;
 	std::vector<Vector> points;
 	luax_catchexcept(L, [&](){ points = curve->renderSegment(start, end, accuracy); });
 	luax_catchexcept(L, [&](){ points = curve->renderSegment(start, end, 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_pushnumber(L, points[i].x);
 		lua_rawseti(L, -2, 2*i+1);
 		lua_rawseti(L, -2, 2*i+1);

+ 2 - 2
src/modules/sound/lullaby/ModPlugDecoder.cpp

@@ -61,7 +61,7 @@ ModPlugDecoder::ModPlugDecoder(Data *data, const std::string &ext, int bufferSiz
 	ModPlug_SetSettings(&settings);
 	ModPlug_SetSettings(&settings);
 
 
 	// Load the module.
 	// Load the module.
-	plug = ModPlug_Load(data->getData(), data->getSize());
+	plug = ModPlug_Load(data->getData(), (int) data->getSize());
 
 
 	if (plug == 0)
 	if (plug == 0)
 		throw love::Exception("Could not load file with ModPlug.");
 		throw love::Exception("Could not load file with ModPlug.");
@@ -121,7 +121,7 @@ bool ModPlugDecoder::rewind()
 {
 {
 	// Let's reload.
 	// Let's reload.
 	ModPlug_Unload(plug);
 	ModPlug_Unload(plug);
-	plug = ModPlug_Load(data->getData(), data->getSize());
+	plug = ModPlug_Load(data->getData(), (int) data->getSize());
 	ModPlug_SetMasterVolume(plug, 128);
 	ModPlug_SetMasterVolume(plug, 128);
 	eof = false;
 	eof = false;
 	return (plug != 0);
 	return (plug != 0);

+ 1 - 1
src/modules/sound/lullaby/Mpg123Decoder.cpp

@@ -157,7 +157,7 @@ Mpg123Decoder::Mpg123Decoder(Data *data, const std::string &ext, int bufferSize)
 		mpg123_format_none(handle);
 		mpg123_format_none(handle);
 		mpg123_format(handle, rate, channels, MPG123_ENC_SIGNED_16);
 		mpg123_format(handle, rate, channels, MPG123_ENC_SIGNED_16);
 
 
-		sampleRate = rate;
+		sampleRate = (int) rate;
 	}
 	}
 	catch (love::Exception &)
 	catch (love::Exception &)
 	{
 	{

+ 5 - 5
src/modules/sound/lullaby/VorbisDecoder.cpp

@@ -76,9 +76,9 @@ static int vorbisSeek(void *datasource	/* ptr to the data that the vorbis files
 			   ogg_int64_t offset	/*offset from the point we wish to seek to*/,
 			   ogg_int64_t offset	/*offset from the point we wish to seek to*/,
 			   int whence			/*where we want to seek to*/)
 			   int whence			/*where we want to seek to*/)
 {
 {
-	int         spaceToEOF;   // How much more we can read till we hit the EOF marker
-	ogg_int64_t actualOffset; // How much we can actually offset it by
-	SOggFile   *vorbisData;   // The data we passed in (for the typecast)
+	int64    spaceToEOF;   // How much more we can read till we hit the EOF marker
+	int64    actualOffset; // How much we can actually offset it by
+	SOggFile *vorbisData;  // The data we passed in (for the typecast)
 
 
 	// Get the data in the right format
 	// Get the data in the right format
 	vorbisData = (SOggFile *) datasource;
 	vorbisData = (SOggFile *) datasource;
@@ -103,7 +103,7 @@ static int vorbisSeek(void *datasource	/* ptr to the data that the vorbis files
 		else
 		else
 			actualOffset = spaceToEOF;
 			actualOffset = spaceToEOF;
 		// Seek from our currrent location
 		// Seek from our currrent location
-		vorbisData->dataRead += (int)actualOffset;
+		vorbisData->dataRead += actualOffset;
 		break;
 		break;
 	case SEEK_END: // Seek from the end of the file
 	case SEEK_END: // Seek from the end of the file
 		if (offset < 0)
 		if (offset < 0)
@@ -147,7 +147,7 @@ VorbisDecoder::VorbisDecoder(Data *data, const std::string &ext, int bufferSize)
 
 
 	// Initialize OGG file
 	// Initialize OGG file
 	oggFile.dataPtr = (const char *) data->getData();
 	oggFile.dataPtr = (const char *) data->getData();
-	oggFile.dataSize = (int) data->getSize();
+	oggFile.dataSize = data->getSize();
 	oggFile.dataRead = 0;
 	oggFile.dataRead = 0;
 
 
 	// Open Vorbis handle
 	// Open Vorbis handle

+ 3 - 2
src/modules/sound/lullaby/VorbisDecoder.h

@@ -23,6 +23,7 @@
 
 
 // LOVE
 // LOVE
 #include "common/Data.h"
 #include "common/Data.h"
+#include "common/int.h"
 #include "Decoder.h"
 #include "Decoder.h"
 
 
 // vorbis
 // vorbis
@@ -41,8 +42,8 @@ namespace lullaby
 struct SOggFile
 struct SOggFile
 {
 {
 	const char *dataPtr;	// Pointer to the data in memory
 	const char *dataPtr;	// Pointer to the data in memory
-	int dataSize;	// Size of the data
-	int dataRead;	// How much we've read so far
+	int64 dataSize;	// Size of the data
+	int64 dataRead;	// How much we've read so far
 };
 };
 
 
 class VorbisDecoder : public Decoder
 class VorbisDecoder : public Decoder