[Libreoffice-commits] core.git: formula/source include/formula sc/inc sc/qa sc/source

Jochen Nitschke j.nitschke+logerrit at ok.de
Mon Apr 3 06:34:16 UTC 2017


 formula/source/core/api/FormulaCompiler.cxx |    2 +-
 include/formula/token.hxx                   |   10 +---------
 sc/inc/token.hxx                            |    2 +-
 sc/qa/unit/ucalc_formula.cxx                |   10 +++++-----
 sc/qa/unit/ucalc_sharedformula.cxx          |    2 +-
 sc/source/core/tool/interpr4.cxx            |    5 ++---
 sc/source/filter/excel/xeformula.cxx        |    2 +-
 7 files changed, 12 insertions(+), 21 deletions(-)

New commits:
commit b7b2c95fbc376ecea60b91e3e04fd52428258137
Author: Jochen Nitschke <j.nitschke+logerrit at ok.de>
Date:   Sat Apr 1 10:05:30 2017 +0200

    remove hack for non DBG_UTIL builds
    
    always use a 8bit enum for StackVar
    
    correct StackVar types for opcode opSep and opClose in unit test
    and test them.
    
    Change-Id: I89fac97d791eb12667ce5218ff31e798c8711e10
    Reviewed-on: https://gerrit.libreoffice.org/36000
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx
index b70af7dc3152..09e355302105 100644
--- a/formula/source/core/api/FormulaCompiler.cxx
+++ b/formula/source/core/api/FormulaCompiler.cxx
@@ -318,7 +318,7 @@ bool isPotentialRangeType( FormulaToken* pToken, bool bRPN, bool bRight )
             return true;
         default:
             // Separators are not part of RPN and right opcodes need to be
-            // other StackVarEnum types or functions and thus svByte.
+            // other StackVar types or functions and thus svByte.
             return !bRPN && !bRight && isPotentialRangeLeftOp( pToken->GetOpCode());
     }
 }
diff --git a/include/formula/token.hxx b/include/formula/token.hxx
index 2de988e551b6..19d1b1bb5bdf 100644
--- a/include/formula/token.hxx
+++ b/include/formula/token.hxx
@@ -44,7 +44,7 @@ enum class FormulaError : sal_uInt16;
 namespace formula
 {
 
-enum StackVarEnum
+enum StackVar : sal_uInt8
 {
     svByte,
     svDouble,
@@ -80,14 +80,6 @@ enum StackVarEnum
     svUnknown                           // unknown StackType
 };
 
-#ifndef DBG_UTIL
-// save memory since compilers tend to int an enum
-typedef sal_uInt8 StackVar;
-#else
-// have enum names in debugger
-typedef StackVarEnum StackVar;
-#endif
-
 // Only to be used for debugging output. No guarantee of stability of the
 // return value.
 inline std::string StackVarEnumToString(StackVar const e)
diff --git a/sc/inc/token.hxx b/sc/inc/token.hxx
index 147bba46730d..7c082010ea93 100644
--- a/sc/inc/token.hxx
+++ b/sc/inc/token.hxx
@@ -320,7 +320,7 @@ public:
                                     {
                                         return xUpperLeft ?
                                             xUpperLeft->GetType() :
-                                            static_cast<formula::StackVar>(formula::svUnknown);
+                                            formula::svUnknown;
                                     }
     const formula::FormulaConstTokenRef& GetUpperLeftToken() const { return xUpperLeft; }
     void Assign( const ScMatrixCellResultToken & r );
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index a10f552933e6..81e2f2121185 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -1068,11 +1068,11 @@ void Test::testFormulaCompilerJumpReordering()
         TokenCheck aCheckRPN[] =
         {
             { ocPush,  svSingleRef },
-            { ocIf,    static_cast<formula::StackVar>(0) },
+            { ocIf,    svUnknown   }, // type is context dependent, don't test it
             { ocPush,  svDouble    },
-            { ocSep,   static_cast<formula::StackVar>(0) },
+            { ocSep,   svSep       },
             { ocPush,  svString    },
-            { ocClose, static_cast<formula::StackVar>(0) },
+            { ocClose, svSep       },
         };
 
         sal_uInt16 nLen = pCode->GetCodeLen();
@@ -1083,7 +1083,7 @@ void Test::testFormulaCompilerJumpReordering()
         {
             const FormulaToken* p = ppTokens[i];
             CPPUNIT_ASSERT_EQUAL(aCheckRPN[i].meOp, p->GetOpCode());
-            if (aCheckRPN[i].meOp == ocPush)
+            if (aCheckRPN[i].meOp != ocIf )
                 CPPUNIT_ASSERT_EQUAL(static_cast<int>(aCheckRPN[i].meType), static_cast<int>(p->GetType()));
         }
 
@@ -1099,7 +1099,7 @@ void Test::testFormulaCompilerJumpReordering()
             { ocPush,  svSingleRef },
             { ocPush,  svDouble    },
             { ocPush,  svString    },
-            { ocIf,    static_cast<formula::StackVar>(0) },
+            { ocIf,    svUnknown   }, // type is context dependent, don't test it
         };
 
         nLen = pCode->GetCodeLen();
