Chromium Code Reviews| Index: Source/WebCore/bindings/dart/DartUtilities.h |
| diff --git a/Source/WebCore/bindings/dart/DartUtilities.h b/Source/WebCore/bindings/dart/DartUtilities.h |
| index 1da2c5e07c9f659ec81f950aa13e0d60ced71ac6..54b5027dbe29d094d1367b2cad759769c7b8c000 100644 |
| --- a/Source/WebCore/bindings/dart/DartUtilities.h |
| +++ b/Source/WebCore/bindings/dart/DartUtilities.h |
| @@ -50,7 +50,19 @@ class ScriptExecutionContext; |
| class SerializedScriptValue; |
| class WebKitFlags; |
| -typedef HashMap<void*, Dart_Handle> DartDOMMap; |
| +class DartStringAdapter { |
| +public: |
| + explicit DartStringAdapter(PassRefPtr<StringImpl> stringImpl) |
| + : m_stringImpl(stringImpl) |
| + { |
| + } |
| + |
| + operator String() const { return String(m_stringImpl); } |
| + operator AtomicString() const { return AtomicString(m_stringImpl); } |
| + |
| +private: |
| + RefPtr<StringImpl> m_stringImpl; |
| +}; |
| class DartUtilities { |
| public: |
| @@ -61,16 +73,6 @@ public: |
| static const char* htmlLibraryName; |
| - static PassRefPtr<StringImpl> toStringImpl(Dart_Handle, ConversionFlag flag, Dart_Handle& exception); |
| - // FIXME: we should get rid of this one in favour of toStringImpl. |
| - static String dartStringToString(Dart_Handle object) |
| - { |
| - Dart_Handle exception = 0; |
| - RefPtr<StringImpl> impl = toStringImpl(object, ConvertNone, exception); |
| - ASSERT(!exception); |
| - return String(impl.release()); |
| - } |
| - |
| static Dart_Handle stringImplToDartString(StringImpl*); |
| static Dart_Handle stringToDartString(const String&); |
| static Dart_Handle stringToDartString(const AtomicString&); |
| @@ -96,6 +98,7 @@ public: |
| static void extractMapElements(Dart_Handle map, Dart_Handle& exception, Vector<Dart_Handle>& keys, Vector<Dart_Handle>& values); |
| static int64_t toInteger(Dart_Handle object, Dart_Handle& exception); |
| + static String toString(Dart_Handle object); |
| static void toMessagePortArray(Dart_Handle object, MessagePortArray&, ArrayBufferArray&, Dart_Handle& exception); |
| static PassRefPtr<SerializedScriptValue> toSerializedScriptValue(Dart_Handle object, MessagePortArray*, ArrayBufferArray*, Dart_Handle& exception); |
| static PassRefPtr<WebKitFlags> toWebKitFlags(Dart_Handle object, Dart_Handle& exception); |
| @@ -146,6 +149,17 @@ public: |
| static Dart_Handle invokeUtilsMethod(const char* methodName, int argCount, Dart_Handle* args); |
| + static DartStringAdapter dartToString(Dart_Handle object, Dart_Handle& exception) |
| + { |
| + // FIXME: [performance] need better treatment of String vs. AtomicString, cf. v8 implementation. |
| + return DartStringAdapter(toStringImpl(object, exception)); |
| + } |
| + static DartStringAdapter dartToStringWithNullCheck(Dart_Handle object, Dart_Handle& exception) |
|
Anton Muhin
2012/06/26 16:52:28
wdyt, do we need to distinguish those? maybe we s
podivilov
2012/06/26 18:07:38
Passing nulls to c++ methods is a bit scary... Als
|
| + { |
| + if (Dart_IsNull(object)) |
| + return DartStringAdapter(0); |
| + return dartToString(object, exception); |
| + } |
| static Dart_Handle stringToDart(const AtomicString& value, ConversionFlag flag = ConvertNone); |
| static Dart_Handle stringToDart(const String& value, ConversionFlag flag = ConvertNone); |
| @@ -195,6 +209,9 @@ public: |
| static PassRefPtr<SerializedScriptValue> dartToSerializedScriptValue(Dart_Handle, Dart_Handle& exception); |
| static Dart_Handle serializedScriptValueToDart(SerializedScriptValue* value); |
| + |
| +private: |
| + static PassRefPtr<StringImpl> toStringImpl(Dart_Handle object, Dart_Handle& exception); |
| }; |
| class DartApiScope { |