Show
Ignore:
Timestamp:
08/18/08 11:14:49 (5 months ago)
Author:
odole
Message:

merge with webkit revision 35814

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/JavaScriptCore/API/JSStringRefCF.cpp

    r396 r440  
    3030#include "APICast.h" 
    3131#include "JSStringRef.h" 
     32#include "OpaqueJSString.h" 
    3233#include <kjs/ustring.h> 
    3334#include <kjs/JSValue.h> 
    34  
    35 using namespace KJS; 
     35#include <wtf/OwnArrayPtr.h> 
    3636 
    3737JSStringRef JSStringCreateWithCFString(CFStringRef string) 
    3838{ 
    3939    CFIndex length = CFStringGetLength(string); 
    40     UString::Rep* rep; 
    41     if (!length) 
    42         rep = UString("").rep()->ref(); 
    43     else { 
    44         UniChar* buffer = static_cast<UniChar*>(fastMalloc(sizeof(UniChar) * length)); 
    45         CFStringGetCharacters(string, CFRangeMake(0, length), buffer); 
     40    if (length) { 
     41        OwnArrayPtr<UniChar> buffer(new UniChar[length]); 
     42        CFStringGetCharacters(string, CFRangeMake(0, length), buffer.get()); 
    4643        COMPILE_ASSERT(sizeof(UniChar) == sizeof(UChar), unichar_and_uchar_must_be_same_size); 
    47         rep = UString(reinterpret_cast<UChar*>(buffer), length, false).rep()->ref(); 
     44        return OpaqueJSString::create(reinterpret_cast<UChar*>(buffer.get()), length).releaseRef(); 
     45    } else { 
     46        return OpaqueJSString::create(0, 0).releaseRef(); 
    4847    } 
    49     return toRef(rep); 
    50 
     48    } 
    5149 
    5250CFStringRef JSStringCopyCFString(CFAllocatorRef alloc, JSStringRef string) 
    5351{ 
    54     UString::Rep* rep = toJS(string); 
    55     return CFStringCreateWithCharacters(alloc, reinterpret_cast<const UniChar*>(rep->data()), rep->size()); 
     52    return CFStringCreateWithCharacters(alloc, reinterpret_cast<const UniChar*>(string->characters()), string->length()); 
    5653}