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

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

Issue 1869503004: Convert //tools to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, change iwyu fixes for converted directories to include <memory> Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « tools/gn/scope.h ('k') | tools/gn/scope_per_file_provider.h » ('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 #include "tools/gn/scope.h" 5 #include "tools/gn/scope.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "tools/gn/parse_tree.h" 9 #include "tools/gn/parse_tree.h"
10 #include "tools/gn/template.h" 10 #include "tools/gn/template.h"
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 } 373 }
374 } 374 }
375 375
376 // Be careful to delete any pointer we're about to clobber. 376 // Be careful to delete any pointer we're about to clobber.
377 dest->templates_[current_name] = pair.second; 377 dest->templates_[current_name] = pair.second;
378 } 378 }
379 379
380 return true; 380 return true;
381 } 381 }
382 382
383 scoped_ptr<Scope> Scope::MakeClosure() const { 383 std::unique_ptr<Scope> Scope::MakeClosure() const {
384 scoped_ptr<Scope> result; 384 std::unique_ptr<Scope> result;
385 if (const_containing_) { 385 if (const_containing_) {
386 // We reached the top of the mutable scope stack. The result scope just 386 // We reached the top of the mutable scope stack. The result scope just
387 // references the const scope (which will never change). 387 // references the const scope (which will never change).
388 result.reset(new Scope(const_containing_)); 388 result.reset(new Scope(const_containing_));
389 } else if (mutable_containing_) { 389 } else if (mutable_containing_) {
390 // There are more nested mutable scopes. Recursively go up the stack to 390 // There are more nested mutable scopes. Recursively go up the stack to
391 // get the closure. 391 // get the closure.
392 result = mutable_containing_->MakeClosure(); 392 result = mutable_containing_->MakeClosure();
393 } else { 393 } else {
394 // This is a standalone scope, just copy it. 394 // This is a standalone scope, just copy it.
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 } 512 }
513 513
514 void Scope::AddProvider(ProgrammaticProvider* p) { 514 void Scope::AddProvider(ProgrammaticProvider* p) {
515 programmatic_providers_.insert(p); 515 programmatic_providers_.insert(p);
516 } 516 }
517 517
518 void Scope::RemoveProvider(ProgrammaticProvider* p) { 518 void Scope::RemoveProvider(ProgrammaticProvider* p) {
519 DCHECK(programmatic_providers_.find(p) != programmatic_providers_.end()); 519 DCHECK(programmatic_providers_.find(p) != programmatic_providers_.end());
520 programmatic_providers_.erase(p); 520 programmatic_providers_.erase(p);
521 } 521 }
OLDNEW
« no previous file with comments | « tools/gn/scope.h ('k') | tools/gn/scope_per_file_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698