[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

barraclough at apple.com barraclough at apple.com
Wed Dec 22 12:02:30 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit f1dafcfd4489fa528752956ec080c3b0b0c15f54
Author: barraclough at apple.com <barraclough at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Aug 13 01:05:10 2010 +0000

    Change UString constructors to match those in WTF::String.
    This changes behaviour of UString((char*)0) to create null
    strings, akin to UString() rather than UString::empty().
    (This matches String).  Remove unused constructors from
    UString, and add null-terminated UTF-16 constructor, to
    match String.  Move String's constructor into the .cpp to
    match UString.
    
    Reviewed by Sam Weinig
    
    * JavaScriptCore.exp:
    * debugger/DebuggerCallFrame.cpp:
    (JSC::DebuggerCallFrame::calculatedFunctionName):
    * runtime/RegExpKey.h:
    (JSC::RegExpKey::RegExpKey):
    * runtime/SmallStrings.cpp:
    (JSC::SmallStrings::createSingleCharacterString):
    * runtime/UString.cpp:
    (JSC::UString::UString):
    * runtime/UString.h:
    (JSC::UString::UString):
    (JSC::UString::swap):
    (JSC::UString::adopt):
    (JSC::UString::operator[]):
    * wtf/text/WTFString.h:
    (WTF::String::String):
    (WTF::String::adopt):
    (WTF::String::operator[]):
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65286 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index acd6396..3ffb511 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,34 @@
+2010-08-12  Gavin Barraclough  <barraclough at apple.com>
+
+        Reviewed by Sam Weinig
+
+        Change UString constructors to match those in WTF::String.
+        This changes behaviour of UString((char*)0) to create null
+        strings, akin to UString() rather than UString::empty().
+        (This matches String).  Remove unused constructors from
+        UString, and add null-terminated UTF-16 constructor, to
+        match String.  Move String's constructor into the .cpp to
+        match UString.
+
+        * JavaScriptCore.exp:
+        * debugger/DebuggerCallFrame.cpp:
+        (JSC::DebuggerCallFrame::calculatedFunctionName):
+        * runtime/RegExpKey.h:
+        (JSC::RegExpKey::RegExpKey):
+        * runtime/SmallStrings.cpp:
+        (JSC::SmallStrings::createSingleCharacterString):
+        * runtime/UString.cpp:
+        (JSC::UString::UString):
+        * runtime/UString.h:
+        (JSC::UString::UString):
+        (JSC::UString::swap):
+        (JSC::UString::adopt):
+        (JSC::UString::operator[]):
+        * wtf/text/WTFString.h:
+        (WTF::String::String):
+        (WTF::String::adopt):
+        (WTF::String::operator[]):
+
 2010-08-12  David Levin  <levin at chromium.org>
 
         Reviewed by NOBODY (build fix).
diff --git a/JavaScriptCore/JavaScriptCore.exp b/JavaScriptCore/JavaScriptCore.exp
index 66201cd..a7a8588 100644
--- a/JavaScriptCore/JavaScriptCore.exp
+++ b/JavaScriptCore/JavaScriptCore.exp
@@ -255,8 +255,6 @@ __ZN3JSC7UString6numberEd
 __ZN3JSC7UString6numberEi
 __ZN3JSC7UString6numberEj
 __ZN3JSC7UString6numberEl
-__ZN3JSC7UStringC1EPKc
-__ZN3JSC7UStringC1EPKtj
 __ZN3JSC8Debugger23recompileAllJSFunctionsEPNS_12JSGlobalDataE
 __ZN3JSC8Debugger6attachEPNS_14JSGlobalObjectE
 __ZN3JSC8Debugger6detachEPNS_14JSGlobalObjectE
@@ -442,7 +440,10 @@ __ZN3WTF6String6removeEji
 __ZN3WTF6String8fromUTF8EPKc
 __ZN3WTF6String8fromUTF8EPKcm
 __ZN3WTF6String8truncateEj
+__ZN3WTF6StringC1EPKc
+__ZN3WTF6StringC1EPKcj
 __ZN3WTF6StringC1EPKt
+__ZN3WTF6StringC1EPKtj
 __ZN3WTF6strtodEPKcPPc
 __ZN3WTF7CString11mutableDataEv
 __ZN3WTF7CString16newUninitializedEmRPc
diff --git a/JavaScriptCore/debugger/DebuggerCallFrame.cpp b/JavaScriptCore/debugger/DebuggerCallFrame.cpp
index da9cb52..32f65dd 100644
--- a/JavaScriptCore/debugger/DebuggerCallFrame.cpp
+++ b/JavaScriptCore/debugger/DebuggerCallFrame.cpp
@@ -57,7 +57,7 @@ UString DebuggerCallFrame::calculatedFunctionName() const
 
     JSObject* function = m_callFrame->callee();
     if (!function || !function->inherits(&JSFunction::info))
-        return 0;
+        return UString();
 
     return asFunction(function)->calculatedDisplayName(m_callFrame);
 }
