Title: [136539] trunk/Source
Revision
136539
Author
fpi...@apple.com
Date
2012-12-04 11:29:13 -0800 (Tue, 04 Dec 2012)

Log Message

Replace JSValue::description() with JSValue::dump(PrintStream&)
https://bugs.webkit.org/show_bug.cgi?id=103866

Reviewed by Darin Adler.

Source/_javascript_Core: 

JSValue now has a dump() method. Anywhere that you would have wanted to use
description(), you can either do toCString(value).data(), or if the callee
is a print()/dataLog() method then you just pass the value directly.

* _javascript_Core.vcproj/_javascript_Core/_javascript_Core.def:
* bytecode/CodeBlock.cpp:
(JSC::valueToSourceString):
(JSC::CodeBlock::finalizeUnconditionally):
* bytecode/ValueProfile.h:
(JSC::ValueProfileBase::dump):
* bytecode/ValueRecovery.h:
(JSC::ValueRecovery::dump):
* dfg/DFGAbstractValue.h:
(JSC::DFG::AbstractValue::dump):
* dfg/DFGGraph.cpp:
(JSC::DFG::Graph::dump):
* interpreter/Interpreter.cpp:
(JSC::Interpreter::dumpRegisters):
* jsc.cpp:
(functionDescribe):
* llint/LLIntSlowPaths.cpp:
(JSC::LLInt::llint_trace_value):
* runtime/JSValue.cpp:
(JSC::JSValue::dump):
* runtime/JSValue.h:

Source/WTF: 

Make it easier to get a String from a StringPrintStream.

* wtf/StringPrintStream.cpp:
(WTF::StringPrintStream::toString):
* wtf/StringPrintStream.h:
(StringPrintStream):
(WTF::toString):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (136538 => 136539)


--- trunk/Source/_javascript_Core/ChangeLog	2012-12-04 19:28:13 UTC (rev 136538)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-12-04 19:29:13 UTC (rev 136539)
@@ -1,3 +1,36 @@
+2012-12-03  Filip Pizlo  <fpi...@apple.com>
+
+        Replace JSValue::description() with JSValue::dump(PrintStream&)
+        https://bugs.webkit.org/show_bug.cgi?id=103866
+
+        Reviewed by Darin Adler.
+
+        JSValue now has a dump() method. Anywhere that you would have wanted to use
+        description(), you can either do toCString(value).data(), or if the callee
+        is a print()/dataLog() method then you just pass the value directly.
+
+        * _javascript_Core.vcproj/_javascript_Core/_javascript_Core.def:
+        * bytecode/CodeBlock.cpp:
+        (JSC::valueToSourceString):
+        (JSC::CodeBlock::finalizeUnconditionally):
+        * bytecode/ValueProfile.h:
+        (JSC::ValueProfileBase::dump):
+        * bytecode/ValueRecovery.h:
+        (JSC::ValueRecovery::dump):
+        * dfg/DFGAbstractValue.h:
+        (JSC::DFG::AbstractValue::dump):
+        * dfg/DFGGraph.cpp:
+        (JSC::DFG::Graph::dump):
+        * interpreter/Interpreter.cpp:
+        (JSC::Interpreter::dumpRegisters):
+        * jsc.cpp:
+        (functionDescribe):
+        * llint/LLIntSlowPaths.cpp:
+        (JSC::LLInt::llint_trace_value):
+        * runtime/JSValue.cpp:
+        (JSC::JSValue::dump):
+        * runtime/JSValue.h:
+
 2012-12-04  Filip Pizlo  <fpi...@apple.com>
 
         jsc command line tool's support for typed arrays should be robust against array buffer allocation errors

Modified: trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def (136538 => 136539)


--- trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def	2012-12-04 19:28:13 UTC (rev 136538)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def	2012-12-04 19:29:13 UTC (rev 136539)
@@ -11,7 +11,6 @@
     ??0DropAllLocks@JSLock@JSC@@QAE@PAVJSGlobalData@2@@Z
     ??0DynamicGlobalObjectScope@JSC@@QAE@AAVJSGlobalData@1@PAVJSGlobalObject@1@@Z 
     ??0ErrorHandlingMode@Interpreter@JSC@@QAE@PAVExecState@2@@Z
