OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef V8_BASE_FLAGS_H_ | 5 #ifndef V8_BASE_FLAGS_H_ |
6 #define V8_BASE_FLAGS_H_ | 6 #define V8_BASE_FLAGS_H_ |
7 | 7 |
8 #include "src/base/compiler-specific.h" | 8 #include "src/base/compiler-specific.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 operator mask_type() const { return mask_; } | 59 operator mask_type() const { return mask_; } |
60 bool operator!() const { return !mask_; } | 60 bool operator!() const { return !mask_; } |
61 | 61 |
62 private: | 62 private: |
63 mask_type mask_; | 63 mask_type mask_; |
64 }; | 64 }; |
65 | 65 |
66 | 66 |
67 #define DEFINE_OPERATORS_FOR_FLAGS(Type) \ | 67 #define DEFINE_OPERATORS_FOR_FLAGS(Type) \ |
68 inline ::v8::base::Flags<Type::flag_type> operator&( \ | 68 inline Type operator&(Type::flag_type lhs, \ |
69 Type::flag_type lhs, \ | 69 Type::flag_type rhs)ALLOW_UNUSED WARN_UNUSED_RESULT; \ |
70 Type::flag_type rhs)ALLOW_UNUSED WARN_UNUSED_RESULT; \ | 70 inline Type operator&(Type::flag_type lhs, Type::flag_type rhs) { \ |
71 inline ::v8::base::Flags<Type::flag_type> operator&(Type::flag_type lhs, \ | 71 return Type(lhs) & rhs; \ |
72 Type::flag_type rhs) { \ | |
73 return ::v8::base::Flags<Type::flag_type>(lhs) & rhs; \ | |
74 } \ | 72 } \ |
75 inline ::v8::base::Flags<Type::flag_type> operator&( \ | 73 inline Type operator&(Type::flag_type lhs, \ |
76 Type::flag_type lhs, const ::v8::base::Flags<Type::flag_type>& rhs) \ | 74 const Type& rhs)ALLOW_UNUSED WARN_UNUSED_RESULT; \ |
77 ALLOW_UNUSED WARN_UNUSED_RESULT; \ | 75 inline Type operator&(Type::flag_type lhs, const Type& rhs) { \ |
78 inline ::v8::base::Flags<Type::flag_type> operator&( \ | |
79 Type::flag_type lhs, const ::v8::base::Flags<Type::flag_type>& rhs) { \ | |
80 return rhs & lhs; \ | 76 return rhs & lhs; \ |
81 } \ | 77 } \ |
82 inline void operator&(Type::flag_type lhs, Type::mask_type rhs)ALLOW_UNUSED; \ | 78 inline void operator&(Type::flag_type lhs, Type::mask_type rhs)ALLOW_UNUSED; \ |
83 inline void operator&(Type::flag_type lhs, Type::mask_type rhs) {} \ | 79 inline void operator&(Type::flag_type lhs, Type::mask_type rhs) {} \ |
84 inline ::v8::base::Flags<Type::flag_type> operator|(Type::flag_type lhs, \ | 80 inline Type operator|(Type::flag_type lhs, Type::flag_type rhs) \ |
85 Type::flag_type rhs) \ | |
86 ALLOW_UNUSED WARN_UNUSED_RESULT; \ | 81 ALLOW_UNUSED WARN_UNUSED_RESULT; \ |
87 inline ::v8::base::Flags<Type::flag_type> operator|(Type::flag_type lhs, \ | 82 inline Type operator|(Type::flag_type lhs, Type::flag_type rhs) { \ |
88 Type::flag_type rhs) { \ | 83 return Type(lhs) | rhs; \ |
89 return ::v8::base::Flags<Type::flag_type>(lhs) | rhs; \ | |
90 } \ | 84 } \ |
91 inline ::v8::base::Flags<Type::flag_type> operator|( \ | 85 inline Type operator|(Type::flag_type lhs, const Type& rhs) \ |
92 Type::flag_type lhs, const ::v8::base::Flags<Type::flag_type>& rhs) \ | |
93 ALLOW_UNUSED WARN_UNUSED_RESULT; \ | 86 ALLOW_UNUSED WARN_UNUSED_RESULT; \ |
94 inline ::v8::base::Flags<Type::flag_type> operator|( \ | 87 inline Type operator|(Type::flag_type lhs, const Type& rhs) { \ |
95 Type::flag_type lhs, const ::v8::base::Flags<Type::flag_type>& rhs) { \ | |
96 return rhs | lhs; \ | 88 return rhs | lhs; \ |
97 } \ | 89 } \ |
98 inline void operator|(Type::flag_type lhs, Type::mask_type rhs) \ | 90 inline void operator|(Type::flag_type lhs, Type::mask_type rhs) \ |
99 ALLOW_UNUSED; \ | 91 ALLOW_UNUSED; \ |
100 inline void operator|(Type::flag_type lhs, Type::mask_type rhs) {} \ | 92 inline void operator|(Type::flag_type lhs, Type::mask_type rhs) {} \ |
101 inline ::v8::base::Flags<Type::flag_type> operator^(Type::flag_type lhs, \ | 93 inline Type operator^(Type::flag_type lhs, Type::flag_type rhs) \ |
102 Type::flag_type rhs) \ | |
103 ALLOW_UNUSED WARN_UNUSED_RESULT; \ | 94 ALLOW_UNUSED WARN_UNUSED_RESULT; \ |
104 inline ::v8::base::Flags<Type::flag_type> operator^(Type::flag_type lhs, \ | 95 inline Type operator^(Type::flag_type lhs, Type::flag_type rhs) { \ |
105 Type::flag_type rhs) { \ | 96 return Type(lhs) ^ rhs; \ |
106 return ::v8::base::Flags<Type::flag_type>(lhs) ^ rhs; \ | 97 } inline Type operator^(Type::flag_type lhs, const Type& rhs) \ |
107 } inline ::v8::base::Flags<Type::flag_type> \ | |
108 operator^(Type::flag_type lhs, \ | |
109 const ::v8::base::Flags<Type::flag_type>& rhs) \ | |
110 ALLOW_UNUSED WARN_UNUSED_RESULT; \ | 98 ALLOW_UNUSED WARN_UNUSED_RESULT; \ |
111 inline ::v8::base::Flags<Type::flag_type> operator^( \ | 99 inline Type operator^(Type::flag_type lhs, const Type& rhs) { \ |
112 Type::flag_type lhs, const ::v8::base::Flags<Type::flag_type>& rhs) { \ | |
113 return rhs ^ lhs; \ | 100 return rhs ^ lhs; \ |
114 } inline void operator^(Type::flag_type lhs, Type::mask_type rhs) \ | 101 } inline void operator^(Type::flag_type lhs, Type::mask_type rhs) \ |
115 ALLOW_UNUSED; \ | 102 ALLOW_UNUSED; \ |
116 inline void operator^(Type::flag_type lhs, Type::mask_type rhs) {} | 103 inline void operator^(Type::flag_type lhs, Type::mask_type rhs) {} |
117 | 104 |
118 } // namespace base | 105 } // namespace base |
119 } // namespace v8 | 106 } // namespace v8 |
120 | 107 |
121 #endif // V8_BASE_FLAGS_H_ | 108 #endif // V8_BASE_FLAGS_H_ |
OLD | NEW |