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 #ifndef TOOLS_GN_FUNCTIONS_H_ | 5 #ifndef TOOLS_GN_FUNCTIONS_H_ |
6 #define TOOLS_GN_FUNCTIONS_H_ | 6 #define TOOLS_GN_FUNCTIONS_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 | 423 |
424 // Returns the name of the toolchain for the given scope. | 424 // Returns the name of the toolchain for the given scope. |
425 const Label& ToolchainLabelForScope(const Scope* scope); | 425 const Label& ToolchainLabelForScope(const Scope* scope); |
426 | 426 |
427 // Generates a label for the given scope, using the current directory and | 427 // Generates a label for the given scope, using the current directory and |
428 // toolchain, and the given name. | 428 // toolchain, and the given name. |
429 Label MakeLabelForScope(const Scope* scope, | 429 Label MakeLabelForScope(const Scope* scope, |
430 const FunctionCallNode* function, | 430 const FunctionCallNode* function, |
431 const std::string& name); | 431 const std::string& name); |
432 | 432 |
| 433 // Some tyesp of blocks can't be nested inside other ones. For such cases, |
| 434 // instantiate this object upon entering the block and Enter() will fail if |
| 435 // there is already another non-nestable block on the stack. |
| 436 class NonNestableBlock { |
| 437 public: |
| 438 enum Type { |
| 439 CONFIG, |
| 440 DECLARE_ARGS, |
| 441 TARGET, |
| 442 TEMPLATE, |
| 443 TOOLCHAIN, |
| 444 }; |
| 445 |
| 446 // type_description is a string that will be used in error messages |
| 447 // describing the type of the block, for example, "template" or "config". |
| 448 NonNestableBlock(Scope* scope, |
| 449 const FunctionCallNode* function, |
| 450 const char* type_description); |
| 451 ~NonNestableBlock(); |
| 452 |
| 453 bool Enter(Err* err); |
| 454 |
| 455 private: |
| 456 // Used as a void* key for the Scope to track our property. The actual value |
| 457 // is never used. |
| 458 static const int kKey; |
| 459 |
| 460 Scope* scope_; |
| 461 const FunctionCallNode* function_; |
| 462 const char* type_description_; |
| 463 |
| 464 // Set to true when the key is added to the scope so we don't try to |
| 465 // delete nonexistant keys which will cause assertions. |
| 466 bool key_added_; |
| 467 }; |
| 468 |
433 #endif // TOOLS_GN_FUNCTIONS_H_ | 469 #endif // TOOLS_GN_FUNCTIONS_H_ |
OLD | NEW |