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/functions.h" | 5 #include "tools/gn/functions.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <iostream> | 8 #include <iostream> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 function, "target defaults", err)) | 94 function, "target defaults", err)) |
95 return false; | 95 return false; |
96 } | 96 } |
97 | 97 |
98 // The name is the single argument to the target function. | 98 // The name is the single argument to the target function. |
99 if (!EnsureSingleStringArg(function, args, err)) | 99 if (!EnsureSingleStringArg(function, args, err)) |
100 return false; | 100 return false; |
101 | 101 |
102 // Set the target name variable to the current target, and mark it used | 102 // Set the target name variable to the current target, and mark it used |
103 // because we don't want to issue an error if the script ignores it. | 103 // because we don't want to issue an error if the script ignores it. |
104 const base::StringPiece target_name("target_name"); | 104 const base::StringPiece target_name(variables::kTargetName); |
105 block_scope->SetValue(target_name, Value(function, args[0].string_value()), | 105 block_scope->SetValue(target_name, Value(function, args[0].string_value()), |
106 function); | 106 function); |
107 block_scope->MarkUsed(target_name); | 107 block_scope->MarkUsed(target_name); |
108 return true; | 108 return true; |
109 } | 109 } |
110 | 110 |
111 void FillNeedsBlockError(const FunctionCallNode* function, Err* err) { | 111 void FillNeedsBlockError(const FunctionCallNode* function, Err* err) { |
112 *err = Err(function->function(), "This function call requires a block.", | 112 *err = Err(function->function(), "This function call requires a block.", |
113 "The block's \"{\" must be on the same line as the function " | 113 "The block's \"{\" must be on the same line as the function " |
114 "call's \")\"."); | 114 "call's \")\"."); |
(...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1098 } | 1098 } |
1099 | 1099 |
1100 // Otherwise it's a no-block function. | 1100 // Otherwise it's a no-block function. |
1101 if (!VerifyNoBlockForFunctionCall(function, block, err)) | 1101 if (!VerifyNoBlockForFunctionCall(function, block, err)) |
1102 return Value(); | 1102 return Value(); |
1103 return found_function->second.no_block_runner(scope, function, | 1103 return found_function->second.no_block_runner(scope, function, |
1104 args.list_value(), err); | 1104 args.list_value(), err); |
1105 } | 1105 } |
1106 | 1106 |
1107 } // namespace functions | 1107 } // namespace functions |
OLD | NEW |