[Libreoffice-commits] .: formula/inc formula/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Tue Dec 21 14:43:37 PST 2010
formula/inc/formula/FormulaCompiler.hxx | 2 +-
formula/inc/formula/token.hxx | 18 ++++++++++++++----
formula/source/core/api/FormulaCompiler.cxx | 10 +++++-----
formula/source/core/api/token.cxx | 2 +-
4 files changed, 21 insertions(+), 11 deletions(-)
New commits:
commit f2689f41bd9c2b4825f9353052d5313551463097
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Tue Dec 21 17:41:33 2010 -0500
Implemented FormulaTokneRef using boost::intrusive_ptr.
diff --git a/formula/inc/formula/FormulaCompiler.hxx b/formula/inc/formula/FormulaCompiler.hxx
index 29fa908..75a00f3 100644
--- a/formula/inc/formula/FormulaCompiler.hxx
+++ b/formula/inc/formula/FormulaCompiler.hxx
@@ -331,7 +331,7 @@ private:
static inline void ForceArrayOperator( FormulaTokenRef& rCurr, const FormulaTokenRef& rPrev )
{
- if ( rPrev.Is() && rPrev->HasForceArray() &&
+ if ( rPrev && rPrev->HasForceArray() &&
rCurr->GetType() == svByte && rCurr->GetOpCode() != ocPush
&& !rCurr->HasForceArray() )
rCurr->SetForceArray( true);
diff --git a/formula/inc/formula/token.hxx b/formula/inc/formula/token.hxx
index be91788..8937f84 100644
--- a/formula/inc/formula/token.hxx
+++ b/formula/inc/formula/token.hxx
@@ -33,11 +33,12 @@
#include <string.h>
#include <vector>
#include "formula/opcode.hxx"
-#include "formula/intruref.hxx"
#include <tools/mempool.hxx>
#include "formula/IFunctionDescription.hxx"
#include "formula/formuladllapi.h"
+#include <boost/intrusive_ptr.hpp>
+
namespace formula
{
@@ -85,9 +86,8 @@ typedef StackVarEnum StackVar;
class FormulaToken;
-typedef SimpleIntrusiveReference< class FormulaToken > FormulaTokenRef;
-typedef SimpleIntrusiveReference< const class FormulaToken > FormulaConstTokenRef;
-
+typedef ::boost::intrusive_ptr<FormulaToken> FormulaTokenRef;
+typedef ::boost::intrusive_ptr<const FormulaToken> FormulaConstTokenRef;
class FORMULA_DLLPUBLIC FormulaToken : public IFormulaToken
{
@@ -179,6 +179,16 @@ public:
{ return GetStrLenBytes( rStr.Len() ); }
};
+inline void intrusive_ptr_add_ref(const FormulaToken* p)
+{
+ p->IncRef();
+}
+
+inline void intrusive_ptr_release(const FormulaToken* p)
+{
+ p->DecRef();
+}
+
class FORMULA_DLLPUBLIC FormulaByteToken : public FormulaToken
{
private:
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx
index 76b9bba..d1c8cc1 100644
--- a/formula/source/core/api/FormulaCompiler.cxx
+++ b/formula/source/core/api/FormulaCompiler.cxx
@@ -859,11 +859,11 @@ BOOL FormulaCompiler::GetToken()
if ( nWasColRowName )
nWasColRowName++;
if ( bAutoCorrect && !pStack )
- CreateStringFromToken( aCorrectedFormula, pToken, FALSE );
+ CreateStringFromToken( aCorrectedFormula, pToken.get(), FALSE );
pToken = pArr->Next();
}
if ( bAutoCorrect && !pStack && pToken )
- CreateStringFromToken( aCorrectedSymbol, pToken, FALSE );
+ CreateStringFromToken( aCorrectedSymbol, pToken.get(), FALSE );
if( !pToken )
{
if( pStack )
@@ -1401,7 +1401,7 @@ bool FormulaCompiler::MergeRangeReference(FormulaToken * * const pCode1, Formula
p->IncRef();
p1->DecRef();
p2->DecRef();
- *pCode1 = p;
+ *pCode1 = p.get();
--pCode, --pc;
pArr->nRefs--;
@@ -1840,7 +1840,7 @@ void FormulaCompiler::PutCode( FormulaTokenRef& p )
{
p = new FormulaByteToken( ocStop );
p->IncRef();
- *pCode++ = p;
+ *pCode++ = p.get();
++pc;
}
SetError(errCodeOverflow);
@@ -1850,7 +1850,7 @@ void FormulaCompiler::PutCode( FormulaTokenRef& p )
return;
ForceArrayOperator( p, pCurrentFactorToken);
p->IncRef();
- *pCode++ = p;
+ *pCode++ = p.get();
pc++;
}
diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx
index 8d9a5f8..edf3d5d 100644
--- a/formula/source/core/api/token.cxx
+++ b/formula/source/core/api/token.cxx
@@ -263,7 +263,7 @@ BOOL FormulaByteToken::operator==( const FormulaToken& r ) const
}
-FormulaToken* FormulaFAPToken::GetFAPOrigToken() const { return pOrigToken; }
+FormulaToken* FormulaFAPToken::GetFAPOrigToken() const { return pOrigToken.get(); }
BOOL FormulaFAPToken::operator==( const FormulaToken& r ) const
{
return FormulaByteToken::operator==( r ) && pOrigToken == r.GetFAPOrigToken();
More information about the Libreoffice-commits
mailing list