Dejan Mircevski | b6fe02f | 2016-01-07 13:44:22 -0500 | [diff] [blame] | 1 | // Copyright (c) 2015-2016 The Khronos Group Inc. |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 2 | // |
David Neto | 9fc8658 | 2016-09-01 15:33:59 -0400 | [diff] [blame] | 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 6 | // |
David Neto | 9fc8658 | 2016-09-01 15:33:59 -0400 | [diff] [blame] | 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 8 | // |
David Neto | 9fc8658 | 2016-09-01 15:33:59 -0400 | [diff] [blame] | 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 14 | |
| 15 | #include "print.h" |
| 16 | |
rdb | ddf4de6 | 2017-05-28 23:19:58 +0200 | [diff] [blame] | 17 | #if defined(SPIRV_ANDROID) || defined(SPIRV_LINUX) || defined(SPIRV_MAC) || defined(SPIRV_FREEBSD) |
David Neto | 0165636 | 2015-11-20 10:44:41 -0500 | [diff] [blame] | 18 | namespace libspirv { |
| 19 | |
Andrew Woloszyn | 4c657bf | 2016-03-18 14:13:16 -0400 | [diff] [blame] | 20 | clr::reset::operator const char*() { return "\x1b[0m"; } |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 21 | |
Andrew Woloszyn | 4c657bf | 2016-03-18 14:13:16 -0400 | [diff] [blame] | 22 | clr::grey::operator const char*() { return "\x1b[1;30m"; } |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 23 | |
Andrew Woloszyn | 4c657bf | 2016-03-18 14:13:16 -0400 | [diff] [blame] | 24 | clr::red::operator const char*() { return "\x1b[31m"; } |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 25 | |
Andrew Woloszyn | 4c657bf | 2016-03-18 14:13:16 -0400 | [diff] [blame] | 26 | clr::green::operator const char*() { return "\x1b[32m"; } |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 27 | |
Andrew Woloszyn | 4c657bf | 2016-03-18 14:13:16 -0400 | [diff] [blame] | 28 | clr::yellow::operator const char*() { return "\x1b[33m"; } |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 29 | |
Andrew Woloszyn | 4c657bf | 2016-03-18 14:13:16 -0400 | [diff] [blame] | 30 | clr::blue::operator const char*() { return "\x1b[34m"; } |
David Neto | 0165636 | 2015-11-20 10:44:41 -0500 | [diff] [blame] | 31 | |
| 32 | } // namespace libspirv |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 33 | #elif defined(SPIRV_WINDOWS) |
David Neto | 7c58c1d | 2016-02-29 01:01:04 -0500 | [diff] [blame] | 34 | #include <windows.h> |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 35 | |
David Neto | 0165636 | 2015-11-20 10:44:41 -0500 | [diff] [blame] | 36 | namespace libspirv { |
| 37 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 38 | clr::reset::operator const char*() { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 39 | const DWORD color = 0Xf; |
| 40 | HANDLE hConsole; |
| 41 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); |
| 42 | SetConsoleTextAttribute(hConsole, color); |
| 43 | hConsole = GetStdHandle(STD_ERROR_HANDLE); |
| 44 | SetConsoleTextAttribute(hConsole, color); |
| 45 | return ""; |
| 46 | } |
| 47 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 48 | clr::grey::operator const char*() { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 49 | const DWORD color = 0x8; |
| 50 | HANDLE hConsole; |
| 51 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); |
| 52 | SetConsoleTextAttribute(hConsole, color); |
| 53 | hConsole = GetStdHandle(STD_ERROR_HANDLE); |
| 54 | SetConsoleTextAttribute(hConsole, color); |
| 55 | return ""; |
| 56 | } |
| 57 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 58 | clr::red::operator const char*() { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 59 | const DWORD color = 0x4; |
| 60 | HANDLE hConsole; |
| 61 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); |
| 62 | SetConsoleTextAttribute(hConsole, color); |
| 63 | hConsole = GetStdHandle(STD_ERROR_HANDLE); |
| 64 | SetConsoleTextAttribute(hConsole, color); |
| 65 | return ""; |
| 66 | } |
| 67 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 68 | clr::green::operator const char*() { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 69 | const DWORD color = 0x2; |
| 70 | HANDLE hConsole; |
| 71 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); |
| 72 | SetConsoleTextAttribute(hConsole, color); |
| 73 | hConsole = GetStdHandle(STD_ERROR_HANDLE); |
| 74 | SetConsoleTextAttribute(hConsole, color); |
| 75 | return ""; |
| 76 | } |
| 77 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 78 | clr::yellow::operator const char*() { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 79 | const DWORD color = 0x6; |
| 80 | HANDLE hConsole; |
| 81 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); |
| 82 | SetConsoleTextAttribute(hConsole, color); |
| 83 | hConsole = GetStdHandle(STD_ERROR_HANDLE); |
| 84 | SetConsoleTextAttribute(hConsole, color); |
| 85 | return ""; |
| 86 | } |
| 87 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 88 | clr::blue::operator const char*() { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 89 | const DWORD color = 0x1; |
| 90 | HANDLE hConsole; |
| 91 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); |
| 92 | SetConsoleTextAttribute(hConsole, color); |
| 93 | hConsole = GetStdHandle(STD_ERROR_HANDLE); |
| 94 | SetConsoleTextAttribute(hConsole, color); |
| 95 | return ""; |
| 96 | } |
David Neto | 0165636 | 2015-11-20 10:44:41 -0500 | [diff] [blame] | 97 | |
| 98 | } // namespace libspirv |
Ben Vanik | 01c8d7a | 2015-11-22 08:32:53 -0800 | [diff] [blame] | 99 | #else |
| 100 | namespace libspirv { |
| 101 | |
| 102 | clr::reset::operator const char*() { return ""; } |
| 103 | |
| 104 | clr::grey::operator const char*() { return ""; } |
| 105 | |
| 106 | clr::red::operator const char*() { return ""; } |
| 107 | |
| 108 | clr::green::operator const char*() { return ""; } |
| 109 | |
| 110 | clr::yellow::operator const char*() { return ""; } |
| 111 | |
| 112 | clr::blue::operator const char*() { return ""; } |
| 113 | |
| 114 | } // namespace libspirv |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 115 | #endif |