Chromium Code Reviews| Index: Source/wtf/UnionType.h |
| diff --git a/Source/wtf/UnionType.h b/Source/wtf/UnionType.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..dd13f20d65a4a77ceb45723009f03925115f02cc |
| --- /dev/null |
| +++ b/Source/wtf/UnionType.h |
| @@ -0,0 +1,48 @@ |
| +#ifndef UnionType_h |
|
haraken
2013/05/15 10:56:25
You need to add a copyright.
|
| +#define UnionType_h |
| + |
| +namespace WTF { |
| + |
| +template<typename Type0, typename Type1> |
| +class UnionType2 { |
|
haraken
2013/05/15 10:56:25
Let's name it UnionMemberType, per the Web IDL spe
|
| +public: |
| + UnionType2() |
| + { |
| + } |
| + UnionType2(PassRefPtr<Type0> value) |
|
haraken
2013/05/15 10:56:25
Please add 'explicit'.
|
| + { |
| + value0 = value; |
| + } |
| + UnionType2(PassRefPtr<Type1> value) |
|
haraken
2013/05/15 10:56:25
Ditto.
|
| + { |
| + value1 = value; |
| + } |
| + bool isNull() const |
| + { |
| + return !value0 && !value1; |
| + } |
| + bool isValue0Enabled() const |
|
haraken
2013/05/15 10:56:25
How about just adding enabledValue()? Then neither
|
| + { |
| + return !value0; |
| + } |
| + PassRefPtr<Type0> getValue0() const |
| + { |
| + return value0; |
| + } |
| + bool isValue1Enabled() const |
| + { |
| + return !value1; |
| + } |
| + PassRefPtr<Type1> getValue1() const |
| + { |
| + return value1; |
| + } |
| +private: |
| + RefPtr<Type0> value0; |
|
haraken
2013/05/15 10:56:25
m_value0
|
| + RefPtr<Type1> value1; |
|
haraken
2013/05/15 10:56:25
m_value1
|
| +}; |
| + |
| + |
| +} // namespace WTF |
| + |
| +#endif // UnionType_h |