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

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

Issue 1841013003: Update GN documentation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 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/docs/style_guide.md ('k') | no next file » | 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) 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/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 {
11 11
12 const char kForEach[] = "foreach"; 12 const char kForEach[] = "foreach";
13 const char kForEach_HelpShort[] = 13 const char kForEach_HelpShort[] =
14 "foreach: Iterate over a list."; 14 "foreach: Iterate over a list.";
15 const char kForEach_Help[] = 15 const char kForEach_Help[] =
16 "foreach: Iterate over a list.\n" 16 "foreach: Iterate over a list.\n"
17 "\n" 17 "\n"
18 " foreach(<loop_var>, <list>) {\n" 18 " foreach(<loop_var>, <list>) {\n"
19 " <loop contents>\n" 19 " <loop contents>\n"
20 " }\n" 20 " }\n"
21 "\n" 21 "\n"
22 " Executes the loop contents block over each item in the list,\n" 22 " Executes the loop contents block over each item in the list,\n"
23 " assigning the loop_var to each item in sequence.\n" 23 " assigning the loop_var to each item in sequence. The loop_var will be\n"
24 " a copy so assigning to it will not mutate the list.\n"
24 "\n" 25 "\n"
25 " The block does not introduce a new scope, so that variable assignments\n" 26 " The block does not introduce a new scope, so that variable assignments\n"
26 " inside the loop will be visible once the loop terminates.\n" 27 " inside the loop will be visible once the loop terminates.\n"
27 "\n" 28 "\n"
28 " The loop variable will temporarily shadow any existing variables with\n" 29 " The loop variable will temporarily shadow any existing variables with\n"
29 " the same name for the duration of the loop. After the loop terminates\n" 30 " the same name for the duration of the loop. After the loop terminates\n"
30 " the loop variable will no longer be in scope, and the previous value\n" 31 " the loop variable will no longer be in scope, and the previous value\n"
31 " (if any) will be restored.\n" 32 " (if any) will be restored.\n"
32 "\n" 33 "\n"
33 "Example\n" 34 "Example\n"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 scope->SetValue(loop_var, old_loop_value, old_loop_value.origin()); 112 scope->SetValue(loop_var, old_loop_value, old_loop_value.origin());
112 } else { 113 } else {
113 // Loop variable was undefined before loop, delete it. 114 // Loop variable was undefined before loop, delete it.
114 scope->RemoveIdentifier(loop_var); 115 scope->RemoveIdentifier(loop_var);
115 } 116 }
116 117
117 return Value(); 118 return Value();
118 } 119 }
119 120
120 } // namespace functions 121 } // namespace functions
OLDNEW
« no previous file with comments | « tools/gn/docs/style_guide.md ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698