Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project 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 /** \mainpage V8 API Reference Guide | 5 /** \mainpage V8 API Reference Guide |
| 6 * | 6 * |
| 7 * V8 is Google's open source JavaScript engine. | 7 * V8 is Google's open source JavaScript engine. |
| 8 * | 8 * |
| 9 * This set of documents provides reference material generated from the | 9 * This set of documents provides reference material generated from the |
| 10 * V8 header file, include/v8.h. | 10 * V8 header file, include/v8.h. |
| (...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 882 | 882 |
| 883 /** | 883 /** |
| 884 * A simple Maybe type, representing an object which may or may not have a | 884 * A simple Maybe type, representing an object which may or may not have a |
| 885 * value. | 885 * value. |
| 886 */ | 886 */ |
| 887 template<class T> | 887 template<class T> |
| 888 struct Maybe { | 888 struct Maybe { |
| 889 Maybe() : has_value(false) {} | 889 Maybe() : has_value(false) {} |
| 890 explicit Maybe(T t) : has_value(true), value(t) {} | 890 explicit Maybe(T t) : has_value(true), value(t) {} |
| 891 Maybe(bool has, T t) : has_value(has), value(t) {} | 891 Maybe(bool has, T t) : has_value(has), value(t) {} |
| 892 bool ToValue(T* t) { | |
|
rossberg
2014/08/06 09:53:02
Can we not introduce this? Maybe intentionally is
arv (Not doing code reviews)
2014/08/06 15:08:28
Reverted this.
| |
| 893 if (!has_value) return false; | |
| 894 *t = value; | |
| 895 return true; | |
| 896 } | |
| 892 | 897 |
| 893 bool has_value; | 898 bool has_value; |
| 894 T value; | 899 T value; |
| 895 }; | 900 }; |
| 896 | 901 |
| 897 | 902 |
| 898 // Convenience wrapper. | 903 // Convenience wrapper. |
| 899 template <class T> | 904 template <class T> |
| 900 inline Maybe<T> maybe(T t) { | 905 inline Maybe<T> maybe(T t) { |
| 901 return Maybe<T>(t); | 906 return Maybe<T>(t); |
| (...skipping 5827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6729 */ | 6734 */ |
| 6730 | 6735 |
| 6731 | 6736 |
| 6732 } // namespace v8 | 6737 } // namespace v8 |
| 6733 | 6738 |
| 6734 | 6739 |
| 6735 #undef TYPE_CHECK | 6740 #undef TYPE_CHECK |
| 6736 | 6741 |
| 6737 | 6742 |
| 6738 #endif // V8_H_ | 6743 #endif // V8_H_ |
| OLD | NEW |