diff --git a/JavaScriptCore/runtime/RegExpKey.h b/JavaScriptCore/runtime/RegExpKey.h
index dccad08..e2ea100 100644
--- a/JavaScriptCore/runtime/RegExpKey.h
+++ b/JavaScriptCore/runtime/RegExpKey.h
@@ -58,6 +58,12 @@ struct RegExpKey {
     {
     }
 
+    RegExpKey(int flags, const RefPtr<StringImpl>& pattern)
+        : flagsValue(flags)
+        , pattern(pattern)
+    {
+    }
+
     RegExpKey(const UString& flags, const UString& pattern)
         : pattern(pattern.impl())
     {
diff --git a/JavaScriptCore/runtime/SmallStrings.cpp b/JavaScriptCore/runtime/SmallStrings.cpp
index 752fbb0..f358727 100644
--- a/JavaScriptCore/runtime/SmallStrings.cpp
+++ b/JavaScriptCore/runtime/SmallStrings.cpp
@@ -129,7 +129,7 @@ void SmallStrings::createSingleCharacterString(JSGlobalData* globalData, unsigne
     if (!m_storage)
         m_storage = adoptPtr(new SmallStringsStorage);
     ASSERT(!m_singleCharacterStrings[character]);
-    m_singleCharacterStrings[character] = new (globalData) JSString(globalData, m_storage->rep(character), JSString::HasOtherOwner);
+    m_singleCharacterStrings[character] = new (globalData) JSString(globalData, PassRefPtr<StringImpl>(m_storage->rep(character)), JSString::HasOtherOwner);
 }
 
 StringImpl* SmallStrings::singleCharacterStringRep(unsigned char character)
diff --git a/JavaScriptCore/runtime/UString.cpp b/JavaScriptCore/runtime/UString.cpp
index 32305db..b884647 100644
--- a/JavaScriptCore/runtime/UString.cpp
+++ b/JavaScriptCore/runtime/UString.cpp
@@ -56,20 +56,29 @@ extern const double Inf;
 
 COMPILE_ASSERT(sizeof(UString) == sizeof(void*), UString_should_stay_small);
 
-UString::UString(const char* c)
-    : m_impl(StringImpl::create(c))
+//    UString::UString(const UChar* characters, unsigned length)
+//        : m_impl(characters ? StringImpl::create(characters, length) : 0)
+//    {
+//    }
+UString::UString(const UChar* characters)
 {
-}
+    if (!characters)
+        return;
 
-UString::UString(const char* c, unsigned length)
-    : m_impl(StringImpl::create(c, length))
-{
-}
+    int length = 0;
+    while (characters[length] != UChar(0))
+        ++length;
 
-UString::UString(const UChar* c, unsigned length)
-    : m_impl(StringImpl::create(c, length))
-{
+    m_impl = StringImpl::create(characters, length);
 }
+//    UString::UString(const char* characters)
+//        : m_impl(characters ? StringImpl::create(characters) : 0)
+//    {
+//    }
+//    UString::UString(const char* characters, unsigned length)
+//        : m_impl(characters ? StringImpl::create(characters, length) : 0)
+//    {
+//    }
 
 UString UString::number(int i)
 {
@@ -210,13 +219,6 @@ char* UString::ascii() const
     return asciiBuffer;
 }
 
-UChar UString::operator[](unsigned pos) const
-{
-    if (pos >= length())
-        return '\0';
-    return characters()[pos];
-}
-
 static inline bool isInfinity(double number)
 {
     return number == Inf || number == -Inf;
diff --git a/JavaScriptCore/runtime/UString.h b/JavaScriptCore/runtime/UString.h
index 8d41c30..0aef693 100644
--- a/JavaScriptCore/runtime/UString.h
+++ b/JavaScriptCore/runtime/UString.h
@@ -43,29 +43,40 @@ using WTF::PlacementNewAdopt;
 
 class UString {
 public:
-    UString() {}
-    UString(const char*); // Constructor for null-terminated string.
-    UString(const char*, unsigned length);
-    UString(const UChar*, unsigned length);
-    UString(const Vector<UChar>& buffer);
-
-    UString(const UString& s)
-        : m_impl(s.m_impl)
+    // Construct a null string, distinguishable from an empty string.
+    UString() { }
+
+    // Construct a string with UTF-16 data.
+    UString(const UChar* characters, unsigned length)
+        : m_impl(characters ? StringImpl::create(characters, length) : 0)
     {
     }
 
-    // Special constructor for cases where we overwrite an object in place.
-    UString(PlacementNewAdoptType)
-        : m_impl(PlacementNewAdopt)
+    // Construct a string with UTF-16 data, from a null-terminated source.
+    UString(const UChar*);
+
+    // Construct a string with latin1 data.
+    UString(const char* characters)
+        : m_impl(characters ? StringImpl::create(characters) : 0)
     {
     }
 
-    template<size_t inlineCapacity>
-    static PassRefPtr<StringImpl> adopt(Vector<UChar, inlineCapacity>& vector)
+    // Construct a string with latin1 data, from a null-terminated source.
+    UString(const char* characters, unsigned length)
+        : m_impl(characters ? StringImpl::create(characters, length) : 0)
     {
-        return StringImpl::adopt(vector);
     }
 
+    // Construct a string referencing an existing StringImpl.
+    UString(StringImpl* impl) : m_impl(impl) { }
+    UString(PassRefPtr<StringImpl> impl) : m_impl(impl) { }
+    UString(RefPtr<StringImpl> impl) : m_impl(impl) { }
+
+    void swap(UString& o) { m_impl.swap(o.m_impl); }
+
+    template<size_t inlineCapacity>
+    static UString adopt(Vector<UChar, inlineCapacity>& vector) { return StringImpl::adopt(vector); }
+
     static UString number(int);
     static UString number(long long);
     static UString number(unsigned);
@@ -100,7 +111,12 @@ public:
         return m_impl->characters();
     }
 
-    UChar operator[](unsigned pos) const;
+    UChar operator[](unsigned index) const
+    {
+        if (!m_impl || index >= m_impl->length())
+            return 0;
+        return m_impl->characters()[index];
+    }
 
     double toDouble(bool tolerateTrailingJunk, bool tolerateEmptyString) const;
     double toDouble(bool tolerateTrailingJunk) const;
@@ -125,11 +141,6 @@ public:
 
     StringImpl* impl() const { return m_impl.get(); }
 
-    UString(PassRefPtr<StringImpl> r)
-        : m_impl(r)
-    {
-    }
-
     size_t cost() const
     {
         if (!m_impl)
diff --git a/JavaScriptCore/wtf/text/WTFString.cpp b/JavaScriptCore/wtf/text/WTFString.cpp
index 6c4de6e..901a121 100644
--- a/JavaScriptCore/wtf/text/WTFString.cpp
+++ b/JavaScriptCore/wtf/text/WTFString.cpp
@@ -36,6 +36,13 @@ namespace WTF {
 
 using namespace Unicode;
 
+// Construct a string with UTF-16 data.
+String::String(const UChar* characters, unsigned length)
+    : m_impl(characters ? StringImpl::create(characters, length) : 0)
+{
+}
+
+// Construct a string with UTF-16 data, from a null-terminated source.
 String::String(const UChar* str)
 {
     if (!str)
@@ -48,6 +55,18 @@ String::String(const UChar* str)
     m_impl = StringImpl::create(str, len);
 }
 
+// Construct a string with latin1 data.
+String::String(const char* characters, unsigned length)
+    : m_impl(characters ? StringImpl::create(characters, length) : 0)
+{
+}
+
+// Construct a string with latin1 data, from a null-terminated source.
+String::String(const char* characters)
+    : m_impl(characters ? StringImpl::create(characters) : 0)
+{
+}
+
 void String::append(const String& str)
 {
     if (str.isEmpty())
diff --git a/JavaScriptCore/wtf/text/WTFString.h b/JavaScriptCore/wtf/text/WTFString.h
index 4921d18..bd30eed 100644
--- a/JavaScriptCore/wtf/text/WTFString.h
+++ b/JavaScriptCore/wtf/text/WTFString.h
@@ -77,29 +77,25 @@ int reverseFind(const UChar*, size_t, UChar, int startPosition = -1);
 
 class String {
 public:
-    String() { } // gives null string, distinguishable from an empty string
-    String(const UChar* str, unsigned len)
-    {
-        if (!str)
-            return;
-        m_impl = StringImpl::create(str, len);
-    }
-    String(const char* str)
-    {
-        if (!str)
-            return;
-        m_impl = StringImpl::create(str);
-    }
-    String(const char* str, unsigned length)
-    {
-        if (!str)
-            return;
-        m_impl = StringImpl::create(str, length);
-    }
-    String(const UChar*); // Specifically for null terminated UTF-16
-    String(StringImpl* i) : m_impl(i) { }
-    String(PassRefPtr<StringImpl> i) : m_impl(i) { }
-    String(RefPtr<StringImpl> i) : m_impl(i) { }
+    // Construct a null string, distinguishable from an empty string.
+    String() { }
+
+    // Construct a string with UTF-16 data.
+    String(const UChar* characters, unsigned length);
+
+    // Construct a string with UTF-16 data, from a null-terminated source.
+    String(const UChar*);
+
+    // Construct a string with latin1 data.
+    String(const char* characters, unsigned length);
+
+    // Construct a string with latin1 data, from a null-terminated source.
+    String(const char* characters);
+
+    // Construct a string referencing an existing StringImpl.
+    String(StringImpl* impl) : m_impl(impl) { }
+    String(PassRefPtr<StringImpl> impl) : m_impl(impl) { }
+    String(RefPtr<StringImpl> impl) : m_impl(impl) { }
 
     void swap(String& o) { m_impl.swap(o.m_impl); }
 
@@ -108,7 +104,9 @@ public:
     bool isHashTableDeletedValue() const { return m_impl.isHashTableDeletedValue(); }
 
     static String adopt(StringBuffer& buffer) { return StringImpl::adopt(buffer); }
-    static String adopt(Vector<UChar>& vector) { return StringImpl::adopt(vector); }
+    template<size_t inlineCapacity>
+    static String adopt(Vector<UChar, inlineCapacity>& vector) { return StringImpl::adopt(vector); }
+
 
     ALWAYS_INLINE unsigned length() const
     {
@@ -126,11 +124,11 @@ public:
 
     const UChar* charactersWithNullTermination();
     
-    UChar operator[](unsigned i) const // if i >= length(), returns 0
+    UChar operator[](unsigned index) const
     {
-        if (!m_impl || i >= m_impl->length())
+        if (!m_impl || index >= m_impl->length())
             return 0;
-        return m_impl->characters()[i];
+        return m_impl->characters()[index];
     }
     UChar32 characterStartingAt(unsigned) const; // Ditto.
     

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list