Browse Source

Automated formatting fix

Bart van Strien 13 years ago
parent
commit
0aae9684b3
100 changed files with 4371 additions and 4289 deletions
  1. 56 56
      src/common/Data.h
  2. 10 10
      src/common/EnumMap.h
  3. 62 61
      src/common/Exception.cpp
  4. 64 64
      src/common/Exception.h
  5. 196 196
      src/common/Matrix.cpp
  6. 166 166
      src/common/Matrix.h
  7. 5 5
      src/common/Memoizer.cpp
  8. 5 5
      src/common/Memoizer.h
  9. 6 6
      src/common/Module.h
  10. 1 1
      src/common/Object.cpp
  11. 70 70
      src/common/Reference.cpp
  12. 6 6
      src/common/Reference.h
  13. 16 16
      src/common/StringMap.h
  14. 25 25
      src/common/Vector.cpp
  15. 310 310
      src/common/Vector.h
  16. 13 12
      src/common/b64.cpp
  17. 3 3
      src/common/b64.h
  18. 3 3
      src/common/config.h
  19. 85 85
      src/common/math.h
  20. 475 474
      src/common/runtime.cpp
  21. 5 5
      src/common/runtime.h
  22. 173 173
      src/common/types.h
  23. 5 5
      src/common/utf8.cpp
  24. 3 3
      src/common/utf8.h
  25. 4 4
      src/common/wrap_Data.cpp
  26. 3 3
      src/common/wrap_Data.h
  27. 12 11
      src/love.cpp
  28. 199 199
      src/modules/audio/Audio.h
  29. 73 73
      src/modules/audio/Source.cpp
  30. 107 107
      src/modules/audio/Source.h
  31. 7 7
      src/modules/audio/null/Audio.cpp
  32. 4 4
      src/modules/audio/null/Audio.h
  33. 2 2
      src/modules/audio/null/Source.cpp
  34. 78 78
      src/modules/audio/null/Source.h
  35. 33 25
      src/modules/audio/openal/Audio.cpp
  36. 5 5
      src/modules/audio/openal/Audio.h
  37. 18 18
      src/modules/audio/openal/Pool.cpp
  38. 3 3
      src/modules/audio/openal/Pool.h
  39. 47 40
      src/modules/audio/openal/Source.cpp
  40. 1 1
      src/modules/audio/openal/Source.h
  41. 318 315
      src/modules/audio/wrap_Audio.cpp
  42. 58 58
      src/modules/audio/wrap_Audio.h
  43. 253 253
      src/modules/audio/wrap_Source.cpp
  44. 59 59
      src/modules/audio/wrap_Source.h
  45. 8 5
      src/modules/event/sdl/Event.cpp
  46. 10 10
      src/modules/event/sdl/Event.h
  47. 233 233
      src/modules/event/sdl/wrap_Event.cpp
  48. 47 47
      src/modules/event/sdl/wrap_Event.h
  49. 4 4
      src/modules/filesystem/File.cpp
  50. 15 15
      src/modules/filesystem/File.h
  51. 5 5
      src/modules/filesystem/FileData.cpp
  52. 4 4
      src/modules/filesystem/FileData.h
  53. 24 24
      src/modules/filesystem/physfs/File.cpp
  54. 4 4
      src/modules/filesystem/physfs/File.h
  55. 59 54
      src/modules/filesystem/physfs/Filesystem.cpp
  56. 16 14
      src/modules/filesystem/physfs/wrap_File.cpp
  57. 3 3
      src/modules/filesystem/physfs/wrap_File.h
  58. 4 4
      src/modules/filesystem/physfs/wrap_FileData.cpp
  59. 3 3
      src/modules/filesystem/physfs/wrap_FileData.h
  60. 23 20
      src/modules/filesystem/physfs/wrap_Filesystem.cpp
  61. 3 3
      src/modules/filesystem/physfs/wrap_Filesystem.h
  62. 3 3
      src/modules/font/Font.h
  63. 3 2
      src/modules/font/GlyphData.cpp
  64. 10 10
      src/modules/font/GlyphData.h
  65. 10 9
      src/modules/font/ImageRasterizer.cpp
  66. 7 7
      src/modules/font/ImageRasterizer.h
  67. 3 3
      src/modules/font/Rasterizer.cpp
  68. 5 5
      src/modules/font/Rasterizer.h
  69. 7 6
      src/modules/font/freetype/Font.cpp
  70. 6 6
      src/modules/font/freetype/Font.h
  71. 14 14
      src/modules/font/freetype/TrueTypeRasterizer.cpp
  72. 4 4
      src/modules/font/freetype/TrueTypeRasterizer.h
  73. 110 108
      src/modules/font/freetype/wrap_Font.cpp
  74. 42 42
      src/modules/font/freetype/wrap_Font.h
  75. 44 44
      src/modules/font/wrap_GlyphData.cpp
  76. 40 40
      src/modules/font/wrap_GlyphData.h
  77. 44 44
      src/modules/font/wrap_Rasterizer.cpp
  78. 38 38
      src/modules/font/wrap_Rasterizer.h
  79. 33 33
      src/modules/graphics/DrawQable.cpp
  80. 4 4
      src/modules/graphics/DrawQable.h
  81. 33 33
      src/modules/graphics/Drawable.cpp
  82. 4 4
      src/modules/graphics/Drawable.h
  83. 14 14
      src/modules/graphics/Image.cpp
  84. 10 10
      src/modules/graphics/Image.h
  85. 36 36
      src/modules/graphics/Quad.cpp
  86. 3 3
      src/modules/graphics/Quad.h
  87. 6 6
      src/modules/graphics/Volatile.cpp
  88. 6 6
      src/modules/graphics/Volatile.h
  89. 20 19
      src/modules/graphics/opengl/Canvas.cpp
  90. 2 2
      src/modules/graphics/opengl/Canvas.h
  91. 42 31
      src/modules/graphics/opengl/Font.cpp
  92. 8 8
      src/modules/graphics/opengl/Font.h
  93. 70 48
      src/modules/graphics/opengl/Graphics.cpp
  94. 1 1
      src/modules/graphics/opengl/Graphics.h
  95. 7 7
      src/modules/graphics/opengl/Image.cpp
  96. 16 16
      src/modules/graphics/opengl/ParticleSystem.cpp
  97. 9 9
      src/modules/graphics/opengl/ParticleSystem.h
  98. 14 7
      src/modules/graphics/opengl/PixelEffect.cpp
  99. 124 123
      src/modules/graphics/opengl/Quad.cpp
  100. 7 7
      src/modules/graphics/opengl/SpriteBatch.cpp

+ 56 - 56
src/common/Data.h

@@ -1,56 +1,56 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-* 
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-* 
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-* 
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#ifndef LOVE_DATA_H
-#define LOVE_DATA_H
-
-// LOVE
-#include "config.h"
-#include "Object.h"
-
-namespace love
-{	
-	/**
-	* This class is a simple abstraction over all objects which contain data. 
-	**/
-	class Data : public Object
-	{
-	public:
-
-		/**
-		* Destructor.
-		**/
-		virtual ~Data() {};
-
-		/**
-		* Gets a pointer to the data. This pointer will obviously not
-		* be valid if the Data object is destroyed.
-		**/
-		virtual void * getData() const = 0 ;
-
-		/**
-		* Gets the size of the Data in bytes.
-		**/
-		virtual int getSize() const = 0;
-
-	}; // Data
-} // love
-
-#endif // LOVE_DATA_H
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#ifndef LOVE_DATA_H
+#define LOVE_DATA_H
+
+// LOVE
+#include "config.h"
+#include "Object.h"
+
+namespace love
+{
+	/**
+	* This class is a simple abstraction over all objects which contain data.
+	**/
+	class Data : public Object
+	{
+	public:
+
+		/**
+		* Destructor.
+		**/
+		virtual ~Data() {};
+
+		/**
+		* Gets a pointer to the data. This pointer will obviously not
+		* be valid if the Data object is destroyed.
+		**/
+		virtual void * getData() const = 0 ;
+
+		/**
+		* Gets the size of the Data in bytes.
+		**/
+		virtual int getSize() const = 0;
+
+	}; // Data
+} // love
+
+#endif // LOVE_DATA_H

+ 10 - 10
src/common/EnumMap.h

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -41,7 +41,7 @@ namespace love
 		Value values_u[PEAK];
 
 	public:
-		
+
 		struct Entry
 		{
 			T t;
@@ -52,27 +52,27 @@ namespace love
 		{
 			unsigned n = size/sizeof(Entry);
 
-			for(unsigned i = 0; i<n; ++i)
+			for (unsigned i = 0; i<n; ++i)
 			{
 				unsigned e_t = (unsigned)entries[i].t;
 				unsigned e_u = (unsigned)entries[i].u;
 
-				if(e_t < PEAK)
+				if (e_t < PEAK)
 				{
 					values_u[e_t].v = e_u;
 					values_u[e_t].set = true;
 				}
-				if(e_u < PEAK)
+				if (e_u < PEAK)
 				{
 					values_t[e_u].v = e_t;
 					values_t[e_u].set = true;
 				}
 			}
 		}
-			
+
 		bool find(T t, U & u)
 		{
-			if((unsigned)t < PEAK && values_u[(unsigned)t].set)
+			if ((unsigned)t < PEAK && values_u[(unsigned)t].set)
 			{
 				u = (U)values_u[(unsigned)t].v;
 				return true;
@@ -83,7 +83,7 @@ namespace love
 
 		bool find(U u, T & t)
 		{
-			if((unsigned)u < PEAK && values_t[(unsigned)u].set)
+			if ((unsigned)u < PEAK && values_t[(unsigned)u].set)
 			{
 				t = (T)values_t[(unsigned)u].v;
 				return true;

+ 62 - 61
src/common/Exception.cpp

@@ -1,61 +1,62 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-* 
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-* 
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-* 
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#include "Exception.h"
-#include <common/config.h>
-#include <iostream>
-using namespace std;
-
-namespace love
-{
-	Exception::Exception(const char * fmt, ...)
-	{
-		va_list args;
-		int size_buffer = 256, size_out;
-		char * buffer;
-		while (true) {
-			buffer = new char[size_buffer];
-			memset(buffer, 0, size_buffer);
-
-			va_start(args, fmt);
-			size_out = vsnprintf(buffer, size_buffer, fmt, args);
-			va_end(args);
-
-			// see http://perfec.to/vsnprintf/pasprintf.c
-			// if size_out ...
-			//      == -1             --> output was truncated
-			//      == size_buffer    --> output was truncated
-			//      == size_buffer-1  --> ambiguous, /may/ have been truncated
-			//       > size_buffer    --> output was truncated, and size_out
-			//                            bytes would have been written
-			if (size_out == size_buffer || size_out == -1 || size_out == size_buffer-1)
-				size_buffer *= 2;
-			else if (size_out > size_buffer)
-				size_buffer = size_out + 2; // to avoid the ambiguous case
-			else
-				break;
-
-			delete[] buffer;
-		}
-		message = std::string(buffer);
-		delete[] buffer;
-	}
-
-}
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#include "Exception.h"
+#include <common/config.h>
+#include <iostream>
+using namespace std;
+
+namespace love
+{
+	Exception::Exception(const char * fmt, ...)
+	{
+		va_list args;
+		int size_buffer = 256, size_out;
+		char * buffer;
+		while (true)
+		{
+			buffer = new char[size_buffer];
+			memset(buffer, 0, size_buffer);
+
+			va_start(args, fmt);
+			size_out = vsnprintf(buffer, size_buffer, fmt, args);
+			va_end(args);
+
+			// see http://perfec.to/vsnprintf/pasprintf.c
+			// if size_out ...
+			//      == -1             --> output was truncated
+			//      == size_buffer    --> output was truncated
+			//      == size_buffer-1  --> ambiguous, /may/ have been truncated
+			//       > size_buffer    --> output was truncated, and size_out
+			//                            bytes would have been written
+			if (size_out == size_buffer || size_out == -1 || size_out == size_buffer-1)
+				size_buffer *= 2;
+			else if (size_out > size_buffer)
+				size_buffer = size_out + 2; // to avoid the ambiguous case
+			else
+				break;
+
+			delete[] buffer;
+		}
+		message = std::string(buffer);
+		delete[] buffer;
+	}
+
+}

+ 64 - 64
src/common/Exception.h

@@ -1,64 +1,64 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-* 
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-* 
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-* 
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#ifndef LOVE_EXCEPTION_H
-#define LOVE_EXCEPTION_H
-
-#include <exception>
-#include <cstdarg> // vararg
-#include <cstdio> // vsnprintf
-#include <cstring> // strncpy
-#include <string>
-
-namespace love
-{
-	/**
-	* A convenient vararg-enabled exception class. 
-	**/
-	class Exception : public std::exception
-	{
-	private:
-
-		std::string message;
-
-	public:
-
-		/**
-		* Creates a new Exception according to printf-rules.
-		* 
-		* See: http://www.cplusplus.com/reference/clibrary/cstdio/printf/
-		* 
-		* @param fmt The format string (see printf).
-		**/
-		Exception(const char * fmt, ...);
-		virtual ~Exception() throw() {}
-
-		/**
-		* Returns a string containing reason for the exception.
-		* @return A description of the exception.
-		**/
-		inline virtual const char * what() const throw()
-		{ return message.c_str(); }
-
-	}; // class
-
-} // love
-
-#endif // LOVE_EXCEPTION_H
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#ifndef LOVE_EXCEPTION_H
+#define LOVE_EXCEPTION_H
+
+#include <exception>
+#include <cstdarg> // vararg
+#include <cstdio> // vsnprintf
+#include <cstring> // strncpy
+#include <string>
+
+namespace love
+{
+	/**
+	* A convenient vararg-enabled exception class.
+	**/
+	class Exception : public std::exception
+	{
+	private:
+
+		std::string message;
+
+	public:
+
+		/**
+		* Creates a new Exception according to printf-rules.
+		*
+		* See: http://www.cplusplus.com/reference/clibrary/cstdio/printf/
+		*
+		* @param fmt The format string (see printf).
+		**/
+		Exception(const char * fmt, ...);
+		virtual ~Exception() throw() {}
+
+		/**
+		* Returns a string containing reason for the exception.
+		* @return A description of the exception.
+		**/
+		inline virtual const char * what() const throw()
+		{ return message.c_str(); }
+
+	}; // class
+
+} // love
+
+#endif // LOVE_EXCEPTION_H

+ 196 - 196
src/common/Matrix.cpp

@@ -1,196 +1,196 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-* 
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-* 
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-* 
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#include "Matrix.h"
-
-// STD
-#include <cstring> // memcpy
-#include <cmath>
-
-namespace love
-{
-
-	// | e0 e4 e8  e12 |
-	// | e1 e5 e9  e13 |
-	// | e2 e6 e10 e14 |
-	// | e3 e7 e11 e15 |
-
-	Matrix::Matrix()
-	{
-		setIdentity();
-	}
-
-	Matrix::~Matrix()
-	{
-	}
-
-	//                 | e0 e4 e8  e12 |
-	//                 | e1 e5 e9  e13 |
-	//                 | e2 e6 e10 e14 |
-	//                 | e3 e7 e11 e15 |
-	// | e0 e4 e8  e12 |
-	// | e1 e5 e9  e13 |
-	// | e2 e6 e10 e14 |
-	// | e3 e7 e11 e15 |
-
-	Matrix Matrix::operator * (const Matrix & m) const
-	{
-		Matrix t;
-		
-		t.e[0] = (e[0]*m.e[0]) + (e[4]*m.e[1]) + (e[8]*m.e[2]) + (e[12]*m.e[3]);
-		t.e[4] = (e[0]*m.e[4]) + (e[4]*m.e[5]) + (e[8]*m.e[6]) + (e[12]*m.e[7]);
-		t.e[8] = (e[0]*m.e[8]) + (e[4]*m.e[9]) + (e[8]*m.e[10]) + (e[12]*m.e[11]);
-		t.e[12] = (e[0]*m.e[12]) + (e[4]*m.e[13]) + (e[8]*m.e[14]) + (e[12]*m.e[15]);
-
-		t.e[1] = (e[1]*m.e[0]) + (e[5]*m.e[1]) + (e[9]*m.e[2]) + (e[13]*m.e[3]);
-		t.e[5] = (e[1]*m.e[4]) + (e[5]*m.e[5]) + (e[9]*m.e[6]) + (e[13]*m.e[7]);
-		t.e[9] = (e[1]*m.e[8]) + (e[5]*m.e[9]) + (e[9]*m.e[10]) + (e[13]*m.e[11]);
-		t.e[13] = (e[1]*m.e[12]) + (e[5]*m.e[13]) + (e[9]*m.e[14]) + (e[13]*m.e[15]);
-
-		t.e[2] = (e[2]*m.e[0]) + (e[6]*m.e[1]) + (e[10]*m.e[2]) + (e[14]*m.e[3]);
-		t.e[6] = (e[2]*m.e[4]) + (e[6]*m.e[5]) + (e[10]*m.e[6]) + (e[14]*m.e[7]);
-		t.e[10] = (e[2]*m.e[8]) + (e[6]*m.e[9]) + (e[10]*m.e[10]) + (e[14]*m.e[11]);
-		t.e[14] = (e[2]*m.e[12]) + (e[6]*m.e[13]) + (e[10]*m.e[14]) + (e[14]*m.e[15]);
-
-		t.e[3] = (e[3]*m.e[0]) + (e[7]*m.e[1]) + (e[11]*m.e[2]) + (e[15]*m.e[3]);
-		t.e[7] = (e[3]*m.e[4]) + (e[7]*m.e[5]) + (e[11]*m.e[6]) + (e[15]*m.e[7]);
-		t.e[11] = (e[3]*m.e[8]) + (e[7]*m.e[9]) + (e[11]*m.e[10]) + (e[15]*m.e[11]);
-		t.e[15] = (e[3]*m.e[12]) + (e[7]*m.e[13]) + (e[11]*m.e[14]) + (e[15]*m.e[15]);
-
-		return t;
-	}
-
-	void Matrix::operator *= (const Matrix & m)
-	{
-		Matrix t = (*this) * m;
-		memcpy((void*)this->e, (void*)t.e, sizeof(float)*16);
-	}
-
-	const float * Matrix::getElements() const
-	{
-		return e;
-	}
-
-	void Matrix::setIdentity()
-	{
-		memset(e, 0, sizeof(float)*16);
-		e[0] = e[5] = e[10] = e[15] = 1;
-	}
-
-	void Matrix::setTranslation(float x, float y)
-	{
-		setIdentity();
-		e[12] = x;
-		e[13] = y;
-	}
-
-	void Matrix::setRotation(float rad)
-	{
-		setIdentity();
-		float c = cos(rad), s = sin(rad);
-		e[0] = c; e[4] = -s;
-		e[1] = s; e[5] = c;
-	}
-
-	void Matrix::setScale(float sx, float sy)
-	{
-		setIdentity();
-		e[0] = sx;
-		e[5] = sy;
-	}
-
-	void Matrix::setShear(float kx, float ky)
-	{
-		setIdentity();
-		e[1] = ky;
-		e[4] = kx;
-	}
-
-	void Matrix::setTransformation(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
-	{
-		memset(e, 0, sizeof(float)*16); // zero out matrix
-		float c = cos(angle), s = sin(angle);
-		// matrix multiplication carried out on paper:
-		// |1     x| |c -s    | |sx       | | 1 ky    | |1     -ox|
-		// |  1   y| |s  c    | |   sy    | |kx  1    | |  1   -oy|
-		// |    1  | |     1  | |      1  | |      1  | |    1    |
-		// |      1| |       1| |        1| |        1| |       1 |
-		//   move      rotate      scale       skew       origin
-		e[10] = e[15] = 1.0f;
-		e[0]  = c * sx - ky * s * sy; // = a
-		e[1]  = s * sx + ky * c * sy; // = b
-		e[4]  = kx * c * sx - s * sy; // = c
-		e[5]  = kx * s * sx + c * sy; // = d
-		e[12] = x - ox * e[0] - oy * e[4];
-		e[13] = y - ox * e[1] - oy * e[5];
-	}
-
-	void Matrix::translate(float x, float y)
-	{
-		Matrix t;
-		t.setTranslation(x, y);
-		this->operator *=(t);
-	}
-
-	void Matrix::rotate(float rad)
-	{
-		Matrix t;
-		t.setRotation(rad);
-		this->operator *=(t);
-	}
-
-	void Matrix::scale(float sx, float sy)
-	{
-		Matrix t;
-		t.setScale(sx, sy);
-		this->operator *=(t);
-	}
-
-	void Matrix::shear(float kx, float ky)
-	{
-		Matrix t;
-		t.setShear(kx,ky);
-		this->operator *=(t);
-	}
-
-	//                 | x |
-	//                 | y |
-	//                 | 0 |
-	//                 | 1 |
-	// | e0 e4 e8  e12 |
-	// | e1 e5 e9  e13 |
-	// | e2 e6 e10 e14 |
-	// | e3 e7 e11 e15 |
-
-	void Matrix::transform(vertex * dst, const vertex * src, int size) const
-	{
-		for(int i = 0;i<size;i++)
-		{
-			// Store in temp variables in case src = dst
-			float x = (e[0]*src[i].x) + (e[4]*src[i].y) + (0) + (e[12]);
-			float y = (e[1]*src[i].x) + (e[5]*src[i].y) + (0) + (e[13]);
-
-			dst[i].x = x;
-			dst[i].y = y;
-		}
-	}
-
-
-} // love
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#include "Matrix.h"
+
+// STD
+#include <cstring> // memcpy
+#include <cmath>
+
+namespace love
+{
+
+	// | e0 e4 e8  e12 |
+	// | e1 e5 e9  e13 |
+	// | e2 e6 e10 e14 |
+	// | e3 e7 e11 e15 |
+
+	Matrix::Matrix()
+	{
+		setIdentity();
+	}
+
+	Matrix::~Matrix()
+	{
+	}
+
+	//                 | e0 e4 e8  e12 |
+	//                 | e1 e5 e9  e13 |
+	//                 | e2 e6 e10 e14 |
+	//                 | e3 e7 e11 e15 |
+	// | e0 e4 e8  e12 |
+	// | e1 e5 e9  e13 |
+	// | e2 e6 e10 e14 |
+	// | e3 e7 e11 e15 |
+
+	Matrix Matrix::operator * (const Matrix & m) const
+	{
+		Matrix t;
+
+		t.e[0] = (e[0]*m.e[0]) + (e[4]*m.e[1]) + (e[8]*m.e[2]) + (e[12]*m.e[3]);
+		t.e[4] = (e[0]*m.e[4]) + (e[4]*m.e[5]) + (e[8]*m.e[6]) + (e[12]*m.e[7]);
+		t.e[8] = (e[0]*m.e[8]) + (e[4]*m.e[9]) + (e[8]*m.e[10]) + (e[12]*m.e[11]);
+		t.e[12] = (e[0]*m.e[12]) + (e[4]*m.e[13]) + (e[8]*m.e[14]) + (e[12]*m.e[15]);
+
+		t.e[1] = (e[1]*m.e[0]) + (e[5]*m.e[1]) + (e[9]*m.e[2]) + (e[13]*m.e[3]);
+		t.e[5] = (e[1]*m.e[4]) + (e[5]*m.e[5]) + (e[9]*m.e[6]) + (e[13]*m.e[7]);
+		t.e[9] = (e[1]*m.e[8]) + (e[5]*m.e[9]) + (e[9]*m.e[10]) + (e[13]*m.e[11]);
+		t.e[13] = (e[1]*m.e[12]) + (e[5]*m.e[13]) + (e[9]*m.e[14]) + (e[13]*m.e[15]);
+
+		t.e[2] = (e[2]*m.e[0]) + (e[6]*m.e[1]) + (e[10]*m.e[2]) + (e[14]*m.e[3]);
+		t.e[6] = (e[2]*m.e[4]) + (e[6]*m.e[5]) + (e[10]*m.e[6]) + (e[14]*m.e[7]);
+		t.e[10] = (e[2]*m.e[8]) + (e[6]*m.e[9]) + (e[10]*m.e[10]) + (e[14]*m.e[11]);
+		t.e[14] = (e[2]*m.e[12]) + (e[6]*m.e[13]) + (e[10]*m.e[14]) + (e[14]*m.e[15]);
+
+		t.e[3] = (e[3]*m.e[0]) + (e[7]*m.e[1]) + (e[11]*m.e[2]) + (e[15]*m.e[3]);
+		t.e[7] = (e[3]*m.e[4]) + (e[7]*m.e[5]) + (e[11]*m.e[6]) + (e[15]*m.e[7]);
+		t.e[11] = (e[3]*m.e[8]) + (e[7]*m.e[9]) + (e[11]*m.e[10]) + (e[15]*m.e[11]);
+		t.e[15] = (e[3]*m.e[12]) + (e[7]*m.e[13]) + (e[11]*m.e[14]) + (e[15]*m.e[15]);
+
+		return t;
+	}
+
+	void Matrix::operator *= (const Matrix & m)
+	{
+		Matrix t = (*this) * m;
+		memcpy((void*)this->e, (void*)t.e, sizeof(float)*16);
+	}
+
+	const float * Matrix::getElements() const
+	{
+		return e;
+	}
+
+	void Matrix::setIdentity()
+	{
+		memset(e, 0, sizeof(float)*16);
+		e[0] = e[5] = e[10] = e[15] = 1;
+	}
+
+	void Matrix::setTranslation(float x, float y)
+	{
+		setIdentity();
+		e[12] = x;
+		e[13] = y;
+	}
+
+	void Matrix::setRotation(float rad)
+	{
+		setIdentity();
+		float c = cos(rad), s = sin(rad);
+		e[0] = c; e[4] = -s;
+		e[1] = s; e[5] = c;
+	}
+
+	void Matrix::setScale(float sx, float sy)
+	{
+		setIdentity();
+		e[0] = sx;
+		e[5] = sy;
+	}
+
+	void Matrix::setShear(float kx, float ky)
+	{
+		setIdentity();
+		e[1] = ky;
+		e[4] = kx;
+	}
+
+	void Matrix::setTransformation(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
+	{
+		memset(e, 0, sizeof(float)*16); // zero out matrix
+		float c = cos(angle), s = sin(angle);
+		// matrix multiplication carried out on paper:
+		// |1     x| |c -s    | |sx       | | 1 ky    | |1     -ox|
+		// |  1   y| |s  c    | |   sy    | |kx  1    | |  1   -oy|
+		// |    1  | |     1  | |      1  | |      1  | |    1    |
+		// |      1| |       1| |        1| |        1| |       1 |
+		//   move      rotate      scale       skew       origin
+		e[10] = e[15] = 1.0f;
+		e[0]  = c * sx - ky * s * sy; // = a
+		e[1]  = s * sx + ky * c * sy; // = b
+		e[4]  = kx * c * sx - s * sy; // = c
+		e[5]  = kx * s * sx + c * sy; // = d
+		e[12] = x - ox * e[0] - oy * e[4];
+		e[13] = y - ox * e[1] - oy * e[5];
+	}
+
+	void Matrix::translate(float x, float y)
+	{
+		Matrix t;
+		t.setTranslation(x, y);
+		this->operator *=(t);
+	}
+
+	void Matrix::rotate(float rad)
+	{
+		Matrix t;
+		t.setRotation(rad);
+		this->operator *=(t);
+	}
+
+	void Matrix::scale(float sx, float sy)
+	{
+		Matrix t;
+		t.setScale(sx, sy);
+		this->operator *=(t);
+	}
+
+	void Matrix::shear(float kx, float ky)
+	{
+		Matrix t;
+		t.setShear(kx,ky);
+		this->operator *=(t);
+	}
+
+	//                 | x |
+	//                 | y |
+	//                 | 0 |
+	//                 | 1 |
+	// | e0 e4 e8  e12 |
+	// | e1 e5 e9  e13 |
+	// | e2 e6 e10 e14 |
+	// | e3 e7 e11 e15 |
+
+	void Matrix::transform(vertex * dst, const vertex * src, int size) const
+	{
+		for (int i = 0;i<size;i++)
+		{
+			// Store in temp variables in case src = dst
+			float x = (e[0]*src[i].x) + (e[4]*src[i].y) + (0) + (e[12]);
+			float y = (e[1]*src[i].x) + (e[5]*src[i].y) + (0) + (e[13]);
+
+			dst[i].x = x;
+			dst[i].y = y;
+		}
+	}
+
+
+} // love

+ 166 - 166
src/common/Matrix.h

@@ -1,166 +1,166 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-* 
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-* 
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-* 
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#ifndef LOVE_MATRIX_H
-#define LOVE_MATRIX_H
-
-// LOVE
-#include "math.h"
-
-namespace love
-{
-	/**
-	* This class is the basis for all transformations in LOVE. Althought not
-	* really needed for 2D, it contains 4x4 elements to be compatible with 
-	* OpenGL without conversions. 
-	**/
-	class Matrix
-	{
-	private:
-
-		/**
-		* | e0 e4 e8  e12 |
-		* | e1 e5 e9  e13 |
-		* | e2 e6 e10 e14 |
-		* | e3 e7 e11 e15 |
-		**/
-		float e[16];
-
-	public:
-
-		/**
-		* Creates a new identity matrix.
-		**/
-		Matrix();
-
-		/**
-		* Destructor.
-		**/
-		~Matrix();
-
-		/**
-		* Multiplies this Matrix with another Matrix, changing neither.
-		* @param m The Matrix to multiply with this Matrix.
-		* @return The combined matrix.
-		**/
-		Matrix operator * (const Matrix & m) const;
-
-		/**
-		* Multiplies a Matrix into this Matrix.
-		* @param m The Matrix to combine into this Matrix.
-		**/
-		void operator *= (const Matrix & m);
-
-		/**
-		* Gets a pointer to the 16 array elements.
-		* @return The array elements.
-		**/
-		const float * getElements() const;
-
-		/**
-		* Resets this Matrix to the identity matrix.
-		**/
-		void setIdentity();
-
-		/**
-		* Resets this Matrix to a translation.
-		* @param x Translation along x-axis.
-		* @param y Translation along y-axis.
-		**/
-		void setTranslation(float x, float y);
-
-		/**
-		* Resets this Matrix to a rotation.
-		* @param r The angle in radians.
-		**/
-		void setRotation(float r);
-
-		/**
-		* Resets this Matrix to a scale transformation.
-		* @param sx Scale factor along the x-axis.
-		* @param sy Scale factor along the y-axis.
-		**/
-		void setScale(float sx, float sy);
-
-		/**
-		* Resets this Matrix to a shear transformation.
-		* @param kx Shear along x-axis.
-		* @param ky Shear along y-axis.
-		**/
-		void setShear(float kx, float ky);
-
-		/**
-		* Creates a transformation with a certain position, orientation, scale
-		* and offset. Perfect for Drawables -- what a coincidence!
-		* 
-		* @param x The translation along the x-axis.
-		* @param y The translation along the y-axis.
-		* @param angle The rotation (rad) around the center with offset (ox,oy).
-		* @param sx Scale along x-axis.
-		* @param sy Scale along y-axis.
-		* @param ox The offset for rotation along the x-axis.
-		* @param oy The offset for rotation along the y-axis.
-		* @param kx Shear along x-axis
-		* @param ky Shear along y-axis
-		**/
-		void setTransformation(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
-
-		/**
-		* Multiplies this Matrix with a translation.
-		* @param x Translation along x-axis.
-		* @param y Translation along y-axis.
-		**/
-		void translate(float x, float y);
-
-		/**
-		* Multiplies this Matrix with a rotation.
-		* @param r Angle in radians.
-		**/
-		void rotate(float r);
-
-		/**
-		* Multiplies this Matrix with a scale transformation.
-		* @param sx Scale factor along the x-axis.
-		* @param sy Scale factor along the y-axis.
-		**/
-		void scale(float sx, float sy);
-
-		/**
-		* Multiplies this Matrix with a shear transformation.
-		* @param kx Shear along the x-axis.
-		* @param ky Shear along the y-axis.
-		**/
-		void shear(float kx, float ky);
-
-		/**
-		* Transforms an array of vertices by this Matrix. The sources and
-		* destination arrays may be the same. 
-		* 
-		* @param dst Storage for the transformed vertices.
-		* @param src The source vertices.
-		* @param size The number of vertices.
-		**/
-		void transform(vertex * dst, const vertex * src, int size) const;
-
-	}; // Matrix
-
-} //love
-
-#endif// LOVE_MATRIX_H
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#ifndef LOVE_MATRIX_H
+#define LOVE_MATRIX_H
+
+// LOVE
+#include "math.h"
+
+namespace love
+{
+	/**
+	* This class is the basis for all transformations in LOVE. Althought not
+	* really needed for 2D, it contains 4x4 elements to be compatible with
+	* OpenGL without conversions.
+	**/
+	class Matrix
+	{
+	private:
+
+		/**
+		* | e0 e4 e8  e12 |
+		* | e1 e5 e9  e13 |
+		* | e2 e6 e10 e14 |
+		* | e3 e7 e11 e15 |
+		**/
+		float e[16];
+
+	public:
+
+		/**
+		* Creates a new identity matrix.
+		**/
+		Matrix();
+
+		/**
+		* Destructor.
+		**/
+		~Matrix();
+
+		/**
+		* Multiplies this Matrix with another Matrix, changing neither.
+		* @param m The Matrix to multiply with this Matrix.
+		* @return The combined matrix.
+		**/
+		Matrix operator * (const Matrix & m) const;
+
+		/**
+		* Multiplies a Matrix into this Matrix.
+		* @param m The Matrix to combine into this Matrix.
+		**/
+		void operator *= (const Matrix & m);
+
+		/**
+		* Gets a pointer to the 16 array elements.
+		* @return The array elements.
+		**/
+		const float * getElements() const;
+
+		/**
+		* Resets this Matrix to the identity matrix.
+		**/
+		void setIdentity();
+
+		/**
+		* Resets this Matrix to a translation.
+		* @param x Translation along x-axis.
+		* @param y Translation along y-axis.
+		**/
+		void setTranslation(float x, float y);
+
+		/**
+		* Resets this Matrix to a rotation.
+		* @param r The angle in radians.
+		**/
+		void setRotation(float r);
+
+		/**
+		* Resets this Matrix to a scale transformation.
+		* @param sx Scale factor along the x-axis.
+		* @param sy Scale factor along the y-axis.
+		**/
+		void setScale(float sx, float sy);
+
+		/**
+		* Resets this Matrix to a shear transformation.
+		* @param kx Shear along x-axis.
+		* @param ky Shear along y-axis.
+		**/
+		void setShear(float kx, float ky);
+
+		/**
+		* Creates a transformation with a certain position, orientation, scale
+		* and offset. Perfect for Drawables -- what a coincidence!
+		*
+		* @param x The translation along the x-axis.
+		* @param y The translation along the y-axis.
+		* @param angle The rotation (rad) around the center with offset (ox,oy).
+		* @param sx Scale along x-axis.
+		* @param sy Scale along y-axis.
+		* @param ox The offset for rotation along the x-axis.
+		* @param oy The offset for rotation along the y-axis.
+		* @param kx Shear along x-axis
+		* @param ky Shear along y-axis
+		**/
+		void setTransformation(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
+
+		/**
+		* Multiplies this Matrix with a translation.
+		* @param x Translation along x-axis.
+		* @param y Translation along y-axis.
+		**/
+		void translate(float x, float y);
+
+		/**
+		* Multiplies this Matrix with a rotation.
+		* @param r Angle in radians.
+		**/
+		void rotate(float r);
+
+		/**
+		* Multiplies this Matrix with a scale transformation.
+		* @param sx Scale factor along the x-axis.
+		* @param sy Scale factor along the y-axis.
+		**/
+		void scale(float sx, float sy);
+
+		/**
+		* Multiplies this Matrix with a shear transformation.
+		* @param kx Shear along the x-axis.
+		* @param ky Shear along the y-axis.
+		**/
+		void shear(float kx, float ky);
+
+		/**
+		* Transforms an array of vertices by this Matrix. The sources and
+		* destination arrays may be the same.
+		*
+		* @param dst Storage for the transformed vertices.
+		* @param src The source vertices.
+		* @param size The number of vertices.
+		**/
+		void transform(vertex * dst, const vertex * src, int size) const;
+
+	}; // Matrix
+
+} //love
+
+#endif// LOVE_MATRIX_H

+ 5 - 5
src/common/Memoizer.cpp

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -29,12 +29,12 @@ namespace love
 	{
 		objectMap[key] = val;
 	}
-	
+
 	void Memoizer::remove(void * key)
 	{
 		objectMap.erase(key);
 	}
-	
+
 	void * Memoizer::find(void * key)
 	{
 		if (objectMap.count(key)) return objectMap[key];

+ 5 - 5
src/common/Memoizer.h

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -34,9 +34,9 @@ namespace love
 	public:
 
 		static void add(void * key, void * val);
-		
+
 		static void remove(void * key);
-		
+
 		static void * find(void * key);
 
 	}; // Memoizer

+ 6 - 6
src/common/Module.h

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -29,7 +29,7 @@
 namespace love
 {
 	/**
-	* Abstract superclass for all modules. 
+	* Abstract superclass for all modules.
 	**/
 	class Module : public Object
 	{
@@ -43,8 +43,8 @@ namespace love
 		/**
 		* Gets the name of the module. This is used in case of errors
 		* and other messages.
-		* 
-		* @return The full name of the module, eg. love.graphics.opengl. 
+		*
+		* @return The full name of the module, eg. love.graphics.opengl.
 		**/
 		virtual const char * getName() const = 0;
 

+ 1 - 1
src/common/Object.cpp

@@ -45,7 +45,7 @@ namespace love
 
 	void Object::release()
 	{
-		if(--count <= 0)
+		if (--count <= 0)
 			delete this;
 	}
 

+ 70 - 70
src/common/Reference.cpp

@@ -1,70 +1,70 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-* 
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-* 
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-* 
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#include "Reference.h"
-
-namespace love
-{
-	Reference::Reference()
-		: L(0), idx(LUA_REFNIL)
-	{
-	}
-
-	Reference::Reference(lua_State * L)
-		: L(0), idx(LUA_REFNIL)
-	{
-		ref(L);
-	}
-
-	Reference::~Reference()
-	{
-		unref();
-	}
-
-	void Reference::ref(lua_State * L)
-	{
-		unref(); // Just to be safe.
-		this->L = L;
-		idx = luaL_ref(L, LUA_GLOBALSINDEX);
-	}
-
-	void Reference::unref()
-	{
-		if(idx != LUA_REFNIL)
-		{
-			luaL_unref(L, LUA_GLOBALSINDEX, idx);
-			idx = LUA_REFNIL;
-		}
-	}
-
-	void Reference::push()
-	{
-		if(idx != LUA_REFNIL)
-			lua_rawgeti(L, LUA_GLOBALSINDEX, idx);
-		else
-			lua_pushnil(L);
-	}
-
-	lua_State * Reference::getL()
-	{
-		return L;
-	}
-
-} // love
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#include "Reference.h"
+
+namespace love
+{
+	Reference::Reference()
+		: L(0), idx(LUA_REFNIL)
+	{
+	}
+
+	Reference::Reference(lua_State * L)
+		: L(0), idx(LUA_REFNIL)
+	{
+		ref(L);
+	}
+
+	Reference::~Reference()
+	{
+		unref();
+	}
+
+	void Reference::ref(lua_State * L)
+	{
+		unref(); // Just to be safe.
+		this->L = L;
+		idx = luaL_ref(L, LUA_GLOBALSINDEX);
+	}
+
+	void Reference::unref()
+	{
+		if (idx != LUA_REFNIL)
+		{
+			luaL_unref(L, LUA_GLOBALSINDEX, idx);
+			idx = LUA_REFNIL;
+		}
+	}
+
+	void Reference::push()
+	{
+		if (idx != LUA_REFNIL)
+			lua_rawgeti(L, LUA_GLOBALSINDEX, idx);
+		else
+			lua_pushnil(L);
+	}
+
+	lua_State * Reference::getL()
+	{
+		return L;
+	}
+
+} // love

+ 6 - 6
src/common/Reference.h

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -49,7 +49,7 @@ namespace love
 		Reference();
 
 		/**
-		* Creates the object and a reference to the value 
+		* Creates the object and a reference to the value
 		* on the top of the stack.
 		**/
 		Reference(lua_State * L);
@@ -58,11 +58,11 @@ namespace love
 		* Deletes the reference, if any.
 		**/
 		virtual ~Reference();
-		
+
 		/**
 		* Creates a reference to the value on the
 		* top of the stack.
-		**/ 
+		**/
 		void ref(lua_State * L);
 
 		/**

+ 16 - 16
src/common/StringMap.h

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -54,12 +54,12 @@ namespace love
 		StringMap(Entry * entries, unsigned num)
 		{
 
-			for(unsigned i = 0; i < SIZE; ++i)
+			for (unsigned i = 0; i < SIZE; ++i)
 				reverse[i] = 0;
 
 			unsigned n = num/sizeof(Entry);
 
-			for(unsigned i = 0; i < n; ++i)
+			for (unsigned i = 0; i < n; ++i)
 			{
 				add(entries[i].key, entries[i].value);
 			}
@@ -67,9 +67,9 @@ namespace love
 
 		bool streq(const char * a, const char * b)
 		{
-			while(*a != 0 && *b != 0)
+			while (*a != 0 && *b != 0)
 			{
-				if(*a != *b)
+				if (*a != *b)
 					return false;
 				++a;
 				++b;
@@ -82,11 +82,11 @@ namespace love
 		{
 			//unsigned str_hash = djb2(key);
 
-			for(unsigned i = 0; i < MAX; ++i)
+			for (unsigned i = 0; i < MAX; ++i)
 			{
 				//unsigned str_i = (str_hash + i) % MAX; //this isn't used, is this intentional?
 
-				if(records[i].set && streq(records[i].key, key))
+				if (records[i].set && streq(records[i].key, key))
 				{
 					t = records[i].value;
 					return true;
@@ -100,10 +100,10 @@ namespace love
 		{
 			unsigned index = (unsigned)key;
 
-			if(index >= SIZE)
+			if (index >= SIZE)
 				return false;
-			
-			if(reverse[index] != 0)
+
+			if (reverse[index] != 0)
 			{
 				str = reverse[index];
 				return true;
@@ -118,12 +118,12 @@ namespace love
 		{
 			unsigned str_hash = djb2(key);
 			bool inserted = false;
-			
-			for(unsigned i = 0; i < MAX; ++i)
+
+			for (unsigned i = 0; i < MAX; ++i)
 			{
 				unsigned str_i = (str_hash + i) % MAX;
 
-				if(!records[str_i].set)
+				if (!records[str_i].set)
 				{
 					inserted = true;
 					records[str_i].set = true;
@@ -135,7 +135,7 @@ namespace love
 
 			unsigned index = (unsigned)value;
 
-			if(index >= SIZE)
+			if (index >= SIZE)
 			{
 				printf("\nConstant %s out of bounds with %i!\n", key, index);
 				return false;

+ 25 - 25
src/common/Vector.cpp

@@ -1,26 +1,26 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-* 
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-* 
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-* 
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#include "Vector.h"
-
-namespace love
-{
-	// Implementation in header.
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#include "Vector.h"
+
+namespace love
+{
+	// Implementation in header.
 }

+ 310 - 310
src/common/Vector.h

@@ -1,310 +1,310 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-* 
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-* 
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-* 
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#ifndef LOVE_VECTOR_H
-#define LOVE_VECTOR_H
-
-// STD
-#include <cmath>
-
-// LOVE
-#include "Matrix.h"
-
-namespace love
-{
-	/**
-	* 2D Vector class.
-	* 
-	* @author Anders Ruud
-	* @date 2006-05-13
-	**/
-	class Vector
-	{
-	public:
-
-		// The components.
-		float x, y;
-
-		/**
-		* Creates a new (1,1) Vector.
-		**/
-		Vector();
-
-		/**
-		* Creates a new Vector.
-		* @param x The x position/dimension.
-		* @param y The y position/dimension.
-		**/
-		Vector(float x, float y);
-
-		/**
-		* Gets the length of the Vector.
-		* @return The length of the Vector.
-		*
-		* This method requires sqrt() and should be used
-		* carefully. 
-		**/
-		float getLength() const;
-
-		/**
-		* Normalizes the Vector.
-		* @return The old length of the Vector.
-		**/
-		float normalize();
-
-		/**
-		* Gets a normal to the Vector.
-		* @return A normal to the Vector.
-		**/
-
-		Vector getNormal() const;
-
-		/**
-		* Adds a Vector to this Vector.
-		* @param v The Vector we want to add to this Vector.
-		* @return The resulting Vector.
-		**/
-		Vector operator + (const Vector & v) const;
-
-		/**
-		* Substracts a Vector to this Vector.
-		* @param v The Vector we want to subtract to this Vector.
-		* @return The resulting Vector.
-		**/
-		Vector operator - (const Vector & v) const;
-
-		/**
-		* Resizes a Vector by a scalar.
-		* @param s The scalar with which to resize the Vector.
-		* @return The resulting Vector.
-		**/
-		Vector operator * (float s) const;
-
-		/**
-		* Resizes a Vector by a scalar.
-		* @param s The scalar with which to resize the Vector.
-		* @return The resulting Vector.
-		**/
-		Vector operator / (float s) const;
-
-		/**
-		* Reverses the Vector.
-		* @return The reversed Vector.
-		**/
-		Vector operator - () const; 
-
-		/**
-		* Adds a Vector to this Vector, and also saves changes in the first Vector.
-		* @param v The Vector we want to add to this Vector.
-		**/
-		void operator += (const Vector & v);
-
-		/**
-		* Subtracts a Vector to this Vector, and also saves changes in the first Vector.
-		* @param v The Vector we want to subtract to this Vector.
-		**/
-		void operator -= (const Vector & v);
-
-		/**
-		* Resizes the Vector, and also saves changes in the first Vector.
-		* @param s The scalar by which we want to resize the Vector.
-		**/
-		void operator *= (float s);
-
-		/**
-		* Resizes the Vector, and also saves changes in the first Vector.
-		* @param s The scalar by which we want to resize the Vector.
-		**/
-		void operator /= (float s);
-
-		/**
-		* Calculates the dot product of two Vectors.
-		* @return The dot product of the two Vectors.
-		**/
-		float operator * (const Vector & v) const;
-
-		/**
-		* Calculates the cross product of two Vectors.
-		* @return The cross product of the two Vectors.
-		**/
-		float operator ^ (const Vector & v) const;
-
-		bool operator == (const Vector & v) const;
-
-		bool operator < (const Vector & v) const;
-		/**
-		* Gets the x value of the Vector.
-		* @return The x value of the Vector.
-		**/
-		float getX() const;
-		
-		/**
-		* Gets the x value of the Vector.
-		* @return The x value of the Vector.
-		**/
-		float getY() const;
-
-		/**
-		* Sets the x value of the Vector.
-		* @param The x value of the Vector.
-		**/
-		void setX(float x);
-
-		/**
-		* Sets the x value of the Vector.
-		* @param The x value of the Vector.
-		**/
-		void setY(float y);
-
-	};
-
-	inline float Vector::getLength() const
-	{
-		return sqrt(x*x + y*y);
-	}
-
-	inline Vector Vector::getNormal() const 
-	{
-		return Vector(-y, x);
-	}
-
-	inline float Vector::normalize()
-	{
-		
-		float len = getLength();
-
-		if(len > 0)
-			(*this) /= len;
-
-		return len;
-	}
-
-	/**
-	* Inline methods must have body in header.
-	**/
-
-	inline Vector::Vector()
-	{
-		x = 1;
-		y = 1;
-	}
-
-	inline Vector::Vector(float x, float y)
-	{
-		this->x = x;
-		this->y = y;
-	}
-
-	inline Vector Vector::operator + (const Vector & v) const
-	{
-		return Vector(x + v.x, y + v.y);
-	}
-
-	inline Vector Vector::operator - (const Vector & v) const
-	{
-		return Vector(x - v.getX(), y - v.getY());
-	}
-	
-	inline Vector Vector::operator * (float s) const
-	{
-		return Vector(x*s, y*s);
-	}
-
-	inline Vector Vector::operator / (float s) const
-	{
-		return Vector(x/s, y/s);
-	}
-
-	inline Vector Vector::operator - () const
-	{
-		return Vector(-x, -y);
-	}
-
-	inline void Vector::operator += (const Vector & v) 
-	{
-		x += v.getX();
-		y += v.getY();
-	}
-
-	inline void Vector::operator -= (const Vector & v) 
-	{
-		x -= v.getX();
-		y -= v.getY();
-	}
-
-	inline void Vector::operator *= (float s)
-	{
-		x *= s;
-		y *= s;
-	}
-
-	inline void Vector::operator /= (float s)
-	{
-		x /= s;
-		y /= s;
-	}
-
-	inline float Vector::operator * (const Vector & v) const
-	{
-		return x * v.getX() + y * v.getY();
-	}
-
-	inline float Vector::operator ^ (const Vector & v) const
-	{
-		return x * v.getY() - y * v.getX();
-	}
-
-	inline bool Vector::operator == (const Vector & v) const
-	{
-		return getLength() == v.getLength();
-	}
-
-	inline bool Vector::operator < (const Vector & v) const
-	{
-		return getLength() < v.getLength();
-	}
-
-	/**
-	* Accessor methods
-	**/
-
-	inline float Vector::getX() const
-	{
-		return x;
-	}
-
-	inline float Vector::getY() const
-	{
-		return y;
-	}
-
-	inline void Vector::setX(float x)
-	{
-		this->x = x;
-	}
-
-	inline void Vector::setY(float y)
-	{
-		this->y = y;
-	}
-
-} //love
-
-#endif// LOVE_VECTOR_H
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#ifndef LOVE_VECTOR_H
+#define LOVE_VECTOR_H
+
+// STD
+#include <cmath>
+
+// LOVE
+#include "Matrix.h"
+
+namespace love
+{
+	/**
+	* 2D Vector class.
+	*
+	* @author Anders Ruud
+	* @date 2006-05-13
+	**/
+	class Vector
+	{
+	public:
+
+		// The components.
+		float x, y;
+
+		/**
+		* Creates a new (1,1) Vector.
+		**/
+		Vector();
+
+		/**
+		* Creates a new Vector.
+		* @param x The x position/dimension.
+		* @param y The y position/dimension.
+		**/
+		Vector(float x, float y);
+
+		/**
+		* Gets the length of the Vector.
+		* @return The length of the Vector.
+		*
+		* This method requires sqrt() and should be used
+		* carefully.
+		**/
+		float getLength() const;
+
+		/**
+		* Normalizes the Vector.
+		* @return The old length of the Vector.
+		**/
+		float normalize();
+
+		/**
+		* Gets a normal to the Vector.
+		* @return A normal to the Vector.
+		**/
+
+		Vector getNormal() const;
+
+		/**
+		* Adds a Vector to this Vector.
+		* @param v The Vector we want to add to this Vector.
+		* @return The resulting Vector.
+		**/
+		Vector operator + (const Vector & v) const;
+
+		/**
+		* Substracts a Vector to this Vector.
+		* @param v The Vector we want to subtract to this Vector.
+		* @return The resulting Vector.
+		**/
+		Vector operator - (const Vector & v) const;
+
+		/**
+		* Resizes a Vector by a scalar.
+		* @param s The scalar with which to resize the Vector.
+		* @return The resulting Vector.
+		**/
+		Vector operator * (float s) const;
+
+		/**
+		* Resizes a Vector by a scalar.
+		* @param s The scalar with which to resize the Vector.
+		* @return The resulting Vector.
+		**/
+		Vector operator / (float s) const;
+
+		/**
+		* Reverses the Vector.
+		* @return The reversed Vector.
+		**/
+		Vector operator - () const;
+
+		/**
+		* Adds a Vector to this Vector, and also saves changes in the first Vector.
+		* @param v The Vector we want to add to this Vector.
+		**/
+		void operator += (const Vector & v);
+
+		/**
+		* Subtracts a Vector to this Vector, and also saves changes in the first Vector.
+		* @param v The Vector we want to subtract to this Vector.
+		**/
+		void operator -= (const Vector & v);
+
+		/**
+		* Resizes the Vector, and also saves changes in the first Vector.
+		* @param s The scalar by which we want to resize the Vector.
+		**/
+		void operator *= (float s);
+
+		/**
+		* Resizes the Vector, and also saves changes in the first Vector.
+		* @param s The scalar by which we want to resize the Vector.
+		**/
+		void operator /= (float s);
+
+		/**
+		* Calculates the dot product of two Vectors.
+		* @return The dot product of the two Vectors.
+		**/
+		float operator * (const Vector & v) const;
+
+		/**
+		* Calculates the cross product of two Vectors.
+		* @return The cross product of the two Vectors.
+		**/
+		float operator ^ (const Vector & v) const;
+
+		bool operator == (const Vector & v) const;
+
+		bool operator < (const Vector & v) const;
+		/**
+		* Gets the x value of the Vector.
+		* @return The x value of the Vector.
+		**/
+		float getX() const;
+
+		/**
+		* Gets the x value of the Vector.
+		* @return The x value of the Vector.
+		**/
+		float getY() const;
+
+		/**
+		* Sets the x value of the Vector.
+		* @param The x value of the Vector.
+		**/
+		void setX(float x);
+
+		/**
+		* Sets the x value of the Vector.
+		* @param The x value of the Vector.
+		**/
+		void setY(float y);
+
+	};
+
+	inline float Vector::getLength() const
+	{
+		return sqrt(x*x + y*y);
+	}
+
+	inline Vector Vector::getNormal() const
+	{
+		return Vector(-y, x);
+	}
+
+	inline float Vector::normalize()
+	{
+
+		float len = getLength();
+
+		if (len > 0)
+			(*this) /= len;
+
+		return len;
+	}
+
+	/**
+	* Inline methods must have body in header.
+	**/
+
+	inline Vector::Vector()
+	{
+		x = 1;
+		y = 1;
+	}
+
+	inline Vector::Vector(float x, float y)
+	{
+		this->x = x;
+		this->y = y;
+	}
+
+	inline Vector Vector::operator + (const Vector & v) const
+	{
+		return Vector(x + v.x, y + v.y);
+	}
+
+	inline Vector Vector::operator - (const Vector & v) const
+	{
+		return Vector(x - v.getX(), y - v.getY());
+	}
+
+	inline Vector Vector::operator * (float s) const
+	{
+		return Vector(x*s, y*s);
+	}
+
+	inline Vector Vector::operator / (float s) const
+	{
+		return Vector(x/s, y/s);
+	}
+
+	inline Vector Vector::operator - () const
+	{
+		return Vector(-x, -y);
+	}
+
+	inline void Vector::operator += (const Vector & v)
+	{
+		x += v.getX();
+		y += v.getY();
+	}
+
+	inline void Vector::operator -= (const Vector & v)
+	{
+		x -= v.getX();
+		y -= v.getY();
+	}
+
+	inline void Vector::operator *= (float s)
+	{
+		x *= s;
+		y *= s;
+	}
+
+	inline void Vector::operator /= (float s)
+	{
+		x /= s;
+		y /= s;
+	}
+
+	inline float Vector::operator * (const Vector & v) const
+	{
+		return x * v.getX() + y * v.getY();
+	}
+
+	inline float Vector::operator ^ (const Vector & v) const
+	{
+		return x * v.getY() - y * v.getX();
+	}
+
+	inline bool Vector::operator == (const Vector & v) const
+	{
+		return getLength() == v.getLength();
+	}
+
+	inline bool Vector::operator < (const Vector & v) const
+	{
+		return getLength() < v.getLength();
+	}
+
+	/**
+	* Accessor methods
+	**/
+
+	inline float Vector::getX() const
+	{
+		return x;
+	}
+
+	inline float Vector::getY() const
+	{
+		return y;
+	}
+
+	inline void Vector::setX(float x)
+	{
+		this->x = x;
+	}
+
+	inline void Vector::setY(float y)
+	{
+		this->y = y;
+	}
+
+} //love
+
+#endif// LOVE_VECTOR_H

+ 13 - 12
src/common/b64.cpp

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -25,7 +25,7 @@ namespace love
 	static const char cd64[]="|$$$}rstuvwxyz{$$$$$$$>?@ABCDEFGHIJKLMNOPQRSTUVW$$$$$$XYZ[\\]^_`abcdefghijklmnopq";
 
 	void b64_decode_block(char in[4], char out[3])
-	{   
+	{
 		out[0] = (char)(in[0] << 2 | in[1] >> 4);
 		out[1] = (char)(in[1] << 4 | in[2] >> 2);
 		out[2] = (char)(((in[2] << 6) & 0xc0) | in[3]);
@@ -41,33 +41,34 @@ namespace love
 		char in[4], out[3], v;
 		int i, len, pos = 0;
 
-		while(pos <= slen)
+		while (pos <= slen)
 		{
-			for(len = 0, i = 0; i < 4 && pos <= slen; i++ )
+			for (len = 0, i = 0; i < 4 && pos <= slen; i++ )
 			{
 				v = 0;
 
-				while(pos <= slen && v == 0 )
+				while (pos <= slen && v == 0 )
 				{
 					v = src[pos++];
 					v = (char)((v < 43 || v > 122) ? 0 : cd64[v - 43]);
-					if(v)
+					if (v)
 						v = (char)((v == '$') ? 0 : v - 61);
 				}
 
-				if(pos <= slen)
+				if (pos <= slen)
 				{
 					len++;
-					if(v)
+					if (v)
 						in[i] = (char)(v - 1);
 				}
 				else
 					in[i] = 0;
 			}
 
-			if(len) {
+			if (len)
+			{
 				b64_decode_block(in, out);
-				for(i = 0; i < len - 1; i++)
+				for (i = 0; i < len - 1; i++)
 					*(d++) = out[i];
 			}
 		}

+ 3 - 3
src/common/b64.h

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be

+ 3 - 3
src/common/config.h

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be

+ 85 - 85
src/common/math.h

@@ -1,85 +1,85 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-* 
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-* 
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-* 
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#ifndef LOVE_MATH_H
-#define LOVE_MATH_H
-
-#include <climits> // for CHAR_BIT
-
-/* Definitions of useful mathematical constants
- * M_E        - e
- * M_LOG2E    - log2(e)
- * M_LOG10E   - log10(e)
- * M_LN2      - ln(2)
- * M_LN10     - ln(10)
- * M_PI       - pi
- * M_PI_2     - pi/2
- * M_PI_4     - pi/4
- * M_1_PI     - 1/pi
- * M_2_PI     - 2/pi
- * M_2_SQRTPI - 2/sqrt(pi)
- * M_SQRT2    - sqrt(2)
- * M_SQRT1_2  - 1/sqrt(2)
- */
-
-#define LOVE_M_E        2.71828182845904523536
-#define LOVE_M_LOG2E    1.44269504088896340736
-#define LOVE_M_LOG10E   0.434294481903251827651
-#define LOVE_M_LN2      0.693147180559945309417
-#define LOVE_M_LN10     2.30258509299404568402
-#define LOVE_M_PI       3.14159265358979323846
-#define LOVE_M_PI_2     1.57079632679489661923
-#define LOVE_M_PI_4     0.785398163397448309616
-#define LOVE_M_1_PI     0.318309886183790671538
-#define LOVE_M_2_PI     0.636619772367581343076
-#define LOVE_M_2_SQRTPI 1.12837916709551257390
-#define LOVE_M_SQRT2    1.41421356237309504880
-#define LOVE_M_SQRT1_2  0.707106781186547524401
-#define LOVE_M_TORAD	(float)(LOVE_M_PI/180.0)
-#define LOVE_M_TODEG    (float)(180.0/LOVE_M_PI)
-#define LOVE_TORAD(x)	(float)(x*LOVE_M_TORAD)
-#define LOVE_TODEG(x)	(float)(x*LOVE_M_TODEG)
-
-namespace love
-{
-
-struct vertex
-{
-	unsigned char r, g, b, a;
-	float x, y;
-	float s, t;
-};
-
-inline int next_p2(int x)
-{
-	x += (x == 0);
-	x--;
-	for (unsigned int i = 1; i < sizeof(int)*CHAR_BIT; i <<= 1) x |= x >> i;
-	return ++x;
-}
-
-inline float next_p2(float x)
-{
-	return static_cast<float>(next_p2(static_cast<int>(x)));
-}
-
-} // love
-
-#endif // LOVE_MATH_H
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#ifndef LOVE_MATH_H
+#define LOVE_MATH_H
+
+#include <climits> // for CHAR_BIT
+
+/* Definitions of useful mathematical constants
+ * M_E        - e
+ * M_LOG2E    - log2(e)
+ * M_LOG10E   - log10(e)
+ * M_LN2      - ln(2)
+ * M_LN10     - ln(10)
+ * M_PI       - pi
+ * M_PI_2     - pi/2
+ * M_PI_4     - pi/4
+ * M_1_PI     - 1/pi
+ * M_2_PI     - 2/pi
+ * M_2_SQRTPI - 2/sqrt(pi)
+ * M_SQRT2    - sqrt(2)
+ * M_SQRT1_2  - 1/sqrt(2)
+ */
+
+#define LOVE_M_E        2.71828182845904523536
+#define LOVE_M_LOG2E    1.44269504088896340736
+#define LOVE_M_LOG10E   0.434294481903251827651
+#define LOVE_M_LN2      0.693147180559945309417
+#define LOVE_M_LN10     2.30258509299404568402
+#define LOVE_M_PI       3.14159265358979323846
+#define LOVE_M_PI_2     1.57079632679489661923
+#define LOVE_M_PI_4     0.785398163397448309616
+#define LOVE_M_1_PI     0.318309886183790671538
+#define LOVE_M_2_PI     0.636619772367581343076
+#define LOVE_M_2_SQRTPI 1.12837916709551257390
+#define LOVE_M_SQRT2    1.41421356237309504880
+#define LOVE_M_SQRT1_2  0.707106781186547524401
+#define LOVE_M_TORAD	(float)(LOVE_M_PI/180.0)
+#define LOVE_M_TODEG    (float)(180.0/LOVE_M_PI)
+#define LOVE_TORAD(x)	(float)(x*LOVE_M_TORAD)
+#define LOVE_TODEG(x)	(float)(x*LOVE_M_TODEG)
+
+namespace love
+{
+
+struct vertex
+{
+	unsigned char r, g, b, a;
+	float x, y;
+	float s, t;
+};
+
+inline int next_p2(int x)
+{
+	x += (x == 0);
+	x--;
+	for (unsigned int i = 1; i < sizeof(int)*CHAR_BIT; i <<= 1) x |= x >> i;
+	return ++x;
+}
+
+inline float next_p2(float x)
+{
+	return static_cast<float>(next_p2(static_cast<int>(x)));
+}
+
+} // love
+
+#endif // LOVE_MATH_H

+ 475 - 474
src/common/runtime.cpp

@@ -1,474 +1,475 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-*
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-*
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-*
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#include "runtime.h"
-
-// LOVE
-#include "Module.h"
-#include "Object.h"
-#include "Reference.h"
-#include "StringMap.h"
-#include <thread/threads.h>
-
-// STD
-#include <iostream>
-
-
-namespace love
-{
-	static thread::Mutex *gcmutex = 0;
-	void *_gcmutex = 0;
-	unsigned int _gcthread = 0;
-	/**
-	* Called when an object is collected. The object is released
-	* once in this function, possibly deleting it.
-	**/
-	static int w__gc(lua_State * L)
-	{
-		if (!gcmutex)
-		{
-			gcmutex = new thread::Mutex();
-			_gcmutex = (void*) gcmutex;
-		}
-		Proxy * p = (Proxy *)lua_touserdata(L, 1);
-		Object * t = (Object *)p->data;
-		if(p->own)
-		{
-			thread::Lock lock(gcmutex);
-			_gcthread = thread::ThreadBase::threadId();
-			t->release();
-		}
-		return 0;
-	}
-
-	static int w__tostring(lua_State * L)
-	{
-		lua_pushvalue(L, lua_upvalueindex(1));
-		return 1;
-	}
-
-	static int w__typeOf(lua_State * L)
-	{
-		Proxy * p = (Proxy *)lua_touserdata(L, 1);
-		Type t = luax_type(L, 2);
-		luax_pushboolean(L, p->flags[t]);
-		return 1;
-	}
-	
-	static int w__eq(lua_State * L)
-	{
-		Proxy * p1 = (Proxy *)lua_touserdata(L, 1);
-		Proxy * p2 = (Proxy *)lua_touserdata(L, 2);
-		luax_pushboolean(L, p1->data == p2->data);
-		return 1;
-	}
-
-	Reference * luax_refif(lua_State * L, int type)
-	{
-		Reference * r = 0;
-
-		// Create a reference only if the test succeeds.
-		if(lua_type(L, -1) == type)
-			r = new Reference(L);
-		else // Pop the value even if it fails (but also if it succeeds).
-			lua_pop(L, 1);
-
-		return r;
-	}
-
-	void luax_printstack(lua_State * L)
-	{
-		for(int i = 1;i<=lua_gettop(L);i++)
-		{
-			std::cout << i << " - " << luaL_typename(L, i) << std::endl;
-		}
-	}
-
-	bool luax_toboolean(lua_State * L, int idx)
-	{
-		return (lua_toboolean(L, idx) != 0);
-	}
-
-	void luax_pushboolean(lua_State * L, bool b)
-	{
-		lua_pushboolean(L, b ? 1 : 0);
-	}
-
-	bool luax_optboolean(lua_State * L, int idx, bool b)
-	{
-		if(lua_isboolean(L, idx) == 1)
-			return (lua_toboolean(L, idx) == 1 ? true : false);
-		return b;
-	}
-	
-	std::string luax_checkstring(lua_State * L, int idx)
-	{
-		size_t len;
-		const char * str = luaL_checklstring(L, idx, &len);
-		return std::string(str, len);
-	}
-	
-	void luax_pushstring(lua_State * L, std::string str)
-	{
-		lua_pushlstring(L, str.data(), str.size());
-	}
-
-	int luax_assert_argc(lua_State * L, int min)
-	{
-		int argc = lua_gettop(L);
-		if( argc < min )
-			return luaL_error(L, "Incorrect number of arguments. Got [%d], expected at least [%d]", argc, min);
-		return 0;
-	}
-
-	int luax_assert_argc(lua_State * L, int min, int max)
-	{
-		int argc = lua_gettop(L);
-		if( argc < min || argc > max)
-			return luaL_error(L, "Incorrect number of arguments. Got [%d], expected [%d-%d]", argc, min, max);
-		return 0;
-	}
-
-	int luax_assert_function(lua_State * L, int n)
-	{
-		if(!lua_isfunction(L, n))
-			return luaL_error(L, "Argument must be of type \"function\".");
-		return 0;
-	}
-
-	int luax_register_module(lua_State * L, const WrappedModule & m)
-	{
-		// Put a reference to the C++ module in Lua.
-		luax_getregistry(L, REGISTRY_MODULES);
-
-		Proxy * p = (Proxy *)lua_newuserdata(L, sizeof(Proxy));
-		p->own = true;
-		p->data = m.module;
-		p->flags = m.flags;
-
-		luaL_newmetatable(L, m.module->getName());
-		lua_pushvalue(L, -1);
-		lua_setfield(L, -2, "__index");
-		lua_pushcfunction(L, w__gc);
-		lua_setfield(L, -2, "__gc");
-
-		lua_setmetatable(L, -2);
-		lua_setfield(L, -2, m.name); // _modules[name] = proxy
-		lua_pop(L, 1);
-
-		// Gets the love table.
-		luax_insistglobal(L, "love");
-
-		// Create new table for module.
-		lua_newtable(L);
-
-		// Register all the functions.
-		luaL_register(L, 0, m.functions);
-
-		// Register types.
-		if(m.types != 0)
-			for(const lua_CFunction * t = m.types; *t != 0; t++)
-				(*t)(L);
-
-		lua_setfield(L, -2, m.name); // love.graphics = table
-		lua_pop(L, 1); // love
-
-		return 0;
-	}
-
-	int luax_preload(lua_State * L, lua_CFunction f, const char * name)
-	{
-		lua_getglobal(L, "package");
-		lua_getfield(L, -1, "preload");
-		lua_pushcfunction(L, f);
-		lua_setfield(L, -2, name);
-		lua_pop(L, 2);
-		return 0;
-	}
-
-	int luax_register_type(lua_State * L, const char * tname, const luaL_Reg * f)
-	{
-		luaL_newmetatable(L, tname);
-
-		// m.__index = m
-		lua_pushvalue(L, -1);
-		lua_setfield(L, -2, "__index");
-
-		// setup gc
-		lua_pushcfunction(L, w__gc);
-		lua_setfield(L, -2, "__gc");
-		
-		// Add equality
-		lua_pushcfunction(L, w__eq);
-		lua_setfield(L, -2, "__eq");
-
-		// Add tostring function.
-		lua_pushstring(L, tname);
-		lua_pushcclosure(L, w__tostring, 1);
-		lua_setfield(L, -2, "__tostring");
-
-		// Add tostring to as type() as well.
-		lua_pushstring(L, tname);
-		lua_pushcclosure(L, w__tostring, 1);
-		lua_setfield(L, -2, "type");
-
-		// Add typeOf
-		lua_pushcfunction(L, w__typeOf);
-		lua_setfield(L, -2, "typeOf");
-
-		if(f != 0)
-			luaL_register(L, 0, f);
-
-		lua_pop(L, 1); // Pops metatable.
-		return 0;
-	}
-	
-	int luax_table_insert(lua_State * L, int tindex, int vindex, int pos)
-	{
-		if (tindex < 0)
-			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);
-			return 0;
-		}
-		else if (pos < 0)
-			pos = lua_objlen(L, tindex)+1+pos;
-		for (int i = 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;
-	}
-
-	int luax_register_searcher(lua_State * L, lua_CFunction f, int pos)
-	{
-		// Add the package loader to the package.loaders table.
-		lua_getglobal(L, "package");
-
-		if(lua_isnil(L, -1))
-			return luaL_error(L, "Can't register searcher: package table does not exist.");
-
-		lua_getfield(L, -1, "loaders");
-
-		if(lua_isnil(L, -1))
-			return luaL_error(L, "Can't register searcher: package.loaders table does not exist.");
-
-		lua_pushcfunction(L, f);
-		luax_table_insert(L, -2, -1, pos);
-		lua_pop(L, 3);
-		return 0;
-	}
-
-	void luax_newtype(lua_State * L, const char * name, bits flags, void * data, bool own)
-	{
-		Proxy * u = (Proxy *)lua_newuserdata(L, sizeof(Proxy));
-
-		u->data = data;
-		u->flags = flags;
-		u->own = own;
-
-		luaL_newmetatable(L, name);
-		lua_setmetatable(L, -2);
-	}
-
-	bool luax_istype(lua_State * L, int idx, love::bits type)
-	{
-		if(lua_isuserdata(L, idx) == 0)
-			return false;
-
-		return ((((Proxy *)lua_touserdata(L, idx))->flags & type) == type);
-	}
-
-	int luax_getfunction(lua_State * L, const char * mod, const char * fn)
-	{
-		lua_getglobal(L, "love");
-		if(lua_isnil(L, -1)) return luaL_error(L, "Could not find global love!");
-		lua_getfield(L, -1, mod);
-		if(lua_isnil(L, -1)) return luaL_error(L, "Could not find love.%s!", mod);
-		lua_getfield(L, -1, fn);
-		if(lua_isnil(L, -1)) return luaL_error(L, "Could not find love.%s.%s!", mod, fn);
-
-		lua_remove(L, -2); // remove mod
-		lua_remove(L, -2); // remove fn
-		return 0;
-	}
-
-	int luax_convobj(lua_State * L, int idx, const char * mod, const char * fn)
-	{
-		// Convert string to a file.
-		luax_getfunction(L, mod, fn);
-		lua_pushvalue(L, idx); // The initial argument.
-		lua_call(L, 1, 1); // Call the function, one arg, one return value.
-		lua_replace(L, idx); // Replace the initial argument with the new object.
-		return 0;
-	}
-
-	int luax_convobj(lua_State * L, int idxs[], int n, const char * mod, const char * fn)
-	{
-		luax_getfunction(L, mod, fn);
-		for (int i = 0; i < n; i++) {
-			lua_pushvalue(L, idxs[i]); // The arguments.
-		}
-		lua_call(L, n, 1); // Call the function, n args, one return value.
-		lua_replace(L, idxs[0]); // Replace the initial argument with the new object.
-		return 0;
-	}
-
-	int luax_strtofile(lua_State * L, int idx)
-	{
-		return luax_convobj(L, idx, "filesystem", "newFile");
-	}
-
-	int luax_filetodata(lua_State * L, int idx)
-	{
-		return luax_convobj(L, idx, "filesystem", "read");
-	}
-
-	int luax_insist(lua_State * L, int idx, const char * k)
-	{
-		lua_getfield(L, idx, k);
-
-		// Create if necessary.
-		if(!lua_istable(L, -1))
-		{
-			lua_pop(L, 1); // Pop the non-table.
-			lua_newtable(L);
-			lua_pushvalue(L, -1); // Duplicate the table to leave on top.
-			lua_setfield(L, -3, k); // k[idx] = table
-		}
-
-		return 1;
-	}
-
-	int luax_insistglobal(lua_State * L, const char * k)
-	{
-		lua_getglobal(L, k);
-
-		if(!lua_istable(L, -1))
-		{
-			lua_pop(L, 1); // Pop the non-table.
-			lua_newtable(L);
-			lua_pushvalue(L, -1);
-			lua_setglobal(L, k);
-		}
-
-		return 1;
-	}
-
-	int luax_insistlove(lua_State * L, const char * k)
-	{
-		luax_insistglobal(L, "love");
-		luax_insist(L, -1, k);
-
-		// The love table should be replaced with the top stack
-		// item. Only the reqested table should remain on the stack.
-		lua_replace(L, -2);
-
-		return 1;
-	}
-
-	int luax_getregistry(lua_State * L, Registry r)
-	{
-		switch(r)
-		{
-		case REGISTRY_GC:
-			return luax_insistlove(L, "_gc");
-		case REGISTRY_MODULES:
-			return luax_insistlove(L, "_modules");
-		default:
-			return luaL_error(L, "Attempted to use invalid registry.");
-		}
-	}
-
-	StringMap<Type, TYPE_MAX_ENUM>::Entry typeEntries[] =
-	{
-		{"Invalid", INVALID_ID},
-
-		{"Object", OBJECT_ID},
-		{"Data", DATA_ID},
-		{"Module", MODULE_ID},
-
-		// Filesystem
-		{"File", FILESYSTEM_FILE_ID},
-		{"FileData", FILESYSTEM_FILE_DATA_ID},
-
-		// Font
-		{"GlyphData", FONT_GLYPH_DATA_ID},
-		{"Rasterizer", FONT_RASTERIZER_ID},
-
-		// Graphics
-		{"Drawable", GRAPHICS_DRAWABLE_ID},
-		{"Image", GRAPHICS_IMAGE_ID},
-		{"Quad", GRAPHICS_QUAD_ID},
-		{"Font", GRAPHICS_FONT_ID},
-		{"ParticleSystem", GRAPHICS_PARTICLE_SYSTEM_ID},
-		{"SpriteBatch", GRAPHICS_SPRITE_BATCH_ID},
-		{"Canvas", GRAPHICS_CANVAS_ID},
-
-		// Image
-		{"ImageData", IMAGE_IMAGE_DATA_ID},
-
-		// Audio
-		{"Source", AUDIO_SOURCE_ID},
-
-		// Sound
-		{"SoundData", SOUND_SOUND_DATA_ID},
-		{"Decoder", SOUND_DECODER_ID},
-
-		// Physics
-		{"World", PHYSICS_WORLD_ID},
-		{"Contact", PHYSICS_CONTACT_ID},
-		{"Body", PHYSICS_BODY_ID},
-		{"Shape", PHYSICS_SHAPE_ID},
-		{"CircleShape", PHYSICS_CIRCLE_SHAPE_ID},
-		{"PolygonShape", PHYSICS_POLYGON_SHAPE_ID},
-		{"Joint", PHYSICS_JOINT_ID},
-		{"MouseJoint", PHYSICS_MOUSE_JOINT_ID},
-		{"DistanceJoint", PHYSICS_DISTANCE_JOINT_ID},
-		{"PrismaticJoint", PHYSICS_PRISMATIC_JOINT_ID},
-		{"RevoluteJoint", PHYSICS_REVOLUTE_JOINT_ID},
-		{"PulleyJoint", PHYSICS_PULLEY_JOINT_ID},
-		{"GearJoint", PHYSICS_GEAR_JOINT_ID},
-
-		// Thread
-		{"Thread", THREAD_THREAD_ID},
-
-		// The modules themselves. Only add abstracted modules here.
-		{"filesystem", MODULE_FILESYSTEM_ID},
-		{"image", MODULE_IMAGE_ID},
-		{"sound", MODULE_SOUND_ID},
-	};
-
-	StringMap<Type, TYPE_MAX_ENUM> types(typeEntries, sizeof(typeEntries));
-
-	Type luax_type(lua_State * L, int idx)
-	{
-		Type t = INVALID_ID;
-		types.find(luaL_checkstring(L, idx), t);
-		return t;
-	}
-} // love
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#include "runtime.h"
+
+// LOVE
+#include "Module.h"
+#include "Object.h"
+#include "Reference.h"
+#include "StringMap.h"
+#include <thread/threads.h>
+
+// STD
+#include <iostream>
+
+
+namespace love
+{
+	static thread::Mutex *gcmutex = 0;
+	void *_gcmutex = 0;
+	unsigned int _gcthread = 0;
+	/**
+	* Called when an object is collected. The object is released
+	* once in this function, possibly deleting it.
+	**/
+	static int w__gc(lua_State * L)
+	{
+		if (!gcmutex)
+		{
+			gcmutex = new thread::Mutex();
+			_gcmutex = (void*) gcmutex;
+		}
+		Proxy * p = (Proxy *)lua_touserdata(L, 1);
+		Object * t = (Object *)p->data;
+		if (p->own)
+		{
+			thread::Lock lock(gcmutex);
+			_gcthread = thread::ThreadBase::threadId();
+			t->release();
+		}
+		return 0;
+	}
+
+	static int w__tostring(lua_State * L)
+	{
+		lua_pushvalue(L, lua_upvalueindex(1));
+		return 1;
+	}
+
+	static int w__typeOf(lua_State * L)
+	{
+		Proxy * p = (Proxy *)lua_touserdata(L, 1);
+		Type t = luax_type(L, 2);
+		luax_pushboolean(L, p->flags[t]);
+		return 1;
+	}
+
+	static int w__eq(lua_State * L)
+	{
+		Proxy * p1 = (Proxy *)lua_touserdata(L, 1);
+		Proxy * p2 = (Proxy *)lua_touserdata(L, 2);
+		luax_pushboolean(L, p1->data == p2->data);
+		return 1;
+	}
+
+	Reference * luax_refif(lua_State * L, int type)
+	{
+		Reference * r = 0;
+
+		// Create a reference only if the test succeeds.
+		if (lua_type(L, -1) == type)
+			r = new Reference(L);
+		else // Pop the value even if it fails (but also if it succeeds).
+			lua_pop(L, 1);
+
+		return r;
+	}
+
+	void luax_printstack(lua_State * L)
+	{
+		for (int i = 1;i<=lua_gettop(L);i++)
+		{
+			std::cout << i << " - " << luaL_typename(L, i) << std::endl;
+		}
+	}
+
+	bool luax_toboolean(lua_State * L, int idx)
+	{
+		return (lua_toboolean(L, idx) != 0);
+	}
+
+	void luax_pushboolean(lua_State * L, bool b)
+	{
+		lua_pushboolean(L, b ? 1 : 0);
+	}
+
+	bool luax_optboolean(lua_State * L, int idx, bool b)
+	{
+		if (lua_isboolean(L, idx) == 1)
+			return (lua_toboolean(L, idx) == 1 ? true : false);
+		return b;
+	}
+
+	std::string luax_checkstring(lua_State * L, int idx)
+	{
+		size_t len;
+		const char * str = luaL_checklstring(L, idx, &len);
+		return std::string(str, len);
+	}
+
+	void luax_pushstring(lua_State * L, std::string str)
+	{
+		lua_pushlstring(L, str.data(), str.size());
+	}
+
+	int luax_assert_argc(lua_State * L, int min)
+	{
+		int argc = lua_gettop(L);
+		if ( argc < min )
+			return luaL_error(L, "Incorrect number of arguments. Got [%d], expected at least [%d]", argc, min);
+		return 0;
+	}
+
+	int luax_assert_argc(lua_State * L, int min, int max)
+	{
+		int argc = lua_gettop(L);
+		if ( argc < min || argc > max)
+			return luaL_error(L, "Incorrect number of arguments. Got [%d], expected [%d-%d]", argc, min, max);
+		return 0;
+	}
+
+	int luax_assert_function(lua_State * L, int n)
+	{
+		if (!lua_isfunction(L, n))
+			return luaL_error(L, "Argument must be of type \"function\".");
+		return 0;
+	}
+
+	int luax_register_module(lua_State * L, const WrappedModule & m)
+	{
+		// Put a reference to the C++ module in Lua.
+		luax_getregistry(L, REGISTRY_MODULES);
+
+		Proxy * p = (Proxy *)lua_newuserdata(L, sizeof(Proxy));
+		p->own = true;
+		p->data = m.module;
+		p->flags = m.flags;
+
+		luaL_newmetatable(L, m.module->getName());
+		lua_pushvalue(L, -1);
+		lua_setfield(L, -2, "__index");
+		lua_pushcfunction(L, w__gc);
+		lua_setfield(L, -2, "__gc");
+
+		lua_setmetatable(L, -2);
+		lua_setfield(L, -2, m.name); // _modules[name] = proxy
+		lua_pop(L, 1);
+
+		// Gets the love table.
+		luax_insistglobal(L, "love");
+
+		// Create new table for module.
+		lua_newtable(L);
+
+		// Register all the functions.
+		luaL_register(L, 0, m.functions);
+
+		// Register types.
+		if (m.types != 0)
+			for (const lua_CFunction * t = m.types; *t != 0; t++)
+				(*t)(L);
+
+		lua_setfield(L, -2, m.name); // love.graphics = table
+		lua_pop(L, 1); // love
+
+		return 0;
+	}
+
+	int luax_preload(lua_State * L, lua_CFunction f, const char * name)
+	{
+		lua_getglobal(L, "package");
+		lua_getfield(L, -1, "preload");
+		lua_pushcfunction(L, f);
+		lua_setfield(L, -2, name);
+		lua_pop(L, 2);
+		return 0;
+	}
+
+	int luax_register_type(lua_State * L, const char * tname, const luaL_Reg * f)
+	{
+		luaL_newmetatable(L, tname);
+
+		// m.__index = m
+		lua_pushvalue(L, -1);
+		lua_setfield(L, -2, "__index");
+
+		// setup gc
+		lua_pushcfunction(L, w__gc);
+		lua_setfield(L, -2, "__gc");
+
+		// Add equality
+		lua_pushcfunction(L, w__eq);
+		lua_setfield(L, -2, "__eq");
+
+		// Add tostring function.
+		lua_pushstring(L, tname);
+		lua_pushcclosure(L, w__tostring, 1);
+		lua_setfield(L, -2, "__tostring");
+
+		// Add tostring to as type() as well.
+		lua_pushstring(L, tname);
+		lua_pushcclosure(L, w__tostring, 1);
+		lua_setfield(L, -2, "type");
+
+		// Add typeOf
+		lua_pushcfunction(L, w__typeOf);
+		lua_setfield(L, -2, "typeOf");
+
+		if (f != 0)
+			luaL_register(L, 0, f);
+
+		lua_pop(L, 1); // Pops metatable.
+		return 0;
+	}
+
+	int luax_table_insert(lua_State * L, int tindex, int vindex, int pos)
+	{
+		if (tindex < 0)
+			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);
+			return 0;
+		}
+		else if (pos < 0)
+			pos = lua_objlen(L, tindex)+1+pos;
+		for (int i = 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;
+	}
+
+	int luax_register_searcher(lua_State * L, lua_CFunction f, int pos)
+	{
+		// Add the package loader to the package.loaders table.
+		lua_getglobal(L, "package");
+
+		if (lua_isnil(L, -1))
+			return luaL_error(L, "Can't register searcher: package table does not exist.");
+
+		lua_getfield(L, -1, "loaders");
+
+		if (lua_isnil(L, -1))
+			return luaL_error(L, "Can't register searcher: package.loaders table does not exist.");
+
+		lua_pushcfunction(L, f);
+		luax_table_insert(L, -2, -1, pos);
+		lua_pop(L, 3);
+		return 0;
+	}
+
+	void luax_newtype(lua_State * L, const char * name, bits flags, void * data, bool own)
+	{
+		Proxy * u = (Proxy *)lua_newuserdata(L, sizeof(Proxy));
+
+		u->data = data;
+		u->flags = flags;
+		u->own = own;
+
+		luaL_newmetatable(L, name);
+		lua_setmetatable(L, -2);
+	}
+
+	bool luax_istype(lua_State * L, int idx, love::bits type)
+	{
+		if (lua_isuserdata(L, idx) == 0)
+			return false;
+
+		return ((((Proxy *)lua_touserdata(L, idx))->flags & type) == type);
+	}
+
+	int luax_getfunction(lua_State * L, const char * mod, const char * fn)
+	{
+		lua_getglobal(L, "love");
+		if (lua_isnil(L, -1)) return luaL_error(L, "Could not find global love!");
+		lua_getfield(L, -1, mod);
+		if (lua_isnil(L, -1)) return luaL_error(L, "Could not find love.%s!", mod);
+		lua_getfield(L, -1, fn);
+		if (lua_isnil(L, -1)) return luaL_error(L, "Could not find love.%s.%s!", mod, fn);
+
+		lua_remove(L, -2); // remove mod
+		lua_remove(L, -2); // remove fn
+		return 0;
+	}
+
+	int luax_convobj(lua_State * L, int idx, const char * mod, const char * fn)
+	{
+		// Convert string to a file.
+		luax_getfunction(L, mod, fn);
+		lua_pushvalue(L, idx); // The initial argument.
+		lua_call(L, 1, 1); // Call the function, one arg, one return value.
+		lua_replace(L, idx); // Replace the initial argument with the new object.
+		return 0;
+	}
+
+	int luax_convobj(lua_State * L, int idxs[], int n, const char * mod, const char * fn)
+	{
+		luax_getfunction(L, mod, fn);
+		for (int i = 0; i < n; i++)
+		{
+			lua_pushvalue(L, idxs[i]); // The arguments.
+		}
+		lua_call(L, n, 1); // Call the function, n args, one return value.
+		lua_replace(L, idxs[0]); // Replace the initial argument with the new object.
+		return 0;
+	}
+
+	int luax_strtofile(lua_State * L, int idx)
+	{
+		return luax_convobj(L, idx, "filesystem", "newFile");
+	}
+
+	int luax_filetodata(lua_State * L, int idx)
+	{
+		return luax_convobj(L, idx, "filesystem", "read");
+	}
+
+	int luax_insist(lua_State * L, int idx, const char * k)
+	{
+		lua_getfield(L, idx, k);
+
+		// Create if necessary.
+		if (!lua_istable(L, -1))
+		{
+			lua_pop(L, 1); // Pop the non-table.
+			lua_newtable(L);
+			lua_pushvalue(L, -1); // Duplicate the table to leave on top.
+			lua_setfield(L, -3, k); // k[idx] = table
+		}
+
+		return 1;
+	}
+
+	int luax_insistglobal(lua_State * L, const char * k)
+	{
+		lua_getglobal(L, k);
+
+		if (!lua_istable(L, -1))
+		{
+			lua_pop(L, 1); // Pop the non-table.
+			lua_newtable(L);
+			lua_pushvalue(L, -1);
+			lua_setglobal(L, k);
+		}
+
+		return 1;
+	}
+
+	int luax_insistlove(lua_State * L, const char * k)
+	{
+		luax_insistglobal(L, "love");
+		luax_insist(L, -1, k);
+
+		// The love table should be replaced with the top stack
+		// item. Only the reqested table should remain on the stack.
+		lua_replace(L, -2);
+
+		return 1;
+	}
+
+	int luax_getregistry(lua_State * L, Registry r)
+	{
+		switch(r)
+		{
+		case REGISTRY_GC:
+			return luax_insistlove(L, "_gc");
+		case REGISTRY_MODULES:
+			return luax_insistlove(L, "_modules");
+		default:
+			return luaL_error(L, "Attempted to use invalid registry.");
+		}
+	}
+
+	StringMap<Type, TYPE_MAX_ENUM>::Entry typeEntries[] =
+	{
+		{"Invalid", INVALID_ID},
+
+		{"Object", OBJECT_ID},
+		{"Data", DATA_ID},
+		{"Module", MODULE_ID},
+
+		// Filesystem
+		{"File", FILESYSTEM_FILE_ID},
+		{"FileData", FILESYSTEM_FILE_DATA_ID},
+
+		// Font
+		{"GlyphData", FONT_GLYPH_DATA_ID},
+		{"Rasterizer", FONT_RASTERIZER_ID},
+
+		// Graphics
+		{"Drawable", GRAPHICS_DRAWABLE_ID},
+		{"Image", GRAPHICS_IMAGE_ID},
+		{"Quad", GRAPHICS_QUAD_ID},
+		{"Font", GRAPHICS_FONT_ID},
+		{"ParticleSystem", GRAPHICS_PARTICLE_SYSTEM_ID},
+		{"SpriteBatch", GRAPHICS_SPRITE_BATCH_ID},
+		{"Canvas", GRAPHICS_CANVAS_ID},
+
+		// Image
+		{"ImageData", IMAGE_IMAGE_DATA_ID},
+
+		// Audio
+		{"Source", AUDIO_SOURCE_ID},
+
+		// Sound
+		{"SoundData", SOUND_SOUND_DATA_ID},
+		{"Decoder", SOUND_DECODER_ID},
+
+		// Physics
+		{"World", PHYSICS_WORLD_ID},
+		{"Contact", PHYSICS_CONTACT_ID},
+		{"Body", PHYSICS_BODY_ID},
+		{"Shape", PHYSICS_SHAPE_ID},
+		{"CircleShape", PHYSICS_CIRCLE_SHAPE_ID},
+		{"PolygonShape", PHYSICS_POLYGON_SHAPE_ID},
+		{"Joint", PHYSICS_JOINT_ID},
+		{"MouseJoint", PHYSICS_MOUSE_JOINT_ID},
+		{"DistanceJoint", PHYSICS_DISTANCE_JOINT_ID},
+		{"PrismaticJoint", PHYSICS_PRISMATIC_JOINT_ID},
+		{"RevoluteJoint", PHYSICS_REVOLUTE_JOINT_ID},
+		{"PulleyJoint", PHYSICS_PULLEY_JOINT_ID},
+		{"GearJoint", PHYSICS_GEAR_JOINT_ID},
+
+		// Thread
+		{"Thread", THREAD_THREAD_ID},
+
+		// The modules themselves. Only add abstracted modules here.
+		{"filesystem", MODULE_FILESYSTEM_ID},
+		{"image", MODULE_IMAGE_ID},
+		{"sound", MODULE_SOUND_ID},
+	};
+
+	StringMap<Type, TYPE_MAX_ENUM> types(typeEntries, sizeof(typeEntries));
+
+	Type luax_type(lua_State * L, int idx)
+	{
+		Type t = INVALID_ID;
+		types.find(luaL_checkstring(L, idx), t);
+		return t;
+	}
+} // love

+ 5 - 5
src/common/runtime.h

@@ -147,7 +147,7 @@ namespace love
 	* @param str The string to push.
 	**/
 	void luax_pushstring(lua_State * L, std::string str);
-	
+
 	/**
 	* Require at least 'min' number of items on the stack.
 	* @param L The Lua state.
@@ -348,12 +348,12 @@ namespace love
 	template <typename T>
 	T * luax_checktype(lua_State * L, int idx, const char * name, love::bits type)
 	{
-		if(lua_isuserdata(L, idx) == 0)
+		if (lua_isuserdata(L, idx) == 0)
 			luaL_error(L, "Incorrect parameter type: expected userdata.");
 
 		Proxy * u = (Proxy *)lua_touserdata(L, idx);
 
-		if((u->flags & type) != type)
+		if ((u->flags & type) != type)
 			luaL_error(L, "Incorrect parameter type: expected %s", name);
 
 		return (T *)u->data;
@@ -365,12 +365,12 @@ namespace love
 		luax_getregistry(L, REGISTRY_MODULES);
 		lua_getfield(L, -1, k);
 
-		if(!lua_isuserdata(L, -1))
+		if (!lua_isuserdata(L, -1))
 			luaL_error(L, "Tried to get nonexisting module %s.", k);
 
 		Proxy * u = (Proxy *)lua_touserdata(L, -1);
 
-		if((u->flags & type) != type)
+		if ((u->flags & type) != type)
 			luaL_error(L, "Incorrect module %s", k);
 
 		lua_pop(L, 2);

+ 173 - 173
src/common/types.h

@@ -1,173 +1,173 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-*
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-*
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-*
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#ifndef LOVE_TYPES_H
-#define LOVE_TYPES_H
-
-// STD
-#include <bitset>
-
-namespace love
-{
-	enum Type
-	{
-		INVALID_ID = 0,
-		// Cross-module types.
-		OBJECT_ID,
-		DATA_ID,
-		MODULE_ID,
-
-		// Filesystem.
-		FILESYSTEM_FILE_ID,
-		FILESYSTEM_FILE_DATA_ID,
-
-		// Font
-		FONT_GLYPH_DATA_ID,
-		FONT_RASTERIZER_ID,
-
-		// Graphics
-		GRAPHICS_DRAWABLE_ID,
-		GRAPHICS_DRAWQABLE_ID,
-		GRAPHICS_IMAGE_ID,
-		GRAPHICS_QUAD_ID,
-		GRAPHICS_FONT_ID,
-		GRAPHICS_PARTICLE_SYSTEM_ID,
-		GRAPHICS_SPRITE_BATCH_ID,
-		GRAPHICS_CANVAS_ID,
-		GRAPHICS_PIXELEFFECT_ID,
-
-		// Image
-		IMAGE_IMAGE_DATA_ID,
-		IMAGE_ENCODED_IMAGE_DATA_ID,
-
-		// Audio
-		AUDIO_SOURCE_ID,
-
-		// Sound
-		SOUND_SOUND_DATA_ID,
-		SOUND_DECODER_ID,
-
-		// Physics
-		PHYSICS_WORLD_ID,
-		PHYSICS_CONTACT_ID,
-		PHYSICS_BODY_ID,
-		PHYSICS_FIXTURE_ID,
-		PHYSICS_SHAPE_ID,
-		PHYSICS_CIRCLE_SHAPE_ID,
-		PHYSICS_POLYGON_SHAPE_ID,
-		PHYSICS_EDGE_SHAPE_ID,
-		PHYSICS_CHAIN_SHAPE_ID,
-		PHYSICS_JOINT_ID,
-		PHYSICS_MOUSE_JOINT_ID,
-		PHYSICS_DISTANCE_JOINT_ID,
-		PHYSICS_PRISMATIC_JOINT_ID,
-		PHYSICS_REVOLUTE_JOINT_ID,
-		PHYSICS_PULLEY_JOINT_ID,
-		PHYSICS_GEAR_JOINT_ID,
-		PHYSICS_FRICTION_JOINT_ID,
-		PHYSICS_WELD_JOINT_ID,
-		PHYSICS_ROPE_JOINT_ID,
-		PHYSICS_WHEEL_JOINT_ID,
-
-		// Thread
-		THREAD_THREAD_ID,
-
-		// The modules themselves. Only add abstracted modules here.
-		MODULE_FILESYSTEM_ID,
-		MODULE_IMAGE_ID,
-		MODULE_SOUND_ID,
-
-		// Count the number of bits needed.
-		TYPE_MAX_ENUM
-	};
-
-	typedef std::bitset<TYPE_MAX_ENUM> bits;
-
-	const bits INVALID_T = bits(1) << INVALID_ID;
-
-	const bits OBJECT_T = bits(1) << OBJECT_ID;
-	const bits DATA_T = (bits(1) << DATA_ID) | OBJECT_T;
-	const bits MODULE_T = (bits(1) << MODULE_ID) | OBJECT_T;
-
-	// Filesystem.
-	const bits FILESYSTEM_FILE_T = (bits(1) << FILESYSTEM_FILE_ID) | OBJECT_T;
-	const bits FILESYSTEM_FILE_DATA_T = (bits(1) << FILESYSTEM_FILE_DATA_ID) | DATA_T;
-
-	const bits FONT_GLYPH_DATA_T = (bits(1) << FONT_GLYPH_DATA_ID) | DATA_T;
-	const bits FONT_RASTERIZER_T = (bits(1) << FONT_RASTERIZER_ID) | OBJECT_T;
-
-	// Graphics.
-	const bits GRAPHICS_DRAWABLE_T = (bits(1) << GRAPHICS_DRAWABLE_ID) | OBJECT_T;
-	const bits GRAPHICS_DRAWQABLE_T = (bits(1) << GRAPHICS_DRAWQABLE_ID) | GRAPHICS_DRAWABLE_T;
-	const bits GRAPHICS_IMAGE_T = (bits(1) << GRAPHICS_IMAGE_ID) | GRAPHICS_DRAWQABLE_T;
-	const bits GRAPHICS_QUAD_T = (bits(1) << GRAPHICS_QUAD_ID) | OBJECT_T;
-	const bits GRAPHICS_FONT_T = (bits(1) << GRAPHICS_FONT_ID) | OBJECT_T;
-	const bits GRAPHICS_PARTICLE_SYSTEM_T = (bits(1) << GRAPHICS_PARTICLE_SYSTEM_ID) | GRAPHICS_DRAWABLE_T;
-	const bits GRAPHICS_SPRITE_BATCH_T = (bits(1) << GRAPHICS_SPRITE_BATCH_ID) | GRAPHICS_DRAWABLE_T;
-	const bits GRAPHICS_CANVAS_T = (bits(1) << GRAPHICS_CANVAS_ID) | GRAPHICS_DRAWQABLE_T;
-	const bits GRAPHICS_PIXELEFFECT_T = (bits(1) << GRAPHICS_PIXELEFFECT_ID) | OBJECT_T;
-
-	// Image.
-	const bits IMAGE_IMAGE_DATA_T = (bits(1) << IMAGE_IMAGE_DATA_ID) | DATA_T;
-	const bits IMAGE_ENCODED_IMAGE_DATA_T = (bits(1) << IMAGE_ENCODED_IMAGE_DATA_ID) | DATA_T;
-
-	// Audio.
-	const bits AUDIO_SOURCE_T = (bits(1) << AUDIO_SOURCE_ID) | OBJECT_T;
-
-	// Sound.
-	const bits SOUND_SOUND_DATA_T = (bits(1) << SOUND_SOUND_DATA_ID) | DATA_T;
-	const bits SOUND_DECODER_T = bits(1) << SOUND_DECODER_ID;
-
-	// Physics.
-	const bits PHYSICS_WORLD_T = (bits(1) << PHYSICS_WORLD_ID) | OBJECT_T;
-	const bits PHYSICS_CONTACT_T = (bits(1) << PHYSICS_CONTACT_ID) | OBJECT_T;
-	const bits PHYSICS_BODY_T = (bits(1) << PHYSICS_BODY_ID) | OBJECT_T;
-	const bits PHYSICS_FIXTURE_T = (bits(1) << PHYSICS_FIXTURE_ID) | OBJECT_T;
-	const bits PHYSICS_SHAPE_T = (bits(1) << PHYSICS_SHAPE_ID) | OBJECT_T;
-	const bits PHYSICS_CIRCLE_SHAPE_T = (bits(1) << PHYSICS_CIRCLE_SHAPE_ID) | PHYSICS_SHAPE_T;
-	const bits PHYSICS_POLYGON_SHAPE_T = (bits(1) << PHYSICS_POLYGON_SHAPE_ID) | PHYSICS_SHAPE_T;
-	const bits PHYSICS_EDGE_SHAPE_T = (bits(1) << PHYSICS_EDGE_SHAPE_ID) | PHYSICS_SHAPE_T;
-	const bits PHYSICS_CHAIN_SHAPE_T = (bits(1) << PHYSICS_CHAIN_SHAPE_ID) | PHYSICS_SHAPE_T;
-	const bits PHYSICS_JOINT_T = (bits(1) << PHYSICS_JOINT_ID) | OBJECT_T;
-	const bits PHYSICS_MOUSE_JOINT_T = (bits(1) << PHYSICS_MOUSE_JOINT_ID) | PHYSICS_JOINT_T;
-	const bits PHYSICS_DISTANCE_JOINT_T = (bits(1) << PHYSICS_DISTANCE_JOINT_ID) | PHYSICS_JOINT_T;
-	const bits PHYSICS_PRISMATIC_JOINT_T = (bits(1) << PHYSICS_PRISMATIC_JOINT_ID) | PHYSICS_JOINT_T;
-	const bits PHYSICS_REVOLUTE_JOINT_T = (bits(1) << PHYSICS_REVOLUTE_JOINT_ID) | PHYSICS_JOINT_T;
-	const bits PHYSICS_PULLEY_JOINT_T = (bits(1) << PHYSICS_PULLEY_JOINT_ID) | PHYSICS_JOINT_T;
-	const bits PHYSICS_GEAR_JOINT_T = (bits(1) << PHYSICS_GEAR_JOINT_ID) | PHYSICS_JOINT_T;
-	const bits PHYSICS_FRICTION_JOINT_T = (bits(1) << PHYSICS_FRICTION_JOINT_ID) | PHYSICS_JOINT_T;
-	const bits PHYSICS_WELD_JOINT_T = (bits(1) << PHYSICS_WELD_JOINT_ID) | PHYSICS_JOINT_T;
-	const bits PHYSICS_ROPE_JOINT_T = (bits(1) << PHYSICS_ROPE_JOINT_ID) | PHYSICS_JOINT_T;
-	const bits PHYSICS_WHEEL_JOINT_T = (bits(1) << PHYSICS_WHEEL_JOINT_ID) | PHYSICS_JOINT_T;
-
-	// Thread.
-	const bits THREAD_THREAD_T = (bits(1) << THREAD_THREAD_ID) | OBJECT_T;
-
-	// Modules.
-	const bits MODULE_FILESYSTEM_T = (bits(1) << MODULE_FILESYSTEM_ID) | MODULE_T;
-	const bits MODULE_IMAGE_T = (bits(1) << MODULE_IMAGE_ID) | MODULE_T;
-	const bits MODULE_SOUND_T = (bits(1) << MODULE_SOUND_ID) | MODULE_T;
-
-	bool getType(const char * in, Type & out);
-	bool getType(Type in, const char *& out);
-
-} // love
-
-#endif // LOVE_TYPES_H
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#ifndef LOVE_TYPES_H
+#define LOVE_TYPES_H
+
+// STD
+#include <bitset>
+
+namespace love
+{
+	enum Type
+	{
+		INVALID_ID = 0,
+		// Cross-module types.
+		OBJECT_ID,
+		DATA_ID,
+		MODULE_ID,
+
+		// Filesystem.
+		FILESYSTEM_FILE_ID,
+		FILESYSTEM_FILE_DATA_ID,
+
+		// Font
+		FONT_GLYPH_DATA_ID,
+		FONT_RASTERIZER_ID,
+
+		// Graphics
+		GRAPHICS_DRAWABLE_ID,
+		GRAPHICS_DRAWQABLE_ID,
+		GRAPHICS_IMAGE_ID,
+		GRAPHICS_QUAD_ID,
+		GRAPHICS_FONT_ID,
+		GRAPHICS_PARTICLE_SYSTEM_ID,
+		GRAPHICS_SPRITE_BATCH_ID,
+		GRAPHICS_CANVAS_ID,
+		GRAPHICS_PIXELEFFECT_ID,
+
+		// Image
+		IMAGE_IMAGE_DATA_ID,
+		IMAGE_ENCODED_IMAGE_DATA_ID,
+
+		// Audio
+		AUDIO_SOURCE_ID,
+
+		// Sound
+		SOUND_SOUND_DATA_ID,
+		SOUND_DECODER_ID,
+
+		// Physics
+		PHYSICS_WORLD_ID,
+		PHYSICS_CONTACT_ID,
+		PHYSICS_BODY_ID,
+		PHYSICS_FIXTURE_ID,
+		PHYSICS_SHAPE_ID,
+		PHYSICS_CIRCLE_SHAPE_ID,
+		PHYSICS_POLYGON_SHAPE_ID,
+		PHYSICS_EDGE_SHAPE_ID,
+		PHYSICS_CHAIN_SHAPE_ID,
+		PHYSICS_JOINT_ID,
+		PHYSICS_MOUSE_JOINT_ID,
+		PHYSICS_DISTANCE_JOINT_ID,
+		PHYSICS_PRISMATIC_JOINT_ID,
+		PHYSICS_REVOLUTE_JOINT_ID,
+		PHYSICS_PULLEY_JOINT_ID,
+		PHYSICS_GEAR_JOINT_ID,
+		PHYSICS_FRICTION_JOINT_ID,
+		PHYSICS_WELD_JOINT_ID,
+		PHYSICS_ROPE_JOINT_ID,
+		PHYSICS_WHEEL_JOINT_ID,
+
+		// Thread
+		THREAD_THREAD_ID,
+
+		// The modules themselves. Only add abstracted modules here.
+		MODULE_FILESYSTEM_ID,
+		MODULE_IMAGE_ID,
+		MODULE_SOUND_ID,
+
+		// Count the number of bits needed.
+		TYPE_MAX_ENUM
+	};
+
+	typedef std::bitset<TYPE_MAX_ENUM> bits;
+
+	const bits INVALID_T = bits(1) << INVALID_ID;
+
+	const bits OBJECT_T = bits(1) << OBJECT_ID;
+	const bits DATA_T = (bits(1) << DATA_ID) | OBJECT_T;
+	const bits MODULE_T = (bits(1) << MODULE_ID) | OBJECT_T;
+
+	// Filesystem.
+	const bits FILESYSTEM_FILE_T = (bits(1) << FILESYSTEM_FILE_ID) | OBJECT_T;
+	const bits FILESYSTEM_FILE_DATA_T = (bits(1) << FILESYSTEM_FILE_DATA_ID) | DATA_T;
+
+	const bits FONT_GLYPH_DATA_T = (bits(1) << FONT_GLYPH_DATA_ID) | DATA_T;
+	const bits FONT_RASTERIZER_T = (bits(1) << FONT_RASTERIZER_ID) | OBJECT_T;
+
+	// Graphics.
+	const bits GRAPHICS_DRAWABLE_T = (bits(1) << GRAPHICS_DRAWABLE_ID) | OBJECT_T;
+	const bits GRAPHICS_DRAWQABLE_T = (bits(1) << GRAPHICS_DRAWQABLE_ID) | GRAPHICS_DRAWABLE_T;
+	const bits GRAPHICS_IMAGE_T = (bits(1) << GRAPHICS_IMAGE_ID) | GRAPHICS_DRAWQABLE_T;
+	const bits GRAPHICS_QUAD_T = (bits(1) << GRAPHICS_QUAD_ID) | OBJECT_T;
+	const bits GRAPHICS_FONT_T = (bits(1) << GRAPHICS_FONT_ID) | OBJECT_T;
+	const bits GRAPHICS_PARTICLE_SYSTEM_T = (bits(1) << GRAPHICS_PARTICLE_SYSTEM_ID) | GRAPHICS_DRAWABLE_T;
+	const bits GRAPHICS_SPRITE_BATCH_T = (bits(1) << GRAPHICS_SPRITE_BATCH_ID) | GRAPHICS_DRAWABLE_T;
+	const bits GRAPHICS_CANVAS_T = (bits(1) << GRAPHICS_CANVAS_ID) | GRAPHICS_DRAWQABLE_T;
+	const bits GRAPHICS_PIXELEFFECT_T = (bits(1) << GRAPHICS_PIXELEFFECT_ID) | OBJECT_T;
+
+	// Image.
+	const bits IMAGE_IMAGE_DATA_T = (bits(1) << IMAGE_IMAGE_DATA_ID) | DATA_T;
+	const bits IMAGE_ENCODED_IMAGE_DATA_T = (bits(1) << IMAGE_ENCODED_IMAGE_DATA_ID) | DATA_T;
+
+	// Audio.
+	const bits AUDIO_SOURCE_T = (bits(1) << AUDIO_SOURCE_ID) | OBJECT_T;
+
+	// Sound.
+	const bits SOUND_SOUND_DATA_T = (bits(1) << SOUND_SOUND_DATA_ID) | DATA_T;
+	const bits SOUND_DECODER_T = bits(1) << SOUND_DECODER_ID;
+
+	// Physics.
+	const bits PHYSICS_WORLD_T = (bits(1) << PHYSICS_WORLD_ID) | OBJECT_T;
+	const bits PHYSICS_CONTACT_T = (bits(1) << PHYSICS_CONTACT_ID) | OBJECT_T;
+	const bits PHYSICS_BODY_T = (bits(1) << PHYSICS_BODY_ID) | OBJECT_T;
+	const bits PHYSICS_FIXTURE_T = (bits(1) << PHYSICS_FIXTURE_ID) | OBJECT_T;
+	const bits PHYSICS_SHAPE_T = (bits(1) << PHYSICS_SHAPE_ID) | OBJECT_T;
+	const bits PHYSICS_CIRCLE_SHAPE_T = (bits(1) << PHYSICS_CIRCLE_SHAPE_ID) | PHYSICS_SHAPE_T;
+	const bits PHYSICS_POLYGON_SHAPE_T = (bits(1) << PHYSICS_POLYGON_SHAPE_ID) | PHYSICS_SHAPE_T;
+	const bits PHYSICS_EDGE_SHAPE_T = (bits(1) << PHYSICS_EDGE_SHAPE_ID) | PHYSICS_SHAPE_T;
+	const bits PHYSICS_CHAIN_SHAPE_T = (bits(1) << PHYSICS_CHAIN_SHAPE_ID) | PHYSICS_SHAPE_T;
+	const bits PHYSICS_JOINT_T = (bits(1) << PHYSICS_JOINT_ID) | OBJECT_T;
+	const bits PHYSICS_MOUSE_JOINT_T = (bits(1) << PHYSICS_MOUSE_JOINT_ID) | PHYSICS_JOINT_T;
+	const bits PHYSICS_DISTANCE_JOINT_T = (bits(1) << PHYSICS_DISTANCE_JOINT_ID) | PHYSICS_JOINT_T;
+	const bits PHYSICS_PRISMATIC_JOINT_T = (bits(1) << PHYSICS_PRISMATIC_JOINT_ID) | PHYSICS_JOINT_T;
+	const bits PHYSICS_REVOLUTE_JOINT_T = (bits(1) << PHYSICS_REVOLUTE_JOINT_ID) | PHYSICS_JOINT_T;
+	const bits PHYSICS_PULLEY_JOINT_T = (bits(1) << PHYSICS_PULLEY_JOINT_ID) | PHYSICS_JOINT_T;
+	const bits PHYSICS_GEAR_JOINT_T = (bits(1) << PHYSICS_GEAR_JOINT_ID) | PHYSICS_JOINT_T;
+	const bits PHYSICS_FRICTION_JOINT_T = (bits(1) << PHYSICS_FRICTION_JOINT_ID) | PHYSICS_JOINT_T;
+	const bits PHYSICS_WELD_JOINT_T = (bits(1) << PHYSICS_WELD_JOINT_ID) | PHYSICS_JOINT_T;
+	const bits PHYSICS_ROPE_JOINT_T = (bits(1) << PHYSICS_ROPE_JOINT_ID) | PHYSICS_JOINT_T;
+	const bits PHYSICS_WHEEL_JOINT_T = (bits(1) << PHYSICS_WHEEL_JOINT_ID) | PHYSICS_JOINT_T;
+
+	// Thread.
+	const bits THREAD_THREAD_T = (bits(1) << THREAD_THREAD_ID) | OBJECT_T;
+
+	// Modules.
+	const bits MODULE_FILESYSTEM_T = (bits(1) << MODULE_FILESYSTEM_ID) | MODULE_T;
+	const bits MODULE_IMAGE_T = (bits(1) << MODULE_IMAGE_ID) | MODULE_T;
+	const bits MODULE_SOUND_T = (bits(1) << MODULE_SOUND_ID) | MODULE_T;
+
+	bool getType(const char * in, Type & out);
+	bool getType(Type in, const char *& out);
+
+} // love
+
+#endif // LOVE_TYPES_H

+ 5 - 5
src/common/utf8.cpp

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -48,9 +48,9 @@ namespace love
 	{
 		int length = str.length();
 
-		for(int i = 0; i<length; i++)
+		for (int i = 0; i<length; i++)
 		{
-			if(str[i] == find)
+			if (str[i] == find)
 				str[i] = replace;
 		}
 	}

+ 3 - 3
src/common/utf8.h

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be

+ 4 - 4
src/common/wrap_Data.cpp

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -52,5 +52,5 @@ namespace love
 		luax_register_type(L, "Data", w_Data_functions);
 		return 0;
 	}
-	
+
 } // love

+ 3 - 3
src/common/wrap_Data.h

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be

+ 12 - 11
src/love.cpp

@@ -112,7 +112,7 @@ extern "C" LOVE_EXPORT int luaopen_love(lua_State * L)
 
 	lua_newtable(L);
 
-	for(int i = 0; love::VERSION_COMPATIBILITY[i] != 0; ++i)
+	for (int i = 0; love::VERSION_COMPATIBILITY[i] != 0; ++i)
 	{
 		lua_pushstring(L, love::VERSION_COMPATIBILITY[i]);
 		lua_rawseti(L, -2, i+1);
@@ -125,7 +125,7 @@ extern "C" LOVE_EXPORT int luaopen_love(lua_State * L)
 #ifdef LOVE_BUILD_STANDALONE
 
 	// Preload module loaders.
-	for(int i = 0; modules[i].name != 0; i++)
+	for (int i = 0; modules[i].name != 0; i++)
 	{
 		love::luax_preload(L, modules[i].func, modules[i].name);
 	}
@@ -143,14 +143,14 @@ void get_utf8_arguments(int & argc, char **& argv)
 {
 	LPWSTR cmd = GetCommandLineW();
 
-	if(!cmd)
+	if (!cmd)
 		return;
 
 	LPWSTR * argv_w = CommandLineToArgvW(cmd, &argc);
 
 	argv = new char*[argc];
 
-	for(int i = 0; i<argc; ++i)
+	for (int i = 0; i<argc; ++i)
 	{
 		// Size of wide char buffer (plus one for trailing '\0').
 		size_t wide_len = wcslen(argv_w[i])+1;
@@ -165,7 +165,7 @@ void get_utf8_arguments(int & argc, char **& argv)
 
 		int len = strlen(argv[i]);
 
-		if(!ok)
+		if (!ok)
 			printf("Warning: could not convert to UTF8.\n");
 	}
 
@@ -180,7 +180,7 @@ int w__openConsole(lua_State * L)
 {
 	static bool is_open = false;
 
-	if(is_open)
+	if (is_open)
 		return 0;
 
 	static const int MAX_CONSOLE_LINES = 5000;
@@ -242,7 +242,8 @@ int main(int argc, char ** argv)
 #endif // LOVE_LEGENDARY_UTF8_ARGV_HACK
 
 	// Oh, you just want the version? Okay!
-	if(argc > 1 && strcmp(argv[1],"--version") == 0) {
+	if (argc > 1 && strcmp(argv[1],"--version") == 0)
+	{
 		printf("LOVE %s (%s)\n", love::VERSION, love::VERSION_CODENAME);
 		return 0;
 	}
@@ -259,7 +260,7 @@ int main(int argc, char ** argv)
 	{
 		lua_newtable(L);
 
-		if(argc > 0)
+		if (argc > 0)
 		{
 			lua_pushstring(L, argv[0]);
 			lua_rawseti(L, -2, -2);
@@ -268,7 +269,7 @@ int main(int argc, char ** argv)
 		lua_pushstring(L, "embedded boot.lua");
 		lua_rawseti(L, -2, -1);
 
-		for(int i = 1; i<argc; i++)
+		for (int i = 1; i<argc; i++)
 		{
 			lua_pushstring(L, argv[i]);
 			lua_rawseti(L, -2, i);
@@ -295,9 +296,9 @@ int main(int argc, char ** argv)
 	lua_close(L);
 
 #ifdef LOVE_LEGENDARY_UTF8_ARGV_HACK
-	if(hack_argv)
+	if (hack_argv)
 	{
-		for(int i = 0; i<hack_argc; ++i)
+		for (int i = 0; i<hack_argc; ++i)
 			delete [] hack_argv[i];
 		delete [] hack_argv;
 	}

+ 199 - 199
src/modules/audio/Audio.h

@@ -1,199 +1,199 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-* 
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-* 
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-* 
-* 1. The origin of this software must not be misrepresented = 0; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#ifndef LOVE_AUDIO_AUDIO_H
-#define LOVE_AUDIO_AUDIO_H
-
-#include <common/Module.h>
-#include "Source.h"
-
-namespace love
-{
-namespace sound
-{
-	class Decoder;
-	class SoundData;
-}
-namespace audio
-{
-	/**
-	* The Audio module is responsible for playing back raw sound samples. 
-	**/
-	class Audio : public Module
-	{
-	public:
-
-		/**
-		* Destructor.
-		**/
-		virtual ~Audio(){};
-
-		virtual Source * newSource(love::sound::Decoder * decoder) = 0;
-		virtual Source * newSource(love::sound::SoundData * soundData) = 0;
-
-		/**
-		* Gets the current number of simultaneous playing sources.
-		* @return The current number of simultaneous playing sources.
-		**/
-		virtual int getNumSources() const = 0;
-
-		/**
-		* Gets the maximum supported number of simultaneous playing sources.
-		* @return The maximum supported number of simultaneous playing sources.
-		**/
-		virtual int getMaxSources() const = 0;
-
-		/**
-		* Play the specified Source.
-		* @param source The Source to play.
-		**/
-		virtual void play(Source * source) = 0;
-
-		/**
-		* Stops playback on the specified source.
-		* @param source The source on which to stop the playback.
-		**/
-		virtual void stop(Source * source) = 0;
-
-		/**
-		* Stops all playing audio.
-		**/
-		virtual void stop() = 0;
-
-		/**
-		* Pauses playback on the specified source.
-		* @param source The source on which to pause the playback.
-		**/
-		virtual void pause(Source * source) = 0;
-
-		/**
-		* Pauses all audio.
-		**/
-		virtual void pause() = 0;
-
-		/**
-		* Resumes playback on the specified source.
-		* @param source The source on which to resume the playback.
-		**/
-		virtual void resume(Source * source) = 0;
-
-		/**
-		* Resumes all audio.
-		**/
-		virtual void resume() = 0;
-
-		/**
-		* Rewinds the specified source. Whatever is playing on this
-		* source gets rewound to the start.
-		* @param source The source to rewind.
-		**/
-		virtual void rewind(Source * source) = 0;
-
-		/**
-		* Rewinds all playing audio.
-		**/
-		virtual void rewind() = 0;
-
-		/**
-		* Sets the master volume, where 0.0f is min (off) and 1.0f is max.
-		* @param volume The new master volume.
-		**/
-		virtual void setVolume(float volume) = 0;
-
-		/**
-		* Gets the master volume.
-		* @return The current master volume.
-		**/
-		virtual float getVolume() const = 0;
-
-		/**
-		* Gets the position of the listener.
-		* @param v A float array of size 3 containing (x,y,z) in that order. 
-		**/
-		virtual void getPosition(float * v) const = 0;
-
-		/**
-		* Sets the position of the listener.
-		* @param v A float array of size 3 containing [x,y,z] in that order. 
-		**/
-		virtual void setPosition(float * v) = 0;
-
-		/**
-		* Gets the orientation of the listener.
-		* @param v A float array of size 6 containing [x,y,z] for the forward
-		* vector, followed by [x,y,z] for the up vector.
-		**/
-		virtual void getOrientation(float * v) const = 0;
-
-		/**
-		* Sets the orientation of the listener.
-		* @param v A float array of size 6 containing [x,y,z] for the forward
-		* vector, followed by [x,y,z] for the up vector.
-		**/
-		virtual void setOrientation(float * v) = 0;
-
-		/**
-		* Gets the velocity of the listener.
-		* @param v A float array of size 3 containing [x,y,z] in that order. 
-		**/
-		virtual void getVelocity(float * v) const = 0;
-
-		/**
-		* Sets the velocity of the listener.
-		* @param v A float array of size 3 containing [x,y,z] in that order. 
-		**/
-		virtual void setVelocity(float * v) = 0;
-		
-		/**
-		* Begins recording audio input from the microphone.
-		**/
-		virtual void record() = 0;
-		
-		/**
-		* Gets a section of recorded audio.
-		* Per OpenAL, the measurement begins from the start of the
-		* audio data in memory, which is after the last time this function
-		* was called. If this function has not been called yet this recording
-		* session, it just grabs from the beginning.
-		* @return All the recorded SoundData thus far.
-		**/
-		virtual love::sound::SoundData * getRecordedData() = 0;
-		
-		/**
-		* Stops recording and, if passed true, returns all the recorded audio
-		* not already gotten by getRecordedData.
-		* @param returnData Whether to return recorded audio.
-		* @return if returnData, all the recorded audio yet to be gotten,
-		* otherwise NULL.
-		**/
-		virtual love::sound::SoundData * stopRecording(bool returnData) = 0;
-		
-		/**
-		* Checks whether LOVE is able to record audio input.
-		* @return hasMic Whether LOVE has a microphone enabled.
-		**/
-		virtual bool canRecord() = 0;
-
-	}; // Audio
-
-} // audio
-} // love
-
-#endif // LOVE_AUDIO_AUDIO_H
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented = 0; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#ifndef LOVE_AUDIO_AUDIO_H
+#define LOVE_AUDIO_AUDIO_H
+
+#include <common/Module.h>
+#include "Source.h"
+
+namespace love
+{
+namespace sound
+{
+	class Decoder;
+	class SoundData;
+}
+namespace audio
+{
+	/**
+	* The Audio module is responsible for playing back raw sound samples.
+	**/
+	class Audio : public Module
+	{
+	public:
+
+		/**
+		* Destructor.
+		**/
+		virtual ~Audio(){};
+
+		virtual Source * newSource(love::sound::Decoder * decoder) = 0;
+		virtual Source * newSource(love::sound::SoundData * soundData) = 0;
+
+		/**
+		* Gets the current number of simultaneous playing sources.
+		* @return The current number of simultaneous playing sources.
+		**/
+		virtual int getNumSources() const = 0;
+
+		/**
+		* Gets the maximum supported number of simultaneous playing sources.
+		* @return The maximum supported number of simultaneous playing sources.
+		**/
+		virtual int getMaxSources() const = 0;
+
+		/**
+		* Play the specified Source.
+		* @param source The Source to play.
+		**/
+		virtual void play(Source * source) = 0;
+
+		/**
+		* Stops playback on the specified source.
+		* @param source The source on which to stop the playback.
+		**/
+		virtual void stop(Source * source) = 0;
+
+		/**
+		* Stops all playing audio.
+		**/
+		virtual void stop() = 0;
+
+		/**
+		* Pauses playback on the specified source.
+		* @param source The source on which to pause the playback.
+		**/
+		virtual void pause(Source * source) = 0;
+
+		/**
+		* Pauses all audio.
+		**/
+		virtual void pause() = 0;
+
+		/**
+		* Resumes playback on the specified source.
+		* @param source The source on which to resume the playback.
+		**/
+		virtual void resume(Source * source) = 0;
+
+		/**
+		* Resumes all audio.
+		**/
+		virtual void resume() = 0;
+
+		/**
+		* Rewinds the specified source. Whatever is playing on this
+		* source gets rewound to the start.
+		* @param source The source to rewind.
+		**/
+		virtual void rewind(Source * source) = 0;
+
+		/**
+		* Rewinds all playing audio.
+		**/
+		virtual void rewind() = 0;
+
+		/**
+		* Sets the master volume, where 0.0f is min (off) and 1.0f is max.
+		* @param volume The new master volume.
+		**/
+		virtual void setVolume(float volume) = 0;
+
+		/**
+		* Gets the master volume.
+		* @return The current master volume.
+		**/
+		virtual float getVolume() const = 0;
+
+		/**
+		* Gets the position of the listener.
+		* @param v A float array of size 3 containing (x,y,z) in that order.
+		**/
+		virtual void getPosition(float * v) const = 0;
+
+		/**
+		* Sets the position of the listener.
+		* @param v A float array of size 3 containing [x,y,z] in that order.
+		**/
+		virtual void setPosition(float * v) = 0;
+
+		/**
+		* Gets the orientation of the listener.
+		* @param v A float array of size 6 containing [x,y,z] for the forward
+		* vector, followed by [x,y,z] for the up vector.
+		**/
+		virtual void getOrientation(float * v) const = 0;
+
+		/**
+		* Sets the orientation of the listener.
+		* @param v A float array of size 6 containing [x,y,z] for the forward
+		* vector, followed by [x,y,z] for the up vector.
+		**/
+		virtual void setOrientation(float * v) = 0;
+
+		/**
+		* Gets the velocity of the listener.
+		* @param v A float array of size 3 containing [x,y,z] in that order.
+		**/
+		virtual void getVelocity(float * v) const = 0;
+
+		/**
+		* Sets the velocity of the listener.
+		* @param v A float array of size 3 containing [x,y,z] in that order.
+		**/
+		virtual void setVelocity(float * v) = 0;
+
+		/**
+		* Begins recording audio input from the microphone.
+		**/
+		virtual void record() = 0;
+
+		/**
+		* Gets a section of recorded audio.
+		* Per OpenAL, the measurement begins from the start of the
+		* audio data in memory, which is after the last time this function
+		* was called. If this function has not been called yet this recording
+		* session, it just grabs from the beginning.
+		* @return All the recorded SoundData thus far.
+		**/
+		virtual love::sound::SoundData * getRecordedData() = 0;
+
+		/**
+		* Stops recording and, if passed true, returns all the recorded audio
+		* not already gotten by getRecordedData.
+		* @param returnData Whether to return recorded audio.
+		* @return if returnData, all the recorded audio yet to be gotten,
+		* otherwise NULL.
+		**/
+		virtual love::sound::SoundData * stopRecording(bool returnData) = 0;
+
+		/**
+		* Checks whether LOVE is able to record audio input.
+		* @return hasMic Whether LOVE has a microphone enabled.
+		**/
+		virtual bool canRecord() = 0;
+
+	}; // Audio
+
+} // audio
+} // love
+
+#endif // LOVE_AUDIO_AUDIO_H

+ 73 - 73
src/modules/audio/Source.cpp

@@ -1,73 +1,73 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-*
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-*
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-*
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#include "Source.h"
-
-namespace love
-{
-namespace audio
-{
-	Source::Source(Type type)
-		: type(type)
-	{
-	}
-
-	Source::~Source()
-	{
-	}
-
-	bool Source::getConstant(const char * in, Type & out)
-	{
-		return types.find(in, out);
-	}
-
-	bool Source::getConstant(Type in, const char *& out)
-	{
-		return types.find(in, out);
-	}
-	
-	bool Source::getConstant(const char * in, Unit & out)
-	{
-		return units.find(in, out);
-	}
-	
-	bool Source::getConstant(Unit in, const char *& out)
-	{
-		return units.find(in, out);
-	}
-
-	StringMap<Source::Type, Source::TYPE_MAX_ENUM>::Entry Source::typeEntries[] =
-	{
-		{"static", Source::TYPE_STATIC},
-		{"stream", Source::TYPE_STREAM},
-	};
-
-	StringMap<Source::Type, Source::TYPE_MAX_ENUM> Source::types(Source::typeEntries, sizeof(Source::typeEntries));
-	
-	StringMap<Source::Unit, Source::UNIT_MAX_ENUM>::Entry Source::unitEntries[] =
-	{
-		{"seconds", Source::UNIT_SECONDS},
-		{"samples", Source::UNIT_SAMPLES},
-	};
-	
-	StringMap<Source::Unit, Source::UNIT_MAX_ENUM> Source::units(Source::unitEntries, sizeof(Source::unitEntries));
-
-} // audio
-} // love
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#include "Source.h"
+
+namespace love
+{
+namespace audio
+{
+	Source::Source(Type type)
+		: type(type)
+	{
+	}
+
+	Source::~Source()
+	{
+	}
+
+	bool Source::getConstant(const char * in, Type & out)
+	{
+		return types.find(in, out);
+	}
+
+	bool Source::getConstant(Type in, const char *& out)
+	{
+		return types.find(in, out);
+	}
+
+	bool Source::getConstant(const char * in, Unit & out)
+	{
+		return units.find(in, out);
+	}
+
+	bool Source::getConstant(Unit in, const char *& out)
+	{
+		return units.find(in, out);
+	}
+
+	StringMap<Source::Type, Source::TYPE_MAX_ENUM>::Entry Source::typeEntries[] =
+	{
+		{"static", Source::TYPE_STATIC},
+		{"stream", Source::TYPE_STREAM},
+	};
+
+	StringMap<Source::Type, Source::TYPE_MAX_ENUM> Source::types(Source::typeEntries, sizeof(Source::typeEntries));
+
+	StringMap<Source::Unit, Source::UNIT_MAX_ENUM>::Entry Source::unitEntries[] =
+	{
+		{"seconds", Source::UNIT_SECONDS},
+		{"samples", Source::UNIT_SAMPLES},
+	};
+
+	StringMap<Source::Unit, Source::UNIT_MAX_ENUM> Source::units(Source::unitEntries, sizeof(Source::unitEntries));
+
+} // audio
+} // love

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

@@ -1,107 +1,107 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-*
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-*
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-*
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#ifndef LOVE_AUDIO_SOURCE_H
-#define LOVE_AUDIO_SOURCE_H
-
-// LOVE
-#include <common/Object.h>
-#include <common/StringMap.h>
-
-namespace love
-{
-namespace audio
-{
-	class Source : public Object
-	{
-	public:
-
-		enum Type
-		{
-			TYPE_STATIC = 1,
-			TYPE_STREAM,
-			TYPE_MAX_ENUM
-		}; // Type
-		
-		enum Unit
-		{
-			UNIT_SECONDS = 1,
-			UNIT_SAMPLES,
-			UNIT_MAX_ENUM
-		};
-
-	protected:
-		Type type;
-	public:
-
-		Source(Type type);
-		virtual ~Source();
-
-		virtual Source * copy() = 0;
-
-		virtual void play() = 0;
-		virtual void stop() = 0;
-		virtual void pause() = 0;
-		virtual void resume() = 0;
-		virtual void rewind() = 0;
-		virtual bool isStopped() const = 0;
-		virtual bool isPaused() const = 0;
-		virtual bool isFinished() const = 0;
-		virtual bool update() = 0;
-
-		virtual void setPitch(float pitch) = 0;
-		virtual float getPitch() const = 0;
-
-		virtual void setVolume(float volume) = 0;
-		virtual float getVolume() const = 0;
-		
-		virtual void seek(float offset, Unit unit) = 0;
-		virtual float tell(Unit unit) = 0;
-
-		// all float * v must be of size 3
-		virtual void setPosition(float * v) = 0;
-		virtual void getPosition(float * v) const = 0;
-		virtual void setVelocity(float * v) = 0;
-		virtual void getVelocity(float * v) const = 0;
-		virtual void setDirection(float * v) = 0;
-		virtual void getDirection(float * v) const = 0;
-
-		virtual void setLooping(bool looping) = 0;
-		virtual bool isLooping() const = 0;
-		virtual bool isStatic() const = 0;
-
-		static bool getConstant(const char * in, Type & out);
-		static bool getConstant(Type in, const char *& out);
-		static bool getConstant(const char * in, Unit & out);
-		static bool getConstant(Unit in, const char *& out);
-
-	private:
-
-		static StringMap<Type, TYPE_MAX_ENUM>::Entry typeEntries[];
-		static StringMap<Type, TYPE_MAX_ENUM> types;
-		static StringMap<Unit, UNIT_MAX_ENUM>::Entry unitEntries[];
-		static StringMap<Unit, UNIT_MAX_ENUM> units;
-
-	}; // Source
-
-} // audio
-} // love
-
-#endif // LOVE_AUDIO_SOURCE_H
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#ifndef LOVE_AUDIO_SOURCE_H
+#define LOVE_AUDIO_SOURCE_H
+
+// LOVE
+#include <common/Object.h>
+#include <common/StringMap.h>
+
+namespace love
+{
+namespace audio
+{
+	class Source : public Object
+	{
+	public:
+
+		enum Type
+		{
+			TYPE_STATIC = 1,
+			TYPE_STREAM,
+			TYPE_MAX_ENUM
+		}; // Type
+
+		enum Unit
+		{
+			UNIT_SECONDS = 1,
+			UNIT_SAMPLES,
+			UNIT_MAX_ENUM
+		};
+
+	protected:
+		Type type;
+	public:
+
+		Source(Type type);
+		virtual ~Source();
+
+		virtual Source * copy() = 0;
+
+		virtual void play() = 0;
+		virtual void stop() = 0;
+		virtual void pause() = 0;
+		virtual void resume() = 0;
+		virtual void rewind() = 0;
+		virtual bool isStopped() const = 0;
+		virtual bool isPaused() const = 0;
+		virtual bool isFinished() const = 0;
+		virtual bool update() = 0;
+
+		virtual void setPitch(float pitch) = 0;
+		virtual float getPitch() const = 0;
+
+		virtual void setVolume(float volume) = 0;
+		virtual float getVolume() const = 0;
+
+		virtual void seek(float offset, Unit unit) = 0;
+		virtual float tell(Unit unit) = 0;
+
+		// all float * v must be of size 3
+		virtual void setPosition(float * v) = 0;
+		virtual void getPosition(float * v) const = 0;
+		virtual void setVelocity(float * v) = 0;
+		virtual void getVelocity(float * v) const = 0;
+		virtual void setDirection(float * v) = 0;
+		virtual void getDirection(float * v) const = 0;
+
+		virtual void setLooping(bool looping) = 0;
+		virtual bool isLooping() const = 0;
+		virtual bool isStatic() const = 0;
+
+		static bool getConstant(const char * in, Type & out);
+		static bool getConstant(Type in, const char *& out);
+		static bool getConstant(const char * in, Unit & out);
+		static bool getConstant(Unit in, const char *& out);
+
+	private:
+
+		static StringMap<Type, TYPE_MAX_ENUM>::Entry typeEntries[];
+		static StringMap<Type, TYPE_MAX_ENUM> types;
+		static StringMap<Unit, UNIT_MAX_ENUM>::Entry unitEntries[];
+		static StringMap<Unit, UNIT_MAX_ENUM> units;
+
+	}; // Source
+
+} // audio
+} // love
+
+#endif // LOVE_AUDIO_SOURCE_H

+ 7 - 7
src/modules/audio/null/Audio.cpp

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -132,21 +132,21 @@ namespace null
 	void Audio::setVelocity(float *)
 	{
 	}
-	
+
 	void Audio::record()
 	{
 	}
-	
+
 	love::sound::SoundData * Audio::getRecordedData()
 	{
 		return NULL;
 	}
-	
+
 	love::sound::SoundData * Audio::stopRecording(bool)
 	{
 		return NULL;
 	}
-	
+
 	bool Audio::canRecord()
 	{
 		return false;

+ 4 - 4
src/modules/audio/null/Audio.h

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -68,7 +68,7 @@ namespace null
 		void setOrientation(float * v);
 		void getVelocity(float * v) const;
 		void setVelocity(float * v);
-		
+
 		void record();
 		love::sound::SoundData * getRecordedData();
 		love::sound::SoundData * stopRecording(bool returnData);

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

@@ -101,11 +101,11 @@ namespace null
 	{
 		return volume;
 	}
-	
+
 	void Source::seek(float, Source::Unit)
 	{
 	}
-	
+
 	float Source::tell(Source::Unit)
 	{
 		return 0.0f;

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

@@ -1,78 +1,78 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-*
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-*
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-*
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#ifndef LOVE_AUDIO_NULL_SOURCE_H
-#define LOVE_AUDIO_NULL_SOURCE_H
-
-// LOVE
-#include <common/Object.h>
-#include <audio/Source.h>
-
-namespace love
-{
-namespace audio
-{
-namespace null
-{
-	class Source : public love::audio::Source
-	{
-	private:
-
-		float pitch;
-		float volume;
-		bool looping;
-
-	public:
-		Source();
-		virtual ~Source();
-
-		virtual love::audio::Source * copy();
-		virtual void play();
-		virtual void stop();
-		virtual void pause();
-		virtual void resume();
-		virtual void rewind();
-		virtual bool isStopped() const;
-		virtual bool isPaused() const;
-		virtual bool isFinished() const;
-		virtual bool update();
-		virtual void setPitch(float pitch);
-		virtual float getPitch() const;
-		virtual void setVolume(float volume);
-		virtual float getVolume() const;
-		virtual void seek(float offset, Unit unit);
-		virtual float tell(Unit unit);
-		virtual void setPosition(float * v);
-		virtual void getPosition(float * v) const;
-		virtual void setVelocity(float * v);
-		virtual void getVelocity(float * v) const;
-		virtual void setDirection(float * v);
-		virtual void getDirection(float * v) const;
-		void setLooping(bool looping);
-		bool isLooping() const;
-		bool isStatic() const;
-
-	}; // Source
-
-} // null
-} // audio
-} // love
-
-#endif // LOVE_AUDIO_NULL_SOURCE_H
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#ifndef LOVE_AUDIO_NULL_SOURCE_H
+#define LOVE_AUDIO_NULL_SOURCE_H
+
+// LOVE
+#include <common/Object.h>
+#include <audio/Source.h>
+
+namespace love
+{
+namespace audio
+{
+namespace null
+{
+	class Source : public love::audio::Source
+	{
+	private:
+
+		float pitch;
+		float volume;
+		bool looping;
+
+	public:
+		Source();
+		virtual ~Source();
+
+		virtual love::audio::Source * copy();
+		virtual void play();
+		virtual void stop();
+		virtual void pause();
+		virtual void resume();
+		virtual void rewind();
+		virtual bool isStopped() const;
+		virtual bool isPaused() const;
+		virtual bool isFinished() const;
+		virtual bool update();
+		virtual void setPitch(float pitch);
+		virtual float getPitch() const;
+		virtual void setVolume(float volume);
+		virtual float getVolume() const;
+		virtual void seek(float offset, Unit unit);
+		virtual float tell(Unit unit);
+		virtual void setPosition(float * v);
+		virtual void getPosition(float * v) const;
+		virtual void setVelocity(float * v);
+		virtual void getVelocity(float * v) const;
+		virtual void setDirection(float * v);
+		virtual void getDirection(float * v) const;
+		void setLooping(bool looping);
+		bool isLooping() const;
+		bool isStatic() const;
+
+	}; // Source
+
+} // null
+} // audio
+} // love
+
+#endif // LOVE_AUDIO_NULL_SOURCE_H

+ 33 - 25
src/modules/audio/openal/Audio.cpp

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -30,16 +30,18 @@ namespace audio
 namespace openal
 {
 	Audio::PoolThread::PoolThread(Pool* pool)
-	: pool(pool), finish(false) {
-
+	: pool(pool), finish(false)
+	{
 	}
 
 	void Audio::PoolThread::main()
 	{
-		while(true) {
+		while (true)
+		{
 			{
 				thread::Lock lock(mutex);
-				if (finish) {
+				if (finish)
+				{
 					return;
 				}
 			}
@@ -61,32 +63,35 @@ namespace openal
 		// Passing zero for default device.
 		device = alcOpenDevice(0);
 
-		if(device == 0)
+		if (device == 0)
 			throw love::Exception("Could not open device.");
 
 		context = alcCreateContext(device, 0);
 
-		if(context == 0)
+		if (context == 0)
 			throw love::Exception("Could not create context.");
 
 		alcMakeContextCurrent(context);
 
-		if(alcGetError(device) != ALC_NO_ERROR)
+		if (alcGetError(device) != ALC_NO_ERROR)
 			throw love::Exception("Could not make context current.");
-		
+
 		/*std::string captureName(alcGetString(NULL, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER));
 		const ALCchar * devices = alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER);
-		while (*devices) {
+		while (*devices)
+		{
 			std::string device(devices);
 			devices += device.size() + 1;
-			if (device.find("Mic") != std::string::npos || device.find("mic") != std::string::npos) {
+			if (device.find("Mic") != std::string::npos || device.find("mic") != std::string::npos)
+			{
 				captureName = device;
 			}
 		}
-		
+
 		capture = alcCaptureOpenDevice(captureName.c_str(), 8000, AL_FORMAT_MONO16, 262144); // about 32 seconds
-		
-		if (!capture) {
+
+		if (!capture)
+		{
 			// We're not going to prevent LOVE from running without a microphone, but we should warn, at least
 			std::cerr << "Warning, couldn't open capture device! No audio input!" << std::endl;
 		}*/
@@ -105,7 +110,7 @@ namespace openal
 
 		delete poolThread;
 		delete pool;
-		
+
 		alcMakeContextCurrent(0);
 		alcDestroyContext(context);
 		//if (capture) alcCaptureCloseDevice(capture);
@@ -167,7 +172,7 @@ namespace openal
 	{
 		source->resume();
 	}
-	
+
 	void Audio::resume()
 	{
 		pool->resume();
@@ -224,16 +229,17 @@ namespace openal
 	{
 		alListenerfv(AL_VELOCITY, v);
 	}
-	
+
 	void Audio::record()
 	{
 		if (!canRecord()) return;
 		alcCaptureStart(capture);
 	}
-	
+
 	love::sound::SoundData * Audio::getRecordedData()
 	{
-		if (!canRecord()) return NULL;
+		if (!canRecord())
+			return NULL;
 		int samplerate = 8000;
 		ALCint samples;
 		alcGetIntegerv(capture, ALC_CAPTURE_SAMPLES, 4, &samples);
@@ -243,18 +249,20 @@ namespace openal
 		free(data);
 		return sd;
 	}
-	
+
 	love::sound::SoundData * Audio::stopRecording(bool returnData)
 	{
-		if (!canRecord()) return NULL;
+		if (!canRecord())
+			return NULL;
 		love::sound::SoundData * sd = NULL;
-		if (returnData) {
+		if (returnData)
+		{
 			sd = getRecordedData();
 		}
 		alcCaptureStop(capture);
 		return sd;
 	}
-	
+
 	bool Audio::canRecord()
 	{
 		return (capture != NULL);

+ 5 - 5
src/modules/audio/openal/Audio.h

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -57,7 +57,7 @@ namespace openal
 
 		// The OpenAL device.
 		ALCdevice * device;
-		
+
 		// The OpenAL capture device (microphone).
 		ALCdevice * capture;
 
@@ -121,7 +121,7 @@ namespace openal
 		void setOrientation(float * v);
 		void getVelocity(float * v) const;
 		void setVelocity(float * v);
-		
+
 		void record();
 		love::sound::SoundData * getRecordedData();
 		love::sound::SoundData * stopRecording(bool returnData);

+ 18 - 18
src/modules/audio/openal/Pool.cpp

@@ -36,11 +36,11 @@ namespace openal
 		// Create the mutex.
 		mutex = new thread::Mutex();
 
-		if(alGetError() != AL_NO_ERROR)
+		if (alGetError() != AL_NO_ERROR)
 			throw love::Exception("Could not generate sources.");
 
 		// Make all sources available initially.
-		for(int i = 0; i < NUM_SOURCES; i++)
+		for (int i = 0; i < NUM_SOURCES; i++)
 			available.push(sources[i]);
 	}
 
@@ -69,9 +69,9 @@ namespace openal
 		bool p = false;
 		{
 			thread::Lock lock(mutex);
-			for(std::map<Source *, ALuint>::iterator i = playing.begin(); i != playing.end(); i++)
+			for (std::map<Source *, ALuint>::iterator i = playing.begin(); i != playing.end(); i++)
 			{
-				if(i->first == s)
+				if (i->first == s)
 					p = true;
 			}
 		}
@@ -84,9 +84,9 @@ namespace openal
 
 		std::map<Source *, ALuint>::iterator i = playing.begin();
 
-		while(i != playing.end())
+		while (i != playing.end())
 		{
-			if(!i->first->update())
+			if (!i->first->update())
 			{
 				i->first->stopAtomic();
 				i->first->rewindAtomic();
@@ -118,10 +118,10 @@ namespace openal
 
 		bool alreadyPlaying = findSource(source, out);
 
-		if(!alreadyPlaying)
+		if (!alreadyPlaying)
 		{
 			// Try to play.
-			if(!available.empty())
+			if (!available.empty())
 			{
 				// Get the first available source.
 				out = available.front();
@@ -154,7 +154,7 @@ namespace openal
 	void Pool::stop()
 	{
 		thread::Lock lock(mutex);
-		for(std::map<Source *, ALuint>::iterator i = playing.begin(); i != playing.end(); i++)
+		for (std::map<Source *, ALuint>::iterator i = playing.begin(); i != playing.end(); i++)
 		{
 			i->first->stopAtomic();
 			i->first->release();
@@ -173,7 +173,7 @@ namespace openal
 	void Pool::pause()
 	{
 		thread::Lock lock(mutex);
-		for(std::map<Source *, ALuint>::iterator i = playing.begin(); i != playing.end(); i++)
+		for (std::map<Source *, ALuint>::iterator i = playing.begin(); i != playing.end(); i++)
 			i->first->pauseAtomic();
 	}
 
@@ -181,14 +181,14 @@ namespace openal
 	{
 		thread::Lock lock(mutex);
 		ALuint out;
-		if(findSource(source, out))
+		if (findSource(source, out))
 			source->pauseAtomic();
 	}
 
 	void Pool::resume()
 	{
 		thread::Lock lock(mutex);
-		for(std::map<Source *, ALuint>::iterator i = playing.begin(); i != playing.end(); i++)
+		for (std::map<Source *, ALuint>::iterator i = playing.begin(); i != playing.end(); i++)
 			i->first->resumeAtomic();
 	}
 
@@ -196,14 +196,14 @@ namespace openal
 	{
 		thread::Lock lock(mutex);
 		ALuint out;
-		if(findSource(source, out))
+		if (findSource(source, out))
 			source->resumeAtomic();
 	}
 
 	void Pool::rewind()
 	{
 		thread::Lock lock(mutex);
-		for(std::map<Source *, ALuint>::iterator i = playing.begin(); i != playing.end(); i++)
+		for (std::map<Source *, ALuint>::iterator i = playing.begin(); i != playing.end(); i++)
 			i->first->rewindAtomic();
 	}
 
@@ -224,7 +224,7 @@ namespace openal
 	{
 		ALuint s = findi(source);
 
-		if(s != 0)
+		if (s != 0)
 		{
 			available.push(s);
 			playing.erase(source);
@@ -247,7 +247,7 @@ namespace openal
 	{
 		std::map<Source *, ALuint>::const_iterator i = playing.find((Source *)source);
 
-		if(i != playing.end())
+		if (i != playing.end())
 			return i->second;
 
 		return 0;
@@ -259,7 +259,7 @@ namespace openal
 
 		bool found = i != playing.end();
 
-		if(found)
+		if (found)
 			out = i->second;
 
 		return found;
@@ -269,7 +269,7 @@ namespace openal
 	{
 		std::map<Source *, ALuint>::iterator i = playing.find((Source *)source);
 
-		if(i != playing.end())
+		if (i != playing.end())
 		{
 			source->stopAtomic();
 			available.push(i->second);

+ 3 - 3
src/modules/audio/openal/Pool.h

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be

+ 47 - 40
src/modules/audio/openal/Source.cpp

@@ -87,7 +87,7 @@ namespace openal
 
 		valid = pool->play(this, source);
 
-		if(valid)
+		if (valid)
 			reset(source);
 	}
 
@@ -117,7 +117,7 @@ namespace openal
 
 	bool Source::isStopped() const
 	{
-		if(valid)
+		if (valid)
 		{
 			ALenum state;
 			alGetSourcei(source, AL_SOURCE_STATE, &state);
@@ -129,7 +129,7 @@ namespace openal
 
 	bool Source::isPaused() const
 	{
-		if(valid)
+		if (valid)
 		{
 			ALenum state;
 			alGetSourcei(source, AL_SOURCE_STATE, &state);
@@ -161,7 +161,7 @@ namespace openal
 
 			alGetSourcei(source, AL_BUFFERS_PROCESSED, &processed);
 
-			while(processed--)
+			while (processed--)
 			{
 				ALuint buffer;
 
@@ -196,7 +196,7 @@ namespace openal
 
 	void Source::setPitch(float pitch)
 	{
-		if(valid)
+		if (valid)
 			alSourcef(source, AL_PITCH, pitch);
 
 		this->pitch = pitch;
@@ -204,7 +204,7 @@ namespace openal
 
 	float Source::getPitch() const
 	{
-		if(valid)
+		if (valid)
 		{
 			ALfloat f;
 			alGetSourcef(source, AL_PITCH, &f);
@@ -217,7 +217,7 @@ namespace openal
 
 	void Source::setVolume(float volume)
 	{
-		if(valid)
+		if (valid)
 		{
 			alSourcef(source, AL_GAIN, volume);
 		}
@@ -227,7 +227,7 @@ namespace openal
 
 	float Source::getVolume() const
 	{
-		if(valid)
+		if (valid)
 		{
 			ALfloat f;
 			alGetSourcef(source, AL_GAIN, &f);
@@ -237,14 +237,15 @@ namespace openal
 		// In case the Source isn't playing.
 		return volume;
 	}
-	
+
 	void Source::seekAtomic(float offset, void * unit)
 	{
 		if (valid)
 		{
 			switch (*((Source::Unit*) unit)) {
 				case Source::UNIT_SAMPLES:
-					if (type == TYPE_STREAM) {
+					if (type == TYPE_STREAM)
+					{
 						offsetSamples = offset;
 						ALint buffer;
 						alGetSourcei(source, AL_BUFFER, &buffer);
@@ -253,13 +254,16 @@ namespace openal
 						offset /= freq;
 						offsetSeconds = offset;
 						decoder->seek(offset);
-					} else {
+					}
+					else
+					{
 						alSourcef(source, AL_SAMPLE_OFFSET, offset);
 					}
 					break;
-				case Source::UNIT_SECONDS:	
+				case Source::UNIT_SECONDS:
 				default:
-					if (type == TYPE_STREAM) {
+					if (type == TYPE_STREAM)
+					{
 						offsetSeconds = offset;
 						decoder->seek(offset);
 						ALint buffer;
@@ -267,7 +271,9 @@ namespace openal
 						int freq;
 						alGetBufferi(buffer, AL_FREQUENCY, &freq);
 						offsetSamples = offset*freq;
-					} else {
+					}
+					else
+					{
 						alSourcef(source, AL_SEC_OFFSET, offset);
 					}
 					break;
@@ -290,7 +296,7 @@ namespace openal
 	{
 		return pool->seek(this, offset, &unit);
 	}
-	
+
 	float Source::tellAtomic(void * unit) const
 	{
 		if (valid)
@@ -324,7 +330,7 @@ namespace openal
 
 	void Source::setPosition(float * v)
 	{
-		if(valid)
+		if (valid)
 			alSourcefv(source, AL_POSITION, v);
 
 		setFloatv(position, v);
@@ -332,7 +338,7 @@ namespace openal
 
 	void Source::getPosition(float * v) const
 	{
-		if(valid)
+		if (valid)
 			alGetSourcefv(source, AL_POSITION, v);
 		else
 			setFloatv(v, position);
@@ -340,7 +346,7 @@ namespace openal
 
 	void Source::setVelocity(float * v)
 	{
-		if(valid)
+		if (valid)
 			alSourcefv(source, AL_VELOCITY, v);
 
 		setFloatv(velocity, v);
@@ -348,7 +354,7 @@ namespace openal
 
 	void Source::getVelocity(float * v) const
 	{
-		if(valid)
+		if (valid)
 			alGetSourcefv(source, AL_VELOCITY, v);
 		else
 			setFloatv(v, velocity);
@@ -356,7 +362,7 @@ namespace openal
 
 	void Source::setDirection(float * v)
 	{
-		if(valid)
+		if (valid)
 			alSourcefv(source, AL_DIRECTION, v);
 		else
 			setFloatv(direction, v);
@@ -364,7 +370,7 @@ namespace openal
 
 	void Source::getDirection(float * v) const
 	{
-		if(valid)
+		if (valid)
 			alGetSourcefv(source, AL_DIRECTION, v);
 		else
 			setFloatv(v, direction);
@@ -372,7 +378,7 @@ namespace openal
 
 	void Source::setLooping(bool looping)
 	{
-		if(valid && type == TYPE_STATIC)
+		if (valid && type == TYPE_STATIC)
 			alSourcei(source, AL_LOOPING, looping ? AL_TRUE : AL_FALSE);
 
 		this->looping = looping;
@@ -385,23 +391,23 @@ namespace openal
 
 	void Source::playAtomic()
 	{
-		if(type == TYPE_STATIC)
+		if (type == TYPE_STATIC)
 		{
 			alSourcei(source, AL_BUFFER, buffers[0]);
 		}
-		else if(type == TYPE_STREAM)
+		else if (type == TYPE_STREAM)
 		{
 			int usedBuffers = 0;
 
-			for(unsigned int i = 0; i < MAX_BUFFERS; i++)
+			for (unsigned int i = 0; i < MAX_BUFFERS; i++)
 			{
 				streamAtomic(buffers[i], decoder);
 				++usedBuffers;
-				if(decoder->isFinished())
+				if (decoder->isFinished())
 					break;
 			}
 
-			if(usedBuffers > 0)
+			if (usedBuffers > 0)
 				alSourceQueueBuffers(source, usedBuffers, buffers);
 		}
 
@@ -418,13 +424,13 @@ namespace openal
 
 	void Source::stopAtomic()
 	{
-		if(valid)
+		if (valid)
 		{
-			if(type == TYPE_STATIC)
+			if (type == TYPE_STATIC)
 			{
 				alSourceStop(source);
 			}
-			else if(type == TYPE_STREAM)
+			else if (type == TYPE_STREAM)
 			{
 				alSourceStop(source);
 				int queued = 0;
@@ -444,7 +450,7 @@ namespace openal
 
 	void Source::pauseAtomic()
 	{
-		if(valid)
+		if (valid)
 		{
 			alSourcePause(source);
 			paused = true;
@@ -453,7 +459,7 @@ namespace openal
 
 	void Source::resumeAtomic()
 	{
-		if(valid && paused)
+		if (valid && paused)
 		{
 			alSourcePlay(source);
 			paused = false;
@@ -462,13 +468,13 @@ namespace openal
 
 	void Source::rewindAtomic()
 	{
-		if(valid && type == TYPE_STATIC)
+		if (valid && type == TYPE_STATIC)
 		{
 			alSourceRewind(source);
 			if (!paused)
 				alSourcePlay(source);
 		}
-		else if(valid && type == TYPE_STREAM)
+		else if (valid && type == TYPE_STREAM)
 		{
 			bool waspaused = paused;
 			decoder->rewind();
@@ -508,13 +514,13 @@ namespace openal
 
 	ALenum Source::getFormat(int channels, int bits) const
 	{
-		if(channels == 1 && bits == 8)
+		if (channels == 1 && bits == 8)
 			return AL_FORMAT_MONO8;
-		else if(channels == 1 && bits == 16)
+		else if (channels == 1 && bits == 16)
 			return AL_FORMAT_MONO16;
-		else if(channels == 2 && bits == 8)
+		else if (channels == 2 && bits == 8)
 			return AL_FORMAT_STEREO8;
-		else if(channels == 2 && bits == 16)
+		else if (channels == 2 && bits == 16)
 			return AL_FORMAT_STEREO16;
 		else
 			return 0;
@@ -527,10 +533,11 @@ namespace openal
 
 		int fmt = getFormat(d->getChannels(), d->getBits());
 
-		if(fmt != 0)
+		if (fmt != 0)
 			alBufferData(buffer, fmt, d->getBuffer(), decoded, d->getSampleRate());
 
-		if(decoder->isFinished() && isLooping()) {
+		if (decoder->isFinished() && isLooping())
+		{
 			int queued, processed;
 			alGetSourcei(source, AL_BUFFERS_QUEUED, &queued);
 			alGetSourcei(source, AL_BUFFERS_PROCESSED, &processed);

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

@@ -63,7 +63,7 @@ namespace openal
 		float direction[3];
 		bool looping;
 		bool paused;
-		
+
 		float offsetSamples;
 		float offsetSeconds;
 

+ 318 - 315
src/modules/audio/wrap_Audio.cpp

@@ -1,315 +1,318 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-*
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-*
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-*
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-// LOVE
-#include "wrap_Audio.h"
-
-#include "openal/Audio.h"
-#include "null/Audio.h"
-
-#include <scripts/audio.lua.h>
-
-#include <common/runtime.h>
-
-namespace love
-{
-namespace audio
-{
-	static Audio * instance = 0;
-
-	int w_getNumSources(lua_State * L)
-	{
-		lua_pushinteger(L, instance->getNumSources());
-		return 1;
-	}
-
-	int w_newSource1(lua_State * L)
-	{
-		Source * t = 0;
-
-		if(luax_istype(L, 1, SOUND_SOUND_DATA_T))
-			t = instance->newSource(luax_totype<love::sound::SoundData>(L, 1, "SoundData", SOUND_SOUND_DATA_T));
-		else if(luax_istype(L, 1, SOUND_DECODER_T))
-			t = instance->newSource(luax_totype<love::sound::Decoder>(L, 1, "Decoder", SOUND_DECODER_T));
-
-		if(t)
-		{
-			luax_newtype(L, "Source", AUDIO_SOURCE_T, (void*)t);
-			return 1;
-		}
-		else
-			return luaL_error(L, "No matching overload");
-
-		return 0;
-	}
-
-	int w_play(lua_State * L)
-	{
-		Source * s = luax_checksource(L, 1);
-		instance->play(s);
-		return 0;
-	}
-
-	int w_stop(lua_State * L)
-	{
-		if(lua_gettop(L) == 0)
-		{
-			instance->stop();
-		}
-		else
-		{
-			Source * s = luax_checksource(L, 1);
-			s->stop();
-		}
-		return 0;
-	}
-
-	int w_pause(lua_State * L)
-	{
-		if(lua_gettop(L) == 0)
-		{
-			instance->pause();
-		}
-		else
-		{
-			Source * s = luax_checksource(L, 1);
-			s->pause();
-		}
-
-		return 0;
-	}
-
-	int w_resume(lua_State * L)
-	{
-		if(lua_gettop(L) == 0)
-		{
-			instance->resume();
-		}
-		else
-		{
-			Source * s = luax_checksource(L, 1);
-			s->resume();
-		}
-		return 0;
-	}
-
-	int w_rewind(lua_State * L)
-	{
-		if(lua_gettop(L) == 0)
-		{
-			instance->rewind();
-		}
-		else
-		{
-			Source * s = luax_checksource(L, 1);
-			s->rewind();
-		}
-		return 0;
-	}
-
-	int w_setVolume(lua_State * L)
-	{
-		float v = (float)luaL_checknumber(L, 1);
-		instance->setVolume(v);
-		return 0;
-	}
-
-	int w_getVolume(lua_State * L)
-	{
-		lua_pushnumber(L, instance->getVolume());
-		return 1;
-	}
-
-	int w_setPosition(lua_State * L)
-	{
-		float v[3];
-		v[0] = (float)luaL_checknumber(L, 1);
-		v[1] = (float)luaL_checknumber(L, 2);
-		v[2] = (float)luaL_checknumber(L, 3);
-		instance->setPosition(v);
-		return 0;
-	}
-
-	int w_getPosition(lua_State * L)
-	{
-		float v[3];
-		instance->getPosition(v);
-		lua_pushnumber(L, v[0]);
-		lua_pushnumber(L, v[1]);
-		lua_pushnumber(L, v[2]);
-		return 3;
-	}
-
-	int w_setOrientation(lua_State * L)
-	{
-		float v[6];
-		v[0] = (float)luaL_checknumber(L, 1);
-		v[1] = (float)luaL_checknumber(L, 2);
-		v[2] = (float)luaL_checknumber(L, 3);
-		v[3] = (float)luaL_checknumber(L, 4);
-		v[4] = (float)luaL_checknumber(L, 5);
-		v[5] = (float)luaL_checknumber(L, 6);
-		instance->setOrientation(v);
-		return 0;
-	}
-
-	int w_getOrientation(lua_State * L)
-	{
-		float v[6];
-		instance->getOrientation(v);
-		lua_pushnumber(L, v[0]);
-		lua_pushnumber(L, v[1]);
-		lua_pushnumber(L, v[2]);
-		lua_pushnumber(L, v[3]);
-		lua_pushnumber(L, v[4]);
-		lua_pushnumber(L, v[5]);
-		return 6;
-	}
-
-	int w_setVelocity(lua_State * L)
-	{
-		float v[3];
-		v[0] = (float)luaL_checknumber(L, 1);
-		v[1] = (float)luaL_checknumber(L, 2);
-		v[2] = (float)luaL_checknumber(L, 3);
-		instance->setVelocity(v);
-		return 0;
-	}
-
-	int w_getVelocity(lua_State * L)
-	{
-		float v[3];
-		instance->getVelocity(v);
-		lua_pushnumber(L, v[0]);
-		lua_pushnumber(L, v[1]);
-		lua_pushnumber(L, v[2]);
-		return 3;
-	}
-	
-	int w_record(lua_State *)
-	{
-		instance->record();
-		return 0;
-	}
-	
-	int w_getRecordedData(lua_State * L)
-	{
-		love::sound::SoundData * sd = instance->getRecordedData();
-		if (!sd) lua_pushnil(L);
-		else luax_newtype(L, "SoundData", SOUND_SOUND_DATA_T, (void*)sd);
-		return 1;
-	}
-	
-	int w_stopRecording(lua_State * L)
-	{
-		if (luax_optboolean(L, 1, true)) {
-			love::sound::SoundData * sd = instance->stopRecording(true);
-			if (!sd) lua_pushnil(L);
-			else luax_newtype(L, "SoundData", SOUND_SOUND_DATA_T, (void*)sd);
-			return 1;
-		}
-		instance->stopRecording(false);
-		return 0;
-	}
-	
-	int w_canRecord(lua_State * L) {
-		luax_pushboolean(L, instance->canRecord());
-		return 1;
-	}
-	
-
-	// List of functions to wrap.
-	static const luaL_Reg functions[] = {
-		{ "getNumSources", w_getNumSources },
-		{ "newSource1", w_newSource1 },
-		{ "play", w_play },
-		{ "stop", w_stop },
-		{ "pause", w_pause },
-		{ "resume", w_resume },
-		{ "rewind", w_rewind },
-		{ "setVolume", w_setVolume },
-		{ "getVolume", w_getVolume },
-		{ "setPosition", w_setPosition },
-		{ "getPosition", w_getPosition },
-		{ "setOrientation", w_setOrientation },
-		{ "getOrientation", w_getOrientation },
-		{ "setVelocity", w_setVelocity },
-		{ "getVelocity", w_getVelocity },
-		/*{ "record", w_record },
-		{ "getRecordedData", w_getRecordedData },
-		{ "stopRecording", w_stopRecording },*/
-		{ 0, 0 }
-	};
-
-	static const lua_CFunction types[] = {
-		luaopen_source,
-		0
-	};
-
-	int luaopen_love_audio(lua_State * L)
-	{
-		if(instance == 0)
-		{
-			// Try OpenAL first.
-			try
-			{
-				instance = new love::audio::openal::Audio();
-			}
-			catch(love::Exception & e)
-			{
-				std::cout << e.what() << std::endl;
-			}
-		}
-		else
-			instance->retain();
-
-		if(instance == 0)
-		{
-			// Fall back to nullaudio.
-			try
-			{
-				instance = new love::audio::null::Audio();
-			}
-			catch(love::Exception & e)
-			{
-				std::cout << e.what() << std::endl;
-			}
-		}
-
-		if(instance == 0)
-			return luaL_error(L, "Could not open any audio module.");
-
-		WrappedModule w;
-		w.module = instance;
-		w.name = "audio";
-		w.flags = MODULE_T;
-		w.functions = functions;
-		w.types = types;
-
-		luax_register_module(L, w);
-
-		if (luaL_loadbuffer(L, (const char *)audio_lua, sizeof(audio_lua), "audio.lua") == 0)
-			lua_call(L, 0, 0);
-
-		return 0;
-	}
-
-} // audio
-} // love
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+// LOVE
+#include "wrap_Audio.h"
+
+#include "openal/Audio.h"
+#include "null/Audio.h"
+
+#include <scripts/audio.lua.h>
+
+#include <common/runtime.h>
+
+namespace love
+{
+namespace audio
+{
+	static Audio * instance = 0;
+
+	int w_getNumSources(lua_State * L)
+	{
+		lua_pushinteger(L, instance->getNumSources());
+		return 1;
+	}
+
+	int w_newSource1(lua_State * L)
+	{
+		Source * t = 0;
+
+		if (luax_istype(L, 1, SOUND_SOUND_DATA_T))
+			t = instance->newSource(luax_totype<love::sound::SoundData>(L, 1, "SoundData", SOUND_SOUND_DATA_T));
+		else if (luax_istype(L, 1, SOUND_DECODER_T))
+			t = instance->newSource(luax_totype<love::sound::Decoder>(L, 1, "Decoder", SOUND_DECODER_T));
+
+		if (t)
+		{
+			luax_newtype(L, "Source", AUDIO_SOURCE_T, (void*)t);
+			return 1;
+		}
+		else
+			return luaL_error(L, "No matching overload");
+
+		return 0;
+	}
+
+	int w_play(lua_State * L)
+	{
+		Source * s = luax_checksource(L, 1);
+		instance->play(s);
+		return 0;
+	}
+
+	int w_stop(lua_State * L)
+	{
+		if (lua_gettop(L) == 0)
+		{
+			instance->stop();
+		}
+		else
+		{
+			Source * s = luax_checksource(L, 1);
+			s->stop();
+		}
+		return 0;
+	}
+
+	int w_pause(lua_State * L)
+	{
+		if (lua_gettop(L) == 0)
+		{
+			instance->pause();
+		}
+		else
+		{
+			Source * s = luax_checksource(L, 1);
+			s->pause();
+		}
+
+		return 0;
+	}
+
+	int w_resume(lua_State * L)
+	{
+		if (lua_gettop(L) == 0)
+		{
+			instance->resume();
+		}
+		else
+		{
+			Source * s = luax_checksource(L, 1);
+			s->resume();
+		}
+		return 0;
+	}
+
+	int w_rewind(lua_State * L)
+	{
+		if (lua_gettop(L) == 0)
+		{
+			instance->rewind();
+		}
+		else
+		{
+			Source * s = luax_checksource(L, 1);
+			s->rewind();
+		}
+		return 0;
+	}
+
+	int w_setVolume(lua_State * L)
+	{
+		float v = (float)luaL_checknumber(L, 1);
+		instance->setVolume(v);
+		return 0;
+	}
+
+	int w_getVolume(lua_State * L)
+	{
+		lua_pushnumber(L, instance->getVolume());
+		return 1;
+	}
+
+	int w_setPosition(lua_State * L)
+	{
+		float v[3];
+		v[0] = (float)luaL_checknumber(L, 1);
+		v[1] = (float)luaL_checknumber(L, 2);
+		v[2] = (float)luaL_checknumber(L, 3);
+		instance->setPosition(v);
+		return 0;
+	}
+
+	int w_getPosition(lua_State * L)
+	{
+		float v[3];
+		instance->getPosition(v);
+		lua_pushnumber(L, v[0]);
+		lua_pushnumber(L, v[1]);
+		lua_pushnumber(L, v[2]);
+		return 3;
+	}
+
+	int w_setOrientation(lua_State * L)
+	{
+		float v[6];
+		v[0] = (float)luaL_checknumber(L, 1);
+		v[1] = (float)luaL_checknumber(L, 2);
+		v[2] = (float)luaL_checknumber(L, 3);
+		v[3] = (float)luaL_checknumber(L, 4);
+		v[4] = (float)luaL_checknumber(L, 5);
+		v[5] = (float)luaL_checknumber(L, 6);
+		instance->setOrientation(v);
+		return 0;
+	}
+
+	int w_getOrientation(lua_State * L)
+	{
+		float v[6];
+		instance->getOrientation(v);
+		lua_pushnumber(L, v[0]);
+		lua_pushnumber(L, v[1]);
+		lua_pushnumber(L, v[2]);
+		lua_pushnumber(L, v[3]);
+		lua_pushnumber(L, v[4]);
+		lua_pushnumber(L, v[5]);
+		return 6;
+	}
+
+	int w_setVelocity(lua_State * L)
+	{
+		float v[3];
+		v[0] = (float)luaL_checknumber(L, 1);
+		v[1] = (float)luaL_checknumber(L, 2);
+		v[2] = (float)luaL_checknumber(L, 3);
+		instance->setVelocity(v);
+		return 0;
+	}
+
+	int w_getVelocity(lua_State * L)
+	{
+		float v[3];
+		instance->getVelocity(v);
+		lua_pushnumber(L, v[0]);
+		lua_pushnumber(L, v[1]);
+		lua_pushnumber(L, v[2]);
+		return 3;
+	}
+
+	int w_record(lua_State *)
+	{
+		instance->record();
+		return 0;
+	}
+
+	int w_getRecordedData(lua_State * L)
+	{
+		love::sound::SoundData * sd = instance->getRecordedData();
+		if (!sd)
+			lua_pushnil(L);
+		else
+			luax_newtype(L, "SoundData", SOUND_SOUND_DATA_T, (void*)sd);
+		return 1;
+	}
+
+	int w_stopRecording(lua_State * L)
+	{
+		if (luax_optboolean(L, 1, true))
+		{
+			love::sound::SoundData * sd = instance->stopRecording(true);
+			if (!sd) lua_pushnil(L);
+			else luax_newtype(L, "SoundData", SOUND_SOUND_DATA_T, (void*)sd);
+			return 1;
+		}
+		instance->stopRecording(false);
+		return 0;
+	}
+
+	int w_canRecord(lua_State * L) {
+		luax_pushboolean(L, instance->canRecord());
+		return 1;
+	}
+
+
+	// List of functions to wrap.
+	static const luaL_Reg functions[] = {
+		{ "getNumSources", w_getNumSources },
+		{ "newSource1", w_newSource1 },
+		{ "play", w_play },
+		{ "stop", w_stop },
+		{ "pause", w_pause },
+		{ "resume", w_resume },
+		{ "rewind", w_rewind },
+		{ "setVolume", w_setVolume },
+		{ "getVolume", w_getVolume },
+		{ "setPosition", w_setPosition },
+		{ "getPosition", w_getPosition },
+		{ "setOrientation", w_setOrientation },
+		{ "getOrientation", w_getOrientation },
+		{ "setVelocity", w_setVelocity },
+		{ "getVelocity", w_getVelocity },
+		/*{ "record", w_record },
+		{ "getRecordedData", w_getRecordedData },
+		{ "stopRecording", w_stopRecording },*/
+		{ 0, 0 }
+	};
+
+	static const lua_CFunction types[] = {
+		luaopen_source,
+		0
+	};
+
+	int luaopen_love_audio(lua_State * L)
+	{
+		if (instance == 0)
+		{
+			// Try OpenAL first.
+			try
+			{
+				instance = new love::audio::openal::Audio();
+			}
+			catch (love::Exception & e)
+			{
+				std::cout << e.what() << std::endl;
+			}
+		}
+		else
+			instance->retain();
+
+		if (instance == 0)
+		{
+			// Fall back to nullaudio.
+			try
+			{
+				instance = new love::audio::null::Audio();
+			}
+			catch (love::Exception & e)
+			{
+				std::cout << e.what() << std::endl;
+			}
+		}
+
+		if (instance == 0)
+			return luaL_error(L, "Could not open any audio module.");
+
+		WrappedModule w;
+		w.module = instance;
+		w.name = "audio";
+		w.flags = MODULE_T;
+		w.functions = functions;
+		w.types = types;
+
+		luax_register_module(L, w);
+
+		if (luaL_loadbuffer(L, (const char *)audio_lua, sizeof(audio_lua), "audio.lua") == 0)
+			lua_call(L, 0, 0);
+
+		return 0;
+	}
+
+} // audio
+} // love

+ 58 - 58
src/modules/audio/wrap_Audio.h

@@ -1,58 +1,58 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-* 
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-* 
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-* 
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#ifndef LOVE_AUDIO_WRAP_AUDIO_H
-#define LOVE_AUDIO_WRAP_AUDIO_H
-
-// LOVE
-#include <common/config.h>
-#include <common/runtime.h>
-#include "Audio.h"
-#include "wrap_Source.h"
-
-namespace love
-{
-namespace audio
-{
-	int w_getNumSources(lua_State * L);
-	int w_newSource1(lua_State * L);
-	int w_play(lua_State * L);
-	int w_stop(lua_State * L);
-	int w_pause(lua_State * L);
-	int w_resume(lua_State * L);
-	int w_rewind(lua_State * L);
-	int w_setVolume(lua_State * L);
-	int w_getVolume(lua_State * L);
-	int w_setPosition(lua_State * L);
-	int w_getPosition(lua_State * L);
-	int w_setOrientation(lua_State * L);
-	int w_getOrientation(lua_State * L);
-	int w_setVelocity(lua_State * L);
-	int w_getVelocity(lua_State * L);
-	int w_record(lua_State * L);
-	int w_getRecordedData(lua_State * L);
-	int w_stopRecording(lua_State * L);
-	int w_canRecord(lua_State * L);
-	extern "C" LOVE_EXPORT int luaopen_love_audio(lua_State * L);
-
-} // audio
-} // love
-
-#endif // LOVE_AUDIO_WRAP_AUDIO_H
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#ifndef LOVE_AUDIO_WRAP_AUDIO_H
+#define LOVE_AUDIO_WRAP_AUDIO_H
+
+// LOVE
+#include <common/config.h>
+#include <common/runtime.h>
+#include "Audio.h"
+#include "wrap_Source.h"
+
+namespace love
+{
+namespace audio
+{
+	int w_getNumSources(lua_State * L);
+	int w_newSource1(lua_State * L);
+	int w_play(lua_State * L);
+	int w_stop(lua_State * L);
+	int w_pause(lua_State * L);
+	int w_resume(lua_State * L);
+	int w_rewind(lua_State * L);
+	int w_setVolume(lua_State * L);
+	int w_getVolume(lua_State * L);
+	int w_setPosition(lua_State * L);
+	int w_getPosition(lua_State * L);
+	int w_setOrientation(lua_State * L);
+	int w_getOrientation(lua_State * L);
+	int w_setVelocity(lua_State * L);
+	int w_getVelocity(lua_State * L);
+	int w_record(lua_State * L);
+	int w_getRecordedData(lua_State * L);
+	int w_stopRecording(lua_State * L);
+	int w_canRecord(lua_State * L);
+	extern "C" LOVE_EXPORT int luaopen_love_audio(lua_State * L);
+
+} // audio
+} // love
+
+#endif // LOVE_AUDIO_WRAP_AUDIO_H

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

@@ -1,253 +1,253 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-*
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-*
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-*
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#include "wrap_Source.h"
-
-namespace love
-{
-namespace audio
-{
-	Source * luax_checksource(lua_State * L, int idx)
-	{
-		return luax_checktype<Source>(L, idx, "Source", AUDIO_SOURCE_T);
-	}
-
-	int w_Source_play(lua_State * L)
-	{
-		Source * t = luax_checksource(L, 1);
-		t->play();
-		return 0;
-	}
-
-	int w_Source_stop(lua_State * L)
-	{
-		Source * t = luax_checksource(L, 1);
-		t->stop();
-		return 0;
-	}
-
-	int w_Source_pause(lua_State * L)
-	{
-		Source * t = luax_checksource(L, 1);
-		t->pause();
-		return 0;
-	}
-
-	int w_Source_resume(lua_State * L)
-	{
-		Source * t = luax_checksource(L, 1);
-		t->resume();
-		return 0;
-	}
-
-	int w_Source_rewind(lua_State * L)
-	{
-		Source * t = luax_checksource(L, 1);
-		t->rewind();
-		return 0;
-	}
-
-	int w_Source_setPitch(lua_State * L)
-	{
-		Source * t = luax_checksource(L, 1);
-		float p = (float)luaL_checknumber(L, 2);
-		t->setPitch(p);
-		return 0;
-	}
-
-	int w_Source_getPitch(lua_State * L)
-	{
-		Source * t = luax_checksource(L, 1);
-		lua_pushnumber(L, t->getPitch());
-		return 1;
-	}
-
-	int w_Source_setVolume(lua_State * L)
-	{
-		Source * t = luax_checksource(L, 1);
-		float p = (float)luaL_checknumber(L, 2);
-		t->setVolume(p);
-		return 0;
-	}
-
-	int w_Source_getVolume(lua_State * L)
-	{
-		Source * t = luax_checksource(L, 1);
-		lua_pushnumber(L, t->getVolume());
-		return 1;
-	}
-	
-	int w_Source_seek(lua_State * L)
-	{
-		Source * t = luax_checksource(L, 1);
-		float offset = (float)luaL_checknumber(L, 2);
-		const char * unit = luaL_optstring(L, 3, "seconds");
-		Source::Unit u;
-		t->getConstant(unit, u);
-		t->seek(offset, u);
-		return 0;
-	}
-	
-	int w_Source_tell(lua_State * L)
-	{
-		Source * t = luax_checksource(L, 1);
-		const char * unit = luaL_optstring(L, 2, "seconds");
-		Source::Unit u;
-		t->getConstant(unit, u);
-		lua_pushnumber(L, t->tell(u));
-		return 1;
-	}
-
-	int w_Source_setPosition(lua_State * L)
-	{
-		Source * t = luax_checksource(L, 1);
-		float v[3];
-		v[0] = (float)luaL_checknumber(L, 2);
-		v[1] = (float)luaL_checknumber(L, 3);
-		v[2] = (float)luaL_checknumber(L, 4);
-		t->setPosition(v);
-		return 0;
-	}
-
-	int w_Source_getPosition(lua_State * L)
-	{
-		Source * t = luax_checksource(L, 1);
-		float v[3];
-		t->getPosition(v);
-		lua_pushnumber(L, v[0]);
-		lua_pushnumber(L, v[1]);
-		lua_pushnumber(L, v[2]);
-		return 3;
-	}
-
-	int w_Source_setVelocity(lua_State * L)
-	{
-		Source * t = luax_checksource(L, 1);
-		float v[3];
-		v[0] = (float)luaL_checknumber(L, 2);
-		v[1] = (float)luaL_checknumber(L, 3);
-		v[2] = (float)luaL_checknumber(L, 4);
-		t->setVelocity(v);
-		return 0;
-	}
-
-	int w_Source_getVelocity(lua_State * L)
-	{
-		Source * t = luax_checksource(L, 1);
-		float v[3];
-		t->getVelocity(v);
-		lua_pushnumber(L, v[0]);
-		lua_pushnumber(L, v[1]);
-		lua_pushnumber(L, v[2]);
-		return 3;
-	}
-
-	int w_Source_setDirection(lua_State * L)
-	{
-		Source * t = luax_checksource(L, 1);
-		float v[3];
-		v[0] = (float)luaL_checknumber(L, 2);
-		v[1] = (float)luaL_checknumber(L, 3);
-		v[2] = (float)luaL_checknumber(L, 4);
-		t->setDirection(v);
-		return 0;
-	}
-
-	int w_Source_getDirection(lua_State * L)
-	{
-		Source * t = luax_checksource(L, 1);
-		float v[3];
-		t->getDirection(v);
-		lua_pushnumber(L, v[0]);
-		lua_pushnumber(L, v[1]);
-		lua_pushnumber(L, v[2]);
-		return 3;
-	}
-
-	int w_Source_setLooping(lua_State * L)
-	{
-		Source * t = luax_checksource(L, 1);
-		t->setLooping(luax_toboolean(L, 2));
-		return 0;
-	}
-
-	int w_Source_isLooping(lua_State * L)
-	{
-		Source * t = luax_checksource(L, 1);
-		luax_pushboolean(L, t->isLooping());
-		return 1;
-	}
-
-	int w_Source_isStopped(lua_State * L)
-	{
-		Source * t = luax_checksource(L, 1);
-		luax_pushboolean(L, t->isStopped());
-		return 1;
-	}
-
-	int w_Source_isPaused(lua_State * L)
-	{
-		Source * t = luax_checksource(L, 1);
-		luax_pushboolean(L, t->isPaused());
-		return 1;
-	}
-
-	int w_Source_isStatic(lua_State * L)
-	{
-		Source * t= luax_checksource(L, 1);
-		luax_pushboolean(L, t->isStatic());
-		return 1;
-	}
-
-	static const luaL_Reg functions[] = {
-		{ "play", w_Source_play },
-		{ "stop", w_Source_stop },
-		{ "pause", w_Source_pause },
-		{ "resume", w_Source_resume },
-		{ "rewind", w_Source_rewind },
-
-		{ "setPitch", w_Source_setPitch },
-		{ "getPitch", w_Source_getPitch },
-		{ "setVolume", w_Source_setVolume },
-		{ "getVolume", w_Source_getVolume },
-		{ "seek", w_Source_seek },
-		{ "tell", w_Source_tell },
-		{ "setPosition", w_Source_setPosition },
-		{ "getPosition", w_Source_getPosition },
-		{ "setVelocity", w_Source_setVelocity },
-		{ "getVelocity", w_Source_getVelocity },
-		{ "setDirection", w_Source_setDirection },
-		{ "getDirection", w_Source_getDirection },
-
-		{ "setLooping", w_Source_setLooping },
-		{ "isLooping", w_Source_isLooping },
-		{ "isStopped", w_Source_isStopped },
-		{ "isPaused", w_Source_isPaused },
-		{ "isStatic", w_Source_isStatic },
-		{ 0, 0 }
-	};
-
-	int luaopen_source(lua_State * L)
-	{
-		return luax_register_type(L, "Source", functions);
-	}
-
-} // audio
-} // love
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#include "wrap_Source.h"
+
+namespace love
+{
+namespace audio
+{
+	Source * luax_checksource(lua_State * L, int idx)
+	{
+		return luax_checktype<Source>(L, idx, "Source", AUDIO_SOURCE_T);
+	}
+
+	int w_Source_play(lua_State * L)
+	{
+		Source * t = luax_checksource(L, 1);
+		t->play();
+		return 0;
+	}
+
+	int w_Source_stop(lua_State * L)
+	{
+		Source * t = luax_checksource(L, 1);
+		t->stop();
+		return 0;
+	}
+
+	int w_Source_pause(lua_State * L)
+	{
+		Source * t = luax_checksource(L, 1);
+		t->pause();
+		return 0;
+	}
+
+	int w_Source_resume(lua_State * L)
+	{
+		Source * t = luax_checksource(L, 1);
+		t->resume();
+		return 0;
+	}
+
+	int w_Source_rewind(lua_State * L)
+	{
+		Source * t = luax_checksource(L, 1);
+		t->rewind();
+		return 0;
+	}
+
+	int w_Source_setPitch(lua_State * L)
+	{
+		Source * t = luax_checksource(L, 1);
+		float p = (float)luaL_checknumber(L, 2);
+		t->setPitch(p);
+		return 0;
+	}
+
+	int w_Source_getPitch(lua_State * L)
+	{
+		Source * t = luax_checksource(L, 1);
+		lua_pushnumber(L, t->getPitch());
+		return 1;
+	}
+
+	int w_Source_setVolume(lua_State * L)
+	{
+		Source * t = luax_checksource(L, 1);
+		float p = (float)luaL_checknumber(L, 2);
+		t->setVolume(p);
+		return 0;
+	}
+
+	int w_Source_getVolume(lua_State * L)
+	{
+		Source * t = luax_checksource(L, 1);
+		lua_pushnumber(L, t->getVolume());
+		return 1;
+	}
+
+	int w_Source_seek(lua_State * L)
+	{
+		Source * t = luax_checksource(L, 1);
+		float offset = (float)luaL_checknumber(L, 2);
+		const char * unit = luaL_optstring(L, 3, "seconds");
+		Source::Unit u;
+		t->getConstant(unit, u);
+		t->seek(offset, u);
+		return 0;
+	}
+
+	int w_Source_tell(lua_State * L)
+	{
+		Source * t = luax_checksource(L, 1);
+		const char * unit = luaL_optstring(L, 2, "seconds");
+		Source::Unit u;
+		t->getConstant(unit, u);
+		lua_pushnumber(L, t->tell(u));
+		return 1;
+	}
+
+	int w_Source_setPosition(lua_State * L)
+	{
+		Source * t = luax_checksource(L, 1);
+		float v[3];
+		v[0] = (float)luaL_checknumber(L, 2);
+		v[1] = (float)luaL_checknumber(L, 3);
+		v[2] = (float)luaL_checknumber(L, 4);
+		t->setPosition(v);
+		return 0;
+	}
+
+	int w_Source_getPosition(lua_State * L)
+	{
+		Source * t = luax_checksource(L, 1);
+		float v[3];
+		t->getPosition(v);
+		lua_pushnumber(L, v[0]);
+		lua_pushnumber(L, v[1]);
+		lua_pushnumber(L, v[2]);
+		return 3;
+	}
+
+	int w_Source_setVelocity(lua_State * L)
+	{
+		Source * t = luax_checksource(L, 1);
+		float v[3];
+		v[0] = (float)luaL_checknumber(L, 2);
+		v[1] = (float)luaL_checknumber(L, 3);
+		v[2] = (float)luaL_checknumber(L, 4);
+		t->setVelocity(v);
+		return 0;
+	}
+
+	int w_Source_getVelocity(lua_State * L)
+	{
+		Source * t = luax_checksource(L, 1);
+		float v[3];
+		t->getVelocity(v);
+		lua_pushnumber(L, v[0]);
+		lua_pushnumber(L, v[1]);
+		lua_pushnumber(L, v[2]);
+		return 3;
+	}
+
+	int w_Source_setDirection(lua_State * L)
+	{
+		Source * t = luax_checksource(L, 1);
+		float v[3];
+		v[0] = (float)luaL_checknumber(L, 2);
+		v[1] = (float)luaL_checknumber(L, 3);
+		v[2] = (float)luaL_checknumber(L, 4);
+		t->setDirection(v);
+		return 0;
+	}
+
+	int w_Source_getDirection(lua_State * L)
+	{
+		Source * t = luax_checksource(L, 1);
+		float v[3];
+		t->getDirection(v);
+		lua_pushnumber(L, v[0]);
+		lua_pushnumber(L, v[1]);
+		lua_pushnumber(L, v[2]);
+		return 3;
+	}
+
+	int w_Source_setLooping(lua_State * L)
+	{
+		Source * t = luax_checksource(L, 1);
+		t->setLooping(luax_toboolean(L, 2));
+		return 0;
+	}
+
+	int w_Source_isLooping(lua_State * L)
+	{
+		Source * t = luax_checksource(L, 1);
+		luax_pushboolean(L, t->isLooping());
+		return 1;
+	}
+
+	int w_Source_isStopped(lua_State * L)
+	{
+		Source * t = luax_checksource(L, 1);
+		luax_pushboolean(L, t->isStopped());
+		return 1;
+	}
+
+	int w_Source_isPaused(lua_State * L)
+	{
+		Source * t = luax_checksource(L, 1);
+		luax_pushboolean(L, t->isPaused());
+		return 1;
+	}
+
+	int w_Source_isStatic(lua_State * L)
+	{
+		Source * t= luax_checksource(L, 1);
+		luax_pushboolean(L, t->isStatic());
+		return 1;
+	}
+
+	static const luaL_Reg functions[] = {
+		{ "play", w_Source_play },
+		{ "stop", w_Source_stop },
+		{ "pause", w_Source_pause },
+		{ "resume", w_Source_resume },
+		{ "rewind", w_Source_rewind },
+
+		{ "setPitch", w_Source_setPitch },
+		{ "getPitch", w_Source_getPitch },
+		{ "setVolume", w_Source_setVolume },
+		{ "getVolume", w_Source_getVolume },
+		{ "seek", w_Source_seek },
+		{ "tell", w_Source_tell },
+		{ "setPosition", w_Source_setPosition },
+		{ "getPosition", w_Source_getPosition },
+		{ "setVelocity", w_Source_setVelocity },
+		{ "getVelocity", w_Source_getVelocity },
+		{ "setDirection", w_Source_setDirection },
+		{ "getDirection", w_Source_getDirection },
+
+		{ "setLooping", w_Source_setLooping },
+		{ "isLooping", w_Source_isLooping },
+		{ "isStopped", w_Source_isStopped },
+		{ "isPaused", w_Source_isPaused },
+		{ "isStatic", w_Source_isStatic },
+		{ 0, 0 }
+	};
+
+	int luaopen_source(lua_State * L)
+	{
+		return luax_register_type(L, "Source", functions);
+	}
+
+} // audio
+} // love

+ 59 - 59
src/modules/audio/wrap_Source.h

@@ -1,59 +1,59 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-*
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-*
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-*
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#ifndef LOVE_AUDIO_WRAP_SOURCE_H
-#define LOVE_AUDIO_WRAP_SOURCE_H
-
-#include <common/runtime.h>
-#include "Source.h"
-
-namespace love
-{
-namespace audio
-{
-	Source * luax_checksource(lua_State * L, int idx);
-	int w_Source_play(lua_State * L);
-	int w_Source_stop(lua_State * L);
-	int w_Source_pause(lua_State * L);
-	int w_Source_resume(lua_State * L);
-	int w_Source_rewind(lua_State * L);
-	int w_Source_setPitch(lua_State * L);
-	int w_Source_getPitch(lua_State * L);
-	int w_Source_setVolume(lua_State * L);
-	int w_Source_getVolume(lua_State * L);
-	int w_Source_seek(lua_State * L);
-	int w_Source_tell(lua_State * L);
-	int w_Source_setPosition(lua_State * L);
-	int w_Source_getPosition(lua_State * L);
-	int w_Source_setVelocity(lua_State * L);
-	int w_Source_getVelocity(lua_State * L);
-	int w_Source_setDirection(lua_State * L);
-	int w_Source_getDirection(lua_State * L);
-	int w_Source_setLooping(lua_State * L);
-	int w_Source_isLooping(lua_State * L);
-	int w_Source_isStopped(lua_State * L);
-	int w_Source_isPaused(lua_State * L);
-	int w_Source_isStatic(lua_State * L);
-	int luaopen_source(lua_State * L);
-
-} // audio
-} // love
-
-#endif // LOVE_AUDIO_WRAP_SOURCE_H
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#ifndef LOVE_AUDIO_WRAP_SOURCE_H
+#define LOVE_AUDIO_WRAP_SOURCE_H
+
+#include <common/runtime.h>
+#include "Source.h"
+
+namespace love
+{
+namespace audio
+{
+	Source * luax_checksource(lua_State * L, int idx);
+	int w_Source_play(lua_State * L);
+	int w_Source_stop(lua_State * L);
+	int w_Source_pause(lua_State * L);
+	int w_Source_resume(lua_State * L);
+	int w_Source_rewind(lua_State * L);
+	int w_Source_setPitch(lua_State * L);
+	int w_Source_getPitch(lua_State * L);
+	int w_Source_setVolume(lua_State * L);
+	int w_Source_getVolume(lua_State * L);
+	int w_Source_seek(lua_State * L);
+	int w_Source_tell(lua_State * L);
+	int w_Source_setPosition(lua_State * L);
+	int w_Source_getPosition(lua_State * L);
+	int w_Source_setVelocity(lua_State * L);
+	int w_Source_getVelocity(lua_State * L);
+	int w_Source_setDirection(lua_State * L);
+	int w_Source_getDirection(lua_State * L);
+	int w_Source_setLooping(lua_State * L);
+	int w_Source_isLooping(lua_State * L);
+	int w_Source_isStopped(lua_State * L);
+	int w_Source_isPaused(lua_State * L);
+	int w_Source_isStatic(lua_State * L);
+	int luaopen_source(lua_State * L);
+
+} // audio
+} // love
+
+#endif // LOVE_AUDIO_WRAP_SOURCE_H

+ 8 - 5
src/modules/event/sdl/Event.cpp

@@ -50,9 +50,9 @@ namespace sdl
 
 		SDL_EnableUNICODE(1);
 
-		while(SDL_PollEvent(&e))
+		while (SDL_PollEvent(&e))
 		{
-			if(convert(e, message))
+			if (convert(e, message))
 				return true;
 		}
 
@@ -77,7 +77,7 @@ namespace sdl
 	{
 		static SDL_Event e;
 
-		while(SDL_PollEvent(&e))
+		while (SDL_PollEvent(&e))
 		{
 			// Do nothing with 'e' ...
 		}
@@ -107,11 +107,14 @@ namespace sdl
 			m.joystick.index = e.jbutton.which;
 			return true;
 		case SDL_ACTIVEEVENT:
-			if (e.active.state & SDL_APPINPUTFOCUS) {
+			if (e.active.state & SDL_APPINPUTFOCUS)
+			{
 				m.type = Event::TYPE_FOCUS;
 				m.focus.f = (e.active.gain != 0);
 				return true;
-			} else break;
+			}
+			else
+				break;
 		case SDL_QUIT:
 			m.type = Event::TYPE_QUIT;
 			return true;

+ 10 - 10
src/modules/event/sdl/Event.h

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -38,22 +38,22 @@ namespace sdl
 	class Event : public love::event::Event
 	{
 	public:
-		
+
 		// Implements Module.
 		const char * getName() const;
 
 		Event();
 
 		/**
-		* Pumps the event queue. This function gathers all the pending input information 
+		* Pumps the event queue. This function gathers all the pending input information
 		* from devices and places it on the event queue. Normally not needed if you poll
 		* for events.
-		**/ 
+		**/
 		void pump();
 
 		/**
-		* Checks if there are messages in the queue. 
-		* 
+		* Checks if there are messages in the queue.
+		*
 		* @param message The next message in the queue, if the return value is true.
 		* @return True if there a message was found, false otherwise.
 		**/
@@ -68,9 +68,9 @@ namespace sdl
 
 		/**
 		* Push a message onto the event queue.
-		* 
+		*
 		* @param message The message to push onto the queue.
-		* @return True on success, false if the queue was full. 
+		* @return True on success, false if the queue was full.
 		**/
 		bool push(Message & message);
 

+ 233 - 233
src/modules/event/sdl/wrap_Event.cpp

@@ -1,233 +1,233 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-*
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-*
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-*
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#include "wrap_Event.h"
-
-// LOVE
-#include <common/runtime.h>
-
-// sdlevent
-#include "Event.h"
-
-namespace love
-{
-namespace event
-{
-namespace sdl
-{
-	static Event * instance = 0;
-
-	static bool to_message(lua_State * L, Event::Message & msg)
-	{
-		const char * str = luaL_checkstring(L, 1);
-
-		if(!Event::getConstant(str, msg.type))
-			return false;
-
-		switch(msg.type)
-		{
-		case Event::TYPE_KEY_PRESSED:
-			if(!Event::getConstant(luaL_checkstring(L, 2), msg.keyboard.k))
-				return false;
-			msg.keyboard.u = (unsigned short)luaL_optint(L, 3, 0);
-			return true;
-		case Event::TYPE_KEY_RELEASED:
-			if(!Event::getConstant(luaL_checkstring(L, 2), msg.keyboard.k))
-				return false;
-			return true;
-		case Event::TYPE_MOUSE_PRESSED:
-		case Event::TYPE_MOUSE_RELEASED:
-			if(!Event::getConstant(luaL_checkstring(L, 2), msg.mouse.b))
-				return false;
-			msg.mouse.x = luaL_checkint(L, 3);
-			msg.mouse.y = luaL_checkint(L, 4);
-			return true;
-		case Event::TYPE_JOYSTICK_PRESSED:
-		case Event::TYPE_JOYSTICK_RELEASED:
-			msg.joystick.index = luaL_checkint(L, 2);
-			msg.joystick.button = luaL_checkint(L, 3);
-			return true;
-		case Event::TYPE_FOCUS:
-			msg.focus.f = luax_toboolean(L, 2);
-			return true;
-		case Event::TYPE_QUIT:
-			return true;
-		default:
-			return false;
-		}
-
-		return false;
-	}
-
-	static int push_message(lua_State * L, const Event::Message & msg)
-	{
-		const char * str = 0;
-
-		if(!Event::getConstant(msg.type, str))
-			return 0;
-
-		lua_pushstring(L, str);
-
-		switch(msg.type)
-		{
-		case Event::TYPE_KEY_PRESSED:
-			if(!Event::getConstant(msg.keyboard.k, str))
-				return 0;
-			lua_pushstring(L, str);
-			lua_pushinteger(L, msg.keyboard.u);
-			return 3;
-		case Event::TYPE_KEY_RELEASED:
-			if(!Event::getConstant(msg.keyboard.k, str))
-				return 0;
-			lua_pushstring(L, str);
-			return 2;
-		case Event::TYPE_MOUSE_PRESSED:
-		case Event::TYPE_MOUSE_RELEASED:
-			if(!Event::getConstant(msg.mouse.b, str))
-				return 0;
-			lua_pushinteger(L, msg.mouse.x);
-			lua_pushinteger(L, msg.mouse.y);
-			lua_pushstring(L, str);
-			return 4;
-		case Event::TYPE_JOYSTICK_PRESSED:
-		case Event::TYPE_JOYSTICK_RELEASED:
-			lua_pushinteger(L, msg.joystick.index+1);
-			lua_pushinteger(L, msg.joystick.button+1);
-			return 3;
-		case Event::TYPE_FOCUS:
-			lua_pushboolean(L, msg.focus.f);
-			return 2;
-		case Event::TYPE_QUIT:
-			return 1;
-		default:
-			return 0;
-		}
-
-		return 0;
-	}
-
-	static int poll_i(lua_State * L)
-	{
-		static Event::Message m;
-
-		while(instance->poll(m))
-		{
-			int args = push_message(L, m);
-			if(args > 0)
-				return args;
-		}
-
-		// No pending events.
-		return 0;
-	}
-
-	int w_pump(lua_State *)
-	{
-		instance->pump();
-		return 0;
-	}
-
-	int w_poll(lua_State * L)
-	{
-		lua_pushcclosure(L, &poll_i, 0);
-		return 1;
-	}
-
-	int w_wait(lua_State * L)
-	{
-		static Event::Message m;
-
-		if(instance->wait(m))
-		{
-			return push_message(L, m);
-		}
-
-		return 0;
-	}
-
-	int w_push(lua_State * L)
-	{
-		static Event::Message m;
-
-		if(!to_message(L, m))
-		{
-			luax_pushboolean(L, false);
-			return 1;
-		}
-
-		luax_pushboolean(L, instance->push(m));
-
-		return 1;
-	}
-
-	int w_clear(lua_State *)
-	{
-		instance->clear();
-		return 0;
-	}
-
-	int w_quit(lua_State * L)
-	{
-		static Event::Message m;
-		m.type = Event::TYPE_QUIT;
-		luax_pushboolean(L, instance->push(m));
-		return 1;
-	}
-
-	// List of functions to wrap.
-	static const luaL_Reg functions[] = {
-		{ "pump", w_pump },
-		{ "poll", w_poll },
-		{ "wait", w_wait },
-		{ "push", w_push },
-		{ "clear", w_clear },
-		{ "quit", w_quit },
-		{ 0, 0 }
-	};
-
-	int luaopen_love_event(lua_State * L)
-	{
-		if(instance == 0)
-		{
-			try
-			{
-				instance = new Event();
-			}
-			catch(Exception & e)
-			{
-				return luaL_error(L, e.what());
-			}
-		}
-		else
-			instance->retain();
-
-		WrappedModule w;
-		w.module = instance;
-		w.name = "event";
-		w.flags = MODULE_T;
-		w.functions = functions;
-		w.types = 0;
-
-		return luax_register_module(L, w);
-	}
-
-} // sdl
-} // event
-} // love
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#include "wrap_Event.h"
+
+// LOVE
+#include <common/runtime.h>
+
+// sdlevent
+#include "Event.h"
+
+namespace love
+{
+namespace event
+{
+namespace sdl
+{
+	static Event * instance = 0;
+
+	static bool to_message(lua_State * L, Event::Message & msg)
+	{
+		const char * str = luaL_checkstring(L, 1);
+
+		if (!Event::getConstant(str, msg.type))
+			return false;
+
+		switch(msg.type)
+		{
+		case Event::TYPE_KEY_PRESSED:
+			if (!Event::getConstant(luaL_checkstring(L, 2), msg.keyboard.k))
+				return false;
+			msg.keyboard.u = (unsigned short)luaL_optint(L, 3, 0);
+			return true;
+		case Event::TYPE_KEY_RELEASED:
+			if (!Event::getConstant(luaL_checkstring(L, 2), msg.keyboard.k))
+				return false;
+			return true;
+		case Event::TYPE_MOUSE_PRESSED:
+		case Event::TYPE_MOUSE_RELEASED:
+			if (!Event::getConstant(luaL_checkstring(L, 2), msg.mouse.b))
+				return false;
+			msg.mouse.x = luaL_checkint(L, 3);
+			msg.mouse.y = luaL_checkint(L, 4);
+			return true;
+		case Event::TYPE_JOYSTICK_PRESSED:
+		case Event::TYPE_JOYSTICK_RELEASED:
+			msg.joystick.index = luaL_checkint(L, 2);
+			msg.joystick.button = luaL_checkint(L, 3);
+			return true;
+		case Event::TYPE_FOCUS:
+			msg.focus.f = luax_toboolean(L, 2);
+			return true;
+		case Event::TYPE_QUIT:
+			return true;
+		default:
+			return false;
+		}
+
+		return false;
+	}
+
+	static int push_message(lua_State * L, const Event::Message & msg)
+	{
+		const char * str = 0;
+
+		if (!Event::getConstant(msg.type, str))
+			return 0;
+
+		lua_pushstring(L, str);
+
+		switch(msg.type)
+		{
+		case Event::TYPE_KEY_PRESSED:
+			if (!Event::getConstant(msg.keyboard.k, str))
+				return 0;
+			lua_pushstring(L, str);
+			lua_pushinteger(L, msg.keyboard.u);
+			return 3;
+		case Event::TYPE_KEY_RELEASED:
+			if (!Event::getConstant(msg.keyboard.k, str))
+				return 0;
+			lua_pushstring(L, str);
+			return 2;
+		case Event::TYPE_MOUSE_PRESSED:
+		case Event::TYPE_MOUSE_RELEASED:
+			if (!Event::getConstant(msg.mouse.b, str))
+				return 0;
+			lua_pushinteger(L, msg.mouse.x);
+			lua_pushinteger(L, msg.mouse.y);
+			lua_pushstring(L, str);
+			return 4;
+		case Event::TYPE_JOYSTICK_PRESSED:
+		case Event::TYPE_JOYSTICK_RELEASED:
+			lua_pushinteger(L, msg.joystick.index+1);
+			lua_pushinteger(L, msg.joystick.button+1);
+			return 3;
+		case Event::TYPE_FOCUS:
+			lua_pushboolean(L, msg.focus.f);
+			return 2;
+		case Event::TYPE_QUIT:
+			return 1;
+		default:
+			return 0;
+		}
+
+		return 0;
+	}
+
+	static int poll_i(lua_State * L)
+	{
+		static Event::Message m;
+
+		while (instance->poll(m))
+		{
+			int args = push_message(L, m);
+			if (args > 0)
+				return args;
+		}
+
+		// No pending events.
+		return 0;
+	}
+
+	int w_pump(lua_State *)
+	{
+		instance->pump();
+		return 0;
+	}
+
+	int w_poll(lua_State * L)
+	{
+		lua_pushcclosure(L, &poll_i, 0);
+		return 1;
+	}
+
+	int w_wait(lua_State * L)
+	{
+		static Event::Message m;
+
+		if (instance->wait(m))
+		{
+			return push_message(L, m);
+		}
+
+		return 0;
+	}
+
+	int w_push(lua_State * L)
+	{
+		static Event::Message m;
+
+		if (!to_message(L, m))
+		{
+			luax_pushboolean(L, false);
+			return 1;
+		}
+
+		luax_pushboolean(L, instance->push(m));
+
+		return 1;
+	}
+
+	int w_clear(lua_State *)
+	{
+		instance->clear();
+		return 0;
+	}
+
+	int w_quit(lua_State * L)
+	{
+		static Event::Message m;
+		m.type = Event::TYPE_QUIT;
+		luax_pushboolean(L, instance->push(m));
+		return 1;
+	}
+
+	// List of functions to wrap.
+	static const luaL_Reg functions[] = {
+		{ "pump", w_pump },
+		{ "poll", w_poll },
+		{ "wait", w_wait },
+		{ "push", w_push },
+		{ "clear", w_clear },
+		{ "quit", w_quit },
+		{ 0, 0 }
+	};
+
+	int luaopen_love_event(lua_State * L)
+	{
+		if (instance == 0)
+		{
+			try
+			{
+				instance = new Event();
+			}
+			catch (Exception & e)
+			{
+				return luaL_error(L, e.what());
+			}
+		}
+		else
+			instance->retain();
+
+		WrappedModule w;
+		w.module = instance;
+		w.name = "event";
+		w.flags = MODULE_T;
+		w.functions = functions;
+		w.types = 0;
+
+		return luax_register_module(L, w);
+	}
+
+} // sdl
+} // event
+} // love

+ 47 - 47
src/modules/event/sdl/wrap_Event.h

@@ -1,47 +1,47 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-* 
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-* 
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-* 
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#ifndef LOVE_EVENT_SDL_WRAP_EVENT_H
-#define LOVE_EVENT_SDL_WRAP_EVENT_H
-
-// LOVE
-#include <common/config.h>
-#include "Event.h"
-
-namespace love
-{
-namespace event
-{
-namespace sdl
-{
-	int w_pump(lua_State * L);
-	int w_poll(lua_State * L);
-	int w_wait(lua_State * L);
-	int w_push(lua_State * L);
-	int w_clear(lua_State * L);
-	int w_quit(lua_State * L);
-
-	extern "C" LOVE_EXPORT int luaopen_love_event(lua_State * L);
-
-} // sdl
-} // event
-} // love
-
-#endif // LOVE_EVENT_SDL_WRAP_EVENT_H
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#ifndef LOVE_EVENT_SDL_WRAP_EVENT_H
+#define LOVE_EVENT_SDL_WRAP_EVENT_H
+
+// LOVE
+#include <common/config.h>
+#include "Event.h"
+
+namespace love
+{
+namespace event
+{
+namespace sdl
+{
+	int w_pump(lua_State * L);
+	int w_poll(lua_State * L);
+	int w_wait(lua_State * L);
+	int w_push(lua_State * L);
+	int w_clear(lua_State * L);
+	int w_quit(lua_State * L);
+
+	extern "C" LOVE_EXPORT int luaopen_love_event(lua_State * L);
+
+} // sdl
+} // event
+} // love
+
+#endif // LOVE_EVENT_SDL_WRAP_EVENT_H

+ 4 - 4
src/modules/filesystem/File.cpp

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -38,7 +38,7 @@ namespace filesystem
 		return modes.find(in, out);
 	}
 
-	StringMap<File::Mode, File::MODE_MAX_ENUM>::Entry File::modeEntries[] = 
+	StringMap<File::Mode, File::MODE_MAX_ENUM>::Entry File::modeEntries[] =
 	{
 		{"c", File::CLOSED},
 		{"r", File::READ},

+ 15 - 15
src/modules/filesystem/File.h

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -34,7 +34,7 @@ namespace love
 namespace filesystem
 {
 	/**
-	* A File interface, providing generic means of reading from and 
+	* A File interface, providing generic means of reading from and
 	* writing to files.
 	**/
 	class File : public Object
@@ -65,7 +65,7 @@ namespace filesystem
 
 		/**
 		* Opens the file in a certain mode.
-		* 
+		*
 		* @param mode READ, WRITE, APPEND.
 		* @return True if successful, false otherwise.
 		**/
@@ -73,21 +73,21 @@ namespace filesystem
 
 		/**
 		* Closes the file.
-		* 
+		*
 		* @return True if successful, false otherwise.
 		**/
 		virtual bool close() = 0;
 
 		/**
 		* Gets the size of the file.
-		* 
+		*
 		* @return The size of the file.
 		**/
 		virtual unsigned int getSize() = 0;
 
 		/**
 		* Reads data from the file and allocates a Data object.
-		* 
+		*
 		* @param size The number of bytes to attempt reading, or -1 for EOF.
 		* @return A newly allocated Data object.
 		**/
@@ -95,7 +95,7 @@ namespace filesystem
 
 		/**
 		* Reads data into the destination buffer.
-		* 
+		*
 		* @param dst The destination buffer.
 		* @param size The number of bytes to attempt reading.
 		* @return The number of bytes actually read.
@@ -104,7 +104,7 @@ namespace filesystem
 
 		/**
 		* Writes data into the File.
-		* 
+		*
 		* @param data The source buffer.
 		* @param size The size of the buffer.
 		* @return True of success, false otherwise.
@@ -113,7 +113,7 @@ namespace filesystem
 
 		/**
 		* Writes a Data object into the File.
-		* 
+		*
 		* @param data The data object to write into the file.
 		* @param size The number of bytes to attempt writing, or -1 for everything.
 		* @return True of success, false otherwise.
@@ -122,28 +122,28 @@ namespace filesystem
 
 		/**
 		* Checks whether we are currently at end-of-file.
-		* 
+		*
 		* @return True if EOF, false otherwise.
 		**/
 		virtual bool eof() = 0;
 
 		/**
 		* Gets the current position in the File.
-		* 
+		*
 		* @return The current byte position in the File.
 		**/
 		virtual int tell() = 0;
 
 		/**
 		* Seeks to a certain position in the File.
-		* 
+		*
 		* @param pos The byte position in the file.
 		* @return True on success, false otherwise.
 		**/
 		virtual bool seek(int pos) = 0;
 
 		/**
-		* Gets the current mode of the File. 
+		* Gets the current mode of the File.
 		* @return The current mode of the File; CLOSED, READ, WRITE or APPEND.
 		**/
 		virtual Mode getMode() = 0;

+ 5 - 5
src/modules/filesystem/FileData.cpp

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -30,7 +30,7 @@ namespace filesystem
 	FileData::FileData(int size, const std::string & filename)
 		: data(new char[size]), size(size), filename(filename)
 	{
-		if(filename.rfind('.') != std::string::npos)
+		if (filename.rfind('.') != std::string::npos)
 			extension = filename.substr(filename.rfind('.')+1);
 	}
 
@@ -69,7 +69,7 @@ namespace filesystem
 		return decoders.find(in, out);
 	}
 
-	StringMap<FileData::Decoder, FileData::DECODE_MAX_ENUM>::Entry FileData::decoderEntries[] = 
+	StringMap<FileData::Decoder, FileData::DECODE_MAX_ENUM>::Entry FileData::decoderEntries[] =
 	{
 		{"file", FileData::FILE},
 		{"base64", FileData::BASE64},

+ 4 - 4
src/modules/filesystem/FileData.h

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -27,7 +27,7 @@
 #include <common/StringMap.h>
 
 namespace love
-{	
+{
 namespace filesystem
 {
 	class FileData : public Data

+ 24 - 24
src/modules/filesystem/physfs/File.cpp

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -35,7 +35,7 @@ namespace physfs
 {
 	extern bool hack_setupWriteDirectory();
 
-	File::File(std::string filename) 
+	File::File(std::string filename)
 		: filename(filename), file(0), mode(filesystem::File::CLOSED)
 	{
 	}
@@ -45,22 +45,22 @@ namespace physfs
 		if (mode != CLOSED)
 			close();
 	}
-	
+
 	bool File::open(Mode mode)
 	{
-		if(mode == CLOSED)
+		if (mode == CLOSED)
 			return true;
 
 		// File must exist if read mode.
-		if((mode == READ) && !PHYSFS_exists(filename.c_str()))
+		if ((mode == READ) && !PHYSFS_exists(filename.c_str()))
 			throw love::Exception("Could not open file %s. Does not exist.", filename.c_str());
 
 		// Check whether the write directory is set.
-		if((mode == APPEND || mode == WRITE) && (PHYSFS_getWriteDir() == 0) && !hack_setupWriteDirectory())
+		if ((mode == APPEND || mode == WRITE) && (PHYSFS_getWriteDir() == 0) && !hack_setupWriteDirectory())
 			throw love::Exception("Could not set write directory.");
 
 		// File already open?
-		if(file != 0)
+		if (file != 0)
 			return false;
 
 		this->mode = mode;
@@ -82,10 +82,10 @@ namespace physfs
 
 		return (file != 0);
 	}
-	
+
 	bool File::close()
 	{
-		if(!PHYSFS_close(file))
+		if (!PHYSFS_close(file))
 			return false;
 		mode = CLOSED;
 		file = 0;
@@ -96,7 +96,7 @@ namespace physfs
 	{
 		// If the file is closed, open it to
 		// check the size.
-		if(file == 0)
+		if (file == 0)
 		{
 			open(READ);
 			unsigned int size = (unsigned int)PHYSFS_fileLength(file);
@@ -112,7 +112,7 @@ namespace physfs
 	{
 		bool isOpen = (file != 0);
 
-		if(!isOpen && !open(READ))
+		if (!isOpen && !open(READ))
 			throw love::Exception("Could not read file %s.", filename.c_str());
 
 		int max = (int)PHYSFS_fileLength(file);
@@ -123,7 +123,7 @@ namespace physfs
 
 		read(fileData->getData(), size);
 
-		if(!isOpen)
+		if (!isOpen)
 			close();
 
 		return fileData;
@@ -133,7 +133,7 @@ namespace physfs
 	{
 		bool isOpen = (file != 0);
 
-		if(!isOpen)
+		if (!isOpen)
 			open(READ);
 
 		int max = (int)PHYSFS_fileLength(file);
@@ -142,7 +142,7 @@ namespace physfs
 
 		int read = (int)PHYSFS_read(file, dst, 1, size);
 
-		if(!isOpen)
+		if (!isOpen)
 			close();
 
 		return read;
@@ -150,14 +150,14 @@ namespace physfs
 
 	bool File::write(const void * data, int size)
 	{
-		if(file == 0)
+		if (file == 0)
 			throw love::Exception("Could not write to file. File not open.");
 
 		// Try to write.
 		int written = static_cast<int>(PHYSFS_write(file, data, 1, size));
 
 		// Check that correct amount of data was written.
-		if(written != size)
+		if (written != size)
 			return false;
 
 		return true;
@@ -187,14 +187,14 @@ namespace physfs
 
 	bool File::eof()
 	{
-		if(file == 0 || test_eof(this, file))
+		if (file == 0 || test_eof(this, file))
 			return true;
 		return false;
 	}
 
 	int File::tell()
 	{
-		if(file == 0)
+		if (file == 0)
 			return -1;
 
 		return (int)PHYSFS_tell(file);
@@ -202,10 +202,10 @@ namespace physfs
 
 	bool File::seek(int pos)
 	{
-		if(file == 0)
+		if (file == 0)
 			return false;
-		
-		if(!PHYSFS_seek(file, (PHYSFS_uint64)pos))
+
+		if (!PHYSFS_seek(file, (PHYSFS_uint64)pos))
 			return false;
 		return true;
 	}
@@ -219,7 +219,7 @@ namespace physfs
 	{
 		std::string::size_type idx = filename.rfind('.');
 
-		if(idx != std::string::npos)
+		if (idx != std::string::npos)
 			return filename.substr(idx+1);
 		else
 			return std::string();

+ 4 - 4
src/modules/filesystem/physfs/File.h

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -63,7 +63,7 @@ namespace physfs
 		File(std::string filename);
 
 		virtual ~File();
-		
+
 		// Implements love::filesystem::File.
 		bool open(Mode mode);
 		bool close();

+ 59 - 54
src/modules/filesystem/physfs/Filesystem.cpp

@@ -40,7 +40,7 @@ namespace physfs
 
 	Filesystem::~Filesystem()
 	{
-		if(isInited)
+		if (isInited)
 		{
 			isInited = false;
 			PHYSFS_deinit();
@@ -54,7 +54,7 @@ namespace physfs
 
 	void Filesystem::init(const char * arg0)
 	{
-		if(!PHYSFS_init(arg0))
+		if (!PHYSFS_init(arg0))
 			throw Exception(PHYSFS_getLastError());
 		isInited = true;
 	}
@@ -76,7 +76,7 @@ namespace physfs
 
 	bool Filesystem::setIdentity( const char * ident )
 	{
-		if(!isInited)
+		if (!isInited)
 			return false;
 
 		// Store the save directory.
@@ -106,15 +106,15 @@ namespace physfs
 
 	bool Filesystem::setSource(const char * source)
 	{
-		if(!isInited)
+		if (!isInited)
 			return false;
 
 		// Check whether directory is already set.
-		if(!game_source.empty())
+		if (!game_source.empty())
 			return false;
 
 		// Add the directory.
-		if(!PHYSFS_addToSearchPath(source, 1))
+		if (!PHYSFS_addToSearchPath(source, 1))
 			return false;
 
 		// Save the game source.
@@ -125,16 +125,16 @@ namespace physfs
 
 	bool Filesystem::setupWriteDirectory()
 	{
-		if(!isInited)
+		if (!isInited)
 			return false;
 
 		// These must all be set.
-		if(save_identity.empty() || save_path_full.empty() || save_path_relative.empty())
+		if (save_identity.empty() || save_path_full.empty() || save_path_relative.empty())
 			return false;
 
 		// Set the appdata folder as writable directory.
 		// (We must create the save folder before mounting it).
-		if(!PHYSFS_setWriteDir(getAppdataDirectory()))
+		if (!PHYSFS_setWriteDir(getAppdataDirectory()))
 			return false;
 
 		// Create the save folder. (We're now "at" %APPDATA%).
@@ -144,18 +144,18 @@ namespace physfs
 		else
 			success = mkdir(save_path_relative.c_str());
 
-		if(!success)
+		if (!success)
 		{
 			PHYSFS_setWriteDir(0); // Clear the write directory in case of error.
 			return false;
 		}
 
 		// Set the final write directory.
-		if(!PHYSFS_setWriteDir(save_path_full.c_str()))
+		if (!PHYSFS_setWriteDir(save_path_full.c_str()))
 			return false;
 
 		// Add the directory. (Will not be readded if already present).
-		if(!PHYSFS_addToSearchPath(save_path_full.c_str(), 0))
+		if (!PHYSFS_addToSearchPath(save_path_full.c_str(), 0))
 		{
 			PHYSFS_setWriteDir(0); // Clear the write directory in case of error.
 			return false;
@@ -195,7 +195,7 @@ namespace physfs
 
 	const char * Filesystem::getWorkingDirectory()
 	{
-		if(cwd.empty())
+		if (cwd.empty())
 		{
 #ifdef LOVE_WINDOWS
 
@@ -206,7 +206,7 @@ namespace physfs
 #else
 			char * cwd_char = new char[LOVE_MAX_PATH];
 
-			if(getcwd(cwd_char, LOVE_MAX_PATH))
+			if (getcwd(cwd_char, LOVE_MAX_PATH))
 				cwd = cwd_char; // if getcwd fails, cwd_char (and thus cwd) will still be empty
 
 			delete [] cwd_char;
@@ -224,7 +224,7 @@ namespace physfs
 	const char * Filesystem::getAppdataDirectory()
 	{
 #ifdef LOVE_WINDOWS
-		if(appdata.empty())
+		if (appdata.empty())
 		{
 			wchar_t * w_appdata = _wgetenv(TEXT("APPDATA"));
 			appdata = to_utf8(w_appdata);
@@ -232,7 +232,7 @@ namespace physfs
 		}
 		return appdata.c_str();
 #elif defined(LOVE_MACOSX)
-		if(appdata.empty())
+		if (appdata.empty())
 		{
 			std::string udir = getUserDirectory();
 			udir.append("/Library/Application Support");
@@ -240,7 +240,7 @@ namespace physfs
 		}
 		return appdata.c_str();
 #elif defined(LOVE_LINUX)
-		if(appdata.empty())
+		if (appdata.empty())
 		{
 			char * xdgdatahome = getenv("XDG_DATA_HOME");
 			if (!xdgdatahome)
@@ -262,14 +262,14 @@ namespace physfs
 
 	bool Filesystem::exists(const char * file)
 	{
-		if(PHYSFS_exists(file))
+		if (PHYSFS_exists(file))
 			return true;
 		return false;
 	}
 
 	bool Filesystem::isDirectory(const char * file)
 	{
-		if(PHYSFS_isDirectory(file))
+		if (PHYSFS_isDirectory(file))
 			return true;
 		return false;
 	}
@@ -281,20 +281,20 @@ namespace physfs
 
 	bool Filesystem::mkdir(const char * file)
 	{
-		if(PHYSFS_getWriteDir() == 0 && !setupWriteDirectory())
+		if (PHYSFS_getWriteDir() == 0 && !setupWriteDirectory())
 			return false;
 
-		if(!PHYSFS_mkdir(file))
+		if (!PHYSFS_mkdir(file))
 			return false;
 		return true;
 	}
 
 	bool Filesystem::remove(const char * file)
 	{
-		if(PHYSFS_getWriteDir() == 0 && !setupWriteDirectory())
+		if (PHYSFS_getWriteDir() == 0 && !setupWriteDirectory())
 			return false;
 
-		if(!PHYSFS_delete(file))
+		if (!PHYSFS_delete(file))
 			return false;
 		return true;
 	}
@@ -305,7 +305,7 @@ namespace physfs
 		// on-the-fly, or passed as a parameter.
 		File * file;
 
-        if(lua_isstring(L, 1))
+        if (lua_isstring(L, 1))
 		{
 			// Create the file.
 			file = newFile(lua_tostring(L, 1));
@@ -321,12 +321,12 @@ namespace physfs
 		Data * data = file->read(count);
 
 		// Error check.
-		if(data == 0)
+		if (data == 0)
 			return luaL_error(L, "File could not be read.");
 
 		// Close and delete the file, if we created it.
 		// (I.e. if the first parameter is a string).
-		if(lua_isstring(L, 1))
+		if (lua_isstring(L, 1))
 			file->release();
 
 		// Push the string.
@@ -349,10 +349,10 @@ namespace physfs
 
 		// We know for sure that we need a second parameter, so
 		// let's check that first.
-		if(lua_isnoneornil(L, 2))
+		if (lua_isnoneornil(L, 2))
 			return luaL_error(L, "Second argument needed.");
 
-		if(lua_isstring(L, 1))
+		if (lua_isstring(L, 1))
 		{
 			// Create the file.
 			file = newFile(lua_tostring(L, 1));
@@ -363,26 +363,31 @@ namespace physfs
 		// Get the current mode of the file.
 		File::Mode mode = file->getMode();
 
-		if(mode == File::CLOSED)
+		if (mode == File::CLOSED)
 		{
 			// It should be possible to use append mode, but
 			// normal File::Mode::Write is the default.
 			int mode = luaL_optint(L, 4, File::WRITE);
 
 			// Open the file.
-			if(!file->open((File::Mode)mode))
+			if (!file->open((File::Mode)mode))
 				return luaL_error(L, "Could not open file.");
 		}
 
 		size_t length = 0;
 		const char * input;
-		if(lua_isstring(L, 2)) {
+		if (lua_isstring(L, 2))
+		{
 			input = lua_tolstring(L, 2, &length);
-		} else if (luax_istype(L, 2, DATA_T)) {
+		}
+		else if (luax_istype(L, 2, DATA_T))
+		{
 			love::Data * data = luax_totype<love::Data>(L, 2, "Data", DATA_T);
 			length = data->getSize();
 			input = (char *)data->getData();
-		} else {
+		}
+		else
+		{
 			return luaL_error(L, "Expected string or data for argument #2.");
 		}
 
@@ -394,14 +399,14 @@ namespace physfs
 
 		// Close and delete the file, if we created
 		// it in this function.
-		if(lua_isstring(L, 1))
+		if (lua_isstring(L, 1))
 		{
 			// Kill the file if "we" created it.
 			file->close();
 			file->release();
 		}
 
-		if(!success)
+		if (!success)
 			return luaL_error(L, "Data could not be written.");
 
 		lua_pushboolean(L, success);
@@ -412,12 +417,12 @@ namespace physfs
 	{
 		int n = lua_gettop(L);
 
-		if( n != 1 )
+		if ( n != 1 )
 			return luaL_error(L, "Function requires a single parameter.");
 
 		int type = lua_type(L, 1);
 
-		if(type != LUA_TSTRING)
+		if (type != LUA_TSTRING)
 			return luaL_error(L, "Function requires parameter of type string.");
 
 		const char * dir = lua_tostring(L, 1);
@@ -444,10 +449,10 @@ namespace physfs
 	{
 		File * file;
 
-		if(lua_isstring(L, 1))
+		if (lua_isstring(L, 1))
 		{
 			file = newFile(lua_tostring(L, 1));
-			if(!file->open(File::READ))
+			if (!file->open(File::READ))
 				return luaL_error(L, "Could not open file %s.\n", lua_tostring(L, 1));
 			lua_pop(L, 1);
 
@@ -458,7 +463,7 @@ namespace physfs
 			return luaL_error(L, "Expected filename.");
 
 		// Reset the file position.
-		if(!file->seek(0))
+		if (!file->seek(0))
 			return luaL_error(L, "File does not appear to be open.\n");
 
 		lua_pushcclosure(L, lines_i, 2);
@@ -480,34 +485,34 @@ namespace physfs
 		int newline = -1;
 		int totalread = 0;
 
-		while(!file->eof())
+		while (!file->eof())
 		{
 			int current = file->tell();
 			int read = file->read(buf, bufsize);
 			totalread += read;
 
-			if(read < 0)
+			if (read < 0)
 				return luaL_error(L, "Readline failed!");
 
-			for(int i = 0;i<read;i++)
+			for (int i = 0;i<read;i++)
 			{
-				if(buf[i] == '\n')
+				if (buf[i] == '\n')
 				{
 					newline = current+i;
 					break;
 				}
 			}
 
-			if(newline > 0)
+			if (newline > 0)
 				break;
 		}
 
 		// Special case for the last "line".
-		if(newline <= 0 && file->eof() && totalread > 0)
+		if (newline <= 0 && file->eof() && totalread > 0)
 			newline = pos + totalread;
 
 		// We've got a newline.
-		if(newline > 0)
+		if (newline > 0)
 		{
 			// Ok, we've got a line.
 			int linesize = (newline-pos);
@@ -517,10 +522,10 @@ namespace physfs
 
 			// Read it.
 			file->seek(pos);
-			if(file->read(str, linesize) == -1)
+			if (file->read(str, linesize) == -1)
 				return luaL_error(L, "Read error.");
 
-			if(str[linesize-1]=='\r')
+			if (str[linesize-1]=='\r')
 				linesize -= 1;
 
 			lua_pushlstring(L, str, linesize);
@@ -529,13 +534,13 @@ namespace physfs
 			delete[] str;
 
 			// Set the beginning of the next line.
-			if(!file->eof())
+			if (!file->eof())
 				file->seek(newline+1);
-	
+
 			return 1;
 		}
 
-		if(close)
+		if (close)
 		{
 			file->close();
 			file->release();
@@ -550,13 +555,13 @@ namespace physfs
 		luax_assert_argc(L, 1, 1);
 
 		// Must be string.
-		if(!lua_isstring(L, -1))
+		if (!lua_isstring(L, -1))
 			return luaL_error(L, "The argument must be a string.");
 
 		std::string filename = lua_tostring(L, -1);
 
 		// The file must exist.
-		if(!exists(filename.c_str()))
+		if (!exists(filename.c_str()))
 			return luaL_error(L, "File %s does not exist.", filename.c_str());
 
 		// Create the file.

+ 16 - 14
src/modules/filesystem/physfs/wrap_File.cpp

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -53,14 +53,14 @@ namespace physfs
 		File * file = luax_checkfile(L, 1);
 		File::Mode mode;
 
-		if(!File::getConstant(luaL_checkstring(L, 2), mode))
+		if (!File::getConstant(luaL_checkstring(L, 2), mode))
 			return luaL_error(L, "Incorrect file open mode: %s", luaL_checkstring(L, 2));
 
 		try
 		{
 			lua_pushboolean(L, file->open(mode) ? 1 : 0);
 		}
-		catch(Exception e)
+		catch (Exception e)
 		{
 			return luaL_error(L, e.what());
 		}
@@ -84,7 +84,7 @@ namespace physfs
 		{
 			d = file->read(luaL_optint(L, 2, file->getSize()));
 		}
-		catch(Exception e)
+		catch (Exception e)
 		{
 			return luaL_error(L, e.what());
 		}
@@ -107,18 +107,20 @@ namespace physfs
 			{
 				result = file->write(lua_tostring(L, 2), luaL_optint(L, 3, lua_objlen(L, 2)));
 			}
-			catch(Exception e)
+			catch (Exception e)
 			{
 				return luaL_error(L, e.what());
 			}
-			
+
 		}
-		else if( luax_istype(L, 2, DATA_T)) {
+		else if ( luax_istype(L, 2, DATA_T))
+		{
 			try
 			{
 				love::Data * data = luax_totype<love::Data>(L, 2, "Data", DATA_T);
 				result = file->write(data, luaL_optint(L, 3, data->getSize()));
-			} catch(Exception e)
+			}
+			catch (Exception e)
 			{
 				return luaL_error(L, e.what());
 			}
@@ -159,7 +161,7 @@ namespace physfs
 	{
 		File * file;
 
-		if(luax_istype(L, 1, FILESYSTEM_FILE_T))
+		if (luax_istype(L, 1, FILESYSTEM_FILE_T))
 		{
 			file = luax_checktype<File>(L, 1, "File", FILESYSTEM_FILE_T);
 			lua_pushnumber(L, 0); // 0 = do not close.
@@ -168,14 +170,14 @@ namespace physfs
 			return luaL_error(L, "Expected file handle.");
 
 		// Reset the file position.
-		if(!file->seek(0))
+		if (!file->seek(0))
 		return luaL_error(L, "File does not appear to be open.\n");
 
 		lua_pushcclosure(L, Filesystem::lines_i, 2);
 		return 1;
 	}
 
-	static const luaL_Reg functions[] = { 
+	static const luaL_Reg functions[] = {
 			{ "getSize", w_File_getSize },
 			{ "open", w_File_open },
 			{ "close", w_File_close },
@@ -192,7 +194,7 @@ namespace physfs
 	{
 		return luax_register_type(L, "File", functions);
 	}
-	
+
 } // physfs
 } // filesystem
 } // love

+ 3 - 3
src/modules/filesystem/physfs/wrap_File.h

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be

+ 4 - 4
src/modules/filesystem/physfs/wrap_FileData.cpp

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -63,7 +63,7 @@ namespace physfs
 	{
 		return luax_register_type(L, "FileData", w_FileData_functions);
 	}
-	
+
 } // physfs
 } // filesystem
 } // love

+ 3 - 3
src/modules/filesystem/physfs/wrap_FileData.h

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be

+ 23 - 20
src/modules/filesystem/physfs/wrap_Filesystem.cpp

@@ -31,7 +31,7 @@ namespace physfs
 
 	bool hack_setupWriteDirectory()
 	{
-		if(instance != 0)
+		if (instance != 0)
 			return instance->setupWriteDirectory();
 		return false;
 	}
@@ -44,7 +44,7 @@ namespace physfs
 		{
 			instance->init(arg0);
 		}
-		catch(Exception & e)
+		catch (Exception & e)
 		{
 			return luaL_error(L, e.what());
 		}
@@ -64,7 +64,7 @@ namespace physfs
 	{
 		const char * arg = luaL_checkstring(L, 1);
 
-		if(!instance->setIdentity(arg))
+		if (!instance->setIdentity(arg))
 			return luaL_error(L, "Could not set write directory.");
 
 		return 0;
@@ -74,7 +74,7 @@ namespace physfs
 	{
 		const char * arg = luaL_checkstring(L, 1);
 
-		if(!instance->setSource(arg))
+		if (!instance->setSource(arg))
 			return luaL_error(L, "Could not set source.");
 
 		return 0;
@@ -88,7 +88,7 @@ namespace physfs
 		{
 			t = instance->newFile(filename);
 		}
-		catch(Exception e)
+		catch (Exception e)
 		{
 			return luaL_error(L, e.what());
 		}
@@ -98,9 +98,9 @@ namespace physfs
 
 	int w_newFileData(lua_State * L)
 	{
-		if(!lua_isstring(L, 1))
+		if (!lua_isstring(L, 1))
 			return luaL_error(L, "String expected.");
-		if(!lua_isstring(L, 2))
+		if (!lua_isstring(L, 2))
 			return luaL_error(L, "String expected.");
 
 		size_t length = 0;
@@ -110,7 +110,7 @@ namespace physfs
 
 		FileData::Decoder decoder = FileData::FILE;
 
-		if(decstr)
+		if (decstr)
 			FileData::getConstant(decstr, decoder);
 
 		FileData * t = 0;
@@ -196,7 +196,7 @@ namespace physfs
 		{
 			return instance->read(L);
 		}
-		catch(Exception e)
+		catch (Exception e)
 		{
 			return luaL_error(L, e.what());
 		}
@@ -208,7 +208,7 @@ namespace physfs
 		{
 			return instance->write(L);
 		}
-		catch(Exception e)
+		catch (Exception e)
 		{
 			return luaL_error(L, e.what());
 		}
@@ -233,10 +233,12 @@ namespace physfs
 
 	int w_load(lua_State * L)
 	{
-		try {
+		try
+		{
 			return instance->load(L);
 		}
-		catch (love::Exception & e) {
+		catch (love::Exception & e)
+		{
 			return luaL_error(L, e.what());
 		}
 	}
@@ -255,16 +257,16 @@ namespace physfs
 
 		int size = tmp.size();
 
-		for(int i=0;i<size-4;i++)
+		for (int i=0;i<size-4;i++)
 		{
-			if(tmp[i] == '.')
+			if (tmp[i] == '.')
 			{
 				tmp[i] = '/';
 			}
 		}
 
 		// Check whether file exists.
-		if(instance->exists(tmp.c_str()))
+		if (instance->exists(tmp.c_str()))
 		{
 			lua_pop(L, 1);
 			lua_pushstring(L, tmp.c_str());
@@ -274,9 +276,9 @@ namespace physfs
 
 		tmp = filename;
 		size = tmp.size();
-		for(int i=0;i<size;i++)
+		for (int i=0;i<size;i++)
 		{
-			if(tmp[i] == '.')
+			if (tmp[i] == '.')
 			{
 				tmp[i] = '/';
 			}
@@ -285,7 +287,8 @@ namespace physfs
 		if (instance->isDirectory(tmp.c_str()))
 		{
 			tmp += "/init.lua";
-			if (instance->exists(tmp.c_str())) {
+			if (instance->exists(tmp.c_str()))
+			{
 				lua_pop(L, 1);
 				lua_pushstring(L, tmp.c_str());
 				// Ok, load it.
@@ -384,7 +387,7 @@ namespace physfs
 
 	int luaopen_love_filesystem(lua_State * L)
 	{
-		if(instance == 0)
+		if (instance == 0)
 		{
 			try
 			{
@@ -392,7 +395,7 @@ namespace physfs
 				love::luax_register_searcher(L, loader, 1);
 				love::luax_register_searcher(L, extloader, 2);
 			}
-			catch(Exception & e)
+			catch (Exception & e)
 			{
 				return luaL_error(L, e.what());
 			}

+ 3 - 3
src/modules/filesystem/physfs/wrap_Filesystem.h

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be

+ 3 - 3
src/modules/font/Font.h

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be

+ 3 - 2
src/modules/font/GlyphData.cpp

@@ -30,7 +30,8 @@ namespace font
 	GlyphData::GlyphData(unsigned short glyph, GlyphMetrics glyphMetrics, GlyphData::Format f)
 		: glyph(glyph), metrics(glyphMetrics), data(0), format(f)
 	{
-		if (metrics.width && metrics.height) {
+		if (metrics.width && metrics.height)
+		{
 			switch (f) {
 				case GlyphData::FORMAT_LUMINANCE_ALPHA:
 					data = new unsigned char[metrics.width * metrics.height * 2];
@@ -116,6 +117,6 @@ namespace font
 	{
 		return format;
 	}
-	
+
 } // font
 } // love

+ 10 - 10
src/modules/font/GlyphData.h

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -47,14 +47,14 @@ namespace font
 	**/
 	class GlyphData : public Data
 	{
-		
+
 	public:
 		enum Format
 		{
 			FORMAT_LUMINANCE_ALPHA,
 			FORMAT_RGBA
 		};
-		
+
 		GlyphData(unsigned short glyph, GlyphMetrics glyphMetrics, Format f);
 		virtual ~GlyphData();
 
@@ -106,22 +106,22 @@ namespace font
 		* Gets the max y value of the glyph.
 		**/
 		int getMaxY() const;
-		
+
 		/**
 		* Gets the format of the glyph data.
 		**/
 		Format getFormat() const;
-		
+
 	private:
 		// The glyph itself
 		unsigned short glyph;
-		
+
 		// Glyph metrics
 		GlyphMetrics metrics;
-		
+
 		// Glyph texture data
 		unsigned char * data;
-		
+
 		// The format the data's in
 		Format format;
 

+ 10 - 9
src/modules/font/ImageRasterizer.cpp

@@ -72,7 +72,8 @@ namespace font
 		if (gm.width == 0) return g;
 		unsigned char * gd = (unsigned char*)g->getData();
 		love::image::pixel * pixels = (love::image::pixel *)(imageData->getData());
-		for (unsigned int i = 0; i < widths[glyph]*getHeight(); i++) {
+		for (unsigned int i = 0; i < widths[glyph]*getHeight(); i++)
+		{
 			love::image::pixel p = pixels[ positions[glyph] + (i % widths[glyph]) + (imageData->getWidth() * (i / widths[glyph])) ];
 			gd[i*4] = p.r;
 			gd[i*4+1] = p.g;
@@ -99,27 +100,27 @@ namespace font
 		unsigned int start = 0;
 		unsigned int end = 0;
 
-		for(unsigned int i = 0; i < length; ++i)
+		for (unsigned int i = 0; i < length; ++i)
 		{
-			if(i >= MAX_CHARS)
+			if (i >= MAX_CHARS)
 				break;
 
 			start = end;
 
 			// Finds out where the first character starts
-			while(start < imgw && equal(pixels[start], spacer))
+			while (start < imgw && equal(pixels[start], spacer))
 				++start;
 
-			if(i > 0)
+			if (i > 0)
 				spacing[glyphs[i - 1]] = (start > end) ? (start - end) : 0;
 
 			end = start;
 
 			// Find where glyph ends.
-			while(end < imgw && !equal(pixels[end], spacer))
+			while (end < imgw && !equal(pixels[end], spacer))
 				++end;
 
-			if(start >= end)
+			if (start >= end)
 				break;
 
 			unsigned c = glyphs[i];
@@ -129,9 +130,9 @@ namespace font
 		}
 
 		// Replace spacer color with an empty pixel
-		for(unsigned int i = 0; i < imgs; ++i)
+		for (unsigned int i = 0; i < imgs; ++i)
 		{
-			if(equal(pixels[i], spacer))
+			if (equal(pixels[i], spacer))
 			{
 				pixels[i].r = 0;
 				pixels[i].g = 0;

+ 7 - 7
src/modules/font/ImageRasterizer.h

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -38,7 +38,7 @@ namespace font
 	private:
 		// Load all the glyph positions into memory
 		void load();
-		
+
 		// The image data
 		love::image::ImageData * imageData;
 		// The glyphs in the font
@@ -51,7 +51,7 @@ namespace font
 		unsigned int * widths;
 		// The spacing of each glyph
 		unsigned int * spacing;
-	
+
 	public:
 		ImageRasterizer(love::image::ImageData * imageData, unsigned short * glyphs, int length);
 		virtual ~ImageRasterizer();
@@ -60,9 +60,9 @@ namespace font
 		virtual int getLineHeight() const;
 		virtual GlyphData * getGlyphData(unsigned short glyph) const;
 		virtual int getNumGlyphs() const;
-		
+
 		static const unsigned int MAX_CHARS = 256;
-		
+
 	}; // ImageRasterizer
 
 } // font

+ 3 - 3
src/modules/font/Rasterizer.cpp

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be

+ 5 - 5
src/modules/font/Rasterizer.h

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -47,7 +47,7 @@ namespace font
 	{
 	protected:
 		FontMetrics metrics;
-		
+
 	public:
 
 		virtual ~Rasterizer();
@@ -82,7 +82,7 @@ namespace font
 		* @param glyph The (UNICODE) glyph to get data for
 		**/
 		virtual GlyphData * getGlyphData(unsigned short glyph) const = 0;
-		
+
 		/**
 		* Gets the number of glyphs the rasterizer has data for.
 		**/

+ 7 - 6
src/modules/font/freetype/Font.cpp

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -31,7 +31,7 @@ namespace freetype
 {
 	Font::Font()
 	{
-		if(FT_Init_FreeType(&library))
+		if (FT_Init_FreeType(&library))
 			throw love::Exception("TrueTypeFont Loading error: FT_Init_FreeType failed\n");
 	}
 
@@ -44,12 +44,13 @@ namespace freetype
 	{
 		return new TrueTypeRasterizer(library, data, size);
 	}
-	
+
 	Rasterizer * Font::newRasterizer(love::image::ImageData * data, std::string glyphs)
 	{
 		int length = glyphs.size();
 		unsigned short * g = new unsigned short[length];
-		for (int i = 0; i < length; i++) {
+		for (int i = 0; i < length; i++)
+		{
 			g[i] = (unsigned char)glyphs[i];
 		}
 		Rasterizer * r = newRasterizer(data, g, length);

+ 6 - 6
src/modules/font/freetype/Font.h

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -52,18 +52,18 @@ namespace freetype
 	public:
 
 		Font();
-		
+
 		/**
 		* Destructor.
 		**/
 		virtual ~Font();
-		
+
 		// Implements Font
 		Rasterizer * newRasterizer(Data * data, int size);
 		Rasterizer * newRasterizer(love::image::ImageData * data, std::string glyphs);
 		Rasterizer * newRasterizer(love::image::ImageData * data, unsigned short * glyphs, int length);
 		GlyphData * newGlyphData(Rasterizer * r, unsigned short glyph);
-		
+
 		// Implement Module
 		const char * getName() const;
 

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

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -36,13 +36,13 @@ namespace freetype
 	{
 		data->retain();
 
-		if(FT_New_Memory_Face(	library,
+		if (FT_New_Memory_Face(	library,
 								(const FT_Byte *)data->getData(),	/* first byte in memory */
 								data->getSize(),					/* size in bytes        */
 								0,									/* face_index           */
 								&face))
 			throw love::Exception("TrueTypeFont Loading error: FT_New_Face failed (there is probably a problem with your font file)\n");
-		
+
 		FT_Set_Pixel_Sizes(face, size, size);
 
 		// Set global metrics
@@ -70,12 +70,12 @@ namespace freetype
 		FT_Glyph ftglyph;
 
 		// Initialize
-		if(FT_Load_Glyph(face, FT_Get_Char_Index(face, glyph), FT_LOAD_DEFAULT))
+		if (FT_Load_Glyph(face, FT_Get_Char_Index(face, glyph), FT_LOAD_DEFAULT))
 			throw love::Exception("TrueTypeFont Loading vm->error: FT_Load_Glyph failed\n");
-		
-		if( FT_Get_Glyph(face->glyph, &ftglyph) )
+
+		if ( FT_Get_Glyph(face->glyph, &ftglyph) )
 			throw love::Exception("TrueTypeFont Loading vm->error: FT_Get_Glyph failed\n");
-			
+
 		FT_Glyph_To_Bitmap(&ftglyph, FT_RENDER_MODE_NORMAL, 0, 1);
 		FT_BitmapGlyph bitmap_glyph = (FT_BitmapGlyph)ftglyph;
 		FT_Bitmap& bitmap = bitmap_glyph->bitmap; //just to make things easier
@@ -93,22 +93,22 @@ namespace freetype
 			int size = bitmap.rows*bitmap.width;
 			unsigned char * dst = (unsigned char *)glyphData->getData();
 
-			// Note that bitmap.buffer contains only luminosity. We copy that single value to 
-			// our luminosity-alpha format. 
-			for(int i = 0; i<size; i++)
+			// Note that bitmap.buffer contains only luminosity. We copy that single value to
+			// our luminosity-alpha format.
+			for (int i = 0; i<size; i++)
 			{
 				dst[2*i] = 255;
 				dst[2*i+1] = bitmap.buffer[i];
 			}
 		}
-		
+
 		// Having copied the data over, we can destroy the glyph
 		FT_Done_Glyph(ftglyph);
 
 		// Return data
 		return glyphData;
 	}
-	
+
 	int TrueTypeRasterizer::getNumGlyphs() const
 	{
 		return 256;

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

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -51,7 +51,7 @@ namespace freetype
 
 		// File data
 		Data * data;
-		
+
 	public:
 		TrueTypeRasterizer(FT_Library library, Data * data, int size);
 		virtual ~TrueTypeRasterizer();

+ 110 - 108
src/modules/font/freetype/wrap_Font.cpp

@@ -1,108 +1,110 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-*
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-*
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-*
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#include "wrap_Font.h"
-
-#include "Font.h"
-
-#include <font/wrap_GlyphData.h>
-#include <font/wrap_Rasterizer.h>
-
-#include "TrueTypeRasterizer.h"
-
-namespace love
-{
-namespace font
-{
-namespace freetype
-{
-	static Font * instance = 0;
-
-	int w_newRasterizer(lua_State * L)
-	{
-		Rasterizer * t = NULL;
-		if (luax_istype(L, 1, IMAGE_IMAGE_DATA_T)) {
-			love::image::ImageData * d = luax_checktype<love::image::ImageData>(L, 1, "ImageData", IMAGE_IMAGE_DATA_T);
-			const char * g = luaL_checkstring(L, 2);
-			std::string glyphs(g);
-			t = instance->newRasterizer(d, glyphs);
-		}
-		else if (luax_istype(L, 1, DATA_T)) {
-			Data * d = luax_checkdata(L, 1);
-			int size = luaL_checkint(L, 2);
-			t = instance->newRasterizer(d, size);
-		}
-		
-		luax_newtype(L, "Rasterizer", FONT_RASTERIZER_T, t);
-		return 1;
-	}
-
-	int w_newGlyphData(lua_State * L)
-	{
-		Rasterizer * r = luax_checkrasterizer(L, 1);
-		unsigned short g = (unsigned short)luaL_checkint(L, 2);
-
-		GlyphData * t = instance->newGlyphData(r, g);
-		luax_newtype(L, "GlyphData", FONT_GLYPH_DATA_T, t);
-		return 1;
-	}
-
-	// List of functions to wrap.
-	static const luaL_Reg functions[] = {
-		{ "newRasterizer",  w_newRasterizer },
-		{ "newGlyphData",  w_newGlyphData },
-		{ 0, 0 }
-	};
-
-	static const lua_CFunction types[] = {
-		luaopen_glyphdata,
-		luaopen_rasterizer,
-		0
-	};
-
-	int luaopen_love_font(lua_State * L)
-	{
-		if(instance == 0)
-		{
-			try
-			{
-				instance = new Font();
-			}
-			catch(Exception & e)
-			{
-				return luaL_error(L, e.what());
-			}
-		}
-		else
-			instance->retain();
-
-		WrappedModule w;
-		w.module = instance;
-		w.name = "font";
-		w.flags = MODULE_T;
-		w.functions = functions;
-		w.types = types;
-
-		return luax_register_module(L, w);
-	}
-
-} // freetype
-} // font
-} // love
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#include "wrap_Font.h"
+
+#include "Font.h"
+
+#include <font/wrap_GlyphData.h>
+#include <font/wrap_Rasterizer.h>
+
+#include "TrueTypeRasterizer.h"
+
+namespace love
+{
+namespace font
+{
+namespace freetype
+{
+	static Font * instance = 0;
+
+	int w_newRasterizer(lua_State * L)
+	{
+		Rasterizer * t = NULL;
+		if (luax_istype(L, 1, IMAGE_IMAGE_DATA_T))
+		{
+			love::image::ImageData * d = luax_checktype<love::image::ImageData>(L, 1, "ImageData", IMAGE_IMAGE_DATA_T);
+			const char * g = luaL_checkstring(L, 2);
+			std::string glyphs(g);
+			t = instance->newRasterizer(d, glyphs);
+		}
+		else if (luax_istype(L, 1, DATA_T))
+		{
+			Data * d = luax_checkdata(L, 1);
+			int size = luaL_checkint(L, 2);
+			t = instance->newRasterizer(d, size);
+		}
+
+		luax_newtype(L, "Rasterizer", FONT_RASTERIZER_T, t);
+		return 1;
+	}
+
+	int w_newGlyphData(lua_State * L)
+	{
+		Rasterizer * r = luax_checkrasterizer(L, 1);
+		unsigned short g = (unsigned short)luaL_checkint(L, 2);
+
+		GlyphData * t = instance->newGlyphData(r, g);
+		luax_newtype(L, "GlyphData", FONT_GLYPH_DATA_T, t);
+		return 1;
+	}
+
+	// List of functions to wrap.
+	static const luaL_Reg functions[] = {
+		{ "newRasterizer",  w_newRasterizer },
+		{ "newGlyphData",  w_newGlyphData },
+		{ 0, 0 }
+	};
+
+	static const lua_CFunction types[] = {
+		luaopen_glyphdata,
+		luaopen_rasterizer,
+		0
+	};
+
+	int luaopen_love_font(lua_State * L)
+	{
+		if (instance == 0)
+		{
+			try
+			{
+				instance = new Font();
+			}
+			catch (Exception & e)
+			{
+				return luaL_error(L, e.what());
+			}
+		}
+		else
+			instance->retain();
+
+		WrappedModule w;
+		w.module = instance;
+		w.name = "font";
+		w.flags = MODULE_T;
+		w.functions = functions;
+		w.types = types;
+
+		return luax_register_module(L, w);
+	}
+
+} // freetype
+} // font
+} // love

+ 42 - 42
src/modules/font/freetype/wrap_Font.h

@@ -1,42 +1,42 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-* 
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-* 
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-* 
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#ifndef LOVE_FONT_FREETYPE_WRAP_FONT_H
-#define LOVE_FONT_FREETYPE_WRAP_FONT_H
-
-// LOVE
-#include <common/config.h>
-#include <common/runtime.h>
-
-namespace love
-{
-namespace font
-{
-namespace freetype
-{
-	int w_newRasterizer(lua_State * L);
-	int w_newGlyphData(lua_State * L);
-	extern "C" LOVE_EXPORT int luaopen_love_font(lua_State * L);
-
-} // freetype
-} // font
-} // love
-
-#endif // LOVE_FONT_FREETYPE_WRAP_FONT_H
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#ifndef LOVE_FONT_FREETYPE_WRAP_FONT_H
+#define LOVE_FONT_FREETYPE_WRAP_FONT_H
+
+// LOVE
+#include <common/config.h>
+#include <common/runtime.h>
+
+namespace love
+{
+namespace font
+{
+namespace freetype
+{
+	int w_newRasterizer(lua_State * L);
+	int w_newGlyphData(lua_State * L);
+	extern "C" LOVE_EXPORT int luaopen_love_font(lua_State * L);
+
+} // freetype
+} // font
+} // love
+
+#endif // LOVE_FONT_FREETYPE_WRAP_FONT_H

+ 44 - 44
src/modules/font/wrap_GlyphData.cpp

@@ -1,44 +1,44 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-* 
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-* 
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-* 
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#include "wrap_GlyphData.h"
-
-namespace love
-{
-namespace font
-{
-	GlyphData * luax_checkglyphdata(lua_State * L, int idx)
-	{
-		return luax_checktype<GlyphData>(L, idx, "GlyphData", FONT_GLYPH_DATA_T);
-	}
-	
-	static const luaL_Reg functions[] = {
-		{ "getPointer", w_Data_getPointer },
-		{ "getSize", w_Data_getSize },
-		{ 0, 0 }
-	};
-
-	int luaopen_glyphdata(lua_State * L)
-	{
-		return luax_register_type(L, "GlyphData", functions);
-	}
-
-} // font
-} // love
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#include "wrap_GlyphData.h"
+
+namespace love
+{
+namespace font
+{
+	GlyphData * luax_checkglyphdata(lua_State * L, int idx)
+	{
+		return luax_checktype<GlyphData>(L, idx, "GlyphData", FONT_GLYPH_DATA_T);
+	}
+
+	static const luaL_Reg functions[] = {
+		{ "getPointer", w_Data_getPointer },
+		{ "getSize", w_Data_getSize },
+		{ 0, 0 }
+	};
+
+	int luaopen_glyphdata(lua_State * L)
+	{
+		return luax_register_type(L, "GlyphData", functions);
+	}
+
+} // font
+} // love

+ 40 - 40
src/modules/font/wrap_GlyphData.h

@@ -1,40 +1,40 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-* 
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-* 
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-* 
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#ifndef LOVE_FONT_WRAP_GLYPH_DATA_H
-#define LOVE_FONT_WRAP_GLYPH_DATA_H
-
-// LOVE
-#include <common/runtime.h>
-#include <common/wrap_Data.h>
-
-#include "GlyphData.h"
-
-namespace love
-{
-namespace font
-{
-	GlyphData * luax_checkglyphdata(lua_State * L, int idx);
-	int luaopen_glyphdata(lua_State * L);
-
-} // font
-} // love
-
-#endif // LOVE_FONT_WRAP_GLYPH_DATA_H
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#ifndef LOVE_FONT_WRAP_GLYPH_DATA_H
+#define LOVE_FONT_WRAP_GLYPH_DATA_H
+
+// LOVE
+#include <common/runtime.h>
+#include <common/wrap_Data.h>
+
+#include "GlyphData.h"
+
+namespace love
+{
+namespace font
+{
+	GlyphData * luax_checkglyphdata(lua_State * L, int idx);
+	int luaopen_glyphdata(lua_State * L);
+
+} // font
+} // love
+
+#endif // LOVE_FONT_WRAP_GLYPH_DATA_H

+ 44 - 44
src/modules/font/wrap_Rasterizer.cpp

@@ -1,44 +1,44 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-* 
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-* 
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-* 
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#include "wrap_Rasterizer.h"
-
-#include <common/wrap_Data.h>
-
-namespace love
-{
-namespace font
-{
-	Rasterizer * luax_checkrasterizer(lua_State * L, int idx)
-	{
-		return luax_checktype<Rasterizer>(L, idx, "Rasterizer", FONT_RASTERIZER_T);
-	}
-
-	static const luaL_Reg functions[] = {
-		{ 0, 0 }
-	};
-
-	int luaopen_rasterizer(lua_State * L)
-	{
-		return luax_register_type(L, "Rasterizer", functions);
-	}
-
-} // font
-} // love
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#include "wrap_Rasterizer.h"
+
+#include <common/wrap_Data.h>
+
+namespace love
+{
+namespace font
+{
+	Rasterizer * luax_checkrasterizer(lua_State * L, int idx)
+	{
+		return luax_checktype<Rasterizer>(L, idx, "Rasterizer", FONT_RASTERIZER_T);
+	}
+
+	static const luaL_Reg functions[] = {
+		{ 0, 0 }
+	};
+
+	int luaopen_rasterizer(lua_State * L)
+	{
+		return luax_register_type(L, "Rasterizer", functions);
+	}
+
+} // font
+} // love

+ 38 - 38
src/modules/font/wrap_Rasterizer.h

@@ -1,38 +1,38 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-* 
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-* 
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-* 
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#ifndef LOVE_FONT_WRAP_RASTERIZER_H
-#define LOVE_FONT_WRAP_RASTERIZER_H
-
-// LOVE
-#include <common/runtime.h>
-#include "Rasterizer.h"
-
-namespace love
-{
-namespace font
-{
-	Rasterizer * luax_checkrasterizer(lua_State * L, int idx);
-	int luaopen_rasterizer(lua_State * L);
-
-} // font
-} // love
-
-#endif // LOVE_FONT_WRAP_RASTERIZER_H
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#ifndef LOVE_FONT_WRAP_RASTERIZER_H
+#define LOVE_FONT_WRAP_RASTERIZER_H
+
+// LOVE
+#include <common/runtime.h>
+#include "Rasterizer.h"
+
+namespace love
+{
+namespace font
+{
+	Rasterizer * luax_checkrasterizer(lua_State * L, int idx);
+	int luaopen_rasterizer(lua_State * L);
+
+} // font
+} // love
+
+#endif // LOVE_FONT_WRAP_RASTERIZER_H

+ 33 - 33
src/modules/graphics/DrawQable.cpp

@@ -1,33 +1,33 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-* 
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-* 
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-* 
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#include "DrawQable.h"
-
-namespace love
-{
-namespace graphics
-{
-
-	DrawQable::~DrawQable()
-	{
-	}
-	
-} // graphics
-} // love
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#include "DrawQable.h"
+
+namespace love
+{
+namespace graphics
+{
+
+	DrawQable::~DrawQable()
+	{
+	}
+
+} // graphics
+} // love

+ 4 - 4
src/modules/graphics/DrawQable.h

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -43,7 +43,7 @@ namespace graphics
 
 		/**
 		* Draws the object with the specified transformation.
-		* 
+		*
 		* @param quad The Quad to use to draw the object.
 		* @param x The position of the object along the x-axis.
 		* @param y The position of the object along the y-axis.

+ 33 - 33
src/modules/graphics/Drawable.cpp

@@ -1,33 +1,33 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-* 
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-* 
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-* 
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#include "Drawable.h"
-
-namespace love
-{
-namespace graphics
-{
-
-	Drawable::~Drawable()
-	{
-	}
-
-} // graphics
-} // love
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#include "Drawable.h"
+
+namespace love
+{
+namespace graphics
+{
+
+	Drawable::~Drawable()
+	{
+	}
+
+} // graphics
+} // love

+ 4 - 4
src/modules/graphics/Drawable.h

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -43,7 +43,7 @@ namespace graphics
 
 		/**
 		* Draws the object with the specified transformation.
-		* 
+		*
 		* @param x The position of the object along the x-axis.
 		* @param y The position of the object along the y-axis.
 		* @param angle The angle of the object (in radians).

+ 14 - 14
src/modules/graphics/Image.cpp

@@ -1,14 +1,14 @@
 /**
  * Copyright (c) 2006-2011 LOVE Development Team
- * 
+ *
  * This software is provided 'as-is', without any express or implied
  * warranty.  In no event will the authors be held liable for any damages
  * arising from the use of this software.
- * 
+ *
  * Permission is granted to anyone to use this software for any purpose,
  * including commercial applications, and to alter it and redistribute it
  * freely, subject to the following restrictions:
- * 
+ *
  * 1. The origin of this software must not be misrepresented; you must not
  *    claim that you wrote the original software. If you use this software
  *    in a product, an acknowledgment in the product documentation would be
@@ -35,43 +35,43 @@ namespace graphics
 	Image::~Image()
 	{
 	}
-	
+
 	bool Image::getConstant(const char * in, FilterMode & out)
 	{
 		return filterModes.find(in, out);
 	}
-	
+
 	bool Image::getConstant(FilterMode in, const char *& out)
 	{
 		return filterModes.find(in, out);
 	}
-	
+
 	bool Image::getConstant(const char * in, WrapMode & out)
 	{
 		return wrapModes.find(in, out);
 	}
-	
+
 	bool Image::getConstant(WrapMode in, const char *& out)
 	{
 		return wrapModes.find(in, out);
 	}
-	
-	StringMap<Image::FilterMode, Image::FILTER_MAX_ENUM>::Entry Image::filterModeEntries[] = 
+
+	StringMap<Image::FilterMode, Image::FILTER_MAX_ENUM>::Entry Image::filterModeEntries[] =
 	{
 		{ "linear", Image::FILTER_LINEAR },
 		{ "nearest", Image::FILTER_NEAREST },
 	};
-	
+
 	StringMap<Image::FilterMode, Image::FILTER_MAX_ENUM> Image::filterModes(Image::filterModeEntries, sizeof(Image::filterModeEntries));
 
-	StringMap<Image::WrapMode, Image::WRAP_MAX_ENUM>::Entry Image::wrapModeEntries[] = 
+	StringMap<Image::WrapMode, Image::WRAP_MAX_ENUM>::Entry Image::wrapModeEntries[] =
 	{
 		{ "clamp", Image::WRAP_CLAMP },
 		{ "repeat", Image::WRAP_REPEAT },
 	};
-	
+
 	StringMap<Image::WrapMode, Image::WRAP_MAX_ENUM> Image::wrapModes(Image::wrapModeEntries, sizeof(Image::wrapModeEntries));
-	
-	
+
+
 } // graphics
 } // love

+ 10 - 10
src/modules/graphics/Image.h

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -30,14 +30,14 @@ namespace love
 {
 namespace graphics
 {
-	
+
 	class Image : public DrawQable, public Volatile
 	{
 	public:
-	
+
 		enum WrapMode
 		{
-			WRAP_CLAMP = 1, 
+			WRAP_CLAMP = 1,
 			WRAP_REPEAT,
 			WRAP_MAX_ENUM
 		};
@@ -64,21 +64,21 @@ namespace graphics
 		};
 
 		virtual ~Image();
-		
+
 		static bool getConstant(const char * in, FilterMode & out);
 		static bool getConstant(FilterMode in, const char *& out);
 		static bool getConstant(const char * in, WrapMode & out);
 		static bool getConstant(WrapMode in, const char *& out);
-		
+
 	private:
-		
+
 		static StringMap<FilterMode, FILTER_MAX_ENUM>::Entry filterModeEntries[];
 		static StringMap<FilterMode, FILTER_MAX_ENUM> filterModes;
 		static StringMap<WrapMode, WRAP_MAX_ENUM>::Entry wrapModeEntries[];
 		static StringMap<WrapMode, WRAP_MAX_ENUM> wrapModes;
 
 	}; // Image
-	
+
 } // graphics
 } // love
 

+ 36 - 36
src/modules/graphics/Quad.cpp

@@ -1,36 +1,36 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-* 
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-* 
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-* 
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#include "Quad.h"
-
-namespace love
-{
-namespace graphics
-{
-	Quad::Quad()
-	{
-	}
-
-	Quad::~Quad()
-	{
-	}
-
-} // graphics
-} // love
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#include "Quad.h"
+
+namespace love
+{
+namespace graphics
+{
+	Quad::Quad()
+	{
+	}
+
+	Quad::~Quad()
+	{
+	}
+
+} // graphics
+} // love

+ 3 - 3
src/modules/graphics/Quad.h

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be

+ 6 - 6
src/modules/graphics/Volatile.cpp

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -37,7 +37,7 @@ namespace graphics
 	Volatile::~Volatile()
 	{
 		// Remove the pointer to this object.
-		all.remove(this);		
+		all.remove(this);
 	}
 
 	bool Volatile::loadAll()
@@ -45,7 +45,7 @@ namespace graphics
 		bool success = true;
 		std::list<Volatile *>::iterator i = all.begin();
 
-		while( i != all.end() )
+		while ( i != all.end() )
 		{
 			success = success && (*i)->loadVolatile();
 			i++;
@@ -58,7 +58,7 @@ namespace graphics
 	{
 		std::list<Volatile *>::iterator i = all.begin();
 
-		while( i != all.end() )
+		while ( i != all.end() )
 		{
 			(*i)->unloadVolatile();
 			i++;

+ 6 - 6
src/modules/graphics/Volatile.h

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -59,7 +59,7 @@ namespace graphics
 		/**
 		* Loads the part(s) of the object which is destroyed when
 		* the display mode is changed.
-		* 
+		*
 		* @return True if successful, false on errors.
 		**/
 		virtual bool loadVolatile() = 0;
@@ -70,11 +70,11 @@ namespace graphics
 		**/
 		virtual void unloadVolatile() = 0;
 
-	// Static: 
+	// Static:
 
 		/**
 		* Calls \c loadVolatile() on each element in the list of volatiles.
-		* 
+		*
 		* @return True if all elements succeeded, false if one or more failed.
 		**/
 		static bool loadAll();

+ 20 - 19
src/modules/graphics/opengl/Canvas.cpp

@@ -29,8 +29,8 @@ namespace love
 namespace graphics
 {
 namespace opengl
-{	
-		
+{
+
 	// strategy for fbo creation, interchangable at runtime:
 	// none, opengl >= 3.0, extensions
 	struct FramebufferStrategy {
@@ -159,20 +159,21 @@ namespace opengl
 			glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer);
 		}
 	};
-	
+
 	FramebufferStrategy* strategy = NULL;
-	
+
 	FramebufferStrategy strategyNone;
-	
+
 	FramebufferStrategyGL3 strategyGL3;
-	
+
 	FramebufferStrategyEXT strategyEXT;
-	
+
 	Canvas* Canvas::current = NULL;
 
 	static void loadStrategy()
 	{
-		if (!strategy) {
+		if (!strategy)
+		{
 			if (GLEE_VERSION_3_0 || GLEE_ARB_framebuffer_object)
 				strategy = &strategyGL3;
 			else if (GLEE_EXT_framebuffer_object && GLEE_EXT_packed_depth_stencil)
@@ -240,15 +241,15 @@ namespace opengl
 		glPushAttrib(GL_VIEWPORT_BIT | GL_TRANSFORM_BIT);
 		strategy->bindFBO(fbo);
 		glViewport(0, 0, width, height);
-		
+
 		// Reset the projection matrix
 		glMatrixMode(GL_PROJECTION);
 		glPushMatrix();
 		glLoadIdentity();
-		
+
 		// Set up orthographic view (no depth)
 		glOrtho(0.0, width, height, 0.0, -1.0, 1.0);
-		
+
 		// Switch back to modelview matrix
 		glMatrixMode(GL_MODELVIEW);
 
@@ -293,7 +294,7 @@ namespace opengl
 
 		drawv(t, vertices);
 	}
-	
+
 	void Canvas::drawq(love::graphics::Quad * quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const
 	{
 		static Matrix t;
@@ -326,7 +327,7 @@ namespace opengl
 			memcpy(dst -= row, src += row, row);
 
 		love::image::ImageData* img = image->newImageData(width, height, (void*)screenshot);
-		
+
 		delete[] screenshot;
 		delete[] pixels;
 
@@ -395,7 +396,7 @@ namespace opengl
 		clear(c);
 		return true;
 	}
-	
+
 	void Canvas::unloadVolatile()
 	{
 		settings.filter = getFilter();
@@ -412,15 +413,15 @@ namespace opengl
 	{
 		return height;
 	}
-	
+
 	void Canvas::drawv(const Matrix & t, const vertex * v) const
 	{
 		glPushMatrix();
-		
+
 		glMultMatrixf((const GLfloat*)t.getElements());
-		
+
 		glBindTexture(GL_TEXTURE_2D, img);
-		
+
 		glEnableClientState(GL_VERTEX_ARRAY);
 		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
 		glVertexPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid*)&v[0].x);
@@ -428,7 +429,7 @@ namespace opengl
 		glDrawArrays(GL_QUADS, 0, 4);
 		glDisableClientState(GL_TEXTURE_COORD_ARRAY);
 		glDisableClientState(GL_VERTEX_ARRAY);
-		
+
 		glPopMatrix();
 	}
 

+ 2 - 2
src/modules/graphics/opengl/Canvas.h

@@ -61,7 +61,7 @@ namespace opengl
 		* @copydoc DrawQable::drawq()
 		**/
 		void drawq(love::graphics::Quad * quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const;
-		
+
 		love::image::ImageData * getImageData(love::image::Image * image);
 
 		void setFilter(const Image::Filter &f);
@@ -94,7 +94,7 @@ namespace opengl
 			Image::Filter filter;
 			Image::Wrap wrap;
 		} settings;
-		
+
 		void drawv(const Matrix & t, const vertex * v) const;
 	};
 

+ 42 - 31
src/modules/graphics/opengl/Font.cpp

@@ -54,7 +54,7 @@ namespace opengl
 		rasterizer->release();
 		unloadVolatile();
 	}
-	
+
 	void Font::createTexture()
 	{
 		texture_x = texture_y = rowHeight = 0;
@@ -62,7 +62,7 @@ namespace opengl
 		glGenTextures(1, &t);
 		textures.push_back(t);
 		glBindTexture(GL_TEXTURE_2D, t);
-		
+
 		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
 						(filter.mag == Image::FILTER_LINEAR) ? GL_LINEAR : GL_NEAREST);
 		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
@@ -70,22 +70,23 @@ namespace opengl
 		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
 		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
 		GLint format = (type == FONT_TRUETYPE ? GL_LUMINANCE_ALPHA : GL_RGBA);
-		glTexImage2D(GL_TEXTURE_2D, 
-					 0, 
-					 GL_RGBA, 
-					 (GLsizei)TEXTURE_WIDTH, 
-					 (GLsizei)TEXTURE_HEIGHT, 
-					 0, 
-					 format, 
-					 GL_UNSIGNED_BYTE, 
+		glTexImage2D(GL_TEXTURE_2D,
+					 0,
+					 GL_RGBA,
+					 (GLsizei)TEXTURE_WIDTH,
+					 (GLsizei)TEXTURE_HEIGHT,
+					 0,
+					 format,
+					 GL_UNSIGNED_BYTE,
 					 NULL);
 	}
-	
+
 	Font::Glyph * Font::addGlyph(int glyph)
 	{
 		Glyph * g = new Glyph;
 		g->list = glGenLists(1);
-		if (g->list == 0) { // opengl failed to generate the list
+		if (g->list == 0)
+		{ // opengl failed to generate the list
 			delete g;
 			return NULL;
 		}
@@ -93,18 +94,20 @@ namespace opengl
 		g->spacing = gd->getAdvance();
 		int w = gd->getWidth();
 		int h = gd->getHeight();
-		if (texture_x + w > TEXTURE_WIDTH) { // out of space - new row!
+		if (texture_x + w > TEXTURE_WIDTH)
+		{ // out of space - new row!
 			texture_x = 0;
 			texture_y += rowHeight;
 			rowHeight = 0;
 		}
-		if (texture_y + h > TEXTURE_HEIGHT) { // totally out of space - new texture!
+		if (texture_y + h > TEXTURE_HEIGHT)
+		{ // totally out of space - new texture!
 			createTexture();
 		}
 		GLuint t = textures.back();
 		glBindTexture(GL_TEXTURE_2D, t);
 		glTexSubImage2D(GL_TEXTURE_2D, 0, texture_x, texture_y, w, h, (type == FONT_TRUETYPE ? GL_LUMINANCE_ALPHA : GL_RGBA), GL_UNSIGNED_BYTE, gd->getData());
-		
+
 		Quad::Viewport v;
 		v.x = (float) texture_x;
 		v.y = (float) texture_y;
@@ -112,12 +115,12 @@ namespace opengl
 		v.h = (float) h;
 		Quad * q = new Quad(v, (const float) TEXTURE_WIDTH, (const float) TEXTURE_HEIGHT);
 		const vertex * verts = q->getVertices();
-		
+
 		glEnableClientState(GL_VERTEX_ARRAY);
 		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
 		glVertexPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid *)&verts[0].x);
 		glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid *)&verts[0].s);
-		
+
 		glNewList(g->list, GL_COMPILE);
 		glBindTexture(GL_TEXTURE_2D, t);
 		glPushMatrix();
@@ -125,16 +128,16 @@ namespace opengl
 		glDrawArrays(GL_QUADS, 0, 4);
 		glPopMatrix();
 		glEndList();
-		
+
 		glDisableClientState(GL_TEXTURE_COORD_ARRAY);
 		glDisableClientState(GL_VERTEX_ARRAY);
-		
+
 		delete q;
 		delete gd;
-		
+
 		texture_x += w;
 		rowHeight = std::max(rowHeight, h);
-		
+
 		glyphs[glyph] = g;
 		return g;
 	}
@@ -156,9 +159,11 @@ namespace opengl
 		{
 			utf8::iterator<std::string::iterator> i (text.begin(), text.begin(), text.end());
 			utf8::iterator<std::string::iterator> end (text.end(), text.begin(), text.end());
-			while (i != end) {
+			while (i != end)
+			{
 				int g = *i++;
-				if (g == '\n') { // wrap newline, but do not print it
+				if (g == '\n')
+				{ // wrap newline, but do not print it
 					glTranslatef(-dx, floor(getHeight() * getLineHeight() + 0.5f), 0);
 					dx = 0.0f;
 					continue;
@@ -194,16 +199,17 @@ namespace opengl
 
 	int Font::getWidth(const std::string & line)
 	{
-		if(line.size() == 0) return 0;
+		if (line.size() == 0) return 0;
 		int temp = 0;
-		
+
 		Glyph * g;
 
 		try
 		{
 			utf8::iterator<std::string::const_iterator> i (line.begin(), line.begin(), line.end());
 			utf8::iterator<std::string::const_iterator> end (line.end(), line.begin(), line.end());
-			while (i != end) {
+			while (i != end)
+			{
 				int c = *i++;
 				g = glyphs[c];
 				if (!g) g = addGlyph(c);
@@ -240,7 +246,8 @@ namespace opengl
 		//split text at newlines
 		istringstream iss( text );
 		string line;
-		while (getline(iss, line, '\n')) {
+		while (getline(iss, line, '\n'))
+		{
 			// split line into words
 			vector<string> words;
 			istringstream word_iss(line);
@@ -252,12 +259,14 @@ namespace opengl
 			float oldwidth = 0.0f;
 			ostringstream string_builder;
 			vector<string>::const_iterator word_iter;
-			for (word_iter = words.begin(); word_iter != words.end(); ++word_iter) {
+			for (word_iter = words.begin(); word_iter != words.end(); ++word_iter)
+			{
 				string word( *word_iter );
 				width += getWidth( word );
 
 				// on wordwrap, push line to line buffer and clear string builder
-				if (width >= wrap && oldwidth > 0) {
+				if (width >= wrap && oldwidth > 0)
+				{
 					int realw = width;
 					lines_to_draw.push_back( string_builder.str() );
 					string_builder.str( "" );
@@ -313,14 +322,16 @@ namespace opengl
 		// nuke everything from orbit
 		std::map<int, Glyph *>::iterator it = glyphs.begin();
 		Glyph * g;
-		while (it != glyphs.end()) {
+		while (it != glyphs.end())
+		{
 			g = it->second;
 			glDeleteLists(g->list, 1);
 			delete g;
 			glyphs.erase(it++);
 		}
 		std::vector<GLuint>::iterator iter = textures.begin();
-		while (iter != textures.end()) {
+		while (iter != textures.end())
+		{
 			glDeleteTextures(1, (GLuint*)&*iter);
 			iter++;
 		}

+ 8 - 8
src/modules/graphics/opengl/Font.h

@@ -42,20 +42,20 @@ namespace opengl
 	class Font : public Object, public Volatile
 	{
 	private:
-		
+
 		enum FontType
 		{
 			FONT_TRUETYPE = 1,
 			FONT_IMAGE,
 			FONT_UNKNOWN
 		};
-		
+
 		struct Glyph
 		{
 			GLuint list;
 			int spacing;
 		};
-		
+
 		love::font::Rasterizer * rasterizer;
 
 		int height;
@@ -65,13 +65,13 @@ namespace opengl
 		std::map<int, Glyph *> glyphs; // maps glyphs to display lists
 		FontType type;
 		Image::Filter filter;
-		
+
 		static const int TEXTURE_WIDTH = 512;
 		static const int TEXTURE_HEIGHT = 512;
-		
+
 		int texture_x, texture_y;
 		int rowHeight;
-		
+
 		void createTexture();
 		Glyph * addGlyph(int glyph);
 
@@ -166,10 +166,10 @@ namespace opengl
 		* Returns the spacing modifier.
 		**/
 		float getSpacing() const;
-		
+
 		// Implements Volatile.
 		bool loadVolatile();
-		void unloadVolatile();	
+		void unloadVolatile();
 
 	}; // Font
 

+ 70 - 48
src/modules/graphics/opengl/Graphics.cpp

@@ -48,13 +48,13 @@ namespace opengl
 		// Window should be centered.
 		SDL_putenv(const_cast<char *>("SDL_VIDEO_CENTERED=center"));
 
-		if(SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
+		if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
 			throw Exception(SDL_GetError());
 	}
 
 	Graphics::~Graphics()
 	{
-		if(currentFont != 0)
+		if (currentFont != 0)
 			currentFont->release();
 
 		SDL_QuitSubSystem(SDL_INIT_VIDEO);
@@ -156,7 +156,7 @@ namespace opengl
 		//    love.mouse.getX() < 800 when switching from 800x600 to a
 		//    higher resolution)
 		SDL_QuitSubSystem(SDL_INIT_VIDEO);
-		if(SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
+		if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
 		{
 			std::cout << "Could not init SDL_VIDEO: " << SDL_GetError() << std::endl;
 			return false;
@@ -173,7 +173,7 @@ namespace opengl
 		SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1);
 
 		// FSAA
-		if(fsaa > 0)
+		if (fsaa > 0)
 		{
 			SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 ) ;
 			SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, fsaa ) ;
@@ -183,14 +183,14 @@ namespace opengl
 		// Fullscreen?
 		Uint32 sdlflags = fullscreen ? (SDL_OPENGL | SDL_FULLSCREEN) : SDL_OPENGL;
 
-		if(!isCreated())
+		if (!isCreated())
 			setCaption("");
 
 		// Have SDL set the video mode.
-		if(SDL_SetVideoMode(width, height, 32, sdlflags ) == 0)
+		if (SDL_SetVideoMode(width, height, 32, sdlflags ) == 0)
 		{
 			bool failed = true;
-			if(fsaa > 0)
+			if (fsaa > 0)
 			{
 				// FSAA might have failed, disable it and try again
 				SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
@@ -202,7 +202,7 @@ namespace opengl
 					failed = SDL_SetVideoMode(width, height, 32, sdlflags ) == 0;
 				}
 			}
-			if(failed)
+			if (failed)
 			{
 				std::cerr << "Could not set video mode: "  << SDL_GetError() << std::endl;
 				return false;
@@ -258,7 +258,7 @@ namespace opengl
 		// Reset modelview matrix
 		glMatrixMode(GL_MODELVIEW);
 		glLoadIdentity();
-		
+
 		// Set pixel row alignment
 		glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
 
@@ -275,12 +275,12 @@ namespace opengl
 		currentMode.vsync = (real_vsync != 0);
 
 		// Reload all volatile objects.
-		if(!Volatile::loadAll())
+		if (!Volatile::loadAll())
 			std::cerr << "Could not reload all volatile objects." << std::endl;
 
 		// Restore the display state.
 		restoreState(tempState);
-		
+
 		// Get the maximum number of matrices
 		// subtract a few to give the engine some room.
 		glGetIntegerv(GL_MAX_MODELVIEW_STACK_DEPTH, &matrixLimit);
@@ -392,14 +392,14 @@ namespace opengl
 	{
 		SDL_Rect ** modes = SDL_ListModes(0, SDL_OPENGL | SDL_FULLSCREEN);
 
-		if(modes == (SDL_Rect **)0 || modes == (SDL_Rect **)-1)
+		if (modes == (SDL_Rect **)0 || modes == (SDL_Rect **)-1)
 			return 0;
 
 		int index = 1;
 
 		lua_newtable(L);
 
-		for(int i=0;modes[i];++i)
+		for (int i=0;modes[i];++i)
 		{
 			lua_pushinteger(L, index);
 			lua_newtable(L);
@@ -437,7 +437,7 @@ namespace opengl
 
 	int Graphics::getScissor(lua_State * L)
 	{
-		if(glIsEnabled(GL_SCISSOR_TEST) == GL_FALSE)
+		if (glIsEnabled(GL_SCISSOR_TEST) == GL_FALSE)
 			return 0;
 
 		GLint scissor[4];
@@ -478,13 +478,17 @@ namespace opengl
 		// Create the image.
 		Image * image = new Image(data);
 		bool success;
-		try {
+		try
+		{
 			success = image->load();
-		} catch (love::Exception & e) {
+		}
+		catch (love::Exception & e)
+		{
 			image->release();
 			throw love::Exception(e.what());
 		}
-		if (!success) {
+		if (!success)
+		{
 			image->release();
 			return 0;
 		}
@@ -509,7 +513,7 @@ namespace opengl
 		Font * font = new Font(r, filter);
 
 		// Load it and check for errors.
-		if(!font)
+		if (!font)
 		{
 			delete font;
 			return 0;
@@ -521,9 +525,12 @@ namespace opengl
 	SpriteBatch * Graphics::newSpriteBatch(Image * image, int size, int usage)
 	{
 		SpriteBatch * t = NULL;
-		try {
+		try
+		{
 			t = new SpriteBatch(image, size, usage);
-		} catch (love::Exception& e) {
+		}
+		catch (love::Exception& e)
+		{
 			if (t) delete t;
 			throw e;
 		}
@@ -584,9 +591,12 @@ namespace opengl
 	PixelEffect * Graphics::newPixelEffect(const std::string& code)
 	{
 		PixelEffect * effect = NULL;
-		try {
+		try
+		{
 			effect = new PixelEffect(code);
-		} catch (love::Exception& e) {
+		}
+		catch (love::Exception& e)
+		{
 			if (effect)
 				delete effect;
 			throw(e);
@@ -634,12 +644,12 @@ namespace opengl
 
 	void Graphics::setFont( Font * font )
 	{
-		if(currentFont != 0)
+		if (currentFont != 0)
 			currentFont->release();
 
 		currentFont = font;
 
-		if(font != 0)
+		if (font != 0)
 			currentFont->retain();
 	}
 
@@ -669,7 +679,7 @@ namespace opengl
 
 	void Graphics::setColorMode ( Graphics::ColorMode mode )
 	{
-		if(mode == COLOR_MODULATE)
+		if (mode == COLOR_MODULATE)
 			glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
 		else // mode = COLOR_REPLACE
 			glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
@@ -689,7 +699,7 @@ namespace opengl
 
 		if (equation == GL_FUNC_REVERSE_SUBTRACT) // && src == GL_SRC_ALPHA && dst == GL_ONE
 			return BLEND_SUBTRACTIVE;
-		else if(src == GL_SRC_ALPHA && dst == GL_ONE) // && equation == GL_FUNC_ADD
+		else if (src == GL_SRC_ALPHA && dst == GL_ONE) // && equation == GL_FUNC_ADD
 			return BLEND_ADDITIVE;
 		else if (src == GL_SRC_ALPHA && dst == GL_ONE_MINUS_SRC_ALPHA) // && equation == GL_FUNC_ADD
 			return BLEND_ALPHA;
@@ -697,7 +707,7 @@ namespace opengl
 			return BLEND_MULTIPLICATIVE;
 		else if (src == GL_ONE && dst == GL_ONE_MINUS_SRC_ALPHA) // && equation == GL_FUNC_ADD
 			return BLEND_PREMULTIPLIED;
-			
+
 		return BLEND_MAX_ENUM; // Should never be reached.
 	}
 
@@ -706,7 +716,7 @@ namespace opengl
 		GLint mode;
 		glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &mode);
 
-		if(mode == GL_MODULATE)
+		if (mode == GL_MODULATE)
 			return COLOR_MODULATE;
 		else // // mode == GL_REPLACE
 			return COLOR_REPLACE;
@@ -727,7 +737,7 @@ namespace opengl
 		//// XXX: actually enables antialiasing for _all_ polygons.
 		//// may need investigation if wanted or not
 		//// maybe rename to something else?
-		//if(style == LINE_ROUGH)
+		//if (style == LINE_ROUGH)
 		//	glDisable (GL_POLYGON_SMOOTH);
 		//else // type == LINE_SMOOTH
 		//{
@@ -741,7 +751,7 @@ namespace opengl
 	{
 		setLineWidth(width);
 
-		if(style == 0)
+		if (style == 0)
 			return;
 		setLineStyle(style);
 	}
@@ -755,7 +765,7 @@ namespace opengl
 
 	Graphics::LineStyle Graphics::getLineStyle()
 	{
-		//if(glIsEnabled(GL_POLYGON_SMOOTH) == GL_TRUE)
+		//if (glIsEnabled(GL_POLYGON_SMOOTH) == GL_TRUE)
 		//	return LINE_SMOOTH;
 		//else
 			return LINE_ROUGH;
@@ -768,7 +778,7 @@ namespace opengl
 
 	void Graphics::setPointStyle( Graphics::PointStyle style )
 	{
-		if( style == POINT_SMOOTH )
+		if ( style == POINT_SMOOTH )
 			glEnable(GL_POINT_SMOOTH);
 		else // love::POINT_ROUGH
 			glDisable(GL_POINT_SMOOTH);
@@ -776,7 +786,7 @@ namespace opengl
 
 	void Graphics::setPoint( float size, Graphics::PointStyle style )
 	{
-		if( style == POINT_SMOOTH )
+		if ( style == POINT_SMOOTH )
 			glEnable(GL_POINT_SMOOTH);
 		else // POINT_ROUGH
 			glDisable(GL_POINT_SMOOTH);
@@ -793,7 +803,7 @@ namespace opengl
 
 	Graphics::PointStyle Graphics::getPointStyle()
 	{
-		if(glIsEnabled(GL_POINT_SMOOTH) == GL_TRUE)
+		if (glIsEnabled(GL_POINT_SMOOTH) == GL_TRUE)
 			return POINT_SMOOTH;
 		else
 			return POINT_ROUGH;
@@ -808,7 +818,7 @@ namespace opengl
 
 	void Graphics::print( const char * str, float x, float y , float angle, float sx, float sy, float ox, float oy, float kx, float ky)
 	{
-		if(currentFont != 0)
+		if (currentFont != 0)
 		{
 			std::string text(str);
 			currentFont->print(text, x, y, angle, sx, sy, ox, oy, kx, ky);
@@ -826,7 +836,8 @@ namespace opengl
 
 		// now for the actual printing
 		vector<string>::const_iterator line_iter, line_end = lines_to_draw.end();
-		for (line_iter = lines_to_draw.begin(); line_iter != line_end; ++line_iter) {
+		for (line_iter = lines_to_draw.begin(); line_iter != line_end; ++line_iter)
+		{
 			float width = static_cast<float>(currentFont->getWidth( *line_iter ));
 			switch (align) {
 				case ALIGN_RIGHT:
@@ -875,7 +886,8 @@ namespace opengl
 		d2 *= halfwidth;
 
 		// lines parallel -> assume intersection at displacement points
-		if (fabs(det_norm) <= .03) {
+		if (fabs(det_norm) <= .03)
+		{
 			vertices[pos]     = q - d2;
 			vertices[pos + 1] = q + d2;
 			return;
@@ -903,7 +915,8 @@ namespace opengl
 		if (looping) q = Vector(coords[count-4], coords[count-3]);
 		else         q = r * 2 - Vector(coords[2], coords[3]);
 
-		for (size_t i = 0; i+3 < count; i += 2) {
+		for (size_t i = 0; i+3 < count; i += 2)
+		{
 			p = q;
 			q = r;
 			r = Vector(coords[i+2], coords[i+3]);
@@ -946,12 +959,13 @@ namespace opengl
 	void Graphics::circle(DrawMode mode, float x, float y, float radius, int points)
 	{
 		float two_pi = static_cast<float>(LOVE_M_PI * 2);
-		if(points <= 0) points = 1;
+		if (points <= 0) points = 1;
 		float angle_shift = (two_pi / points);
 		float phi = .0f;
 
 		float *coords = new float[2 * (points + 1)];
-		for (int i = 0; i < points; ++i, phi += angle_shift) {
+		for (int i = 0; i < points; ++i, phi += angle_shift)
+		{
 			coords[2*i]   = x + radius * cos(phi);
 			coords[2*i+1] = y + radius * sin(phi);
 		}
@@ -963,7 +977,7 @@ namespace opengl
 
 		delete[] coords;
 	}
-	
+
 	void Graphics::arc(DrawMode mode, float x, float y, float radius, float angle1, float angle2, int points)
 	{
 		angle1 = fmod(angle1, 2.0f * (float)LOVE_M_PI);
@@ -974,23 +988,27 @@ namespace opengl
 			angle2 += (float)LOVE_M_PI * 2.0f;
 
 
-		if(points <= 0) points = 1;
+		if (points <= 0) points = 1;
 		float angle_shift = ((angle2 - angle1) / points);
 		float phi = angle1;
 
 		// GL_POLYGON can only fill-draw convex polygons, so we need to do stuff manually here
-		if (mode == DRAW_LINE) {
+		if (mode == DRAW_LINE)
+		{
 			float *coords = new float[(points + 3) * 2];
 			coords[0] = coords[2 * points + 4] = x;
 			coords[1] = coords[2 * points + 5] = y;
-			for (int i = 0; i <= points; ++i, phi += angle_shift) {
+			for (int i = 0; i <= points; ++i, phi += angle_shift)
+			{
 				coords[2 * (i+1)]     = x + radius * cos(phi);
 				coords[2 * (i+1) + 1] = y - radius * sin(phi);
 			}
 			polyline(coords, (points + 3) * 2); // artifacts at sharp angles if set to looping
 
 			delete[] coords;
-		} else {
+		}
+		else
+		{
 			glDisable(GL_TEXTURE_2D);
 			glBegin(GL_TRIANGLE_FAN);
 			glVertex2f(x, y);
@@ -1009,9 +1027,12 @@ namespace opengl
 	{
 		// coords is an array of a closed loop of vertices, i.e.
 		// coords[count-2] = coords[0], coords[count-1] = coords[1]
-		if (mode == DRAW_LINE) {
+		if (mode == DRAW_LINE)
+		{
 			polyline(coords, count, true);
-		} else {
+		}
+		else
+		{
 			glDisable(GL_TEXTURE_2D);
 			glEnableClientState(GL_VERTEX_ARRAY);
 			glVertexPointer(2, GL_FLOAT, 0, (const GLvoid*)coords);
@@ -1039,7 +1060,8 @@ namespace opengl
 
 		GLubyte *src = pixels - row, *dst = screenshot + size;
 
-		for (int i = 0; i < h; ++i) {
+		for (int i = 0; i < h; ++i)
+		{
 			memcpy(dst-=row, src+=row, row);
 		}
 

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

@@ -498,7 +498,7 @@ namespace opengl
 		* @param points Number of points to use to draw the circle.
 		**/
 		void circle(DrawMode mode, float x, float y, float radius, int points = 10);
-		
+
 		/**
 		* Draws an arc using the specified arguments.
 		* @param mode The mode of drawing (line/filled).

+ 7 - 7
src/modules/graphics/opengl/Image.cpp

@@ -53,7 +53,7 @@ namespace opengl
 
 	Image::~Image()
 	{
-		if(data != 0)
+		if (data != 0)
 			data->release();
 		unload();
 	}
@@ -262,7 +262,7 @@ namespace opengl
 
 	void Image::bind() const
 	{
-		if(texture != 0)
+		if (texture != 0)
 			glBindTexture(GL_TEXTURE_2D,texture);
 	}
 
@@ -293,12 +293,12 @@ namespace opengl
 
 		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
 		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-		
+
 		float p2width = next_p2(width);
 		float p2height = next_p2(height);
 		float s = width/p2width;
 		float t = height/p2height;
-		
+
 		vertices[1].t = t;
 		vertices[2].t = t;
 		vertices[2].s = s;
@@ -313,7 +313,7 @@ namespace opengl
 			GL_RGBA,
 			GL_UNSIGNED_BYTE,
 			0);
-			
+
 		glTexSubImage2D(GL_TEXTURE_2D,
 			0,
 			0,
@@ -339,7 +339,7 @@ namespace opengl
 
 		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
 		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-		
+
 		glTexImage2D(GL_TEXTURE_2D,
 			0,
 			GL_RGBA8,
@@ -361,7 +361,7 @@ namespace opengl
 		settings.filter = getFilter();
 		settings.wrap = getWrap();
 		// Delete the hardware texture.
-		if(texture != 0)
+		if (texture != 0)
 		{
 			glDeleteTextures(1, (GLuint*)&texture);
 			texture = 0;

+ 16 - 16
src/modules/graphics/opengl/ParticleSystem.cpp

@@ -67,22 +67,22 @@ namespace opengl
 
 	ParticleSystem::~ParticleSystem()
 	{
-		if(this->sprite != 0)
+		if (this->sprite != 0)
 			this->sprite->release();
 
-		if(pStart != 0)
+		if (pStart != 0)
 			delete [] pStart;
 	}
 
 	void ParticleSystem::add()
 	{
-		if(isFull()) return;
+		if (isFull()) return;
 
 		float min,max;
 
 		min = particleLifeMin;
 		max = particleLifeMax;
-		if(min == max)
+		if (min == max)
 			pLast->life = min;
 		else
 			pLast->life = (rand() / (float(RAND_MAX)+1)) * (max - min) + min;
@@ -132,7 +132,7 @@ namespace opengl
 
 	void ParticleSystem::remove(particle * p)
 	{
-		if(!isEmpty())
+		if (!isEmpty())
 		{
 			*p = *(--pLast);
 		}
@@ -140,7 +140,7 @@ namespace opengl
 
 	void ParticleSystem::setSprite(Image * image)
 	{
-		if(sprite != 0)
+		if (sprite != 0)
 			sprite->release();
 
 		sprite = image;
@@ -170,7 +170,7 @@ namespace opengl
 	void ParticleSystem::setParticleLife(float min, float max)
 	{
 		particleLifeMin = min;
-		if(max == 0)
+		if (max == 0)
 			particleLifeMax = min;
 		else
 			particleLifeMax = max;
@@ -387,7 +387,7 @@ namespace opengl
 
 	void ParticleSystem::draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const
 	{
-		if(sprite == 0) return; // just in case of failure
+		if (sprite == 0) return; // just in case of failure
 
 		glPushMatrix();
 		glPushAttrib(GL_CURRENT_BIT);
@@ -397,7 +397,7 @@ namespace opengl
 		glMultMatrixf((const GLfloat*)t.getElements());
 
 		particle * p = pStart;
-		while(p != pLast)
+		while (p != pLast)
 		{
 			glPushMatrix();
 
@@ -418,30 +418,30 @@ namespace opengl
 		particle * p = pStart;
 
 		// Make some more particles.
-		if(active)
+		if (active)
 		{
 			float rate = 1.0f / emissionRate; // the amount of time between each particle emit
 			emitCounter += dt;
-			while(emitCounter > rate)
+			while (emitCounter > rate)
 			{
 				add();
 				emitCounter -= rate;
 			}
 			/*int particles = (int)(emissionRate * dt);
-			for(int i = 0; i != particles; i++)
+			for (int i = 0; i != particles; i++)
 				add();*/
 
 			life -= dt;
-			if(lifetime != -1 && life < 0)
+			if (lifetime != -1 && life < 0)
 				stop();
 		}
 
-		while(p != pLast)
+		while (p != pLast)
 		{
 			// Decrease lifespan.
 			p->life -= dt;
 
-			if(p->life > 0)
+			if (p->life > 0)
 			{
 
 				// Temp variables.
@@ -509,7 +509,7 @@ namespace opengl
 			{
 				remove(p);
 
-				if(p >= pLast)
+				if (p >= pLast)
 					return;
 			} // else
 		} // while

+ 9 - 9
src/modules/graphics/opengl/ParticleSystem.h

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -143,7 +143,7 @@ namespace opengl
 		float spinStart;
 		float spinEnd;
 		float spinVariation;
-		
+
 		// Offsets
 		float offsetX;
 		float offsetY;
@@ -339,14 +339,14 @@ namespace opengl
 		* @param color The color.
 		**/
 		void setColor(const Color& color);
-		
+
 		/**
 		* Sets the particles' offsets for rotation.
 		* @param x The x offset.
 		* @param y The y offset.
 		**/
 		void setOffset(float x, float y);
-		
+
 		/**
 		* Sets the color of the particles.
 		* @param newColors Array of colors
@@ -372,17 +372,17 @@ namespace opengl
 		* Returns the directional spread of the emitter (in degrees).
 		**/
 		float getSpread() const;
-		
+
 		/**
 		* Returns the X offset of the particles.
 		**/
 		float getOffsetX() const;
-		
+
 		/**
 		* Returns the Y offset of the particles.
 		**/
 		float getOffsetY() const;
-		
+
 		/**
 		* Returns the amount of particles that are currently active in the system.
 		**/

+ 14 - 7
src/modules/graphics/opengl/PixelEffect.cpp

@@ -78,7 +78,8 @@ namespace opengl
 
 		GLuint shader = glCreateShader(GL_FRAGMENT_SHADER);
 		// should only fail if this is called between a glBegin()/glEnd() pair
-		if (shader == 0) {
+		if (shader == 0)
+		{
 			glDeleteProgram(_program);
 			throw love::Exception("Cannot create shader object.");
 		}
@@ -91,7 +92,8 @@ namespace opengl
 
 		GLint compile_ok;
 		glGetShaderiv(shader, GL_COMPILE_STATUS, &compile_ok);
-		if (GL_FALSE == compile_ok) {
+		if (GL_FALSE == compile_ok)
+		{
 			// get compiler error
 			glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &strlen);
 			char *error_str = new char[strlen];
@@ -112,7 +114,8 @@ namespace opengl
 		glAttachShader(_program, shader);
 		glLinkProgram(_program);
 		glGetProgramiv(_program, GL_LINK_STATUS, &link_ok);
-		if (GL_FALSE == link_ok) {
+		if (GL_FALSE == link_ok)
+		{
 			// this should not happen if compiling is ok, but one can never be too careful
 			// get linker error
 			std::string tmp(getWarnings());
@@ -189,7 +192,8 @@ namespace opengl
 		TemporaryAttacher attacher(this);
 		GLint location = getUniformLocation(name);
 
-		if (size < 1 || size > 4) {
+		if (size < 1 || size > 4)
+		{
 			throw love::Exception("Invalid variable size: %d (expected 1-4).", size);
 		}
 
@@ -218,7 +222,8 @@ namespace opengl
 		TemporaryAttacher attacher(this);
 		GLint location = getUniformLocation(name);
 
-		if (size < 2 || size > 4) {
+		if (size < 2 || size > 4)
+		{
 			throw love::Exception("Invalid matrix size: %dx%d "
 					"(can only set 2x2, 3x3 or 4x4 matrices).", size,size);
 		}
@@ -283,7 +288,8 @@ namespace opengl
 			return it->second;
 
 		GLint location = glGetUniformLocation(_program, name.c_str());
-		if (location == -1) {
+		if (location == -1)
+		{
 			throw love::Exception(
 					"Cannot get location of shader variable `%s'.\n"
 					"A common error is to define but not use the variable.", name.c_str());
@@ -296,7 +302,8 @@ namespace opengl
 	void PixelEffect::checkSetUniformError()
 	{
 		GLenum error_code = glGetError();
-		if (GL_INVALID_OPERATION == error_code) {
+		if (GL_INVALID_OPERATION == error_code)
+		{
 			throw love::Exception(
 				"Invalid operation:\n"
 				"- Trying to send the wrong value type to shader variable, or\n"

+ 124 - 123
src/modules/graphics/opengl/Quad.cpp

@@ -1,123 +1,124 @@
-/**
-* Copyright (c) 2006-2011 LOVE Development Team
-*
-* This software is provided 'as-is', without any express or implied
-* warranty.  In no event will the authors be held liable for any damages
-* arising from the use of this software.
-*
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-*
-* 1. The origin of this software must not be misrepresented; you must not
-*    claim that you wrote the original software. If you use this software
-*    in a product, an acknowledgment in the product documentation would be
-*    appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-*    misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-#include "Quad.h"
-#include <common/Matrix.h>
-
-// GLee
-#include "GLee.h"
-
-// STD
-#include <cstring> // For memcpy
-
-namespace love
-{
-namespace graphics
-{
-namespace opengl
-{
-	Quad::Quad(const Viewport & v, float sw, float sh)
-		: sw(sw), sh(sh)
-	{
-		memset(vertices, 255, sizeof(vertex)*NUM_VERTICES);
-		refresh(v, sw, sh);
-	}
-
-	Quad::~Quad()
-	{
-	}
-
-	void Quad::refresh(const Viewport & v, float sw, float sh)
-	{
-		if (!GLEE_ARB_texture_non_power_of_two)
-		{
-			sw = next_p2(sw);
-			sh = next_p2(sh);
-		}
-		viewport = v;
-
-		vertices[0].x = 0;
-		vertices[0].y = 0;
-		vertices[1].x = 0;
-		vertices[1].y = v.h;
-		vertices[2].x = v.w;
-		vertices[2].y = v.h;
-		vertices[3].x = v.w;
-		vertices[3].y = 0;
-
-		vertices[0].s = v.x/sw;
-		vertices[0].t = v.y/sh;
-		vertices[1].s = v.x/sw;
-		vertices[1].t = (v.y+v.h)/sh;
-		vertices[2].s = (v.x+v.w)/sw;
-		vertices[2].t = (v.y+v.h)/sh;
-		vertices[3].s = (v.x+v.w)/sw;
-		vertices[3].t = v.y/sh;
-	}
-
-	void Quad::setViewport(const Quad::Viewport & v)
-	{
-		refresh(v, sw, sh);
-	}
-
-	Quad::Viewport Quad::getViewport() const
-	{
-		return viewport;
-	}
-
-	void Quad::flip(bool x, bool y)
-	{
-		vertex temp[4];
-		if (x)
-		{
-			memcpy(temp, vertices, sizeof(vertex)*NUM_VERTICES);
-			vertices[0].s = temp[3].s; vertices[0].t = temp[3].t;
-			vertices[1].s = temp[2].s; vertices[1].t = temp[2].t;
-			vertices[2].s = temp[1].s; vertices[2].t = temp[1].t;
-			vertices[3].s = temp[0].s; vertices[3].t = temp[0].t;
-		}
-		if (y)
-		{
-			memcpy(temp, vertices, sizeof(vertex)*NUM_VERTICES);
-			vertices[0].s = temp[1].s; vertices[0].t = temp[1].t;
-			vertices[1].s = temp[0].s; vertices[1].t = temp[0].t;
-			vertices[2].s = temp[3].s; vertices[2].t = temp[3].t;
-			vertices[3].s = temp[2].s; vertices[3].t = temp[2].t;
-		}
-	}
-
-	void Quad::mirror(bool x, bool y)
-	{
-		for (size_t i = 0; i < NUM_VERTICES; ++i) {
-			if (x)
-				vertices[i].s = 1.0 - vertices[i].s;
-			if (y)
-				vertices[i].s = 1.0 - vertices[i].s;
-		}
-	}
-
-	const vertex * Quad::getVertices() const
-	{
-		return vertices;
-	}
-
-} // opengl
-} // graphics
-} // love
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#include "Quad.h"
+#include <common/Matrix.h>
+
+// GLee
+#include "GLee.h"
+
+// STD
+#include <cstring> // For memcpy
+
+namespace love
+{
+namespace graphics
+{
+namespace opengl
+{
+	Quad::Quad(const Viewport & v, float sw, float sh)
+		: sw(sw), sh(sh)
+	{
+		memset(vertices, 255, sizeof(vertex)*NUM_VERTICES);
+		refresh(v, sw, sh);
+	}
+
+	Quad::~Quad()
+	{
+	}
+
+	void Quad::refresh(const Viewport & v, float sw, float sh)
+	{
+		if (!GLEE_ARB_texture_non_power_of_two)
+		{
+			sw = next_p2(sw);
+			sh = next_p2(sh);
+		}
+		viewport = v;
+
+		vertices[0].x = 0;
+		vertices[0].y = 0;
+		vertices[1].x = 0;
+		vertices[1].y = v.h;
+		vertices[2].x = v.w;
+		vertices[2].y = v.h;
+		vertices[3].x = v.w;
+		vertices[3].y = 0;
+
+		vertices[0].s = v.x/sw;
+		vertices[0].t = v.y/sh;
+		vertices[1].s = v.x/sw;
+		vertices[1].t = (v.y+v.h)/sh;
+		vertices[2].s = (v.x+v.w)/sw;
+		vertices[2].t = (v.y+v.h)/sh;
+		vertices[3].s = (v.x+v.w)/sw;
+		vertices[3].t = v.y/sh;
+	}
+
+	void Quad::setViewport(const Quad::Viewport & v)
+	{
+		refresh(v, sw, sh);
+	}
+
+	Quad::Viewport Quad::getViewport() const
+	{
+		return viewport;
+	}
+
+	void Quad::flip(bool x, bool y)
+	{
+		vertex temp[4];
+		if (x)
+		{
+			memcpy(temp, vertices, sizeof(vertex)*NUM_VERTICES);
+			vertices[0].s = temp[3].s; vertices[0].t = temp[3].t;
+			vertices[1].s = temp[2].s; vertices[1].t = temp[2].t;
+			vertices[2].s = temp[1].s; vertices[2].t = temp[1].t;
+			vertices[3].s = temp[0].s; vertices[3].t = temp[0].t;
+		}
+		if (y)
+		{
+			memcpy(temp, vertices, sizeof(vertex)*NUM_VERTICES);
+			vertices[0].s = temp[1].s; vertices[0].t = temp[1].t;
+			vertices[1].s = temp[0].s; vertices[1].t = temp[0].t;
+			vertices[2].s = temp[3].s; vertices[2].t = temp[3].t;
+			vertices[3].s = temp[2].s; vertices[3].t = temp[2].t;
+		}
+	}
+
+	void Quad::mirror(bool x, bool y)
+	{
+		for (size_t i = 0; i < NUM_VERTICES; ++i)
+		{
+			if (x)
+				vertices[i].s = 1.0 - vertices[i].s;
+			if (y)
+				vertices[i].s = 1.0 - vertices[i].s;
+		}
+	}
+
+	const vertex * Quad::getVertices() const
+	{
+		return vertices;
+	}
+
+} // opengl
+} // graphics
+} // love

+ 7 - 7
src/modules/graphics/opengl/SpriteBatch.cpp

@@ -1,14 +1,14 @@
 /**
 * Copyright (c) 2006-2011 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
@@ -102,7 +102,7 @@ namespace opengl
 	int SpriteBatch::add(float x, float y, float a, float sx, float sy, float ox, float oy, float kx, float ky, int index /*= -1*/)
 	{
 		// Only do this if there's a free slot.
-		if((index == -1 && next >= size) || index < -1 || index >= size)
+		if ((index == -1 && next >= size) || index < -1 || index >= size)
 			return -1;
 
 		// Needed for colors.
@@ -127,7 +127,7 @@ namespace opengl
 	int SpriteBatch::addq(Quad * quad, float x, float y, float a, float sx, float sy, float ox, float oy, float kx, float ky, int index /*= -1*/)
 	{
 		// Only do this if there's a free slot.
-		if((index == -1 && next >= size) || index < -1 || index >= next)
+		if ((index == -1 && next >= size) || index < -1 || index >= next)
 			return -1;
 
 		// Needed for colors.
@@ -178,7 +178,7 @@ namespace opengl
 
 	void SpriteBatch::setColor(const Color & color)
 	{
-		if(!this->color)
+		if (!this->color)
 			this->color = new Color(color);
 		else
 			*(this->color) = color;
@@ -218,7 +218,7 @@ namespace opengl
 		glEnableClientState(GL_VERTEX_ARRAY);
 		glVertexPointer(2, GL_FLOAT, sizeof(vertex), array_buf->getPointer(vertex_offset));
 
-		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
 		glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), array_buf->getPointer(texel_offset));
 
 		glDrawElements(GL_TRIANGLES, next*6, GL_UNSIGNED_SHORT, element_buf->getPointer(0));

Some files were not shown because too many files changed in this diff