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

Unified Diff: tools/gn/scope.h

Issue 2224343003: GN: Throw an error overwriting a nonempty scope. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment Created 4 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 side-by-side diff with in-line comments
Download patch
Index: tools/gn/scope.h
diff --git a/tools/gn/scope.h b/tools/gn/scope.h
index 3d3671254beae20ef3387cb3e7b629f95df34f8e..b87afcd6f9c756178c0ef0c4c76057d857faa868 100644
--- a/tools/gn/scope.h
+++ b/tools/gn/scope.h
@@ -125,6 +125,14 @@ class Scope {
// self-sufficient.
void DetachFromContaining();
+ // Returns true if the scope has any values set. This does not check other
+ // things that may be set like templates or defaults.
+ //
+ // Currently this does not search nested scopes and this will assert if you
+ // want to search nested scopes. The enum is passed so the callers are
+ // unambiguous about nested scope handling. This can be added if needed.
+ bool HasValues(SearchNested search_nested) const;
+
// Returns NULL if there's no such value.
//
// counts_as_used should be set if the variable is being read in a way that
@@ -133,16 +141,6 @@ class Scope {
bool counts_as_used);
const Value* GetValue(const base::StringPiece& ident) const;
- // If the value exists in the current scope, destrictively moves it into the
- // return value. If it exists in a containing scope, copies it.
- //
- // This is for implementing modify-write operations where we want to read
- // the existing value and plan to immediately overwrite it. If the value is
- // in a containing scope, we never want to touch it (all writes go to the
- // current scope), but if it's in the current scope, avoid the copy since it
- // will be overwritten anyway.
- //Value DestructiveMoveOut(const base::StringPiece& ident);
-
// 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
« tools/gn/operators.cc ('K') | « tools/gn/operators_unittest.cc ('k') | tools/gn/scope.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698