~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/extensions/transformiix/source/xslt/txExecutionState.h

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.
 
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
 * Jonas Sicking. 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_TXEXECUTIONSTATE_H
 
40
#define TRANSFRMX_TXEXECUTIONSTATE_H
 
41
 
 
42
#include "txError.h"
 
43
#include "baseutils.h"
 
44
#include "txXMLEventHandler.h"
 
45
#include "txStack.h"
 
46
#include "XMLUtils.h"
 
47
#include "nsVoidArray.h"
 
48
#include "txIXPathContext.h"
 
49
#include "txVariableMap.h"
 
50
#include "nsTHashtable.h"
 
51
#include "nsHashKeys.h"
 
52
#include "txKey.h"
 
53
#include "txStylesheet.h"
 
54
 
 
55
class txInstruction;
 
56
class txIOutputHandlerFactory;
 
57
class txExpandedNameMap;
 
58
 
 
59
class txLoadedDocumentEntry : public nsStringHashKey
 
60
{
 
61
public:
 
62
    txLoadedDocumentEntry(KeyTypePointer aStr) : nsStringHashKey(aStr)
 
63
    {
 
64
    }
 
65
    txLoadedDocumentEntry(const txLoadedDocumentEntry& aToCopy)
 
66
        : nsStringHashKey(aToCopy)
 
67
    {
 
68
        NS_ERROR("We're horked.");
 
69
    }
 
70
    ~txLoadedDocumentEntry()
 
71
    {
 
72
        if (mDocument) {
 
73
            txXPathNodeUtils::release(mDocument);
 
74
        }
 
75
    }
 
76
 
 
77
    nsAutoPtr<txXPathNode> mDocument;
 
78
};
 
79
 
 
80
class txLoadedDocumentsHash : public nsTHashtable<txLoadedDocumentEntry>
 
81
{
 
82
public:
 
83
    ~txLoadedDocumentsHash();
 
84
    nsresult init(txXPathNode* aSourceDocument);
 
85
 
 
86
private:
 
87
    friend class txExecutionState;
 
88
    txXPathNode* mSourceDocument;
 
89
};
 
90
 
 
91
 
 
92
class txExecutionState : public txIMatchContext
 
93
{
 
94
public:
 
95
    txExecutionState(txStylesheet* aStylesheet);
 
96
    ~txExecutionState();
 
97
    nsresult init(const txXPathNode& aNode, txExpandedNameMap* aGlobalParams);
 
98
    nsresult end();
 
99
 
 
100
    TX_DECL_MATCH_CONTEXT;
 
101
 
 
102
    /**
 
103
     * Struct holding information about a current template rule
 
104
     */
 
105
    struct TemplateRule {
 
106
        txStylesheet::ImportFrame* mFrame;
 
107
        PRInt32 mModeNsId;
 
108
        nsIAtom* mModeLocalName;
 
109
        txVariableMap* mParams;
 
110
    };
 
111
 
 
112
    // Stack functions
 
113
    nsresult pushEvalContext(txIEvalContext* aContext);
 
114
    txIEvalContext* popEvalContext();
 
115
    nsresult pushString(const nsAString& aStr);
 
116
    void popString(nsAString& aStr);
 
117
    nsresult pushInt(PRInt32 aInt);
 
118
    PRInt32 popInt();
 
119
    nsresult pushResultHandler(txAXMLEventHandler* aHandler);
 
120
    txAXMLEventHandler* popResultHandler();
 
121
    nsresult pushTemplateRule(txStylesheet::ImportFrame* aFrame,
 
122
                              const txExpandedName& aMode,
 
123
                              txVariableMap* aParams);
 
124
    void popTemplateRule();
 
125
    nsresult pushParamMap(txVariableMap* aParams);
 
126
    txVariableMap* popParamMap();
 
127
 
 
128
    // state-getting functions
 
129
    txIEvalContext* getEvalContext();
 
130
    txExpandedNameMap* getParamMap();
 
131
    const txXPathNode* retrieveDocument(const nsAString& aUri);
 
132
    nsresult getKeyNodes(const txExpandedName& aKeyName,
 
133
                         const txXPathNode& aDocument,
 
134
                         const nsAString& aKeyValue, PRBool aIndexIfNotFound,
 
135
                         txNodeSet** aResult);
 
136
    TemplateRule* getCurrentTemplateRule();
 
137
 
 
138
    // state-modification functions
 
139
    txInstruction* getNextInstruction();
 
140
    nsresult runTemplate(txInstruction* aInstruction);
 
141
    nsresult runTemplate(txInstruction* aInstruction,
 
142
                         txInstruction* aReturnTo);
 
143
    void gotoInstruction(txInstruction* aNext);
 
144
    void returnFromTemplate();
 
145
    nsresult bindVariable(const txExpandedName& aName,
 
146
                          txAExprResult* aValue);
 
147
    void removeVariable(const txExpandedName& aName);
 
148
 
 
149
    txAXMLEventHandler* mOutputHandler;
 
150
    txAXMLEventHandler* mResultHandler;
 
151
    txAOutputHandlerFactory* mOutputHandlerFactory;
 
152
 
 
153
    nsAutoPtr<txVariableMap> mTemplateParams;
 
154
 
 
155
    nsRefPtr<txStylesheet> mStylesheet;
 
156
 
 
157
private:
 
158
    txStack mReturnStack;
 
159
    txStack mLocalVarsStack;
 
160
    txStack mEvalContextStack;
 
161
    txStack mIntStack;
 
162
    txStack mResultHandlerStack;
 
163
    txStack mParamStack;
 
164
    nsStringArray mStringStack;
 
165
    txInstruction* mNextInstruction;
 
166
    txVariableMap* mLocalVariables;
 
167
    txVariableMap mGlobalVariableValues;
 
168
    nsRefPtr<txAExprResult> mGlobalVarPlaceholderValue;
 
169
    PRInt32 mRecursionDepth;
 
170
 
 
171
    TemplateRule* mTemplateRules;
 
172
    PRInt32 mTemplateRulesBufferSize;
 
173
    PRInt32 mTemplateRuleCount;
 
174
 
 
175
    txIEvalContext* mEvalContext;
 
176
    txIEvalContext* mInitialEvalContext;
 
177
    //Document* mRTFDocument;
 
178
    txExpandedNameMap* mGlobalParams;
 
179
 
 
180
    txLoadedDocumentsHash mLoadedDocuments;
 
181
    txKeyHash mKeyHash;
 
182
    nsRefPtr<txResultRecycler> mRecycler;
 
183
 
 
184
    static const PRInt32 kMaxRecursionDepth;
 
185
};
 
186
 
 
187
#endif