Back to index

lightning-sunbird  0.9+nobinonly
txInstructions.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is TransforMiiX XSLT processor code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Jonas Sicking.
00019  * Portions created by the Initial Developer are Copyright (C) 2002
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Jonas Sicking <jonas@sicking.cc>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either the GNU General Public License Version 2 or later (the "GPL"), or
00027  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 #ifndef TRANSFRMX_TXINSTRUCTIONS_H
00040 #define TRANSFRMX_TXINSTRUCTIONS_H
00041 
00042 #include "nsCOMPtr.h"
00043 #include "txCore.h"
00044 #include "nsString.h"
00045 #include "XMLUtils.h"
00046 #include "txNamespaceMap.h"
00047 #include "nsAutoPtr.h"
00048 #include "txXSLTNumber.h"
00049 
00050 class nsIAtom;
00051 class txExecutionState;
00052 
00053 class txInstruction : public TxObject
00054 {
00055 public:
00056     txInstruction() : mNext(0)
00057     {
00058     }
00059 
00060     virtual ~txInstruction()
00061     {
00062         delete mNext;
00063     }
00064 
00065     virtual nsresult execute(txExecutionState& aEs) = 0;
00066 
00067     txInstruction* mNext;
00068 };
00069 
00070 #define TX_DECL_TXINSTRUCTION  \
00071     virtual nsresult execute(txExecutionState& aEs);
00072 
00073 
00074 class txApplyDefaultElementTemplate : public txInstruction
00075 {
00076 public:
00077     TX_DECL_TXINSTRUCTION
00078 };
00079 
00080 class txApplyImportsEnd : public txInstruction
00081 {
00082 public:
00083     TX_DECL_TXINSTRUCTION
00084 };
00085 
00086 class txApplyImportsStart : public txInstruction
00087 {
00088 public:
00089     TX_DECL_TXINSTRUCTION
00090 };
00091 
00092 class txApplyTemplates : public txInstruction
00093 {
00094 public:
00095     txApplyTemplates(const txExpandedName& aMode);
00096 
00097     TX_DECL_TXINSTRUCTION
00098     
00099     txExpandedName mMode;
00100 };
00101 
00102 class txAttribute : public txInstruction
00103 {
00104 public:
00105     txAttribute(nsAutoPtr<Expr> aName, nsAutoPtr<Expr> aNamespace,
00106                 txNamespaceMap* aMappings);
00107 
00108     TX_DECL_TXINSTRUCTION
00109 
00110     nsAutoPtr<Expr> mName;
00111     nsAutoPtr<Expr> mNamespace;
00112     nsRefPtr<txNamespaceMap> mMappings;
00113 };
00114 
00115 class txCallTemplate : public txInstruction
00116 {
00117 public:
00118     txCallTemplate(const txExpandedName& aName);
00119 
00120     TX_DECL_TXINSTRUCTION
00121 
00122     txExpandedName mName;
00123 };
00124 
00125 class txCheckParam : public txInstruction
00126 {
00127 public:
00128     txCheckParam(const txExpandedName& aName);
00129 
00130     TX_DECL_TXINSTRUCTION
00131 
00132     txExpandedName mName;
00133     txInstruction* mBailTarget;
00134 };
00135 
00136 class txConditionalGoto : public txInstruction
00137 {
00138 public:
00139     txConditionalGoto(nsAutoPtr<Expr> aCondition, txInstruction* aTarget);
00140 
00141     TX_DECL_TXINSTRUCTION
00142     
00143     nsAutoPtr<Expr> mCondition;
00144     txInstruction* mTarget;
00145 };
00146 
00147 class txComment : public txInstruction
00148 {
00149 public:
00150     TX_DECL_TXINSTRUCTION
00151 };
00152 
00153 class txCopyBase : public txInstruction
00154 {
00155 protected:
00156     nsresult copyNode(const txXPathNode& aNode, txExecutionState& aEs);
00157 };
00158 
00159 class txCopy : public txCopyBase
00160 {
00161 public:
00162     txCopy();
00163 
00164     TX_DECL_TXINSTRUCTION
00165     
00166     txInstruction* mBailTarget;
00167 };
00168 
00169 class txCopyOf : public txCopyBase
00170 {
00171 public:
00172     txCopyOf(nsAutoPtr<Expr> aSelect);
00173 
00174     TX_DECL_TXINSTRUCTION
00175     
00176     nsAutoPtr<Expr> mSelect;
00177 };
00178 
00179 class txEndElement : public txInstruction
00180 {
00181 public:
00182     TX_DECL_TXINSTRUCTION
00183 };
00184 
00185 class txErrorInstruction : public txInstruction
00186 {
00187 public:
00188     TX_DECL_TXINSTRUCTION
00189 };
00190 
00191 class txGoTo : public txInstruction
00192 {
00193 public:
00194     txGoTo(txInstruction* aTarget);
00195 
00196     TX_DECL_TXINSTRUCTION
00197     
00198     txInstruction* mTarget;
00199 };
00200 
00201 class txInsertAttrSet : public txInstruction
00202 {
00203 public:
00204     txInsertAttrSet(const txExpandedName& aName);
00205 
00206     TX_DECL_TXINSTRUCTION
00207 
00208     txExpandedName mName;
00209 };
00210 
00211 class txLoopNodeSet : public txInstruction
00212 {
00213 public:
00214     txLoopNodeSet(txInstruction* aTarget);
00215 
00216     TX_DECL_TXINSTRUCTION
00217     
00218     txInstruction* mTarget;
00219 };
00220 
00221 class txLREAttribute : public txInstruction
00222 {
00223 public:
00224     txLREAttribute(PRInt32 aNamespaceID, nsIAtom* aLocalName,
00225                    nsIAtom* aPrefix, nsAutoPtr<Expr> aValue);
00226 
00227     TX_DECL_TXINSTRUCTION
00228 
00229     PRInt32 mNamespaceID;
00230     nsCOMPtr<nsIAtom> mLocalName;
00231     nsCOMPtr<nsIAtom> mPrefix;
00232     nsAutoPtr<Expr> mValue;
00233 };
00234 
00235 class txMessage : public txInstruction
00236 {
00237 public:
00238     txMessage(PRBool aTerminate);
00239 
00240     TX_DECL_TXINSTRUCTION
00241 
00242     PRBool mTerminate;
00243 };
00244 
00245 class txNumber : public txInstruction
00246 {
00247 public:
00248     txNumber(txXSLTNumber::LevelType aLevel, nsAutoPtr<txPattern> aCount,
00249              nsAutoPtr<txPattern> aFrom, nsAutoPtr<Expr> aValue,
00250              nsAutoPtr<Expr> aFormat, nsAutoPtr<Expr> aGroupingSeparator,
00251              nsAutoPtr<Expr> aGroupingSize);
00252 
00253     TX_DECL_TXINSTRUCTION
00254 
00255     txXSLTNumber::LevelType mLevel;
00256     nsAutoPtr<txPattern> mCount;
00257     nsAutoPtr<txPattern> mFrom;
00258     nsAutoPtr<Expr> mValue;
00259     nsAutoPtr<Expr> mFormat;
00260     nsAutoPtr<Expr> mGroupingSeparator;
00261     nsAutoPtr<Expr> mGroupingSize;
00262 };
00263 
00264 class txPopParams : public txInstruction
00265 {
00266 public:
00267     TX_DECL_TXINSTRUCTION
00268 };
00269 
00270 class txProcessingInstruction : public txInstruction
00271 {
00272 public:
00273     txProcessingInstruction(nsAutoPtr<Expr> aName);
00274 
00275     TX_DECL_TXINSTRUCTION
00276 
00277     nsAutoPtr<Expr> mName;
00278 };
00279 
00280 class txPushNewContext : public txInstruction
00281 {
00282 public:
00283     txPushNewContext(nsAutoPtr<Expr> aSelect);
00284     ~txPushNewContext();
00285 
00286     TX_DECL_TXINSTRUCTION
00287     
00288     
00289     nsresult addSort(nsAutoPtr<Expr> aSelectExpr, nsAutoPtr<Expr> aLangExpr,
00290                      nsAutoPtr<Expr> aDataTypeExpr, nsAutoPtr<Expr> aOrderExpr,
00291                      nsAutoPtr<Expr> aCaseOrderExpr);
00292 
00293     struct SortKey {
00294         SortKey(nsAutoPtr<Expr> aSelectExpr, nsAutoPtr<Expr> aLangExpr,
00295                 nsAutoPtr<Expr> aDataTypeExpr, nsAutoPtr<Expr> aOrderExpr,
00296                 nsAutoPtr<Expr> aCaseOrderExpr);
00297 
00298         nsAutoPtr<Expr> mSelectExpr;
00299         nsAutoPtr<Expr> mLangExpr;
00300         nsAutoPtr<Expr> mDataTypeExpr;
00301         nsAutoPtr<Expr> mOrderExpr;
00302         nsAutoPtr<Expr> mCaseOrderExpr;
00303     };
00304     
00305     nsVoidArray mSortKeys;
00306     nsAutoPtr<Expr> mSelect;
00307     txInstruction* mBailTarget;
00308 };
00309 
00310 class txPushNullTemplateRule : public txInstruction
00311 {
00312 public:
00313     TX_DECL_TXINSTRUCTION
00314 };
00315 
00316 class txPushParams : public txInstruction
00317 {
00318 public:
00319     TX_DECL_TXINSTRUCTION
00320 };
00321 
00322 class txPushRTFHandler : public txInstruction
00323 {
00324 public:
00325     TX_DECL_TXINSTRUCTION
00326 };
00327 
00328 class txPushStringHandler : public txInstruction
00329 {
00330 public:
00331     txPushStringHandler(PRBool aOnlyText);
00332 
00333     TX_DECL_TXINSTRUCTION
00334 
00335     PRBool mOnlyText;
00336 };
00337 
00338 class txRemoveVariable : public txInstruction
00339 {
00340 public:
00341     txRemoveVariable(const txExpandedName& aName);
00342 
00343     TX_DECL_TXINSTRUCTION
00344 
00345     txExpandedName mName;
00346 };
00347 
00348 class txReturn : public txInstruction
00349 {
00350 public:
00351     TX_DECL_TXINSTRUCTION
00352 };
00353 
00354 class txSetParam : public txInstruction
00355 {
00356 public:
00357     txSetParam(const txExpandedName& aName, nsAutoPtr<Expr> aValue);
00358 
00359     TX_DECL_TXINSTRUCTION
00360 
00361     txExpandedName mName;
00362     nsAutoPtr<Expr> mValue;
00363 };
00364 
00365 class txSetVariable : public txInstruction
00366 {
00367 public:
00368     txSetVariable(const txExpandedName& aName, nsAutoPtr<Expr> aValue);
00369 
00370     TX_DECL_TXINSTRUCTION
00371 
00372     txExpandedName mName;
00373     nsAutoPtr<Expr> mValue;
00374 };
00375 
00376 class txStartElement : public txInstruction
00377 {
00378 public:
00379     txStartElement(nsAutoPtr<Expr> aName, nsAutoPtr<Expr> aNamespace,
00380                    txNamespaceMap* aMappings);
00381 
00382     TX_DECL_TXINSTRUCTION
00383 
00384     nsAutoPtr<Expr> mName;
00385     nsAutoPtr<Expr> mNamespace;
00386     nsRefPtr<txNamespaceMap> mMappings;
00387 };
00388 
00389 class txStartLREElement : public txInstruction
00390 {
00391 public:
00392     txStartLREElement(PRInt32 aNamespaceID, nsIAtom* aLocalName,
00393                       nsIAtom* aPrefix);
00394 
00395     TX_DECL_TXINSTRUCTION
00396 
00397     PRInt32 mNamespaceID;
00398     nsCOMPtr<nsIAtom> mLocalName;
00399     nsCOMPtr<nsIAtom> mPrefix;
00400 };
00401 
00402 class txText : public txInstruction
00403 {
00404 public:
00405     txText(const nsAString& aStr, PRBool aDOE);
00406 
00407     TX_DECL_TXINSTRUCTION
00408 
00409     nsString mStr;
00410     PRBool mDOE;
00411 };
00412 
00413 class txValueOf : public txInstruction
00414 {
00415 public:
00416     txValueOf(nsAutoPtr<Expr> aExpr, PRBool aDOE);
00417 
00418     TX_DECL_TXINSTRUCTION
00419 
00420     nsAutoPtr<Expr> mExpr;
00421     PRBool mDOE;
00422 };
00423 
00424 #endif //TRANSFRMX_TXINSTRUCTIONS_H