| OLD | NEW |
| 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 Loading... |
| 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 |
| OLD | NEW |