Changeset 15328 in webkit for trunk/JavaScriptCore/API/JSInternalStringRef.cpp
- Timestamp:
- Jul 10, 2006, 10:37:00 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/JSInternalStringRef.cpp
r15307 r15328 37 37 using namespace KJS; 38 38 39 JSValueRef JSStringMake(JSInternalStringRef buffer)39 JSValueRef JSStringMake(JSInternalStringRef string) 40 40 { 41 41 JSLock lock; 42 UString::Rep* rep = toJS( buffer);42 UString::Rep* rep = toJS(string); 43 43 return toRef(jsString(UString(rep))); 44 44 } … … 58 58 } 59 59 60 JSInternalStringRef JSInternalStringRetain(JSInternalStringRef buffer)60 JSInternalStringRef JSInternalStringRetain(JSInternalStringRef string) 61 61 { 62 UString::Rep* rep = toJS( buffer);62 UString::Rep* rep = toJS(string); 63 63 return toRef(rep->ref()); 64 64 } 65 65 66 void JSInternalStringRelease(JSInternalStringRef buffer)66 void JSInternalStringRelease(JSInternalStringRef string) 67 67 { 68 68 JSLock lock; 69 UString::Rep* rep = toJS( buffer);69 UString::Rep* rep = toJS(string); 70 70 rep->deref(); 71 71 } … … 77 77 ExecState* exec = toJS(context); 78 78 79 JSInternalStringRef charBufferRef = toRef(jsValue->toString(exec).rep()->ref());79 JSInternalStringRef stringRef = toRef(jsValue->toString(exec).rep()->ref()); 80 80 if (exec->hadException()) 81 81 exec->clearException(); 82 return charBufferRef;82 return stringRef; 83 83 } 84 84 85 size_t JSInternalStringGetLength(JSInternalStringRef buffer)85 size_t JSInternalStringGetLength(JSInternalStringRef string) 86 86 { 87 UString::Rep* rep = toJS( buffer);87 UString::Rep* rep = toJS(string); 88 88 return rep->size(); 89 89 } 90 90 91 const JSChar* JSInternalStringGetCharactersPtr(JSInternalStringRef buffer)91 const JSChar* JSInternalStringGetCharactersPtr(JSInternalStringRef string) 92 92 { 93 UString::Rep* rep = toJS( buffer);93 UString::Rep* rep = toJS(string); 94 94 return reinterpret_cast<const JSChar*>(rep->data()); 95 95 } 96 96 97 void JSInternalStringGetCharacters(JSInternalStringRef inBuffer, JSChar* outBuffer, size_t numChars)97 void JSInternalStringGetCharacters(JSInternalStringRef string, JSChar* buffer, size_t numChars) 98 98 { 99 UString::Rep* rep = toJS( inBuffer);99 UString::Rep* rep = toJS(string); 100 100 const JSChar* data = reinterpret_cast<const JSChar*>(rep->data()); 101 101 102 memcpy( outBuffer, data, numChars * sizeof(JSChar));102 memcpy(buffer, data, numChars * sizeof(JSChar)); 103 103 } 104 104 105 size_t JSInternalStringGetMaxLengthUTF8(JSInternalStringRef buffer)105 size_t JSInternalStringGetMaxLengthUTF8(JSInternalStringRef string) 106 106 { 107 UString::Rep* rep = toJS( buffer);107 UString::Rep* rep = toJS(string); 108 108 109 109 // Any UTF8 character > 3 bytes encodes as a UTF16 surrogate pair. … … 111 111 } 112 112 113 size_t JSInternalStringGetCharactersUTF8(JSInternalStringRef inBuffer, char* outBuffer, size_t bufferSize)113 size_t JSInternalStringGetCharactersUTF8(JSInternalStringRef string, char* buffer, size_t bufferSize) 114 114 { 115 115 JSLock lock; 116 UString::Rep* rep = toJS( inBuffer);116 UString::Rep* rep = toJS(string); 117 117 CString cString = UString(rep).UTF8String(); 118 118 119 119 size_t length = std::min(bufferSize, cString.size() + 1); // + 1 for terminating '\0' 120 memcpy( outBuffer, cString.c_str(), length);120 memcpy(buffer, cString.c_str(), length); 121 121 return length; 122 122 } … … 157 157 } 158 158 159 CFStringRef CFStringCreateWithJSInternalString(CFAllocatorRef alloc, JSInternalStringRef buffer)159 CFStringRef CFStringCreateWithJSInternalString(CFAllocatorRef alloc, JSInternalStringRef string) 160 160 { 161 UString::Rep* rep = toJS( buffer);161 UString::Rep* rep = toJS(string); 162 162 return CFStringCreateWithCharacters(alloc, reinterpret_cast<const JSChar*>(rep->data()), rep->size()); 163 163 }
Note:
See TracChangeset
for help on using the changeset viewer.