2 * The contents of this file are subject to the Mozilla Public
3 * License Version 1.1 (the "License"); you may not use this file
4 * except in compliance with the License. You may obtain a copy of
5 * the License at http://www.mozilla.org/MPL/
7 * Software distributed under the License is distributed on an "AS
8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9 * implied. See the License for the specific language governing
10 * rights and limitations under the License.
12 * The Original Code is the Sablotron XSLT Processor.
14 * The Initial Developer of the Original Code is Ginger Alliance Ltd.
15 * Portions created by Ginger Alliance are Copyright (C) 2000-2002
16 * Ginger Alliance Ltd. All Rights Reserved.
20 * Alternatively, the contents of this file may be used under the
21 * terms of the GNU General Public License Version 2 or later (the
22 * "GPL"), in which case the provisions of the GPL are applicable
23 * instead of those above. If you wish to allow use of your
24 * version of this file only under the terms of the GPL and not to
25 * allow others to use your version of this file under the MPL,
26 * indicate your decision by deleting the provisions above and
27 * replace them with the notice and other provisions required by
28 * the GPL. If you do not delete the provisions above, a recipient
29 * may use your version of this file under either the MPL or the
39 /****************************************
43 ****************************************/
50 //#define SablotNSBegin namespace _sablotns {
51 //#define SablotNSEnd }
55 // #include "shandler.h"
57 // see also end of file
59 // **************************************
60 // enum for list sizes
62 //start the internal namespace
72 LIST_SIZE_EXPR_TOKENS = LIST_SIZE_MEDIUM
76 #define TWO_TO(EXPONENT) (1L << EXPONENT)
78 /****************************************
82 ****************************************/
84 //maximum expression length in chars:
85 #define MAX_EXPR_LEN 80
87 //max # of params and args passed to SablotProcessVA
90 // the size of the buffer allocated from expat
91 #define PARSE_BUFSIZE 16384
92 // this is for the buffer with raw text to convert
93 #define PARSE_CONV_BUFSIZE PARSE_BUFSIZE * 4
96 #define PRIORITY_NOMATCH -10e6
101 /****************************************
105 ****************************************/
107 // vertex type. To be replaced by OTYPE (Sablot object type) (??)
111 VT_VERTEX,VT_ROOT,VT_ELEMENT,VT_ATTRIBUTE,VT_TEXT,
112 VT_PI, VT_COMMENT, VT_NAMESPACE,
113 VT_VERTEX_WF = VT_VERTEX,
114 VT_ATTRIBUTE_WF = VT_ATTRIBUTE,
115 VT_TEXT_WF = VT_TEXT,
117 VT_DADDY_FLAG = 0x2000,
118 VT_DADDY_WF = VT_VERTEX | VT_DADDY_FLAG,
119 VT_ELEMENT_WF = VT_ELEMENT | VT_DADDY_FLAG, //WF = with flags
120 VT_ROOT_WF = VT_ROOT | VT_DADDY_FLAG,
122 VT_XSL_ELEMENT_WF = VT_XSL | VT_ELEMENT_WF,
124 VT_EXT_ELEMENT_WF = VT_EXT | VT_ELEMENT_WF,
125 VT_TOP_FOREIGN = 0x10000 //used during parse
128 // SpeakMode. Used to distinguish between vertex output for logging and for 'official' output.
135 SM_OFFICIAL = SM_NAME | SM_CONTENTS,
137 SM_INS_SPACES = 0x1000,
138 SM_DESCRIBE = 0x2000,
142 /****************************************
144 ****************************************/
145 // the corresponding string tables are declared later and defined in base.cpp
149 XSL_APPLY_IMPORTS, XSL_APPLY_TEMPLATES,
150 XSL_ATTRIBUTE, XSL_ATTRIBUTE_SET,
151 XSL_CALL_TEMPLATE, XSL_CHOOSE,
152 XSL_COMMENT, XSL_COPY, XSL_COPY_OF,
153 XSL_DECIMAL_FORMAT, XSL_ELEMENT,
154 XSL_FALLBACK, XSL_FOR_EACH,
156 XSL_INCLUDE, XSL_KEY,
157 XSL_MESSAGE, XSL_NAMESPACE_ALIAS,
158 XSL_NUMBER, XSL_OTHERWISE,
159 XSL_OUTPUT, XSL_PARAM,
160 XSL_PRESERVE_SPACE, XSL_PROCESSING_INSTR,
161 XSL_SORT, XSL_STRIP_SPACE,
162 XSL_STYLESHEET, XSL_TEMPLATE,
163 XSL_TEXT, XSL_TRANSFORM,
164 XSL_VALUE_OF, XSL_VARIABLE,
165 XSL_WHEN, XSL_WITH_PARAM,
171 XSLA_CASE_ORDER, XSLA_CDATA_SECT_ELEMS, XSLA_COUNT,
172 XSLA_DATA_TYPE, XSLA_DECIMAL_SEPARATOR, XSLA_DIGIT, XSLA_DISABLE_OUTPUT_ESC, XSLA_DOCTYPE_PUBLIC, XSLA_DOCTYPE_SYSTEM,
173 XSLA_ELEMENTS, XSLA_ENCODING, XSLA_EXCL_RES_PREFIXES, XSLA_EXT_ELEM_PREFIXES,
174 XSLA_FORMAT, XSLA_FROM,
175 XSLA_GROUPING_SEPARATOR, XSLA_GROUPING_SIZE,
177 XSLA_ID, XSLA_INDENT, XSLA_INFINITY,
178 XSLA_LANG, XSLA_LETTER_VALUE, XSLA_LEVEL,
179 XSLA_MATCH, XSLA_MEDIA_TYPE, XSLA_METHOD, XSLA_MINUS_SIGN, XSLA_MODE,
180 XSLA_NAME, XSLA_NAMESPACE, XSLA_NAN,
181 XSLA_OMIT_XML_DECL, XSLA_ORDER,
182 XSLA_PATTERN_SEPARATOR, XSLA_PERCENT, XSLA_PER_MILLE, XSLA_PRIORITY,
184 XSLA_SELECT, XSLA_STANDALONE, XSLA_STYLESHEET_PREFIX,
185 XSLA_TERMINATE, XSLA_TEST,
186 XSLA_USE, XSLA_USE_ATTR_SETS,
187 XSLA_VALUE, XSLA_VERSION,
194 AXIS_ANCESTOR, AXIS_ANC_OR_SELF, AXIS_ATTRIBUTE, AXIS_CHILD,
195 AXIS_DESCENDANT, AXIS_DESC_OR_SELF, AXIS_FOLLOWING, AXIS_FOLL_SIBLING,
196 AXIS_NAMESPACE, AXIS_PARENT, AXIS_PRECEDING, AXIS_PREC_SIBLING,
200 //not recognized in stylesheet:
213 /****************************************
217 ****************************************/
219 /* the following was truly a burden:
227 #define ITEM_NOT_FOUND (unsigned long) -1L
228 #define PHRASE_NOT_FOUND ITEM_NOT_FOUND
229 #define UNDEF_PHRASE (unsigned long) -2L
231 typedef unsigned long oolong;
232 typedef oolong HashId;
233 typedef HashId Phrase;
244 /****************************************
248 ****************************************/
250 #define NONZERO(x) (assert(x),x)
251 #define NZ(x) NONZERO(x)
252 #define cdelete(PTR) {if (PTR) delete PTR; PTR = NULL;}
253 #define ccdelete(PTR, TYPED) {if (PTR) delete TYPED; PTR = NULL;}
254 #define cdeleteArr(PTR) {if (PTR) delete[] PTR; PTR = NULL;}
257 #define cast(TYPE,PTR) (NZ(dynamic_cast<TYPE>(PTR)))
259 #define cast(TYPE,PTR) ((TYPE) PTR)
262 // macros for checking vertex types
264 #define baseType(v) (((Vertex*)NZ(v)) -> vt & VT_BASE)
265 #define basetype(v) baseType(v)
266 #define isDaddy(v) (((Vertex*)NZ(v)) -> vt & VT_DADDY_FLAG)
267 #define isRoot(v) (baseType(v) == VT_ROOT)
268 #define isPI(v) (baseType(v) == VT_PI)
269 #define isComment(v) (baseType(v) == VT_COMMENT)
270 #define isElement(v) (baseType(v) == VT_ELEMENT || baseType(v) == VT_ROOT)
271 #define isText(v) (baseType(v) == VT_TEXT)
272 #define isXSL(v) (((Vertex*)NZ(v)) -> vt & VT_XSL)
273 #define isExt(v) (((Vertex*)NZ(v)) -> vt & VT_EXT)
274 #define isXSLElement(v) ((isElement(v)) && (isXSL(v)))
275 #define isExtension(v) ((isElement(v)) && (isExt(v)))
276 #define isAttr(v) (baseType(v) == VT_ATTRIBUTE)
277 #define isNS(v) (baseType(v) == VT_NAMESPACE)
279 // macros for downcasting
281 #define toV(v) ((Vertex*)v)
282 #define toNS(v) (cast(NmSpace*,toV(v)))
283 #define toE(v) (cast(Element*,toV(v)))
284 #define toX(v) (cast(XSLElement*,toV(v)))
285 #define toExtension(v) (cast(ExtensionElement*,toV(v)))
286 #define toA(v) (cast(Attribute*,toV(v)))
287 #define toText(v) (cast(Text*,toV(v)))
288 #define toD(v) (cast(Daddy*,toV(v)))
289 #define toRoot(v) (cast(RootNode*,toV(v)))
290 #define toComment(v) (cast(Comment*,toV(v)))
291 #define toPI(v) (cast(ProcInstr*,toV(v)))
292 // for "casting" a root node to the containing document
293 #define toTree(v) (&(toRoot(v) -> getOwner()))
294 // casts a Tree object to an SXP_Document
295 #define toSXP_Document(t) &((t).getRoot())
297 #define toPhysical(v) toV(v)
304 // return OK, putting a VALUE in a VARiable
305 #define RetOK( VAR, VALUE ) {VAR = VALUE; return OK;}
307 // to support the change to Unicode
309 #define Mstrlen strlen
310 #define Mstrchr strchr
311 #define Mstrcmp strcmp
312 #define Mstrncmp strncmp
316 extern const char* theWhitespace;
317 #define skipWhite(p) p+=strspn((p), theWhitespace)
318 #define isWhite(c) (!!(strchr(theWhitespace,(c))))
319 #define isAllWhite( STR ) (!((STR)[strspn((STR), theWhitespace)]))
321 // messaging macro from "Advanced Windows"
322 // #pragma Msg(some_message) emits a message at compile time
324 #define MsgToS2(x) MsgToS(x)
325 #define Msg(x) message(__FILE__"(" MsgToS2(__LINE__) "): "#x" <---")
327 /****************************************
331 ****************************************/
333 extern const char* xslOpNames[];
334 extern const char* xslAttNames[];
335 extern const char* axisNames[];
336 extern const char* exNodeTypeNames[];
337 extern const char* vertexTypeNames[];
338 extern int lookup(const char* str, const char** table);
339 extern int lookupNoCase(const char* str, const char** table);
340 extern int fcomp(double,double); //float comparison
341 extern Bool isstd(const char *);
342 extern int stdclose(FILE *f);
343 extern FILE* stdopen(const char *fn, const char *mode);
344 extern Bool strEqNoCase(const char*, const char*);
347 // extern Processor* proc;
348 // extern SituationObj situation;
349 //extern void pushNewHandler();
350 //extern void popNewHandler();
352 extern SchemeHandler *theSchemeHandler;
353 extern MessageHandler *theMessageHandler;
354 extern SAXHandler *theSAXHandler;
355 extern void* theSAXUserData;
358 extern Bool isValidNCName(const char* name);
359 extern Bool isValidQName(const char* name);
363 extern Bool getWhDelimString(char *&list, Str& firstPart);
370 extern const char *theXSLTNamespace, *oldXSLTNamespace, *theXMLNamespace,
371 *theXHTMLNamespace, *theXMLNSNamespace, *theSabExtNamespace;
378 *escNewline, *escTab, *escQuote, *escApos,
379 *escLess, *escGreater;
381 /****************************************
385 ****************************************/
391 void *operator new(unsigned int);
392 void operator delete(void *, unsigned int);
396 /*****************************************************************
397 Memory leak test stuff
398 *****************************************************************/
399 #if defined(CHECK_LEAKS)
401 #define CRTDBG_MAP_ALLOC
403 #else // if defined(__linux__)
408 extern void checkLeak();
409 extern void memStats();
412 extern Str getMillisecsDiff(double originalTime);
415 /****************************************
417 f i n a l i n c l u d e s
419 ****************************************/
421 #ifndef BaseH_NoErrorH
424 #undef BaseH_NoErrorH
431 #endif //ifndef BaseHIncl