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

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

Issue 2664753002: Remove base::StringValue (Closed)
Patch Set: Rebase Created 3 years, 9 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/command_desc.cc ('k') | tools/ipc_fuzzer/fuzzer/fuzzer.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) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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 <set> 5 #include <set>
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "tools/gn/commands.h" 9 #include "tools/gn/commands.h"
10 #include "tools/gn/config.h" 10 #include "tools/gn/config.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 ValuePtr RenderValue(const std::vector<T>& vector) { 116 ValuePtr RenderValue(const std::vector<T>& vector) {
117 auto res = base::MakeUnique<base::ListValue>(); 117 auto res = base::MakeUnique<base::ListValue>();
118 for (const auto& v : vector) 118 for (const auto& v : vector)
119 res->Append(RenderValue(v)); 119 res->Append(RenderValue(v));
120 120
121 return std::move(res); 121 return std::move(res);
122 } 122 }
123 123
124 ValuePtr RenderValue(const std::string& s, bool optional = false) { 124 ValuePtr RenderValue(const std::string& s, bool optional = false) {
125 return (s.empty() && optional) ? base::Value::CreateNullValue() 125 return (s.empty() && optional) ? base::Value::CreateNullValue()
126 : ValuePtr(new base::StringValue(s)); 126 : ValuePtr(new base::Value(s));
127 } 127 }
128 128
129 ValuePtr RenderValue(const SourceDir& d) { 129 ValuePtr RenderValue(const SourceDir& d) {
130 return d.is_null() ? base::Value::CreateNullValue() 130 return d.is_null() ? base::Value::CreateNullValue()
131 : ValuePtr(new base::StringValue(FormatSourceDir(d))); 131 : ValuePtr(new base::Value(FormatSourceDir(d)));
132 } 132 }
133 133
134 ValuePtr RenderValue(const SourceFile& f) { 134 ValuePtr RenderValue(const SourceFile& f) {
135 return f.is_null() ? base::Value::CreateNullValue() 135 return f.is_null() ? base::Value::CreateNullValue()
136 : ValuePtr(new base::StringValue(f.value())); 136 : ValuePtr(new base::Value(f.value()));
137 } 137 }
138 138
139 ValuePtr RenderValue(const LibFile& lib) { 139 ValuePtr RenderValue(const LibFile& lib) {
140 if (lib.is_source_file()) 140 if (lib.is_source_file())
141 return RenderValue(lib.source_file()); 141 return RenderValue(lib.source_file());
142 return RenderValue(lib.value()); 142 return RenderValue(lib.value());
143 } 143 }
144 144
145 template <class VectorType> 145 template <class VectorType>
146 void FillInConfigVector(base::ListValue* out, 146 void FillInConfigVector(base::ListValue* out,
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 res->AppendString(from); 672 res->AppendString(from);
673 } 673 }
674 } 674 }
675 675
676 for (const T& val : vec) { 676 for (const T& val : vec) {
677 ValuePtr rendered = RenderValue(val); 677 ValuePtr rendered = RenderValue(val);
678 std::string str; 678 std::string str;
679 // Indent string values in blame mode 679 // Indent string values in blame mode
680 if (blame_ && rendered->GetAsString(&str)) { 680 if (blame_ && rendered->GetAsString(&str)) {
681 str = " " + str; 681 str = " " + str;
682 rendered = base::MakeUnique<base::StringValue>(str); 682 rendered = base::MakeUnique<base::Value>(str);
683 } 683 }
684 res->Append(std::move(rendered)); 684 res->Append(std::move(rendered));
685 } 685 }
686 } 686 }
687 return res->empty() ? nullptr : std::move(res); 687 return res->empty() ? nullptr : std::move(res);
688 } 688 }
689 689
690 Label GetToolchainLabel() const override { 690 Label GetToolchainLabel() const override {
691 return target_->label().GetToolchainLabel(); 691 return target_->label().GetToolchainLabel();
692 } 692 }
(...skipping 18 matching lines...) Expand all
711 711
712 std::unique_ptr<base::DictionaryValue> DescBuilder::DescriptionForConfig( 712 std::unique_ptr<base::DictionaryValue> DescBuilder::DescriptionForConfig(
713 const Config* config, 713 const Config* config,
714 const std::string& what) { 714 const std::string& what) {
715 std::set<std::string> w; 715 std::set<std::string> w;
716 if (!what.empty()) 716 if (!what.empty())
717 w.insert(what); 717 w.insert(what);
718 ConfigDescBuilder b(config, w); 718 ConfigDescBuilder b(config, w);
719 return b.BuildDescription(); 719 return b.BuildDescription();
720 } 720 }
OLDNEW
« no previous file with comments | « tools/gn/command_desc.cc ('k') | tools/ipc_fuzzer/fuzzer/fuzzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698