-    ??1ErrorHandlingMode@Interpreter@JSC@@QAE@XZ
     ??0InstrumentedPointerBase@MemoryInstrumentation@WTF@@QAE@PAVMemoryObjectInfo@2@@Z
     ??0InternalFunction@JSC@@IAE@PAVJSGlobalObject@1@PAVStructure@1@@Z
     ??0JSGlobalObject@JSC@@IAE@AAVJSGlobalData@1@PAVStructure@1@PBUGlobalObjectMethodTable@1@@Z
@@ -27,6 +26,7 @@
     ??0RegExpObject@JSC@@IAE@PAVJSGlobalObject@1@PAVStructure@1@PAVRegExp@1@@Z
     ??0SHA1@WTF@@QAE@XZ
     ??0StringObject@JSC@@IAE@AAVJSGlobalData@1@PAVStructure@1@@Z
+    ??0StringPrintStream@WTF@@QAE@XZ
     ??0Structure@JSC@@AAE@AAVJSGlobalData@1@PAVJSGlobalObject@1@VJSValue@1@ABVTypeInfo@1@PBUClassInfo@1@EH@Z
     ??0ThreadCondition@WTF@@QAE@XZ
     ??0WTFThreadData@WTF@@QAE@XZ
@@ -36,6 +36,7 @@
     ??1Collator@WTF@@QAE@XZ
     ??1Debugger@JSC@@UAE@XZ
     ??1DropAllLocks@JSLock@JSC@@QAE@XZ
+    ??1ErrorHandlingMode@Interpreter@JSC@@QAE@XZ
     ??1JSGlobalData@JSC@@QAE@XZ
     ??1JSGlobalObject@JSC@@QAE@XZ
     ??1JSLockHolder@JSC@@QAE@XZ
@@ -44,6 +45,7 @@
     ??1Mutex@WTF@@QAE@XZ
     ??1RefCountedLeakCounter@WTF@@QAE@XZ
     ??1SourceProviderCache@JSC@@QAE@XZ
+    ??1StringPrintStream@WTF@@UAE@XZ
     ??1ThreadCondition@WTF@@QAE@XZ
     ??1WeakHandleOwner@JSC@@UAE@XZ
     ??1WTFThreadData@WTF@@QAE@XZ
@@ -175,7 +177,6 @@
     ?deletePropertyByIndex@JSObject@JSC@@SA_NPAVJSCell@2@PAVExecState@2@I@Z
     ?deletePropertyByIndex@JSProxy@JSC@@KA_NPAVJSCell@2@PAVExecState@2@I@Z
     ?deleteTable@HashTable@JSC@@QBEXXZ
-    ?description@JSValue@JSC@@QBEPADXZ
     ?despecifyDictionaryFunction@Structure@JSC@@QAEXAAVJSGlobalData@2@VPropertyName@2@@Z
     ?despecifyFunctionTransition@Structure@JSC@@SAPAV12@AAVJSGlobalData@2@PAV12@VPropertyName@2@@Z
     ?destroy@JSCell@JSC@@KAXPAV12@@Z
@@ -186,6 +187,7 @@
     ?didTimeOut@TimeoutChecker@JSC@@QAE_NPAVExecState@2@@Z
     ?displayName@JSFunction@JSC@@QAE?AVString@WTF@@PAVExecState@2@@Z
     ?dtoa@WTF@@YAXQADNAA_NAAHAAI@Z
+    ?dump@JSValue@JSC@@QBEXAAVPrintStream@WTF@@@Z
     ?dumpAllOptions@Options@JSC@@SAXPAU_iobuf@@@Z
     ?dumpCallFrame@Interpreter@JSC@@QAEXPAVExecState@2@@Z
     ?dumpSampleData@JSGlobalData@JSC@@QAEXPAVExecState@2@@Z
@@ -384,6 +386,7 @@
     ?tlsKeyCount@WTF@@YAAAJXZ
     ?tlsKeys@WTF@@YAPAKXZ
     ?toBoolean@JSString@JSC@@QBE_NXZ
+    ?toCString@StringPrintStream@WTF@@QAE?AVCString@2@XZ
     ?toDouble@MediaTime@WTF@@QBENXZ 
     ?ToExponential@DoubleToStringConverter@double_conversion@WTF@@QBE_NNHPAVStringBuilder@23@@Z
     ?ToFixed@DoubleToStringConverter@double_conversion@WTF@@QBE_NNHPAVStringBuilder@23@@Z

Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp (136538 => 136539)


--- trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp	2012-12-04 19:28:13 UTC (rev 136538)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp	2012-12-04 19:29:13 UTC (rev 136539)
@@ -48,6 +48,7 @@
 #include "SlotVisitorInlines.h"
 #include <stdio.h>
 #include <wtf/StringExtras.h>
+#include <wtf/StringPrintStream.h>
 #include <wtf/UnusedParam.h>
 
 #if ENABLE(DFG_JIT)
@@ -99,7 +100,7 @@
     if (val.isString())
         return makeString("\"", escapeQuotes(val.toString(exec)->value(exec)), "\"");
 
-    return val.description();
+    return toString(val);
 }
 
 static CString constantName(ExecState* exec, int k, JSValue value)
@@ -2233,15 +2234,13 @@
                 JSCell* to = transition.m_to.get();
                 if ((!origin || Heap::isMarked(origin)) && Heap::isMarked(from))
                     continue;
-                dataLogF("    Transition under %s, ", JSValue(origin).description());
-                dataLogF("%s -> ", JSValue(from).description());
-                dataLogF("%s.\n", JSValue(to).description());
+                dataLog("    Transition under ", JSValue(origin), ", ", JSValue(from), " -> ", JSValue(to), ".\n");
             }
             for (unsigned i = 0; i < m_dfgData->weakReferences.size(); ++i) {
                 JSCell* weak = m_dfgData->weakReferences[i].get();
                 if (Heap::isMarked(weak))
                     continue;
-                dataLogF("    Weak reference %s.\n", JSValue(weak).description());
+                dataLog("    Weak reference ", JSValue(weak), ".\n");
             }
         }
         

Modified: trunk/Source/_javascript_Core/bytecode/ValueProfile.h (136538 => 136539)


--- trunk/Source/_javascript_Core/bytecode/ValueProfile.h	2012-12-04 19:28:13 UTC (rev 136538)
+++ trunk/Source/_javascript_Core/bytecode/ValueProfile.h	2012-12-04 19:29:13 UTC (rev 136539)
@@ -117,7 +117,7 @@
         if (m_singletonValueIsTop)
             out.printf("TOP");
         else
-            out.printf("%s", m_singletonValue.description());
+            out.print(m_singletonValue);
         bool first = true;
         for (unsigned i = 0; i < totalNumberOfBuckets; ++i) {
             JSValue value = JSValue::decode(m_buckets[i]);
@@ -127,7 +127,7 @@
                     first = false;
                 } else
                     out.printf(", ");
-                out.printf("%s", value.description());
+                out.print(value);
             }
         }
     }

Modified: trunk/Source/_javascript_Core/bytecode/ValueRecovery.h (136538 => 136539)


--- trunk/Source/_javascript_Core/bytecode/ValueRecovery.h	2012-12-04 19:28:13 UTC (rev 136538)
+++ trunk/Source/_javascript_Core/bytecode/ValueRecovery.h	2012-12-04 19:29:13 UTC (rev 136539)
@@ -331,7 +331,7 @@
             out.printf("arguments");
             break;
         case Constant:
-            out.printf("[%s]", constant().description());
+            out.print("[", constant(), "]");
             break;
         case DontKnow:
             out.printf("!");

Modified: trunk/Source/_javascript_Core/dfg/DFGAbstractValue.h (136538 => 136539)


--- trunk/Source/_javascript_Core/dfg/DFGAbstractValue.h	2012-12-04 19:28:13 UTC (rev 136538)
+++ trunk/Source/_javascript_Core/dfg/DFGAbstractValue.h	2012-12-04 19:29:13 UTC (rev 136539)
@@ -377,7 +377,7 @@
             "(", SpeculationDump(m_type), ", ", arrayModesToString(m_arrayModes), ", ",
             m_currentKnownStructure, ", ", m_futurePossibleStructure);
         if (!!m_value)
-            out.print(", ", m_value.description());
+            out.print(", ", m_value);
         out.print(")");
     }
     

Modified: trunk/Source/_javascript_Core/dfg/DFGGraph.cpp (136538 => 136539)


--- trunk/Source/_javascript_Core/dfg/DFGGraph.cpp	2012-12-04 19:28:13 UTC (rev 136538)
+++ trunk/Source/_javascript_Core/dfg/DFGGraph.cpp	2012-12-04 19:29:13 UTC (rev 136539)
@@ -245,7 +245,7 @@
         for (unsigned i = 0; i < node.numConstants(); ++i) {
             if (i)
                 out.print(", ");
-            out.print(m_codeBlock->constantBuffer(node.startConstant())[i].description());
+            out.print(m_codeBlock->constantBuffer(node.startConstant())[i]);
         }
         out.print("]");
         hasPrinted = true;
@@ -258,7 +258,7 @@
     if (op == JSConstant) {
         out.print(hasPrinted ? ", " : "", "$", node.constantNumber());
         JSValue value = valueOfJSConstant(nodeIndex);
-        out.print(" = ", value.description());
+        out.print(" = ", value);
         hasPrinted = true;
     }
     if (op == WeakJSConstant) {

Modified: trunk/Source/_javascript_Core/interpreter/Interpreter.cpp (136538 => 136539)


--- trunk/Source/_javascript_Core/interpreter/Interpreter.cpp	2012-12-04 19:28:13 UTC (rev 136538)
+++ trunk/Source/_javascript_Core/interpreter/Interpreter.cpp	2012-12-04 19:29:13 UTC (rev 136539)
@@ -67,6 +67,7 @@
 #include <limits.h>
 #include <stdio.h>
 #include <wtf/StackStats.h>
+#include <wtf/StringPrintStream.h>
 #include <wtf/Threading.h>
 #include <wtf/WTFThreadData.h>
 #include <wtf/text/StringBuilder.h>
@@ -401,7 +402,7 @@
         JSValue v = it->jsValue();
         int registerNumber = it - callFrame->registers();
         String name = codeBlock->nameForRegister(registerNumber);
-        dataLogF("[r% 3d %14s]      | %10p | %-16s 0x%lld \n", registerNumber, name.ascii().data(), it, v.description(), (long long)JSValue::encode(v));
+        dataLogF("[r% 3d %14s]      | %10p | %-16s 0x%lld \n", registerNumber, name.ascii().data(), it, toCString(v).data(), (long long)JSValue::encode(v));
         it++;
     }
     
@@ -436,7 +437,7 @@
             JSValue v = it->jsValue();
             int registerNumber = it - callFrame->registers();
             String name = codeBlock->nameForRegister(registerNumber);
-            dataLogF("[r% 3d %14s]      | %10p | %-16s 0x%lld \n", registerNumber, name.ascii().data(), it, v.description(), (long long)JSValue::encode(v));
+            dataLogF("[r% 3d %14s]      | %10p | %-16s 0x%lld \n", registerNumber, name.ascii().data(), it, toCString(v).data(), (long long)JSValue::encode(v));
             ++it;
             ++registerCount;
         } while (it != end);
