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 | // |
| 3 | // Permission is hereby granted, free of charge, to any person obtaining a |
| 4 | // copy of this software and/or associated documentation files (the |
| 5 | // "Materials"), to deal in the Materials without restriction, including |
| 6 | // without limitation the rights to use, copy, modify, merge, publish, |
| 7 | // distribute, sublicense, and/or sell copies of the Materials, and to |
| 8 | // permit persons to whom the Materials are furnished to do so, subject to |
| 9 | // the following conditions: |
| 10 | // |
| 11 | // The above copyright notice and this permission notice shall be included |
| 12 | // in all copies or substantial portions of the Materials. |
| 13 | // |
| 14 | // MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS |
| 15 | // KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS |
| 16 | // SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT |
| 17 | // https://www.khronos.org/registry/ |
| 18 | // |
| 19 | // THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 22 | // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 23 | // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 24 | // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 25 | // MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. |
| 26 | |
| 27 | #include "print.h" |
| 28 | |
| 29 | #if defined(SPIRV_LINUX) || defined(SPIRV_MAC) |
David Neto | 0165636 | 2015-11-20 10:44:41 -0500 | [diff] [blame] | 30 | namespace libspirv { |
| 31 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 32 | clr::reset::operator const char*() { return "\e[0m"; } |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 33 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 34 | clr::grey::operator const char*() { return "\e[1;30m"; } |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 35 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 36 | clr::red::operator const char*() { return "\e[31m"; } |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 37 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 38 | clr::green::operator const char*() { return "\e[32m"; } |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 39 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 40 | clr::yellow::operator const char*() { return "\e[33m"; } |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 41 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 42 | clr::blue::operator const char*() { return "\e[34m"; } |
David Neto | 0165636 | 2015-11-20 10:44:41 -0500 | [diff] [blame] | 43 | |
| 44 | } // namespace libspirv |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 45 | #elif defined(SPIRV_WINDOWS) |
| 46 | #include <Windows.h> |
| 47 | |
David Neto | 0165636 | 2015-11-20 10:44:41 -0500 | [diff] [blame] | 48 | namespace libspirv { |
| 49 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 50 | clr::reset::operator const char*() { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 51 | const DWORD color = 0Xf; |
| 52 | HANDLE hConsole; |
| 53 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); |
| 54 | SetConsoleTextAttribute(hConsole, color); |
| 55 | hConsole = GetStdHandle(STD_ERROR_HANDLE); |
| 56 | SetConsoleTextAttribute(hConsole, color); |
| 57 | return ""; |
| 58 | } |
| 59 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 60 | clr::grey::operator const char*() { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 61 | const DWORD color = 0x8; |
| 62 | HANDLE hConsole; |
| 63 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); |
| 64 | SetConsoleTextAttribute(hConsole, color); |
| 65 | hConsole = GetStdHandle(STD_ERROR_HANDLE); |
| 66 | SetConsoleTextAttribute(hConsole, color); |
| 67 | return ""; |
| 68 | } |
| 69 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 70 | clr::red::operator const char*() { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 71 | const DWORD color = 0x4; |
| 72 | HANDLE hConsole; |
| 73 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); |
| 74 | SetConsoleTextAttribute(hConsole, color); |
| 75 | hConsole = GetStdHandle(STD_ERROR_HANDLE); |
| 76 | SetConsoleTextAttribute(hConsole, color); |
| 77 | return ""; |
| 78 | } |
| 79 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 80 | clr::green::operator const char*() { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 81 | const DWORD color = 0x2; |
| 82 | HANDLE hConsole; |
| 83 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); |
| 84 | SetConsoleTextAttribute(hConsole, color); |
| 85 | hConsole = GetStdHandle(STD_ERROR_HANDLE); |
| 86 | SetConsoleTextAttribute(hConsole, color); |
| 87 | return ""; |
| 88 | } |
| 89 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 90 | clr::yellow::operator const char*() { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 91 | const DWORD color = 0x6; |
| 92 | HANDLE hConsole; |
| 93 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); |
| 94 | SetConsoleTextAttribute(hConsole, color); |
| 95 | hConsole = GetStdHandle(STD_ERROR_HANDLE); |
| 96 | SetConsoleTextAttribute(hConsole, color); |
| 97 | return ""; |
| 98 | } |
| 99 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 100 | clr::blue::operator const char*() { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 101 | const DWORD color = 0x1; |
| 102 | HANDLE hConsole; |
| 103 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); |
| 104 | SetConsoleTextAttribute(hConsole, color); |
| 105 | hConsole = GetStdHandle(STD_ERROR_HANDLE); |
| 106 | SetConsoleTextAttribute(hConsole, color); |
| 107 | return ""; |
| 108 | } |
David Neto | 0165636 | 2015-11-20 10:44:41 -0500 | [diff] [blame] | 109 | |
| 110 | } // namespace libspirv |
Ben Vanik | 01c8d7a | 2015-11-22 08:32:53 -0800 | [diff] [blame] | 111 | #else |
| 112 | namespace libspirv { |
| 113 | |
| 114 | clr::reset::operator const char*() { return ""; } |
| 115 | |
| 116 | clr::grey::operator const char*() { return ""; } |
| 117 | |
| 118 | clr::red::operator const char*() { return ""; } |
| 119 | |
| 120 | clr::green::operator const char*() { return ""; } |
| 121 | |
| 122 | clr::yellow::operator const char*() { return ""; } |
| 123 | |
| 124 | clr::blue::operator const char*() { return ""; } |
| 125 | |
| 126 | } // namespace libspirv |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 127 | #endif |