| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "tools/gn/value.h" | 5 #include "tools/gn/value.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "tools/gn/scope.h" | 9 #include "tools/gn/scope.h" |
| 10 | 10 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 return result; | 170 return result; |
| 171 } | 171 } |
| 172 } | 172 } |
| 173 return std::string(); | 173 return std::string(); |
| 174 } | 174 } |
| 175 | 175 |
| 176 bool Value::VerifyTypeIs(Type t, Err* err) const { | 176 bool Value::VerifyTypeIs(Type t, Err* err) const { |
| 177 if (type_ == t) | 177 if (type_ == t) |
| 178 return true; | 178 return true; |
| 179 | 179 |
| 180 *err = Err(origin(), std::string("This is not a ") + DescribeType(t) + "."); | 180 *err = Err(origin(), |
| 181 std::string("This is not a ") + DescribeType(t) + ".", |
| 182 std::string("Instead I see a ") + DescribeType(type_) + " = " + |
| 183 ToString(true)); |
| 181 return false; | 184 return false; |
| 182 } | 185 } |
| 183 | 186 |
| 184 bool Value::operator==(const Value& other) const { | 187 bool Value::operator==(const Value& other) const { |
| 185 if (type_ != other.type_) | 188 if (type_ != other.type_) |
| 186 return false; | 189 return false; |
| 187 | 190 |
| 188 switch (type_) { | 191 switch (type_) { |
| 189 case Value::BOOLEAN: | 192 case Value::BOOLEAN: |
| 190 return boolean_value() == other.boolean_value(); | 193 return boolean_value() == other.boolean_value(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 206 // iteration code. | 209 // iteration code. |
| 207 return false; | 210 return false; |
| 208 default: | 211 default: |
| 209 return false; | 212 return false; |
| 210 } | 213 } |
| 211 } | 214 } |
| 212 | 215 |
| 213 bool Value::operator!=(const Value& other) const { | 216 bool Value::operator!=(const Value& other) const { |
| 214 return !operator==(other); | 217 return !operator==(other); |
| 215 } | 218 } |
| OLD | NEW |