Chromium Code Reviews| Index: Source/bindings/tests/results/core/UnionTypesCore.h |
| diff --git a/Source/bindings/tests/results/core/UnionTypesCore.h b/Source/bindings/tests/results/core/UnionTypesCore.h |
| index 59d2429fc17a4c01e825a79b8b12ba0dda17c87c..a19aab004620e07ed6fe4646525724826589d1fc 100644 |
| --- a/Source/bindings/tests/results/core/UnionTypesCore.h |
| +++ b/Source/bindings/tests/results/core/UnionTypesCore.h |
| @@ -7,32 +7,260 @@ |
| #ifndef UnionTypeCore_h |
| #define UnionTypeCore_h |
| +#include "bindings/core/v8/ExceptionState.h" |
| +#include "bindings/core/v8/V8Binding.h" |
| +#include "platform/heap/Handle.h" |
| + |
| namespace blink { |
| +class Node; |
| +class NodeList; |
| +class TestDictionary; |
| +class TestInterface; |
| +class TestInterfaceEmpty; |
| +class TestInterfaceGarbageCollected; |
| +class TestInterfaceWillBeGarbageCollected; |
| + |
| class LongSequenceOrStringArrayOrUnrestrictedDouble final { |
| - // FIXME: Implement |
| + ALLOW_ONLY_INLINE_ALLOCATION(); |
| +public: |
| + LongSequenceOrStringArrayOrUnrestrictedDouble(); |
| + bool isNull() const { return m_specificType == SpecificTypeNone; } |
| + |
| + bool isLongSequence() const { return m_specificType == SpecificTypeLongSequence; } |
| + const Vector<int>& getAsLongSequence(); |
| + void setLongSequence(const Vector<int>&); |
| + |
| + bool isStringArray() const { return m_specificType == SpecificTypeStringArray; } |
| + const Vector<String>& getAsStringArray(); |
| + void setStringArray(const Vector<String>&); |
| + |
| + bool isUnrestrictedDouble() const { return m_specificType == SpecificTypeUnrestrictedDouble; } |
| + double getAsUnrestrictedDouble(); |
| + void setUnrestrictedDouble(double); |
| + |
| +private: |
| + enum SpecificTypes { |
| + SpecificTypeNone, |
| + SpecificTypeLongSequence, |
| + SpecificTypeStringArray, |
| + SpecificTypeUnrestrictedDouble, |
| + }; |
| + SpecificTypes m_specificType; |
|
haraken
2014/10/29 04:59:30
Nit: 'Types m_type' might be enough.
bashi
2014/10/29 09:57:37
Done.
|
| + |
| + Vector<int> m_longSequence; |
| + Vector<String> m_stringArray; |
| + double m_unrestrictedDouble; |
| }; |
| +class V8LongSequenceOrStringArrayOrUnrestrictedDouble { |
|
haraken
2014/10/29 04:59:30
Add final.
bashi
2014/10/29 09:57:37
Done.
|
| +public: |
| + static void toImpl(v8::Isolate*, v8::Handle<v8::Value>, LongSequenceOrStringArrayOrUnrestrictedDouble&, ExceptionState&); |
| +}; |
| + |
| +v8::Handle<v8::Value> toV8(LongSequenceOrStringArrayOrUnrestrictedDouble&, v8::Handle<v8::Object>, v8::Isolate*); |
| + |
| +template <class CallbackInfo> |
| +inline void v8SetReturnValue(const CallbackInfo& callbackInfo, LongSequenceOrStringArrayOrUnrestrictedDouble& impl) |
|
haraken
2014/10/29 04:59:30
For now I'm fine with static toImpl(), toV8() and
bashi
2014/10/29 09:57:37
I'm not sure we could have benefits from ScriptWra
|
| +{ |
| + v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate())); |
| +} |
| + |
| class NodeOrNodeList final { |
| - // FIXME: Implement |
| + ALLOW_ONLY_INLINE_ALLOCATION(); |
| +public: |
| + NodeOrNodeList(); |
| + bool isNull() const { return m_specificType == SpecificTypeNone; } |
| + |
| + bool isNode() const { return m_specificType == SpecificTypeNode; } |
| + PassRefPtr<Node> getAsNode(); |
| + void setNode(PassRefPtr<Node>); |
| + |
| + bool isNodeList() const { return m_specificType == SpecificTypeNodeList; } |
| + PassRefPtr<NodeList> getAsNodeList(); |
| + void setNodeList(PassRefPtr<NodeList>); |
| + |
| +private: |
| + enum SpecificTypes { |
| + SpecificTypeNone, |
| + SpecificTypeNode, |
| + SpecificTypeNodeList, |
| + }; |
| + SpecificTypes m_specificType; |
| + |
| + RefPtr<Node> m_node; |
| + RefPtr<NodeList> m_nodeList; |
| +}; |
| + |
| +class V8NodeOrNodeList { |
| +public: |
| + static void toImpl(v8::Isolate*, v8::Handle<v8::Value>, NodeOrNodeList&, ExceptionState&); |
| }; |
| +v8::Handle<v8::Value> toV8(NodeOrNodeList&, v8::Handle<v8::Object>, v8::Isolate*); |
| + |
| +template <class CallbackInfo> |
| +inline void v8SetReturnValue(const CallbackInfo& callbackInfo, NodeOrNodeList& impl) |
| +{ |
| + v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate())); |
| +} |
| + |
| class StringOrDouble final { |
| - // FIXME: Implement |
| + ALLOW_ONLY_INLINE_ALLOCATION(); |
| +public: |
| + StringOrDouble(); |
| + bool isNull() const { return m_specificType == SpecificTypeNone; } |
| + |
| + bool isString() const { return m_specificType == SpecificTypeString; } |
| + String getAsString(); |
| + void setString(String); |
| + |
| + bool isDouble() const { return m_specificType == SpecificTypeDouble; } |
| + double getAsDouble(); |
| + void setDouble(double); |
| + |
| +private: |
| + enum SpecificTypes { |
| + SpecificTypeNone, |
| + SpecificTypeString, |
| + SpecificTypeDouble, |
| + }; |
| + SpecificTypes m_specificType; |
| + |
| + String m_string; |
| + double m_double; |
| }; |
| +class V8StringOrDouble { |
| +public: |
| + static void toImpl(v8::Isolate*, v8::Handle<v8::Value>, StringOrDouble&, ExceptionState&); |
| +}; |
| + |
| +v8::Handle<v8::Value> toV8(StringOrDouble&, v8::Handle<v8::Object>, v8::Isolate*); |
| + |
| +template <class CallbackInfo> |
| +inline void v8SetReturnValue(const CallbackInfo& callbackInfo, StringOrDouble& impl) |
| +{ |
| + v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate())); |
| +} |
| + |
| class TestInterfaceGarbageCollectedOrString final { |
| - // FIXME: Implement |
| + ALLOW_ONLY_INLINE_ALLOCATION(); |
| +public: |
| + TestInterfaceGarbageCollectedOrString(); |
| + bool isNull() const { return m_specificType == SpecificTypeNone; } |
| + |
| + bool isTestInterfaceGarbageCollected() const { return m_specificType == SpecificTypeTestInterfaceGarbageCollected; } |
| + PassRefPtr<TestInterfaceGarbageCollected> getAsTestInterfaceGarbageCollected(); |
| + void setTestInterfaceGarbageCollected(PassRefPtr<TestInterfaceGarbageCollected>); |
| + |
| + bool isString() const { return m_specificType == SpecificTypeString; } |
| + String getAsString(); |
| + void setString(String); |
| + |
| +private: |
| + enum SpecificTypes { |
| + SpecificTypeNone, |
| + SpecificTypeTestInterfaceGarbageCollected, |
| + SpecificTypeString, |
| + }; |
| + SpecificTypes m_specificType; |
| + |
| + RefPtr<TestInterfaceGarbageCollected> m_testInterfaceGarbageCollected; |
| + String m_string; |
| +}; |
| + |
| +class V8TestInterfaceGarbageCollectedOrString { |
| +public: |
| + static void toImpl(v8::Isolate*, v8::Handle<v8::Value>, TestInterfaceGarbageCollectedOrString&, ExceptionState&); |
| }; |
| +v8::Handle<v8::Value> toV8(TestInterfaceGarbageCollectedOrString&, v8::Handle<v8::Object>, v8::Isolate*); |
| + |
| +template <class CallbackInfo> |
| +inline void v8SetReturnValue(const CallbackInfo& callbackInfo, TestInterfaceGarbageCollectedOrString& impl) |
| +{ |
| + v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate())); |
| +} |
| + |
| class TestInterfaceOrTestInterfaceEmpty final { |
| - // FIXME: Implement |
| + ALLOW_ONLY_INLINE_ALLOCATION(); |
| +public: |
| + TestInterfaceOrTestInterfaceEmpty(); |
| + bool isNull() const { return m_specificType == SpecificTypeNone; } |
| + |
| + bool isTestInterface() const { return m_specificType == SpecificTypeTestInterface; } |
| + PassRefPtr<TestInterface> getAsTestInterface(); |
| + void setTestInterface(PassRefPtr<TestInterface>); |
| + |
| + bool isTestInterfaceEmpty() const { return m_specificType == SpecificTypeTestInterfaceEmpty; } |
| + PassRefPtr<TestInterfaceEmpty> getAsTestInterfaceEmpty(); |
| + void setTestInterfaceEmpty(PassRefPtr<TestInterfaceEmpty>); |
| + |
| +private: |
| + enum SpecificTypes { |
| + SpecificTypeNone, |
| + SpecificTypeTestInterface, |
| + SpecificTypeTestInterfaceEmpty, |
| + }; |
| + SpecificTypes m_specificType; |
| + |
| + RefPtr<TestInterface> m_testInterface; |
| + RefPtr<TestInterfaceEmpty> m_testInterfaceEmpty; |
| }; |
| +class V8TestInterfaceOrTestInterfaceEmpty { |
| +public: |
| + static void toImpl(v8::Isolate*, v8::Handle<v8::Value>, TestInterfaceOrTestInterfaceEmpty&, ExceptionState&); |
| +}; |
| + |
| +v8::Handle<v8::Value> toV8(TestInterfaceOrTestInterfaceEmpty&, v8::Handle<v8::Object>, v8::Isolate*); |
| + |
| +template <class CallbackInfo> |
| +inline void v8SetReturnValue(const CallbackInfo& callbackInfo, TestInterfaceOrTestInterfaceEmpty& impl) |
| +{ |
| + v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate())); |
| +} |
| + |
| class TestInterfaceWillBeGarbageCollectedOrTestDictionary final { |
| - // FIXME: Implement |
| + ALLOW_ONLY_INLINE_ALLOCATION(); |
| +public: |
| + TestInterfaceWillBeGarbageCollectedOrTestDictionary(); |
| + bool isNull() const { return m_specificType == SpecificTypeNone; } |
| + |
| + bool isTestInterfaceWillBeGarbageCollected() const { return m_specificType == SpecificTypeTestInterfaceWillBeGarbageCollected; } |
| + PassRefPtr<TestInterfaceWillBeGarbageCollected> getAsTestInterfaceWillBeGarbageCollected(); |
| + void setTestInterfaceWillBeGarbageCollected(PassRefPtr<TestInterfaceWillBeGarbageCollected>); |
| + |
| + bool isTestDictionary() const { return m_specificType == SpecificTypeTestDictionary; } |
| + PassRefPtr<TestDictionary> getAsTestDictionary(); |
| + void setTestDictionary(PassRefPtr<TestDictionary>); |
| + |
| +private: |
| + enum SpecificTypes { |
| + SpecificTypeNone, |
| + SpecificTypeTestInterfaceWillBeGarbageCollected, |
| + SpecificTypeTestDictionary, |
| + }; |
| + SpecificTypes m_specificType; |
| + |
| + RefPtr<TestInterfaceWillBeGarbageCollected> m_testInterfaceWillBeGarbageCollected; |
| + RefPtr<TestDictionary> m_testDictionary; |
| +}; |
| + |
| +class V8TestInterfaceWillBeGarbageCollectedOrTestDictionary { |
| +public: |
| + static void toImpl(v8::Isolate*, v8::Handle<v8::Value>, TestInterfaceWillBeGarbageCollectedOrTestDictionary&, ExceptionState&); |
| }; |
| +v8::Handle<v8::Value> toV8(TestInterfaceWillBeGarbageCollectedOrTestDictionary&, v8::Handle<v8::Object>, v8::Isolate*); |
| + |
| +template <class CallbackInfo> |
| +inline void v8SetReturnValue(const CallbackInfo& callbackInfo, TestInterfaceWillBeGarbageCollectedOrTestDictionary& impl) |
| +{ |
| + v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate())); |
| +} |
| + |
| } // namespace blink |
| #endif // UnionTypeCore_h |