Tue, 22 Jul 2014 02:52:25 +0300
- major refactoring pretty much done, compiles now
CMakeLists.txt | file | annotate | diff | comparison | revisions | |
namedenums/namedenums.cpp | file | annotate | diff | comparison | revisions | |
src/botStuff.h | file | annotate | diff | comparison | revisions | |
src/format.h | file | annotate | diff | comparison | revisions | |
src/lexer.cpp | file | annotate | diff | comparison | revisions | |
src/lexerScanner.cpp | file | annotate | diff | comparison | revisions | |
src/tokens.h | file | annotate | diff | comparison | revisions |
--- a/CMakeLists.txt Mon Jul 21 17:14:42 2014 +0300 +++ b/CMakeLists.txt Tue Jul 22 02:52:25 2014 +0300 @@ -57,9 +57,9 @@ include_directories (${CMAKE_SOURCE_DIR}/src) if (NOT MSVC) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -W -Wall") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -W -Wall -Og") - if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") + if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" OR "${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG") endif() endif()
--- a/namedenums/namedenums.cpp Mon Jul 21 17:14:42 2014 +0300 +++ b/namedenums/namedenums.cpp Tue Jul 22 02:52:25 2014 +0300 @@ -341,6 +341,10 @@ if (*cp == '=') { + // until I figure out how to deal with the duplicate value issue + // I should probably use a map but not today. + Error ("cannot have named enums that define enumerator values"); + nenum.valuedefs = true; while (*cp != ',' && *cp != '\0') @@ -414,7 +418,7 @@ source.append ("const char* Get%sString (%s value)\n" "{\n" - "\treturn %sNames[value];\n" + "\treturn %sNames[long (value)];\n" "}\n", e.name.c_str(), e.name.c_str(), e.name.c_str()); }
--- a/src/botStuff.h Mon Jul 21 17:14:42 2014 +0300 +++ b/src/botStuff.h Tue Jul 22 02:52:25 2014 +0300 @@ -34,19 +34,19 @@ #include "main.h" -struct Limits +namespace Limits { - static const int MaxStates = 256; - static const int MaxEvents = 32; - static const int MaxGlobalEvents = 32; - static const int MaxGlobalVars = 128; - static const int MaxGlobalArrays = 16; - static const int MaxArraySize = 65536; - static const int MaxStateVars = 16; - static const int MaxStringlistSize = 128; - static const int MaxStringLength = 256; - static const int MaxReactionTime = 52; - static const int MaxStoredEvents = 64; + static constexpr int MaxStates = 256; + static constexpr int MaxEvents = 32; + static constexpr int MaxGlobalEvents = 32; + static constexpr int MaxGlobalVars = 128; + static constexpr int MaxGlobalArrays = 16; + static constexpr int MaxArraySize = 65536; + static constexpr int MaxStateVars = 16; + static constexpr int MaxStringlistSize = 128; + static constexpr int MaxStringLength = 256; + static constexpr int MaxReactionTime = 52; + static constexpr int MaxStoredEvents = 64; }; named_enum class DataHeader
--- a/src/format.h Mon Jul 21 17:14:42 2014 +0300 +++ b/src/format.h Tue Jul 22 02:52:25 2014 +0300 @@ -33,50 +33,50 @@ #include "list.h" #include "enumstrings.h" -String MakeFormatArgument (const String& a) +inline String MakeFormatArgument (const String& a) { return a; } -String MakeFormatArgument (char a) +inline String MakeFormatArgument (char a) { return String (a); } -String MakeFormatArgument (int a) +inline String MakeFormatArgument (int a) { return String::fromNumber (a); } -String MakeFormatArgument (long a) +inline String MakeFormatArgument (long a) { return String::fromNumber (a); } -String MakeFormatArgument (size_t a) +inline String MakeFormatArgument (size_t a) { return String::fromNumber (long (a)); } -String MakeFormatArgument (const char* a) +inline String MakeFormatArgument (const char* a) { return a; } -String MakeFormatArgument (const void* a) +inline String MakeFormatArgument (const void* a) { String text; text.sprintf ("%p", a); return text; } -String MakeFormatArgument (std::nullptr_t) +inline String MakeFormatArgument (std::nullptr_t) { return "(nullptr)"; } template<class T> -String MakeFormatArgument (List<T> const& list) +inline String MakeFormatArgument (List<T> const& list) { String result;
--- a/src/lexer.cpp Mon Jul 21 17:14:42 2014 +0300 +++ b/src/lexer.cpp Tue Jul 22 02:52:25 2014 +0300 @@ -256,7 +256,7 @@ // String Lexer::describeTokenPrivate (Token tokType, Lexer::TokenInfo* tok) { - if (tokType < Token::LastNamedToken) + if (tokType < LastNamedToken) return "\"" + LexerScanner::GetTokenString (tokType) + "\""; switch (tokType)
--- a/src/lexerScanner.cpp Mon Jul 21 17:14:42 2014 +0300 +++ b/src/lexerScanner.cpp Tue Jul 22 02:52:25 2014 +0300 @@ -111,7 +111,7 @@ "return", }; -static_assert (countof (gTokenStrings) == (int) Token::LastNamedToken + 1, +static_assert (countof (gTokenStrings) == (int) LastNamedToken + 1, "Count of gTokenStrings is not the same as the amount of named token identifiers."); // ============================================================================= @@ -192,7 +192,7 @@ { int flags = 0; - if (i >= int (Token::FirstNamedToken)) + if (i >= int (FirstNamedToken)) flags |= FCheckWord; if (checkString (gTokenStrings[i], flags)) @@ -290,7 +290,7 @@ // String LexerScanner::GetTokenString (Token a) { - ASSERT_LT_EQ (a, Token::LastNamedToken); + ASSERT_LT_EQ (a, LastNamedToken); return gTokenStrings[int (a)]; }
--- a/src/tokens.h Mon Jul 21 17:14:42 2014 +0300 +++ b/src/tokens.h Tue Jul 22 02:52:25 2014 +0300 @@ -123,9 +123,9 @@ Number, String, Any, - - FirstNamedToken = Token::Bool, - LastNamedToken = Token::Return, }; +static Token const FirstNamedToken = Token::Bool; +static Token const LastNamedToken = Token::Return; + #endif