[Libreoffice-commits] core.git: basic/source include/basic

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Tue Oct 27 10:23:31 UTC 2020


 basic/source/sbx/sbxvalue.cxx |   34 +++++++---------------------------
 include/basic/sbxvar.hxx      |   33 ++++++++++++++++++---------------
 2 files changed, 25 insertions(+), 42 deletions(-)

New commits:
commit 94044b8981b9fd861c28c0bf2537b29a8461e0b5
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Tue Oct 27 11:15:54 2020 +0300
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Tue Oct 27 11:22:46 2020 +0100

    Replace these macro-based implementations with normal C++
    
    Change-Id: Ibb227a0f9e7178ea388e720874ec31a178c2aab0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104859
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx
index 74b2fcd23d98..fb8f8518573e 100644
--- a/basic/source/sbx/sbxvalue.cxx
+++ b/basic/source/sbx/sbxvalue.cxx
@@ -352,6 +352,13 @@ bool SbxValue::Get( SbxValues& rRes ) const
     return bRes;
 }
 
+SbxValues SbxValue::Get(SbxDataType t) const
+{
+    SbxValues aRes(t);
+    Get(aRes);
+    return aRes;
+}
+
 const OUString& SbxValue::GetCoreString() const
 {
     SbxValues aRes;
@@ -379,33 +386,6 @@ OUString SbxValue::GetOUString() const
     return aResult;
 }
 
-bool SbxValue::GetBool() const
-{
-    SbxValues aRes;
-    aRes.eType = SbxBOOL;
-    Get( aRes );
-    return aRes.nUShort != 0;
-}
-
-#define GET( g, e, t, m ) \
-t SbxValue::g() const { SbxValues aRes(e); Get( aRes ); return aRes.m; }
-
-GET( GetByte,     SbxBYTE,       sal_uInt8,     nByte )
-GET( GetChar,     SbxCHAR,       sal_Unicode,   nChar )
-GET( GetCurrency, SbxCURRENCY,   sal_Int64,     nInt64 )
-GET( GetDate,     SbxDATE,       double,        nDouble )
-GET( GetDouble,   SbxDOUBLE,     double,        nDouble )
-GET( GetInteger,  SbxINTEGER,    sal_Int16,     nInteger )
-GET( GetLong,     SbxLONG,       sal_Int32,     nLong )
-GET( GetObject,   SbxOBJECT,     SbxBase*,      pObj )
-GET( GetSingle,   SbxSINGLE,     float,         nSingle )
-GET( GetULong,    SbxULONG,      sal_uInt32,    nULong )
-GET( GetUShort,   SbxUSHORT,     sal_uInt16,    nUShort )
-GET( GetInt64,    SbxSALINT64,   sal_Int64,     nInt64 )
-GET( GetUInt64,   SbxSALUINT64,  sal_uInt64,    uInt64 )
-GET( GetDecimal,  SbxDECIMAL,    SbxDecimal*,   pDecimal )
-
-
 //////////////////////////// Write data
 
 bool SbxValue::Put( const SbxValues& rVal )
diff --git a/include/basic/sbxvar.hxx b/include/basic/sbxvar.hxx
index 4ab7052cc2dd..14c3eb97a788 100644
--- a/include/basic/sbxvar.hxx
+++ b/include/basic/sbxvar.hxx
@@ -135,27 +135,27 @@ public:
 
     SbxValues * data() { return &aData; }
 
-    sal_Unicode GetChar() const;
-    sal_Int16   GetInteger() const;
-    sal_Int32   GetLong() const;
-    sal_Int64   GetInt64() const;
-    sal_uInt64  GetUInt64() const;
+    sal_Unicode GetChar() const { return Get(SbxCHAR).nChar; }
+    sal_Int16 GetInteger() const { return Get(SbxINTEGER).nInteger; }
+    sal_Int32 GetLong() const { return Get(SbxLONG).nLong; }
+    sal_Int64 GetInt64() const { return Get(SbxSALINT64).nInt64; }
+    sal_uInt64 GetUInt64() const { return Get(SbxSALUINT64).uInt64; }
 
-    sal_Int64   GetCurrency() const;
-    SbxDecimal* GetDecimal() const;
+    sal_Int64 GetCurrency() const { return Get(SbxCURRENCY).nInt64; }
+    SbxDecimal* GetDecimal() const { return Get(SbxDECIMAL).pDecimal; }
 
-    float       GetSingle() const;
-    double      GetDouble() const;
-    double      GetDate() const;
+    float GetSingle() const { return Get(SbxSINGLE).nSingle; }
+    double GetDouble() const { return Get(SbxDOUBLE).nDouble; }
+    double GetDate() const { return Get(SbxDATE).nDouble; }
 
-    bool    GetBool() const;
+    bool GetBool() const { return Get(SbxBOOL).nUShort != 0; }
     const OUString&   GetCoreString() const;
     OUString    GetOUString() const;
 
-    SbxBase*    GetObject() const;
-    sal_uInt8   GetByte() const;
-    sal_uInt16  GetUShort() const;
-    sal_uInt32  GetULong() const;
+    SbxBase* GetObject() const { return Get(SbxOBJECT).pObj; }
+    sal_uInt8 GetByte() const { return Get(SbxBYTE).nByte; }
+    sal_uInt16 GetUShort() const { return Get(SbxUSHORT).nUShort; }
+    sal_uInt32 GetULong() const { return Get(SbxULONG).nULong; }
 
     bool PutInteger( sal_Int16 );
     bool PutLong( sal_Int32 );
@@ -202,6 +202,9 @@ public:
     inline SbxValue& operator /=( const SbxValue& );
     inline SbxValue& operator +=( const SbxValue& );
     inline SbxValue& operator -=( const SbxValue& );
+
+private:
+    SbxValues Get(SbxDataType t) const;
 };
 
 inline bool SbxValue::operator<=( const SbxValue& r ) const


More information about the Libreoffice-commits mailing list