diff --git a/sc/qa/unit/ucalc_sharedformula.cxx b/sc/qa/unit/ucalc_sharedformula.cxx
index ecd253d86b66..1659c8b46166 100644
--- a/sc/qa/unit/ucalc_sharedformula.cxx
+++ b/sc/qa/unit/ucalc_sharedformula.cxx
@@ -1005,7 +1005,7 @@ void Test::testSharedFormulasDeleteColumns()
     const ScTokenArray* pCode = pFC->GetCode();
     CPPUNIT_ASSERT(pCode && pCode->GetLen() == 1);
     const FormulaToken* pToken = pCode->GetArray()[0];
-    CPPUNIT_ASSERT_EQUAL(svSingleRef, static_cast<StackVarEnum>(pToken->GetType()));
+    CPPUNIT_ASSERT_EQUAL(svSingleRef, pToken->GetType());
     const ScSingleRefData* pSRef = pToken->GetSingleRef();
     CPPUNIT_ASSERT(pSRef->IsColDeleted());
     CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(0), pSRef->toAbs(ScAddress(1,0,0)).Row());
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 1c64a8556ffb..c044db1120cc 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -2716,7 +2716,7 @@ void ScInterpreter::ScExternal()
                 continue;   // while
             }
 
-            sal_uInt8 nStackType = sal::static_int_cast<sal_uInt8>( GetStackType() );
+            StackVar nStackType = GetStackType();
             ScAddInArgumentType eType = aCall.GetArgType( nPar );
             switch (eType)
             {
@@ -3204,8 +3204,7 @@ void ScInterpreter::ScMacro()
     for( short i = nParamCount; i && bOk ; i-- )
     {
         SbxVariable* pPar = refPar->Get( (sal_uInt16) i );
-        sal_uInt8 nStackType = sal::static_int_cast<sal_uInt8>( GetStackType() );
-        switch( nStackType )
+        switch( GetStackType() )
         {
             case svDouble:
                 pPar->PutDouble( GetDouble() );
diff --git a/sc/source/filter/excel/xeformula.cxx b/sc/source/filter/excel/xeformula.cxx
index 97e1907df15b..1fa791647a30 100644
--- a/sc/source/filter/excel/xeformula.cxx
+++ b/sc/source/filter/excel/xeformula.cxx
@@ -59,7 +59,7 @@ struct XclExpScToken
 
     explicit     XclExpScToken() : mpScToken( nullptr ), mnSpaces( 0 ) {}
     bool         Is() const { return mpScToken != nullptr; }
-    StackVar     GetType() const { return mpScToken ? mpScToken->GetType() : static_cast< StackVar >( svUnknown ); }
+    StackVar     GetType() const { return mpScToken ? mpScToken->GetType() : svUnknown; }
     OpCode       GetOpCode() const { return mpScToken ? mpScToken->GetOpCode() : ocNone; }
 };
 


More information about the Libreoffice-commits mailing list