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

Unified Diff: tools/gn/value.cc

Issue 223783005: Add support for reading .gypi files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« tools/gn/value.h ('K') | « tools/gn/value.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/value.cc
diff --git a/tools/gn/value.cc b/tools/gn/value.cc
index 6bf78da2cfaf5753b7af7c6586a284f7c6edd29d..443ee06dc2a6c481c9e9bfb8658780ae70bc516b 100644
--- a/tools/gn/value.cc
+++ b/tools/gn/value.cc
@@ -92,6 +92,8 @@ const char* Value::DescribeType(Type t) {
return "list";
case SCOPE:
return "scope";
+ case DICT:
+ return "dict";
default:
NOTREACHED();
return "UNKNOWN";
@@ -122,6 +124,15 @@ std::string Value::ToString(bool quote_string) const {
}
case SCOPE:
return std::string("<scope>");
+ case DICT: {
+ std::string result = "{\n";
+ for (std::map<std::string, Value>::const_iterator i = dict_value_.begin();
+ i != dict_value_.end(); ++i) {
+ result += " " + i->first + " = " + i->second.ToString(true) + "\n";
+ }
+ result += "}";
+ return result;
+ }
}
return std::string();
}
@@ -154,9 +165,14 @@ bool Value::operator==(const Value& other) const {
}
return true;
case Value::SCOPE:
- // Its not clear what people mean when comparing scope values, so we test
- // for scope identity and not contents equality.
- return scope_value() == other.scope_value();
+ // Scopes are always considered not equal because there's currently
+ // no use case for comparing them, and it requires a bunch of complex
+ // iteration code.
+ return false;
+ case Value::DICT:
+ return dict_value_.size() == other.dict_value_.size() &&
+ std::equal(dict_value_.begin(), dict_value_.end(),
+ other.dict_value_.begin());
default:
return false;
}
« tools/gn/value.h ('K') | « tools/gn/value.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698