summaryrefslogtreecommitdiff
path: root/sax
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-07-17 23:27:20 +0200
committerMichael Stahl <mstahl@redhat.com>2015-07-18 22:51:47 +0200
commit2842c5cfb99d41b36dba52db01ca6cd37d2ef4b0 (patch)
treec74e2e8a37f57d6610684d9abbbf21386bd24194 /sax
parent7352a7c17875e5adcc4226c45f4a03e11c44ff49 (diff)
sax, sw: try to make that maMarkStack easier to understand
In DocxAttributeOutput it's not at all obvious which mark() is supposed to be ended by which mergeTopMarks(), so add an extra parameter to the FastSaxSerializer functions and verify with an assertion that a LIFO order is maintained. Change-Id: I5a421e2fb11f15343147417fe0b9b23642c70721
Diffstat (limited to 'sax')
-rw-r--r--sax/source/tools/fastserializer.cxx14
-rw-r--r--sax/source/tools/fastserializer.hxx22
-rw-r--r--sax/source/tools/fshelper.cxx10
3 files changed, 29 insertions, 17 deletions
diff --git a/sax/source/tools/fastserializer.cxx b/sax/source/tools/fastserializer.cxx
index 2d4a2e1ff5bc..66466e9b6b90 100644
--- a/sax/source/tools/fastserializer.cxx
+++ b/sax/source/tools/fastserializer.cxx
@@ -330,17 +330,17 @@ namespace sax_fastparser {
}
}
- void FastSaxSerializer::mark( const Int32Sequence& aOrder )
+ void FastSaxSerializer::mark(sal_Int32 const nTag, const Int32Sequence& rOrder)
{
- if ( aOrder.hasElements() )
+ if (rOrder.hasElements())
{
- boost::shared_ptr< ForMerge > pSort( new ForSort( aOrder ) );
+ boost::shared_ptr< ForMerge > pSort( new ForSort(nTag, rOrder) );
maMarkStack.push( pSort );
maCachedOutputStream.setOutput( pSort );
}
else
{
- boost::shared_ptr< ForMerge > pMerge( new ForMerge( ) );
+ boost::shared_ptr< ForMerge > pMerge( new ForMerge(nTag) );
maMarkStack.push( pMerge );
maCachedOutputStream.setOutput( pMerge );
}
@@ -401,12 +401,16 @@ namespace sax_fastparser {
}
#endif
- void FastSaxSerializer::mergeTopMarks( sax_fastparser::MergeMarksEnum eMergeType )
+ void FastSaxSerializer::mergeTopMarks(
+ sal_Int32 const nTag, sax_fastparser::MergeMarksEnum const eMergeType)
{
SAL_WARN_IF(mbMarkStackEmpty, "sax", "Empty mark stack - nothing to merge");
+ assert(!mbMarkStackEmpty); // should never happen
if ( mbMarkStackEmpty )
return;
+ assert(maMarkStack.top()->m_Tag == nTag && "mark/merge tag mismatch!");
+ (void) nTag;
#ifdef DBG_UTIL
if (dynamic_cast<ForSort*>(maMarkStack.top().get()))
{
diff --git a/sax/source/tools/fastserializer.hxx b/sax/source/tools/fastserializer.hxx
index 4dc786b7a712..5fcbef51b6df 100644
--- a/sax/source/tools/fastserializer.hxx
+++ b/sax/source/tools/fastserializer.hxx
@@ -127,8 +127,10 @@ public:
p, r, mark(), t, [text], /t, mark(), rPr, [something], /rPr,
mergeTopMarks( MERGE_MARKS_PREPEND ), mergeTopMarks( MERGE_MARKS_APPEND ), /r, /p
and you are done.
+
+ @param nTag debugging aid to ensure mark and merge match in LIFO order
*/
- void mark( const Int32Sequence& aOrder = Int32Sequence() );
+ void mark(sal_Int32 nTag, const Int32Sequence& rOrder = Int32Sequence());
/** Merge 2 topmost marks.
@@ -143,9 +145,12 @@ public:
When the MERGE_MARKS_POSTPONE is specified, the merge happens just
before the next merge.
+ @param nTag debugging aid to ensure mark and merge match in LIFO order
+
@see mark()
*/
- void mergeTopMarks( sax_fastparser::MergeMarksEnum eMergeType = sax_fastparser::MERGE_MARKS_APPEND );
+ void mergeTopMarks(sal_Int32 nTag,
+ sax_fastparser::MergeMarksEnum eMergeType = sax_fastparser::MERGE_MARKS_APPEND);
private:
/** Helper class to cache data and write in chunks to XOutputStream or ForMerge::append.
@@ -161,6 +166,7 @@ private:
Int8Sequence maPostponed;
public:
+ sal_Int32 const m_Tag;
#ifdef DBG_UTIL
// pending close tags, followed by pending open tags
::std::deque<sal_Int32> m_DebugEndedElements;
@@ -170,7 +176,7 @@ private:
::std::deque<sal_Int32> m_DebugPostponedStartedElements;
#endif
- ForMerge() : maData(), maPostponed() {}
+ ForMerge(sal_Int32 const nTag) : m_Tag(nTag) {}
virtual ~ForMerge() {}
virtual void setCurrentElement( ::sal_Int32 /*nToken*/ ) {}
@@ -196,11 +202,11 @@ private:
Int32Sequence maOrder;
public:
- ForSort( const Int32Sequence& aOrder ) :
- ForMerge(),
- maData(),
- mnCurrentElement( 0 ),
- maOrder( aOrder ) {}
+ ForSort(sal_Int32 const nTag, const Int32Sequence& rOrder)
+ : ForMerge(nTag)
+ , mnCurrentElement( 0 )
+ , maOrder( rOrder )
+ {}
void setCurrentElement( ::sal_Int32 nToken ) SAL_OVERRIDE;
diff --git a/sax/source/tools/fshelper.cxx b/sax/source/tools/fshelper.cxx
index 438aef75c48a..46d87644d471 100644
--- a/sax/source/tools/fshelper.cxx
+++ b/sax/source/tools/fshelper.cxx
@@ -153,14 +153,16 @@ FastSerializerHelper* FastSerializerHelper::writeId(sal_Int32 tokenId)
return mpSerializer->getOutputStream();
}
-void FastSerializerHelper::mark( const Sequence< sal_Int32 >& aOrder )
+void FastSerializerHelper::mark(
+ sal_Int32 const nTag, const Sequence<sal_Int32>& rOrder)
{
- mpSerializer->mark( aOrder );
+ mpSerializer->mark(nTag, rOrder);
}
-void FastSerializerHelper::mergeTopMarks( MergeMarksEnum eMergeType )
+void FastSerializerHelper::mergeTopMarks(
+ sal_Int32 const nTag, MergeMarksEnum const eMergeType)
{
- mpSerializer->mergeTopMarks( eMergeType );
+ mpSerializer->mergeTopMarks(nTag, eMergeType);
}
FastAttributeList * FastSerializerHelper::createAttrList()