1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is TransforMiiX XSLT processor code.
16 : *
17 : * The Initial Developer of the Original Code is
18 : * Jonas Sicking.
19 : * Portions created by the Initial Developer are Copyright (C) 2002
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : * Jonas Sicking <jonas@sicking.cc>
24 : *
25 : * Alternatively, the contents of this file may be used under the terms of
26 : * either the GNU General Public License Version 2 or later (the "GPL"), or
27 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 : * in which case the provisions of the GPL or the LGPL are applicable instead
29 : * of those above. If you wish to allow use of your version of this file only
30 : * under the terms of either the GPL or the LGPL, and not to allow others to
31 : * use your version of this file under the terms of the MPL, indicate your
32 : * decision by deleting the provisions above and replace them with the notice
33 : * and other provisions required by the GPL or the LGPL. If you do not delete
34 : * the provisions above, a recipient may use your version of this file under
35 : * the terms of any one of the MPL, the GPL or the LGPL.
36 : *
37 : * ***** END LICENSE BLOCK ***** */
38 :
39 : #ifndef TRANSFRMX_TXINSTRUCTIONS_H
40 : #define TRANSFRMX_TXINSTRUCTIONS_H
41 :
42 : #include "nsCOMPtr.h"
43 : #include "txCore.h"
44 : #include "nsString.h"
45 : #include "txXMLUtils.h"
46 : #include "txNamespaceMap.h"
47 : #include "nsAutoPtr.h"
48 : #include "txXSLTNumber.h"
49 : #include "nsTArray.h"
50 :
51 : class nsIAtom;
52 : class txExecutionState;
53 :
54 : class txInstruction : public txObject
55 : {
56 : public:
57 0 : txInstruction()
58 0 : {
59 0 : MOZ_COUNT_CTOR(txInstruction);
60 0 : }
61 :
62 0 : virtual ~txInstruction()
63 0 : {
64 0 : MOZ_COUNT_DTOR(txInstruction);
65 0 : }
66 :
67 : virtual nsresult execute(txExecutionState& aEs) = 0;
68 :
69 : nsAutoPtr<txInstruction> mNext;
70 : };
71 :
72 : #define TX_DECL_TXINSTRUCTION \
73 : virtual nsresult execute(txExecutionState& aEs);
74 :
75 :
76 : class txApplyDefaultElementTemplate : public txInstruction
77 0 : {
78 : public:
79 : TX_DECL_TXINSTRUCTION
80 : };
81 :
82 : class txApplyImportsEnd : public txInstruction
83 0 : {
84 : public:
85 : TX_DECL_TXINSTRUCTION
86 : };
87 :
88 : class txApplyImportsStart : public txInstruction
89 0 : {
90 : public:
91 : TX_DECL_TXINSTRUCTION
92 : };
93 :
94 : class txApplyTemplates : public txInstruction
95 0 : {
96 : public:
97 : txApplyTemplates(const txExpandedName& aMode);
98 :
99 : TX_DECL_TXINSTRUCTION
100 :
101 : txExpandedName mMode;
102 : };
103 :
104 : class txAttribute : public txInstruction
105 0 : {
106 : public:
107 : txAttribute(nsAutoPtr<Expr> aName, nsAutoPtr<Expr> aNamespace,
108 : txNamespaceMap* aMappings);
109 :
110 : TX_DECL_TXINSTRUCTION
111 :
112 : nsAutoPtr<Expr> mName;
113 : nsAutoPtr<Expr> mNamespace;
114 : nsRefPtr<txNamespaceMap> mMappings;
115 : };
116 :
117 : class txCallTemplate : public txInstruction
118 0 : {
119 : public:
120 : txCallTemplate(const txExpandedName& aName);
121 :
122 : TX_DECL_TXINSTRUCTION
123 :
124 : txExpandedName mName;
125 : };
126 :
127 : class txCheckParam : public txInstruction
128 0 : {
129 : public:
130 : txCheckParam(const txExpandedName& aName);
131 :
132 : TX_DECL_TXINSTRUCTION
133 :
134 : txExpandedName mName;
135 : txInstruction* mBailTarget;
136 : };
137 :
138 : class txConditionalGoto : public txInstruction
139 0 : {
140 : public:
141 : txConditionalGoto(nsAutoPtr<Expr> aCondition, txInstruction* aTarget);
142 :
143 : TX_DECL_TXINSTRUCTION
144 :
145 : nsAutoPtr<Expr> mCondition;
146 : txInstruction* mTarget;
147 : };
148 :
149 : class txComment : public txInstruction
150 0 : {
151 : public:
152 : TX_DECL_TXINSTRUCTION
153 : };
154 :
155 : class txCopyBase : public txInstruction
156 0 : {
157 : protected:
158 : nsresult copyNode(const txXPathNode& aNode, txExecutionState& aEs);
159 : };
160 :
161 : class txCopy : public txCopyBase
162 0 : {
163 : public:
164 : txCopy();
165 :
166 : TX_DECL_TXINSTRUCTION
167 :
168 : txInstruction* mBailTarget;
169 : };
170 :
171 : class txCopyOf : public txCopyBase
172 0 : {
173 : public:
174 : txCopyOf(nsAutoPtr<Expr> aSelect);
175 :
176 : TX_DECL_TXINSTRUCTION
177 :
178 : nsAutoPtr<Expr> mSelect;
179 : };
180 :
181 : class txEndElement : public txInstruction
182 0 : {
183 : public:
184 : TX_DECL_TXINSTRUCTION
185 : };
186 :
187 : class txErrorInstruction : public txInstruction
188 0 : {
189 : public:
190 : TX_DECL_TXINSTRUCTION
191 : };
192 :
193 : class txGoTo : public txInstruction
194 0 : {
195 : public:
196 : txGoTo(txInstruction* aTarget);
197 :
198 : TX_DECL_TXINSTRUCTION
199 :
200 : txInstruction* mTarget;
201 : };
202 :
203 : class txInsertAttrSet : public txInstruction
204 0 : {
205 : public:
206 : txInsertAttrSet(const txExpandedName& aName);
207 :
208 : TX_DECL_TXINSTRUCTION
209 :
210 : txExpandedName mName;
211 : };
212 :
213 : class txLoopNodeSet : public txInstruction
214 0 : {
215 : public:
216 : txLoopNodeSet(txInstruction* aTarget);
217 :
218 : TX_DECL_TXINSTRUCTION
219 :
220 : txInstruction* mTarget;
221 : };
222 :
223 : class txLREAttribute : public txInstruction
224 0 : {
225 : public:
226 : txLREAttribute(PRInt32 aNamespaceID, nsIAtom* aLocalName,
227 : nsIAtom* aPrefix, nsAutoPtr<Expr> aValue);
228 :
229 : TX_DECL_TXINSTRUCTION
230 :
231 : PRInt32 mNamespaceID;
232 : nsCOMPtr<nsIAtom> mLocalName;
233 : nsCOMPtr<nsIAtom> mLowercaseLocalName;
234 : nsCOMPtr<nsIAtom> mPrefix;
235 : nsAutoPtr<Expr> mValue;
236 : };
237 :
238 : class txMessage : public txInstruction
239 0 : {
240 : public:
241 : txMessage(bool aTerminate);
242 :
243 : TX_DECL_TXINSTRUCTION
244 :
245 : bool mTerminate;
246 : };
247 :
248 : class txNumber : public txInstruction
249 0 : {
250 : public:
251 : txNumber(txXSLTNumber::LevelType aLevel, nsAutoPtr<txPattern> aCount,
252 : nsAutoPtr<txPattern> aFrom, nsAutoPtr<Expr> aValue,
253 : nsAutoPtr<Expr> aFormat, nsAutoPtr<Expr> aGroupingSeparator,
254 : nsAutoPtr<Expr> aGroupingSize);
255 :
256 : TX_DECL_TXINSTRUCTION
257 :
258 : txXSLTNumber::LevelType mLevel;
259 : nsAutoPtr<txPattern> mCount;
260 : nsAutoPtr<txPattern> mFrom;
261 : nsAutoPtr<Expr> mValue;
262 : nsAutoPtr<Expr> mFormat;
263 : nsAutoPtr<Expr> mGroupingSeparator;
264 : nsAutoPtr<Expr> mGroupingSize;
265 : };
266 :
267 : class txPopParams : public txInstruction
268 0 : {
269 : public:
270 : TX_DECL_TXINSTRUCTION
271 : };
272 :
273 : class txProcessingInstruction : public txInstruction
274 0 : {
275 : public:
276 : txProcessingInstruction(nsAutoPtr<Expr> aName);
277 :
278 : TX_DECL_TXINSTRUCTION
279 :
280 : nsAutoPtr<Expr> mName;
281 : };
282 :
283 : class txPushNewContext : public txInstruction
284 : {
285 : public:
286 : txPushNewContext(nsAutoPtr<Expr> aSelect);
287 : ~txPushNewContext();
288 :
289 : TX_DECL_TXINSTRUCTION
290 :
291 :
292 : nsresult addSort(nsAutoPtr<Expr> aSelectExpr, nsAutoPtr<Expr> aLangExpr,
293 : nsAutoPtr<Expr> aDataTypeExpr, nsAutoPtr<Expr> aOrderExpr,
294 : nsAutoPtr<Expr> aCaseOrderExpr);
295 :
296 0 : struct SortKey {
297 : nsAutoPtr<Expr> mSelectExpr;
298 : nsAutoPtr<Expr> mLangExpr;
299 : nsAutoPtr<Expr> mDataTypeExpr;
300 : nsAutoPtr<Expr> mOrderExpr;
301 : nsAutoPtr<Expr> mCaseOrderExpr;
302 : };
303 :
304 : nsTArray<SortKey> mSortKeys;
305 : nsAutoPtr<Expr> mSelect;
306 : txInstruction* mBailTarget;
307 : };
308 :
309 : class txPushNullTemplateRule : public txInstruction
310 0 : {
311 : public:
312 : TX_DECL_TXINSTRUCTION
313 : };
314 :
315 : class txPushParams : public txInstruction
316 0 : {
317 : public:
318 : TX_DECL_TXINSTRUCTION
319 : };
320 :
321 : class txPushRTFHandler : public txInstruction
322 0 : {
323 : public:
324 : TX_DECL_TXINSTRUCTION
325 : };
326 :
327 : class txPushStringHandler : public txInstruction
328 0 : {
329 : public:
330 : txPushStringHandler(bool aOnlyText);
331 :
332 : TX_DECL_TXINSTRUCTION
333 :
334 : bool mOnlyText;
335 : };
336 :
337 : class txRemoveVariable : public txInstruction
338 0 : {
339 : public:
340 : txRemoveVariable(const txExpandedName& aName);
341 :
342 : TX_DECL_TXINSTRUCTION
343 :
344 : txExpandedName mName;
345 : };
346 :
347 : class txReturn : public txInstruction
348 0 : {
349 : public:
350 : TX_DECL_TXINSTRUCTION
351 : };
352 :
353 : class txSetParam : public txInstruction
354 0 : {
355 : public:
356 : txSetParam(const txExpandedName& aName, nsAutoPtr<Expr> aValue);
357 :
358 : TX_DECL_TXINSTRUCTION
359 :
360 : txExpandedName mName;
361 : nsAutoPtr<Expr> mValue;
362 : };
363 :
364 : class txSetVariable : public txInstruction
365 0 : {
366 : public:
367 : txSetVariable(const txExpandedName& aName, nsAutoPtr<Expr> aValue);
368 :
369 : TX_DECL_TXINSTRUCTION
370 :
371 : txExpandedName mName;
372 : nsAutoPtr<Expr> mValue;
373 : };
374 :
375 : class txStartElement : public txInstruction
376 0 : {
377 : public:
378 : txStartElement(nsAutoPtr<Expr> aName, nsAutoPtr<Expr> aNamespace,
379 : txNamespaceMap* aMappings);
380 :
381 : TX_DECL_TXINSTRUCTION
382 :
383 : nsAutoPtr<Expr> mName;
384 : nsAutoPtr<Expr> mNamespace;
385 : nsRefPtr<txNamespaceMap> mMappings;
386 : };
387 :
388 : class txStartLREElement : public txInstruction
389 0 : {
390 : public:
391 : txStartLREElement(PRInt32 aNamespaceID, nsIAtom* aLocalName,
392 : nsIAtom* aPrefix);
393 :
394 : TX_DECL_TXINSTRUCTION
395 :
396 : PRInt32 mNamespaceID;
397 : nsCOMPtr<nsIAtom> mLocalName;
398 : nsCOMPtr<nsIAtom> mLowercaseLocalName;
399 : nsCOMPtr<nsIAtom> mPrefix;
400 : };
401 :
402 : class txText : public txInstruction
403 0 : {
404 : public:
405 : txText(const nsAString& aStr, bool aDOE);
406 :
407 : TX_DECL_TXINSTRUCTION
408 :
409 : nsString mStr;
410 : bool mDOE;
411 : };
412 :
413 : class txValueOf : public txInstruction
414 0 : {
415 : public:
416 : txValueOf(nsAutoPtr<Expr> aExpr, bool aDOE);
417 :
418 : TX_DECL_TXINSTRUCTION
419 :
420 : nsAutoPtr<Expr> mExpr;
421 : bool mDOE;
422 : };
423 :
424 : #endif //TRANSFRMX_TXINSTRUCTIONS_H
|