LRDE Tiger Compiler  1.34a $Id: 7fef12e1f5fa43449d667a0eec1d837c40fc1202 $
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
libtask.hh
Go to the documentation of this file.
1 
7 /* This file must not be protected against multiple inclusion,
8  because it might be read to define or declare the tasks. */
9 
10 #include <task/boolean-task.hh>
11 #include <task/function-task.hh>
12 #include <task/int-task.hh>
13 #include <task/string-task.hh>
15 #include <task/disjunctive-task.hh>
16 
18 namespace task {}
19 
21 # define CONCAT_(A, B) A ## B
22 # define CONCAT(A, B) CONCAT_(A, B)
23 
32 # define TASK_UNIQUE() CONCAT(task_, __LINE__)
33 
34 /*------------------------------.
35 | Easy instantiation of Tasks. |
36 `------------------------------*/
37 
38 #undef TASK_GROUP
39 #undef TASK_DECLARE
40 #undef BOOLEAN_TASK_DECLARE
41 #undef INT_TASK_DECLARE
42 #undef STRING_TASK_DECLARE
43 #undef MULTIPLE_STRING_TASK_DECLARE
44 #undef DISJUNCTIVE_TASK_DECLARE
45 
46 // Should we define the objects, or just declare them?
47 #if DEFINE_TASKS
48 
50 # define TASK_GROUP(Name) \
51  const char group_name[] = Name
52 
54 # define TASK_DECLARE(Name, Help, Routine, Deps) \
55  extern void (Routine) (); \
56  static task::FunctionTask task_##Routine(Routine, group_name, Help, \
57  Name, Deps)
58 
60 # define BOOLEAN_TASK_DECLARE(Name, Help, Flag, Deps) \
61  bool Flag; \
62  static task::BooleanTask task_##Flag(Flag, group_name, Help, \
63  Name, Deps)
64 
65 # define TASK_UNIQUE_NAME_(Line) \
66  task_##Line
67 
68 # define TASK_UNIQUE_NAME \
69  TASK_UNIQUE_NAME_(__LINE__)
70 
72 # define INT_TASK_DECLARE(Name, Min, Max, Help, Flag, Deps) \
73  static task::IntTask TASK_UNIQUE() (Flag, Min, Max, group_name, \
74  Help, Name, Deps)
75 
76 
78 # define STRING_TASK_DECLARE(Name, Default, Help, Flag, Deps) \
79  std::string Flag = Default; \
80  static task::StringTask task_##Flag(Flag, group_name, Help, \
81  Name, Deps)
82 
84 # define MULTIPLE_STRING_TASK_DECLARE(Name, Help, Routine, Deps) \
85  extern task::MultipleStringTask::callback_type Routine; \
86  static task::MultipleStringTask task_##Routine(Routine, group_name, \
87  Help, Name, \
88  Deps)
89 
91 # define DISJUNCTIVE_TASK_DECLARE(Name, Help, Deps) \
92  static task::DisjunctiveTask task_##Routine(group_name, Help, \
93  Name, Deps)
94 
95 #else // !DEFINE_TASKS
96 
98 # define TASK_GROUP(Name) \
99  extern const char* group_name
100 
101 # define TASK_DECLARE(Name, Help, Routine, Deps) \
102  extern void (Routine) ()
103 
104 # define BOOLEAN_TASK_DECLARE(Name, Help, Flag, Deps) \
105  extern bool Flag;
106 
107 # define INT_TASK_DECLARE(Name, Min, Max, Help, Flag, Deps)
108 
109 # define STRING_TASK_DECLARE(Name, Default, Help, Flag, Deps) \
110  extern std::string Flag;
111 
112 # define MULTIPLE_STRING_TASK_DECLARE(Name, Help, Routine, Deps) \
113  extern void (Routine) (std::string);
114 
115 # define DISJUNCTIVE_TASK_DECLARE(Name, Help, Deps)
116 
117 #endif // !DEFINE_TASKS