[Libreoffice-commits] core.git: Branch 'aoo/trunk' - basic/inc basic/source

Tsutomu Uchino hanya at apache.org
Thu Jan 8 10:11:12 PST 2015


 basic/inc/basic/sbxmeth.hxx     |   11 ++++++++---
 basic/inc/basic/sbxobj.hxx      |    2 +-
 basic/source/comp/parser.cxx    |   10 +++++++++-
 basic/source/runtime/stdobj.cxx |    2 +-
 basic/source/sbx/sbxobj.cxx     |    4 ++--
 5 files changed, 21 insertions(+), 8 deletions(-)

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

    #i63614# fix strange type missmatch when Iif runtime 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.

diff --git a/basic/inc/basic/sbxmeth.hxx b/basic/inc/basic/sbxmeth.hxx
index dc25ee9..7fa7eed 100644
--- a/basic/inc/basic/sbxmeth.hxx
+++ b/basic/inc/basic/sbxmeth.hxx
@@ -31,17 +31,22 @@ class SbxMethodImpl;
 class SbxMethod : public SbxVariable
 {
     SbxMethodImpl* mpSbxMethodImpl; // Impl data
+    bool           mbIsRuntimeFunction;
+    SbxDataType    mbRuntimeFunctionReturnType;
 
 public:
     SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_METHOD,1);
     TYPEINFO();
-    SbxMethod( const String& r, SbxDataType t )
-    : SbxVariable( t ) { SetName( r ); }
-    SbxMethod( const SbxMethod& r ) : SvRefBase( r ), SbxVariable( r ) {}
+    SbxMethod( const String& r, SbxDataType t, bool bIsRuntimeFunction=false )
+    : SbxVariable( t ), mbIsRuntimeFunction( bIsRuntimeFunction ), mbRuntimeFunctionReturnType( t ) { SetName( r ); }
+    SbxMethod( const SbxMethod& r )
+    : SvRefBase( r ), SbxVariable( r ), mbIsRuntimeFunction( r.IsRuntimeFunction() ) {}
     SbxMethod& operator=( const SbxMethod& r )
     { SbxVariable::operator=( r ); return *this; }
     sal_Bool Run( SbxValues* pValues = NULL );
     virtual SbxClassType GetClass() const;
+    bool IsRuntimeFunction() const { return mbIsRuntimeFunction; }
+    SbxDataType GetRuntimeFunctionReturnType() const{ return mbRuntimeFunctionReturnType; }
 };
 
 #ifndef __SBX_SBXMETHODREF_HXX
diff --git a/basic/inc/basic/sbxobj.hxx b/basic/inc/basic/sbxobj.hxx
index 989ea40..f78d453 100644
--- a/basic/inc/basic/sbxobj.hxx
+++ b/basic/inc/basic/sbxobj.hxx
@@ -80,7 +80,7 @@ public:
     SbxVariable* Execute( const String& );
     // Manage elements
     virtual sal_Bool GetAll( SbxClassType ) { return sal_True; }
-    SbxVariable* Make( const String&, SbxClassType, SbxDataType );
+    SbxVariable* Make( const String&, SbxClassType, SbxDataType, bool bIsRuntimeFunction = false );
     virtual SbxObject* MakeObject( const String&, const String& );
     virtual void Insert( SbxVariable* );
     // AB 23.4.1997, Optimization, Insertion without check for duplicate Entries and
diff --git a/basic/source/comp/parser.cxx b/basic/source/comp/parser.cxx
index 85c4920..b06e997 100644
--- a/basic/source/comp/parser.cxx
+++ b/basic/source/comp/parser.cxx
@@ -169,7 +169,15 @@ SbiSymDef* SbiParser::CheckRTLForSym( const String& 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 8e1058a..eb3cdcc 100644
--- a/basic/source/runtime/stdobj.cxx
+++ b/basic/source/runtime/stdobj.cxx
@@ -715,7 +715,7 @@ SbxVariable* SbiStdObject::Find( const String& rName, SbxClassType t )
                 eCT = SbxCLASS_PROPERTY;
             else if( nType & _METHOD )
                 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 9934331..ce30eed 100644
--- a/basic/source/sbx/sbxobj.cxx
+++ b/basic/source/sbx/sbxobj.cxx
@@ -376,7 +376,7 @@ SbxArray* SbxObject::FindVar( SbxVariable* pVar, sal_uInt16& nArrayIdx )
 // Falls ein neues Objekt eingerichtet wird, wird es, falls es bereits
 // eines mit diesem Namen gibt, indiziert.
 
-SbxVariable* SbxObject::Make( const XubString& rName, SbxClassType ct, SbxDataType dt )
+SbxVariable* SbxObject::Make( const XubString& rName, SbxClassType ct, SbxDataType dt, bool bIsRuntimeFunction )
 {
     // Ist das Objekt bereits vorhanden?
     SbxArray* pArray = NULL;
@@ -422,7 +422,7 @@ SbxVariable* SbxObject::Make( const XubString& rName, SbxClassType ct, SbxDataTy
             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 );


More information about the Libreoffice-commits mailing list