| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef SKY_ENGINE_BINDINGS_CORE_V8_NULLABLE_H_ | 5 #ifndef Nullable_h |
| 6 #define SKY_ENGINE_BINDINGS_CORE_V8_NULLABLE_H_ | 6 #define Nullable_h |
| 7 | 7 |
| 8 #include "sky/engine/platform/heap/Handle.h" | 8 #include "platform/heap/Handle.h" |
| 9 #include "sky/engine/wtf/Assertions.h" | 9 #include "wtf/Assertions.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 template <typename T> | 13 template <typename T> |
| 14 class Nullable { | 14 class Nullable { |
| 15 DISALLOW_ALLOCATION(); | 15 DISALLOW_ALLOCATION(); |
| 16 public: | 16 public: |
| 17 Nullable() | 17 Nullable() |
| 18 : m_value() | 18 : m_value() |
| 19 , m_isNull(true) { } | 19 , m_isNull(true) { } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 44 | 44 |
| 45 // See comment in RefPtr.h about what UnspecifiedBoolType is. | 45 // See comment in RefPtr.h about what UnspecifiedBoolType is. |
| 46 typedef const T* UnspecifiedBoolType; | 46 typedef const T* UnspecifiedBoolType; |
| 47 operator UnspecifiedBoolType() const { return m_isNull ? 0 : &m_value; } | 47 operator UnspecifiedBoolType() const { return m_isNull ? 0 : &m_value; } |
| 48 | 48 |
| 49 bool operator==(const Nullable& other) const | 49 bool operator==(const Nullable& other) const |
| 50 { | 50 { |
| 51 return (m_isNull && other.m_isNull) || (!m_isNull && !other.m_isNull &&
m_value == other.m_value); | 51 return (m_isNull && other.m_isNull) || (!m_isNull && !other.m_isNull &&
m_value == other.m_value); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void trace(Visitor* visitor) |
| 55 { |
| 56 TraceIfNeeded<T>::trace(visitor, &m_value); |
| 57 } |
| 58 |
| 54 private: | 59 private: |
| 55 T m_value; | 60 T m_value; |
| 56 bool m_isNull; | 61 bool m_isNull; |
| 57 }; | 62 }; |
| 58 | 63 |
| 59 } // namespace blink | 64 } // namespace blink |
| 60 | 65 |
| 61 #endif // SKY_ENGINE_BINDINGS_CORE_V8_NULLABLE_H_ | 66 #endif // Nullable_h |
| OLD | NEW |