X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/14957cd040308e3eeec43d26bae5d76da13fcd85..8b637bb680022adfddad653280734877951535a9:/API/OpaqueJSString.h?ds=sidebyside diff --git a/API/OpaqueJSString.h b/API/OpaqueJSString.h index 69c0962..c374b56 100644 --- a/API/OpaqueJSString.h +++ b/API/OpaqueJSString.h @@ -26,11 +26,12 @@ #ifndef OpaqueJSString_h #define OpaqueJSString_h -#include +#include +#include namespace JSC { class Identifier; - class JSGlobalData; + class VM; } struct OpaqueJSString : public ThreadSafeRefCounted { @@ -40,42 +41,50 @@ struct OpaqueJSString : public ThreadSafeRefCounted { return adoptRef(new OpaqueJSString); } + static PassRefPtr create(const LChar* characters, unsigned length) + { + return adoptRef(new OpaqueJSString(characters, length)); + } + static PassRefPtr create(const UChar* characters, unsigned length) { return adoptRef(new OpaqueJSString(characters, length)); } - static PassRefPtr create(const JSC::UString&); + JS_EXPORT_PRIVATE static PassRefPtr create(const String&); - UChar* characters() { return this ? m_characters : 0; } - unsigned length() { return this ? m_length : 0; } + const UChar* characters() { return !!this ? m_string.characters() : 0; } + unsigned length() { return !!this ? m_string.length() : 0; } - JSC::UString ustring() const; - JSC::Identifier identifier(JSC::JSGlobalData*) const; + JS_EXPORT_PRIVATE String string() const; + JSC::Identifier identifier(JSC::VM*) const; +#if PLATFORM(QT) + QString qString() const { return m_string; } +#endif private: friend class WTF::ThreadSafeRefCounted; OpaqueJSString() - : m_characters(0) - , m_length(0) { } - OpaqueJSString(const UChar* characters, unsigned length) - : m_length(length) + OpaqueJSString(const String& string) + : m_string(string.isolatedCopy()) { - m_characters = new UChar[length]; - memcpy(m_characters, characters, length * sizeof(UChar)); } - ~OpaqueJSString() + OpaqueJSString(const LChar* characters, unsigned length) + { + m_string = String(characters, length); + } + + OpaqueJSString(const UChar* characters, unsigned length) { - delete[] m_characters; + m_string = String(characters, length); } - UChar* m_characters; - unsigned m_length; + String m_string; }; #endif