diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2019-04-16 16:32:08 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@qt.io> | 2019-04-16 16:32:08 +0200 |
commit | 6630937e63ae5797487b86743a7733c8ae5cc42c (patch) | |
tree | 3d53dacf6430f9099e1fb20835881205de674961 /src/3rdparty/angle/src/compiler/translator/InfoSink.h | |
parent | 37ed6dae00640f9cc980ffda05347c12a7eb5d7e (diff) | |
parent | c7af193d2e49e9f10b86262e63d8d13abf72b5cf (diff) |
Merge commit 'dev' into 'wip/cmake-merge'
Change-Id: I176c40d031be26a1dd1cf08843e448a660598783
Diffstat (limited to 'src/3rdparty/angle/src/compiler/translator/InfoSink.h')
-rw-r--r-- | src/3rdparty/angle/src/compiler/translator/InfoSink.h | 78 |
1 files changed, 41 insertions, 37 deletions
diff --git a/src/3rdparty/angle/src/compiler/translator/InfoSink.h b/src/3rdparty/angle/src/compiler/translator/InfoSink.h index f47fafa8ee..2705f48d59 100644 --- a/src/3rdparty/angle/src/compiler/translator/InfoSink.h +++ b/src/3rdparty/angle/src/compiler/translator/InfoSink.h @@ -10,38 +10,32 @@ #include <math.h> #include <stdlib.h> #include "compiler/translator/Common.h" +#include "compiler/translator/Severity.h" + +namespace sh +{ // Returns the fractional part of the given floating-point number. -inline float fractionalPart(float f) { - float intPart = 0.0f; - return modff(f, &intPart); +inline float fractionalPart(float f) +{ + float intPart = 0.0f; + return modff(f, &intPart); } // -// TPrefixType is used to centralize how info log messages start. -// See below. -// -enum TPrefixType { - EPrefixNone, - EPrefixWarning, - EPrefixError, - EPrefixInternalError, - EPrefixUnimplemented, - EPrefixNote -}; - -// // Encapsulate info logs for all objects that have them. // // The methods are a general set of tools for getting a variety of // messages and types inserted into the log. // -class TInfoSinkBase { -public: +class TInfoSinkBase +{ + public: TInfoSinkBase() {} template <typename T> - TInfoSinkBase& operator<<(const T& t) { + TInfoSinkBase &operator<<(const T &t) + { TPersistStringStream stream; stream << t; sink.append(stream.str()); @@ -49,33 +43,41 @@ public: } // Override << operator for specific types. It is faster to append strings // and characters directly to the sink. - TInfoSinkBase& operator<<(char c) { + TInfoSinkBase &operator<<(char c) + { sink.append(1, c); return *this; } - TInfoSinkBase& operator<<(const char* str) { + TInfoSinkBase &operator<<(const char *str) + { sink.append(str); return *this; } - TInfoSinkBase& operator<<(const TPersistString& str) { + TInfoSinkBase &operator<<(const TPersistString &str) + { sink.append(str); return *this; } - TInfoSinkBase& operator<<(const TString& str) { + TInfoSinkBase &operator<<(const TString &str) + { sink.append(str.c_str()); return *this; } // Make sure floats are written with correct precision. - TInfoSinkBase& operator<<(float f) { + TInfoSinkBase &operator<<(float f) + { // Make sure that at least one decimal point is written. If a number // does not have a fractional part, the default precision format does // not write the decimal portion which gets interpreted as integer by // the compiler. TPersistStringStream stream; - if (fractionalPart(f) == 0.0f) { + if (fractionalPart(f) == 0.0f) + { stream.precision(1); stream << std::showpoint << std::fixed << f; - } else { + } + else + { stream.unsetf(std::ios::fixed); stream.unsetf(std::ios::scientific); stream.precision(8); @@ -85,8 +87,9 @@ public: return *this; } // Write boolean values as their names instead of integral value. - TInfoSinkBase& operator<<(bool b) { - const char* str = b ? "true" : "false"; + TInfoSinkBase &operator<<(bool b) + { + const char *str = b ? "true" : "false"; sink.append(str); return *this; } @@ -94,23 +97,24 @@ public: void erase() { sink.clear(); } int size() { return static_cast<int>(sink.size()); } - const TPersistString& str() const { return sink; } - const char* c_str() const { return sink.c_str(); } + const TPersistString &str() const { return sink; } + const char *c_str() const { return sink.c_str(); } - void prefix(TPrefixType p); + void prefix(Severity severity); void location(int file, int line); - void location(const TSourceLoc& loc); - void message(TPrefixType p, const TSourceLoc& loc, const char* m); -private: + private: TPersistString sink; }; -class TInfoSink { -public: +class TInfoSink +{ + public: TInfoSinkBase info; TInfoSinkBase debug; TInfoSinkBase obj; }; -#endif // COMPILER_TRANSLATOR_INFOSINK_H_ +} // namespace sh + +#endif // COMPILER_TRANSLATOR_INFOSINK_H_ |