Ignore:
Timestamp:
Jan 17, 2014, 9:44:49 AM (12 years ago)
Author:
[email protected]
Message:

Get rid of OpaqueJSString::deprecatedCharacters()
https://bugs.webkit.org/show_bug.cgi?id=127161

Reviewed by Sam Weinig.

Handle OpaqueJSString::m_string being either 8-bit or 16-bit and add extra
code paths for the 8-bit cases.

Unfortunately, JSStringGetCharactersPtr is still expected to return a 16-bit character pointer.
Handle this by storing a separate 16-bit string and initializing it on demand when JSStringGetCharactersPtr
is called and the backing string is 8-bit.

This has the nice side effect of making JSStringGetCharactersPtr thread-safe when it wasn't before.
(In theory, someone could have a JSStringRef backed by an 8-bit string and call JSStringGetCharactersPtr on it
causing an unsafe upconversion to a 16-bit string).

  • API/JSStringRef.cpp:

(JSStringGetCharactersPtr):
Call OpaqueJSString::characters.

(JSStringGetUTF8CString):
Add a code path that handles 8-bit strings.

(JSStringIsEqual):
Call OpaqueJSString::equal.

  • API/JSStringRefCF.cpp:

(JSStringCreateWithCFString):
Reformat the code to use an early return instead of putting most of the code inside the body of an if statement.

(JSStringCopyCFString):
Create an 8-bit CFStringRef if possible.

  • API/OpaqueJSString.cpp:

(OpaqueJSString::create):
Use nullptr.

(OpaqueJSString::~OpaqueJSString):
Free m_characters.

(OpaqueJSString::characters):
Do the up-conversion and store the result in m_characters.

(OpaqueJSString::equal):
New helper function.

  • API/OpaqueJSString.h:

(OpaqueJSString::is8Bit):
New function that returns whether a string is 8-bit or not.

(OpaqueJSString::characters8):
(OpaqueJSString::characters16):
Add getters.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r162198 r162205  
     12014-01-17  Anders Carlsson  <[email protected]>
     2
     3        Get rid of OpaqueJSString::deprecatedCharacters()
     4        https://bugs.webkit.org/show_bug.cgi?id=127161
     5
     6        Reviewed by Sam Weinig.
     7
     8        Handle OpaqueJSString::m_string being either 8-bit or 16-bit and add extra
     9        code paths for the 8-bit cases.
     10       
     11        Unfortunately, JSStringGetCharactersPtr is still expected to return a 16-bit character pointer.
     12        Handle this by storing a separate 16-bit string and initializing it on demand when JSStringGetCharactersPtr
     13        is called and the backing string is 8-bit.
     14       
     15        This has the nice side effect of making JSStringGetCharactersPtr thread-safe when it wasn't before.
     16        (In theory, someone could have a JSStringRef backed by an 8-bit string and call JSStringGetCharactersPtr on it
     17        causing an unsafe upconversion to a 16-bit string).
     18
     19        * API/JSStringRef.cpp:
     20        (JSStringGetCharactersPtr):
     21        Call OpaqueJSString::characters.
     22
     23        (JSStringGetUTF8CString):
     24        Add a code path that handles 8-bit strings.
     25
     26        (JSStringIsEqual):
     27        Call OpaqueJSString::equal.
     28
     29        * API/JSStringRefCF.cpp:
     30        (JSStringCreateWithCFString):
     31        Reformat the code to use an early return instead of putting most of the code inside the body of an if statement.
     32
     33        (JSStringCopyCFString):
     34        Create an 8-bit CFStringRef if possible.
     35
     36        * API/OpaqueJSString.cpp:
     37        (OpaqueJSString::create):
     38        Use nullptr.
     39
     40        (OpaqueJSString::~OpaqueJSString):
     41        Free m_characters.
     42
     43        (OpaqueJSString::characters):
     44        Do the up-conversion and store the result in m_characters.
     45
     46        (OpaqueJSString::equal):
     47        New helper function.
     48
     49        * API/OpaqueJSString.h:
     50        (OpaqueJSString::is8Bit):
     51        New function that returns whether a string is 8-bit or not.
     52
     53        (OpaqueJSString::characters8):
     54        (OpaqueJSString::characters16):
     55        Add getters.
     56
    1572014-01-17  Peter Molnar  <[email protected]>
    258
Note: See TracChangeset for help on using the changeset viewer.