Changeset 83110 in webkit


Ignore:
Timestamp:
Apr 6, 2011 3:24:32 PM (13 years ago)
Author:
jeffm@apple.com
Message:

2011-04-06 Jeff Miller <jeffm@apple.com>

Reviewed by Adam Roben.

Add WKStringGetCharactersPtr() and WKStringGetLength() to WebKit2 C API
https://bugs.webkit.org/show_bug.cgi?id=57989


Note that WKChar, which is returned by WKStringGetCharactersPtr(), is defined the same way we define JSChar in JSStringRef.h.

  • Shared/API/c/WKString.cpp: (WKStringGetLength): Added. (WKStringGetCharactersPtr): Added.
  • Shared/API/c/WKString.h: Define WKChar and added WKStringGetLength() and WKStringGetCharactersPtr().
  • Shared/WebString.h: (WebKit::WebString::length): Added. (WebKit::WebString::characters): Added.
Location:
trunk/Source/WebKit2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r83109 r83110  
     12011-04-06  Jeff Miller  <jeffm@apple.com>
     2
     3        Reviewed by Adam Roben.
     4
     5        Add WKStringGetCharactersPtr() and WKStringGetLength() to WebKit2 C API
     6        https://bugs.webkit.org/show_bug.cgi?id=57989
     7       
     8        Note that WKChar, which is returned by WKStringGetCharactersPtr(), is defined the same way we define JSChar in JSStringRef.h.
     9
     10        * Shared/API/c/WKString.cpp:
     11        (WKStringGetLength): Added.
     12        (WKStringGetCharactersPtr): Added.
     13        * Shared/API/c/WKString.h: Define WKChar and added WKStringGetLength() and WKStringGetCharactersPtr().
     14        * Shared/WebString.h:
     15        (WebKit::WebString::length): Added.
     16        (WebKit::WebString::characters): Added.
     17
    1182011-04-06  Anders Carlsson  <andersca@apple.com>
    219
  • trunk/Source/WebKit2/Shared/API/c/WKString.cpp

    r81084 r83110  
    4848}
    4949
     50size_t WKStringGetLength(WKStringRef stringRef)
     51{
     52    return toImpl(stringRef)->length();
     53}
     54
     55const WKChar* WKStringGetCharactersPtr(WKStringRef stringRef)
     56{
     57    COMPILE_ASSERT(sizeof(WKChar) == sizeof(UChar), WKStringGetCharactersPtr_sizeof_WKChar_matches_UChar);
     58    return reinterpret_cast<const WKChar*>(toImpl(stringRef)->characters());
     59}
     60
    5061size_t WKStringGetMaximumUTF8CStringSize(WKStringRef stringRef)
    5162{
  • trunk/Source/WebKit2/Shared/API/c/WKString.h

    r81084 r83110  
    3737#endif
    3838
     39#if !defined(WIN32) && !defined(_WIN32) && !defined(__WINSCW__) \
     40    && !((defined(__CC_ARM) || defined(__ARMCC__)) && !defined(__linux__)) /* RVCT */
     41    typedef unsigned short WKChar;
     42#else
     43    typedef wchar_t WKChar;
     44#endif
     45
    3946WK_EXPORT WKTypeID WKStringGetTypeID();
    4047
     
    4249
    4350WK_EXPORT bool WKStringIsEmpty(WKStringRef string);
     51
     52WK_EXPORT size_t WKStringGetLength(WKStringRef string);
     53WK_EXPORT const WKChar* WKStringGetCharactersPtr(WKStringRef string);
    4454
    4555WK_EXPORT size_t WKStringGetMaximumUTF8CStringSize(WKStringRef string);
  • trunk/Source/WebKit2/Shared/WebString.h

    r81084 r83110  
    5858    bool isNull() const { return m_string.isNull(); }
    5959    bool isEmpty() const { return m_string.isEmpty(); }
     60   
     61    size_t length() const { return m_string.length(); }
     62    const UChar* characters() const { return m_string.characters(); }
    6063
    6164    size_t maximumUTF8CStringSize() const { return m_string.length() * 3 + 1; }
Note: See TracChangeset for help on using the changeset viewer.