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

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

Issue 610293003: Replace more for loops in GN (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 6 years, 2 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/function_foreach.cc ('k') | tools/gn/function_get_target_outputs.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/err.h" 5 #include "tools/gn/err.h"
6 #include "tools/gn/filesystem_utils.h" 6 #include "tools/gn/filesystem_utils.h"
7 #include "tools/gn/functions.h" 7 #include "tools/gn/functions.h"
8 #include "tools/gn/parse_tree.h" 8 #include "tools/gn/parse_tree.h"
9 #include "tools/gn/scope.h" 9 #include "tools/gn/scope.h"
10 #include "tools/gn/value.h" 10 #include "tools/gn/value.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 return Value(); 215 return Value();
216 } 216 }
217 217
218 const SourceDir& current_dir = scope->GetSourceDir(); 218 const SourceDir& current_dir = scope->GetSourceDir();
219 if (args[0].type() == Value::STRING) { 219 if (args[0].type() == Value::STRING) {
220 return Value(function, GetOnePathInfo(scope->settings(), current_dir, what, 220 return Value(function, GetOnePathInfo(scope->settings(), current_dir, what,
221 args[0], err)); 221 args[0], err));
222 } else if (args[0].type() == Value::LIST) { 222 } else if (args[0].type() == Value::LIST) {
223 const std::vector<Value>& input_list = args[0].list_value(); 223 const std::vector<Value>& input_list = args[0].list_value();
224 Value result(function, Value::LIST); 224 Value result(function, Value::LIST);
225 for (size_t i = 0; i < input_list.size(); i++) { 225 for (const auto& cur : input_list) {
226 result.list_value().push_back(Value(function, 226 result.list_value().push_back(Value(function,
227 GetOnePathInfo(scope->settings(), current_dir, what, 227 GetOnePathInfo(scope->settings(), current_dir, what, cur, err)));
228 input_list[i], err)));
229 if (err->has_error()) 228 if (err->has_error())
230 return Value(); 229 return Value();
231 } 230 }
232 return result; 231 return result;
233 } 232 }
234 233
235 *err = Err(args[0], "Path must be a string or a list of strings."); 234 *err = Err(args[0], "Path must be a string or a list of strings.");
236 return Value(); 235 return Value();
237 } 236 }
238 237
239 } // namespace functions 238 } // namespace functions
OLDNEW
« no previous file with comments | « tools/gn/function_foreach.cc ('k') | tools/gn/function_get_target_outputs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698