From: <man...@us...> - 2014-02-23 17:52:41
|
Revision: 3761 http://sourceforge.net/p/modplug/code/3761 Author: manxorist Date: 2014-02-23 17:52:33 +0000 (Sun, 23 Feb 2014) Log Message: ----------- [Ref] Flatten header dependencies of the headers that get included via stdafx.h . [Ref] Update comments about which headers get included via our headers in stdafx.h . [Ref] Move logging functions from typedefs.h into Logging.h . [Ref] Always include trivially short header Logging.h in stdafx.h . [Ref] Avoid always dragging in non-standard header strings.h in GCC/Clang builds by un-inlining mpt::strnicmp . Modified Paths: -------------- trunk/OpenMPT/common/Logging.h trunk/OpenMPT/common/mptPathString.h trunk/OpenMPT/common/mptString.cpp trunk/OpenMPT/common/mptString.h trunk/OpenMPT/common/stdafx.h trunk/OpenMPT/common/typedefs.h trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/common/Logging.h =================================================================== --- trunk/OpenMPT/common/Logging.h 2014-02-23 15:54:25 UTC (rev 3760) +++ trunk/OpenMPT/common/Logging.h 2014-02-23 17:52:33 UTC (rev 3761) @@ -40,3 +40,38 @@ virtual void AddToLog(LogLevel level, const std::string &text) const = 0; }; + +#ifndef NO_LOGGING +void MPT_PRINTF_FUNC(1,2) Log(const char *format, ...); +void Log(const std::string &text); +void Log(const std::wstring &text); +class Logger +{ +private: + const char * const file; + int const line; + const char * const function; +public: + Logger(const char *file_, int line_, const char *function_) : file(file_), line(line_), function(function_) {} + void MPT_PRINTF_FUNC(2,3) operator () (const char *format, ...); + void operator () (const std::string &text); + void operator () (const std::wstring &text); +}; +#define Log Logger(__FILE__, __LINE__, __FUNCTION__) +#else // !NO_LOGGING +static inline void MPT_PRINTF_FUNC(1,2) Log(const char * /*format*/, ...) {} +static inline void Log(const std::string & /*text*/ ) {} +static inline void Log(const std::wstring & /*text*/ ) {} +class Logger +{ +public: + inline void MPT_PRINTF_FUNC(2,3) operator () (const char * /*format*/, ...) {} + inline void operator () (const std::string & /*text*/ ) {} + inline void operator () (const std::wstring & /*text*/ ) {} +}; +#define Log if(true) {} else Logger() // completely compile out arguments to Log() so that they do not even get evaluated +#endif // NO_LOGGING + +// just #undef Log in files, where this Log redefinition causes problems +//#undef Log + Modified: trunk/OpenMPT/common/mptPathString.h =================================================================== --- trunk/OpenMPT/common/mptPathString.h 2014-02-23 15:54:25 UTC (rev 3760) +++ trunk/OpenMPT/common/mptPathString.h 2014-02-23 17:52:33 UTC (rev 3761) @@ -10,6 +10,9 @@ #pragma once +#include <cstdio> +#include <stdio.h> + //#define MPT_DEPRECATED_PATH #define MPT_DEPRECATED_PATH MPT_DEPRECATED Modified: trunk/OpenMPT/common/mptString.cpp =================================================================== --- trunk/OpenMPT/common/mptString.cpp 2014-02-23 15:54:25 UTC (rev 3760) +++ trunk/OpenMPT/common/mptString.cpp 2014-02-23 17:52:33 UTC (rev 3761) @@ -25,11 +25,32 @@ #include <cstdarg> +#if MPT_COMPILER_GCC || MPT_COMPILER_CLANG +#include <strings.h> // for strncasecmp +#endif + #if !defined(MPT_CHARSET_CPP) && !defined(MPT_CHARSET_CUSTOMUTF8) && !defined(WIN32) #include <iconv.h> #endif // !WIN32 +namespace mpt { + + +int strnicmp(const char *a, const char *b, size_t count) +//------------------------------------------------------ +{ +#if MPT_COMPILER_MSVC + return _strnicmp(a, b, count); +#else + return strncasecmp(a, b, count); +#endif +} + + +} // namespace mpt + + namespace mpt { namespace String { Modified: trunk/OpenMPT/common/mptString.h =================================================================== --- trunk/OpenMPT/common/mptString.h 2014-02-23 15:54:25 UTC (rev 3760) +++ trunk/OpenMPT/common/mptString.h 2014-02-23 17:52:33 UTC (rev 3761) @@ -16,12 +16,7 @@ #include <type_traits> #endif -#include <cstdio> #include <cstring> -#include <stdio.h> -#if MPT_COMPILER_GCC || MPT_COMPILER_CLANG -#include <strings.h> // for strcasecmp -#endif namespace mpt @@ -161,15 +156,7 @@ } -static inline int strnicmp(const char *a, const char *b, size_t count) -//-------------------------------------------------------------------- -{ - #if MPT_COMPILER_MSVC - return _strnicmp(a, b, count); - #else - return strncasecmp(a, b, count); - #endif -} +int strnicmp(const char *a, const char *b, size_t count); enum Charset { Modified: trunk/OpenMPT/common/stdafx.h =================================================================== --- trunk/OpenMPT/common/stdafx.h 2014-02-23 15:54:25 UTC (rev 3760) +++ trunk/OpenMPT/common/stdafx.h 2014-02-23 17:52:33 UTC (rev 3761) @@ -60,19 +60,26 @@ #endif // this will be available everywhere + #include "../common/typedefs.h" -// this adds: // <memory> // <new> -// <string> -// <vector> // <cstdarg> // <cstdint> +// <stdint.h> + +#include "../common/mptString.h" +// <limits> +// <string> +// <type_traits> +// <cstring> + +#include "../common/mptPathString.h" // <cstdio> // <stdio.h> -#include "../common/mptString.h" -#include "../common/mptPathString.h" +#include "../common/Logging.h" + //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. Modified: trunk/OpenMPT/common/typedefs.h =================================================================== --- trunk/OpenMPT/common/typedefs.h 2014-02-23 15:54:25 UTC (rev 3760) +++ trunk/OpenMPT/common/typedefs.h 2014-02-23 17:52:33 UTC (rev 3761) @@ -432,8 +432,6 @@ #define MPT_PRINTF_FUNC(formatstringindex,varargsindex) #endif -#include "../common/mptString.h" - //To mark string that should be translated in case of multilingual version. #define GetStrI18N(x) (x) @@ -458,42 +456,6 @@ -#ifndef NO_LOGGING -void MPT_PRINTF_FUNC(1,2) Log(const char *format, ...); -void Log(const std::string &text); -void Log(const std::wstring &text); -class Logger -{ -private: - const char * const file; - int const line; - const char * const function; -public: - Logger(const char *file_, int line_, const char *function_) : file(file_), line(line_), function(function_) {} - void MPT_PRINTF_FUNC(2,3) operator () (const char *format, ...); - void operator () (const std::string &text); - void operator () (const std::wstring &text); -}; -#define Log Logger(__FILE__, __LINE__, __FUNCTION__) -#else // !NO_LOGGING -static inline void MPT_PRINTF_FUNC(1,2) Log(const char * /*format*/, ...) {} -static inline void Log(const std::string & /*text*/ ) {} -static inline void Log(const std::wstring & /*text*/ ) {} -class Logger -{ -public: - inline void MPT_PRINTF_FUNC(2,3) operator () (const char * /*format*/, ...) {} - inline void operator () (const std::string & /*text*/ ) {} - inline void operator () (const std::wstring & /*text*/ ) {} -}; -#define Log if(true) {} else Logger() // completely compile out arguments to Log() so that they do not even get evaluated -#endif // NO_LOGGING - -// just #undef Log in files, where this Log redefinition causes problems -//#undef Log - - - #if MPT_COMPILER_MSVC && defined(UNREFERENCED_PARAMETER) #define MPT_UNREFERENCED_PARAMETER(x) UNREFERENCED_PARAMETER(x) #else Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2014-02-23 15:54:25 UTC (rev 3760) +++ trunk/OpenMPT/mptrack/Moddoc.h 2014-02-23 17:52:33 UTC (rev 3761) @@ -14,7 +14,6 @@ #include "../common/misc_util.h" #include "Undo.h" #include "Notification.h" -#include "../common/Logging.h" #include <time.h> class EncoderFactoryBase; Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2014-02-23 15:54:25 UTC (rev 3760) +++ trunk/OpenMPT/soundlib/Sndfile.h 2014-02-23 17:52:33 UTC (rev 3761) @@ -14,7 +14,6 @@ #include "../soundlib/SoundFilePlayConfig.h" #include "../soundlib/MixerSettings.h" #include "../common/misc_util.h" -#include "../common/Logging.h" #include "mod_specifications.h" #include <vector> #include <bitset> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |