LCOV - code coverage report
Current view: top level - stoc/source/corereflection - crbase.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 63 89 70.8 %
Date: 2012-08-25 Functions: 14 25 56.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 42 82 51.2 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : 
      20                 :            : #include <cppuhelper/queryinterface.hxx>
      21                 :            : #include <uno/any2.h>
      22                 :            : 
      23                 :            : #include "base.hxx"
      24                 :            : 
      25                 :            : namespace stoc_corefl
      26                 :            : {
      27                 :            : 
      28                 :            : #ifdef TEST_LIST_CLASSES
      29                 :            : ClassNameList g_aClassNames;
      30                 :            : #endif
      31                 :            : 
      32                 :            : //--------------------------------------------------------------------------------------------------
      33                 :     281016 : Mutex & getMutexAccess()
      34                 :            : {
      35                 :            :     static Mutex * s_pMutex = 0;
      36         [ +  + ]:     281016 :     if (! s_pMutex)
      37                 :            :     {
      38 [ +  - ][ +  - ]:        182 :         MutexGuard aGuard( Mutex::getGlobalMutex() );
      39         [ +  - ]:        182 :         if (! s_pMutex)
      40                 :            :         {
      41 [ +  - ][ +  - ]:        182 :             static Mutex s_aMutex;
         [ +  - ][ #  # ]
      42                 :        182 :             s_pMutex = &s_aMutex;
      43         [ +  - ]:        182 :         }
      44                 :            :     }
      45                 :     281016 :     return *s_pMutex;
      46                 :            : }
      47                 :            : 
      48                 :            : //__________________________________________________________________________________________________
      49                 :      25713 : IdlClassImpl::IdlClassImpl( IdlReflectionServiceImpl * pReflection,
      50                 :            :                             const OUString & rName, typelib_TypeClass eTypeClass,
      51                 :            :                             typelib_TypeDescription * pTypeDescr )
      52                 :            :     : _pReflection( pReflection )
      53                 :            :     , _aName( rName )
      54                 :            :     , _eTypeClass( (TypeClass)eTypeClass )
      55                 :      25713 :     , _pTypeDescr( pTypeDescr )
      56                 :            : {
      57         [ +  - ]:      25713 :     if (_pReflection)
      58                 :      25713 :         _pReflection->acquire();
      59         [ +  - ]:      25713 :     if (_pTypeDescr)
      60                 :            :     {
      61                 :      25713 :         typelib_typedescription_acquire( _pTypeDescr );
      62         [ +  + ]:      25713 :         if (! _pTypeDescr->bComplete)
      63                 :      15491 :             typelib_typedescription_complete( &_pTypeDescr );
      64                 :            :     }
      65                 :            : 
      66                 :            : #ifdef TEST_LIST_CLASSES
      67                 :            :     ClassNameList::const_iterator iFind( find( g_aClassNames.begin(), g_aClassNames.end(), _aName ) );
      68                 :            :     OSL_ENSURE( iFind == g_aClassNames.end(), "### idl class already exists!" );
      69                 :            :     g_aClassNames.push_front( _aName );
      70                 :            : #endif
      71                 :      25713 : }
      72                 :            : //__________________________________________________________________________________________________
      73                 :       6720 : IdlClassImpl::~IdlClassImpl()
      74                 :            : {
      75         [ +  - ]:       6720 :     if (_pTypeDescr)
      76                 :       6720 :         typelib_typedescription_release( _pTypeDescr );
      77         [ +  - ]:       6720 :     if (_pReflection)
      78                 :       6720 :         _pReflection->release();
      79                 :            : 
      80                 :            : #ifdef TEST_LIST_CLASSES
      81                 :            :     ClassNameList::iterator iFind( find( g_aClassNames.begin(), g_aClassNames.end(), _aName ) );
      82                 :            :     OSL_ENSURE( iFind != g_aClassNames.end(), "### idl class does not exist!" );
      83                 :            :     g_aClassNames.erase( iFind );
      84                 :            : #endif
      85         [ -  + ]:       7049 : }
      86                 :            : 
      87                 :            : // XIdlClassImpl default implementation
      88                 :            : //__________________________________________________________________________________________________
      89                 :     823730 : TypeClass IdlClassImpl::getTypeClass()
      90                 :            :     throw(::com::sun::star::uno::RuntimeException)
      91                 :            : {
      92                 :     823730 :     return _eTypeClass;
      93                 :            : }
      94                 :            : //__________________________________________________________________________________________________
      95                 :     699532 : OUString IdlClassImpl::getName()
      96                 :            :     throw(::com::sun::star::uno::RuntimeException)
      97                 :            : {
      98                 :     699532 :     return _aName;
      99                 :            : }
     100                 :            : //__________________________________________________________________________________________________
     101                 :     688943 : sal_Bool IdlClassImpl::equals( const Reference< XIdlClass >& xType )
     102                 :            :     throw(::com::sun::star::uno::RuntimeException)
     103                 :            : {
     104                 :     688943 :     return (xType.is() &&
     105 [ +  - ][ +  - ]:     688943 :             (xType->getTypeClass() == _eTypeClass) && (xType->getName() == _aName));
         [ +  + ][ +  - ]
         [ +  - ][ +  + ]
         [ +  + ][ #  # ]
                 [ +  - ]
     106                 :            : }
     107                 :            : 
     108                 :            : static sal_Bool s_aAssignableFromTab[11][11] =
     109                 :            : {
     110                 :            :                          /* from CH,BO,BY,SH,US,LO,UL,HY,UH,FL,DO */
     111                 :            : /* TypeClass_CHAR */            { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
     112                 :            : /* TypeClass_BOOLEAN */         { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
     113                 :            : /* TypeClass_BYTE */            { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 },
     114                 :            : /* TypeClass_SHORT */           { 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 },
     115                 :            : /* TypeClass_UNSIGNED_SHORT */  { 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 },
     116                 :            : /* TypeClass_LONG */            { 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0 },
     117                 :            : /* TypeClass_UNSIGNED_LONG */   { 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0 },
     118                 :            : /* TypeClass_HYPER */           { 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0 },
     119                 :            : /* TypeClass_UNSIGNED_HYPER */  { 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0 },
     120                 :            : /* TypeClass_FLOAT */           { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
     121                 :            : /* TypeClass_DOUBLE */          { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
     122                 :            : };
     123                 :            : //__________________________________________________________________________________________________
     124                 :      39251 : sal_Bool IdlClassImpl::isAssignableFrom( const Reference< XIdlClass > & xType )
     125                 :            :     throw(::com::sun::star::uno::RuntimeException)
     126                 :            : {
     127                 :      39251 :     TypeClass eAssign = getTypeClass();
     128 [ +  + ][ +  + ]:      39251 :     if (equals( xType ) || eAssign == TypeClass_ANY) // default shot
                 [ +  + ]
     129                 :            :     {
     130                 :      21860 :         return sal_True;
     131                 :            :     }
     132                 :            :     else
     133                 :            :     {
     134                 :      17391 :         TypeClass eFrom   = xType->getTypeClass();
     135 [ +  + ][ +  - ]:      17391 :         if (eAssign > TypeClass_VOID && eAssign < TypeClass_STRING &&
         [ +  - ][ +  - ]
     136                 :            :             eFrom > TypeClass_VOID && eFrom < TypeClass_STRING)
     137                 :            :         {
     138                 :      16515 :             return s_aAssignableFromTab[eAssign-1][eFrom-1];
     139                 :            :         }
     140                 :            :     }
     141                 :      39251 :     return sal_False;
     142                 :            : }
     143                 :            : //__________________________________________________________________________________________________
     144                 :       7913 : void IdlClassImpl::createObject( Any & rObj )
     145                 :            :     throw(::com::sun::star::uno::RuntimeException)
     146                 :            : {
     147                 :       7913 :     rObj.clear();
     148                 :       7913 :     uno_any_destruct( &rObj, reinterpret_cast< uno_ReleaseFunc >(cpp_release) );
     149                 :       7913 :     uno_any_construct( &rObj, 0, getTypeDescr(), 0 );
     150                 :       7913 : }
     151                 :            : 
     152                 :            : // what TODO ????
     153                 :            : //__________________________________________________________________________________________________
     154                 :          0 : Sequence< Reference< XIdlClass > > IdlClassImpl::getClasses()
     155                 :            :     throw(::com::sun::star::uno::RuntimeException)
     156                 :            : {
     157                 :            :     OSL_FAIL( "### unexpected use!" );
     158                 :          0 :     return Sequence< Reference< XIdlClass > >();
     159                 :            : }
     160                 :            : //__________________________________________________________________________________________________
     161                 :          0 : Reference< XIdlClass > IdlClassImpl::getClass( const OUString & )
     162                 :            :     throw(::com::sun::star::uno::RuntimeException)
     163                 :            : {
     164                 :            :     OSL_FAIL( "### unexpected use!" );
     165                 :          0 :     return Reference< XIdlClass >();
     166                 :            : }
     167                 :            : //__________________________________________________________________________________________________
     168                 :      44381 : Sequence< Reference< XIdlClass > > IdlClassImpl::getInterfaces()
     169                 :            :     throw(::com::sun::star::uno::RuntimeException)
     170                 :            : {
     171                 :            : //      OSL_FAIL( "### unexpected use!" );
     172                 :      44381 :     return Sequence< Reference< XIdlClass > >();
     173                 :            : }
     174                 :            : 
     175                 :            : // structs, interfaces
     176                 :            : //__________________________________________________________________________________________________
     177                 :       1552 : Sequence< Reference< XIdlClass > > IdlClassImpl::getSuperclasses() throw(::com::sun::star::uno::RuntimeException)
     178                 :            : {
     179                 :       1552 :     return Sequence< Reference< XIdlClass > >();
     180                 :            : }
     181                 :            : // structs
     182                 :            : //__________________________________________________________________________________________________
     183                 :          0 : Reference< XIdlField > IdlClassImpl::getField( const OUString & )
     184                 :            :     throw(::com::sun::star::uno::RuntimeException)
     185                 :            : {
     186                 :          0 :     return Reference< XIdlField >();
     187                 :            : }
     188                 :            : //__________________________________________________________________________________________________
     189                 :          0 : Sequence< Reference< XIdlField > > IdlClassImpl::getFields()
     190                 :            :     throw(::com::sun::star::uno::RuntimeException)
     191                 :            : {
     192                 :          0 :     return Sequence< Reference< XIdlField > >();
     193                 :            : }
     194                 :            : // interfaces
     195                 :            : //__________________________________________________________________________________________________
     196                 :          0 : Uik IdlClassImpl::getUik()
     197                 :            :     throw(::com::sun::star::uno::RuntimeException)
     198                 :            : {
     199                 :          0 :     return Uik();
     200                 :            : }
     201                 :            : //__________________________________________________________________________________________________
     202                 :          0 : Reference< XIdlMethod > IdlClassImpl::getMethod( const OUString & )
     203                 :            :     throw(::com::sun::star::uno::RuntimeException)
     204                 :            : {
     205                 :          0 :     return Reference< XIdlMethod >();
     206                 :            : }
     207                 :            : //__________________________________________________________________________________________________
     208                 :          0 : Sequence< Reference< XIdlMethod > > IdlClassImpl::getMethods()
     209                 :            :     throw(::com::sun::star::uno::RuntimeException)
     210                 :            : {
     211                 :          0 :     return Sequence< Reference< XIdlMethod > >();
     212                 :            : }
     213                 :            : // array
     214                 :            : //__________________________________________________________________________________________________
     215                 :          0 : Reference< XIdlClass > IdlClassImpl::getComponentType()
     216                 :            :     throw(::com::sun::star::uno::RuntimeException)
     217                 :            : {
     218                 :          0 :     return Reference< XIdlClass >();
     219                 :            : }
     220                 :            : //__________________________________________________________________________________________________
     221                 :          0 : Reference< XIdlArray > IdlClassImpl::getArray()
     222                 :            :     throw(::com::sun::star::uno::RuntimeException)
     223                 :            : {
     224                 :          0 :     return Reference< XIdlArray >();
     225                 :            : }
     226                 :            : 
     227                 :            : 
     228                 :            : //##################################################################################################
     229                 :            : //##################################################################################################
     230                 :            : //##################################################################################################
     231                 :            : 
     232                 :            : 
     233                 :            : //__________________________________________________________________________________________________
     234                 :     144347 : IdlMemberImpl::IdlMemberImpl( IdlReflectionServiceImpl * pReflection, const OUString & rName,
     235                 :            :                               typelib_TypeDescription * pTypeDescr,
     236                 :            :                               typelib_TypeDescription * pDeclTypeDescr )
     237                 :            :     : _pReflection( pReflection )
     238                 :            :     , _aName( rName )
     239                 :            :     , _pTypeDescr( pTypeDescr )
     240                 :     144347 :     , _pDeclTypeDescr( pDeclTypeDescr )
     241                 :            : {
     242                 :     144347 :     _pReflection->acquire();
     243                 :     144347 :     typelib_typedescription_acquire( _pTypeDescr );
     244         [ +  + ]:     144347 :     if (! _pTypeDescr->bComplete)
     245                 :         36 :         typelib_typedescription_complete( &_pTypeDescr );
     246                 :     144347 :     typelib_typedescription_acquire( _pDeclTypeDescr );
     247         [ -  + ]:     144347 :     if (! _pDeclTypeDescr->bComplete)
     248                 :          0 :         typelib_typedescription_complete( &_pDeclTypeDescr );
     249                 :     144347 : }
     250                 :            : //__________________________________________________________________________________________________
     251                 :     136779 : IdlMemberImpl::~IdlMemberImpl()
     252                 :            : {
     253                 :     136779 :     typelib_typedescription_release( _pDeclTypeDescr );
     254                 :     136779 :     typelib_typedescription_release( _pTypeDescr );
     255                 :     136779 :     _pReflection->release();
     256         [ -  + ]:     136779 : }
     257                 :            : 
     258                 :            : // XIdlMember
     259                 :            : //__________________________________________________________________________________________________
     260                 :          0 : Reference< XIdlClass > IdlMemberImpl::getDeclaringClass()
     261                 :            :     throw(::com::sun::star::uno::RuntimeException)
     262                 :            : {
     263         [ #  # ]:          0 :     if (! _xDeclClass.is())
     264                 :            :     {
     265         [ #  # ]:          0 :         Reference< XIdlClass > xDeclClass( getReflection()->forType( getDeclTypeDescr() ) );
     266 [ #  # ][ #  # ]:          0 :         MutexGuard aGuard( getMutexAccess() );
     267         [ #  # ]:          0 :         if (! _xDeclClass.is())
     268 [ #  # ][ #  # ]:          0 :             _xDeclClass = xDeclClass;
     269                 :            :     }
     270                 :          0 :     return _xDeclClass;
     271                 :            : }
     272                 :            : //__________________________________________________________________________________________________
     273                 :     343993 : OUString IdlMemberImpl::getName()
     274                 :            :     throw(::com::sun::star::uno::RuntimeException)
     275                 :            : {
     276                 :     343993 :     return _aName;
     277                 :            : }
     278                 :            : 
     279                 :            : }
     280                 :            : 
     281                 :            : 
     282                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10