Changeset 19059 in webkit for trunk/JavaScriptCore/API/JSStringRef.cpp
- Timestamp:
- Jan 23, 2007, 2:23:09 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/JSStringRef.cpp
r17372 r19059 47 47 { 48 48 JSLock lock; 49 // FIXME: Only works with ASCII 50 // Use decodeUTF8Sequence or http://www.unicode.org/Public/PROGRAMS/CVTUTF/ instead 49 // FIXME: <rdar://problem/4949018> 51 50 return toRef(UString(string).rep()->ref()); 52 51 } … … 112 111 return result; 113 112 } 114 115 #if defined(__APPLE__)116 JSStringRef JSStringCreateWithCFString(CFStringRef string)117 {118 JSLock lock;119 CFIndex length = CFStringGetLength(string);120 121 // Optimized path for when CFString backing store is a UTF16 buffer122 if (const UniChar* buffer = CFStringGetCharactersPtr(string)) {123 UString::Rep* rep = UString(reinterpret_cast<const UChar*>(buffer), length).rep()->ref();124 return toRef(rep);125 }126 127 UniChar* buffer = static_cast<UniChar*>(fastMalloc(sizeof(UniChar) * length));128 CFStringGetCharacters(string, CFRangeMake(0, length), buffer);129 UString::Rep* rep = UString(reinterpret_cast<UChar*>(buffer), length, false).rep()->ref();130 return toRef(rep);131 }132 133 CFStringRef JSStringCopyCFString(CFAllocatorRef alloc, JSStringRef string)134 {135 UString::Rep* rep = toJS(string);136 return CFStringCreateWithCharacters(alloc, reinterpret_cast<const JSChar*>(rep->data()), rep->size());137 }138 139 #endif // __APPLE__
Note:
See TracChangeset
for help on using the changeset viewer.