| 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 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 #include "wtf/PrintStream.h" | 26 #include "wtf/PrintStream.h" |
| 27 | 27 |
| 28 #include "wtf/text/CString.h" | 28 #include "wtf/text/CString.h" |
| 29 #include "wtf/text/WTFString.h" | 29 #include "wtf/text/WTFString.h" |
| 30 #include <stdio.h> | 30 #include <stdio.h> |
| 31 | 31 |
| 32 namespace WTF { | 32 namespace WTF { |
| 33 | 33 |
| 34 PrintStream::PrintStream() {} | 34 PrintStream::PrintStream() {} |
| 35 PrintStream::~PrintStream() {} // Force the vtable to be in this module | 35 PrintStream::~PrintStream() {} // Force the vtable to be in this module |
| 36 | 36 |
| 37 void PrintStream::printf(const char* format, ...) | 37 void PrintStream::printf(const char* format, ...) { |
| 38 { | 38 va_list argList; |
| 39 va_list argList; | 39 va_start(argList, format); |
| 40 va_start(argList, format); | 40 vprintf(format, argList); |
| 41 vprintf(format, argList); | 41 va_end(argList); |
| 42 va_end(argList); | |
| 43 } | 42 } |
| 44 | 43 |
| 45 void PrintStream::flush() | 44 void PrintStream::flush() {} |
| 46 { | 45 |
| 46 void printInternal(PrintStream& out, const char* string) { |
| 47 out.printf("%s", string); |
| 47 } | 48 } |
| 48 | 49 |
| 49 void printInternal(PrintStream& out, const char* string) | 50 void printInternal(PrintStream& out, const CString& string) { |
| 50 { | 51 out.print(string.data()); |
| 51 out.printf("%s", string); | |
| 52 } | 52 } |
| 53 | 53 |
| 54 void printInternal(PrintStream& out, const CString& string) | 54 void printInternal(PrintStream& out, const String& string) { |
| 55 { | 55 out.print(string.utf8()); |
| 56 out.print(string.data()); | |
| 57 } | 56 } |
| 58 | 57 |
| 59 void printInternal(PrintStream& out, const String& string) | 58 void printInternal(PrintStream& out, bool value) { |
| 60 { | 59 if (value) |
| 61 out.print(string.utf8()); | 60 out.print("true"); |
| 61 else |
| 62 out.print("false"); |
| 62 } | 63 } |
| 63 | 64 |
| 64 void printInternal(PrintStream& out, bool value) | 65 void printInternal(PrintStream& out, int value) { |
| 65 { | 66 out.printf("%d", value); |
| 66 if (value) | |
| 67 out.print("true"); | |
| 68 else | |
| 69 out.print("false"); | |
| 70 } | 67 } |
| 71 | 68 |
| 72 void printInternal(PrintStream& out, int value) | 69 void printInternal(PrintStream& out, unsigned value) { |
| 73 { | 70 out.printf("%u", value); |
| 74 out.printf("%d", value); | |
| 75 } | 71 } |
| 76 | 72 |
| 77 void printInternal(PrintStream& out, unsigned value) | 73 void printInternal(PrintStream& out, long value) { |
| 78 { | 74 out.printf("%ld", value); |
| 79 out.printf("%u", value); | |
| 80 } | 75 } |
| 81 | 76 |
| 82 void printInternal(PrintStream& out, long value) | 77 void printInternal(PrintStream& out, unsigned long value) { |
| 83 { | 78 out.printf("%lu", value); |
| 84 out.printf("%ld", value); | |
| 85 } | 79 } |
| 86 | 80 |
| 87 void printInternal(PrintStream& out, unsigned long value) | 81 void printInternal(PrintStream& out, long long value) { |
| 88 { | 82 out.printf("%lld", value); |
| 89 out.printf("%lu", value); | |
| 90 } | 83 } |
| 91 | 84 |
| 92 void printInternal(PrintStream& out, long long value) | 85 void printInternal(PrintStream& out, unsigned long long value) { |
| 93 { | 86 out.printf("%llu", value); |
| 94 out.printf("%lld", value); | |
| 95 } | 87 } |
| 96 | 88 |
| 97 void printInternal(PrintStream& out, unsigned long long value) | 89 void printInternal(PrintStream& out, float value) { |
| 98 { | 90 out.print(static_cast<double>(value)); |
| 99 out.printf("%llu", value); | |
| 100 } | 91 } |
| 101 | 92 |
| 102 void printInternal(PrintStream& out, float value) | 93 void printInternal(PrintStream& out, double value) { |
| 103 { | 94 out.printf("%lf", value); |
| 104 out.print(static_cast<double>(value)); | |
| 105 } | 95 } |
| 106 | 96 |
| 107 void printInternal(PrintStream& out, double value) | 97 void dumpCharacter(PrintStream& out, char value) { |
| 108 { | 98 out.printf("%c", value); |
| 109 out.printf("%lf", value); | |
| 110 } | 99 } |
| 111 | 100 |
| 112 void dumpCharacter(PrintStream& out, char value) | 101 } // namespace WTF |
| 113 { | |
| 114 out.printf("%c", value); | |
| 115 } | |
| 116 | |
| 117 } // namespace WTF | |
| 118 | |
| OLD | NEW |