@@ -447,7 +448,7 @@
     if (it != end) {
         do {
             JSValue v = (*it).jsValue();
-            dataLogF("[r% 3d]                     | %10p | %-16s 0x%lld \n", registerCount, it, v.description(), (long long)JSValue::encode(v));
+            dataLogF("[r% 3d]                     | %10p | %-16s 0x%lld \n", registerCount, it, toCString(v).data(), (long long)JSValue::encode(v));
             ++it;
             ++registerCount;
         } while (it != end);

Modified: trunk/Source/_javascript_Core/jsc.cpp (136538 => 136539)


--- trunk/Source/_javascript_Core/jsc.cpp	2012-12-04 19:28:13 UTC (rev 136538)
+++ trunk/Source/_javascript_Core/jsc.cpp	2012-12-04 19:29:13 UTC (rev 136539)
@@ -43,6 +43,7 @@
 #include <string.h>
 #include <wtf/CurrentTime.h>
 #include <wtf/MainThread.h>
+#include <wtf/StringPrintStream.h>
 #include <wtf/text/StringBuilder.h>
 
 #if !OS(WINDOWS)
@@ -311,7 +312,7 @@
 
 EncodedJSValue JSC_HOST_CALL functionDescribe(ExecState* exec)
 {
-    fprintf(stderr, "--> %s\n", exec->argument(0).description());
+    fprintf(stderr, "--> %s\n", toCString(exec->argument(0)).data());
     return JSValue::encode(jsUndefined());
 }
 

Modified: trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp (136538 => 136539)


--- trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp	2012-12-04 19:28:13 UTC (rev 136538)
+++ trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp	2012-12-04 19:29:13 UTC (rev 136539)
@@ -48,6 +48,7 @@
 #include "LLIntExceptions.h"
 #include "LowLevelInterpreter.h"
 #include "Operations.h"
+#include <wtf/StringPrintStream.h>
 
 namespace JSC { namespace LLInt {
 
@@ -184,17 +185,18 @@
         EncodedJSValue asValue;
     } u;
     u.asValue = JSValue::encode(value);
-    dataLogF("%p / %p: executing bc#%zu, op#%u: Trace(%d): %d: %d: %08x:%08x: %s\n",
-            exec->codeBlock(),
-            exec,
-            static_cast<intptr_t>(pc - exec->codeBlock()->instructions().begin()),
-            exec->globalData().interpreter->getOpcodeID(pc[0].u.opcode),
-            fromWhere,
-            operand,
-            pc[operand].u.operand,
-            u.bits.tag,
-            u.bits.payload,
-            value.description());
+    dataLogF(
+        "%p / %p: executing bc#%zu, op#%u: Trace(%d): %d: %d: %08x:%08x: %s\n",
+        exec->codeBlock(),
+        exec,
+        static_cast<intptr_t>(pc - exec->codeBlock()->instructions().begin()),
+        exec->globalData().interpreter->getOpcodeID(pc[0].u.opcode),
+        fromWhere,
+        operand,
+        pc[operand].u.operand,
+        u.bits.tag,
+        u.bits.payload,
+        toCString(value).data());
     LLINT_END_IMPL();
 }
 

Modified: trunk/Source/_javascript_Core/runtime/JSValue.cpp (136538 => 136539)


--- trunk/Source/_javascript_Core/runtime/JSValue.cpp	2012-12-04 19:28:13 UTC (rev 136538)
+++ trunk/Source/_javascript_Core/runtime/JSValue.cpp	2012-12-04 19:29:13 UTC (rev 136539)
@@ -193,51 +193,46 @@
         throwTypeError(exec, StrictModeReadonlyPropertyWriteError);
 }
 
