Changeset 65344 in webkit for trunk/JavaScriptCore/runtime


Ignore:
Timestamp:
Aug 13, 2010, 6:28:27 PM (15 years ago)
Author:
[email protected]
Message:

Switch String::/UString::ascii() to return a CString.

Rubber stamped by Sam Weinig.

JavaScriptCore:

(JSC::CodeBlock::dump):

  • bytecode/SamplingTool.cpp:

(JSC::SamplingTool::dump):

  • interpreter/CallFrame.cpp:

(JSC::CallFrame::dumpCaller):

  • jsc.cpp:

(runWithScripts):
(runInteractive):

  • runtime/Identifier.h:

(JSC::Identifier::ascii):

  • runtime/ScopeChain.cpp:

(JSC::ScopeChainNode::print):

  • runtime/UString.cpp:

(JSC::UString::ascii):
(JSC::UString::latin1):

  • runtime/UString.h:
  • wtf/text/StringImpl.cpp:

(WTF::StringImpl::asciiOLD):

  • wtf/text/StringImpl.h:
  • wtf/text/WTFString.cpp:

(WTF::String::ascii):
(WTF::String::latin1):

  • wtf/text/WTFString.h:

WebCore:

  • WebCore.xcodeproj/project.pbxproj:
  • bridge/c/c_class.cpp:

(JSC::Bindings::CClass::methodsNamed):
(JSC::Bindings::CClass::fieldNamed):

  • bridge/jni/jsc/JNIBridgeJSC.cpp:

(JavaField::valueFromInstance):
(JavaField::setValueToInstance):

  • bridge/jni/jsc/JavaInstanceJSC.cpp:

(JavaInstance::invokeMethod):

  • bridge/objc/objc_class.mm:

(JSC::Bindings::ObjcClass::methodsNamed):
(JSC::Bindings::ObjcClass::fieldNamed):

  • bridge/objc/objc_instance.mm:

(ObjcInstance::setValueOfUndefinedField):
(ObjcInstance::getValueOfUndefinedField):

  • loader/icon/IconRecord.cpp:
  • platform/sql/SQLiteDatabase.cpp:
  • platform/sql/SQLiteStatement.cpp:
  • storage/SQLStatement.cpp:

WebKit:

  • WebKit.xcodeproj/project.pbxproj:

WebKit/mac:

  • Plugins/Hosted/ProxyInstance.mm:

(WebKit::ProxyInstance::methodsNamed):
(WebKit::ProxyInstance::fieldNamed):

Location:
trunk/JavaScriptCore/runtime
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/Identifier.h

    r65305 r65344  
    5151        int length() const { return m_string.length(); }
    5252       
    53         const char* ascii() const { return m_string.ascii(); }
     53        CString ascii() const { return m_string.ascii(); }
    5454       
    5555        static Identifier from(ExecState* exec, unsigned y);
  • trunk/JavaScriptCore/runtime/ScopeChain.cpp

    r48774 r65344  
    4444        for (PropertyNameArray::const_iterator propIter = propertyNames.begin(); propIter != propEnd; propIter++) {
    4545            Identifier name = *propIter;
    46             fprintf(stderr, "%s, ", name.ascii());
     46            fprintf(stderr, "%s, ", name.ustring().utf8().data());
    4747        }
    4848        fprintf(stderr, "\n");
  • trunk/JavaScriptCore/runtime/UString.cpp

    r65305 r65344  
    205205}
    206206
    207 char* UString::ascii() const
    208 {
    209     static char* asciiBuffer = 0;
    210 
    211     unsigned len = length();
    212     unsigned neededSize = len + 1;
    213     delete[] asciiBuffer;
    214     asciiBuffer = new char[neededSize];
    215 
    216     const UChar* p = characters();
    217     char* q = asciiBuffer;
    218     const UChar* limit = p + len;
    219     while (p != limit) {
    220         *q = static_cast<char>(p[0]);
    221         ++p;
    222         ++q;
    223     }
    224     *q = '\0';
    225 
    226     return asciiBuffer;
    227 }
    228 
    229207static inline bool isInfinity(double number)
    230208{
     
    584562}
    585563
     564CString UString::ascii() const
     565{
     566    // Basic Latin1 (ISO) encoding - Unicode characters 0..255 are
     567    // preserved, characters outside of this range are converted to '?'.
     568
     569    unsigned length = this->length();
     570    const UChar* characters = this->characters();
     571
     572    char* characterBuffer;
     573    CString result = CString::newUninitialized(length, characterBuffer);
     574
     575    for (unsigned i = 0; i < length; ++i) {
     576        UChar ch = characters[i];
     577        characterBuffer[i] = ch && (ch < 0x20 || ch >= 0x7f) ? '?' : ch;
     578    }
     579
     580    return result;
     581}
     582
     583CString UString::latin1() const
     584{
     585    // Basic Latin1 (ISO) encoding - Unicode characters 0..255 are
     586    // preserved, characters outside of this range are converted to '?'.
     587
     588    unsigned length = this->length();
     589    const UChar* characters = this->characters();
     590
     591    char* characterBuffer;
     592    CString result = CString::newUninitialized(length, characterBuffer);
     593
     594    for (unsigned i = 0; i < length; ++i) {
     595        UChar ch = characters[i];
     596        characterBuffer[i] = ch > 0xff ? '?' : ch;
     597    }
     598
     599    return result;
     600}
     601
    586602// Helper to write a three-byte UTF-8 code point to the buffer, caller must check room is available.
    587603static inline void putUTF8Triple(char*& buffer, UChar ch)
  • trunk/JavaScriptCore/runtime/UString.h

    r65305 r65344  
    8888    }
    8989
     90    CString ascii() const;
     91    CString latin1() const;
    9092    CString utf8(bool strict = false) const;
    9193
     
    120122
    121123    UString substr(unsigned pos = 0, unsigned len = 0xFFFFFFFF) const;
    122 
    123     // NOTE: This method should only be used for *debugging* purposes as it
    124     // is neither Unicode safe nor free from side effects nor thread-safe.
    125     char* ascii() const;
    126124
    127125private:
Note: See TracChangeset for help on using the changeset viewer.