From 57f9cf439e7fa9a230a0f83eae068499a01cd610 Mon Sep 17 00:00:00 2001 From: Bill Meltsner Date: Wed, 12 Oct 2011 14:03:38 -0500 Subject: [PATCH] Add LOVE_UNUSED macro to stamp out all those "unused parameter" warnings --- src/common/Exception.cpp | 2 + src/common/config.h | 4 + src/modules/graphics/opengl/Graphics.cpp | 1 + src/modules/graphics/opengl/VertexBuffer.cpp | 154 ++++++++++--------- src/modules/thread/sdl/threads.h | 7 +- src/modules/thread/threads.h | 2 +- 6 files changed, 90 insertions(+), 80 deletions(-) diff --git a/src/common/Exception.cpp b/src/common/Exception.cpp index 8d0a9ed6e..ca804345a 100644 --- a/src/common/Exception.cpp +++ b/src/common/Exception.cpp @@ -19,6 +19,7 @@ **/ #include "Exception.h" +#include namespace love { @@ -32,6 +33,7 @@ namespace love Exception::Exception(int unparsed, const char * str) { + LOVE_UNUSED(unparsed); strncpy(buffer, str, BUFFER_SIZE); } diff --git a/src/common/config.h b/src/common/config.h index bfd8f80c7..ae35a6069 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -48,6 +48,10 @@ # define _CRT_SECURE_NO_WARNINGS #endif +#ifndef LOVE_UNUSED +# define LOVE_UNUSED(x) (void)sizeof(x) +#endif + #ifndef LOVE_BUILD # define LOVE_BUILD # define LOVE_BUILD_STANDALONE diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index 15b21a64d..3614c6651 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -734,6 +734,7 @@ namespace opengl // glEnable (GL_POLYGON_SMOOTH); // glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST); //} + LOVE_UNUSED(style); } void Graphics::setLine( float width, Graphics::LineStyle style ) diff --git a/src/modules/graphics/opengl/VertexBuffer.cpp b/src/modules/graphics/opengl/VertexBuffer.cpp index 7953e28ea..9bedca37a 100644 --- a/src/modules/graphics/opengl/VertexBuffer.cpp +++ b/src/modules/graphics/opengl/VertexBuffer.cpp @@ -21,6 +21,7 @@ #include "VertexBuffer.h" #include "common/Exception.h" +#include #include #include @@ -61,13 +62,13 @@ namespace opengl } // VertexBuffer::Bind - - VertexBuffer::Bind::Bind(VertexBuffer &buf) - : buf(buf) - { - buf.bind(); - } - + + VertexBuffer::Bind::Bind(VertexBuffer &buf) + : buf(buf) + { + buf.bind(); + } + VertexBuffer::Bind::~Bind() { buf.unbind(); @@ -86,23 +87,24 @@ namespace opengl delete [] buf; } - void *VertexArray::map(GLenum access) - { - return buf; - } - - void VertexArray::unmap() - { - } - - void VertexArray::bind() - { - } - - void VertexArray::unbind() - { - } - + void *VertexArray::map(GLenum access) + { + LOVE_UNUSED(access); + return buf; + } + + void VertexArray::unmap() + { + } + + void VertexArray::bind() + { + } + + void VertexArray::unbind() + { + } + void VertexArray::fill(int offset, int size, const void *data) { memcpy(buf + offset, data, size); @@ -136,33 +138,33 @@ namespace opengl unload(false); } - void *VBO::map(GLenum access) - { - // Don't map twice. - if (mapped) - return mapped; - - mapped = glMapBufferARB(getTarget(), access); - - return mapped; - } - - void VBO::unmap() - { - glUnmapBufferARB(getTarget()); - mapped = 0; - } - - void VBO::bind() - { - glBindBufferARB(getTarget(), vbo); - } - - void VBO::unbind() - { - glBindBufferARB(getTarget(), 0); - } - + void *VBO::map(GLenum access) + { + // Don't map twice. + if (mapped) + return mapped; + + mapped = glMapBufferARB(getTarget(), access); + + return mapped; + } + + void VBO::unmap() + { + glUnmapBufferARB(getTarget()); + mapped = 0; + } + + void VBO::bind() + { + glBindBufferARB(getTarget(), vbo); + } + + void VBO::unbind() + { + glBindBufferARB(getTarget(), 0); + } + void VBO::fill(int offset, int size, const void *data) { if (mapped) @@ -176,35 +178,35 @@ namespace opengl return reinterpret_cast(offset); } - bool VBO::loadVolatile() - { - return load(true); - } - - void VBO::unloadVolatile() - { - unload(true); + bool VBO::loadVolatile() + { + return load(true); } - bool VBO::load(bool restore) - { - glGenBuffersARB(1, &vbo); - - VertexBuffer::Bind bind(*this); - - // Copy the old buffer only if 'restore' was requested. - const GLvoid *src = restore ? buffer_copy : 0; - - // Note that if 'src' is '0', no data will be copied. - glBufferDataARB(getTarget(), getSize(), src, getUsage()); - + void VBO::unloadVolatile() + { + unload(true); + } + + bool VBO::load(bool restore) + { + glGenBuffersARB(1, &vbo); + + VertexBuffer::Bind bind(*this); + + // Copy the old buffer only if 'restore' was requested. + const GLvoid *src = restore ? buffer_copy : 0; + + // Note that if 'src' is '0', no data will be copied. + glBufferDataARB(getTarget(), getSize(), src, getUsage()); + // Clean up buffer_copy, if it exists. delete[] buffer_copy; - buffer_copy = 0; - - return true; - } - + buffer_copy = 0; + + return true; + } + void VBO::unload(bool save) { // Clean up buffer_copy, if it exists. diff --git a/src/modules/thread/sdl/threads.h b/src/modules/thread/sdl/threads.h index 0b73f8e88..693a21b1e 100644 --- a/src/modules/thread/sdl/threads.h +++ b/src/modules/thread/sdl/threads.h @@ -22,6 +22,7 @@ #define LOVE_THREAD_SDL_THREADS_H #include "SDL.h" +#include namespace love { @@ -31,7 +32,7 @@ namespace thread class Mutex { private: SDL_mutex* mutex; - Mutex(const Mutex& mutex) {} + Mutex(const Mutex& mutex) {LOVE_UNUSED(mutex);} friend class Conditional; @@ -48,7 +49,7 @@ namespace thread class ThreadBase { private: SDL_Thread* thread; - ThreadBase(ThreadBase& thread) {} + ThreadBase(ThreadBase& thread) {LOVE_UNUSED(thread);} bool running; static int thread_runner(void* param); @@ -70,7 +71,7 @@ namespace thread class Semaphore { private: - Semaphore(const Semaphore& sem) {} + Semaphore(const Semaphore& sem) {LOVE_UNUSED(sem);} SDL_sem* semaphore; public: diff --git a/src/modules/thread/threads.h b/src/modules/thread/threads.h index c8f94845a..eb431e484 100644 --- a/src/modules/thread/threads.h +++ b/src/modules/thread/threads.h @@ -63,7 +63,7 @@ namespace thread private: Mutex* mutex; - Lock(Lock& lock) {} + Lock(Lock& lock) {LOVE_UNUSED(lock);} public: Lock(Mutex* m): mutex(m) {