]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /*\r |
2 | *\r | |
3 | * Copyright 2004 The Ant-Contrib project\r | |
4 | *\r | |
5 | * Licensed under the Apache License, Version 2.0 (the "License");\r | |
6 | * you may not use this file except in compliance with the License.\r | |
7 | * You may obtain a copy of the License at\r | |
8 | *\r | |
9 | * http://www.apache.org/licenses/LICENSE-2.0\r | |
10 | *\r | |
11 | * Unless required by applicable law or agreed to in writing, software\r | |
12 | * distributed under the License is distributed on an "AS IS" BASIS,\r | |
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r | |
14 | * See the License for the specific language governing permissions and\r | |
15 | * limitations under the License.\r | |
16 | */\r | |
17 | package net.sf.antcontrib.cpptasks;\r | |
18 | \r | |
19 | import org.apache.tools.ant.types.DataType;\r | |
20 | import org.apache.tools.ant.types.Reference;\r | |
21 | \r | |
22 | /**\r | |
23 | * Information on the execution platforms for the generated code.\r | |
24 | * (Non-functional prototype)\r | |
25 | *\r | |
26 | */\r | |
27 | public final class TargetDef\r | |
28 | extends DataType {\r | |
29 | /**\r | |
30 | * if property.\r | |
31 | */\r | |
32 | private String ifCond;\r | |
33 | \r | |
34 | /**\r | |
35 | * unless property.\r | |
36 | */\r | |
37 | private String unlessCond;\r | |
38 | \r | |
39 | /**\r | |
40 | * cpu.\r | |
41 | *\r | |
42 | */\r | |
43 | private CPUEnum cpu;\r | |
44 | \r | |
45 | /**\r | |
46 | * architecture.\r | |
47 | *\r | |
48 | */\r | |
49 | private ArchEnum arch;\r | |
50 | \r | |
51 | /**\r | |
52 | * OS Family.\r | |
53 | *\r | |
54 | */\r | |
55 | private OSFamilyEnum osFamily;\r | |
56 | \r | |
57 | /**\r | |
58 | * Constructor.\r | |
59 | *\r | |
60 | */\r | |
61 | public TargetDef() {\r | |
62 | }\r | |
63 | \r | |
64 | /**\r | |
65 | * Bogus method required for documentation generation.\r | |
66 | */\r | |
67 | public void execute() {\r | |
68 | throw new org.apache.tools.ant.BuildException(\r | |
69 | "Not an actual task, but looks like one for documentation purposes");\r | |
70 | }\r | |
71 | \r | |
72 | /**\r | |
73 | * Returns true if the define's if and unless conditions (if any) are\r | |
74 | * satisfied.\r | |
75 | * @return true if active\r | |
76 | */\r | |
77 | public boolean isActive() {\r | |
78 | return CUtil.isActive(getProject(), ifCond, unlessCond);\r | |
79 | }\r | |
80 | \r | |
81 | /**\r | |
82 | * Sets a description of the current data type.\r | |
83 | * @param desc description\r | |
84 | */\r | |
85 | public void setDescription(final String desc) {\r | |
86 | super.setDescription(desc);\r | |
87 | }\r | |
88 | \r | |
89 | /**\r | |
90 | * Sets an id that can be used to reference this element.\r | |
91 | *\r | |
92 | * @param id\r | |
93 | * id\r | |
94 | */\r | |
95 | public void setId(final String id) {\r | |
96 | //\r | |
97 | // this is actually accomplished by a different\r | |
98 | // mechanism, but we can document it\r | |
99 | //\r | |
100 | }\r | |
101 | \r | |
102 | /**\r | |
103 | * Sets the property name for the 'if' condition.\r | |
104 | *\r | |
105 | * The define will be ignored unless the property is defined.\r | |
106 | *\r | |
107 | * The value of the property is insignificant, but values that would imply\r | |
108 | * misinterpretation ("false", "no") will throw an exception when\r | |
109 | * evaluated.\r | |
110 | *\r | |
111 | * @param propName\r | |
112 | * property name\r | |
113 | */\r | |
114 | public void setIf(final String propName) {\r | |
115 | ifCond = propName;\r | |
116 | }\r | |
117 | \r | |
118 | /**\r | |
119 | * Specifies that this element should behave as if the content of the\r | |
120 | * element with the matching id attribute was inserted at this location. If\r | |
121 | * specified, no other attributes should be specified.\r | |
122 | * @param r id of referenced target\r | |
123 | */\r | |
124 | public void setRefid(final Reference r) {\r | |
125 | super.setRefid(r);\r | |
126 | }\r | |
127 | \r | |
128 | /**\r | |
129 | * Set the property name for the 'unless' condition.\r | |
130 | *\r | |
131 | * If named property is set, the define will be ignored.\r | |
132 | *\r | |
133 | * The value of the property is insignificant, but values that would imply\r | |
134 | * misinterpretation ("false", "no") of the behavior will throw an\r | |
135 | * exception when evaluated.\r | |
136 | *\r | |
137 | * @param propName\r | |
138 | * name of property\r | |
139 | */\r | |
140 | public void setUnless(final String propName) {\r | |
141 | unlessCond = propName;\r | |
142 | }\r | |
143 | \r | |
144 | /**\r | |
145 | * Gets cpu.\r | |
146 | * @return cpu, may be null.\r | |
147 | *\r | |
148 | */\r | |
149 | public CPUEnum getCpu() {\r | |
150 | if (isReference()) {\r | |
151 | TargetDef refPlatform = (TargetDef)\r | |
152 | getCheckedRef(TargetDef.class,\r | |
153 | "TargetDef");\r | |
154 | return refPlatform.getCpu();\r | |
155 | }\r | |
156 | return cpu;\r | |
157 | }\r | |
158 | \r | |
159 | /**\r | |
160 | * Gets arch.\r | |
161 | * @return arch, may be null.\r | |
162 | *\r | |
163 | */\r | |
164 | public ArchEnum getArch() {\r | |
165 | if (isReference()) {\r | |
166 | TargetDef refPlatform = (TargetDef)\r | |
167 | getCheckedRef(TargetDef.class,\r | |
168 | "TargetDef");\r | |
169 | return refPlatform.getArch();\r | |
170 | }\r | |
171 | return arch;\r | |
172 | }\r | |
173 | \r | |
174 | /**\r | |
175 | * Gets operating system family.\r | |
176 | * @return os family, may be null.\r | |
177 | *\r | |
178 | */\r | |
179 | public OSFamilyEnum getOsfamily() {\r | |
180 | if (isReference()) {\r | |
181 | TargetDef refPlatform = (TargetDef)\r | |
182 | getCheckedRef(TargetDef.class,\r | |
183 | "TargetDef");\r | |
184 | return refPlatform.getOsfamily();\r | |
185 | }\r | |
186 | return osFamily;\r | |
187 | }\r | |
188 | \r | |
189 | /**\r | |
190 | * Sets preferred cpu, but does not use cpu specific instructions.\r | |
191 | * @param value new value\r | |
192 | */\r | |
193 | public void setCpu(final CPUEnum value) {\r | |
194 | if (isReference()) {\r | |
195 | throw tooManyAttributes();\r | |
196 | }\r | |
197 | cpu = value;\r | |
198 | }\r | |
199 | \r | |
200 | /**\r | |
201 | * Sets cpu architecture, compiler may use cpu specific instructions.\r | |
202 | * @param value new value\r | |
203 | */\r | |
204 | public void setArch(final ArchEnum value) {\r | |
205 | if (isReference()) {\r | |
206 | throw tooManyAttributes();\r | |
207 | }\r | |
208 | if (cpu != null) {\r | |
209 | throw tooManyAttributes();\r | |
210 | }\r | |
211 | arch = value;\r | |
212 | }\r | |
213 | \r | |
214 | /**\r | |
215 | * Sets operating system family.\r | |
216 | * @param value new value\r | |
217 | */\r | |
218 | public void setOsfamily(final OSFamilyEnum value) {\r | |
219 | if (isReference()) {\r | |
220 | throw tooManyAttributes();\r | |
221 | }\r | |
222 | if (cpu != null) {\r | |
223 | throw tooManyAttributes();\r | |
224 | }\r | |
225 | osFamily = value;\r | |
226 | }\r | |
227 | \r | |
228 | }\r |