basic/source/comp/codegen.cxx    |    4 ++--
 basic/source/comp/scanner.cxx    |    2 +-
 basic/source/inc/codegen.hxx     |   15 +++++++++++++--
 basic/source/inc/iosys.hxx       |    2 +-
 basic/source/inc/runtime.hxx     |    2 +-
 basic/source/runtime/runtime.cxx |    6 +++---
 6 files changed, 21 insertions(+), 10 deletions(-)

New commits:
commit e789e9135d08a5935062be0565c8c02b30cc0a4f
Author:     Sergey Anisimov <[email protected]>
AuthorDate: Mon Oct 6 16:59:23 2025 +0300
Commit:     Hossein <[email protected]>
CommitDate: Thu Oct 30 14:16:40 2025 +0100

    tdf#145614 - Convert #define to enum or constexpr
    
    Change-Id: I8b08c068b096a19febf88d70a23959e572b96640
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191982
    Reviewed-by: Hossein <[email protected]>
    Tested-by: Jenkins

diff --git a/basic/source/comp/codegen.cxx b/basic/source/comp/codegen.cxx
index 40b6a6fc00f4..7bb3302aaccf 100644
--- a/basic/source/comp/codegen.cxx
+++ b/basic/source/comp/codegen.cxx
@@ -332,11 +332,11 @@ void SbiCodeGen::Save()
                         }
                         if( pPar->IsParamArray() )
                         {
-                            nUserData |= PARAM_INFO_PARAMARRAY;
+                            ParamInfoFlag::setFlagFor(nUserData, 
ParamInfo::ParamArray);
                         }
                         if( pPar->IsWithBrackets() )
                         {
-                            nUserData |= PARAM_INFO_WITHBRACKETS;
+                            ParamInfoFlag::setFlagFor(nUserData, 
ParamInfo::WithBrackets);
                         }
                         SbxParamInfo* pParam = nullptr;
                         if( nUserData )
diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx
index 656ba6d8442f..5e6c29150267 100644
--- a/basic/source/comp/scanner.cxx
+++ b/basic/source/comp/scanner.cxx
@@ -142,7 +142,6 @@ static SbxDataType GetSuffixType( sal_Unicode c )
 
 // reading the next symbol into the variables aSym, nVal and eType
 // return value is sal_False at EOF or errors
-#define BUF_SIZE 80
 
 void SbiScanner::scanAlphanumeric()
 {
@@ -222,6 +221,7 @@ static bool isValidCompilerDirective(std::u16string_view 
directive)
 
 bool SbiScanner::NextSym()
 {
+    constexpr sal_Int32 BUF_SIZE = 80;
     // memorize for the EOLN-case
     sal_Int32 nOldLine = nLine;
     sal_Int32 nOldCol1 = nCol1;
diff --git a/basic/source/inc/codegen.hxx b/basic/source/inc/codegen.hxx
index e9e06216014b..ff8851317b6e 100644
--- a/basic/source/inc/codegen.hxx
+++ b/basic/source/inc/codegen.hxx
@@ -80,7 +80,18 @@ public:
 
 // #111897 PARAM_INFO flags start at 0x00010000 to not
 // conflict with DefaultId in SbxParamInfo::nUserData
-#define PARAM_INFO_PARAMARRAY       0x0010000
-#define PARAM_INFO_WITHBRACKETS     0x0020000
+
+enum class ParamInfo{
+    ParamArray  =     0x0010000,
+    WithBrackets =    0x0020000
+};
+struct ParamInfoFlag{
+    static void setFlagFor(sal_uInt32& val, const ParamInfo &&pe){
+        val |= static_cast<sal_uInt32>(pe);
+    };
+    static bool checkFlagFor(const sal_uInt32& val, const ParamInfo &&pe){
+        return val & static_cast<sal_uInt32>(pe);
+    };
+};
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basic/source/inc/iosys.hxx b/basic/source/inc/iosys.hxx
index e4e3ff3f181e..24c3f476afd5 100644
--- a/basic/source/inc/iosys.hxx
+++ b/basic/source/inc/iosys.hxx
@@ -30,7 +30,7 @@ class SvStream;
 // Global files (channel numbers 256 to 511) are not
 // implemented at the moment.
 
-#define CHANNELS 256
+constexpr sal_Int32 CHANNELS = 256;
 
 enum class SbiStreamFlags
 {
diff --git a/basic/source/inc/runtime.hxx b/basic/source/inc/runtime.hxx
index eaf9966b197d..bcf23145da3e 100644
--- a/basic/source/inc/runtime.hxx
+++ b/basic/source/inc/runtime.hxx
@@ -85,7 +85,7 @@ struct SbiForStack {                // for/next stack:
     {}
 };
 
-#define MAXRECURSION 500 //to prevent dead-recursions
+constexpr size_t MAXRECURSION = 500; //to prevent dead-recursions
 
 // Related to: Dir, GetAttr, SetAttr
 namespace SbAttributes
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index 93775a086554..4dcd6952f3e9 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -654,7 +654,7 @@ void SbiRuntime::SetParameters( SbxArray* pParams )
             const SbxParamInfo* p = pInfo ? pInfo->GetParam( 
sal::static_int_cast<sal_uInt16>(i) ) : nullptr;
 
             // #111897 ParamArray
-            if( p && (p->nUserData & PARAM_INFO_PARAMARRAY) != 0 )
+            if( p && ParamInfoFlag::checkFlagFor(p->nUserData, 
ParamInfo::ParamArray) )
             {
                 SbxDimArray* pArray = new SbxDimArray( SbxVARIANT );
                 sal_uInt32 nParamArrayParamCount = nParamCount - i;
@@ -697,7 +697,7 @@ void SbiRuntime::SetParameters( SbxArray* pParams )
                     bByVal = true;
                 }
 
-                bTargetTypeIsArray = (p->nUserData & PARAM_INFO_WITHBRACKETS) 
!= 0;
+                bTargetTypeIsArray = ParamInfoFlag::checkFlagFor(p->nUserData, 
ParamInfo::WithBrackets);
             }
             if( bByVal )
             {
@@ -745,7 +745,7 @@ void SbiRuntime::SetParameters( SbxArray* pParams )
 
     // #111897 Check first missing parameter for ParamArray
     const SbxParamInfo* p = 
pInfo->GetParam(sal::static_int_cast<sal_uInt16>(nParamCount));
-    if( p && (p->nUserData & PARAM_INFO_PARAMARRAY) != 0 )
+    if( p && ParamInfoFlag::checkFlagFor(p->nUserData, ParamInfo::ParamArray) )
     {
         SbxDimArray* pArray = new SbxDimArray( SbxVARIANT );
         pArray->unoAddDim(0, -1);

Reply via email to