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_TXTOPLEVELITEMS_H 7 #define TRANSFRMX_TXTOPLEVELITEMS_H 8 9 #include "nsError.h" 10 #include "txOutputFormat.h" 11 #include "txXMLUtils.h" 12 #include "txStylesheet.h" 13 #include "txInstructions.h" 14 15 class txPattern; 16 class Expr; 17 18 class txToplevelItem 19 { 20 public: txToplevelItem()21 txToplevelItem() 22 { 23 MOZ_COUNT_CTOR(txToplevelItem); 24 } ~txToplevelItem()25 virtual ~txToplevelItem() 26 { 27 MOZ_COUNT_DTOR(txToplevelItem); 28 } 29 30 enum type { 31 attributeSet, 32 dummy, 33 import, 34 //namespaceAlias, 35 output, 36 stripSpace, //also used for preserve-space 37 templ, 38 variable 39 }; 40 41 virtual type getType() = 0; 42 }; 43 44 #define TX_DECL_TOPLEVELITEM virtual type getType(); 45 #define TX_IMPL_GETTYPE(_class, _type) \ 46 txToplevelItem::type \ 47 _class::getType() { return _type;} 48 49 class txInstructionContainer : public txToplevelItem 50 { 51 public: 52 nsAutoPtr<txInstruction> mFirstInstruction; 53 }; 54 55 // xsl:attribute-set 56 class txAttributeSetItem : public txInstructionContainer 57 { 58 public: txAttributeSetItem(const txExpandedName aName)59 explicit txAttributeSetItem(const txExpandedName aName) : mName(aName) 60 { 61 } 62 63 TX_DECL_TOPLEVELITEM 64 65 txExpandedName mName; 66 }; 67 68 // xsl:import 69 class txImportItem : public txToplevelItem 70 { 71 public: 72 TX_DECL_TOPLEVELITEM 73 74 nsAutoPtr<txStylesheet::ImportFrame> mFrame; 75 }; 76 77 // xsl:output 78 class txOutputItem : public txToplevelItem 79 { 80 public: 81 TX_DECL_TOPLEVELITEM 82 83 txOutputFormat mFormat; 84 }; 85 86 // insertionpoint for xsl:include 87 class txDummyItem : public txToplevelItem 88 { 89 public: 90 TX_DECL_TOPLEVELITEM 91 }; 92 93 // xsl:strip-space and xsl:preserve-space 94 class txStripSpaceItem : public txToplevelItem 95 { 96 public: 97 ~txStripSpaceItem(); 98 99 TX_DECL_TOPLEVELITEM 100 101 nsresult addStripSpaceTest(txStripSpaceTest* aStripSpaceTest); 102 103 nsTArray<txStripSpaceTest*> mStripSpaceTests; 104 }; 105 106 // xsl:template 107 class txTemplateItem : public txInstructionContainer 108 { 109 public: 110 txTemplateItem(nsAutoPtr<txPattern>&& aMatch, const txExpandedName& aName, 111 const txExpandedName& aMode, double aPrio); 112 113 TX_DECL_TOPLEVELITEM 114 115 nsAutoPtr<txPattern> mMatch; 116 txExpandedName mName; 117 txExpandedName mMode; 118 double mPrio; 119 }; 120 121 // xsl:variable at top level 122 class txVariableItem : public txInstructionContainer 123 { 124 public: 125 txVariableItem(const txExpandedName& aName, nsAutoPtr<Expr>&& aValue, 126 bool aIsParam); 127 128 TX_DECL_TOPLEVELITEM 129 130 txExpandedName mName; 131 nsAutoPtr<Expr> mValue; 132 bool mIsParam; 133 }; 134 135 #endif //TRANSFRMX_TXTOPLEVELITEMS_H 136