Commit 9fba5a50 authored by jeffm@apple.com's avatar jeffm@apple.com

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.


git-svn-id: svn://svn.chromium.org/blink/trunk@83110 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent f2eb6885
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.
2011-04-06 Anders Carlsson <andersca@apple.com>
Reviewed by Oliver Hunt.
......
......@@ -47,6 +47,17 @@ bool WKStringIsEmpty(WKStringRef stringRef)
return toImpl(stringRef)->isEmpty();
}
size_t WKStringGetLength(WKStringRef stringRef)
{
return toImpl(stringRef)->length();
}
const WKChar* WKStringGetCharactersPtr(WKStringRef stringRef)
{
COMPILE_ASSERT(sizeof(WKChar) == sizeof(UChar), WKStringGetCharactersPtr_sizeof_WKChar_matches_UChar);
return reinterpret_cast<const WKChar*>(toImpl(stringRef)->characters());
}
size_t WKStringGetMaximumUTF8CStringSize(WKStringRef stringRef)
{
return toImpl(stringRef)->maximumUTF8CStringSize();
......
......@@ -36,12 +36,22 @@
extern "C" {
#endif
#if !defined(WIN32) && !defined(_WIN32) && !defined(__WINSCW__) \
&& !((defined(__CC_ARM) || defined(__ARMCC__)) && !defined(__linux__)) /* RVCT */
typedef unsigned short WKChar;
#else
typedef wchar_t WKChar;
#endif
WK_EXPORT WKTypeID WKStringGetTypeID();
WK_EXPORT WKStringRef WKStringCreateWithUTF8CString(const char* string);
WK_EXPORT bool WKStringIsEmpty(WKStringRef string);
WK_EXPORT size_t WKStringGetLength(WKStringRef string);
WK_EXPORT const WKChar* WKStringGetCharactersPtr(WKStringRef string);
WK_EXPORT size_t WKStringGetMaximumUTF8CStringSize(WKStringRef string);
WK_EXPORT size_t WKStringGetUTF8CString(WKStringRef string, char* buffer, size_t bufferSize);
......
......@@ -57,6 +57,9 @@ public:
bool isNull() const { return m_string.isNull(); }
bool isEmpty() const { return m_string.isEmpty(); }
size_t length() const { return m_string.length(); }
const UChar* characters() const { return m_string.characters(); }
size_t maximumUTF8CStringSize() const { return m_string.length() * 3 + 1; }
size_t getUTF8CString(char* buffer, size_t bufferSize)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment