diff --git a/platform/msvc2008/common/common.vcproj b/platform/msvc2008/common/common.vcproj index ea6c39744..ad2161819 100644 --- a/platform/msvc2008/common/common.vcproj +++ b/platform/msvc2008/common/common.vcproj @@ -154,6 +154,10 @@ RelativePath="..\..\..\src\common\Data.h" > + + @@ -306,6 +310,18 @@ RelativePath="..\..\..\src\common\runtime.h" > + + + + + + diff --git a/platform/msvc2008/event/event.vcproj b/platform/msvc2008/event/event.vcproj index fafe117a4..ac7acfd4f 100644 --- a/platform/msvc2008/event/event.vcproj +++ b/platform/msvc2008/event/event.vcproj @@ -205,6 +205,26 @@ > + + + + + + + + diff --git a/platform/msvc2008/filesystem/filesystem.vcproj b/platform/msvc2008/filesystem/filesystem.vcproj index 30801e074..53954a800 100644 --- a/platform/msvc2008/filesystem/filesystem.vcproj +++ b/platform/msvc2008/filesystem/filesystem.vcproj @@ -170,7 +170,7 @@ + + diff --git a/platform/msvc2008/graphics/graphics.vcproj b/platform/msvc2008/graphics/graphics.vcproj index d2f6f3e2e..6f520194b 100644 --- a/platform/msvc2008/graphics/graphics.vcproj +++ b/platform/msvc2008/graphics/graphics.vcproj @@ -234,6 +234,7 @@ @@ -606,6 +607,10 @@ RelativePath="..\..\..\src\modules\graphics\Drawable.h" > + + diff --git a/platform/msvc2008/joystick/joystick.vcproj b/platform/msvc2008/joystick/joystick.vcproj index 078f37ab3..0b1f9cc67 100644 --- a/platform/msvc2008/joystick/joystick.vcproj +++ b/platform/msvc2008/joystick/joystick.vcproj @@ -205,6 +205,10 @@ > + + diff --git a/platform/msvc2008/keyboard/keyboard.vcproj b/platform/msvc2008/keyboard/keyboard.vcproj index 8d7531371..ef72139a5 100644 --- a/platform/msvc2008/keyboard/keyboard.vcproj +++ b/platform/msvc2008/keyboard/keyboard.vcproj @@ -205,6 +205,10 @@ > + + diff --git a/platform/msvc2008/love.sln b/platform/msvc2008/love.sln index 41e4571de..674311b5a 100644 --- a/platform/msvc2008/love.sln +++ b/platform/msvc2008/love.sln @@ -42,11 +42,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mouse", "mouse\mouse.vcproj {8273822F-45A4-4BE3-82F3-B8B3223C578C} = {8273822F-45A4-4BE3-82F3-B8B3223C578C} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "native", "native\native.vcproj", "{CCAD89EC-2C3C-4F69-BF71-D9DA230FE109}" - ProjectSection(ProjectDependencies) = postProject - {8273822F-45A4-4BE3-82F3-B8B3223C578C} = {8273822F-45A4-4BE3-82F3-B8B3223C578C} - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "physics", "physics\physics.vcproj", "{39CDF8C8-016D-423E-94BA-7DD798CF0E15}" ProjectSection(ProjectDependencies) = postProject {8273822F-45A4-4BE3-82F3-B8B3223C578C} = {8273822F-45A4-4BE3-82F3-B8B3223C578C} @@ -77,11 +72,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "font", "font\font.vcproj", EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "love", "love.vcproj", "{F2FDC53D-1ECD-4CF1-BA3F-3E59A2484DB9}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "signal", "signal\signal.vcproj", "{5A7AAEBC-F269-41DA-984A-75F975549CA5}" - ProjectSection(ProjectDependencies) = postProject - {8273822F-45A4-4BE3-82F3-B8B3223C578C} = {8273822F-45A4-4BE3-82F3-B8B3223C578C} - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lovedll", "lovedll\lovedll.vcproj", "{2863FF8A-153F-46E0-8E71-2E58F3809E9B}" ProjectSection(ProjectDependencies) = postProject {8273822F-45A4-4BE3-82F3-B8B3223C578C} = {8273822F-45A4-4BE3-82F3-B8B3223C578C} @@ -129,10 +119,6 @@ Global {88881251-6818-485E-A262-DE1283096589}.Debug|Win32.Build.0 = Debug|Win32 {88881251-6818-485E-A262-DE1283096589}.Release|Win32.ActiveCfg = Release|Win32 {88881251-6818-485E-A262-DE1283096589}.Release|Win32.Build.0 = Release|Win32 - {CCAD89EC-2C3C-4F69-BF71-D9DA230FE109}.Debug|Win32.ActiveCfg = Debug|Win32 - {CCAD89EC-2C3C-4F69-BF71-D9DA230FE109}.Debug|Win32.Build.0 = Debug|Win32 - {CCAD89EC-2C3C-4F69-BF71-D9DA230FE109}.Release|Win32.ActiveCfg = Release|Win32 - {CCAD89EC-2C3C-4F69-BF71-D9DA230FE109}.Release|Win32.Build.0 = Release|Win32 {39CDF8C8-016D-423E-94BA-7DD798CF0E15}.Debug|Win32.ActiveCfg = Debug|Win32 {39CDF8C8-016D-423E-94BA-7DD798CF0E15}.Debug|Win32.Build.0 = Debug|Win32 {39CDF8C8-016D-423E-94BA-7DD798CF0E15}.Release|Win32.ActiveCfg = Release|Win32 @@ -157,10 +143,6 @@ Global {F2FDC53D-1ECD-4CF1-BA3F-3E59A2484DB9}.Debug|Win32.Build.0 = Debug|Win32 {F2FDC53D-1ECD-4CF1-BA3F-3E59A2484DB9}.Release|Win32.ActiveCfg = Release|Win32 {F2FDC53D-1ECD-4CF1-BA3F-3E59A2484DB9}.Release|Win32.Build.0 = Release|Win32 - {5A7AAEBC-F269-41DA-984A-75F975549CA5}.Debug|Win32.ActiveCfg = Debug|Win32 - {5A7AAEBC-F269-41DA-984A-75F975549CA5}.Debug|Win32.Build.0 = Debug|Win32 - {5A7AAEBC-F269-41DA-984A-75F975549CA5}.Release|Win32.ActiveCfg = Release|Win32 - {5A7AAEBC-F269-41DA-984A-75F975549CA5}.Release|Win32.Build.0 = Release|Win32 {2863FF8A-153F-46E0-8E71-2E58F3809E9B}.Debug|Win32.ActiveCfg = Debug|Win32 {2863FF8A-153F-46E0-8E71-2E58F3809E9B}.Debug|Win32.Build.0 = Debug|Win32 {2863FF8A-153F-46E0-8E71-2E58F3809E9B}.Release|Win32.ActiveCfg = Release|Win32 diff --git a/platform/msvc2008/love.vcproj b/platform/msvc2008/love.vcproj index 834d388a1..62c2d83ae 100644 --- a/platform/msvc2008/love.vcproj +++ b/platform/msvc2008/love.vcproj @@ -538,6 +538,26 @@ + + + + + + + + @@ -598,6 +618,10 @@ + + @@ -778,6 +802,10 @@ RelativePath="..\..\src\modules\graphics\Drawable.h" > + + @@ -846,6 +874,7 @@ @@ -1382,6 +1412,26 @@ + + + + + + + + @@ -1442,6 +1492,26 @@ + + + + + + + + @@ -1502,6 +1572,26 @@ + + + + + + + + @@ -1562,10 +1652,50 @@ + + + + + + + + + + + + + + + + @@ -3231,368 +3361,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -3757,6 +3529,10 @@ RelativePath="..\..\src\common\runtime.h" > + + diff --git a/platform/msvc2008/mouse/mouse.vcproj b/platform/msvc2008/mouse/mouse.vcproj index 9c8400cf5..04337a725 100644 --- a/platform/msvc2008/mouse/mouse.vcproj +++ b/platform/msvc2008/mouse/mouse.vcproj @@ -205,6 +205,10 @@ > + + diff --git a/platform/msvc2008/native/native.vcproj b/platform/msvc2008/native/native.vcproj deleted file mode 100644 index 08f33c109..000000000 --- a/platform/msvc2008/native/native.vcproj +++ /dev/null @@ -1,260 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/platform/msvc2008/physics/physics.vcproj b/platform/msvc2008/physics/physics.vcproj index c66b6c607..20ff39758 100644 --- a/platform/msvc2008/physics/physics.vcproj +++ b/platform/msvc2008/physics/physics.vcproj @@ -1241,10 +1241,18 @@ + + + + diff --git a/platform/msvc2008/signal/signal.vcproj b/platform/msvc2008/signal/signal.vcproj deleted file mode 100644 index 9adf640fb..000000000 --- a/platform/msvc2008/signal/signal.vcproj +++ /dev/null @@ -1,213 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/common/EnumMap.h b/src/common/EnumMap.h new file mode 100644 index 000000000..674452c33 --- /dev/null +++ b/src/common/EnumMap.h @@ -0,0 +1,99 @@ +/** +* Copyright (c) 2006-2009 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_ENUM_MAP_H +#define LOVE_ENUM_MAP_H + +#include "Exception.h" + +namespace love +{ + template + class EnumMap + { + private: + + struct Value + { + unsigned v; + bool set; + Value() : set(false) {} + }; + + Value values_t[PEAK]; + Value values_u[PEAK]; + + public: + + struct Entry + { + T t; + U u; + }; + + EnumMap(Entry * entries, unsigned size) + { + unsigned n = size/sizeof(Entry); + + for(unsigned i = 0; i + class StringMap + { + private: + + struct Record + { + const char * key; + T value; + bool set; + Record() : set(false) {} + }; + + const static unsigned MAX = (unsigned)((float)SIZE * 1.5f); + + Record records[MAX]; + const char * reverse[SIZE]; + + public: + + struct Entry + { + const char * key; + T value; + }; + + StringMap(Entry * entries, unsigned num) + { + + for(unsigned i = 0; i < SIZE; ++i) + reverse[i] = 0; + + unsigned n = num/sizeof(Entry); + + for(unsigned i = 0; i < n; ++i) + { + add(entries[i].key, entries[i].value); + } + } + + bool streq(const char * a, const char * b) + { + while(*a != 0 && *b != 0) + { + if(*a != *b) + return false; + ++a; + ++b; + } + + return (*a == 0 && *b == 0); + } + + bool find(const char * key, T & t) + { + unsigned str_hash = djb2(key); + + for(unsigned i = 0; i < MAX; ++i) + { + unsigned str_i = (str_hash + i) % MAX; + + if(records[i].set && streq(records[i].key, key)) + { + t = records[i].value; + return true; + } + } + + return false; + } + + bool find(T key, const char *& str) + { + unsigned index = (unsigned)key; + + if(index >= SIZE) + return false; + + if(reverse[index] != 0) + { + str = reverse[index]; + return true; + } + else + { + return false; + } + } + + bool add(const char * key, T value) + { + unsigned str_hash = djb2(key); + bool inserted = false; + + for(unsigned i = 0; i < MAX; ++i) + { + unsigned str_i = (str_hash + i) % MAX; + + if(!records[str_i].set) + { + inserted = true; + records[str_i].set = true; + records[str_i].key = key; + records[str_i].value = value; + break; + } + } + + unsigned index = (unsigned)value; + + if(index >= SIZE) + { + printf("\nConstant %s out of bounds with %i!\n", key, index); + return false; + } + + reverse[index] = key; + + return inserted; + } + + unsigned djb2(const char * key) + { + unsigned hash = 5381; + int c; + + while (c = *key++) + hash = ((hash << 5) + hash) + c; + + return hash; + } + + }; // StringMap + +} // love + +#endif // LOVE_STRING_MAP_H diff --git a/src/common/runtime.cpp b/src/common/runtime.cpp index 73f157cd3..3db3f3705 100644 --- a/src/common/runtime.cpp +++ b/src/common/runtime.cpp @@ -134,16 +134,6 @@ namespace love // Gets the love table. luax_insistglobal(L, "love"); - // Install constants. - if(m.constants != 0) - { - for(int i = 0; m.constants[i].name != 0; i++) - { - lua_pushinteger(L, m.constants[i].value); - lua_setfield(L, -2, m.constants[i].name); - } - } - // Create new table for module. lua_newtable(L); diff --git a/src/common/runtime.h b/src/common/runtime.h index e926d4934..1449ad57f 100644 --- a/src/common/runtime.h +++ b/src/common/runtime.h @@ -65,16 +65,6 @@ namespace love bool own; }; - - /** - * Used to store constants in arrays. - **/ - struct Constant - { - const char * name; - int value; - }; - /** * A Module with Lua wrapper functions and other data. **/ @@ -95,8 +85,6 @@ namespace love // A list of functions which expose the types of the modules (last element 0). const lua_CFunction * types; - // A list of constants (last element 0). - const Constant * constants; }; /** diff --git a/src/love.cpp b/src/love.cpp index 08b0b4a1a..7239d745c 100644 --- a/src/love.cpp +++ b/src/love.cpp @@ -33,15 +33,12 @@ #include