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

Side by Side Diff: tools/gn/scope.h

Issue 2509333003: Change GN to disallow reading args defined in the same declare_args() call. (Closed)
Patch Set: add tests Created 4 years, 1 month 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
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 #ifndef TOOLS_GN_SCOPE_H_ 5 #ifndef TOOLS_GN_SCOPE_H_
6 #define TOOLS_GN_SCOPE_H_ 6 #define TOOLS_GN_SCOPE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 explicit Scope(const Settings* settings); 105 explicit Scope(const Settings* settings);
106 106
107 // Creates a dependent scope. 107 // Creates a dependent scope.
108 explicit Scope(Scope* parent); 108 explicit Scope(Scope* parent);
109 explicit Scope(const Scope* parent); 109 explicit Scope(const Scope* parent);
110 110
111 ~Scope(); 111 ~Scope();
112 112
113 const Settings* settings() const { return settings_; } 113 const Settings* settings() const { return settings_; }
114 114
115 // See the const_/mutable_containing_ var declaraions below. Yes, it's a 115 // See the const_/mutable_containing_ var declarations below. Yes, it's a
116 // bit weird that we can have a const pointer to the "mutable" one. 116 // bit weird that we can have a const pointer to the "mutable" one.
117 Scope* mutable_containing() { return mutable_containing_; } 117 Scope* mutable_containing() { return mutable_containing_; }
118 const Scope* mutable_containing() const { return mutable_containing_; } 118 const Scope* mutable_containing() const { return mutable_containing_; }
119 const Scope* const_containing() const { return const_containing_; } 119 const Scope* const_containing() const { return const_containing_; }
120 const Scope* containing() const { 120 const Scope* containing() const {
121 return mutable_containing_ ? mutable_containing_ : const_containing_; 121 return mutable_containing_ ? mutable_containing_ : const_containing_;
122 } 122 }
123 123
124 // Clears any references to containing scopes. This scope will now be 124 // Clears any references to containing scopes. This scope will now be
125 // self-sufficient. 125 // self-sufficient.
126 void DetachFromContaining(); 126 void DetachFromContaining();
127 127
128 // Returns true if the scope has any values set. This does not check other 128 // Returns true if the scope has any values set. This does not check other
129 // things that may be set like templates or defaults. 129 // things that may be set like templates or defaults.
130 // 130 //
131 // Currently this does not search nested scopes and this will assert if you 131 // Currently this does not search nested scopes and this will assert if you
132 // want to search nested scopes. The enum is passed so the callers are 132 // want to search nested scopes. The enum is passed so the callers are
133 // unambiguous about nested scope handling. This can be added if needed. 133 // unambiguous about nested scope handling. This can be added if needed.
134 bool HasValues(SearchNested search_nested) const; 134 bool HasValues(SearchNested search_nested) const;
135 135
136 // Returns NULL if there's no such value. 136 // Returns NULL if there's no such value.
137 // 137 //
138 // counts_as_used should be set if the variable is being read in a way that 138 // counts_as_used should be set if the variable is being read in a way that
139 // should count for unused variable checking. 139 // should count for unused variable checking.
brettw 2016/11/21 17:23:39 Can this document what found_in_scope means (in pa
Dirk Pranke 2016/11/21 17:39:48 Will do.
140 const Value* GetValue(const base::StringPiece& ident, 140 const Value* GetValue(const base::StringPiece& ident,
141 bool counts_as_used); 141 bool counts_as_used);
142 const Value* GetValue(const base::StringPiece& ident) const; 142 const Value* GetValue(const base::StringPiece& ident) const;
143 const Value* GetValueWithScope(const base::StringPiece& ident,
144 const Scope** found_in_scope) const;
145 const Value* GetValueWithScope(const base::StringPiece& ident,
146 bool counts_as_used,
147 const Scope** found_in_scope);
143 148
144 // Returns the requested value as a mutable one if possible. If the value 149 // Returns the requested value as a mutable one if possible. If the value
145 // is not found in a mutable scope, then returns null. Note that the value 150 // is not found in a mutable scope, then returns null. Note that the value
146 // could still exist in a const scope, so GetValue() could still return 151 // could still exist in a const scope, so GetValue() could still return
147 // non-null in this case. 152 // non-null in this case.
148 // 153 //
149 // Say you have a local scope that then refers to the const root scope from 154 // Say you have a local scope that then refers to the const root scope from
150 // the master build config. You can't change the values from the master 155 // the master build config. You can't change the values from the master
151 // build config (it's read-only so it can be read from multiple threads 156 // build config (it's read-only so it can be read from multiple threads
152 // without locking). Read-only operations would work on values from the root 157 // without locking). Read-only operations would work on values from the root
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 374
370 typedef std::set<ProgrammaticProvider*> ProviderSet; 375 typedef std::set<ProgrammaticProvider*> ProviderSet;
371 ProviderSet programmatic_providers_; 376 ProviderSet programmatic_providers_;
372 377
373 SourceDir source_dir_; 378 SourceDir source_dir_;
374 379
375 DISALLOW_COPY_AND_ASSIGN(Scope); 380 DISALLOW_COPY_AND_ASSIGN(Scope);
376 }; 381 };
377 382
378 #endif // TOOLS_GN_SCOPE_H_ 383 #endif // TOOLS_GN_SCOPE_H_
OLDNEW
« tools/gn/functions.cc ('K') | « tools/gn/parse_tree.cc ('k') | tools/gn/scope.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698