Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmFunctionCommand.h
blobf6973849911268607e21ce688daad509ce3ff0ae
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmFunctionCommand.h,v $
5 Language: C++
6 Date: $Date: 2009-01-22 18:16:47 $
7 Version: $Revision: 1.5 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #ifndef cmFunctionCommand_h
18 #define cmFunctionCommand_h
20 #include "cmCommand.h"
21 #include "cmFunctionBlocker.h"
23 /** \class cmFunctionFunctionBlocker
24 * \brief subclass of function blocker
28 class cmFunctionFunctionBlocker : public cmFunctionBlocker
30 public:
31 cmFunctionFunctionBlocker() {this->Depth=0;}
32 virtual ~cmFunctionFunctionBlocker() {}
33 virtual bool IsFunctionBlocked(const cmListFileFunction&,
34 cmMakefile &mf,
35 cmExecutionStatus &);
36 virtual bool ShouldRemove(const cmListFileFunction&, cmMakefile &mf);
38 std::vector<std::string> Args;
39 std::vector<cmListFileFunction> Functions;
40 int Depth;
43 /** \class cmFunctionCommand
44 * \brief starts an if block
46 * cmFunctionCommand starts an if block
48 class cmFunctionCommand : public cmCommand
50 public:
51 /**
52 * This is a virtual constructor for the command.
54 virtual cmCommand* Clone()
56 return new cmFunctionCommand;
59 /**
60 * This is called when the command is first encountered in
61 * the CMakeLists.txt file.
63 virtual bool InitialPass(std::vector<std::string> const& args,
64 cmExecutionStatus &status);
66 /**
67 * This determines if the command is invoked when in script mode.
69 virtual bool IsScriptable() { return true; }
71 /**
72 * The name of the command as specified in CMakeList.txt.
74 virtual const char* GetName() { return "function";}
76 /**
77 * Succinct documentation.
79 virtual const char* GetTerseDocumentation()
81 return "Start recording a function for later invocation as a command.";
84 /**
85 * More documentation.
87 virtual const char* GetFullDocumentation()
89 return
90 " function(<name> [arg1 [arg2 [arg3 ...]]])\n"
91 " COMMAND1(ARGS ...)\n"
92 " COMMAND2(ARGS ...)\n"
93 " ...\n"
94 " endfunction(<name>)\n"
95 "Define a function named <name> that takes arguments named "
96 "arg1 arg2 arg3 (...). Commands listed after function, but before "
97 "the matching endfunction, are not invoked until the function "
98 "is invoked. When it is invoked, the commands recorded in the "
99 "function are first modified by replacing formal parameters (${arg1}) "
100 "with the arguments passed, and then invoked as normal commands. In "
101 "addition to referencing the formal parameters you can reference "
102 "the variable ARGC which will be set to the number of arguments "
103 "passed into the function as well as ARGV0 ARGV1 ARGV2 ... which "
104 "will have the actual values of the arguments passed in. This "
105 "facilitates creating functions with optional arguments. Additionally "
106 "ARGV holds the list of all arguments given to the function and ARGN "
107 "holds the list of argument pass the last expected argument."
108 "\n"
109 "See the cmake_policy() command documentation for the behavior of "
110 "policies inside functions."
114 cmTypeMacro(cmFunctionCommand, cmCommand);
118 #endif