~ubuntu-branches/ubuntu/jaunty/cmake/jaunty-security

« back to all changes in this revision

Viewing changes to Source/cmMacroCommand.h

  • Committer: Bazaar Package Importer
  • Author(s): A. Maitland Bottoms
  • Date: 2005-03-02 09:22:44 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050302092244-y6o9j8wr27vqcqvx
Tags: 2.0.5-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*=========================================================================
 
2
 
 
3
  Program:   CMake - Cross-Platform Makefile Generator
 
4
  Module:    $RCSfile: cmMacroCommand.h,v $
 
5
  Language:  C++
 
6
  Date:      $Date: 2004/04/29 21:41:33 $
 
7
  Version:   $Revision: 1.8 $
 
8
 
 
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.
 
11
 
 
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.
 
15
 
 
16
=========================================================================*/
 
17
#ifndef cmMacroCommand_h
 
18
#define cmMacroCommand_h
 
19
 
 
20
#include "cmCommand.h"
 
21
#include "cmFunctionBlocker.h"
 
22
 
 
23
/** \class cmMacroFunctionBlocker
 
24
 * \brief subclass of function blocker
 
25
 *
 
26
 * 
 
27
 */
 
28
class cmMacroFunctionBlocker : public cmFunctionBlocker
 
29
{
 
30
public:
 
31
  cmMacroFunctionBlocker() {m_Executing = false;}
 
32
  virtual ~cmMacroFunctionBlocker() {}
 
33
  virtual bool IsFunctionBlocked(const cmListFileFunction&, cmMakefile &mf);
 
34
  virtual bool ShouldRemove(const cmListFileFunction&, cmMakefile &mf);
 
35
  virtual void ScopeEnded(cmMakefile &mf);
 
36
  
 
37
  std::vector<std::string> m_Args;
 
38
  std::vector<cmListFileFunction> m_Functions;
 
39
  bool m_Executing;
 
40
};
 
41
 
 
42
/** \class cmMacroCommand
 
43
 * \brief starts an if block
 
44
 *
 
45
 * cmMacroCommand starts an if block
 
46
 */
 
47
class cmMacroCommand : public cmCommand
 
48
{
 
49
public:
 
50
  /**
 
51
   * This is a virtual constructor for the command.
 
52
   */
 
53
  virtual cmCommand* Clone() 
 
54
    {
 
55
    return new cmMacroCommand;
 
56
    }
 
57
 
 
58
  /**
 
59
   * This is called when the command is first encountered in
 
60
   * the CMakeLists.txt file.
 
61
   */
 
62
  virtual bool InitialPass(std::vector<std::string> const& args);
 
63
 
 
64
  /**
 
65
   * This determines if the command gets propagated down
 
66
   * to makefiles located in subdirectories.
 
67
   */
 
68
  virtual bool IsInherited() {return true;}
 
69
 
 
70
  /**
 
71
   * This determines if the command is invoked when in script mode.
 
72
   */
 
73
  virtual bool IsScriptable() { return true; }
 
74
 
 
75
  /**
 
76
   * The name of the command as specified in CMakeList.txt.
 
77
   */
 
78
  virtual const char* GetName() { return "MACRO";}
 
79
 
 
80
  /**
 
81
   * Succinct documentation.
 
82
   */
 
83
  virtual const char* GetTerseDocumentation() 
 
84
    {
 
85
    return "Start recording a macro for later invocation as a command.";
 
86
    }
 
87
  
 
88
  /**
 
89
   * More documentation.
 
90
   */
 
91
  virtual const char* GetFullDocumentation()
 
92
    {
 
93
    return
 
94
      "  MACRO(<name> [arg1 [arg2 [arg3 ...]]])\n"
 
95
      "    COMMAND1(ARGS ...)\n"
 
96
      "    COMMAND2(ARGS ...)\n"
 
97
      "    ...\n"
 
98
      "  ENDMACRO(<name>)\n"
 
99
      "Define a macro named <name> that takes arguments named "
 
100
      "arg1 arg2 arg3 (...).  Commands listed after MACRO, "
 
101
      "but before the matching ENDMACRO, are not invoked until the macro "
 
102
      "is invoked.  When it is invoked, the commands recorded in the "
 
103
      "macro are first modified by replacing formal parameters (${arg1}) with "
 
104
      "the arguments passed, and then invoked as normal commands. In "
 
105
      "addition to referencing the formal parameters you can reference "
 
106
      "the variable ARGC which will be set to the number of arguments "
 
107
      "passed into the function as well as ARGV0 ARGV1 ARGV2 ... which "
 
108
      "will have the actual values of the arguments passed in. This "
 
109
      "fascilitates creating macros with optional arguments. Additionally "
 
110
      "ARGV holds the list of all arguments given to the macro and ARGN "
 
111
      "holds the list of argument pass the last expected argument.";
 
112
    }
 
113
  
 
114
  cmTypeMacro(cmMacroCommand, cmCommand);
 
115
};
 
116
 
 
117
 
 
118
#endif