Ignore:
Timestamp:
Apr 20, 2010, 12:28:41 PM (15 years ago)
Author:
[email protected]
Message:

Bug 37828 - Move WebCore's String classes to WTF

Reviewed by Geoff Garen.

Move these classes up to WTF so they are available to all clients of WTF (in
particular JSC).

As a first patch, making the most minimal change possible, since this patch
could easily grow rather large since we'll have to change every class forward
declaration ( e.g. every "namespace WebCore { class String; }" much change to
"namespace WTF { class String; }").

JavaScriptCore:

Moving the files, but leaving the classes logically in the WebCore namespace -
which is technically a layering violation - I'll come back and fix this up in a
subsequent patch.

  • Android.mk:
  • Android.v8.wtf.mk:
  • GNUmakefile.am:
  • JavaScriptCore.exp:
  • JavaScriptCore.gypi:
  • JavaScriptCore.pro:
  • JavaScriptCore.vcproj/WTF/WTF.vcproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • config.h:
  • wtf/StaticConstructors.h: Copied from WebCore/platform/StaticConstructors.h.
  • wtf/text/AtomicString.cpp: Copied from WebCore/platform/text/AtomicString.cpp.
  • wtf/text/AtomicString.h: Copied from WebCore/platform/text/AtomicString.h.
  • wtf/text/AtomicStringImpl.h: Copied from WebCore/platform/text/AtomicStringImpl.h.
  • wtf/text/StringBuffer.h: Copied from WebCore/platform/text/StringBuffer.h.
  • wtf/text/StringHash.h: Copied from WebCore/platform/text/StringHash.h.
  • wtf/text/StringImpl.cpp: Copied from WebCore/platform/text/StringImpl.cpp.
  • wtf/text/StringImpl.h: Copied from WebCore/platform/text/StringImpl.h.
  • wtf/text/WTFString.cpp: Copied from WebCore/platform/text/String.cpp.

(WebCore::charactersToFloat):

  • wtf/text/WTFString.h: Copied from WebCore/platform/text/PlatformString.h.

WebCore:

Moving the files, but leaving the classes logically in the WebCore namespace –
which is technically a layering violation – I'll come back and fix this up in a
subsequent patch.

  • Android.mk:
  • ForwardingHeaders/wtf/StaticConstructors.h: Added.
  • ForwardingHeaders/wtf/text/AtomicString.h: Added.
  • ForwardingHeaders/wtf/text/AtomicStringImpl.h: Added.
  • ForwardingHeaders/wtf/text/StringBuffer.h: Added.
  • ForwardingHeaders/wtf/text/StringHash.h: Added.
  • ForwardingHeaders/wtf/text/StringImpl.h: Added.
  • ForwardingHeaders/wtf/text/WTFString.h: Added.
  • GNUmakefile.am:
  • WebCore.gypi:
  • WebCore.pro:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • css/MediaFeatureNames.cpp:
  • dom/QualifiedName.cpp:
  • dom/make_names.pl:
  • platform/StaticConstructors.h: Removed.
  • platform/text/AtomicString.cpp: Removed.
  • platform/text/AtomicString.h:
  • platform/text/AtomicStringImpl.h:
  • platform/text/PlatformString.h:
  • platform/text/String.cpp:
  • platform/text/StringHash.h:
  • platform/text/StringImpl.cpp: Removed.
  • platform/text/StringImpl.h:
File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/text/WTFString.cpp

    r57828 r57904  
    2121
    2222#include "config.h"
    23 #include "PlatformString.h"
    24 
    25 #include "FloatConversion.h"
    26 #include "SharedBuffer.h"
    27 #include "StringBuffer.h"
    28 #include "TextBreakIterator.h"
     23#include "WTFString.h"
     24
    2925#include <limits>
    3026#include <stdarg.h>
     
    641637}
    642638
    643 #ifndef NDEBUG
    644639Vector<char> String::ascii() const
    645640{
     
    655650    return buffer;
    656651}
    657 #endif
    658652
    659653CString String::latin1() const
     
    951945{
    952946    // FIXME: This will return ok even when the string fits into a double but not a float.
    953     return narrowPrecisionToFloat(charactersToDouble(data, length, ok));
    954 }
    955 
    956 PassRefPtr<SharedBuffer> utf8Buffer(const String& string)
    957 {
    958     // Allocate a buffer big enough to hold all the characters.
    959     const int length = string.length();
    960     Vector<char> buffer(length * 3);
    961 
    962     // Convert to runs of 8-bit characters.
    963     char* p = buffer.data();
    964     const UChar* d = string.characters();
    965     ConversionResult result = convertUTF16ToUTF8(&d, d + length, &p, p + buffer.size(), true);
    966     if (result != conversionOK)
    967         return 0;
    968 
    969     buffer.shrink(p - buffer.data());
    970     return SharedBuffer::adoptVector(buffer);
    971 }
    972 
    973 unsigned numGraphemeClusters(const String& s)
    974 {
    975     TextBreakIterator* it = characterBreakIterator(s.characters(), s.length());
    976     if (!it)
    977         return s.length();
    978 
    979     unsigned num = 0;
    980     while (textBreakNext(it) != TextBreakDone)
    981         ++num;
    982     return num;
    983 }
    984 
    985 unsigned numCharactersInGraphemeClusters(const String& s, unsigned numGraphemeClusters)
    986 {
    987     TextBreakIterator* it = characterBreakIterator(s.characters(), s.length());
    988     if (!it)
    989         return min(s.length(), numGraphemeClusters);
    990 
    991     for (unsigned i = 0; i < numGraphemeClusters; ++i) {
    992         if (textBreakNext(it) == TextBreakDone)
    993             return s.length();
    994     }
    995     return textBreakCurrent(it);
     947    return static_cast<float>(charactersToDouble(data, length, ok));
    996948}
    997949
Note: See TracChangeset for help on using the changeset viewer.