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

Unified Diff: tools/gn/functions.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
Index: tools/gn/functions.cc
diff --git a/tools/gn/functions.cc b/tools/gn/functions.cc
index ac1c29492d15be5817f560f9ba02066c1dc99f0e..c8ae4690c2043f6332985503e996297c4b145611 100644
--- a/tools/gn/functions.cc
+++ b/tools/gn/functions.cc
@@ -354,16 +354,26 @@ Value RunDefined(Scope* scope,
if (accessor) {
// Passed an accessor "defined(foo.bar)".
if (accessor->member()) {
- // The base of the accessor must be a scope if it's defined.
+ // The base of the accessor must be a scope/dict if it's defined.
const Value* base = scope->GetValue(accessor->base().value());
if (!base)
return Value(function, false);
- if (!base->VerifyTypeIs(Value::SCOPE, err))
+ if (base->type() == Value::SCOPE) {
+ // Check the member inside the scope to see if its defined.
+ if (base->scope_value()->GetValue(accessor->member()->value().value()))
+ return Value(function, true);
+ } else if (base->type() == Value::DICT) {
+ // Check the dictionary to see if the member is present.
+ if (base->dict_value().find(
+ accessor->member()->value().value().as_string()) !=
+ base->dict_value().end())
+ return Value(function, true);
+ } else {
+ *err = Err(function,
+ std::string("Type \"") + Value::DescribeType(base->type()) +
+ "\" is not usable with the '.' operator.");
return Value();
-
- // Check the member inside the scope to see if its defined.
- if (base->scope_value()->GetValue(accessor->member()->value().value()))
- return Value(function, true);
+ }
return Value(function, false);
}
}

Powered by Google App Engine
This is Rietveld 408576698