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

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

Issue 2586073002: Revert GN declare_args() change. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « tools/gn/parse_tree.cc ('k') | tools/gn/scope.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 explicit Scope(const Settings* settings); 102 explicit Scope(const Settings* settings);
103 103
104 // Creates a dependent scope. 104 // Creates a dependent scope.
105 explicit Scope(Scope* parent); 105 explicit Scope(Scope* parent);
106 explicit Scope(const Scope* parent); 106 explicit Scope(const Scope* parent);
107 107
108 ~Scope(); 108 ~Scope();
109 109
110 const Settings* settings() const { return settings_; } 110 const Settings* settings() const { return settings_; }
111 111
112 // See the const_/mutable_containing_ var declarations below. Yes, it's a 112 // See the const_/mutable_containing_ var declaraions below. Yes, it's a
113 // bit weird that we can have a const pointer to the "mutable" one. 113 // bit weird that we can have a const pointer to the "mutable" one.
114 Scope* mutable_containing() { return mutable_containing_; } 114 Scope* mutable_containing() { return mutable_containing_; }
115 const Scope* mutable_containing() const { return mutable_containing_; } 115 const Scope* mutable_containing() const { return mutable_containing_; }
116 const Scope* const_containing() const { return const_containing_; } 116 const Scope* const_containing() const { return const_containing_; }
117 const Scope* containing() const { 117 const Scope* containing() const {
118 return mutable_containing_ ? mutable_containing_ : const_containing_; 118 return mutable_containing_ ? mutable_containing_ : const_containing_;
119 } 119 }
120 120
121 // Clears any references to containing scopes. This scope will now be 121 // Clears any references to containing scopes. This scope will now be
122 // self-sufficient. 122 // self-sufficient.
123 void DetachFromContaining(); 123 void DetachFromContaining();
124 124
125 // Returns true if the scope has any values set. This does not check other 125 // Returns true if the scope has any values set. This does not check other
126 // things that may be set like templates or defaults. 126 // things that may be set like templates or defaults.
127 // 127 //
128 // Currently this does not search nested scopes and this will assert if you 128 // Currently this does not search nested scopes and this will assert if you
129 // want to search nested scopes. The enum is passed so the callers are 129 // want to search nested scopes. The enum is passed so the callers are
130 // unambiguous about nested scope handling. This can be added if needed. 130 // unambiguous about nested scope handling. This can be added if needed.
131 bool HasValues(SearchNested search_nested) const; 131 bool HasValues(SearchNested search_nested) const;
132 132
133 // Returns NULL if there's no such value. 133 // Returns NULL if there's no such value.
134 // 134 //
135 // counts_as_used should be set if the variable is being read in a way that 135 // counts_as_used should be set if the variable is being read in a way that
136 // should count for unused variable checking. 136 // should count for unused variable checking.
137 //
138 // found_in_scope is set to the scope that contains the definition of the
139 // ident. If the value was provided programmatically (like host_cpu),
140 // found_in_scope will be set to null.
141 const Value* GetValue(const base::StringPiece& ident, 137 const Value* GetValue(const base::StringPiece& ident,
142 bool counts_as_used); 138 bool counts_as_used);
143 const Value* GetValue(const base::StringPiece& ident) const; 139 const Value* GetValue(const base::StringPiece& ident) const;
144 const Value* GetValueWithScope(const base::StringPiece& ident,
145 const Scope** found_in_scope) const;
146 const Value* GetValueWithScope(const base::StringPiece& ident,
147 bool counts_as_used,
148 const Scope** found_in_scope);
149 140
150 // Returns the requested value as a mutable one if possible. If the value 141 // Returns the requested value as a mutable one if possible. If the value
151 // is not found in a mutable scope, then returns null. Note that the value 142 // is not found in a mutable scope, then returns null. Note that the value
152 // could still exist in a const scope, so GetValue() could still return 143 // could still exist in a const scope, so GetValue() could still return
153 // non-null in this case. 144 // non-null in this case.
154 // 145 //
155 // Say you have a local scope that then refers to the const root scope from 146 // Say you have a local scope that then refers to the const root scope from
156 // the master build config. You can't change the values from the master 147 // the master build config. You can't change the values from the master
157 // build config (it's read-only so it can be read from multiple threads 148 // build config (it's read-only so it can be read from multiple threads
158 // without locking). Read-only operations would work on values from the root 149 // without locking). Read-only operations would work on values from the root
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 366
376 typedef std::set<ProgrammaticProvider*> ProviderSet; 367 typedef std::set<ProgrammaticProvider*> ProviderSet;
377 ProviderSet programmatic_providers_; 368 ProviderSet programmatic_providers_;
378 369
379 SourceDir source_dir_; 370 SourceDir source_dir_;
380 371
381 DISALLOW_COPY_AND_ASSIGN(Scope); 372 DISALLOW_COPY_AND_ASSIGN(Scope);
382 }; 373 };
383 374
384 #endif // TOOLS_GN_SCOPE_H_ 375 #endif // TOOLS_GN_SCOPE_H_
OLDNEW
« no previous file with comments | « 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