dbertoni 2002/10/30 23:15:58
Modified: c/src/XSLT AVT.cpp AVT.hpp AVTPartSimple.cpp
AVTPartSimple.hpp ElemAttribute.cpp ElemElement.cpp
ElemLiteralResult.cpp ElemLiteralResult.hpp
ElemNumber.cpp ElemPI.cpp ElemSort.cpp
ElemTextLiteral.cpp ElemUse.cpp ElemUse.hpp
Stylesheet.cpp Stylesheet.hpp
StylesheetConstructionContext.cpp
StylesheetConstructionContext.hpp
StylesheetConstructionContextDefault.cpp
StylesheetConstructionContextDefault.hpp
StylesheetHandler.cpp StylesheetHandler.hpp
StylesheetRoot.cpp StylesheetRoot.hpp
XSLTEngineImpl.cpp XSLTEngineImpl.hpp
Added: c/src/XSLT XalanAVTAllocator.cpp XalanAVTAllocator.hpp
XalanAVTPartSimpleAllocator.cpp
XalanAVTPartSimpleAllocator.hpp
XalanAVTPartXPathAllocator.cpp
XalanAVTPartXPathAllocator.hpp
Log:
New construction context class for better dynamic memory allocation.
Revision Changes Path
1.18 +44 -63 xml-xalan/c/src/XSLT/AVT.cpp
Index: AVT.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/AVT.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- AVT.cpp 21 Sep 2002 01:24:41 -0000 1.17
+++ AVT.cpp 31 Oct 2002 07:15:56 -0000 1.18
@@ -58,14 +58,6 @@
-#include <algorithm>
-
-
-
-#include <Include/STLHelper.hpp>
-
-
-
#include <PlatformSupport/DOMStringHelper.hpp>
#include <PlatformSupport/StringTokenizer.hpp>
#include <PlatformSupport/XalanUnicode.hpp>
@@ -119,12 +111,13 @@
* on to the string if the AVT is simple.
*/
AVT::AVT(
+ StylesheetConstructionContext& constructionContext,
const Locator* locator,
const XalanDOMChar* name,
const XalanDOMChar*
stringedValue,
- const PrefixResolver& resolver,
- StylesheetConstructionContext& constructionContext) :
- m_parts(),
+ const PrefixResolver& resolver) :
+ m_parts(0),
+ m_partsSize(0),
m_simpleString(0),
m_simpleStringLength(0),
m_name(constructionContext.getPooledString(name))
@@ -137,17 +130,20 @@
{
// Do the simple thing
m_simpleStringLength = length(stringedValue);
- m_simpleString =
constructionContext.allocateVector(stringedValue, m_simpleStringLength, false);
+
+ m_simpleString =
constructionContext.allocateXalanDOMCharVector(stringedValue,
m_simpleStringLength, false);
}
else
{
- m_parts.reserve(nTokens + 1);
+ // This over-allocates, but we probably won't waste that much
space. If necessary,
+ // we could tokenize twice, just counting the numbers of
AVTPart instances we
+ // will need the first time.
+ m_parts =
constructionContext.allocateAVTPartPointerVector(nTokens + 1);
XalanDOMString buffer;
XalanDOMString exprBuffer;
XalanDOMString t; // base token
XalanDOMString lookahead; // next token
- XalanDOMString error; // if non-null, break from loop
while(tokenizer.hasMoreTokens())
{
@@ -175,7 +171,7 @@
if(equals(lookahead,
theLeftCurlyBracketString))
{
- // Double curlys mean
escape to show curly
+ // Double braces mean
escape to show brace
append(buffer,
lookahead);
clear(lookahead);
@@ -186,7 +182,12 @@
{
if(length(buffer) > 0)
{
-
m_parts.push_back(new AVTPartSimple(constructionContext, c_wstr(buffer),
length(buffer)));
+
assert(m_partsSize + 1 < nTokens);
+
+
m_parts[m_partsSize++] =
+
constructionContext.createAVTPart(
+
c_wstr(buffer),
+
length(buffer));
clear(buffer);
}
@@ -205,7 +206,11 @@
// String start
append(exprBuffer, lookahead);
-
const XalanDOMString quote = lookahead;
+
const XalanDOMChar quote[2] =
+
{
+
lookahead[0],
+
0
+
};
// Consume stuff 'till next quote
nextToken(constructionContext, locator, tokenizer, lookahead);
@@ -214,25 +219,25 @@
{
append(exprBuffer, lookahead);
-
nextToken(constructionContext, locator, tokenizer, lookahead);
+
nextToken(constructionContext, locator, tokenizer, lookahead);
}
append(exprBuffer,lookahead);
break;
}
+
case XalanUnicode::charLeftCurlyBracket:
-
{
-
// What's another curly doing here?
-
error = TranscodeFromLocalCodePage("Error: Can not have \"{\" within
expression.");
+
// What's another brace doing here?
+
constructionContext.error("\"{\" cannot appear within an expression.");
break;
-
}
+
default:
-
{
// part of the template stuff, just add it.
append(exprBuffer, lookahead);
-
}
+
break;
+
} //
end inner switch
} // end if
lookahead length == 1
else
@@ -256,14 +261,16 @@
resolver);
assert(xpath != 0);
- m_parts.push_back(new
AVTPartXPath(xpath));
+ assert(m_partsSize + 1
< nTokens);
- clear(lookahead); //
breaks out of inner while loop
+ m_parts[m_partsSize++] =
+
constructionContext.createAVTPart(
+ locator,
+
c_wstr(exprBuffer),
+
length(exprBuffer),
+
resolver);
- if(length(error) > 0)
- {
- break; // from
inner while loop
- }
+ clear(lookahead); //
breaks out of inner while loop
}
break;
}
@@ -273,18 +280,14 @@
if(equals(lookahead,
theRightCurlyBracketString))
{
- // Double curlys mean
escape to show curly
+ // Double brace mean
escape to show brace
append(buffer,
lookahead);
clear(lookahead); //
swallow
}
else
{
- // Illegal, I think...
-
constructionContext.warn("Found \"}\" but no attribute template open!");
-
- append(buffer,
theRightCurlyBracketString);
- // leave the lookahead
to be processed by the next round.
+
constructionContext.error("An unmatched \"}\" was found!");
}
break;
}
@@ -302,43 +305,23 @@
// Anything else just add to string.
append(buffer,t);
}
-
- if(length(error) > 0)
- {
- constructionContext.warn("Attr Template, " +
error);
-
- break;
- }
} // end while(tokenizer.hasMoreTokens())
if(length(buffer) > 0)
{
- m_parts.push_back(new
AVTPartSimple(constructionContext, c_wstr(buffer), length(buffer)));
+ assert(m_partsSize + 1 < nTokens);
+
+ m_parts[m_partsSize++] =
constructionContext.createAVTPart(c_wstr(buffer), length(buffer));
clear(buffer);
}
-
} // end else nTokens > 1
-
- if (m_parts.size() < m_parts.capacity())
- {
- AVTPartPtrVectorType(m_parts).swap(m_parts);
- }
-
}
AVT::~AVT()
{
-#if !defined(XALAN_NO_NAMESPACES)
- using std::for_each;
-#endif
-
- // Clean up all entries in the vector.
- for_each(m_parts.begin(),
- m_parts.end(),
- DeleteFunctor<AVTPart>());
}
@@ -352,11 +335,9 @@
{
clear(buf);
- if(m_parts.empty() == false)
+ if(m_partsSize != 0)
{
- const AVTPartPtrVectorType::size_type n = m_parts.size();
-
- for(AVTPartPtrVectorType::size_type i = 0; i < n; i++)
+ for(size_type i = 0; i < m_partsSize; i++)
{
assert(m_parts[i] != 0);
1.15 +15 -17 xml-xalan/c/src/XSLT/AVT.hpp
Index: AVT.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/AVT.hpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- AVT.hpp 21 Sep 2002 01:24:41 -0000 1.14
+++ AVT.hpp 31 Oct 2002 07:15:56 -0000 1.15
@@ -69,10 +69,6 @@
-#include <vector>
-
-
-
#include <XalanDOM/XalanDOMString.hpp>
@@ -90,27 +86,33 @@
/**
* Class to hold an Attribute Value Template.
*/
-class AVT //: public AVTPart
+class AVT
{
public:
+#if defined(XALAN_SIZE_T_IN_NAMESPACE_STD)
+ typedef std::size_t size_type;
+#else
+ typedef size_t size_type;
+#endif
+
/**
* Construct an Attribute Value Template(AVT) by parsing the string, and
* either constructing a vector of AVTParts, or simply hold on to the
* string if the AVT is simple.
*
- * @param ownerElement the Locator for the AVT. May be null.
+ * @param constructionContext context for construction of AVT
+ * @param locator the Locator for the AVT. May be null.
* @param name name of AVT
* @param stringedValue string value to parse
* @param resolver resolver for namespace resolution
- * @param constructionContext context for construction of AVT
*/
AVT(
+ StylesheetConstructionContext& constructionContext,
const Locator* locator,
const XalanDOMChar* name,
const XalanDOMChar*
stringedValue,
- const PrefixResolver& resolver,
- StylesheetConstructionContext& constructionContext);
+ const PrefixResolver& resolver);
virtual
~AVT();
@@ -143,12 +145,6 @@
}
}
-#if defined(XALAN_NO_NAMESPACES)
- typedef vector<const AVTPart*> AVTPartPtrVectorType;
-#else
- typedef std::vector<const AVTPart*> AVTPartPtrVectorType;
-#endif
-
private:
void
@@ -176,7 +172,9 @@
// Data members...
- AVTPartPtrVectorType m_parts;
+ const AVTPart** m_parts;
+
+ size_type m_partsSize;
const XalanDOMChar* m_simpleString;
1.5 +1 -1 xml-xalan/c/src/XSLT/AVTPartSimple.cpp
Index: AVTPartSimple.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/AVTPartSimple.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AVTPartSimple.cpp 21 Sep 2002 01:24:41 -0000 1.4
+++ AVTPartSimple.cpp 31 Oct 2002 07:15:56 -0000 1.5
@@ -74,7 +74,7 @@
const XalanDOMChar* val,
XalanDOMString::size_type len) :
AVTPart(),
- m_val(constructionContext.allocateVector(val, len, false)),
+ m_val(constructionContext.allocateXalanDOMCharVector(val, len, false)),
m_len(len)
{
}
1.6 +2 -1 xml-xalan/c/src/XSLT/AVTPartSimple.hpp
Index: AVTPartSimple.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/AVTPartSimple.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AVTPartSimple.hpp 21 Sep 2002 01:24:41 -0000 1.5
+++ AVTPartSimple.hpp 31 Oct 2002 07:15:56 -0000 1.6
@@ -93,6 +93,7 @@
*
* @param constructionContext context when object constructed
* @param val A pure string section of an AVT
+ * @param len The length of val
*/
AVTPartSimple(
StylesheetConstructionContext& constructionContext,
1.41 +4 -20 xml-xalan/c/src/XSLT/ElemAttribute.cpp
Index: ElemAttribute.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemAttribute.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- ElemAttribute.cpp 24 Sep 2002 01:42:34 -0000 1.40
+++ ElemAttribute.cpp 31 Oct 2002 07:15:56 -0000 1.41
@@ -100,13 +100,13 @@
if(equals(aname, Constants::ATTRNAME_NAME))
{
- m_pNameAVT = new AVT(getLocator(), aname,
atts.getValue(i),
- *this, constructionContext);
+ m_pNameAVT =
+ constructionContext.createAVT(getLocator(),
aname, atts.getValue(i), *this);
}
else if(equals(aname, Constants::ATTRNAME_NAMESPACE))
{
- m_pNamespaceAVT = new AVT(getLocator(), aname,
atts.getValue(i),
- *this, constructionContext);
+ m_pNamespaceAVT =
+ constructionContext.createAVT(getLocator(),
aname, atts.getValue(i), *this);
}
else if(!(isAttrOK(aname, atts, i, constructionContext) ||
processSpaceAttr(aname, atts, i,
constructionContext)))
@@ -120,33 +120,17 @@
if(0 == m_pNameAVT)
{
-#if defined(XALAN_CANNOT_DELETE_CONST)
- delete (AVT*)m_pNamespaceAVT;
-#else
- delete m_pNamespaceAVT;
-#endif
-
constructionContext.error(
"xsl:attribute must have a 'name' attribute",
0,
this);
}
-
}
ElemAttribute::~ElemAttribute()
{
-#if defined(XALAN_CANNOT_DELETE_CONST)
- delete (AVT*)m_pNameAVT;
-
- delete (AVT*)m_pNamespaceAVT;
-#else
- delete m_pNameAVT;
-
- delete m_pNamespaceAVT;
-#endif
}
1.42 +4 -14 xml-xalan/c/src/XSLT/ElemElement.cpp
Index: ElemElement.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemElement.cpp,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- ElemElement.cpp 4 Oct 2002 01:41:57 -0000 1.41
+++ ElemElement.cpp 31 Oct 2002 07:15:56 -0000 1.42
@@ -100,13 +100,13 @@
if(equals(aname, Constants::ATTRNAME_NAME))
{
- m_nameAVT = new AVT(getLocator(), aname,
atts.getValue(i),
- *this, constructionContext);
+ m_nameAVT =
+ constructionContext.createAVT(getLocator(),
aname, atts.getValue(i), *this);
}
else if(equals(aname, Constants::ATTRNAME_NAMESPACE))
{
- m_namespaceAVT = new AVT(getLocator(), aname,
atts.getValue(i),
- *this, constructionContext);
+ m_namespaceAVT =
+ constructionContext.createAVT(getLocator(),
aname, atts.getValue(i), *this);
}
else if(!(processUseAttributeSets(constructionContext, aname,
atts, i) ||
processSpaceAttr(aname, atts, i,
constructionContext) ||
@@ -126,22 +126,12 @@
0,
this);
}
-
}
ElemElement::~ElemElement()
{
-#if defined(XALAN_CANNOT_DELETE_CONST)
- delete (AVT*)m_nameAVT;
-
- delete (AVT*)m_namespaceAVT;
-#else
- delete m_nameAVT;
-
- delete m_namespaceAVT;
-#endif
}
1.56 +26 -41 xml-xalan/c/src/XSLT/ElemLiteralResult.cpp
Index: ElemLiteralResult.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemLiteralResult.cpp,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- ElemLiteralResult.cpp 26 Sep 2002 01:38:15 -0000 1.55
+++ ElemLiteralResult.cpp 31 Oct 2002 07:15:56 -0000 1.56
@@ -58,18 +58,10 @@
-#include <algorithm>
-
-
-
#include <xercesc/sax/AttributeList.hpp>
-#include <Include/STLHelper.hpp>
-
-
-
#include <PlatformSupport/DoubleSupport.hpp>
@@ -99,8 +91,8 @@
columnNumber,
StylesheetConstructionContext::ELEMNAME_LITERAL_RESULT),
m_elementName(constructionContext.getPooledString(name)),
- m_avts(),
- m_attrCount(0),
+ m_avts(0),
+ m_avtsCount(0),
m_hasPrefix(indexOf(name, XalanUnicode::charColon) < length(name) ?
true : false)
{
init(constructionContext, stylesheetTree, atts);
@@ -122,8 +114,8 @@
columnNumber,
xslToken),
m_elementName(constructionContext.getPooledString(name)),
- m_avts(),
- m_attrCount(0),
+ m_avts(0),
+ m_avtsCount(0),
m_hasPrefix(indexOf(name, XalanUnicode::charColon) < length(name) ?
true : false)
{
init(constructionContext, stylesheetTree, atts);
@@ -139,9 +131,13 @@
{
const unsigned int nAttrs = atts.getLength();
- m_avts.reserve(nAttrs);
+ // This over-allocates, but we probably won't waste that much space.
+ m_avts = constructionContext.allocateAVTPointerVector(nAttrs);
+ assert(m_avts != 0);
- XalanDOMString theBuffer;
+ const StylesheetConstructionContext::GetAndReleaseCachedString
theGuard(constructionContext);
+
+ XalanDOMString& theBuffer = theGuard.get();
for(unsigned int i = 0; i < nAttrs; i++)
{
@@ -199,33 +195,17 @@
if(! processUseAttributeSets(constructionContext,
aname, atts, i) &&
isAttrOK(aname, atts, i,
constructionContext))
{
- m_avts.push_back(new AVT(getLocator(), aname,
atts.getValue(i),
- *this,
constructionContext));
+ m_avts[m_avtsCount++] =
+
constructionContext.createAVT(getLocator(), aname, atts.getValue(i), *this);
}
}
}
-
- // Shrink the vector of AVTS, if necessary...
- if (m_avts.capacity() > m_avts.size())
- {
- // Make a copy that's the exact size, and
- // swap the two...
- AVTVectorType(m_avts).swap(m_avts);
- }
}
ElemLiteralResult::~ElemLiteralResult()
{
-#if !defined(XALAN_NO_NAMESPACES)
- using std::for_each;
-#endif
-
- // Clean up all entries in the vector.
- for_each(m_avts.begin(),
- m_avts.end(),
- DeleteFunctor<AVT>());
}
@@ -246,11 +226,11 @@
// OK, now check all attribute AVTs to make sure
// our NamespacesHandler knows about any prefixes
// that will need namespace declarations...
- m_attrCount = m_avts.size();
+ const StylesheetConstructionContext::GetAndReleaseCachedString
theGuard(constructionContext);
- XalanDOMString thePrefix;
+ XalanDOMString& thePrefix = theGuard.get();
- for(AVTVectorType::size_type i = 0; i < m_attrCount; ++i)
+ for(unsigned int i = 0; i < m_avtsCount; ++i)
{
const AVT* const avt = m_avts[i];
@@ -266,7 +246,7 @@
}
}
- if (m_attrCount != 0 ||
+ if (m_avtsCount != 0 ||
m_namespacesHandler.getNamespaceDeclarationsCount() != 0)
{
canGenerateAttributes(true);
@@ -339,13 +319,13 @@
}
}
- if(m_attrCount > 0)
+ if(m_avtsCount > 0)
{
StylesheetExecutionContext::GetAndReleaseCachedString
theGuard(executionContext);
XalanDOMString& theStringedValue = theGuard.get();
- for(AVTVectorType::size_type i = 0; i < m_attrCount; ++i)
+ for(unsigned int i = 0; i < m_avtsCount; ++i)
{
const AVT* const avt = m_avts[i];
@@ -376,18 +356,23 @@
if(isAttrOK == false)
{
+ const XalanDOMString::size_type len = length(attrName);
const XalanDOMString::size_type indexOfNSSep =
indexOf(attrName, XalanUnicode::charColon);
- if(indexOfNSSep >= length(attrName))
+ if(indexOfNSSep >= len)
{
// An empty namespace is OK.
isAttrOK = true;
}
else
{
- const XalanDOMString prefix(attrName, indexOfNSSep);
+ const
StylesheetConstructionContext::GetAndReleaseCachedString
theGuard(constructionContext);
+
+ XalanDOMString& thePrefix = theGuard.get();
+
+ thePrefix.assign(attrName, indexOfNSSep);
- const XalanDOMString* const ns =
getStylesheet().getNamespaceForPrefixFromStack(prefix);
+ const XalanDOMString* const ns =
getStylesheet().getNamespaceForPrefixFromStack(thePrefix);
if (ns != 0 && equals(*ns,
constructionContext.getXSLTNamespaceURI()) == false)
{
1.29 +5 -11 xml-xalan/c/src/XSLT/ElemLiteralResult.hpp
Index: ElemLiteralResult.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemLiteralResult.hpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- ElemLiteralResult.hpp 24 Sep 2002 01:42:34 -0000 1.28
+++ ElemLiteralResult.hpp 31 Oct 2002 07:15:56 -0000 1.29
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -118,12 +118,6 @@
virtual void
execute(StylesheetExecutionContext& executionContext) const;
-#if defined(XALAN_NO_NAMESPACES)
- typedef vector<const AVT*> AVTVectorType;
-#else
- typedef std::vector<const AVT*> AVTVectorType;
-#endif
-
protected:
/**
@@ -186,22 +180,22 @@
/**
* The name of the literal result element.
*/
- const XalanDOMString& m_elementName;
+ const XalanDOMString& m_elementName;
/**
* A vector to keep track of the attribute elements.
*/
- AVTVectorType m_avts;
+ const AVT** m_avts;
/**
* The size of m_avts, once the stylesheet is compiled...
*/
- AVTVectorType::size_type m_attrCount;
+ unsigned int m_avtsCount;
/**
* If true, the literal result element has a namespace prefix...
*/
- const bool m_hasPrefix;
+ const bool m_hasPrefix;
};
1.67 +10 -23 xml-xalan/c/src/XSLT/ElemNumber.cpp
Index: ElemNumber.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemNumber.cpp,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -r1.66 -r1.67
--- ElemNumber.cpp 3 Oct 2002 06:04:18 -0000 1.66
+++ ElemNumber.cpp 31 Oct 2002 07:15:56 -0000 1.67
@@ -170,28 +170,28 @@
}
else if(equals(aname, Constants::ATTRNAME_FORMAT))
{
- m_format_avt = new AVT(getLocator(), aname,
- atts.getValue(i), *this,
constructionContext);
+ m_format_avt =
+ constructionContext.createAVT(getLocator(),
aname, atts.getValue(i), *this);
}
else if(equals(aname, Constants::ATTRNAME_LANG))
{
- m_lang_avt = new AVT(getLocator(), aname,
- atts.getValue(i), *this,
constructionContext);
+ m_lang_avt =
+ constructionContext.createAVT(getLocator(),
aname, atts.getValue(i), *this);
}
else if(equals(aname, Constants::ATTRNAME_LETTERVALUE))
{
- m_lettervalue_avt = new AVT(getLocator(), aname,
- atts.getValue(i), *this,
constructionContext);
+ m_lettervalue_avt =
+ constructionContext.createAVT(getLocator(),
aname, atts.getValue(i), *this);
}
else if(equals(aname,Constants::ATTRNAME_GROUPINGSEPARATOR))
{
- m_groupingSeparator_avt = new AVT(getLocator(), aname,
- atts.getValue(i), *this,
constructionContext);
+ m_groupingSeparator_avt =
+ constructionContext.createAVT(getLocator(),
aname, atts.getValue(i), *this);
}
else if(equals(aname,Constants::ATTRNAME_GROUPINGSIZE))
{
- m_groupingSize_avt = new AVT(getLocator(), aname,
- atts.getValue(i), *this,
constructionContext);
+ m_groupingSize_avt =
+ constructionContext.createAVT(getLocator(),
aname, atts.getValue(i), *this);
}
else if(!isAttrOK(aname, atts, i, constructionContext))
{
@@ -206,19 +206,6 @@
ElemNumber::~ElemNumber()
{
-#if defined(XALAN_CANNOT_DELETE_CONST)
- delete (AVT*)m_format_avt;
- delete (AVT*)m_lang_avt;
- delete (AVT*)m_lettervalue_avt;
- delete (AVT*)m_groupingSeparator_avt;
- delete (AVT*)m_groupingSize_avt;
-#else
- delete m_format_avt;
- delete m_lang_avt;
- delete m_lettervalue_avt;
- delete m_groupingSeparator_avt;
- delete m_groupingSize_avt;
-#endif
}
1.24 +2 -7 xml-xalan/c/src/XSLT/ElemPI.cpp
Index: ElemPI.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemPI.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- ElemPI.cpp 24 Sep 2002 01:42:34 -0000 1.23
+++ ElemPI.cpp 31 Oct 2002 07:15:56 -0000 1.24
@@ -93,8 +93,8 @@
if(equals(aname, Constants::ATTRNAME_NAME))
{
- m_nameAVT = new AVT(getLocator(), aname,
atts.getValue(i),
- *this, constructionContext);
+ m_nameAVT =
+
constructionContext.createAVT(getLocator(), aname, atts.getValue(i), *this);
}
else if(isAttrOK(aname, atts, i, constructionContext) == false
||
processSpaceAttr(aname, atts, i,
constructionContext))
@@ -119,11 +119,6 @@
ElemPI::~ElemPI()
{
-#if defined(XALAN_CANNOT_DELETE_CONST)
- delete (AVT*)m_nameAVT;
-#else
- delete m_nameAVT;
-#endif
}
1.16 +20 -29 xml-xalan/c/src/XSLT/ElemSort.cpp
Index: ElemSort.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemSort.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- ElemSort.cpp 24 Sep 2002 01:42:34 -0000 1.15
+++ ElemSort.cpp 31 Oct 2002 07:15:56 -0000 1.16
@@ -101,23 +101,23 @@
}
else if(equals(aname, Constants::ATTRNAME_LANG))
{
- m_langAVT = new AVT(getLocator(), aname,
atts.getValue(i),
- *this, constructionContext);
+ m_langAVT =
+
constructionContext.createAVT(getLocator(), aname, atts.getValue(i), *this);
}
else if(equals(aname, Constants::ATTRNAME_DATATYPE))
{
- m_dataTypeAVT = new AVT(getLocator(), aname,
atts.getValue(i),
- *this, constructionContext);
+ m_dataTypeAVT =
+
constructionContext.createAVT(getLocator(), aname, atts.getValue(i), *this);
}
else if(equals(aname, Constants::ATTRNAME_ORDER))
{
- m_orderAVT = new AVT(getLocator(), aname,
atts.getValue(i),
- *this, constructionContext);
+ m_orderAVT =
+
constructionContext.createAVT(getLocator(), aname, atts.getValue(i), *this);
}
else if(equals(aname, Constants::ATTRNAME_CASEORDER))
{
- m_caseOrderAVT = new AVT(getLocator(), aname,
atts.getValue(i),
- *this, constructionContext);
+ m_caseOrderAVT =
+
constructionContext.createAVT(getLocator(), aname, atts.getValue(i), *this);
}
else if(!isAttrOK(aname, atts, i, constructionContext))
{
@@ -130,14 +130,22 @@
if(0 == m_dataTypeAVT)
{
- m_dataTypeAVT = new AVT(getLocator(),
c_wstr(Constants::ATTRNAME_DATATYPE), c_wstr(Constants::ATTRVAL_DATATYPE_TEXT),
- *this, constructionContext);
+ m_dataTypeAVT =
+ constructionContext.createAVT(
+ getLocator(),
+ c_wstr(Constants::ATTRNAME_DATATYPE),
+ c_wstr(Constants::ATTRVAL_DATATYPE_TEXT),
+ *this);
}
if(0 == m_orderAVT)
{
- m_orderAVT = new AVT(getLocator(),
c_wstr(Constants::ATTRNAME_ORDER), c_wstr(Constants::ATTRVAL_ORDER_ASCENDING),
- *this, constructionContext);
+ m_orderAVT =
+ constructionContext.createAVT(
+ getLocator(),
+ c_wstr(Constants::ATTRNAME_ORDER),
+ c_wstr(Constants::ATTRVAL_ORDER_ASCENDING),
+ *this);
}
if(0 == m_selectPattern)
@@ -149,23 +157,6 @@
ElemSort::~ElemSort()
{
-#if defined(XALAN_CANNOT_DELETE_CONST)
- delete (AVT*)m_langAVT;
-
- delete (AVT*)m_dataTypeAVT;
-
- delete (AVT*)m_orderAVT;
-
- delete (AVT*)m_caseOrderAVT;
-#else
- delete m_langAVT;
-
- delete m_dataTypeAVT;
-
- delete m_orderAVT;
-
- delete m_caseOrderAVT;
-#endif
}
1.19 +1 -1 xml-xalan/c/src/XSLT/ElemTextLiteral.cpp
Index: ElemTextLiteral.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemTextLiteral.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- ElemTextLiteral.cpp 24 Sep 2002 01:42:34 -0000 1.18
+++ ElemTextLiteral.cpp 31 Oct 2002 07:15:56 -0000 1.19
@@ -93,7 +93,7 @@
m_disableOutputEscaping(disableOutputEscaping),
m_isWhitespace(isXMLWhitespace(ch, start, length)),
// Always null-terminate our buffer, since we may need it that way.
- m_ch(constructionContext.allocateVector(ch + start, length, true)),
+ m_ch(constructionContext.allocateXalanDOMCharVector(ch + start, length,
true)),
m_length(length)
{
}
1.21 +44 -21 xml-xalan/c/src/XSLT/ElemUse.cpp
Index: ElemUse.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemUse.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- ElemUse.cpp 24 Sep 2002 05:59:38 -0000 1.20
+++ ElemUse.cpp 31 Oct 2002 07:15:56 -0000 1.21
@@ -91,7 +91,8 @@
lineNumber,
columnNumber,
xslToken),
- m_attributeSetsNames()
+ m_attributeSetsNames(0),
+ m_attributeSetsNamesCount(0)
{
}
@@ -116,7 +117,7 @@
StylesheetConstructionContext& constructionContext,
const NamespacesHandler&
theParentHandler)
{
- if (m_attributeSetsNames.empty() == false)
+ if (m_attributeSetsNamesCount > 0)
{
canGenerateAttributes(true);
}
@@ -140,14 +141,17 @@
StylesheetExecutionContext&
executionContext,
bool
applyAttributeSets) const
{
+ assert(m_attributeSetsNamesCount == 0 || m_attributeSetsNames != 0);
+
ElemTemplateElement::execute(executionContext);
- if(applyAttributeSets == true && m_attributeSetsNames.empty() == false)
+ if(applyAttributeSets == true && m_attributeSetsNamesCount > 0)
{
assert(canGenerateAttributes() == true);
getStylesheet().getStylesheetRoot().applyAttrSets(
m_attributeSetsNames,
+ m_attributeSetsNamesCount,
executionContext,
executionContext.getCurrentNode());
}
@@ -166,11 +170,10 @@
if(StylesheetConstructionContext::ELEMNAME_LITERAL_RESULT ==
getXSLToken())
{
- const XalanQNameByValue qname(attrName,
getStylesheet().getNamespaces());
-
- isUAS = ((equals(qname.getNamespace(),
- constructionContext.getXSLTNamespaceURI())) &&
- (equals(qname.getLocalPart(),
Constants::ATTRNAME_USEATTRIBUTESETS)));
+ isUAS = constructionContext.isXSLUseAttributeSetsAttribute(
+ attrName,
+ getStylesheet(),
+ getLocator());
}
else
{
@@ -179,26 +182,46 @@
if(isUAS == true)
{
+#if 1
+ m_attributeSetsNames =
+ constructionContext.tokenizeQNames(
+ m_attributeSetsNamesCount,
+ atts.getValue(which),
+ getStylesheet().getNamespaces(),
+ getLocator());
+ assert(m_attributeSetsNamesCount == 0 || m_attributeSetsNames
!= 0);
+#else
const XalanDOMChar* const qnames = atts.getValue(which);
- StringTokenizer tokenizer(qnames,
-
c_wstr(XALAN_STATIC_UCODE_STRING(" \t\n\r")),
-
false);
+ StringTokenizer tokenizer(qnames);
- m_attributeSetsNames.reserve(tokenizer.countTokens());
+ m_attributeSetsNamesCount = tokenizer.countTokens();
- XalanDOMString qname;
-
- while(tokenizer.hasMoreTokens())
+ if (m_attributeSetsNamesCount > 0)
{
- tokenizer.nextToken(qname);
- assert(length(qname) != 0);
+ m_attributeSetsNames =
constructionContext.allocateQNamePointerVector(m_attributeSetsNamesCount);
+
+ const
StylesheetConstructionContext::GetAndReleaseCachedString
theGuard(constructionContext);
+
+ XalanDOMString& qname = theGuard.get();
+
+ size_type theCurrentIndex = 0;
+
+ while(tokenizer.hasMoreTokens())
+ {
+ tokenizer.nextToken(qname);
+ assert(length(qname) != 0);
+
+ m_attributeSetsNames[theCurrentIndex++] =
+ constructionContext.createQNameByValue(
+ qname,
+ getStylesheet().getNamespaces(),
+ getLocator());
+ }
- m_attributeSetsNames.push_back(
- QNameVectorType::value_type(
- qname,
- getStylesheet().getNamespaces()));
+ assert(theCurrentIndex == m_attributeSetsNamesCount);
}
+#endif
}
return isUAS;
1.18 +6 -4 xml-xalan/c/src/XSLT/ElemUse.hpp
Index: ElemUse.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemUse.hpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- ElemUse.hpp 24 Sep 2002 01:42:35 -0000 1.17
+++ ElemUse.hpp 31 Oct 2002 07:15:56 -0000 1.18
@@ -81,10 +81,10 @@
{
public:
-#if defined(XALAN_NO_NAMESPACES)
- typedef vector<XalanQNameByValue> QNameVectorType;
+#if defined(XALAN_SIZE_T_IN_NAMESPACE_STD)
+ typedef std::size_t size_type;
#else
- typedef std::vector<XalanQNameByValue> QNameVectorType;
+ typedef size_t size_type;
#endif
/**
@@ -155,7 +155,9 @@
private:
- QNameVectorType m_attributeSetsNames;
+ const XalanQName** m_attributeSetsNames;
+
+ size_type m_attributeSetsNamesCount;
};
1.82 +9 -27 xml-xalan/c/src/XSLT/Stylesheet.cpp
Index: Stylesheet.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/Stylesheet.cpp,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -r1.81 -r1.82
--- Stylesheet.cpp 26 Sep 2002 01:38:15 -0000 1.81
+++ Stylesheet.cpp 31 Oct 2002 07:15:56 -0000 1.82
@@ -158,7 +158,6 @@
m_attributeSetsSize(0),
m_surrogateChildren(*this),
m_elemDecimalFormats(),
- m_prefixAliases(),
m_namespacesHandler()
{
if (length(m_baseIdent) == 0)
@@ -1355,28 +1354,10 @@
}
else
{
-#if 1
- // $$$ ToDo: Enable other code. Perhaps an error?
- m_prefixAliases[*stylesheetNamespace] = *resultNamespace;
-
m_namespacesHandler.setNamespaceAlias(
constructionContext,
*stylesheetNamespace,
*resultNamespace);
-#else
- const PrefixAliasesMapType::iterator i =
- m_prefixAliases.find(*stylesheetNamespace);
-
- if (i != m_prefixAliases.end())
- {
- // $$$ ToDo: This could also be an error?
- (*i).second = *resultNamespace;
- }
- else
- {
-
m_prefixAliases.insert(PrefixAliasesMapType::value_type(*stylesheetNamespace,
*resultNamespace));
- }
-#endif
}
}
@@ -1435,13 +1416,12 @@
void
Stylesheet::applyAttrSets(
- const QNameVectorType&
attributeSetsNames,
+ const XalanQName**
attributeSetsNames,
+ size_type
attributeSetsNamesCount,
StylesheetExecutionContext& executionContext,
XalanNode*
sourceNode) const
{
- const QNameVectorType::size_type nNames =
attributeSetsNames.size();
-
- if(0 != nNames)
+ if(0 != attributeSetsNamesCount)
{
// Process up the import chain...
const StylesheetVectorType::const_reverse_iterator theEnd
= m_imports.rend();
@@ -1450,16 +1430,18 @@
while(i != theEnd)
{
(*i)->applyAttrSets(
- attributeSetsNames,
+ attributeSetsNames,
+ attributeSetsNamesCount,
executionContext,
sourceNode);
++i;
}
- for(QNameVectorType::size_type j = 0; j < nNames; j++)
+ for(QNameVectorType::size_type j = 0; j <
attributeSetsNamesCount; j++)
{
- const XalanQName& qname = attributeSetsNames[j];
+ const XalanQName* const qname =
attributeSetsNames[j];
+ assert(qname != 0);
assert(m_attributeSetsSize == m_attributeSets.size());
@@ -1468,7 +1450,7 @@
const ElemAttributeSet* const attrSet =
m_attributeSets[k];
assert(attrSet != 0);
- if(qname.equals(attrSet->getQName()))
+ if(qname->equals(attrSet->getQName()))
{
attrSet->execute(executionContext);
}
1.50 +21 -14 xml-xalan/c/src/XSLT/Stylesheet.hpp
Index: Stylesheet.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/Stylesheet.hpp,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- Stylesheet.hpp 11 Oct 2002 02:01:54 -0000 1.49
+++ Stylesheet.hpp 31 Oct 2002 07:15:56 -0000 1.50
@@ -108,6 +108,7 @@
class PrefixResolver;
class StylesheetConstructionContext;
class StylesheetRoot;
+class XalanQName;
class XMLURL;
class XObject;
class StylesheetExecutionContext;
@@ -123,19 +124,22 @@
public:
+#if defined(XALAN_SIZE_T_IN_NAMESPACE_STD)
+ typedef std::size_t size_type;
+#else
+ typedef size_t size_type;
+#endif
+
typedef StylesheetExecutionContext::ParamVectorType
ParamVectorType;
typedef XalanQName::NamespaceVectorType
NamespaceVectorType;
typedef XalanQName::NamespacesStackType
NamespacesStackType;
#if defined(XALAN_NO_NAMESPACES)
typedef map<XalanDOMString,
- XalanDOMString,
- less<XalanDOMString> >
StringToStringMapType;
- typedef map<XalanDOMString,
ExtensionNSHandler*,
less<XalanDOMString> >
ExtensionNamespacesMapType;
typedef map<XalanQNameByReference,
- ElemTemplate*,
+ const ElemTemplate*,
less<XalanQName> >
ElemTemplateMapType;
typedef vector<ElemAttributeSet*>
AttributeSetVectorType;
typedef vector<ElemVariable*>
ElemVariableVectorType;
@@ -143,24 +147,24 @@
typedef map<const XalanNode*,
KeyTable*,
less<const XalanNode*> >
KeyTablesTableType;
- typedef vector<XalanQNameByValue>
QNameVectorType;
typedef vector<Stylesheet*>
StylesheetVectorType;
typedef vector<XalanDOMString>
URLStackType;
typedef vector<const XPath*>
XPathVectorType;
typedef vector<ElemDecimalFormat*>
ElemDecimalFormatVectorType;
#else
- typedef std::map<XalanDOMString, XalanDOMString>
StringToStringMapType;
typedef std::map<XalanDOMString, ExtensionNSHandler*>
ExtensionNamespacesMapType;
- typedef std::map<XalanQNameByReference, ElemTemplate*>
ElemTemplateMapType;
+ typedef std::map<XalanQNameByReference,
+ const ElemTemplate*,
+ std::less<XalanQName> >
ElemTemplateMapType;
typedef std::vector<ElemAttributeSet*>
AttributeSetVectorType;
typedef std::vector<ElemVariable*>
ElemVariableVectorType;
typedef std::vector<KeyDeclaration>
KeyDeclarationVectorType;
typedef std::map<const XalanNode*, KeyTable*>
KeyTablesTableType;
- typedef std::vector<XalanQNameByValue>
QNameVectorType;
typedef std::vector<Stylesheet*>
StylesheetVectorType;
typedef std::vector<XalanDOMString>
URLStackType;
typedef std::vector<const XPath*>
XPathVectorType;
typedef std::vector<ElemDecimalFormat*>
ElemDecimalFormatVectorType;
+ typedef std::vector<XalanQNameByValue>
QNameVectorType;
#endif
/**
@@ -521,13 +525,15 @@
* Apply the set of named attributes to a node in a given context with a
* given mode
*
- * @param attributeSetsNames list of attribute set names
- * @param executionContext current execution context
- * @param sourceNode source node
+ * @param attributeSetsNames The vector of attribute set names
+ * @param attributeSetsNamesCount The size of the vector
+ * @param executionContext The current execution context
+ * @param sourceNode The source node
*/
void
applyAttrSets(
- const QNameVectorType&
attributeSetsNames,
+ const XalanQName**
attributeSetsNames,
+ size_type
attributeSetsNamesCount,
StylesheetExecutionContext& executionContext,
XalanNode*
sourceNode) const;
@@ -1297,13 +1303,14 @@
AttributeSetVectorType m_attributeSets;
+ /**
+ * This caches the number of attribute sets.
+ */
AttributeSetVectorType::size_type m_attributeSetsSize;
XalanNodeListSurrogate
m_surrogateChildren;
ElemDecimalFormatVectorType
m_elemDecimalFormats;
-
- StringToStringMapType m_prefixAliases;
NamespacesHandler
m_namespacesHandler;
1.3 +2 -1 xml-xalan/c/src/XSLT/StylesheetConstructionContext.cpp
Index: StylesheetConstructionContext.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetConstructionContext.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- StylesheetConstructionContext.cpp 24 Sep 2002 01:42:35 -0000 1.2
+++ StylesheetConstructionContext.cpp 31 Oct 2002 07:15:56 -0000 1.3
@@ -59,7 +59,8 @@
-StylesheetConstructionContext::StylesheetConstructionContext()
+StylesheetConstructionContext::StylesheetConstructionContext() :
+ XPathConstructionContext()
{
}
1.17 +154 -23 xml-xalan/c/src/XSLT/StylesheetConstructionContext.hpp
Index: StylesheetConstructionContext.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetConstructionContext.hpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- StylesheetConstructionContext.hpp 24 Sep 2002 05:59:38 -0000 1.16
+++ StylesheetConstructionContext.hpp 31 Oct 2002 07:15:56 -0000 1.17
@@ -74,6 +74,13 @@
+#include <XPath/XalanQName.hpp>
+#include <XPath/XPathConstructionContext.hpp>
+
+
+
+class AVT;
+class AVTPart;
class DocumentHandler;
class ElemTemplateElement;
class Locator;
@@ -92,10 +99,18 @@
// An abstract class which provides support for constructing the internal
// representation of a stylesheet.
//
-class XALAN_XSLT_EXPORT StylesheetConstructionContext
+class XALAN_XSLT_EXPORT StylesheetConstructionContext : public
XPathConstructionContext
{
public:
+ typedef XalanQName::NamespacesStackType NamespacesStackType;
+
+#if defined(XALAN_SIZE_T_IN_NAMESPACE_STD)
+ typedef std::size_t size_type;
+#else
+ typedef size_t size_type;
+#endif
+
/**
* IDs for XSL element types. These are the values
* that must be returned by getElementToken().
@@ -336,6 +351,23 @@
const PrefixResolver& resolver) = 0;
/**
+ * Create and initialize an xpath and return it. This is to be used by
+ * stylesheet elements that need an XPath that is guaranteed to persist
+ * while it lives.
+ *
+ * @param locator the locator for the XPath. May be null.
+ * @param str string to match
+ * @param resolver resolver for namespace resolution
+ * @return XPath for string matched
+ */
+ virtual XPath*
+ createXPath(
+ const Locator* locator,
+ const XalanDOMChar* str,
+ XalanDOMString::size_type len,
+ const PrefixResolver& resolver) = 0;
+
+ /**
* Get the locator from the top of the locator stack.
*
* @return A pointer to the Locator, or 0 if there is nothing on the
stack.
@@ -395,6 +427,18 @@
const Locator* theLocator) = 0;
/**
+ * Given an name, determine if it is the xsl:use-attribute-sets
attribute
+ *
+ * @param name a name
+ * @return true if the string is the xsl:use-attribute-sets attribute
name
+ */
+ virtual bool
+ isXSLUseAttributeSetsAttribute(
+ const XalanDOMChar* theAttributeName,
+ const Stylesheet& theStylesheet,
+ const Locator* theLocator) = 0;
+
+ /**
* Given an XSL tag name, return an integer token that corresponds to
* the enums defined above.
*
@@ -412,41 +456,29 @@
virtual double
getXSLTVersionSupported() const = 0;
- /**
- * Get a pooled string given the source string. If
- * the string already exists in the pool, no copy
- * will be made. If not, a copy will be made and
- * kept for later use.
- *
- * @param theString The source string
- * @return a const reference to a pooled string.
- */
virtual const XalanDOMString&
getPooledString(const XalanDOMString& theString) = 0;
- /**
- * Get a pooled string given the source character
- * array. If the string already exists in the pool,
- * no copy will be made. If not, a copy will be made
- * and kept for later use.
- *
- * @param theString The source character array
- * @param theLength The length of the character array
- * @return a const reference to a pooled string.
- */
virtual const XalanDOMString&
getPooledString(
const XalanDOMChar* theString,
XalanDOMString::size_type theLength =
XalanDOMString::npos) = 0;
+ virtual XalanDOMString&
+ getCachedString() = 0;
+
+ virtual bool
+ releaseCachedString(XalanDOMString& theString) = 0;
+
/**
* Allocate a vector of XalanDOMChar of the specified
* size.
*
* @param theLength The length of the character vector
+ * @return A pointer to the vector.
*/
virtual XalanDOMChar*
- allocateVector(XalanDOMString::size_type theLength) = 0;
+ allocateXalanDOMCharVector(XalanDOMString::size_type theLength) = 0;
/**
* Allocate a vector of XalanDOMChar of the specified
@@ -455,14 +487,113 @@
* @param theString The source character array
* @param theLength The length of the character vector
* @param fTerminate If true, terminate the new vector with 0
+ * @return A pointer to the array.
*/
virtual XalanDOMChar*
- allocateVector(
+ allocateXalanDOMCharVector(
const XalanDOMChar* theString,
XalanDOMString::size_type theLength =
XalanDOMString::npos,
bool
fTerminate = true) = 0;
- // These interfaces are inherited from ExecutionContext...
+ /**
+ * Create an AVT instance.
+ *
+ * @param locator the Locator for the instance. May be null.
+ * @param name name of AVT
+ * @param stringedValue string value to parse
+ * @param resolver resolver for namespace resolution
+ * @return A pointer to the instance.
+ */
+ virtual const AVT*
+ createAVT(
+ const Locator* locator,
+ const XalanDOMChar* name,
+ const XalanDOMChar*
stringedValue,
+ const PrefixResolver& resolver) = 0;
+
+ /**
+ * Create an AVTPart instance.
+ *
+ * @param theString The source character array
+ * @param theLength The length of the character vector
+ * @param fTerminate If true, terminate the new vector with 0
+ * @return A pointer to the instance.
+ */
+ virtual const AVTPart*
+ createAVTPart(
+ const XalanDOMChar* theString,
+ XalanDOMString::size_type theLength =
XalanDOMString::npos) = 0;
+
+ /**
+ * Create an AVTPart instance.
+ *
+ * @param locator the Locator for the instance. May be null.
+ * @param str The XPath expression for the instance
+ * @param len The length of the expression
+ * @param resolver resolver for namespace resolution
+ * @return A pointer to the instance.
+ */
+ virtual const AVTPart*
+ createAVTPart(
+ const Locator* locator,
+ const XalanDOMChar* str,
+ XalanDOMString::size_type len,
+ const PrefixResolver& resolver) = 0;
+
+ /**
+ * Allocate a vector of const AVT* of the specified
+ * length.
+ *
+ * @param theLength The length of the vector
+ * @return A pointer to the vector.
+ */
+ virtual const AVT**
+ allocateAVTPointerVector(size_type theLength) = 0;
+
+ /**
+ * Allocate a vector of const AVTPart* of the specified
+ * length.
+ *
+ * @param theLength The length of the vector
+ * @return A pointer to the vector.
+ */
+ virtual const AVTPart**
+ allocateAVTPartPointerVector(size_type theLength) = 0;
+
+ /**
+ * Create a XalanQName-derived instance.
+ *
+ * @param qname The qname string
+ * @param namespaces The stack of namespaces
+ * @param Locator The current Locator, if any
+ * @param fUseDefault If true, a qname without a prefix will use the
default namespace
+ * @return A pointer to the new instance
+ */
+ virtual const XalanQName*
+ createXalanQNameByValue(
+ const XalanDOMString& qname,
+ const NamespacesStackType& namespaces,
+ const Locator* locator = 0,
+ bool
fUseDefault = false) = 0;
+
+ /**
+ * Tokenize a string and return the QNames corresponding to
+ * those tokens.
+ *
+ * @param count The number of namespaces in the vector returned
+ * @param qnameTokens The string to tokenize
+ * @param namespaces The stack of namespaces
+ * @param Locator The current Locator, if any
+ * @param fUseDefault If true, qnames without prefixes will use the
default namespace
+ * @return The resulting vector of XalanQName instances.
+ */
+ virtual const XalanQName**
+ tokenizeQNames(
+ size_type& count,
+ const XalanDOMChar* qnameTokens,
+ const NamespacesStackType& namespaces,
+ const Locator* locator = 0,
+ bool
fUseDefault = false) = 0;
virtual void
error(
1.25 +221 -9
xml-xalan/c/src/XSLT/StylesheetConstructionContextDefault.cpp
Index: StylesheetConstructionContextDefault.cpp
===================================================================
RCS file:
/home/cvs/xml-xalan/c/src/XSLT/StylesheetConstructionContextDefault.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- StylesheetConstructionContextDefault.cpp 24 Sep 2002 05:59:38 -0000
1.24
+++ StylesheetConstructionContextDefault.cpp 31 Oct 2002 07:15:56 -0000
1.25
@@ -69,6 +69,7 @@
+#include <PlatformSupport/StringTokenizer.hpp>
#include <PlatformSupport/URISupport.hpp>
@@ -93,17 +94,35 @@
StylesheetConstructionContextDefault::StylesheetConstructionContextDefault(
- XSLTEngineImpl& processor,
- XPathFactory& xpathFactory,
- VectorAllocatorSizeType theAllocatorSize) :
+ XSLTEngineImpl&
processor,
+ XPathFactory&
xpathFactory,
+ VectorAllocatorSizeType
theXalanDOMCharVectorAllocatorBlockSize,
+ XalanAVTAllocator::size_type
theAVTAllocatorBlockSize,
+ XalanAVTPartSimpleAllocator::size_type
theAVTPartSimpleAllocatorBlockSize,
+ XalanAVTPartXPathAllocator::size_type
theAVTPartXPathAllocatorBlockSize,
+ VectorAllocatorSizeType
theAVTPointerVectorAllocatorBlockSize,
+ VectorAllocatorSizeType
theAVTPartPointerVectorAllocatorBlockSize,
+ XalanQNameByValueAllocator::size_type
theXalanQNameByValueAllocatorBlockSize,
+ VectorAllocatorSizeType
theXalanQNamePointerVectorAllocatorBlockSize) :
StylesheetConstructionContext(),
m_processor(processor),
m_xpathFactory(xpathFactory),
m_xpathProcessor(new XPathProcessorImpl),
m_stylesheets(),
m_stringPool(),
- m_xalanDOMCharVectorAllocator(theAllocatorSize),
- m_tempBuffer()
+ m_xalanDOMCharVectorAllocator(theXalanDOMCharVectorAllocatorBlockSize),
+ m_tempBuffer(),
+ m_scratchQName(),
+ m_stringCache(),
+ m_avtAllocator(theAVTAllocatorBlockSize),
+ m_avtPartSimpleAllocator(theAVTPartSimpleAllocatorBlockSize),
+ m_avtPartXPathAllocator(theAVTPartXPathAllocatorBlockSize),
+ m_avtPointerVectorAllocator(theAVTPointerVectorAllocatorBlockSize),
+
m_avtPartPointerVectorAllocator(theAVTPartPointerVectorAllocatorBlockSize),
+ m_xalanQNameByValueAllocator(theXalanQNameByValueAllocatorBlockSize),
+
m_xalanQNameVectorAllocator(theXalanQNamePointerVectorAllocatorBlockSize),
+ m_useAttributeSetsQName(XSLTEngineImpl::getXSLNameSpaceURL(),
Constants::ATTRNAME_USEATTRIBUTESETS),
+ m_pointerVectorAllocator(512)
{
}
@@ -284,6 +303,8 @@
m_stylesheets.clear();
m_xpathFactory.reset();
+
+ m_stringCache.reset();
}
@@ -416,6 +437,7 @@
// will be used at run-time.
m_xpathProcessor->initMatchPattern(
*xpath,
+ *this,
str,
resolver,
getLocatorFromStack());
@@ -459,6 +481,7 @@
// will be used at run-time.
m_xpathProcessor->initXPath(
*xpath,
+ *this,
str,
resolver,
getLocatorFromStack());
@@ -487,6 +510,22 @@
+XPath*
+StylesheetConstructionContextDefault::createXPath(
+ const Locator* locator,
+ const XalanDOMChar* str,
+ XalanDOMString::size_type len,
+ const PrefixResolver& resolver)
+{
+ assert(str != 0);
+
+ assign(m_tempBuffer, str, len);
+
+ return createXPath(locator, m_tempBuffer, resolver);
+}
+
+
+
const Locator*
StylesheetConstructionContextDefault::getLocatorFromStack() const
{
@@ -538,9 +577,24 @@
{
assert(theAttributeName != 0);
- m_spaceAttributeQName.set(theAttributeName,
theStylesheet.getNamespaces(), theLocator, true);
+ m_scratchQName.set(theAttributeName, theStylesheet.getNamespaces(),
theLocator, true);
+
+ return s_spaceAttrQName.equals(m_scratchQName);
+}
+
+
+
+bool
+StylesheetConstructionContextDefault::isXSLUseAttributeSetsAttribute(
+ const XalanDOMChar* theAttributeName,
+ const Stylesheet& theStylesheet,
+ const Locator* theLocator)
+{
+ assert(theAttributeName != 0);
+
+ m_scratchQName.set(theAttributeName, theStylesheet.getNamespaces(),
theLocator, true);
- return s_spaceAttrQName.equals(m_spaceAttributeQName);
+ return m_useAttributeSetsQName.equals(m_scratchQName);
}
@@ -612,8 +666,24 @@
+XalanDOMString&
+StylesheetConstructionContextDefault::getCachedString()
+{
+ return m_stringCache.get();
+}
+
+
+
+bool
+StylesheetConstructionContextDefault::releaseCachedString(XalanDOMString&
theString)
+{
+ return m_stringCache.release(theString);
+}
+
+
+
XalanDOMChar*
-StylesheetConstructionContextDefault::allocateVector(XalanDOMString::size_type
theLength)
+StylesheetConstructionContextDefault::allocateXalanDOMCharVector(XalanDOMString::size_type
theLength)
{
return m_xalanDOMCharVectorAllocator.allocate(theLength);
}
@@ -621,7 +691,7 @@
XalanDOMChar*
-StylesheetConstructionContextDefault::allocateVector(
+StylesheetConstructionContextDefault::allocateXalanDOMCharVector(
const XalanDOMChar* theString,
XalanDOMString::size_type theLength,
bool
fTerminate)
@@ -643,6 +713,148 @@
}
return theVector;
+}
+
+
+
+const AVT*
+StylesheetConstructionContextDefault::createAVT(
+ const Locator* locator,
+ const XalanDOMChar* name,
+ const XalanDOMChar*
stringedValue,
+ const PrefixResolver& resolver)
+{
+ return m_avtAllocator.create(*this, locator, name, stringedValue,
resolver);
+}
+
+
+
+const AVTPart*
+StylesheetConstructionContextDefault::createAVTPart(
+ const XalanDOMChar* theString,
+ XalanDOMString::size_type theLength)
+{
+ return m_avtPartSimpleAllocator.create(*this, theString, theLength);
+}
+
+
+
+const AVTPart*
+StylesheetConstructionContextDefault::createAVTPart(
+ const Locator* locator,
+ const XalanDOMChar* str,
+ XalanDOMString::size_type len,
+ const PrefixResolver& resolver)
+{
+ const XPath* const xpath =
+ createXPath(
+ locator,
+ str,
+ len,
+ resolver);
+
+ assert(xpath != 0);
+
+ return m_avtPartXPathAllocator.create(xpath);
+}
+
+
+
+template<class Type>
+Type
+allocate(
+
StylesheetConstructionContextDefault::XalanVoidPointerVectorAllocatorType&
theAllocator,
+ StylesheetConstructionContextDefault::size_type
theSize,
+ Type
theDummy)
+{
+#if defined(XALAN_OLD_STYLE_CASTS)
+ return (Type)theAllocator.allocate(theSize);
+#else
+ return reinterpret_cast<Type>(theAllocator.allocate(theSize));
+#endif
+}
+
+
+
+const AVT**
+StylesheetConstructionContextDefault::allocateAVTPointerVector(size_type
theLength)
+{
+ const AVT** theDummy;
+
+ return allocate(m_pointerVectorAllocator, theLength, theDummy);
+}
+
+
+
+const AVTPart**
+StylesheetConstructionContextDefault::allocateAVTPartPointerVector(size_type
theLength)
+{
+ const AVTPart** theDummy;
+
+ return allocate(m_pointerVectorAllocator, theLength, theDummy);
+}
+
+
+
+const XalanQName*
+StylesheetConstructionContextDefault::createXalanQNameByValue(
+ const XalanDOMString& qname,
+ const NamespacesStackType& namespaces,
+ const Locator* locator,
+ bool
fUseDefault)
+{
+ return m_xalanQNameByValueAllocator.create(qname, namespaces, locator,
fUseDefault);
+
+}
+
+
+
+const XalanQName**
+StylesheetConstructionContextDefault::tokenizeQNames(
+ size_type& count,
+ const XalanDOMChar* qnameTokens,
+ const NamespacesStackType& namespaces,
+ const Locator* locator,
+ bool
fUseDefault)
+{
+ assert(qnameTokens != 0);
+
+ StringTokenizer tokenizer(qnameTokens);
+
+ count = tokenizer.countTokens();
+
+ if (count == 0)
+ {
+ return 0;
+ }
+ else
+ {
+ const XalanQName** theResult =
allocate(m_pointerVectorAllocator, count, theResult);
+ assert(theResult != 0);
+
+ const GetAndReleaseCachedString theGuard(*this);
+
+ XalanDOMString& qname = theGuard.get();
+
+ size_type theCurrentIndex = 0;
+
+ while(tokenizer.hasMoreTokens())
+ {
+ tokenizer.nextToken(qname);
+ assert(length(qname) != 0);
+
+ theResult[theCurrentIndex++] =
+ m_xalanQNameByValueAllocator.create(
+ qname,
+ namespaces,
+ locator,
+ fUseDefault);
+ }
+
+ assert(theCurrentIndex == count);
+
+ return theResult;
+ }
}
1.25 +135 -17
xml-xalan/c/src/XSLT/StylesheetConstructionContextDefault.hpp
Index: StylesheetConstructionContextDefault.hpp
===================================================================
RCS file:
/home/cvs/xml-xalan/c/src/XSLT/StylesheetConstructionContextDefault.hpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- StylesheetConstructionContextDefault.hpp 24 Sep 2002 05:59:38 -0000
1.24
+++ StylesheetConstructionContextDefault.hpp 31 Oct 2002 07:15:56 -0000
1.25
@@ -66,6 +66,11 @@
+#include <vector>
+
+
+
+#include <PlatformSupport/ArenaAllocator.hpp>
#include <PlatformSupport/XalanArrayAllocator.hpp>
#include <PlatformSupport/XalanDOMStringPool.hpp>
@@ -81,8 +86,13 @@
+#include <PlatformSupport/XalanDOMStringCache.hpp>
+
+
+
#include <XPath/XalanQNameByReference.hpp>
#include <XPath/XalanQNameByValue.hpp>
+#include <XPath/XalanQNameByValueAllocator.hpp>
@@ -91,7 +101,12 @@
-#include <vector>
+#include <XSLT/AVT.hpp>
+#include <XSLT/XalanAVTAllocator.hpp>
+#include <XSLT/AVTPartSimple.hpp>
+#include <XSLT/XalanAVTPartSimpleAllocator.hpp>
+#include <XSLT/AVTPartXPath.hpp>
+#include <XSLT/XalanAVTPartXPathAllocator.hpp>
@@ -113,10 +128,22 @@
public:
typedef XalanArrayAllocator<XalanDOMChar>
XalanDOMCharVectorAllocatorType;
+ typedef XalanArrayAllocator<const AVT*>
XalanAVTPointerVectorAllocatorType;
+ typedef XalanArrayAllocator<const AVTPart*>
XalanAVTPartPointerVectorAllocatorType;
+ typedef XalanArrayAllocator<const XalanQName*>
XalanQNameVectorAllocatorType;
+ typedef XalanArrayAllocator<const void*>
XalanVoidPointerVectorAllocatorType;
typedef XalanDOMCharVectorAllocatorType::size_type
VectorAllocatorSizeType;
// Default size for vector allocation.
- enum { eDefaultBlockSize = 1024 };
+ enum {
+ eDefaultXalanDOMCharVectorBlockSize = 1024,
+ eDefaultAVTBlockSize = 128,
+ eDefaultAVTPartSimpleBlockSize = 128,
+ eDefaultAVTPartXPathBlockSize = 128,
+ eDefaultAVTPointerVectorBlockSize = 512,
+ eDefaultAVTPartPointerVectorBlockSize = 512,
+ eDefaultXalanQNameByValueBlockSize = 32,
+ eDefaultXalanQNamePointerVectorBlockSize = 512 };
/*
* Construct an instance. If the stylesheet(s) constructed is/are
meant to be reused (a.k.a. "compiled"),
@@ -127,17 +154,29 @@
*
* @param processor a reference to an XSLTEngineImpl instance. Used
for error reporting.
* @param xpathFactory a reference to an XPathFactory instance. See
comments above for important details.
- * @param theAllocatorSize The block size to use for allocating vectors
of XalanDOMChars
+ * @param theXalanDOMCharVectorAllocatorBlockSize The block size to use
for allocating vectors of XalanDOMChars
+ * @param theAVTAllocatorBlockSize The block size to use for allocating
AVT instances.
+ * @param theAVTPartSimpleAllocatorBlockSize The block size to use for
allocating AVTPartSimple instances.
+ * @param theAVTPartXPathAllocatorBlockSize The block size to use for
allocating AVTPartXPath instances.
+ * @param theAVTPartPointerVectorAllocatorBlockSize The block size to
use for allocating vectors of AVTPart pointers.
+ * @param theXalanQNameByValueAllocatorBlockSize The block size to use
for allocating XalanQNameByValue instances.
+ * @param theAVTPartPointerVectorAllocatorBlockSize The block size to
use for allocating vectors of AVTPart pointers.
*/
StylesheetConstructionContextDefault(
- XSLTEngineImpl& processor,
- XPathFactory& xpathFactory,
- VectorAllocatorSizeType theAllocatorSize =
eDefaultBlockSize);
+ XSLTEngineImpl&
processor,
+ XPathFactory&
xpathFactory,
+ VectorAllocatorSizeType
theXalanDOMCharVectorAllocatorBlockSize = eDefaultXalanDOMCharVectorBlockSize,
+ XalanAVTAllocator::size_type
theAVTAllocatorBlockSize = eDefaultAVTBlockSize,
+ XalanAVTPartSimpleAllocator::size_type
theAVTPartSimpleAllocatorBlockSize = eDefaultAVTPartSimpleBlockSize,
+ XalanAVTPartXPathAllocator::size_type
theAVTPartXPathAllocatorBlockSize = eDefaultAVTPartXPathBlockSize,
+ VectorAllocatorSizeType
theAVTPointerVectorAllocatorBlockSize = eDefaultAVTPointerVectorBlockSize,
+ VectorAllocatorSizeType
theAVTPartPointerVectorAllocatorBlockSize =
eDefaultAVTPartPointerVectorBlockSize,
+ XalanQNameByValueAllocator::size_type
theXalanQNameByValueAllocatorBlockSize = eDefaultXalanQNameByValueBlockSize,
+ VectorAllocatorSizeType
theXalanQNamePointerVectorAllocatorBlockSize =
eDefaultAVTPartPointerVectorBlockSize);
virtual
~StylesheetConstructionContextDefault();
- // These interfaces are inherited from ExecutionContext...
virtual void
error(
@@ -269,6 +308,13 @@
virtual XPath*
createXPath(
+ const Locator* locator,
+ const XalanDOMChar* str,
+ XalanDOMString::size_type len,
+ const PrefixResolver& resolver);
+
+ virtual XPath*
+ createXPath(
const Locator* locator,
const XalanDOMChar* str,
const PrefixResolver& resolver);
@@ -297,6 +343,12 @@
const Stylesheet& theStylesheet,
const Locator* theLocator);
+ virtual bool
+ isXSLUseAttributeSetsAttribute(
+ const XalanDOMChar* theAttributeName,
+ const Stylesheet& theStylesheet,
+ const Locator* theLocator);
+
virtual int
getElementToken(const XalanDOMString& name) const;
@@ -311,15 +363,61 @@
const XalanDOMChar* theString,
XalanDOMString::size_type theLength =
XalanDOMString::npos);
+ virtual XalanDOMString&
+ getCachedString();
+
+ virtual bool
+ releaseCachedString(XalanDOMString& theString);
+
virtual XalanDOMChar*
- allocateVector(XalanDOMString::size_type theLength);
+ allocateXalanDOMCharVector(XalanDOMString::size_type theLength);
virtual XalanDOMChar*
- allocateVector(
+ allocateXalanDOMCharVector(
const XalanDOMChar* theString,
XalanDOMString::size_type theLength =
XalanDOMString::npos,
bool
fTerminate = true);
+ virtual const AVT*
+ createAVT(
+ const Locator* locator,
+ const XalanDOMChar* name,
+ const XalanDOMChar*
stringedValue,
+ const PrefixResolver& resolver);
+
+ virtual const AVTPart*
+ createAVTPart(
+ const XalanDOMChar* theString,
+ XalanDOMString::size_type theLength =
XalanDOMString::npos);
+
+ virtual const AVTPart*
+ createAVTPart(
+ const Locator* locator,
+ const XalanDOMChar* str,
+ XalanDOMString::size_type len,
+ const PrefixResolver& resolver);
+
+ virtual const AVT**
+ allocateAVTPointerVector(size_type theLength);
+
+ virtual const AVTPart**
+ allocateAVTPartPointerVector(size_type theLength);
+
+ virtual const XalanQName*
+ createXalanQNameByValue(
+ const XalanDOMString& qname,
+ const NamespacesStackType& namespaces,
+ const Locator* locator = 0,
+ bool
fUseDefault = false);
+
+ virtual const XalanQName**
+ tokenizeQNames(
+ size_type& count,
+ const XalanDOMChar* qnameTokens,
+ const NamespacesStackType& namespaces,
+ const Locator* locator = 0,
+ bool
fUseDefault = false);
+
static int
getElementNameToken(const XalanDOMString& name);
@@ -331,23 +429,43 @@
private:
- XSLTEngineImpl& m_processor;
+ XSLTEngineImpl&
m_processor;
- XPathFactory& m_xpathFactory;
+ XPathFactory&
m_xpathFactory;
typedef XalanAutoPtr<XPathProcessor> XPathProcessAutoPtr;
- XPathProcessAutoPtr
m_xpathProcessor;
+ XPathProcessAutoPtr
m_xpathProcessor;
+
+ StylesheetVectorType m_stylesheets;
+
+ XalanDOMStringPool
m_stringPool;
+
+ XalanDOMCharVectorAllocatorType
m_xalanDOMCharVectorAllocator;
+
+ mutable XalanDOMString m_tempBuffer;
+
+ XalanQNameByValue
m_scratchQName;
+
+ XalanDOMStringCache
m_stringCache;
+
+ XalanAVTAllocator
m_avtAllocator;
+
+ XalanAVTPartSimpleAllocator
m_avtPartSimpleAllocator;
+
+ XalanAVTPartXPathAllocator
m_avtPartXPathAllocator;
+
+ XalanAVTPointerVectorAllocatorType
m_avtPointerVectorAllocator;
- StylesheetVectorType m_stylesheets;
+ XalanAVTPartPointerVectorAllocatorType m_avtPartPointerVectorAllocator;
- XalanDOMStringPool m_stringPool;
+ XalanQNameByValueAllocator
m_xalanQNameByValueAllocator;
- XalanDOMCharVectorAllocatorType m_xalanDOMCharVectorAllocator;
+ XalanQNameVectorAllocatorType
m_xalanQNameVectorAllocator;
- mutable XalanDOMString m_tempBuffer;
+ const XalanQNameByReference
m_useAttributeSetsQName;
- XalanQNameByValue
m_spaceAttributeQName;
+ XalanVoidPointerVectorAllocatorType
m_pointerVectorAllocator;
static const XalanQNameByReference s_spaceAttrQName;
1.92 +4 -6 xml-xalan/c/src/XSLT/StylesheetHandler.cpp
Index: StylesheetHandler.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetHandler.cpp,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -r1.91 -r1.92
--- StylesheetHandler.cpp 27 Sep 2002 23:32:23 -0000 1.91
+++ StylesheetHandler.cpp 31 Oct 2002 07:15:56 -0000 1.92
@@ -1190,19 +1190,17 @@
const XalanQName& theVariableName,
const Locator* theLocator)
{
- XalanQNameByValue theLocalVariableName(theVariableName);
-
if (m_inTemplate == false)
{
assert(m_inScopeVariableNamesStack.empty() == true);
- if (m_globalVariableNames.find(theLocalVariableName) !=
m_globalVariableNames.end())
+ if (m_globalVariableNames.find(theVariableName) !=
m_globalVariableNames.end())
{
error("A global variable with this name has already
been declared", theLocator);
}
else
{
- m_globalVariableNames.insert(theLocalVariableName);
+ m_globalVariableNames.insert(theVariableName);
}
}
else
@@ -1216,7 +1214,7 @@
{
QNameSetVectorType::value_type theLocalScope =
*theCurrent;
- if (theLocalScope.find(theLocalVariableName) !=
theLocalScope.end())
+ if (theLocalScope.find(theVariableName) !=
theLocalScope.end())
{
error("A variable with this name has already
been declared in this template", theLocator);
}
@@ -1226,7 +1224,7 @@
assert(theCurrent == theEnd);
- m_inScopeVariableNamesStack.back().insert(theLocalVariableName);
+ m_inScopeVariableNamesStack.back().insert(theVariableName);
}
}
1.36 +5 -4 xml-xalan/c/src/XSLT/StylesheetHandler.hpp
Index: StylesheetHandler.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetHandler.hpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- StylesheetHandler.hpp 24 Sep 2002 05:59:38 -0000 1.35
+++ StylesheetHandler.hpp 31 Oct 2002 07:15:56 -0000 1.36
@@ -113,15 +113,16 @@
typedef set<ElemTemplateElement*,
less<ElemTemplateElement*> >
ElemTemplateSetType;
typedef vector<bool>
BoolStackType;
- typedef set<XalanQNameByValue,
- less<XalanQNameByValue> >
QNameSetType;
+ typedef set<XalanQNameByReference,
+ less<XalanQName> >
QNameSetType;
typedef vector<QNameSetType>
QNameSetVectorType;
#else
typedef std::vector<ElemTemplateElement*> ElemTemplateStackType;
typedef std::vector<ElemTextLiteral*>
ElemTextLiteralStackType;
typedef std::set<ElemTemplateElement*> ElemTemplateSetType;
typedef std::vector<bool>
BoolStackType;
- typedef std::set<XalanQNameByValue> QNameSetType;
+ typedef std::set<XalanQNameByReference,
+ std::less<XalanQName> >
QNameSetType;
typedef std::vector<QNameSetType>
QNameSetVectorType;
#endif
@@ -620,7 +621,7 @@
// PushPopIncludeState...
unsigned long m_locatorsPushed;
- QNameSetType m_globalVariableNames;
+ QNameSetType m_globalVariableNames;
enum { eVariablesStackDefault = 20 };
1.65 +12 -13 xml-xalan/c/src/XSLT/StylesheetRoot.cpp
Index: StylesheetRoot.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetRoot.cpp,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -r1.64 -r1.65
--- StylesheetRoot.cpp 26 Sep 2002 01:38:16 -0000 1.64
+++ StylesheetRoot.cpp 31 Oct 2002 07:15:56 -0000 1.65
@@ -134,7 +134,7 @@
m_resultNameSpaceURL(),
m_outputMethod(FormatterListener::OUTPUT_METHOD_NONE),
m_cdataSectionElems(),
- m_hasCdataSectionElems(false),
+ m_hasCDATASectionElems(false),
m_importStack(),
m_defaultTextRule(0),
m_defaultRule(0),
@@ -176,19 +176,18 @@
m_needToBuildKeysTable = true;
}
+ if (m_cdataSectionElems.size() > 0)
+ {
#if !defined(XALAN_NO_NAMESPACES)
- using std::sort;
- using std::less;
+ using std::sort;
#endif
- sort(
+ sort(
m_cdataSectionElems.begin(),
m_cdataSectionElems.end(),
- less<XalanQName>());
+ pointer_less<XalanQName>());
- if (m_cdataSectionElems.empty() == false)
- {
- m_hasCdataSectionElems = true;
+ m_hasCDATASectionElems = true;
}
}
@@ -542,7 +541,7 @@
StringTokenizer::size_type theTokenCount =
theTokenizer.countTokens();
- m_cdataSectionElems.reserve(theTokenCount);
+ m_cdataSectionElems.reserve(m_cdataSectionElems.size()
+ theTokenCount);
XalanDOMString theToken;
@@ -553,7 +552,7 @@
--theTokenCount;
m_cdataSectionElems.push_back(
- XalanQNameByValue(theToken,
getNamespaces(), theLocator, true));
+
constructionContext.createXalanQNameByValue(theToken, getNamespaces(),
theLocator, true));
}
assert(theTokenizer.hasMoreTokens() == false);
@@ -709,13 +708,13 @@
StylesheetRoot::isCDATASectionElementName(const XalanQName&
theQName) const
{
#if !defined(XALAN_NO_NAMESPACES)
- using std::find;
+ using std::find_if;
#endif
- return find(
+ return find_if(
m_cdataSectionElems.begin(),
m_cdataSectionElems.end(),
- theQName) != m_cdataSectionElems.end() ? true : false;
+ pointer_equals_predicate<XalanQName>(&theQName)) !=
m_cdataSectionElems.end() ? true : false;
}
1.22 +12 -6 xml-xalan/c/src/XSLT/StylesheetRoot.hpp
Index: StylesheetRoot.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetRoot.hpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- StylesheetRoot.hpp 24 Sep 2002 06:57:42 -0000 1.21
+++ StylesheetRoot.hpp 31 Oct 2002 07:15:56 -0000 1.22
@@ -90,6 +90,12 @@
{
public:
+#if defined(XALAN_NO_NAMESPACES)
+ typedef vector<const XalanQName*> XalanQNameVectorType;
+#else
+ typedef std::vector<const XalanQName*> XalanQNameVectorType;
+#endif
+
/**
* Construct a Stylesheet from a Document.
*
@@ -405,10 +411,10 @@
bool
hasCDATASectionElements() const
{
- assert(m_hasCdataSectionElems == false &&
m_cdataSectionElems.empty() == true ||
- m_hasCdataSectionElems == true &&
m_cdataSectionElems.empty() == false);
+ assert(m_hasCDATASectionElems == false &&
m_cdataSectionElems.size() == 0 ||
+ m_hasCDATASectionElems == true &&
m_cdataSectionElems.size() != 0);
- return m_hasCdataSectionElems;
+ return m_hasCDATASectionElems;
}
/**
@@ -469,12 +475,12 @@
FormatterListener::eFormat m_outputMethod;
/**
- * List of qnames that specifies elements that should be formatted
+ * Vector of qnames that specifies elements that should be formatted
* as CDATA.
*/
- QNameVectorType m_cdataSectionElems;
+ XalanQNameVectorType m_cdataSectionElems;
- bool m_hasCdataSectionElems;
+ bool m_hasCDATASectionElems;
/**
* A stack of who's importing whom is needed in order to detect
1.161 +31 -20 xml-xalan/c/src/XSLT/XSLTEngineImpl.cpp
Index: XSLTEngineImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/XSLTEngineImpl.cpp,v
retrieving revision 1.160
retrieving revision 1.161
diff -u -r1.160 -r1.161
--- XSLTEngineImpl.cpp 4 Oct 2002 08:30:30 -0000 1.160
+++ XSLTEngineImpl.cpp 31 Oct 2002 07:15:56 -0000 1.161
@@ -196,7 +196,8 @@
m_scratchString(),
m_attributeNamesVisited(),
m_hasStripOrPreserveSpace(false),
- m_hasCDATASectionElements(false)
+ m_hasCDATASectionElements(false),
+ m_xpathConstructionContext()
{
m_outputContextStack.pushContext();
}
@@ -228,6 +229,8 @@
m_hasStripOrPreserveSpace = false;
m_hasCDATASectionElements = false;
+
+ m_xpathConstructionContext.reset();
}
@@ -2970,19 +2973,21 @@
{
assert(executionContext.getPrefixResolver() != 0);
- XPath* const theXPath = m_xpathFactory.create();
+ XPath* const theXPath = m_xpathFactory.create();
- XPathGuard theGuard(m_xpathFactory,
- theXPath);
+ const XPathGuard theGuard(m_xpathFactory, theXPath);
- m_xpathProcessor->initXPath(*theXPath,
- str,
-
*executionContext.getPrefixResolver(),
-
getLocatorFromStack());
-
- return theXPath->execute(executionContext.getCurrentNode(),
-
*executionContext.getPrefixResolver(),
- executionContext);
+ m_xpathProcessor->initXPath(
+ *theXPath,
+ m_xpathConstructionContext,
+ str,
+ *executionContext.getPrefixResolver(),
+ getLocatorFromStack());
+
+ return theXPath->execute(
+ executionContext.getCurrentNode(),
+ *executionContext.getPrefixResolver(),
+ executionContext);
}
@@ -2994,15 +2999,16 @@
const PrefixResolver& prefixResolver,
XPathExecutionContext& executionContext)
{
- XPath* const theXPath = m_xpathFactory.create();
+ XPath* const theXPath = m_xpathFactory.create();
- XPathGuard theGuard(m_xpathFactory,
- theXPath);
+ const XPathGuard theGuard(m_xpathFactory, theXPath);
- m_xpathProcessor->initXPath(*theXPath,
- str,
- prefixResolver,
-
getLocatorFromStack());
+ m_xpathProcessor->initXPath(
+ *theXPath,
+ m_xpathConstructionContext,
+ str,
+ prefixResolver,
+ getLocatorFromStack());
return theXPath->execute(contextNode, prefixResolver, executionContext);
}
@@ -3036,7 +3042,12 @@
{
XPath* const xpath = m_xpathFactory.create();
- m_xpathProcessor->initMatchPattern(*xpath, str, resolver,
getLocatorFromStack());
+ m_xpathProcessor->initMatchPattern(
+ *xpath,
+ m_xpathConstructionContext,
+ str,
+ resolver,
+ getLocatorFromStack());
return xpath;
}
1.100 +6 -0 xml-xalan/c/src/XSLT/XSLTEngineImpl.hpp
Index: XSLTEngineImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/XSLTEngineImpl.hpp,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -r1.99 -r1.100
--- XSLTEngineImpl.hpp 11 Oct 2002 02:01:37 -0000 1.99
+++ XSLTEngineImpl.hpp 31 Oct 2002 07:15:56 -0000 1.100
@@ -106,6 +106,10 @@
+#include <XPath/XPathConstructionContextDefault.hpp>
+
+
+
#include "KeyDeclaration.hpp"
#include "OutputContextStack.hpp"
#include "ProblemListenerDefault.hpp"
@@ -1738,6 +1742,8 @@
bool
m_hasStripOrPreserveSpace;
bool
m_hasCDATASectionElements;
+
+ XPathConstructionContextDefault m_xpathConstructionContext;
static void
installFunctions();
1.1 xml-xalan/c/src/XSLT/XalanAVTAllocator.cpp
Index: XalanAVTAllocator.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
// Class header file.
#include "XalanAVTAllocator.hpp"
XalanAVTAllocator::XalanAVTAllocator(size_type theBlockCount) :
m_allocator(theBlockCount)
{
}
XalanAVTAllocator::~XalanAVTAllocator()
{
}
XalanAVTAllocator::data_type*
XalanAVTAllocator::create(
StylesheetConstructionContext& constructionContext,
const Locator* locator,
const XalanDOMChar* name,
const XalanDOMChar*
stringedValue,
const PrefixResolver& resolver)
{
data_type* const theBlock = m_allocator.allocateBlock();
assert(theBlock != 0);
data_type* const theResult =
new(theBlock) data_type(
constructionContext,
locator,
name,
stringedValue,
resolver);
m_allocator.commitAllocation(theBlock);
return theResult;
}
1.1 xml-xalan/c/src/XSLT/XalanAVTAllocator.hpp
Index: XalanAVTAllocator.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(XALANAVTALLOCATOR_INCLUDE_GUARD_12455133)
#define XALANAVTALLOCATOR_INCLUDE_GUARD_12455133
// Base include file. Must be first.
#include <XSLT/XSLTDefinitions.hpp>
#include <XSLT/AVT.hpp>
#include <PlatformSupport/ArenaAllocator.hpp>
class XALAN_XSLT_EXPORT XalanAVTAllocator
{
public:
typedef AVT
data_type;
#if defined(XALAN_NO_DEFAULT_TEMPLATE_ARGUMENTS)
typedef ArenaBlock<data_type> ArenaBlockType;
typedef ArenaAllocator<data_type,
ArenaBlockType>
ArenaAllocatorType;
#else
typedef ArenaAllocator<data_type>
ArenaAllocatorType;
#endif
typedef ArenaAllocatorType::size_type size_type;
/**
* Construct an instance that will allocate blocks of the specified
size.
*
* @param theBlockSize The block size.
*/
XalanAVTAllocator(size_type theBlockCount);
~XalanAVTAllocator();
/**
* Create an instance.
*
* @param constructionContext context for construction of AVT
* @param locator the Locator for the AVT. May be null.
* @param name name of AVT
* @param stringedValue string value to parse
* @param resolvervresolver for namespace resolution
*
* @return A pointer to the new instance.
*/
data_type*
create(
StylesheetConstructionContext& constructionContext,
const Locator* locator,
const XalanDOMChar* name,
const XalanDOMChar*
stringedValue,
const PrefixResolver& resolver);
/**
* Determine if an object is owned by the allocator...
*/
bool
ownsObject(const data_type* theObject)
{
return m_allocator.ownsObject(theObject);
}
/**
* Delete all objects from the allocator.
*/
void
reset()
{
m_allocator.reset();
}
/**
* Get the number of ArenaBlocks currently allocated.
*
* @return The number of blocks.
*/
size_type
getBlockCount() const
{
return m_allocator.getBlockCount();
}
/**
* Get size of an ArenaBlock, that is, the number
* of objects in each block.
*
* @return The size of the block
*/
size_type
getBlockSize() const
{
return m_allocator.getBlockSize();
}
private:
// Not implemented...
XalanAVTAllocator(const XalanAVTAllocator&);
XalanAVTAllocator&
operator=(const XalanAVTAllocator&);
// Data members...
ArenaAllocatorType m_allocator;
};
#endif // XALANAVTALLOCATOR_INCLUDE_GUARD_12455133
1.1 xml-xalan/c/src/XSLT/XalanAVTPartSimpleAllocator.cpp
Index: XalanAVTPartSimpleAllocator.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
// Class header file.
#include "XalanAVTPartSimpleAllocator.hpp"
XalanAVTPartSimpleAllocator::XalanAVTPartSimpleAllocator(size_type
theBlockCount) :
m_allocator(theBlockCount)
{
}
XalanAVTPartSimpleAllocator::~XalanAVTPartSimpleAllocator()
{
}
XalanAVTPartSimpleAllocator::data_type*
XalanAVTPartSimpleAllocator::create(
StylesheetConstructionContext& constructionContext,
const XalanDOMChar* val,
XalanDOMString::size_type len)
{
data_type* const theBlock = m_allocator.allocateBlock();
assert(theBlock != 0);
data_type* const theResult =
new(theBlock) data_type(constructionContext, val, len);
m_allocator.commitAllocation(theBlock);
return theResult;
}
1.1 xml-xalan/c/src/XSLT/XalanAVTPartSimpleAllocator.hpp
Index: XalanAVTPartSimpleAllocator.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(XALANAVTPARTSIMPLEALLOCATOR_INCLUDE_GUARD_12455133)
#define XALANAVTPARTSIMPLEALLOCATOR_INCLUDE_GUARD_12455133
// Base include file. Must be first.
#include <XSLT/XSLTDefinitions.hpp>
#include <XSLT/AVTPartSimple.hpp>
#include <PlatformSupport/ArenaAllocator.hpp>
class XALAN_XSLT_EXPORT XalanAVTPartSimpleAllocator
{
public:
typedef AVTPartSimple
data_type;
#if defined(XALAN_NO_DEFAULT_TEMPLATE_ARGUMENTS)
typedef ArenaBlock<data_type> ArenaBlockType;
typedef ArenaAllocator<data_type,
ArenaBlockType>
ArenaAllocatorType;
#else
typedef ArenaAllocator<data_type>
ArenaAllocatorType;
#endif
typedef ArenaAllocatorType::size_type size_type;
/**
* Construct an instance that will allocate blocks of the specified
size.
*
* @param theBlockSize The block size.
*/
XalanAVTPartSimpleAllocator(size_type theBlockCount);
~XalanAVTPartSimpleAllocator();
/**
* Create an instance.
*
* @param constructionContext context when object constructed
* @param val A pure string section of an AVT
* @param len The length of val
*
* @return A pointer to the new instance.
*/
data_type*
create(
StylesheetConstructionContext& constructionContext,
const XalanDOMChar* val,
XalanDOMString::size_type len);
/**
* Determine if an object is owned by the allocator...
*/
bool
ownsObject(const data_type* theObject)
{
return m_allocator.ownsObject(theObject);
}
/**
* Delete all objects from the allocator.
*/
void
reset()
{
m_allocator.reset();
}
/**
* Get the number of ArenaBlocks currently allocated.
*
* @return The number of blocks.
*/
size_type
getBlockCount() const
{
return m_allocator.getBlockCount();
}
/**
* Get size of an ArenaBlock, that is, the number
* of objects in each block.
*
* @return The size of the block
*/
size_type
getBlockSize() const
{
return m_allocator.getBlockSize();
}
private:
// Not implemented...
XalanAVTPartSimpleAllocator(const XalanAVTPartSimpleAllocator&);
XalanAVTPartSimpleAllocator&
operator=(const XalanAVTPartSimpleAllocator&);
// Data members...
ArenaAllocatorType m_allocator;
};
#endif // XALANAVTPARTSIMPLEALLOCATOR_INCLUDE_GUARD_12455133
1.1 xml-xalan/c/src/XSLT/XalanAVTPartXPathAllocator.cpp
Index: XalanAVTPartXPathAllocator.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
// Class header file.
#include "XalanAVTPartXPathAllocator.hpp"
XalanAVTPartXPathAllocator::XalanAVTPartXPathAllocator(size_type
theBlockCount) :
m_allocator(theBlockCount)
{
}
XalanAVTPartXPathAllocator::~XalanAVTPartXPathAllocator()
{
}
XalanAVTPartXPathAllocator::data_type*
XalanAVTPartXPathAllocator::create(const XPath* xpath)
{
data_type* const theBlock = m_allocator.allocateBlock();
assert(theBlock != 0);
data_type* const theResult =
new(theBlock) data_type(xpath);
m_allocator.commitAllocation(theBlock);
return theResult;
}
1.1 xml-xalan/c/src/XSLT/XalanAVTPartXPathAllocator.hpp
Index: XalanAVTPartXPathAllocator.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(XALANAVTPARTXPATHALLOCATOR_INCLUDE_GUARD_12455133)
#define XALANAVTPARTXPATHALLOCATOR_INCLUDE_GUARD_12455133
// Base include file. Must be first.
#include <XSLT/XSLTDefinitions.hpp>
#include <XSLT/AVTPartXPath.hpp>
#include <PlatformSupport/ArenaAllocator.hpp>
class XALAN_XSLT_EXPORT XalanAVTPartXPathAllocator
{
public:
typedef AVTPartXPath
data_type;
#if defined(XALAN_NO_DEFAULT_TEMPLATE_ARGUMENTS)
typedef ArenaBlock<data_type> ArenaBlockType;
typedef ArenaAllocator<data_type,
ArenaBlockType>
ArenaAllocatorType;
#else
typedef ArenaAllocator<data_type>
ArenaAllocatorType;
#endif
typedef ArenaAllocatorType::size_type size_type;
/**
* Construct an instance that will allocate blocks of the specified
size.
*
* @param theBlockSize The block size.
*/
XalanAVTPartXPathAllocator(size_type theBlockCount);
~XalanAVTPartXPathAllocator();
/**
* Create an instance.
*
* @param xpath XPath to evaluate
*
* @return A pointer to the new instance.
*/
data_type*
create(const XPath* xpath);
/**
* Determine if an object is owned by the allocator...
*/
bool
ownsObject(const data_type* theObject)
{
return m_allocator.ownsObject(theObject);
}
/**
* Delete all objects from the allocator.
*/
void
reset()
{
m_allocator.reset();
}
/**
* Get the number of ArenaBlocks currently allocated.
*
* @return The number of blocks.
*/
size_type
getBlockCount() const
{
return m_allocator.getBlockCount();
}
/**
* Get size of an ArenaBlock, that is, the number
* of objects in each block.
*
* @return The size of the block
*/
size_type
getBlockSize() const
{
return m_allocator.getBlockSize();
}
private:
// Not implemented...
XalanAVTPartXPathAllocator(const XalanAVTPartXPathAllocator&);
XalanAVTPartXPathAllocator&
operator=(const XalanAVTPartXPathAllocator&);
// Data members...
ArenaAllocatorType m_allocator;
};
#endif // XALANAVTPARTXPATHALLOCATOR_INCLUDE_GUARD_12455133
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]