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

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

Issue 2187523003: Allow creation and modification of scopes in GN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 4 years, 4 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/functions.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/functions.h" 6 #include "tools/gn/functions.h"
7 #include "tools/gn/parse_tree.h" 7 #include "tools/gn/parse_tree.h"
8 #include "tools/gn/scope.h" 8 #include "tools/gn/scope.h"
9 9
10 namespace functions { 10 namespace functions {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 // identifier. It is difficult to write code where this is not the case, and 176 // identifier. It is difficult to write code where this is not the case, and
177 // this saves an expensive scope copy. If necessary, this could be expanded 177 // this saves an expensive scope copy. If necessary, this could be expanded
178 // to execute the ParseNode and get the value out if it's not an identifer. 178 // to execute the ParseNode and get the value out if it's not an identifer.
179 const IdentifierNode* identifier = args_vector[0]->AsIdentifier(); 179 const IdentifierNode* identifier = args_vector[0]->AsIdentifier();
180 if (!identifier) { 180 if (!identifier) {
181 *err = Err(args_vector[0].get(), "Expected an identifier for the scope."); 181 *err = Err(args_vector[0].get(), "Expected an identifier for the scope.");
182 return Value(); 182 return Value();
183 } 183 }
184 184
185 // Extract the source scope. 185 // Extract the source scope.
186 Value* value = scope->GetMutableValue(identifier->value().value(), true); 186 Value* value = scope->GetMutableValue(
187 identifier->value().value(), Scope::SEARCH_NESTED, true);
187 if (!value) { 188 if (!value) {
188 *err = Err(identifier, "Undefined identifier."); 189 *err = Err(identifier, "Undefined identifier.");
189 return Value(); 190 return Value();
190 } 191 }
191 if (!value->VerifyTypeIs(Value::SCOPE, err)) 192 if (!value->VerifyTypeIs(Value::SCOPE, err))
192 return Value(); 193 return Value();
193 Scope* source = value->scope_value(); 194 Scope* source = value->scope_value();
194 195
195 // Extract the exclusion list if defined. 196 // Extract the exclusion list if defined.
196 std::set<std::string> exclusion_set; 197 std::set<std::string> exclusion_set;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 } 231 }
231 } 232 }
232 233
233 // Not the right type of argument. 234 // Not the right type of argument.
234 *err = Err(what_value, "Not a valid list of variables to copy.", 235 *err = Err(what_value, "Not a valid list of variables to copy.",
235 "Expecting either the string \"*\" or a list of strings."); 236 "Expecting either the string \"*\" or a list of strings.");
236 return Value(); 237 return Value();
237 } 238 }
238 239
239 } // namespace functions 240 } // namespace functions
OLDNEW
« no previous file with comments | « tools/gn/function_foreach.cc ('k') | tools/gn/functions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698