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

Tsutomu Uchino hanya at apache.org
Fri Jan 9 01:25:17 PST 2015


 basic/source/comp/parser.cxx    |   10 +++++++++-
 basic/source/runtime/stdobj.cxx |    2 +-
 basic/source/sbx/sbxobj.cxx     |   17 +++++++++++------
 include/basic/sbxmeth.hxx       |    6 +++++-
 include/basic/sbxobj.hxx        |    2 +-
 5 files changed, 27 insertions(+), 10 deletions(-)

New commits:
commit a272f5b7b30f356418ecf28eb95d066f081d1624
Author: Tsutomu Uchino <hanya at apache.org>
Date:   Thu Jan 8 16:28:11 2015 +0000

    Resolves: #i63614# fix strange type mismatch when Iif function is used
    
    Second or later compilation uses value type returned by previous execution of code.
    Use the defined type as return value of the runtime function of Basic always.
    
    (cherry picked from commit 7470c682e136a4a89c1e9474bbc79b2d61f31048)
    
    Conflicts:
    	basic/inc/basic/sbxmeth.hxx
    	basic/inc/basic/sbxobj.hxx
    	basic/source/runtime/stdobj.cxx
    	basic/source/sbx/sbxobj.cxx
    
    Change-Id: I3064e8403286a9c1401ef658bf139bedeae11f17

diff --git a/basic/source/comp/parser.cxx b/basic/source/comp/parser.cxx
index 9ce5bdb..ea2976a 100644
--- a/basic/source/comp/parser.cxx
+++ b/basic/source/comp/parser.cxx
@@ -161,7 +161,15 @@ SbiSymDef* SbiParser::CheckRTLForSym( const OUString& rSym, SbxDataType eType )
         if( pVar->IsA( TYPE(SbxMethod) ) )
         {
             SbiProcDef* pProc_ = aRtlSyms.AddProc( rSym );
-            pProc_->SetType( pVar->GetType() );
+            SbxMethod* pMethod = (SbxMethod*) pVar;
+            if ( pMethod && pMethod->IsRuntimeFunction() )
+            {
+                pProc_->SetType( pMethod->GetRuntimeFunctionReturnType() );
+            }
+            else
+            {
+                pProc_->SetType( pVar->GetType() );
+            }
             pDef = pProc_;
         }
         else
diff --git a/basic/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx
index f9f0b54..2e4f2a4 100644
--- a/basic/source/runtime/stdobj.cxx
+++ b/basic/source/runtime/stdobj.cxx
@@ -802,7 +802,7 @@ SbxVariable* SbiStdObject::Find( const OUString& rName, SbxClassType t )
             {
                 eCT = SbxCLASS_METHOD;
             }
-            pVar = Make( aName_, eCT, p->eType );
+            pVar = Make( aName_, eCT, p->eType, ( p->nArgs & _FUNCTION ) == _FUNCTION );
             pVar->SetUserData( nIndex + 1 );
             pVar->SetFlags( nAccess );
         }
diff --git a/basic/source/sbx/sbxobj.cxx b/basic/source/sbx/sbxobj.cxx
index 35a0eb2..a7d8d4b 100644
--- a/basic/source/sbx/sbxobj.cxx
+++ b/basic/source/sbx/sbxobj.cxx
@@ -377,7 +377,7 @@ SbxArray* SbxObject::FindVar( SbxVariable* pVar, sal_uInt16& nArrayIdx )
 // If a new object will be established, this object will be indexed,
 // if an object of this name exists already.
 
-SbxVariable* SbxObject::Make( const OUString& rName, SbxClassType ct, SbxDataType dt )
+SbxVariable* SbxObject::Make( const OUString& rName, SbxClassType ct, SbxDataType dt, bool bIsRuntimeFunction )
 {
     // Is the object already available?
     SbxArray* pArray = NULL;
@@ -410,7 +410,7 @@ SbxVariable* SbxObject::Make( const OUString& rName, SbxClassType ct, SbxDataTyp
         pVar = new SbxProperty( rName, dt );
         break;
     case SbxCLASS_METHOD:
-        pVar = new SbxMethod( rName, dt );
+        pVar = new SbxMethod( rName, dt, bIsRuntimeFunction );
         break;
     case SbxCLASS_OBJECT:
         pVar = CreateObject( rName );
@@ -964,14 +964,19 @@ void SbxObject::Dump( SvStream& rStrm, bool bFill )
     --nLevel;
 }
 
-SbxMethod::SbxMethod( const OUString& r, SbxDataType t )
-    : SbxVariable( t )
+SbxMethod::SbxMethod( const OUString& r, SbxDataType t, bool bIsRuntimeFunction )
+    : SbxVariable(t)
+    , mbIsRuntimeFunction(bIsRuntimeFunction)
+    , mbRuntimeFunctionReturnType(t)
 {
-    SetName( r );
+    SetName(r);
 }
 
 SbxMethod::SbxMethod( const SbxMethod& r )
-    : SvRefBase( r ), SbxVariable( r )
+    : SvRefBase(r)
+    , SbxVariable(r)
+    , mbIsRuntimeFunction(r.IsRuntimeFunction())
+    , mbRuntimeFunctionReturnType(r.GetRuntimeFunctionReturnType())
 {
 }
 
diff --git a/include/basic/sbxmeth.hxx b/include/basic/sbxmeth.hxx
index 6d8be5c..e7d9cae 100644
--- a/include/basic/sbxmeth.hxx
+++ b/include/basic/sbxmeth.hxx
@@ -25,14 +25,18 @@
 
 class BASIC_DLLPUBLIC SbxMethod : public SbxVariable
 {
+    bool           mbIsRuntimeFunction;
+    SbxDataType    mbRuntimeFunctionReturnType;
 public:
     SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_METHOD,1);
     TYPEINFO_OVERRIDE();
-    SbxMethod( const OUString& r, SbxDataType t );
+    SbxMethod( const OUString& r, SbxDataType t, bool bIsRuntimeFunction=false );
     SbxMethod( const SbxMethod& r );
     virtual ~SbxMethod();
     SbxMethod& operator=( const SbxMethod& r ) { SbxVariable::operator=( r ); return *this; }
     virtual SbxClassType GetClass() const SAL_OVERRIDE;
+    bool IsRuntimeFunction() const { return mbIsRuntimeFunction; }
+    SbxDataType GetRuntimeFunctionReturnType() const{ return mbRuntimeFunctionReturnType; }
 };
 
 #endif
diff --git a/include/basic/sbxobj.hxx b/include/basic/sbxobj.hxx
index c6c09cf..004e14b 100644
--- a/include/basic/sbxobj.hxx
+++ b/include/basic/sbxobj.hxx
@@ -68,7 +68,7 @@ public:
     SbxVariable* Execute( const OUString& );
     // Manage elements
     virtual bool GetAll( SbxClassType ) { return true; }
-    SbxVariable* Make( const OUString&, SbxClassType, SbxDataType );
+    SbxVariable* Make( const OUString&, SbxClassType, SbxDataType, bool bIsRuntimeFunction = false );
     virtual SbxObject* MakeObject( const OUString&, const OUString& );
     virtual void Insert( SbxVariable* );
     // AB 23.4.1997, Optimization, Insertion without check for duplicate Entries and


More information about the Libreoffice-commits mailing list