Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #ifndef TRANSFRMX_TXINSTRUCTIONS_H
7 : #define TRANSFRMX_TXINSTRUCTIONS_H
8 :
9 : #include "nsCOMPtr.h"
10 : #include "txCore.h"
11 : #include "nsString.h"
12 : #include "txXMLUtils.h"
13 : #include "txExpandedName.h"
14 : #include "txNamespaceMap.h"
15 : #include "nsAutoPtr.h"
16 : #include "txXSLTNumber.h"
17 : #include "nsTArray.h"
18 :
19 : class nsIAtom;
20 : class txExecutionState;
21 :
22 : class txInstruction : public txObject
23 : {
24 : public:
25 0 : txInstruction()
26 0 : {
27 0 : MOZ_COUNT_CTOR(txInstruction);
28 0 : }
29 :
30 0 : virtual ~txInstruction()
31 0 : {
32 0 : MOZ_COUNT_DTOR(txInstruction);
33 0 : }
34 :
35 : virtual nsresult execute(txExecutionState& aEs) = 0;
36 :
37 : nsAutoPtr<txInstruction> mNext;
38 : };
39 :
40 : #define TX_DECL_TXINSTRUCTION \
41 : virtual nsresult execute(txExecutionState& aEs);
42 :
43 :
44 0 : class txApplyDefaultElementTemplate : public txInstruction
45 : {
46 : public:
47 : TX_DECL_TXINSTRUCTION
48 : };
49 :
50 0 : class txApplyImports : public txInstruction
51 : {
52 : public:
53 : TX_DECL_TXINSTRUCTION
54 : };
55 :
56 0 : class txApplyTemplates : public txInstruction
57 : {
58 : public:
59 : explicit txApplyTemplates(const txExpandedName& aMode);
60 :
61 : TX_DECL_TXINSTRUCTION
62 :
63 : txExpandedName mMode;
64 : };
65 :
66 0 : class txAttribute : public txInstruction
67 : {
68 : public:
69 : txAttribute(nsAutoPtr<Expr>&& aName, nsAutoPtr<Expr>&& aNamespace,
70 : txNamespaceMap* aMappings);
71 :
72 : TX_DECL_TXINSTRUCTION
73 :
74 : nsAutoPtr<Expr> mName;
75 : nsAutoPtr<Expr> mNamespace;
76 : RefPtr<txNamespaceMap> mMappings;
77 : };
78 :
79 0 : class txCallTemplate : public txInstruction
80 : {
81 : public:
82 : explicit txCallTemplate(const txExpandedName& aName);
83 :
84 : TX_DECL_TXINSTRUCTION
85 :
86 : txExpandedName mName;
87 : };
88 :
89 0 : class txCheckParam : public txInstruction
90 : {
91 : public:
92 : explicit txCheckParam(const txExpandedName& aName);
93 :
94 : TX_DECL_TXINSTRUCTION
95 :
96 : txExpandedName mName;
97 : txInstruction* mBailTarget;
98 : };
99 :
100 0 : class txConditionalGoto : public txInstruction
101 : {
102 : public:
103 : txConditionalGoto(nsAutoPtr<Expr>&& aCondition, txInstruction* aTarget);
104 :
105 : TX_DECL_TXINSTRUCTION
106 :
107 : nsAutoPtr<Expr> mCondition;
108 : txInstruction* mTarget;
109 : };
110 :
111 0 : class txComment : public txInstruction
112 : {
113 : public:
114 : TX_DECL_TXINSTRUCTION
115 : };
116 :
117 0 : class txCopyBase : public txInstruction
118 : {
119 : protected:
120 : nsresult copyNode(const txXPathNode& aNode, txExecutionState& aEs);
121 : };
122 :
123 0 : class txCopy : public txCopyBase
124 : {
125 : public:
126 : txCopy();
127 :
128 : TX_DECL_TXINSTRUCTION
129 :
130 : txInstruction* mBailTarget;
131 : };
132 :
133 0 : class txCopyOf : public txCopyBase
134 : {
135 : public:
136 : explicit txCopyOf(nsAutoPtr<Expr>&& aSelect);
137 :
138 : TX_DECL_TXINSTRUCTION
139 :
140 : nsAutoPtr<Expr> mSelect;
141 : };
142 :
143 0 : class txEndElement : public txInstruction
144 : {
145 : public:
146 : TX_DECL_TXINSTRUCTION
147 : };
148 :
149 0 : class txErrorInstruction : public txInstruction
150 : {
151 : public:
152 : TX_DECL_TXINSTRUCTION
153 : };
154 :
155 0 : class txGoTo : public txInstruction
156 : {
157 : public:
158 : explicit txGoTo(txInstruction* aTarget);
159 :
160 : TX_DECL_TXINSTRUCTION
161 :
162 : txInstruction* mTarget;
163 : };
164 :
165 0 : class txInsertAttrSet : public txInstruction
166 : {
167 : public:
168 : explicit txInsertAttrSet(const txExpandedName& aName);
169 :
170 : TX_DECL_TXINSTRUCTION
171 :
172 : txExpandedName mName;
173 : };
174 :
175 0 : class txLoopNodeSet : public txInstruction
176 : {
177 : public:
178 : explicit txLoopNodeSet(txInstruction* aTarget);
179 :
180 : TX_DECL_TXINSTRUCTION
181 :
182 : txInstruction* mTarget;
183 : };
184 :
185 0 : class txLREAttribute : public txInstruction
186 : {
187 : public:
188 : txLREAttribute(int32_t aNamespaceID, nsIAtom* aLocalName,
189 : nsIAtom* aPrefix, nsAutoPtr<Expr>&& aValue);
190 :
191 : TX_DECL_TXINSTRUCTION
192 :
193 : int32_t mNamespaceID;
194 : nsCOMPtr<nsIAtom> mLocalName;
195 : nsCOMPtr<nsIAtom> mLowercaseLocalName;
196 : nsCOMPtr<nsIAtom> mPrefix;
197 : nsAutoPtr<Expr> mValue;
198 : };
199 :
200 0 : class txMessage : public txInstruction
201 : {
202 : public:
203 : explicit txMessage(bool aTerminate);
204 :
205 : TX_DECL_TXINSTRUCTION
206 :
207 : bool mTerminate;
208 : };
209 :
210 0 : class txNumber : public txInstruction
211 : {
212 : public:
213 : txNumber(txXSLTNumber::LevelType aLevel, nsAutoPtr<txPattern>&& aCount,
214 : nsAutoPtr<txPattern>&& aFrom, nsAutoPtr<Expr>&& aValue,
215 : nsAutoPtr<Expr>&& aFormat, nsAutoPtr<Expr>&& aGroupingSeparator,
216 : nsAutoPtr<Expr>&& aGroupingSize);
217 :
218 : TX_DECL_TXINSTRUCTION
219 :
220 : txXSLTNumber::LevelType mLevel;
221 : nsAutoPtr<txPattern> mCount;
222 : nsAutoPtr<txPattern> mFrom;
223 : nsAutoPtr<Expr> mValue;
224 : nsAutoPtr<Expr> mFormat;
225 : nsAutoPtr<Expr> mGroupingSeparator;
226 : nsAutoPtr<Expr> mGroupingSize;
227 : };
228 :
229 0 : class txPopParams : public txInstruction
230 : {
231 : public:
232 : TX_DECL_TXINSTRUCTION
233 : };
234 :
235 0 : class txProcessingInstruction : public txInstruction
236 : {
237 : public:
238 : explicit txProcessingInstruction(nsAutoPtr<Expr>&& aName);
239 :
240 : TX_DECL_TXINSTRUCTION
241 :
242 : nsAutoPtr<Expr> mName;
243 : };
244 :
245 : class txPushNewContext : public txInstruction
246 : {
247 : public:
248 : explicit txPushNewContext(nsAutoPtr<Expr>&& aSelect);
249 : ~txPushNewContext();
250 :
251 : TX_DECL_TXINSTRUCTION
252 :
253 :
254 : nsresult addSort(nsAutoPtr<Expr>&& aSelectExpr,
255 : nsAutoPtr<Expr>&& aLangExpr,
256 : nsAutoPtr<Expr>&& aDataTypeExpr,
257 : nsAutoPtr<Expr>&& aOrderExpr,
258 : nsAutoPtr<Expr>&& aCaseOrderExpr);
259 :
260 0 : struct SortKey {
261 : nsAutoPtr<Expr> mSelectExpr;
262 : nsAutoPtr<Expr> mLangExpr;
263 : nsAutoPtr<Expr> mDataTypeExpr;
264 : nsAutoPtr<Expr> mOrderExpr;
265 : nsAutoPtr<Expr> mCaseOrderExpr;
266 : };
267 :
268 : nsTArray<SortKey> mSortKeys;
269 : nsAutoPtr<Expr> mSelect;
270 : txInstruction* mBailTarget;
271 : };
272 :
273 0 : class txPushNullTemplateRule : public txInstruction
274 : {
275 : public:
276 : TX_DECL_TXINSTRUCTION
277 : };
278 :
279 0 : class txPushParams : public txInstruction
280 : {
281 : public:
282 : TX_DECL_TXINSTRUCTION
283 : };
284 :
285 0 : class txPushRTFHandler : public txInstruction
286 : {
287 : public:
288 : TX_DECL_TXINSTRUCTION
289 : };
290 :
291 0 : class txPushStringHandler : public txInstruction
292 : {
293 : public:
294 : explicit txPushStringHandler(bool aOnlyText);
295 :
296 : TX_DECL_TXINSTRUCTION
297 :
298 : bool mOnlyText;
299 : };
300 :
301 0 : class txRemoveVariable : public txInstruction
302 : {
303 : public:
304 : explicit txRemoveVariable(const txExpandedName& aName);
305 :
306 : TX_DECL_TXINSTRUCTION
307 :
308 : txExpandedName mName;
309 : };
310 :
311 0 : class txReturn : public txInstruction
312 : {
313 : public:
314 : TX_DECL_TXINSTRUCTION
315 : };
316 :
317 0 : class txSetParam : public txInstruction
318 : {
319 : public:
320 : txSetParam(const txExpandedName& aName, nsAutoPtr<Expr>&& aValue);
321 :
322 : TX_DECL_TXINSTRUCTION
323 :
324 : txExpandedName mName;
325 : nsAutoPtr<Expr> mValue;
326 : };
327 :
328 0 : class txSetVariable : public txInstruction
329 : {
330 : public:
331 : txSetVariable(const txExpandedName& aName, nsAutoPtr<Expr>&& aValue);
332 :
333 : TX_DECL_TXINSTRUCTION
334 :
335 : txExpandedName mName;
336 : nsAutoPtr<Expr> mValue;
337 : };
338 :
339 0 : class txStartElement : public txInstruction
340 : {
341 : public:
342 : txStartElement(nsAutoPtr<Expr>&& aName, nsAutoPtr<Expr>&& aNamespace,
343 : txNamespaceMap* aMappings);
344 :
345 : TX_DECL_TXINSTRUCTION
346 :
347 : nsAutoPtr<Expr> mName;
348 : nsAutoPtr<Expr> mNamespace;
349 : RefPtr<txNamespaceMap> mMappings;
350 : };
351 :
352 0 : class txStartLREElement : public txInstruction
353 : {
354 : public:
355 : txStartLREElement(int32_t aNamespaceID, nsIAtom* aLocalName,
356 : nsIAtom* aPrefix);
357 :
358 : TX_DECL_TXINSTRUCTION
359 :
360 : int32_t mNamespaceID;
361 : nsCOMPtr<nsIAtom> mLocalName;
362 : nsCOMPtr<nsIAtom> mLowercaseLocalName;
363 : nsCOMPtr<nsIAtom> mPrefix;
364 : };
365 :
366 0 : class txText : public txInstruction
367 : {
368 : public:
369 : txText(const nsAString& aStr, bool aDOE);
370 :
371 : TX_DECL_TXINSTRUCTION
372 :
373 : nsString mStr;
374 : bool mDOE;
375 : };
376 :
377 0 : class txValueOf : public txInstruction
378 : {
379 : public:
380 : txValueOf(nsAutoPtr<Expr>&& aExpr, bool aDOE);
381 :
382 : TX_DECL_TXINSTRUCTION
383 :
384 : nsAutoPtr<Expr> mExpr;
385 : bool mDOE;
386 : };
387 :
388 : #endif //TRANSFRMX_TXINSTRUCTIONS_H
|