Address some compiler warnings about implicit integer conversions.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2016-10-18 22:32:35 -03:00
parent 2e016810c9
commit 0653ec9564
23 changed files with 44 additions and 43 deletions
+1 -1
View File
@@ -103,7 +103,7 @@ public:
virtual int getChannels() 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;
+1 -1
View File
@@ -222,7 +222,7 @@ int Source::getFreeBufferCount() const
return 0;
}
bool Source::queue(void *, int, int, int, int)
bool Source::queue(void *, size_t, int, int, int)
{
return false;
}
+1 -1
View File
@@ -77,7 +77,7 @@ public:
virtual int getChannels() 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:
+4 -4
View File
@@ -663,7 +663,7 @@ bool Source::isLooping() const
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)
throw QueueTypeMismatchException();
@@ -883,7 +883,7 @@ bool Source::playAtomic(const std::vector<love::audio::Source*> &sources, const
}
alGetError();
alSourcePlayv(toPlay.size(), &toPlay[0]);
alSourcePlayv((ALsizei) toPlay.size(), &toPlay[0]);
bool success = alGetError() == AL_NO_ERROR;
for (auto &_source : sources)
@@ -912,7 +912,7 @@ void Source::stopAtomic(const std::vector<love::audio::Source*> &sources)
sourceIds.push_back(source->source);
}
alSourceStopv(sources.size(), &sourceIds[0]);
alSourceStopv((ALsizei) sources.size(), &sourceIds[0]);
for (auto &_source : sources)
{
@@ -936,7 +936,7 @@ void Source::pauseAtomic(const std::vector<love::audio::Source*> &sources)
sourceIds.push_back(source->source);
}
alSourcePausev(sources.size(), &sourceIds[0]);
alSourcePausev((ALsizei) sources.size(), &sourceIds[0]);
}
void Source::reset()
+1 -1
View File
@@ -142,7 +142,7 @@ public:
virtual int getChannels() 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);
void prepareAtomic();
+4 -4
View File
@@ -101,10 +101,10 @@ static std::vector<Source*> readSourceList(lua_State *L, int n)
if (n < 0)
n += lua_gettop(L) + 1;
size_t items = lua_objlen(L, n);
int items = (int) lua_objlen(L, n);
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);
sources[i] = luax_checksource(L, -1);
@@ -147,8 +147,8 @@ int w_pause(lua_State *L)
{
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]);
lua_rawseti(L, -2, i+1);
+5 -5
View File
@@ -344,10 +344,10 @@ int w_Source_queue(lua_State *L)
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 length = s->getSize();
size_t length = s->getSize();
if (lua_gettop(L) == 4)
{
@@ -357,12 +357,12 @@ int w_Source_queue(lua_State *L)
else if (lua_gettop(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.");
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))
@@ -76,7 +76,7 @@ GlyphData *TrueTypeRasterizer::getGlyphData(uint32 glyph) const
FT_Glyph ftglyph;
FT_Error err = FT_Err_Ok;
FT_ULong loadoption = hintingToLoadOption(hinting);
FT_UInt loadoption = hintingToLoadOption(hinting);
// Initialize
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;
}
FT_ULong TrueTypeRasterizer::hintingToLoadOption(Hinting hint)
FT_UInt TrueTypeRasterizer::hintingToLoadOption(Hinting hint)
{
switch (hint)
{
@@ -58,7 +58,7 @@ public:
private:
static FT_ULong hintingToLoadOption(Hinting hinting);
static FT_UInt hintingToLoadOption(Hinting hinting);
// TrueType face
FT_Face face;
+1 -1
View File
@@ -629,7 +629,7 @@ love::image::ImageData *Canvas::newImageData(love::image::Image *image, int x, i
break;
}
int size = w * h * image::ImageData::getPixelSize(imageformat);
size_t size = w * h * image::ImageData::getPixelSize(imageformat);
uint8 *pixels = nullptr;
try
{
+1 -1
View File
@@ -1299,7 +1299,7 @@ void Graphics::points(const float *coords, const uint8 *colors, size_t numpoints
}
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)
+1 -1
View File
@@ -569,7 +569,7 @@ int Mesh::bindAttributeToShaderInput(int attributeindex, const std::string &inpu
GLenum datatype = getGLDataType(format.type);
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;
}
+1 -1
View File
@@ -420,7 +420,7 @@ void Shader::attach(bool temporary)
{
// make sure all sent textures are properly bound to their respective texture units
// 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)
gl.bindTextureToUnit(activeTexUnits[i], i + 1, false);
+2 -2
View File
@@ -131,7 +131,7 @@ int w_Mesh_setVertices(lua_State *L)
}
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())
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;
for (size_t i = 0; i < nvertices; i++)
for (int i = 0; i < nvertices; i++)
{
// get vertices[vertindex]
lua_rawgeti(L, 2, i + 1);
+1 -1
View File
@@ -39,7 +39,7 @@ void luax_checkcoloredstring(lua_State *L, int idx, std::vector<Font::ColoredStr
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++)
{
+1 -1
View File
@@ -233,7 +233,7 @@ vector<Vector> BezierCurve::render(int accuracy) const
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)
throw Exception("Invalid Bezier curve: Not enough control points.");
+1 -1
View File
@@ -136,7 +136,7 @@ public:
* @param accuracy The 'fineness' of 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:
std::vector<Vector> controlPoints;
+1 -1
View File
@@ -146,7 +146,7 @@ public:
{
// Account for our custom header's size in the decompress arguments.
int result = LZ4_decompress_safe(data + headersize, rawbytes,
dataSize - headersize, rawsize);
(int) (dataSize - headersize), rawsize);
if (result < 0)
{
+3 -3
View File
@@ -196,13 +196,13 @@ int w_BezierCurve_renderSegment(lua_State *L)
BezierCurve *curve = luax_checkbeziercurve(L, 1);
double start = luaL_checknumber(L, 2);
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;
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_rawseti(L, -2, 2*i+1);
+2 -2
View File
@@ -61,7 +61,7 @@ ModPlugDecoder::ModPlugDecoder(Data *data, const std::string &ext, int bufferSiz
ModPlug_SetSettings(&settings);
// Load the module.
plug = ModPlug_Load(data->getData(), data->getSize());
plug = ModPlug_Load(data->getData(), (int) data->getSize());
if (plug == 0)
throw love::Exception("Could not load file with ModPlug.");
@@ -121,7 +121,7 @@ bool ModPlugDecoder::rewind()
{
// Let's reload.
ModPlug_Unload(plug);
plug = ModPlug_Load(data->getData(), data->getSize());
plug = ModPlug_Load(data->getData(), (int) data->getSize());
ModPlug_SetMasterVolume(plug, 128);
eof = false;
return (plug != 0);
+1 -1
View File
@@ -157,7 +157,7 @@ Mpg123Decoder::Mpg123Decoder(Data *data, const std::string &ext, int bufferSize)
mpg123_format_none(handle);
mpg123_format(handle, rate, channels, MPG123_ENC_SIGNED_16);
sampleRate = rate;
sampleRate = (int) rate;
}
catch (love::Exception &)
{
+5 -5
View File
@@ -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*/,
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
vorbisData = (SOggFile *) datasource;
@@ -103,7 +103,7 @@ static int vorbisSeek(void *datasource /* ptr to the data that the vorbis files
else
actualOffset = spaceToEOF;
// Seek from our currrent location
vorbisData->dataRead += (int)actualOffset;
vorbisData->dataRead += actualOffset;
break;
case SEEK_END: // Seek from the end of the file
if (offset < 0)
@@ -147,7 +147,7 @@ VorbisDecoder::VorbisDecoder(Data *data, const std::string &ext, int bufferSize)
// Initialize OGG file
oggFile.dataPtr = (const char *) data->getData();
oggFile.dataSize = (int) data->getSize();
oggFile.dataSize = data->getSize();
oggFile.dataRead = 0;
// Open Vorbis handle
+3 -2
View File
@@ -23,6 +23,7 @@
// LOVE
#include "common/Data.h"
#include "common/int.h"
#include "Decoder.h"
// vorbis
@@ -41,8 +42,8 @@ namespace lullaby
struct SOggFile
{
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