#ifndef OpaqueJSString_h
#define OpaqueJSString_h
-#include <runtime/UString.h>
+#include <wtf/ThreadSafeRefCounted.h>
+#include <wtf/text/WTFString.h>
namespace JSC {
class Identifier;
- class JSGlobalData;
+ class VM;
}
struct OpaqueJSString : public ThreadSafeRefCounted<OpaqueJSString> {
return adoptRef(new OpaqueJSString);
}
+ static PassRefPtr<OpaqueJSString> create(const LChar* characters, unsigned length)
+ {
+ return adoptRef(new OpaqueJSString(characters, length));
+ }
+
static PassRefPtr<OpaqueJSString> create(const UChar* characters, unsigned length)
{
return adoptRef(new OpaqueJSString(characters, length));
}
- static PassRefPtr<OpaqueJSString> create(const JSC::UString&);
+ JS_EXPORT_PRIVATE static PassRefPtr<OpaqueJSString> 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>;
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