From: <rel...@us...> - 2009-01-23 18:49:57
|
Revision: 247 http://modplug.svn.sourceforge.net/modplug/?rev=247&view=rev Author: relabsoluness Date: 2009-01-23 18:49:52 +0000 (Fri, 23 Jan 2009) Log Message: ----------- ? Minor internal tweaks. Modified Paths: -------------- trunk/OpenMPT/mptrack/misc_util.h trunk/OpenMPT/mptrack/serialization_utils.h trunk/OpenMPT/mptrack/test/test.cpp trunk/OpenMPT/mptrack/typedefs.h trunk/OpenMPT/soundlib/tuningCollection.cpp trunk/OpenMPT/soundlib/tuningcollection.h Modified: trunk/OpenMPT/mptrack/misc_util.h =================================================================== --- trunk/OpenMPT/mptrack/misc_util.h 2009-01-17 21:37:21 UTC (rev 246) +++ trunk/OpenMPT/mptrack/misc_util.h 2009-01-23 18:49:52 UTC (rev 247) @@ -7,9 +7,7 @@ #define ARRAYELEMCOUNT(x) (sizeof(x)/sizeof(x[0])) //Compile time assert. -#define STATIC_ASSERT(expr) typedef char ___staticAssertTypedef[(expr)]; -STATIC_ASSERT(true); //STATIC_ASSERT(false) doesn't necessarily cause error on some compilers - //if used alone. Using STATIC_ASSERT(true) first should make sure it does. +#define STATIC_ASSERT(expr) C_ASSERT(expr) //Convert object(typically number) to string template<class T> Modified: trunk/OpenMPT/mptrack/serialization_utils.h =================================================================== --- trunk/OpenMPT/mptrack/serialization_utils.h 2009-01-17 21:37:21 UTC (rev 246) +++ trunk/OpenMPT/mptrack/serialization_utils.h 2009-01-23 18:49:52 UTC (rev 247) @@ -10,6 +10,7 @@ #include <algorithm> #include "misc_util.h" #include "typedefs.h" +#include <limits> using std::numeric_limits; using std::ostringstream; Modified: trunk/OpenMPT/mptrack/test/test.cpp =================================================================== --- trunk/OpenMPT/mptrack/test/test.cpp 2009-01-17 21:37:21 UTC (rev 246) +++ trunk/OpenMPT/mptrack/test/test.cpp 2009-01-23 18:49:52 UTC (rev 247) @@ -7,6 +7,7 @@ #include "test.h" #include "../version.h" #include "../misc_util.h" +#include <limits> #ifdef ENABLE_TESTS @@ -41,6 +42,7 @@ void TestVersion(); +void TestTypes(); @@ -49,6 +51,7 @@ //------------ { DO_TEST(TestVersion); + DO_TEST(TestTypes); MessageBox(0, "Tests were run", "Testing", MB_ICONINFORMATION); } @@ -112,6 +115,30 @@ } } + +void TestTypes() +//-------------- +{ + VERIFY_EQUAL(int8_min, (std::numeric_limits<int8>::min)()); + VERIFY_EQUAL(int8_max, (std::numeric_limits<int8>::max)()); + VERIFY_EQUAL(uint8_max, (std::numeric_limits<uint8>::max)()); + + VERIFY_EQUAL(int16_min, (std::numeric_limits<int16>::min)()); + VERIFY_EQUAL(int16_max, (std::numeric_limits<int16>::max)()); + VERIFY_EQUAL(uint16_max, (std::numeric_limits<uint16>::max)()); + + VERIFY_EQUAL(int32_min, (std::numeric_limits<int32>::min)()); + VERIFY_EQUAL(int32_max, (std::numeric_limits<int32>::max)()); + VERIFY_EQUAL(uint32_max, (std::numeric_limits<uint32>::max)()); + + VERIFY_EQUAL(int64_min, (std::numeric_limits<int64>::min)()); + VERIFY_EQUAL(int64_max, (std::numeric_limits<int64>::max)()); + VERIFY_EQUAL(uint64_max, (std::numeric_limits<uint64>::max)()); + + VERIFY_EQUAL(ROWINDEX_MAX, (std::numeric_limits<ROWINDEX>::max)()); + VERIFY_EQUAL(ORDERINDEX_MAX, (std::numeric_limits<ORDERINDEX>::max)()); +} + }; //Namespace MptTest #else //Case: ENABLE_TESTS is not defined. Modified: trunk/OpenMPT/mptrack/typedefs.h =================================================================== --- trunk/OpenMPT/mptrack/typedefs.h 2009-01-17 21:37:21 UTC (rev 246) +++ trunk/OpenMPT/mptrack/typedefs.h 2009-01-23 18:49:52 UTC (rev 247) @@ -1,8 +1,6 @@ #ifndef TYPEDEFS_H #define TYPEDEFS_H -#include <limits> - typedef __int8 int8; typedef __int16 int16; typedef __int32 int32; @@ -13,27 +11,29 @@ typedef unsigned __int32 uint32; typedef unsigned __int64 uint64; -const int8 int8_min = (std::numeric_limits<int8>::min)(); -const int16 int16_min = (std::numeric_limits<int16>::min)(); -const int32 int32_min = (std::numeric_limits<int32>::min)(); -const int64 int64_min = (std::numeric_limits<int64>::min)(); +const int8 int8_min = -127-1; +const int16 int16_min = -32767-1; +const int32 int32_min = -2147483647-1; +const int64 int64_min = -9223372036854775807-1; -const int8 int8_max = (std::numeric_limits<int8>::max)(); -const int16 int16_max = (std::numeric_limits<int16>::max)(); -const int32 int32_max = (std::numeric_limits<int32>::max)(); -const int64 int64_max = (std::numeric_limits<int64>::max)(); +const int8 int8_max = 127; +const int16 int16_max = 32767; +const int32 int32_max = 2147483647; +const int64 int64_max = 9223372036854775807; -const uint8 uint8_max = (std::numeric_limits<uint8>::max)(); -const uint16 uint16_max = (std::numeric_limits<uint16>::max)(); -const uint32 uint32_max = (std::numeric_limits<uint32>::max)(); -const uint64 uint64_max = (std::numeric_limits<uint64>::max)(); +const uint8 uint8_max = 255; +const uint16 uint16_max = 65535; +const uint32 uint32_max = 4294967295; +const uint64 uint64_max = 18446744073709551615; typedef float float32; typedef uint32 ROWINDEX; + const ROWINDEX ROWINDEX_MAX = uint32_max; typedef uint16 CHANNELINDEX; typedef uint16 ORDERINDEX; + const ORDERINDEX ORDERINDEX_MAX = uint16_max; typedef uint16 PATTERNINDEX; typedef uint8 PLUGINDEX; typedef uint16 TEMPO; @@ -41,8 +41,5 @@ typedef uint16 INSTRUMENTINDEX; typedef uint32 MODTYPE; -const ORDERINDEX ORDERINDEX_MAX = (std::numeric_limits<ORDERINDEX>::max)(); -const ROWINDEX ROWINDEX_MAX = (std::numeric_limits<ROWINDEX>::max)(); - #endif Modified: trunk/OpenMPT/soundlib/tuningCollection.cpp =================================================================== --- trunk/OpenMPT/soundlib/tuningCollection.cpp 2009-01-17 21:37:21 UTC (rev 246) +++ trunk/OpenMPT/soundlib/tuningCollection.cpp 2009-01-23 18:49:52 UTC (rev 247) @@ -4,7 +4,7 @@ #include <bitset> //Serializations statics: -const CTuningCollection::SERIALIZATION_VERSION CTuningCollection::s_SerializationVersion = 3; +//const CTuningCollection::SERIALIZATION_VERSION CTuningCollection::s_SerializationVersion = 3; /* Version history: @@ -15,18 +15,8 @@ using namespace std; - -const CTuningCollection::SERIALIZATION_RETURN_TYPE CTuningCollection::SERIALIZATION_SUCCESS = false; -const CTuningCollection::SERIALIZATION_RETURN_TYPE CTuningCollection::SERIALIZATION_FAILURE = true; - const string CTuningCollection::s_FileExtension = ".tc"; -//BUG(?): These might not be called before constructor for certain -//CTuningCollection objects - not good. -const CTuningCollection::EDITMASK CTuningCollection::EM_ADD = 1; //0..01 -const CTuningCollection::EDITMASK CTuningCollection::EM_REMOVE = 2; //0..010 -const CTuningCollection::EDITMASK CTuningCollection::EM_ALLOWALL = 0xFFFF; -const CTuningCollection::EDITMASK CTuningCollection::EM_CONST = 0; /* TODOS: @@ -35,7 +25,7 @@ -CTuningCollection::CTuningCollection(const string& name) : m_Name(name), m_EditMask(0xFFFF) +CTuningCollection::CTuningCollection(const string& name) : m_Name(name), m_EditMask(EM_ALLOWALL) //------------------------------------ { if(m_Name.size() > GetNameLengthMax()) m_Name.resize(GetNameLengthMax()); Modified: trunk/OpenMPT/soundlib/tuningcollection.h =================================================================== --- trunk/OpenMPT/soundlib/tuningcollection.h 2009-01-17 21:37:21 UTC (rev 246) +++ trunk/OpenMPT/soundlib/tuningcollection.h 2009-01-23 18:49:52 UTC (rev 247) @@ -31,15 +31,18 @@ //BEGIN PUBLIC STATIC CONSTS public: - static const EDITMASK EM_ADD; //true <~> allowed - static const EDITMASK EM_REMOVE; - static const EDITMASK EM_ALLOWALL; - static const EDITMASK EM_CONST; + enum + { + EM_ADD = 1, //true <~> allowed + EM_REMOVE = 2, + EM_ALLOWALL = 0xffff, + EM_CONST = 0, - static const SERIALIZATION_VERSION s_SerializationVersion; + s_SerializationVersion = 3, - static const SERIALIZATION_RETURN_TYPE SERIALIZATION_SUCCESS; - static const SERIALIZATION_RETURN_TYPE SERIALIZATION_FAILURE; + SERIALIZATION_SUCCESS = false, + SERIALIZATION_FAILURE = true + }; static const string s_FileExtension; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |