[Libreoffice-commits] core.git: rsc/inc rsc/source

Jochen Nitschke j.nitschke+logerrit at ok.de
Wed Aug 31 16:34:39 UTC 2016


 rsc/inc/rscarray.hxx        |    6 +++---
 rsc/inc/rscclass.hxx        |    2 +-
 rsc/inc/rscconst.hxx        |    3 +--
 rsc/inc/rsccont.hxx         |    6 +++---
 rsc/inc/rscflag.hxx         |    4 ++--
 rsc/inc/rscmgr.hxx          |    2 +-
 rsc/inc/rscrange.hxx        |    9 +++------
 rsc/inc/rscstr.hxx          |    3 +--
 rsc/inc/rsctop.hxx          |    2 +-
 rsc/source/res/rscarray.cxx |    9 ++++-----
 rsc/source/res/rscclass.cxx |    7 +++----
 rsc/source/res/rscclobj.cxx |    9 ++++-----
 rsc/source/res/rscconst.cxx |    4 +---
 rsc/source/res/rsccont.cxx  |   14 ++++++--------
 rsc/source/res/rscflag.cxx  |    6 ++----
 rsc/source/res/rscmgr.cxx   |    2 +-
 rsc/source/res/rscrange.cxx |   12 ++++--------
 rsc/source/res/rscstr.cxx   |    3 +--
 rsc/source/res/rsctop.cxx   |    2 +-
 19 files changed, 43 insertions(+), 62 deletions(-)

New commits:
commit f322c52b89f514b792179c4d7e6ee2c3aa893a4e
Author: Jochen Nitschke <j.nitschke+logerrit at ok.de>
Date:   Wed Aug 31 14:14:50 2016 +0200

    use initializer list ctors for res types
    
    make nSize and nOffInstData const,
    let Size() return fixed sizes
    
    Change-Id: I7e2792e1cd990e65582020353054087f94856151
    Reviewed-on: https://gerrit.libreoffice.org/28545
    Reviewed-by: Jochen Nitschke <j.nitschke+logerrit at ok.de>
    Tested-by: Jochen Nitschke <j.nitschke+logerrit at ok.de>

diff --git a/rsc/inc/rscarray.hxx b/rsc/inc/rscarray.hxx
index c917db5..a7bf2c4 100644
--- a/rsc/inc/rscarray.hxx
+++ b/rsc/inc/rscarray.hxx
@@ -54,8 +54,8 @@ class RscArray : public RscTop
 {
 protected:
     RscEnum *       pTypeClass; // type of entries
-    sal_uInt32      nSize;      // size of this class instance data with super class
-    sal_uInt32      nOffInstData;// Offset of self instance data
+    const sal_uInt32 nOffInstData;// Offset of self instance data
+    const sal_uInt32 nSize;      // size of this class instance data with super class
     void            WriteSrcArray( const RSCINST & rInst, FILE * fOutput,
                                    RscTypCont * pTC, sal_uInt32 nTab, const char * );
 public:
@@ -75,7 +75,7 @@ public:
                                  RSCINST * pGetInst ) override;
 
                     // gives the size of the class in bytes
-    sal_uInt32      Size() override { return nSize; }
+    sal_uInt32      Size() const override { return nSize; }
 
     bool            IsConsistent( const RSCINST & rInst ) override;
     virtual void    SetToDefault( const RSCINST & rInst ) override;
diff --git a/rsc/inc/rscclass.hxx b/rsc/inc/rscclass.hxx
index 1b78859..46fe526 100644
--- a/rsc/inc/rscclass.hxx
+++ b/rsc/inc/rscclass.hxx
@@ -82,7 +82,7 @@ public:
     RSCINST         GetCopyVar( const RSCINST & rInst, Atom nVarName ) override;
 
                     // gives the class size in bytes
-    sal_uInt32      Size() override { return nSize; }
+    sal_uInt32      Size() const override { return nSize; }
 
     bool            IsConsistent( const RSCINST & rInst ) override;
     void            SetToDefault( const RSCINST & rInst ) override;
diff --git a/rsc/inc/rscconst.hxx b/rsc/inc/rscconst.hxx
index 275996f..ec3d362 100644
--- a/rsc/inc/rscconst.hxx
+++ b/rsc/inc/rscconst.hxx
@@ -52,11 +52,10 @@ class RscEnum : public RscConst
         sal_uInt32  nValue; // constant position in the array
         bool        bDflt;  // is default
     };
-    sal_uInt32      nSize;
 public:
                     RscEnum( Atom nId, sal_uInt32 nTypId );
     RSCINST         Create( RSCINST * pInst, const RSCINST & rDfltInst, bool bOwnClass = false ) override;
-    sal_uInt32      Size() override { return nSize; }
+    sal_uInt32      Size() const override { return ALIGNED_SIZE(sizeof(RscEnumInst)); }
 
     virtual void    SetToDefault( const RSCINST & rInst ) override
                     {
diff --git a/rsc/inc/rsccont.hxx b/rsc/inc/rsccont.hxx
index 36aa2cf..f72f1ae 100644
--- a/rsc/inc/rsccont.hxx
+++ b/rsc/inc/rsccont.hxx
@@ -43,8 +43,8 @@ protected:
     RscTop *        pTypeClass; // type of entries
     RscTop *        pTypeClass1;// two different types may exist
     bool            bNoId;      // whether there is no identifier
-    sal_uInt32      nSize;      // size of this class and super classes instance data
-    sal_uInt32      nOffInstData;// offset of own instance data
+    const sal_uInt32 nOffInstData;// offset of own instance data
+    const sal_uInt32 nSize;      // size of this class and super classes instance data
     static void     DestroyElements( RscBaseContInst * pClassData );
     RSCINST         SearchElePos( const RSCINST & rInst, const RscId & rEleName,
                                   RscTop * pClass, sal_uInt32 nPos );
@@ -86,7 +86,7 @@ public:
     ERRTYPE         SetRef( const RSCINST & rInst, const RscId & rRefId ) override;
 
                     // returns the class size in bytes
-    sal_uInt32      Size() override { return nSize; }
+    sal_uInt32      Size() const override { return nSize; }
 
     bool            IsConsistent( const RSCINST & rInst ) override;
     void            SetToDefault( const RSCINST & rInst ) override;
diff --git a/rsc/inc/rscflag.hxx b/rsc/inc/rscflag.hxx
index a783ed4..77b21f3f 100644
--- a/rsc/inc/rscflag.hxx
+++ b/rsc/inc/rscflag.hxx
@@ -38,7 +38,7 @@ public:
     RSCINST         Create( RSCINST * pInst, const RSCINST & rDflt, bool bOwnClass = false ) override;
     RSCINST         CreateClient( RSCINST * pInst, const RSCINST & rDflt,
                                   bool bOwnClass, Atom nConsId );
-    sal_uInt32      Size() override;
+    sal_uInt32      Size() const override;
 
     virtual void    SetToDefault( const RSCINST & rInst ) override;
     bool            IsDefault( const RSCINST & rInst ) override;
@@ -71,7 +71,7 @@ public:
                                Atom nConstantId );
     virtual RSCCLASS_TYPE   GetClassType() const override;
     RSCINST         Create( RSCINST * pInst, const RSCINST & rDflt, bool bOwnClass = false ) override;
-    sal_uInt32      Size() override { return pRefClass->Size(); }
+    sal_uInt32      Size() const override { return pRefClass->Size(); }
 
                     // an assignment to a variable
     bool            IsDefault( const RSCINST & rInst ) override {
diff --git a/rsc/inc/rscmgr.hxx b/rsc/inc/rscmgr.hxx
index f70cdf8..3fd9afa 100644
--- a/rsc/inc/rscmgr.hxx
+++ b/rsc/inc/rscmgr.hxx
@@ -45,7 +45,7 @@ public:
 
     RSCINST         Create( RSCINST * pInst, const RSCINST & rDflt, bool bOwnClass = false ) override;
     void            Destroy( const RSCINST & rInst ) override;
-    sal_uInt32      Size() override;
+    sal_uInt32      Size() const override;
     void            WriteSrcHeader( const RSCINST & aInst, FILE * fOutput,
                                     RscTypCont * pTC, sal_uInt32 nTab,
                                     const RscId & rId, const char * ) override;
diff --git a/rsc/inc/rscrange.hxx b/rsc/inc/rscrange.hxx
index bbcd8a7..aee604b 100644
--- a/rsc/inc/rscrange.hxx
+++ b/rsc/inc/rscrange.hxx
@@ -34,7 +34,6 @@ protected:
     };
     sal_Int32       nMin;   // range minimum value
     sal_Int32       nMax;   // range maximum value
-    sal_uInt32      nSize;
 public:
                     RscRange( Atom nId, sal_uInt32 nTypId );
     virtual RSCCLASS_TYPE   GetClassType() const override;
@@ -42,7 +41,7 @@ public:
                     // sets the allowed range
     void            SetRange( sal_Int32 nMinimum, sal_Int32 nMaximum );
                     // returns the class size in bytes
-    sal_uInt32      Size() override { return nSize; }
+    sal_uInt32      Size() const override { return ALIGNED_SIZE(sizeof(RscRangeInst)); }
                     // an assignment to a variable
     virtual void    SetToDefault( const RSCINST & rInst ) override
                         {
@@ -72,7 +71,6 @@ protected:
     };
     sal_Int32    nMin;   // range minimum value
     sal_Int32    nMax;   // range maximum value
-    sal_uInt32  nSize;
 public:
                     RscLongRange( Atom nId, sal_uInt32 nTypId );
     virtual RSCCLASS_TYPE   GetClassType() const override;
@@ -80,7 +78,7 @@ public:
                     // sets the allowed range
     void            SetRange( sal_Int32 nMinimum, sal_Int32 nMaximum );
                     // returns the class size in bytes
-    sal_uInt32      Size() override { return nSize; }
+    sal_uInt32      Size() const override { return ALIGNED_SIZE(sizeof(RscLongRangeInst)); }
                     // an assignment to a variable
     virtual void    SetToDefault( const RSCINST & rInst ) override
                         {
@@ -112,7 +110,6 @@ public:
 
 class RscIdRange : public RscTop
 {
-    sal_uInt32  nSize;
 protected:
     sal_Int32    nMin;   // range minimum value
     sal_Int32    nMax;   // range maximum value
@@ -127,7 +124,7 @@ public:
                         }
     RSCINST         Create( RSCINST * pInst, const RSCINST & rDfltInst, bool bOwnClass = false ) override;
     void            Destroy( const RSCINST & rInst ) override;
-    sal_uInt32          Size() override { return nSize; }
+    sal_uInt32      Size() const override { return ALIGNED_SIZE(sizeof(RscId)); }
     virtual void    SetToDefault( const RSCINST & rInst ) override
                         {
                             reinterpret_cast<RscId*>(rInst.pData)->aExp.cUnused = true;
diff --git a/rsc/inc/rscstr.hxx b/rsc/inc/rscstr.hxx
index c51f4a6..ae20f04 100644
--- a/rsc/inc/rscstr.hxx
+++ b/rsc/inc/rscstr.hxx
@@ -33,7 +33,6 @@ class RscString : public RscTop
         bool    bDflt;  // is default
         RscId   aRefId; // reference name
     };
-    sal_uInt32  nSize;
 public:
                     RscString( Atom nId, sal_uInt32 nTypId );
     virtual RSCCLASS_TYPE   GetClassType() const override;
@@ -42,7 +41,7 @@ public:
     RSCINST         Create( RSCINST * pInst, const RSCINST & rDfltInst, bool bOwnClass = false ) override;
                     // sets the allowed range
     void            Destroy( const RSCINST & rInst ) override;
-    sal_uInt32      Size() override { return nSize; }
+    sal_uInt32      Size() const override { return ALIGNED_SIZE(sizeof(RscStringInst)); }
     void            SetToDefault( const RSCINST & rInst ) override
                         {
                             reinterpret_cast<RscStringInst*>(rInst.pData)->bDflt = true;
diff --git a/rsc/inc/rsctop.hxx b/rsc/inc/rsctop.hxx
index 6d57114..f4da6ee 100644
--- a/rsc/inc/rsctop.hxx
+++ b/rsc/inc/rsctop.hxx
@@ -72,7 +72,7 @@ public:
     virtual RscTop* GetTypeClass() const;
 
                     // returns the class size in bytes
-    virtual sal_uInt32  Size();
+    virtual sal_uInt32  Size() const;
 
                     // returns the reference
     virtual ERRTYPE GetRef( const RSCINST & rInst, RscId * );
diff --git a/rsc/source/res/rscarray.cxx b/rsc/source/res/rscarray.cxx
index 595963b..b73c932 100644
--- a/rsc/source/res/rscarray.cxx
+++ b/rsc/source/res/rscarray.cxx
@@ -26,9 +26,8 @@
 #include <rscarray.hxx>
 #include <rscdb.hxx>
 
-RscInstNode::RscInstNode( sal_uInt32 nId )
+RscInstNode::RscInstNode(sal_uInt32 nId) : nTypeId(nId)
 {
-    nTypeId = nId;
 }
 
 RscInstNode::~RscInstNode()
@@ -47,10 +46,10 @@ sal_uInt32 RscInstNode::GetId() const
 
 RscArray::RscArray( Atom nId, sal_uInt32 nTypeId, RscTop * pSuper, RscEnum * pTypeCl )
     : RscTop( nId, nTypeId, pSuper )
+    , pTypeClass(pTypeCl)
+    , nOffInstData(RscTop::Size())
+    , nSize(nOffInstData + ALIGNED_SIZE(sizeof(RscArrayInst)))
 {
-    pTypeClass = pTypeCl;
-    nOffInstData = RscTop::Size();
-    nSize = nOffInstData + ALIGNED_SIZE( sizeof( RscArrayInst ) );
 }
 
 RscArray::~RscArray()
diff --git a/rsc/source/res/rscclass.cxx b/rsc/source/res/rscclass.cxx
index 27500f6..366d683 100644
--- a/rsc/source/res/rscclass.cxx
+++ b/rsc/source/res/rscclass.cxx
@@ -30,11 +30,10 @@
 
 RscClass::RscClass( Atom nId, sal_uInt32 nTypeId, RscTop * pSuperCl )
     : RscTop( nId, nTypeId, pSuperCl )
+    , nSuperSize(RscTop::Size())
+    , nSize(nSuperSize + ALIGNED_SIZE(sizeof(RscClassInst )))
+    , nEntries(0), pVarTypeList(nullptr)
 {
-    nEntries = 0;
-    pVarTypeList = nullptr;
-    nSuperSize = RscTop::Size();
-    nSize = nSuperSize + ALIGNED_SIZE( sizeof( RscClassInst ) );
 }
 
 void RscClass::Pre_dtor()
diff --git a/rsc/source/res/rscclobj.cxx b/rsc/source/res/rscclobj.cxx
index 9401636..993be7f 100644
--- a/rsc/source/res/rscclobj.cxx
+++ b/rsc/source/res/rscclobj.cxx
@@ -23,9 +23,8 @@
 
 
 RefNode::RefNode( Atom nTyp )
+    : nTypNameId(nTyp), pObjBiTree(nullptr)
 {
-    pObjBiTree = nullptr;
-    nTypNameId = nTyp;
 }
 
 sal_uInt32 RefNode::GetId() const
@@ -58,10 +57,10 @@ ObjNode * RefNode::GetObjNode( const RscId & rRscId )
 }
 
 ObjNode::ObjNode( const RscId & rId, CLASS_DATA pData, sal_uLong lKey )
+    : aRscId(rId)
+    , pRscObj(pData)
+    , lFileKey(lKey)
 {
-    pRscObj  = pData;
-    aRscId   = rId;
-    lFileKey = lKey;
 }
 
 ObjNode * ObjNode::DelObjNode( RscTop * pClass, sal_uLong nFileKey )
diff --git a/rsc/source/res/rscconst.cxx b/rsc/source/res/rscconst.cxx
index a61af44..f45045b 100644
--- a/rsc/source/res/rscconst.cxx
+++ b/rsc/source/res/rscconst.cxx
@@ -28,9 +28,8 @@
 
 RscConst::RscConst( Atom nId, sal_uInt32 nTypeId )
     : RscTop( nId, nTypeId )
+    , pVarArray(nullptr), nEntries(0)
 {
-    pVarArray = nullptr;
-    nEntries = 0;
 }
 
 RscConst::~RscConst()
@@ -102,7 +101,6 @@ sal_uInt32 RscConst::GetConstPos( Atom nConst )
 RscEnum::RscEnum( Atom nId, sal_uInt32 nTypeId )
     : RscConst( nId, nTypeId )
 {
-    nSize = ALIGNED_SIZE( sizeof( RscEnumInst ) );
 }
 
 ERRTYPE RscEnum::SetConst( const RSCINST & rInst, Atom nConst, sal_Int32 /*nVal*/ )
diff --git a/rsc/source/res/rsccont.cxx b/rsc/source/res/rsccont.cxx
index 012aa28..c3bf619 100644
--- a/rsc/source/res/rsccont.cxx
+++ b/rsc/source/res/rsccont.cxx
@@ -37,14 +37,12 @@ void ENTRY_STRUCT::Destroy()
 
 RscBaseCont::RscBaseCont( Atom nId, sal_uInt32 nTypeId, RscTop * pSuper,
                           bool bNoIdent )
-    : RscTop( nId, nTypeId, pSuper )
-    , nSize( 0 )
-{
-    pTypeClass = nullptr;
-    pTypeClass1 = nullptr;
-    bNoId = bNoIdent;
-    nOffInstData = RscTop::Size();
-    nSize = nOffInstData + ALIGNED_SIZE( sizeof( RscBaseContInst ) );
+    : RscTop(nId, nTypeId, pSuper)
+    , pTypeClass(nullptr), pTypeClass1(nullptr)
+    , bNoId(bNoIdent), nOffInstData(RscTop::Size())
+    , nSize(nOffInstData + ALIGNED_SIZE(sizeof(RscBaseContInst)))
+
+{
 }
 
 RscBaseCont::~RscBaseCont()
diff --git a/rsc/source/res/rscflag.cxx b/rsc/source/res/rscflag.cxx
index 1c4b04b..4ac6473 100644
--- a/rsc/source/res/rscflag.cxx
+++ b/rsc/source/res/rscflag.cxx
@@ -29,7 +29,7 @@ RscFlag::RscFlag( Atom nId, sal_uInt32 nTypeId )
 {
 }
 
-sal_uInt32 RscFlag::Size()
+sal_uInt32 RscFlag::Size() const
 {
     return ALIGNED_SIZE( sizeof( RscFlagInst ) *
             ( 1 + (nEntries -1) / (sizeof( sal_uInt32 ) * 8) ) );
@@ -294,10 +294,8 @@ ERRTYPE RscFlag::WriteRc( const RSCINST & rInst, RscWriteRc & aMem,
 
 RscClient::RscClient( Atom nId, sal_uInt32 nTypeId, RscFlag * pClass,
                       Atom nConstantId )
-    : RscTop ( nId, nTypeId )
+    : RscTop(nId, nTypeId), pRefClass(pClass), nConstId(nConstantId)
 {
-   pRefClass = pClass;
-   nConstId = nConstantId;
 }
 
 RSCCLASS_TYPE RscClient::GetClassType() const
diff --git a/rsc/source/res/rscmgr.cxx b/rsc/source/res/rscmgr.cxx
index 682ea0c..2de220d 100644
--- a/rsc/source/res/rscmgr.cxx
+++ b/rsc/source/res/rscmgr.cxx
@@ -31,7 +31,7 @@ RscMgr::RscMgr( Atom nId, sal_uInt32 nTypeId, RscTop * pSuperCl )
 {
 }
 
-sal_uInt32 RscMgr::Size()
+sal_uInt32 RscMgr::Size() const
 {
     return RscClass::Size() + ALIGNED_SIZE( sizeof( RscMgrInst ) );
 }
diff --git a/rsc/source/res/rscrange.cxx b/rsc/source/res/rscrange.cxx
index 6e379ff..d243ca8 100644
--- a/rsc/source/res/rscrange.cxx
+++ b/rsc/source/res/rscrange.cxx
@@ -26,9 +26,8 @@
 
 RscRange::RscRange( Atom nId, sal_uInt32 nTypeId )
     : RscTop( nId, nTypeId )
+    , nMin(0), nMax(0)
 {
-    nMin = nMax = 0;
-    nSize = ALIGNED_SIZE( sizeof( RscRangeInst ) );
 }
 
 RSCCLASS_TYPE RscRange::GetClassType() const
@@ -138,9 +137,8 @@ ERRTYPE RscRange::WriteRc( const RSCINST & rInst, RscWriteRc & aMem,
 
 RscLongRange::RscLongRange( Atom nId, sal_uInt32 nTypeId )
     : RscTop( nId, nTypeId )
+    , nMin(0), nMax(0)
 {
-    nMin = nMax = 0;
-    nSize = ALIGNED_SIZE( sizeof( RscLongRangeInst ) );
 }
 
 RSCCLASS_TYPE RscLongRange::GetClassType() const
@@ -256,9 +254,8 @@ ERRTYPE RscLongEnumRange::SetConst( const RSCINST & rInst, Atom /*nConst*/,
 
 RscIdRange::RscIdRange( Atom nId, sal_uInt32 nTypeId )
     : RscTop( nId, nTypeId )
+    , nMin(0), nMax(0)
 {
-    nSize = ALIGNED_SIZE( sizeof( RscId ) );
-    nMin = nMax = 0;
 }
 
 RSCCLASS_TYPE RscIdRange::GetClassType() const
@@ -416,9 +413,8 @@ void RscBool::WriteSrc( const RSCINST & rInst, FILE * fOutput,
 }
 
 RscBreakRange::RscBreakRange( Atom nId, sal_uInt32 nTypeId )
-    : RscRange( nId, nTypeId )
+    : RscRange(nId, nTypeId), nOutRange(0xFFFFFFFF)
 {
-    nOutRange = 0xFFFFFFFF;
 }
 
 ERRTYPE RscBreakRange::SetNumber( const RSCINST & rInst, sal_Int32 nValue )
diff --git a/rsc/source/res/rscstr.cxx b/rsc/source/res/rscstr.cxx
index 5bd886e..f03bf4e 100644
--- a/rsc/source/res/rscstr.cxx
+++ b/rsc/source/res/rscstr.cxx
@@ -30,9 +30,8 @@
 
 RscString::RscString( Atom nId, sal_uInt32 nTypeId )
     : RscTop( nId, nTypeId )
+    , pRefClass(nullptr)
 {
-    nSize = ALIGNED_SIZE( sizeof( RscStringInst ) );
-    pRefClass = nullptr;
 }
 
 RSCCLASS_TYPE RscString::GetClassType() const
diff --git a/rsc/source/res/rsctop.cxx b/rsc/source/res/rsctop.cxx
index 47fa95a..bf17295 100644
--- a/rsc/source/res/rsctop.cxx
+++ b/rsc/source/res/rsctop.cxx
@@ -66,7 +66,7 @@ RscTop * RscTop::GetTypeClass() const
         return nullptr;
 }
 
-sal_uInt32 RscTop::Size()
+sal_uInt32 RscTop::Size() const
 {
     if( pSuperClass )
         return pSuperClass->Size();


More information about the Libreoffice-commits mailing list