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 #include "tools/gn/input_conversion.h" | 5 #include "tools/gn/input_conversion.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/macros.h" | 9 #include "base/macros.h" |
8 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
9 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
10 #include "tools/gn/build_settings.h" | 12 #include "tools/gn/build_settings.h" |
11 #include "tools/gn/err.h" | 13 #include "tools/gn/err.h" |
12 #include "tools/gn/input_file.h" | 14 #include "tools/gn/input_file.h" |
13 #include "tools/gn/label.h" | 15 #include "tools/gn/label.h" |
14 #include "tools/gn/parse_tree.h" | 16 #include "tools/gn/parse_tree.h" |
15 #include "tools/gn/parser.h" | 17 #include "tools/gn/parser.h" |
16 #include "tools/gn/scheduler.h" | 18 #include "tools/gn/scheduler.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 76 |
75 scoped_ptr<Scope> scope(new Scope(settings)); | 77 scoped_ptr<Scope> scope(new Scope(settings)); |
76 Value result = parse_root->Execute(scope.get(), err); | 78 Value result = parse_root->Execute(scope.get(), err); |
77 if (err->has_error()) | 79 if (err->has_error()) |
78 return Value(); | 80 return Value(); |
79 | 81 |
80 // When we want the result as a scope, the result is actually the scope | 82 // When we want the result as a scope, the result is actually the scope |
81 // we made, rather than the result of running the block (which will be empty). | 83 // we made, rather than the result of running the block (which will be empty). |
82 if (what == PARSE_SCOPE) { | 84 if (what == PARSE_SCOPE) { |
83 DCHECK(result.type() == Value::NONE); | 85 DCHECK(result.type() == Value::NONE); |
84 result = Value(origin, scope.Pass()); | 86 result = Value(origin, std::move(scope)); |
85 } | 87 } |
86 return result; | 88 return result; |
87 } | 89 } |
88 | 90 |
89 Value ParseList(const std::string& input, const ParseNode* origin, Err* err) { | 91 Value ParseList(const std::string& input, const ParseNode* origin, Err* err) { |
90 Value ret(origin, Value::LIST); | 92 Value ret(origin, Value::LIST); |
91 std::vector<std::string> as_lines = base::SplitString( | 93 std::vector<std::string> as_lines = base::SplitString( |
92 input, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 94 input, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
93 | 95 |
94 // Trim one empty line from the end since the last line might end in a | 96 // Trim one empty line from the end since the last line might end in a |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 const ParseNode* origin, | 204 const ParseNode* origin, |
203 const Value& input_conversion_value, | 205 const Value& input_conversion_value, |
204 Err* err) { | 206 Err* err) { |
205 if (input_conversion_value.type() == Value::NONE) | 207 if (input_conversion_value.type() == Value::NONE) |
206 return Value(); // Allow null inputs to mean discard the result. | 208 return Value(); // Allow null inputs to mean discard the result. |
207 if (!input_conversion_value.VerifyTypeIs(Value::STRING, err)) | 209 if (!input_conversion_value.VerifyTypeIs(Value::STRING, err)) |
208 return Value(); | 210 return Value(); |
209 return DoConvertInputToValue(settings, input, origin, input_conversion_value, | 211 return DoConvertInputToValue(settings, input, origin, input_conversion_value, |
210 input_conversion_value.string_value(), err); | 212 input_conversion_value.string_value(), err); |
211 } | 213 } |
OLD | NEW |