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

Unified Diff: tools/gn/scope.h

Issue 207233003: Add "." accessors to GN. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments 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
« no previous file with comments | « tools/gn/parser_unittest.cc ('k') | tools/gn/scope.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/scope.h
diff --git a/tools/gn/scope.h b/tools/gn/scope.h
index d4a35fff9b6380c888594b33931cf48b73cdcafd..bd6722d94b029d09cdbff3cfc26a54ecf711105e 100644
--- a/tools/gn/scope.h
+++ b/tools/gn/scope.h
@@ -86,6 +86,30 @@ class Scope {
bool counts_as_used);
const Value* GetValue(const base::StringPiece& ident) const;
+ // Returns the requested value as a mutable one if possible. If the value
+ // is not found in a mutable scope, then returns null. Note that the value
+ // could still exist in a const scope, so GetValue() could still return
+ // non-null in this case.
+ //
+ // Say you have a local scope that then refers to the const root scope from
+ // the master build config. You can't change the values from the master
+ // build config (it's read-only so it can be read from multiple threads
+ // without locking). Read-only operations would work on values from the root
+ // scope, but write operations would only work on values in the derived
+ // scope(s).
+ //
+ // Be careful when calling this. It's not normally correct to modify values,
+ // but you should instead do a new Set each time.
+ //
+ // Consider this code:
+ // a = 5
+ // {
+ // a = 6
+ // }
+ // The 6 should get set on the nested scope rather than modify the value
+ // in the outer one.
+ Value* GetMutableValue(const base::StringPiece& ident, bool counts_as_used);
+
// Same as GetValue, but if the value exists in a parent scope, we'll copy
// it to the current scope. If the return value is non-null, the value is
// guaranteed to be set in the current scope. Generatlly this will be used
« no previous file with comments | « tools/gn/parser_unittest.cc ('k') | tools/gn/scope.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698