Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: tools/gn/value.cc

Issue 439513003: Improve GN value origins for error messages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/gn/parse_tree_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « tools/gn/parse_tree_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698