OLD | NEW |
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 <set> | 10 #include <set> |
10 #include <utility> | 11 #include <utility> |
11 | 12 |
12 #include "base/containers/hash_tables.h" | 13 #include "base/containers/hash_tables.h" |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | |
16 #include "base/memory/scoped_vector.h" | 16 #include "base/memory/scoped_vector.h" |
17 #include "tools/gn/err.h" | 17 #include "tools/gn/err.h" |
18 #include "tools/gn/pattern.h" | 18 #include "tools/gn/pattern.h" |
19 #include "tools/gn/source_dir.h" | 19 #include "tools/gn/source_dir.h" |
20 #include "tools/gn/value.h" | 20 #include "tools/gn/value.h" |
21 | 21 |
22 class FunctionCallNode; | 22 class FunctionCallNode; |
23 class ImportManager; | 23 class ImportManager; |
24 class Item; | 24 class Item; |
25 class ParseNode; | 25 class ParseNode; |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 const MergeOptions& options, | 220 const MergeOptions& options, |
221 const ParseNode* node_for_err, | 221 const ParseNode* node_for_err, |
222 const char* desc_for_err, | 222 const char* desc_for_err, |
223 Err* err) const; | 223 Err* err) const; |
224 | 224 |
225 // Constructs a scope that is a copy of the current one. Nested scopes will | 225 // Constructs a scope that is a copy of the current one. Nested scopes will |
226 // be collapsed until we reach a const containing scope. Private values will | 226 // be collapsed until we reach a const containing scope. Private values will |
227 // be included. The resulting closure will reference the const containing | 227 // be included. The resulting closure will reference the const containing |
228 // scope as its containing scope (since we assume the const scope won't | 228 // scope as its containing scope (since we assume the const scope won't |
229 // change, we don't have to copy its values). | 229 // change, we don't have to copy its values). |
230 scoped_ptr<Scope> MakeClosure() const; | 230 std::unique_ptr<Scope> MakeClosure() const; |
231 | 231 |
232 // Makes an empty scope with the given name. Returns NULL if the name is | 232 // Makes an empty scope with the given name. Returns NULL if the name is |
233 // already set. | 233 // already set. |
234 Scope* MakeTargetDefaults(const std::string& target_type); | 234 Scope* MakeTargetDefaults(const std::string& target_type); |
235 | 235 |
236 // Gets the scope associated with the given target name, or null if it hasn't | 236 // Gets the scope associated with the given target name, or null if it hasn't |
237 // been set. | 237 // been set. |
238 const Scope* GetTargetDefaults(const std::string& target_type) const; | 238 const Scope* GetTargetDefaults(const std::string& target_type) const; |
239 | 239 |
240 // Filter to apply when the sources variable is assigned. May return NULL. | 240 // Filter to apply when the sources variable is assigned. May return NULL. |
241 const PatternList* GetSourcesAssignmentFilter() const; | 241 const PatternList* GetSourcesAssignmentFilter() const; |
242 void set_sources_assignment_filter( | 242 void set_sources_assignment_filter(std::unique_ptr<PatternList> f) { |
243 scoped_ptr<PatternList> f) { | |
244 sources_assignment_filter_ = std::move(f); | 243 sources_assignment_filter_ = std::move(f); |
245 } | 244 } |
246 | 245 |
247 // Indicates if we're currently processing the build configuration file. | 246 // Indicates if we're currently processing the build configuration file. |
248 // This is true when processing the config file for any toolchain. | 247 // This is true when processing the config file for any toolchain. |
249 // | 248 // |
250 // To set or clear the flag, it must currently be in the opposite state in | 249 // To set or clear the flag, it must currently be in the opposite state in |
251 // the current scope. Note that querying the state of the flag recursively | 250 // the current scope. Note that querying the state of the flag recursively |
252 // checks all containing scopes until it reaches the top or finds the flag | 251 // checks all containing scopes until it reaches the top or finds the flag |
253 // set. | 252 // set. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 RecordMap values_; | 334 RecordMap values_; |
336 | 335 |
337 // Owning pointers. Note that this can't use string pieces since the names | 336 // Owning pointers. Note that this can't use string pieces since the names |
338 // are constructed from Values which might be deallocated before this goes | 337 // are constructed from Values which might be deallocated before this goes |
339 // out of scope. | 338 // out of scope. |
340 typedef base::hash_map<std::string, Scope*> NamedScopeMap; | 339 typedef base::hash_map<std::string, Scope*> NamedScopeMap; |
341 NamedScopeMap target_defaults_; | 340 NamedScopeMap target_defaults_; |
342 | 341 |
343 // Null indicates not set and that we should fallback to the containing | 342 // Null indicates not set and that we should fallback to the containing |
344 // scope's filter. | 343 // scope's filter. |
345 scoped_ptr<PatternList> sources_assignment_filter_; | 344 std::unique_ptr<PatternList> sources_assignment_filter_; |
346 | 345 |
347 // Owning pointers, must be deleted. | 346 // Owning pointers, must be deleted. |
348 typedef std::map<std::string, scoped_refptr<const Template> > TemplateMap; | 347 typedef std::map<std::string, scoped_refptr<const Template> > TemplateMap; |
349 TemplateMap templates_; | 348 TemplateMap templates_; |
350 | 349 |
351 ItemVector* item_collector_; | 350 ItemVector* item_collector_; |
352 | 351 |
353 // Opaque pointers. See SetProperty() above. | 352 // Opaque pointers. See SetProperty() above. |
354 typedef std::map<const void*, void*> PropertyMap; | 353 typedef std::map<const void*, void*> PropertyMap; |
355 PropertyMap properties_; | 354 PropertyMap properties_; |
356 | 355 |
357 typedef std::set<ProgrammaticProvider*> ProviderSet; | 356 typedef std::set<ProgrammaticProvider*> ProviderSet; |
358 ProviderSet programmatic_providers_; | 357 ProviderSet programmatic_providers_; |
359 | 358 |
360 SourceDir source_dir_; | 359 SourceDir source_dir_; |
361 | 360 |
362 DISALLOW_COPY_AND_ASSIGN(Scope); | 361 DISALLOW_COPY_AND_ASSIGN(Scope); |
363 }; | 362 }; |
364 | 363 |
365 #endif // TOOLS_GN_SCOPE_H_ | 364 #endif // TOOLS_GN_SCOPE_H_ |
OLD | NEW |