| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2012 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 WTF_EXPORT void PrintInternal(PrintStream&, long long); | 85 WTF_EXPORT void PrintInternal(PrintStream&, long long); |
| 86 WTF_EXPORT void PrintInternal(PrintStream&, unsigned long long); | 86 WTF_EXPORT void PrintInternal(PrintStream&, unsigned long long); |
| 87 WTF_EXPORT void PrintInternal(PrintStream&, float); | 87 WTF_EXPORT void PrintInternal(PrintStream&, float); |
| 88 WTF_EXPORT void PrintInternal(PrintStream&, double); | 88 WTF_EXPORT void PrintInternal(PrintStream&, double); |
| 89 | 89 |
| 90 template <typename T> | 90 template <typename T> |
| 91 void PrintInternal(PrintStream& out, const T& value) { | 91 void PrintInternal(PrintStream& out, const T& value) { |
| 92 value.Dump(out); | 92 value.Dump(out); |
| 93 } | 93 } |
| 94 | 94 |
| 95 #define MAKE_PRINT_ADAPTOR(Name, Type, function) \ | |
| 96 class Name final { \ | |
| 97 STACK_ALLOCATED(); \ | |
| 98 \ | |
| 99 public: \ | |
| 100 Name(const Type& value) : value_(value) {} \ | |
| 101 void Dump(PrintStream& out) const { function(out, value_); } \ | |
| 102 \ | |
| 103 private: \ | |
| 104 Type value_; \ | |
| 105 } | |
| 106 | |
| 107 #define MAKE_PRINT_METHOD_ADAPTOR(Name, Type, method) \ | |
| 108 class Name final { \ | |
| 109 STACK_ALLOCATED(); \ | |
| 110 \ | |
| 111 public: \ | |
| 112 Name(const Type& value) : m_value(value) {} \ | |
| 113 void dump(PrintStream& out) const { m_value.method(out); } \ | |
| 114 \ | |
| 115 private: \ | |
| 116 const Type& m_value; \ | |
| 117 } | |
| 118 | |
| 119 #define MAKE_PRINT_METHOD(Type, dumpMethod, method) \ | |
| 120 MAKE_PRINT_METHOD_ADAPTOR(DumperFor_##method, Type, dumpMethod); \ | |
| 121 DumperFor_##method method() const { return DumperFor_##method(*this); } | |
| 122 | |
| 123 // Use an adaptor-based dumper for characters to avoid situations where | |
| 124 // you've "compressed" an integer to a character and it ends up printing | |
| 125 // as ASCII when you wanted it to print as a number. | |
| 126 void DumpCharacter(PrintStream&, char); | |
| 127 MAKE_PRINT_ADAPTOR(CharacterDump, char, DumpCharacter); | |
| 128 | |
| 129 } // namespace WTF | 95 } // namespace WTF |
| 130 | 96 |
| 131 using WTF::CharacterDump; | |
| 132 using WTF::PrintStream; | 97 using WTF::PrintStream; |
| 133 | 98 |
| 134 #endif // PrintStream_h | 99 #endif // PrintStream_h |
| OLD | NEW |