Ignore:
Timestamp:
Jan 16, 2014, 10:50:26 PM (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. 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

    r162158 r162185  
     12014-01-16  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. This has the nice side effect of making JSStringGetCharactersPtr thread-safe when it wasn't before.
     14        (In theory, someone could have a JSStringRef backed by an 8-bit string and call JSStringGetCharactersPtr on it
     15        causing an unsafe upconversion to a 16-bit string).
     16
     17        * API/JSStringRef.cpp:
     18        (JSStringGetCharactersPtr):
     19        Call OpaqueJSString::characters.
     20
     21        (JSStringGetUTF8CString):
     22        Add a code path that handles 8-bit strings.
     23
     24        (JSStringIsEqual):
     25        Call OpaqueJSString::equal.
     26
     27        * API/JSStringRefCF.cpp:
     28        (JSStringCreateWithCFString):
     29        Reformat the code to use an early return instead of putting most of the code inside the body of an if statement.
     30
     31        (JSStringCopyCFString):
     32        Create an 8-bit CFStringRef if possible.
     33
     34        * API/OpaqueJSString.cpp:
     35        (OpaqueJSString::create):
     36        Use nullptr.
     37
     38        (OpaqueJSString::~OpaqueJSString):
     39        Free m_characters.
     40
     41        (OpaqueJSString::characters):
     42        Do the up-conversion and store the result in m_characters.
     43
     44        (OpaqueJSString::equal):
     45        New helper function.
     46
     47        * API/OpaqueJSString.h:
     48        (OpaqueJSString::is8Bit):
     49        New function that returns whether a string is 8-bit or not.
     50
     51        (OpaqueJSString::characters8):
     52        (OpaqueJSString::characters16):
     53        Add getters.
     54
    1552014-01-16  Anders Carlsson  <[email protected]>
    256
Note: See TracChangeset for help on using the changeset viewer.