diff options
author | Jamie Madill <jmadill@chromium.org> | 2016-12-12 14:42:19 -0500 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2016-12-12 22:28:55 +0000 |
commit | d7b1ab5893953b97fe5dc1b3087a9b4b50ec45ee (patch) | |
tree | a03c67ce8afcbda1b730f809f98f079f56c590f3 /src/compiler/translator/InfoSink.h | |
parent | cc507aa0efca2cae35ddc257092e5ceacb7570c9 (diff) | |
download | angle-d7b1ab5893953b97fe5dc1b3087a9b4b50ec45ee.tar.gz |
Fix up translator style.
Using git cl format.
BUG=angleproject:650
Change-Id: I7d3f98d2b0dcfb0a8de6c35327db74e55c28d761
Reviewed-on: https://chromium-review.googlesource.com/419059
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Diffstat (limited to 'src/compiler/translator/InfoSink.h')
-rw-r--r-- | src/compiler/translator/InfoSink.h | 62 |
1 files changed, 38 insertions, 24 deletions
diff --git a/src/compiler/translator/InfoSink.h b/src/compiler/translator/InfoSink.h index b18e5861b9..e01255804c 100644 --- a/src/compiler/translator/InfoSink.h +++ b/src/compiler/translator/InfoSink.h @@ -15,16 +15,18 @@ 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 { +enum TPrefixType +{ EPrefixNone, EPrefixWarning, EPrefixError, @@ -39,12 +41,14 @@ enum TPrefixType { // 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()); @@ -52,33 +56,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); @@ -88,8 +100,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; } @@ -97,20 +110,21 @@ 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 location(int file, int line); - void location(const TSourceLoc& loc); - void message(TPrefixType p, const TSourceLoc& loc, const char* m); + 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; @@ -118,4 +132,4 @@ public: } // namespace sh -#endif // COMPILER_TRANSLATOR_INFOSINK_H_ +#endif // COMPILER_TRANSLATOR_INFOSINK_H_ |