-char* JSValue::description() const
+void JSValue::dump(PrintStream& out) const
 {
-    static const size_t size = 256;
-    static char description[size];
-
     if (!*this)
-        snprintf(description, size, "<JSValue()>");
+        out.print("<JSValue()>");
     else if (isInt32())
-        snprintf(description, size, "Int32: %d", asInt32());
+        out.printf("Int32: %d", asInt32());
     else if (isDouble()) {
 #if USE(JSVALUE64)
-        snprintf(description, size, "Double: %lld, %lf", (long long)reinterpretDoubleToInt64(asDouble()), asDouble());
+        out.printf("Double: %lld, %lf", (long long)reinterpretDoubleToInt64(asDouble()), asDouble());
 #else
         union {
             double asDouble;
             uint32_t asTwoInt32s[2];
         } u;
         u.asDouble = asDouble();
-        snprintf(description, size, "Double: %08x:%08x, %lf", u.asTwoInt32s[1], u.asTwoInt32s[0], asDouble());
+        out.printf("Double: %08x:%08x, %lf", u.asTwoInt32s[1], u.asTwoInt32s[0], asDouble());
 #endif
     } else if (isCell()) {
         if (asCell()->inherits(&Structure::s_info)) {
             Structure* structure = jsCast<Structure*>(asCell());
-            snprintf(
-                description, size, "Structure: %p: %s, %s",
+            out.printf(
+                "Structure: %p: %s, %s",
                 structure, structure->classInfo()->className,
                 indexingTypeToString(structure->indexingTypeIncludingHistory()));
         } else {
-            snprintf(
-                description, size, "Cell: %p -> %p (%p: %s, %s)",
+            out.printf(
+                "Cell: %p -> %p (%p: %s, %s)",
                 asCell(), isObject() ? asObject(*this)->butterfly() : 0, asCell()->structure(), asCell()->structure()->classInfo()->className,
                 indexingTypeToString(asCell()->structure()->indexingTypeIncludingHistory()));
         }
     } else if (isTrue())
-        snprintf(description, size, "True");
+        out.print("True");
     else if (isFalse())
-        snprintf(description, size, "False");
+        out.print("False");
     else if (isNull())
-        snprintf(description, size, "Null");
+        out.print("Null");
     else if (isUndefined())
-        snprintf(description, size, "Undefined");
+        out.print("Undefined");
     else
-        snprintf(description, size, "INVALID");
-
-    return description;
+        out.print("INVALID");
 }
 
 // This in the ToInt32 operation is defined in section 9.5 of the ECMA-262 spec.

Modified: trunk/Source/_javascript_Core/runtime/JSValue.h (136538 => 136539)


--- trunk/Source/_javascript_Core/runtime/JSValue.h	2012-12-04 19:28:13 UTC (rev 136538)
+++ trunk/Source/_javascript_Core/runtime/JSValue.h	2012-12-04 19:29:13 UTC (rev 136539)
@@ -258,7 +258,7 @@
         
     JSValue structureOrUndefined() const;
 
-    JS_EXPORT_PRIVATE char* description() const;
+    JS_EXPORT_PRIVATE void dump(PrintStream&) const;
 
     JS_EXPORT_PRIVATE JSObject* synthesizePrototype(ExecState*) const;
 

Modified: trunk/Source/WTF/ChangeLog (136538 => 136539)


--- trunk/Source/WTF/ChangeLog	2012-12-04 19:28:13 UTC (rev 136538)
+++ trunk/Source/WTF/ChangeLog	2012-12-04 19:29:13 UTC (rev 136539)
@@ -1,3 +1,18 @@
+2012-12-03  Filip Pizlo  <fpi...@apple.com>
+
+        Replace JSValue::description() with JSValue::dump(PrintStream&)
+        https://bugs.webkit.org/show_bug.cgi?id=103866
+
+        Reviewed by Darin Adler.
+
+        Make it easier to get a String from a StringPrintStream.
+
+        * wtf/StringPrintStream.cpp:
+        (WTF::StringPrintStream::toString):
+        * wtf/StringPrintStream.h:
+        (StringPrintStream):
+        (WTF::toString):
+
 2012-12-02  Filip Pizlo  <fpi...@apple.com>
 
         It should be possible to build and run with DFG_ENABLE(PROPAGATION_VERBOSE)

Modified: trunk/Source/WTF/wtf/StringPrintStream.cpp (136538 => 136539)


--- trunk/Source/WTF/wtf/StringPrintStream.cpp	2012-12-04 19:28:13 UTC (rev 136538)
+++ trunk/Source/WTF/wtf/StringPrintStream.cpp	2012-12-04 19:29:13 UTC (rev 136539)
@@ -92,6 +92,12 @@
     return CString(m_buffer, m_next);
 }
 
+String StringPrintStream::toString()
+{
+    ASSERT(m_next == strlen(m_buffer));
+    return String::fromUTF8(m_buffer, m_next);
+}
+
 void StringPrintStream::increaseSize(size_t newSize)
 {
     ASSERT(newSize > m_size);

Modified: trunk/Source/WTF/wtf/StringPrintStream.h (136538 => 136539)


--- trunk/Source/WTF/wtf/StringPrintStream.h	2012-12-04 19:28:13 UTC (rev 136538)
+++ trunk/Source/WTF/wtf/StringPrintStream.h	2012-12-04 19:29:13 UTC (rev 136539)
@@ -28,17 +28,19 @@
 
 #include <wtf/PrintStream.h>
 #include <wtf/text/CString.h>
+#include <wtf/text/WTFString.h>
 
 namespace WTF {
 
 class StringPrintStream : public PrintStream {
 public:
-    StringPrintStream();
-    ~StringPrintStream();
+    WTF_EXPORT_PRIVATE StringPrintStream();
+    WTF_EXPORT_PRIVATE ~StringPrintStream();
     
     virtual void vprintf(const char* format, va_list) WTF_ATTRIBUTE_PRINTF(2, 0);
     
-    CString toCString();
+    WTF_EXPORT_PRIVATE CString toCString();
+    WTF_EXPORT_PRIVATE String toString();
     
 private:
     void increaseSize(size_t);
@@ -58,10 +60,19 @@
     return stream.toCString();
 }
 
+template<typename T>
+String toString(const T& value)
+{
+    StringPrintStream stream;
+    stream.print(value);
+    return stream.toString();
+}
+
 } // namespace WTF
 
 using WTF::StringPrintStream;
 using WTF::toCString;
+using WTF::toString;
 
 #endif // StringPrintStream_h
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to