Changeset 33374 in webkit for trunk/JavaScriptCore/API


Ignore:
Timestamp:
May 13, 2008, 2:46:47 AM (17 years ago)
Author:
[email protected]
Message:

Reviewed by Geoffrey Garen.

<rdar://problem/4949018> JavaScriptCore API claims to work with UTF8 strings, but only works
with ASCII strings


  • kjs/ustring.h:
  • kjs/ustring.cpp: (KJS::UString::Rep::createFromUTF8): Added. Implementation adapted from JSStringCreateWithUTF8CString().
  • API/JSStringRef.cpp: (JSStringCreateWithUTF8CString):
  • API/JSClassRef.cpp: (OpaqueJSClass::OpaqueJSClass): Use UString::Rep::createFromUTF8().
Location:
trunk/JavaScriptCore/API
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/API/JSClassRef.cpp

    r33038 r33374  
    4040
    4141OpaqueJSClass::OpaqueJSClass(const JSClassDefinition* definition, OpaqueJSClass* protoClass)
    42     // FIXME: <rdar://problem/4949018>
    43     : className(definition->className)
     42    : className(UString::Rep::createFromUTF8(definition->className))
    4443    , parentClass(definition->parentClass)
    4544    , prototypeClass(0)
     
    6261        staticValues = new StaticValuesTable();
    6362        while (staticValue->name) {
    64             // FIXME: <rdar://problem/4949018>
    65             staticValues->add(Identifier(staticValue->name).ustring().rep(),
     63            staticValues->add(Identifier(UString::Rep::createFromUTF8(staticValue->name).get()).ustring().rep(),
    6664                              new StaticValueEntry(staticValue->getProperty, staticValue->setProperty, staticValue->attributes));
    6765            ++staticValue;
     
    7270        staticFunctions = new StaticFunctionsTable();
    7371        while (staticFunction->name) {
    74             // FIXME: <rdar://problem/4949018>
    75             staticFunctions->add(Identifier(staticFunction->name).ustring().rep(),
     72            staticFunctions->add(Identifier(UString::Rep::createFromUTF8(staticFunction->name).get()).ustring().rep(),
    7673                                 new StaticFunctionEntry(staticFunction->callAsFunction, staticFunction->attributes));
    7774            ++staticFunction;
  • trunk/JavaScriptCore/API/JSStringRef.cpp

    r30942 r33374  
    5252    JSLock lock;
    5353
    54     size_t length = strlen(string);
    55     Vector<UChar, 1024> buffer(length);
    56     UChar* p = buffer.data();
    57     if (conversionOK != convertUTF8ToUTF16(&string, string + length, &p, p + length))
     54    RefPtr<UString::Rep> result = UString::Rep::createFromUTF8(string);
     55    if (result.get() == &UString::Rep::null)
    5856        return 0;
    5957
    60     return toRef(UString(buffer.data(), p - buffer.data()).rep()->ref());
     58    return toRef(result.release().releaseRef());
    6159}
    6260
Note: See TracChangeset for help on using the changeset viewer.