| Index: Source/bindings/dart/DartScriptValue.h
|
| diff --git a/Source/bindings/dart/DartScriptValue.h b/Source/bindings/dart/DartScriptValue.h
|
| index 4da4128a7c05f3d9e3e7cf26db55b611b1456440..e4da7d7d5a0fa0feaefe6ad0a9ccc8ad75b3ff82 100644
|
| --- a/Source/bindings/dart/DartScriptValue.h
|
| +++ b/Source/bindings/dart/DartScriptValue.h
|
| @@ -1,5 +1,5 @@
|
| /*
|
| - * Copyright (C) 2012 Google Inc. All rights reserved.
|
| + * Copyright (C) 2014 Google Inc. All rights reserved.
|
| *
|
| * Redistribution and use in source and binary forms, with or without
|
| * modification, are permitted provided that the following conditions are
|
| @@ -31,26 +31,110 @@
|
| #ifndef DartScriptValue_h
|
| #define DartScriptValue_h
|
|
|
| -#include "bindings/dart/DartIsolateDestructionObserver.h"
|
| -
|
| +#include "bindings/common/AbstractScriptValue.h"
|
| +#include "bindings/dart/V8Converter.h"
|
| +#include "wtf/PassRefPtr.h"
|
| +#include "wtf/RefPtr.h"
|
| +#include "wtf/text/WTFString.h"
|
| #include <dart_api.h>
|
| -#include <wtf/Noncopyable.h>
|
| -#include <wtf/RefPtr.h>
|
|
|
| namespace WebCore {
|
|
|
| -class DartScriptValue : public DartIsolateDestructionObserver {
|
| +class JSONValue;
|
| +class ScriptState;
|
| +
|
| +class DartScriptValue : public AbstractScriptValue {
|
| WTF_MAKE_NONCOPYABLE(DartScriptValue);
|
| public:
|
| - explicit DartScriptValue(Dart_Handle value);
|
| - ~DartScriptValue();
|
| + virtual ~DartScriptValue();
|
| +
|
| + static PassRefPtr<DartScriptValue> create(Dart_Handle value)
|
| + {
|
| + return adoptRef(new DartScriptValue(value));
|
| + }
|
| +
|
| + static PassRefPtr<DartScriptValue> create()
|
| + {
|
| + return adoptRef(new DartScriptValue());
|
| + }
|
| +
|
| + bool isDart() const { return true; }
|
| +
|
| + Dart_Handle dartValue() const { return m_value; }
|
| +
|
| + v8::Handle<v8::Value> v8Value() const
|
| + {
|
| + // FIXMEMUTLIVM: Should not be converting v8 values. Major culprit is IDB.
|
| + Dart_Handle exception = 0;
|
| + return V8Converter::toV8(m_value, exception);
|
| + }
|
| +
|
| + bool equals(AbstractScriptValue* other) const
|
| + {
|
| + if (!other->isDart())
|
| + return false;
|
| +
|
| + DartScriptValue* dartOther = static_cast<DartScriptValue*>(other);
|
| + if (hasNoValue())
|
| + return dartOther->hasNoValue();
|
| + if (dartOther->hasNoValue())
|
| + return false;
|
| + return Dart_IdentityEquals(m_value, dartOther->m_value);
|
| + }
|
|
|
| - Dart_PersistentHandle value() { return m_value; }
|
| + bool isFunction() const
|
| + {
|
| + ASSERT(!hasNoValue());
|
| + return Dart_IsClosure(m_value);
|
| + }
|
| +
|
| + bool isNull() const
|
| + {
|
| + ASSERT(!hasNoValue());
|
| + return Dart_IsNull(m_value);
|
| + }
|
| +
|
| + bool isUndefined() const
|
| + {
|
| + ASSERT(!hasNoValue());
|
| + return false;
|
| + }
|
| +
|
| + bool isObject() const
|
| + {
|
| + ASSERT(!hasNoValue());
|
| + return true;
|
| + }
|
| +
|
| + bool hasNoValue() const
|
| + {
|
| + return !m_value;
|
| + }
|
| +
|
| + void clear()
|
| + {
|
| + m_value = 0;
|
| + }
|
| +
|
| + bool getString(String& result) const;
|
| + String toString() const;
|
| +
|
| + PassRefPtr<JSONValue> toJSONValue(ScriptState*) const;
|
|
|
| private:
|
| - Dart_PersistentHandle m_value;
|
| + Dart_Handle m_value;
|
| +
|
| + explicit DartScriptValue()
|
| + : m_value(0)
|
| + {
|
| + }
|
| +
|
| + explicit DartScriptValue(Dart_Handle value)
|
| + : m_value(value)
|
| + {
|
| + }
|
| };
|
|
|
| -}
|
| +} // namespace WebCore
|
|
|
| #endif // DartScriptValue_h
|
|
|