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 <iostream> | 7 #include <iostream> |
8 | 8 |
9 #include "base/environment.h" | 9 #include "base/environment.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 is_target); | 702 is_target); |
703 | 703 |
704 INSERT_FUNCTION(Action, true) | 704 INSERT_FUNCTION(Action, true) |
705 INSERT_FUNCTION(ActionForEach, true) | 705 INSERT_FUNCTION(ActionForEach, true) |
706 INSERT_FUNCTION(Copy, true) | 706 INSERT_FUNCTION(Copy, true) |
707 INSERT_FUNCTION(Executable, true) | 707 INSERT_FUNCTION(Executable, true) |
708 INSERT_FUNCTION(Group, true) | 708 INSERT_FUNCTION(Group, true) |
709 INSERT_FUNCTION(SharedLibrary, true) | 709 INSERT_FUNCTION(SharedLibrary, true) |
710 INSERT_FUNCTION(SourceSet, true) | 710 INSERT_FUNCTION(SourceSet, true) |
711 INSERT_FUNCTION(StaticLibrary, true) | 711 INSERT_FUNCTION(StaticLibrary, true) |
| 712 INSERT_FUNCTION(Target, true) |
712 | 713 |
713 INSERT_FUNCTION(Assert, false) | 714 INSERT_FUNCTION(Assert, false) |
714 INSERT_FUNCTION(Config, false) | 715 INSERT_FUNCTION(Config, false) |
715 INSERT_FUNCTION(DeclareArgs, false) | 716 INSERT_FUNCTION(DeclareArgs, false) |
716 INSERT_FUNCTION(Defined, false) | 717 INSERT_FUNCTION(Defined, false) |
717 INSERT_FUNCTION(ExecScript, false) | 718 INSERT_FUNCTION(ExecScript, false) |
718 INSERT_FUNCTION(ForEach, false) | 719 INSERT_FUNCTION(ForEach, false) |
| 720 INSERT_FUNCTION(ForwardVariablesFrom, false) |
719 INSERT_FUNCTION(GetEnv, false) | 721 INSERT_FUNCTION(GetEnv, false) |
720 INSERT_FUNCTION(GetLabelInfo, false) | 722 INSERT_FUNCTION(GetLabelInfo, false) |
721 INSERT_FUNCTION(GetPathInfo, false) | 723 INSERT_FUNCTION(GetPathInfo, false) |
722 INSERT_FUNCTION(GetTargetOutputs, false) | 724 INSERT_FUNCTION(GetTargetOutputs, false) |
723 INSERT_FUNCTION(Import, false) | 725 INSERT_FUNCTION(Import, false) |
724 INSERT_FUNCTION(Print, false) | 726 INSERT_FUNCTION(Print, false) |
725 INSERT_FUNCTION(ProcessFileTemplate, false) | 727 INSERT_FUNCTION(ProcessFileTemplate, false) |
726 INSERT_FUNCTION(ReadFile, false) | 728 INSERT_FUNCTION(ReadFile, false) |
727 INSERT_FUNCTION(RebasePath, false) | 729 INSERT_FUNCTION(RebasePath, false) |
728 INSERT_FUNCTION(SetDefaults, false) | 730 INSERT_FUNCTION(SetDefaults, false) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 if (err->has_error()) | 764 if (err->has_error()) |
763 return Value(); | 765 return Value(); |
764 return templ->Invoke(scope, function, args.list_value(), block, err); | 766 return templ->Invoke(scope, function, args.list_value(), block, err); |
765 } | 767 } |
766 | 768 |
767 *err = Err(name, "Unknown function."); | 769 *err = Err(name, "Unknown function."); |
768 return Value(); | 770 return Value(); |
769 } | 771 } |
770 | 772 |
771 if (found_function->second.self_evaluating_args_runner) { | 773 if (found_function->second.self_evaluating_args_runner) { |
772 // Self evaluating args functions are special weird built-ins. Currently, | 774 // Self evaluating args functions are special weird built-ins like foreach. |
773 // only foreach() takes a block following it. Rather than force them all to | 775 // Rather than force them all to check that they have a block or no block |
774 // check that they have a block or no block and risk bugs for new additions, | 776 // and risk bugs for new additions, check a whitelist here. |
775 // check a whitelist here. | |
776 if (found_function->second.self_evaluating_args_runner != &RunForEach) { | 777 if (found_function->second.self_evaluating_args_runner != &RunForEach) { |
777 if (!VerifyNoBlockForFunctionCall(function, block, err)) | 778 if (!VerifyNoBlockForFunctionCall(function, block, err)) |
778 return Value(); | 779 return Value(); |
779 } | 780 } |
780 return found_function->second.self_evaluating_args_runner( | 781 return found_function->second.self_evaluating_args_runner( |
781 scope, function, args_list, err); | 782 scope, function, args_list, err); |
782 } | 783 } |
783 | 784 |
784 // All other function types take a pre-executed set of args. | 785 // All other function types take a pre-executed set of args. |
785 Value args = args_list->Execute(scope, err); | 786 Value args = args_list->Execute(scope, err); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 } | 818 } |
818 | 819 |
819 // Otherwise it's a no-block function. | 820 // Otherwise it's a no-block function. |
820 if (!VerifyNoBlockForFunctionCall(function, block, err)) | 821 if (!VerifyNoBlockForFunctionCall(function, block, err)) |
821 return Value(); | 822 return Value(); |
822 return found_function->second.no_block_runner(scope, function, | 823 return found_function->second.no_block_runner(scope, function, |
823 args.list_value(), err); | 824 args.list_value(), err); |
824 } | 825 } |
825 | 826 |
826 } // namespace functions | 827 } // namespace functions |
OLD | NEW |