LCOV - code coverage report
Current view: top level - cppu/source/typelib - typelib.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 910 1097 83.0 %
Date: 2012-08-25 Functions: 50 55 90.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 567 972 58.3 %

           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                 :            : 
      21                 :            : #if OSL_DEBUG_LEVEL > 1
      22                 :            : #include <stdio.h>
      23                 :            : #endif
      24                 :            : 
      25                 :            : #include <boost/unordered_map.hpp>
      26                 :            : #include <list>
      27                 :            : #include <set>
      28                 :            : #include <vector>
      29                 :            : 
      30                 :            : #include <stdarg.h>
      31                 :            : #include <stdlib.h>
      32                 :            : #include <string.h>
      33                 :            : #include <sal/alloca.h>
      34                 :            : #include <new>
      35                 :            : #include <osl/interlck.h>
      36                 :            : #include <osl/mutex.hxx>
      37                 :            : #include <rtl/ustring.hxx>
      38                 :            : #include <rtl/ustrbuf.hxx>
      39                 :            : #include <rtl/alloc.h>
      40                 :            : #include <rtl/instance.hxx>
      41                 :            : #include <osl/diagnose.h>
      42                 :            : #include <typelib/typedescription.h>
      43                 :            : #include <uno/any2.h>
      44                 :            : 
      45                 :            : using namespace std;
      46                 :            : using namespace osl;
      47                 :            : 
      48                 :            : using ::rtl::OUString;
      49                 :            : using ::rtl::OUStringBuffer;
      50                 :            : using ::rtl::OString;
      51                 :            : 
      52                 :            : #ifdef SAL_W32
      53                 :            : #pragma pack(push, 8)
      54                 :            : #endif
      55                 :            : 
      56                 :            : /**
      57                 :            :  * The double member determin the alignment.
      58                 :            :  * Under Os2 and MS-Windows the Alignment is min( 8, sizeof( type ) ).
      59                 :            :  * The aligment of a strukture is min( 8, sizeof( max basic type ) ), the greatest basic type
      60                 :            :  * determine the aligment.
      61                 :            :  */
      62                 :            : struct AlignSize_Impl
      63                 :            : {
      64                 :            :     sal_Int16 nInt16;
      65                 :            : #ifdef AIX
      66                 :            :     //double: doubleword aligned if -qalign=natural/-malign=natural
      67                 :            :     //which isn't the default ABI. Otherwise word aligned, While a long long int
      68                 :            :     //is always doubleword aligned, so use that instead.
      69                 :            :     sal_Int64 dDouble;
      70                 :            : #else
      71                 :            :     double dDouble;
      72                 :            : #endif
      73                 :            : };
      74                 :            : 
      75                 :            : #ifdef SAL_W32
      76                 :            : #pragma pack(pop)
      77                 :            : #endif
      78                 :            : 
      79                 :            : // the value of the maximal alignment
      80                 :            : static sal_Int32 nMaxAlignment = (sal_Int32)( (sal_Size)(&((AlignSize_Impl *) 16)->dDouble) - 16);
      81                 :            : 
      82                 :     716819 : static inline sal_Int32 adjustAlignment( sal_Int32 nRequestedAlignment )
      83                 :            :     SAL_THROW(())
      84                 :            : {
      85         [ +  + ]:     716819 :     if( nRequestedAlignment > nMaxAlignment )
      86                 :       4644 :         nRequestedAlignment = nMaxAlignment;
      87                 :     716819 :     return nRequestedAlignment;
      88                 :            : }
      89                 :            : 
      90                 :            : /**
      91                 :            :  * Calculate the new size of the struktur.
      92                 :            :  */
      93                 :     425703 : static inline sal_Int32 newAlignedSize(
      94                 :            :     sal_Int32 OldSize, sal_Int32 ElementSize, sal_Int32 NeededAlignment )
      95                 :            :     SAL_THROW(())
      96                 :            : {
      97                 :     425703 :     NeededAlignment = adjustAlignment( NeededAlignment );
      98                 :     425703 :     return (OldSize + NeededAlignment -1) / NeededAlignment * NeededAlignment + ElementSize;
      99                 :            : }
     100                 :            : 
     101                 :  191581310 : static inline sal_Bool reallyWeak( typelib_TypeClass eTypeClass )
     102                 :            :     SAL_THROW(())
     103                 :            : {
     104 [ +  + ][ +  + ]:  191581310 :     return TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK( eTypeClass );
     105                 :            : }
     106                 :            : 
     107                 :      60042 : static inline sal_Int32 getDescriptionSize( typelib_TypeClass eTypeClass )
     108                 :            :     SAL_THROW(())
     109                 :            : {
     110                 :            :     OSL_ASSERT( typelib_TypeClass_TYPEDEF != eTypeClass );
     111                 :            : 
     112                 :            :     sal_Int32 nSize;
     113                 :            :     // The reference is the description
     114                 :            :     // if the description is empty, than it must be filled with
     115                 :            :     // the new description
     116   [ -  +  -  +  :      60042 :     switch( eTypeClass )
          +  +  +  -  -  
                      + ]
     117                 :            :     {
     118                 :            :         case typelib_TypeClass_ARRAY:
     119                 :          0 :             nSize = (sal_Int32)sizeof( typelib_ArrayTypeDescription );
     120                 :          0 :         break;
     121                 :            : 
     122                 :            :         case typelib_TypeClass_SEQUENCE:
     123                 :        303 :             nSize = (sal_Int32)sizeof( typelib_IndirectTypeDescription );
     124                 :        303 :         break;
     125                 :            : 
     126                 :            :         case typelib_TypeClass_UNION:
     127                 :          0 :             nSize = (sal_Int32)sizeof( typelib_UnionTypeDescription );
     128                 :          0 :         break;
     129                 :            : 
     130                 :            :         case typelib_TypeClass_STRUCT:
     131                 :       6282 :             nSize = (sal_Int32)sizeof( typelib_StructTypeDescription );
     132                 :       6282 :         break;
     133                 :            : 
     134                 :            :         case typelib_TypeClass_EXCEPTION:
     135                 :       5369 :             nSize = (sal_Int32)sizeof( typelib_CompoundTypeDescription );
     136                 :       5369 :         break;
     137                 :            : 
     138                 :            :         case typelib_TypeClass_ENUM:
     139                 :       1942 :             nSize = (sal_Int32)sizeof( typelib_EnumTypeDescription );
     140                 :       1942 :         break;
     141                 :            : 
     142                 :            :         case typelib_TypeClass_INTERFACE:
     143                 :      43765 :             nSize = (sal_Int32)sizeof( typelib_InterfaceTypeDescription );
     144                 :      43765 :         break;
     145                 :            : 
     146                 :            :         case typelib_TypeClass_INTERFACE_METHOD:
     147                 :          0 :             nSize = (sal_Int32)sizeof( typelib_InterfaceMethodTypeDescription );
     148                 :          0 :         break;
     149                 :            : 
     150                 :            :         case typelib_TypeClass_INTERFACE_ATTRIBUTE:
     151                 :          0 :             nSize = (sal_Int32)sizeof( typelib_InterfaceAttributeTypeDescription );
     152                 :          0 :         break;
     153                 :            : 
     154                 :            :         default:
     155                 :       2381 :             nSize = (sal_Int32)sizeof( typelib_TypeDescription );
     156                 :            :     }
     157                 :      60042 :     return nSize;
     158                 :            : }
     159                 :            : 
     160                 :            : 
     161                 :            : //-----------------------------------------------------------------------------
     162                 :            : extern "C" void SAL_CALL typelib_typedescriptionreference_getByName(
     163                 :            :     typelib_TypeDescriptionReference ** ppRet, rtl_uString * pName )
     164                 :            :     SAL_THROW_EXTERN_C();
     165                 :            : 
     166                 :            : //-----------------------------------------------------------------------------
     167                 :            : struct equalStr_Impl
     168                 :            : {
     169                 :    4709266 :     sal_Bool operator()(const sal_Unicode * const & s1, const sal_Unicode * const & s2) const SAL_THROW(())
     170                 :    4709266 :         { return 0 == rtl_ustr_compare( s1, s2 ); }
     171                 :            : };
     172                 :            : 
     173                 :            : //-----------------------------------------------------------------------------
     174                 :            : struct hashStr_Impl
     175                 :            : {
     176                 :    6318514 :     size_t operator()(const sal_Unicode * const & s) const SAL_THROW(())
     177                 :    6318514 :         { return rtl_ustr_hashCode( s ); }
     178                 :            : };
     179                 :            : 
     180                 :            : 
     181                 :            : //-----------------------------------------------------------------------------
     182                 :            : // Heavy hack, the const sal_Unicode * is hold by the typedescription reference
     183                 :            : typedef boost::unordered_map< const sal_Unicode *, typelib_TypeDescriptionReference *,
     184                 :            :                   hashStr_Impl, equalStr_Impl > WeakMap_Impl;
     185                 :            : 
     186                 :            : typedef pair< void *, typelib_typedescription_Callback > CallbackEntry;
     187                 :            : typedef list< CallbackEntry > CallbackSet_Impl;
     188                 :            : typedef list< typelib_TypeDescription * > TypeDescriptionList_Impl;
     189                 :            : 
     190                 :            : // # of cached elements
     191                 :            : static sal_Int32 nCacheSize = 256;
     192                 :            : 
     193                 :            : struct TypeDescriptor_Init_Impl
     194                 :            : {
     195                 :            :     //sal_Bool          bDesctructorCalled;
     196                 :            :     // all type description references
     197                 :            :     WeakMap_Impl *              pWeakMap;
     198                 :            :     // all type description callbacks
     199                 :            :     CallbackSet_Impl *          pCallbacks;
     200                 :            :     // A cache to hold descriptions
     201                 :            :     TypeDescriptionList_Impl *  pCache;
     202                 :            :     // The mutex to guard all type library accesses
     203                 :            :     Mutex *                     pMutex;
     204                 :            : 
     205                 :            :     inline Mutex & getMutex() SAL_THROW(());
     206                 :            : 
     207                 :            :     inline void callChain( typelib_TypeDescription ** ppRet, rtl_uString * pName ) SAL_THROW(());
     208                 :            : 
     209                 :            : #if OSL_DEBUG_LEVEL > 1
     210                 :            :     // only for debugging
     211                 :            :     sal_Int32           nTypeDescriptionCount;
     212                 :            :     sal_Int32           nCompoundTypeDescriptionCount;
     213                 :            :     sal_Int32           nUnionTypeDescriptionCount;
     214                 :            :     sal_Int32           nIndirectTypeDescriptionCount;
     215                 :            :     sal_Int32           nArrayTypeDescriptionCount;
     216                 :            :     sal_Int32           nEnumTypeDescriptionCount;
     217                 :            :     sal_Int32           nInterfaceMethodTypeDescriptionCount;
     218                 :            :     sal_Int32           nInterfaceAttributeTypeDescriptionCount;
     219                 :            :     sal_Int32           nInterfaceTypeDescriptionCount;
     220                 :            :     sal_Int32           nTypeDescriptionReferenceCount;
     221                 :            : #endif
     222                 :            : 
     223                 :        782 :     TypeDescriptor_Init_Impl():
     224                 :        782 :         pWeakMap(0), pCallbacks(0), pCache(0), pMutex(0)
     225                 :            : #if OSL_DEBUG_LEVEL > 1
     226                 :            :         , nTypeDescriptionCount(0), nCompoundTypeDescriptionCount(0),
     227                 :            :         nUnionTypeDescriptionCount(0), nIndirectTypeDescriptionCount(0),
     228                 :            :         nArrayTypeDescriptionCount(0), nEnumTypeDescriptionCount(0),
     229                 :            :         nInterfaceMethodTypeDescriptionCount(0),
     230                 :            :         nInterfaceAttributeTypeDescriptionCount(0),
     231                 :            :         nInterfaceTypeDescriptionCount(0), nTypeDescriptionReferenceCount(0)
     232                 :            : #endif
     233                 :        782 :     {}
     234                 :            : 
     235                 :            :     ~TypeDescriptor_Init_Impl() SAL_THROW(());
     236                 :            : };
     237                 :            : //__________________________________________________________________________________________________
     238                 :   11639747 : inline Mutex & TypeDescriptor_Init_Impl::getMutex() SAL_THROW(())
     239                 :            : {
     240         [ +  + ]:   11639747 :     if( !pMutex )
     241                 :            :     {
     242 [ +  - ][ +  - ]:        782 :         MutexGuard aGuard( Mutex::getGlobalMutex() );
     243         [ +  - ]:        782 :         if( !pMutex )
     244 [ +  - ][ +  - ]:        782 :             pMutex = new Mutex();
                 [ +  - ]
     245                 :            :     }
     246                 :   11639747 :     return * pMutex;
     247                 :            : }
     248                 :            : //__________________________________________________________________________________________________
     249                 :      86001 : inline void TypeDescriptor_Init_Impl::callChain(
     250                 :            :     typelib_TypeDescription ** ppRet, rtl_uString * pName )
     251                 :            :     SAL_THROW(())
     252                 :            : {
     253         [ +  - ]:      86001 :     if (pCallbacks)
     254                 :            :     {
     255                 :      86001 :         CallbackSet_Impl::const_iterator aIt = pCallbacks->begin();
     256         [ +  + ]:     172002 :         while( aIt != pCallbacks->end() )
     257                 :            :         {
     258                 :      86001 :             const CallbackEntry & rEntry = *aIt;
     259         [ +  - ]:      86001 :             (*rEntry.second)( rEntry.first, ppRet, pName );
     260         [ +  + ]:      86001 :             if( *ppRet )
     261                 :      86001 :                 return;
     262                 :       2810 :             ++aIt;
     263                 :            :         }
     264                 :            :     }
     265         [ -  + ]:       2810 :     if (*ppRet)
     266                 :            :     {
     267                 :          0 :         typelib_typedescription_release( *ppRet );
     268                 :          0 :         *ppRet = 0;
     269                 :            :     }
     270                 :            : }
     271                 :            : 
     272                 :            : //__________________________________________________________________________________________________
     273                 :        782 : TypeDescriptor_Init_Impl::~TypeDescriptor_Init_Impl() SAL_THROW(())
     274                 :            : {
     275         [ +  + ]:        782 :     if( pCache )
     276                 :            :     {
     277                 :        343 :         TypeDescriptionList_Impl::const_iterator aIt = pCache->begin();
     278         [ +  + ]:      54189 :         while( aIt != pCache->end() )
     279                 :            :         {
     280                 :      53846 :             typelib_typedescription_release( (*aIt) );
     281                 :      53846 :             ++aIt;
     282                 :            :         }
     283         [ +  - ]:        343 :         delete pCache;
     284                 :        343 :         pCache = 0;
     285                 :            :     }
     286                 :            : 
     287         [ +  - ]:        782 :     if( pWeakMap )
     288                 :            :     {
     289         [ +  - ]:        782 :         std::vector< typelib_TypeDescriptionReference * > ppTDR;
     290                 :            :         // save al weak references
     291         [ +  - ]:        782 :         WeakMap_Impl::const_iterator aIt = pWeakMap->begin();
     292 [ +  - ][ +  + ]:     785020 :         while( aIt != pWeakMap->end() )
     293                 :            :         {
     294 [ +  - ][ +  - ]:     784238 :             ppTDR.push_back( (*aIt).second );
     295         [ +  - ]:     784238 :             typelib_typedescriptionreference_acquire( ppTDR.back() );
     296                 :     784238 :             ++aIt;
     297                 :            :         }
     298                 :            : 
     299 [ +  + ][ +  - ]:    1570040 :         for( std::vector< typelib_TypeDescriptionReference * >::iterator i(
     300                 :        782 :                  ppTDR.begin() );
     301                 :     785020 :              i != ppTDR.end(); ++i )
     302                 :            :         {
     303                 :     784238 :             typelib_TypeDescriptionReference * pTDR = *i;
     304                 :            :             OSL_ASSERT( pTDR->nRefCount > pTDR->nStaticRefCount );
     305                 :     784238 :             pTDR->nRefCount -= pTDR->nStaticRefCount;
     306                 :            : 
     307 [ +  + ][ +  + ]:     784238 :             if( pTDR->pType && !pTDR->pType->bOnDemand )
     308                 :            :             {
     309                 :     180332 :                 pTDR->pType->bOnDemand = sal_True;
     310                 :     180332 :                 typelib_typedescription_release( pTDR->pType );
     311                 :            :             }
     312                 :     784238 :             typelib_typedescriptionreference_release( pTDR );
     313                 :            :         }
     314                 :            : 
     315                 :            : #if OSL_DEBUG_LEVEL > 1
     316                 :            :         aIt = pWeakMap->begin();
     317                 :            :         while( aIt != pWeakMap->end() )
     318                 :            :         {
     319                 :            :             typelib_TypeDescriptionReference * pTDR = (*aIt).second;
     320                 :            :             if (pTDR)
     321                 :            :             {
     322                 :            :                 OString aTypeName( rtl::OUStringToOString( pTDR->pTypeName, RTL_TEXTENCODING_ASCII_US ) );
     323                 :            :                 OSL_TRACE(
     324                 :            :                     "### remaining type: %s; ref count = %d", aTypeName.getStr(), pTDR->nRefCount );
     325                 :            :             }
     326                 :            :             else
     327                 :            :             {
     328                 :            :                 OSL_TRACE( "### remaining null type entry!?" );
     329                 :            :             }
     330                 :            :             ++aIt;
     331                 :            :         }
     332                 :            : #endif
     333                 :            : 
     334 [ +  - ][ +  - ]:        782 :         delete pWeakMap;
     335                 :        782 :         pWeakMap = 0;
     336                 :            :     }
     337                 :            : #if OSL_DEBUG_LEVEL > 1
     338                 :            :     OSL_ENSURE( !nTypeDescriptionCount, "### nTypeDescriptionCount is not zero" );
     339                 :            :     OSL_ENSURE( !nCompoundTypeDescriptionCount, "### nCompoundTypeDescriptionCount is not zero" );
     340                 :            :     OSL_ENSURE( !nUnionTypeDescriptionCount, "### nUnionTypeDescriptionCount is not zero" );
     341                 :            :     OSL_ENSURE( !nIndirectTypeDescriptionCount, "### nIndirectTypeDescriptionCount is not zero" );
     342                 :            :     OSL_ENSURE( !nArrayTypeDescriptionCount, "### nArrayTypeDescriptionCount is not zero" );
     343                 :            :     OSL_ENSURE( !nEnumTypeDescriptionCount, "### nEnumTypeDescriptionCount is not zero" );
     344                 :            :     OSL_ENSURE( !nInterfaceMethodTypeDescriptionCount, "### nInterfaceMethodTypeDescriptionCount is not zero" );
     345                 :            :     OSL_ENSURE( !nInterfaceAttributeTypeDescriptionCount, "### nInterfaceAttributeTypeDescriptionCount is not zero" );
     346                 :            :     OSL_ENSURE( !nInterfaceTypeDescriptionCount, "### nInterfaceTypeDescriptionCount is not zero" );
     347                 :            :     OSL_ENSURE( !nTypeDescriptionReferenceCount, "### nTypeDescriptionReferenceCount is not zero" );
     348                 :            : 
     349                 :            :     OSL_ENSURE( !pCallbacks || pCallbacks->empty(), "### pCallbacks is not NULL or empty" );
     350                 :            : #endif
     351                 :            : 
     352         [ +  + ]:        782 :     delete pCallbacks;
     353                 :        782 :     pCallbacks = 0;
     354                 :            : 
     355         [ +  - ]:        782 :     if( pMutex )
     356                 :            :     {
     357         [ +  - ]:        782 :         delete pMutex;
     358                 :        782 :         pMutex = 0;
     359                 :            :     }
     360                 :        782 : };
     361                 :            : 
     362                 :            : namespace { struct Init : public rtl::Static< TypeDescriptor_Init_Impl, Init > {}; }
     363                 :            : 
     364                 :        756 : extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_registerCallback(
     365                 :            :     void * pContext, typelib_typedescription_Callback pCallback )
     366                 :            :     SAL_THROW_EXTERN_C()
     367                 :            : {
     368                 :            :     // todo mt safe: guard is no solution, can not acquire while calling callback!
     369                 :        756 :     TypeDescriptor_Init_Impl &rInit = Init::get();
     370                 :            : //      OslGuard aGuard( rInit.getMutex() );
     371         [ +  + ]:        756 :     if( !rInit.pCallbacks )
     372         [ +  - ]:        742 :         rInit.pCallbacks = new CallbackSet_Impl;
     373         [ +  - ]:        756 :     rInit.pCallbacks->push_back( CallbackEntry( pContext, pCallback ) );
     374                 :        756 : }
     375                 :            : 
     376                 :            : //------------------------------------------------------------------------
     377                 :        360 : extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_revokeCallback(
     378                 :            :     void * pContext, typelib_typedescription_Callback pCallback )
     379                 :            :     SAL_THROW_EXTERN_C()
     380                 :            : {
     381                 :        360 :     TypeDescriptor_Init_Impl &rInit = Init::get();
     382         [ +  - ]:        360 :     if( rInit.pCallbacks )
     383                 :            :     {
     384                 :            :         // todo mt safe: guard is no solution, can not acquire while calling callback!
     385                 :            : //          OslGuard aGuard( rInit.getMutex() );
     386                 :        360 :         CallbackEntry aEntry( pContext, pCallback );
     387                 :        360 :         CallbackSet_Impl::iterator iPos( rInit.pCallbacks->begin() );
     388         [ +  + ]:        741 :         while (!(iPos == rInit.pCallbacks->end()))
     389                 :            :         {
     390         [ +  + ]:        381 :             if (*iPos == aEntry)
     391                 :            :             {
     392         [ +  - ]:        360 :                 rInit.pCallbacks->erase( iPos );
     393                 :        360 :                 iPos = rInit.pCallbacks->begin();
     394                 :            :             }
     395                 :            :             else
     396                 :            :             {
     397                 :         21 :                 ++iPos;
     398                 :            :             }
     399                 :            :         }
     400                 :            :     }
     401                 :        360 : }
     402                 :            : 
     403                 :            : extern "C" sal_Int32 SAL_CALL typelib_typedescription_getAlignedUnoSize(
     404                 :            :     const typelib_TypeDescription * pTypeDescription,
     405                 :            :     sal_Int32 nOffset, sal_Int32 & rMaxIntegralTypeSize )
     406                 :            :     SAL_THROW_EXTERN_C();
     407                 :            : 
     408                 :            : //------------------------------------------------------------------------
     409                 :      22025 : static inline void typelib_typedescription_initTables(
     410                 :            :     typelib_TypeDescription * pTD )
     411                 :            :     SAL_THROW(())
     412                 :            : {
     413                 :      22025 :     typelib_InterfaceTypeDescription * pITD = (typelib_InterfaceTypeDescription *)pTD;
     414                 :            : 
     415                 :      22025 :     sal_Bool * pReadWriteAttributes = (sal_Bool *)alloca( pITD->nAllMembers );
     416         [ +  + ]:     188228 :     for ( sal_Int32 i = pITD->nAllMembers; i--; )
     417                 :            :     {
     418                 :     166203 :         pReadWriteAttributes[i] = sal_False;
     419         [ +  + ]:     166203 :         if( typelib_TypeClass_INTERFACE_ATTRIBUTE == pITD->ppAllMembers[i]->eTypeClass )
     420                 :            :         {
     421                 :       7002 :             typelib_TypeDescription * pM = 0;
     422 [ +  - ][ +  - ]:       7002 :             TYPELIB_DANGER_GET( &pM, pITD->ppAllMembers[i] );
         [ #  # ][ #  # ]
                 [ #  # ]
     423                 :            :             OSL_ASSERT( pM );
     424         [ +  - ]:       7002 :             if (pM)
     425                 :            :             {
     426                 :       7002 :                 pReadWriteAttributes[i] = !((typelib_InterfaceAttributeTypeDescription *)pM)->bReadOnly;
     427 [ +  - ][ +  - ]:       7002 :                 TYPELIB_DANGER_RELEASE( pM );
     428                 :            :             }
     429                 :            : #if OSL_DEBUG_LEVEL > 1
     430                 :            :             else
     431                 :            :             {
     432                 :            :                 OString aStr( rtl::OUStringToOString( pITD->ppAllMembers[i]->pTypeName, RTL_TEXTENCODING_ASCII_US ) );
     433                 :            :                 OSL_TRACE( "\n### cannot get attribute type description: %s", aStr.getStr() );
     434                 :            :             }
     435                 :            : #endif
     436                 :            :         }
     437                 :            :     }
     438                 :            : 
     439 [ +  - ][ +  - ]:      22025 :     MutexGuard aGuard( Init::get().getMutex() );
     440         [ +  - ]:      22025 :     if( !pTD->bComplete )
     441                 :            :     {
     442                 :            :         // create the index table from member to function table
     443         [ +  - ]:      22025 :         pITD->pMapMemberIndexToFunctionIndex = new sal_Int32[ pITD->nAllMembers ];
     444                 :      22025 :         sal_Int32 nAdditionalOffset = 0; // +1 for read/write attributes
     445                 :            :         sal_Int32 i;
     446         [ +  + ]:     188228 :         for( i = 0; i < pITD->nAllMembers; i++ )
     447                 :            :         {
     448                 :            :             // index to the get method of the attribute
     449                 :     166203 :             pITD->pMapMemberIndexToFunctionIndex[i] = i + nAdditionalOffset;
     450                 :            :             // extra offset if it is a read/write attribute?
     451         [ +  + ]:     166203 :             if( pReadWriteAttributes[i] )
     452                 :            :             {
     453                 :            :                 // a read/write attribute
     454                 :       4200 :                 nAdditionalOffset++;
     455                 :            :             }
     456                 :            :         }
     457                 :            : 
     458                 :            :         // create the index table from function to member table
     459         [ +  - ]:      22025 :         pITD->pMapFunctionIndexToMemberIndex = new sal_Int32[ pITD->nAllMembers + nAdditionalOffset ];
     460                 :      22025 :         nAdditionalOffset = 0; // +1 for read/write attributes
     461         [ +  + ]:     188228 :         for( i = 0; i < pITD->nAllMembers; i++ )
     462                 :            :         {
     463                 :            :             // index to the get method of the attribute
     464                 :     166203 :             pITD->pMapFunctionIndexToMemberIndex[i + nAdditionalOffset] = i;
     465                 :            :             // extra offset if it is a read/write attribute?
     466         [ +  + ]:     166203 :             if( pReadWriteAttributes[i] )
     467                 :            :             {
     468                 :            :                 // a read/write attribute
     469                 :       4200 :                 pITD->pMapFunctionIndexToMemberIndex[i + ++nAdditionalOffset] = i;
     470                 :            :             }
     471                 :            :         }
     472                 :            :         // must be the last action after all initialization is done
     473                 :      22025 :         pITD->nMapFunctionIndexToMemberIndex = pITD->nAllMembers + nAdditionalOffset;
     474                 :      22025 :         pTD->bComplete = sal_True;
     475         [ +  - ]:      22025 :     }
     476                 :      22025 : }
     477                 :            : 
     478                 :            : namespace {
     479                 :            : 
     480                 :            : // In some situations (notably typelib_typedescription_newInterfaceMethod and
     481                 :            : // typelib_typedescription_newInterfaceAttribute), only the members nMembers,
     482                 :            : // ppMembers, nAllMembers, and ppAllMembers of an incomplete interface type
     483                 :            : // description are necessary, but not the additional
     484                 :            : // pMapMemberIndexToFunctionIndex, nMapFunctionIndexToMemberIndex, and
     485                 :            : // pMapFunctionIndexToMemberIndex (which are computed by
     486                 :            : // typelib_typedescription_initTables).  Furthermore, in those situations, it
     487                 :            : // might be illegal to compute those tables, as the creation of the interface
     488                 :            : // member type descriptions would recursively require a complete interface type
     489                 :            : // description.  The parameter initTables controls whether or not to call
     490                 :            : // typelib_typedescription_initTables in those situations.
     491                 :    1426708 : bool complete(typelib_TypeDescription ** ppTypeDescr, bool initTables) {
     492         [ +  + ]:    1426708 :     if (! (*ppTypeDescr)->bComplete)
     493                 :            :     {
     494                 :            :         OSL_ASSERT( (typelib_TypeClass_STRUCT == (*ppTypeDescr)->eTypeClass ||
     495                 :            :                      typelib_TypeClass_EXCEPTION == (*ppTypeDescr)->eTypeClass ||
     496                 :            :                      typelib_TypeClass_UNION == (*ppTypeDescr)->eTypeClass ||
     497                 :            :                      typelib_TypeClass_ENUM == (*ppTypeDescr)->eTypeClass ||
     498                 :            :                      typelib_TypeClass_INTERFACE == (*ppTypeDescr)->eTypeClass) &&
     499                 :            :                     !reallyWeak( (*ppTypeDescr)->eTypeClass ) );
     500                 :            : 
     501 [ +  - ][ +  - ]:     447135 :         if (typelib_TypeClass_INTERFACE == (*ppTypeDescr)->eTypeClass &&
     502                 :            :             ((typelib_InterfaceTypeDescription *)*ppTypeDescr)->ppAllMembers)
     503                 :            :         {
     504         [ +  + ]:     447135 :             if (initTables) {
     505         [ +  - ]:      22025 :                 typelib_typedescription_initTables( *ppTypeDescr );
     506                 :            :             }
     507                 :     447135 :             return true;
     508                 :            :         }
     509                 :            : 
     510                 :          0 :         typelib_TypeDescription * pTD = 0;
     511                 :            :         // on demand access of complete td
     512                 :          0 :         TypeDescriptor_Init_Impl &rInit = Init::get();
     513         [ #  # ]:          0 :         rInit.callChain( &pTD, (*ppTypeDescr)->pTypeName );
     514         [ #  # ]:          0 :         if (pTD)
     515                 :            :         {
     516         [ #  # ]:          0 :             if (typelib_TypeClass_TYPEDEF == pTD->eTypeClass)
     517                 :            :             {
     518                 :            :                 typelib_typedescriptionreference_getDescription(
     519                 :          0 :                     &pTD, ((typelib_IndirectTypeDescription *)pTD)->pType );
     520                 :            :                 OSL_ASSERT( pTD );
     521         [ #  # ]:          0 :                 if (! pTD)
     522                 :          0 :                     return false;
     523                 :            :             }
     524                 :            : 
     525                 :            :             OSL_ASSERT( typelib_TypeClass_TYPEDEF != pTD->eTypeClass );
     526                 :            :             // typedescription found
     527                 :            :             // set to on demand
     528                 :          0 :             pTD->bOnDemand = sal_True;
     529                 :            : 
     530 [ #  # ][ #  # ]:          0 :             if (pTD->eTypeClass == typelib_TypeClass_INTERFACE
                 [ #  # ]
     531                 :          0 :                 && !pTD->bComplete && initTables)
     532                 :            :             {
     533                 :            :                 // mandatory info from callback chain
     534                 :            :                 OSL_ASSERT( ((typelib_InterfaceTypeDescription *)pTD)->ppAllMembers );
     535                 :            :                 // complete except of tables init
     536         [ #  # ]:          0 :                 typelib_typedescription_initTables( pTD );
     537                 :          0 :                 pTD->bComplete = sal_True;
     538                 :            :             }
     539                 :            : 
     540                 :            :             // The type description is hold by the reference until
     541                 :            :             // on demand is activated.
     542                 :          0 :             ::typelib_typedescription_register( &pTD ); // replaces incomplete one
     543                 :            :             OSL_ASSERT( pTD == *ppTypeDescr ); // has to merge into existing one
     544                 :            : 
     545                 :            :             // insert into the chache
     546 [ #  # ][ #  # ]:          0 :             MutexGuard aGuard( rInit.getMutex() );
     547         [ #  # ]:          0 :             if( !rInit.pCache )
     548 [ #  # ][ #  # ]:          0 :                 rInit.pCache = new TypeDescriptionList_Impl;
     549         [ #  # ]:          0 :             if( (sal_Int32)rInit.pCache->size() >= nCacheSize )
     550                 :            :             {
     551         [ #  # ]:          0 :                 typelib_typedescription_release( rInit.pCache->front() );
     552         [ #  # ]:          0 :                 rInit.pCache->pop_front();
     553                 :            :             }
     554                 :            :             // descriptions in the cache must be acquired!
     555                 :          0 :             typelib_typedescription_acquire( pTD );
     556         [ #  # ]:          0 :             rInit.pCache->push_back( pTD );
     557                 :            : 
     558                 :            :             OSL_ASSERT(
     559                 :            :                 pTD->bComplete
     560                 :            :                 || (pTD->eTypeClass == typelib_TypeClass_INTERFACE
     561                 :            :                     && !initTables));
     562                 :            : 
     563                 :          0 :             ::typelib_typedescription_release( *ppTypeDescr );
     564         [ #  # ]:          0 :             *ppTypeDescr = pTD;
     565                 :            :         }
     566                 :            :         else
     567                 :            :         {
     568                 :            : #if OSL_DEBUG_LEVEL > 1
     569                 :            :             OString aStr(
     570                 :            :                 rtl::OUStringToOString( (*ppTypeDescr)->pTypeName, RTL_TEXTENCODING_ASCII_US ) );
     571                 :            :             OSL_TRACE( "\n### type cannot be completed: %s", aStr.getStr() );
     572                 :            : #endif
     573                 :     447135 :             return false;
     574                 :            :         }
     575                 :            :     }
     576                 :    1426708 :     return true;
     577                 :            : }
     578                 :            : 
     579                 :            : }
     580                 :            : 
     581                 :            : //------------------------------------------------------------------------
     582                 :     857853 : extern "C" void SAL_CALL typelib_typedescription_newEmpty(
     583                 :            :     typelib_TypeDescription ** ppRet,
     584                 :            :     typelib_TypeClass eTypeClass, rtl_uString * pTypeName )
     585                 :            :     SAL_THROW_EXTERN_C()
     586                 :            : {
     587         [ +  + ]:     857853 :     if( *ppRet )
     588                 :            :     {
     589                 :      11580 :         typelib_typedescription_release( *ppRet );
     590                 :      11580 :         *ppRet = 0;
     591                 :            :     }
     592                 :            : 
     593                 :            :     OSL_ASSERT( typelib_TypeClass_TYPEDEF != eTypeClass );
     594                 :            : 
     595                 :            :     typelib_TypeDescription * pRet;
     596   [ -  +  -  +  :     857853 :     switch( eTypeClass )
          +  +  +  +  +  
                      + ]
     597                 :            :     {
     598                 :            :         case typelib_TypeClass_ARRAY:
     599                 :            :         {
     600                 :          0 :             typelib_ArrayTypeDescription * pTmp = new typelib_ArrayTypeDescription();
     601                 :          0 :             typelib_IndirectTypeDescription * pIndirect = (typelib_IndirectTypeDescription *)pTmp;
     602                 :          0 :             pRet = (typelib_TypeDescription *)pTmp;
     603                 :            : #if OSL_DEBUG_LEVEL > 1
     604                 :            :             osl_incrementInterlockedCount(
     605                 :            :                 &Init::get().nArrayTypeDescriptionCount );
     606                 :            : #endif
     607                 :          0 :             pIndirect->pType = 0;
     608                 :          0 :             pTmp->nDimensions = 0;
     609                 :          0 :             pTmp->nTotalElements = 0;
     610                 :          0 :             pTmp->pDimensions = 0;
     611                 :            :         }
     612                 :          0 :         break;
     613                 :            : 
     614                 :            :         case typelib_TypeClass_SEQUENCE:
     615                 :            :         {
     616                 :      18385 :             typelib_IndirectTypeDescription * pTmp = new typelib_IndirectTypeDescription();
     617                 :      18385 :             pRet = (typelib_TypeDescription *)pTmp;
     618                 :            : #if OSL_DEBUG_LEVEL > 1
     619                 :            :             osl_incrementInterlockedCount(
     620                 :            :                 &Init::get().nIndirectTypeDescriptionCount );
     621                 :            : #endif
     622                 :      18385 :             pTmp->pType = 0;
     623                 :            :         }
     624                 :      18385 :         break;
     625                 :            : 
     626                 :            :         case typelib_TypeClass_UNION:
     627                 :            :         {
     628                 :            :             typelib_UnionTypeDescription * pTmp;
     629                 :          0 :             pTmp = new typelib_UnionTypeDescription();
     630                 :          0 :             pRet = (typelib_TypeDescription *)pTmp;
     631                 :            : #if OSL_DEBUG_LEVEL > 1
     632                 :            :             osl_incrementInterlockedCount(
     633                 :            :                 &Init::get().nUnionTypeDescriptionCount );
     634                 :            : #endif
     635                 :          0 :             pTmp->nMembers = 0;
     636                 :          0 :             pTmp->pDiscriminantTypeRef = 0;
     637                 :          0 :             pTmp->pDiscriminants = 0;
     638                 :          0 :             pTmp->ppTypeRefs = 0;
     639                 :          0 :             pTmp->ppMemberNames = 0;
     640                 :          0 :             pTmp->pDefaultTypeRef = 0;
     641                 :            :         }
     642                 :          0 :         break;
     643                 :            : 
     644                 :            :         case typelib_TypeClass_STRUCT:
     645                 :            :         {
     646                 :            :             // FEATURE_EMPTYCLASS
     647                 :            :             typelib_StructTypeDescription * pTmp;
     648                 :      24726 :             pTmp = new typelib_StructTypeDescription();
     649                 :      24726 :             pRet = (typelib_TypeDescription *)pTmp;
     650                 :            : #if OSL_DEBUG_LEVEL > 1
     651                 :            :             osl_incrementInterlockedCount(
     652                 :            :                 &Init::get().nCompoundTypeDescriptionCount );
     653                 :            : #endif
     654                 :      24726 :             pTmp->aBase.pBaseTypeDescription = 0;
     655                 :      24726 :             pTmp->aBase.nMembers = 0;
     656                 :      24726 :             pTmp->aBase.pMemberOffsets = 0;
     657                 :      24726 :             pTmp->aBase.ppTypeRefs = 0;
     658                 :      24726 :             pTmp->aBase.ppMemberNames = 0;
     659                 :      24726 :             pTmp->pParameterizedTypes = 0;
     660                 :            :         }
     661                 :      24726 :         break;
     662                 :            : 
     663                 :            :         case typelib_TypeClass_EXCEPTION:
     664                 :            :         {
     665                 :            :             // FEATURE_EMPTYCLASS
     666                 :            :             typelib_CompoundTypeDescription * pTmp;
     667                 :      32605 :             pTmp = new typelib_CompoundTypeDescription();
     668                 :      32605 :             pRet = (typelib_TypeDescription *)pTmp;
     669                 :            : #if OSL_DEBUG_LEVEL > 1
     670                 :            :             osl_incrementInterlockedCount(
     671                 :            :                 &Init::get().nCompoundTypeDescriptionCount );
     672                 :            : #endif
     673                 :      32605 :             pTmp->pBaseTypeDescription = 0;
     674                 :      32605 :             pTmp->nMembers = 0;
     675                 :      32605 :             pTmp->pMemberOffsets = 0;
     676                 :      32605 :             pTmp->ppTypeRefs = 0;
     677                 :      32605 :             pTmp->ppMemberNames = 0;
     678                 :            :         }
     679                 :      32605 :         break;
     680                 :            : 
     681                 :            :         case typelib_TypeClass_ENUM:
     682                 :            :         {
     683                 :      10301 :             typelib_EnumTypeDescription * pTmp = new typelib_EnumTypeDescription();
     684                 :      10301 :             pRet = (typelib_TypeDescription *)pTmp;
     685                 :            : #if OSL_DEBUG_LEVEL > 1
     686                 :            :             osl_incrementInterlockedCount(
     687                 :            :                 &Init::get().nEnumTypeDescriptionCount );
     688                 :            : #endif
     689                 :      10301 :             pTmp->nDefaultEnumValue = 0;
     690                 :      10301 :             pTmp->nEnumValues       = 0;
     691                 :      10301 :             pTmp->ppEnumNames       = 0;
     692                 :      10301 :             pTmp->pEnumValues       = 0;
     693                 :            :         }
     694                 :      10301 :         break;
     695                 :            : 
     696                 :            :         case typelib_TypeClass_INTERFACE:
     697                 :            :         {
     698                 :     297205 :             typelib_InterfaceTypeDescription * pTmp = new typelib_InterfaceTypeDescription();
     699                 :     297205 :             pRet = (typelib_TypeDescription *)pTmp;
     700                 :            : #if OSL_DEBUG_LEVEL > 1
     701                 :            :             osl_incrementInterlockedCount(
     702                 :            :                 &Init::get().nInterfaceTypeDescriptionCount );
     703                 :            : #endif
     704                 :     297205 :             pTmp->pBaseTypeDescription = 0;
     705                 :     297205 :             pTmp->nMembers = 0;
     706                 :     297205 :             pTmp->ppMembers = 0;
     707                 :     297205 :             pTmp->nAllMembers = 0;
     708                 :     297205 :             pTmp->ppAllMembers = 0;
     709                 :     297205 :             pTmp->nMapFunctionIndexToMemberIndex = 0;
     710                 :     297205 :             pTmp->pMapFunctionIndexToMemberIndex = 0;
     711                 :     297205 :             pTmp->pMapMemberIndexToFunctionIndex= 0;
     712                 :     297205 :             pTmp->nBaseTypes = 0;
     713                 :     297205 :             pTmp->ppBaseTypes = 0;
     714                 :            :         }
     715                 :     297205 :         break;
     716                 :            : 
     717                 :            :         case typelib_TypeClass_INTERFACE_METHOD:
     718                 :            :         {
     719                 :     451282 :             typelib_InterfaceMethodTypeDescription * pTmp = new typelib_InterfaceMethodTypeDescription();
     720                 :     451282 :             pRet = (typelib_TypeDescription *)pTmp;
     721                 :            : #if OSL_DEBUG_LEVEL > 1
     722                 :            :             osl_incrementInterlockedCount(
     723                 :            :                 &Init::get().nInterfaceMethodTypeDescriptionCount );
     724                 :            : #endif
     725                 :     451282 :             pTmp->aBase.pMemberName = 0;
     726                 :     451282 :             pTmp->pReturnTypeRef = 0;
     727                 :     451282 :             pTmp->nParams = 0;
     728                 :     451282 :             pTmp->pParams = 0;
     729                 :     451282 :             pTmp->nExceptions = 0;
     730                 :     451282 :             pTmp->ppExceptions = 0;
     731                 :     451282 :             pTmp->pInterface = 0;
     732                 :     451282 :             pTmp->pBaseRef = 0;
     733                 :     451282 :             pTmp->nIndex = 0;
     734                 :            :         }
     735                 :     451282 :         break;
     736                 :            : 
     737                 :            :         case typelib_TypeClass_INTERFACE_ATTRIBUTE:
     738                 :            :         {
     739                 :       8938 :             typelib_InterfaceAttributeTypeDescription * pTmp = new typelib_InterfaceAttributeTypeDescription();
     740                 :       8938 :             pRet = (typelib_TypeDescription *)pTmp;
     741                 :            : #if OSL_DEBUG_LEVEL > 1
     742                 :            :             osl_incrementInterlockedCount(
     743                 :            :                 &Init::get().nInterfaceAttributeTypeDescriptionCount );
     744                 :            : #endif
     745                 :       8938 :             pTmp->aBase.pMemberName = 0;
     746                 :       8938 :             pTmp->pAttributeTypeRef = 0;
     747                 :       8938 :             pTmp->pInterface = 0;
     748                 :       8938 :             pTmp->pBaseRef = 0;
     749                 :       8938 :             pTmp->nIndex = 0;
     750                 :       8938 :             pTmp->nGetExceptions = 0;
     751                 :       8938 :             pTmp->ppGetExceptions = 0;
     752                 :       8938 :             pTmp->nSetExceptions = 0;
     753                 :       8938 :             pTmp->ppSetExceptions = 0;
     754                 :            :         }
     755                 :       8938 :         break;
     756                 :            : 
     757                 :            :         default:
     758                 :            :         {
     759                 :      14411 :             pRet = new typelib_TypeDescription();
     760                 :            : #if OSL_DEBUG_LEVEL > 1
     761                 :            :             osl_incrementInterlockedCount( &Init::get().nTypeDescriptionCount );
     762                 :            : #endif
     763                 :            :         }
     764                 :            :     }
     765                 :            : 
     766                 :     857853 :     pRet->nRefCount = 1; // reference count is initially 1
     767                 :     857853 :     pRet->nStaticRefCount = 0;
     768                 :     857853 :     pRet->eTypeClass = eTypeClass;
     769                 :     857853 :     pRet->pTypeName = 0;
     770                 :     857853 :     pRet->pUniqueIdentifier = 0;
     771                 :     857853 :     pRet->pReserved = 0;
     772                 :     857853 :     rtl_uString_acquire( pRet->pTypeName = pTypeName );
     773                 :     857853 :     pRet->pSelf = pRet;
     774                 :     857853 :     pRet->bComplete = sal_True;
     775                 :     857853 :     pRet->nSize = 0;
     776                 :     857853 :     pRet->nAlignment = 0;
     777                 :     857853 :     pRet->pWeakRef = 0;
     778                 :     857853 :     pRet->bOnDemand = sal_False;
     779                 :     857853 :     *ppRet = pRet;
     780                 :     857853 : }
     781                 :            : 
     782                 :            : //------------------------------------------------------------------------
     783                 :            : namespace {
     784                 :            : 
     785                 :      70832 : void newTypeDescription(
     786                 :            :     typelib_TypeDescription ** ppRet, typelib_TypeClass eTypeClass,
     787                 :            :     rtl_uString * pTypeName, typelib_TypeDescriptionReference * pType,
     788                 :            :     sal_Int32 nMembers, typelib_CompoundMember_Init * pCompoundMembers,
     789                 :            :     typelib_StructMember_Init * pStructMembers)
     790                 :            : {
     791                 :            :     OSL_ASSERT(
     792                 :            :         (pCompoundMembers == 0 || pStructMembers == 0)
     793                 :            :         && (pStructMembers == 0 || eTypeClass == typelib_TypeClass_STRUCT));
     794         [ -  + ]:      70832 :     if (typelib_TypeClass_TYPEDEF == eTypeClass)
     795                 :            :     {
     796                 :            :         OSL_TRACE( "### unexpected typedef!" );
     797                 :          0 :         typelib_typedescriptionreference_getDescription( ppRet, pType );
     798                 :      70832 :         return;
     799                 :            :     }
     800                 :            : 
     801                 :      70832 :     typelib_typedescription_newEmpty( ppRet, eTypeClass, pTypeName );
     802                 :            : 
     803      [ +  +  + ]:      70832 :     switch( eTypeClass )
     804                 :            :     {
     805                 :            :         case typelib_TypeClass_SEQUENCE:
     806                 :            :         {
     807                 :            :             OSL_ASSERT( nMembers == 0 );
     808                 :      17804 :             typelib_typedescriptionreference_acquire( pType );
     809                 :      17804 :             ((typelib_IndirectTypeDescription *)*ppRet)->pType = pType;
     810                 :            :         }
     811                 :      17804 :         break;
     812                 :            : 
     813                 :            :         case typelib_TypeClass_EXCEPTION:
     814                 :            :         case typelib_TypeClass_STRUCT:
     815                 :            :         {
     816                 :            :             // FEATURE_EMPTYCLASS
     817                 :      41003 :             typelib_CompoundTypeDescription * pTmp = (typelib_CompoundTypeDescription*)*ppRet;
     818                 :            : 
     819                 :      41003 :             sal_Int32 nOffset = 0;
     820         [ +  + ]:      41003 :             if( pType )
     821                 :            :             {
     822                 :            :                 typelib_typedescriptionreference_getDescription(
     823                 :      25835 :                     (typelib_TypeDescription **)&pTmp->pBaseTypeDescription, pType );
     824                 :      25835 :                 nOffset = ((typelib_TypeDescription *)pTmp->pBaseTypeDescription)->nSize;
     825                 :            :                 OSL_ENSURE( newAlignedSize( 0, ((typelib_TypeDescription *)pTmp->pBaseTypeDescription)->nSize, ((typelib_TypeDescription *)pTmp->pBaseTypeDescription)->nAlignment ) == ((typelib_TypeDescription *)pTmp->pBaseTypeDescription)->nSize, "### unexpected offset!" );
     826                 :            :             }
     827         [ +  + ]:      41003 :             if( nMembers )
     828                 :            :             {
     829                 :      19468 :                 pTmp->nMembers = nMembers;
     830                 :      19468 :                 pTmp->pMemberOffsets = new sal_Int32[ nMembers ];
     831                 :      19468 :                 pTmp->ppTypeRefs = new typelib_TypeDescriptionReference *[ nMembers ];
     832                 :      19468 :                 pTmp->ppMemberNames = new rtl_uString *[ nMembers ];
     833                 :            :                 bool polymorphic = eTypeClass == typelib_TypeClass_STRUCT
     834 [ +  + ][ +  + ]:      19468 :                     && rtl::OUString::unacquired(&pTypeName).indexOf('<') >= 0;
     835                 :            :                 OSL_ASSERT(!polymorphic || pStructMembers != 0);
     836         [ +  + ]:      19468 :                 if (polymorphic) {
     837                 :            :                     reinterpret_cast< typelib_StructTypeDescription * >(pTmp)->
     838                 :        441 :                         pParameterizedTypes = new sal_Bool[nMembers];
     839                 :            :                 }
     840         [ +  + ]:      82071 :                 for( sal_Int32 i = 0 ; i < nMembers; i++ )
     841                 :            :                 {
     842                 :            :                     // read the type and member names
     843                 :      62603 :                     pTmp->ppTypeRefs[i] = 0;
     844         [ +  + ]:      62603 :                     if (pCompoundMembers != 0) {
     845                 :            :                         typelib_typedescriptionreference_new(
     846                 :       5858 :                             pTmp->ppTypeRefs +i, pCompoundMembers[i].eTypeClass,
     847                 :       5858 :                             pCompoundMembers[i].pTypeName );
     848                 :            :                         rtl_uString_acquire(
     849                 :      11716 :                             pTmp->ppMemberNames[i]
     850                 :       5858 :                             = pCompoundMembers[i].pMemberName );
     851                 :            :                     } else {
     852                 :            :                         typelib_typedescriptionreference_new(
     853                 :            :                             pTmp->ppTypeRefs +i,
     854                 :      56745 :                             pStructMembers[i].aBase.eTypeClass,
     855                 :      56745 :                             pStructMembers[i].aBase.pTypeName );
     856                 :            :                         rtl_uString_acquire(
     857                 :     113490 :                             pTmp->ppMemberNames[i]
     858                 :      56745 :                             = pStructMembers[i].aBase.pMemberName );
     859                 :            :                     }
     860                 :            :                     // write offset
     861                 :            :                     sal_Int32 size;
     862                 :            :                     sal_Int32 alignment;
     863         [ +  + ]:      62603 :                     if (pTmp->ppTypeRefs[i]->eTypeClass ==
     864                 :            :                         typelib_TypeClass_SEQUENCE)
     865                 :            :                     {
     866                 :            :                         // Take care of recursion like
     867                 :            :                         // struct S { sequence<S> x; };
     868                 :       2212 :                         size = sizeof(void *);
     869                 :       2212 :                         alignment = adjustAlignment(size);
     870                 :            :                     } else {
     871                 :      60391 :                         typelib_TypeDescription * pTD = 0;
     872 [ +  - ][ -  + ]:      60391 :                         TYPELIB_DANGER_GET( &pTD, pTmp->ppTypeRefs[i] );
         [ +  - ][ +  + ]
                 [ +  - ]
     873                 :            :                         OSL_ENSURE( pTD->nSize, "### void member?" );
     874                 :      60391 :                         size = pTD->nSize;
     875                 :      60391 :                         alignment = pTD->nAlignment;
     876 [ +  - ][ -  + ]:      60391 :                         TYPELIB_DANGER_RELEASE( pTD );
     877                 :            :                     }
     878                 :      62603 :                     nOffset = newAlignedSize( nOffset, size, alignment );
     879                 :      62603 :                     pTmp->pMemberOffsets[i] = nOffset - size;
     880                 :            : 
     881         [ +  + ]:      62603 :                     if (polymorphic) {
     882                 :            :                         reinterpret_cast< typelib_StructTypeDescription * >(
     883                 :        697 :                             pTmp)->pParameterizedTypes[i]
     884                 :        697 :                             = pStructMembers[i].bParameterizedType;
     885                 :            :                     }
     886                 :            :                 }
     887                 :            :             }
     888                 :            :         }
     889                 :      41003 :         break;
     890                 :            : 
     891                 :            :         default:
     892                 :      12025 :         break;
     893                 :            :     }
     894                 :            : 
     895         [ +  - ]:      70832 :     if( !reallyWeak( eTypeClass ) )
     896                 :      70832 :         (*ppRet)->pWeakRef = (typelib_TypeDescriptionReference *)*ppRet;
     897         [ +  + ]:      70832 :     if( eTypeClass != typelib_TypeClass_VOID )
     898                 :            :     {
     899                 :            :         // sizeof( void ) not allowed
     900                 :      70060 :         (*ppRet)->nSize = typelib_typedescription_getAlignedUnoSize( (*ppRet), 0, (*ppRet)->nAlignment );
     901                 :      70060 :         (*ppRet)->nAlignment = adjustAlignment( (*ppRet)->nAlignment );
     902                 :            :     }
     903                 :            : }
     904                 :            : 
     905                 :            : }
     906                 :            : 
     907                 :      55667 : extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_new(
     908                 :            :     typelib_TypeDescription ** ppRet,
     909                 :            :     typelib_TypeClass eTypeClass,
     910                 :            :     rtl_uString * pTypeName,
     911                 :            :     typelib_TypeDescriptionReference * pType,
     912                 :            :     sal_Int32 nMembers,
     913                 :            :     typelib_CompoundMember_Init * pMembers )
     914                 :            :     SAL_THROW_EXTERN_C()
     915                 :            : {
     916                 :            :     newTypeDescription(
     917                 :      55667 :         ppRet, eTypeClass, pTypeName, pType, nMembers, pMembers, 0);
     918                 :      55667 : }
     919                 :            : 
     920                 :      15165 : extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_newStruct(
     921                 :            :     typelib_TypeDescription ** ppRet,
     922                 :            :     rtl_uString * pTypeName,
     923                 :            :     typelib_TypeDescriptionReference * pType,
     924                 :            :     sal_Int32 nMembers,
     925                 :            :     typelib_StructMember_Init * pMembers )
     926                 :            :     SAL_THROW_EXTERN_C()
     927                 :            : {
     928                 :            :     newTypeDescription(
     929                 :            :         ppRet, typelib_TypeClass_STRUCT, pTypeName, pType, nMembers, 0,
     930                 :      15165 :         pMembers);
     931                 :      15165 : }
     932                 :            : 
     933                 :            : //------------------------------------------------------------------------
     934                 :          0 : extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_newUnion(
     935                 :            :     typelib_TypeDescription ** ppRet,
     936                 :            :     rtl_uString * pTypeName,
     937                 :            :     typelib_TypeDescriptionReference * pDiscriminantTypeRef,
     938                 :            :     sal_Int64 nDefaultDiscriminant,
     939                 :            :     typelib_TypeDescriptionReference * pDefaultTypeRef,
     940                 :            :     sal_Int32 nMembers,
     941                 :            :     typelib_Union_Init * pMembers )
     942                 :            :     SAL_THROW_EXTERN_C()
     943                 :            : {
     944                 :          0 :     typelib_typedescription_newEmpty( ppRet, typelib_TypeClass_UNION, pTypeName );
     945                 :            :     // discriminant type
     946                 :          0 :     typelib_UnionTypeDescription * pTmp = (typelib_UnionTypeDescription *)*ppRet;
     947                 :          0 :     typelib_typedescriptionreference_acquire( pTmp->pDiscriminantTypeRef = pDiscriminantTypeRef );
     948                 :            : 
     949                 :            :     sal_Int32 nPos;
     950                 :            : 
     951                 :          0 :     pTmp->nMembers = nMembers;
     952                 :            :     // default discriminant
     953         [ #  # ]:          0 :     if (nMembers)
     954                 :            :     {
     955                 :          0 :         pTmp->pDiscriminants = new sal_Int64[ nMembers ];
     956         [ #  # ]:          0 :         for ( nPos = nMembers; nPos--; )
     957                 :            :         {
     958                 :          0 :             pTmp->pDiscriminants[nPos] = pMembers[nPos].nDiscriminant;
     959                 :            :         }
     960                 :            :     }
     961                 :            :     // default default discriminant
     962                 :          0 :     pTmp->nDefaultDiscriminant = nDefaultDiscriminant;
     963                 :            : 
     964                 :            :     // union member types
     965                 :          0 :     pTmp->ppTypeRefs = new typelib_TypeDescriptionReference *[ nMembers ];
     966         [ #  # ]:          0 :     for ( nPos = nMembers; nPos--; )
     967                 :            :     {
     968                 :          0 :         typelib_typedescriptionreference_acquire( pTmp->ppTypeRefs[nPos] = pMembers[nPos].pTypeRef );
     969                 :            :     }
     970                 :            :     // union member names
     971                 :          0 :     pTmp->ppMemberNames = new rtl_uString *[ nMembers ];
     972         [ #  # ]:          0 :     for ( nPos = nMembers; nPos--; )
     973                 :            :     {
     974                 :          0 :         rtl_uString_acquire( pTmp->ppMemberNames[nPos] = pMembers[nPos].pMemberName );
     975                 :            :     }
     976                 :            : 
     977                 :            :     // default union type
     978                 :          0 :     typelib_typedescriptionreference_acquire( pTmp->pDefaultTypeRef = pDefaultTypeRef );
     979                 :            : 
     980         [ #  # ]:          0 :     if (! reallyWeak( typelib_TypeClass_UNION ))
     981                 :          0 :         (*ppRet)->pWeakRef = (typelib_TypeDescriptionReference *)*ppRet;
     982                 :          0 :     (*ppRet)->nSize = typelib_typedescription_getAlignedUnoSize( (*ppRet), 0, (*ppRet)->nAlignment );
     983                 :          0 :     (*ppRet)->nAlignment = adjustAlignment( (*ppRet)->nAlignment );
     984                 :          0 : }
     985                 :            : 
     986                 :            : //------------------------------------------------------------------------
     987                 :       4061 : extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_newEnum(
     988                 :            :     typelib_TypeDescription ** ppRet,
     989                 :            :     rtl_uString * pTypeName,
     990                 :            :     sal_Int32 nDefaultValue,
     991                 :            :     sal_Int32 nEnumValues,
     992                 :            :     rtl_uString ** ppEnumNames,
     993                 :            :     sal_Int32 * pEnumValues )
     994                 :            :     SAL_THROW_EXTERN_C()
     995                 :            : {
     996                 :       4061 :     typelib_typedescription_newEmpty( ppRet, typelib_TypeClass_ENUM, pTypeName );
     997                 :       4061 :     typelib_EnumTypeDescription * pEnum = (typelib_EnumTypeDescription *)*ppRet;
     998                 :            : 
     999                 :       4061 :     pEnum->nDefaultEnumValue = nDefaultValue;
    1000                 :       4061 :     pEnum->nEnumValues       = nEnumValues;
    1001                 :       4061 :     pEnum->ppEnumNames       = new rtl_uString * [ nEnumValues ];
    1002         [ +  + ]:      39442 :     for ( sal_Int32 nPos = nEnumValues; nPos--; )
    1003                 :            :     {
    1004                 :      35381 :         rtl_uString_acquire( pEnum->ppEnumNames[nPos] = ppEnumNames[nPos] );
    1005                 :            :     }
    1006                 :       4061 :     pEnum->pEnumValues      = new sal_Int32[ nEnumValues ];
    1007                 :       4061 :     ::memcpy( pEnum->pEnumValues, pEnumValues, nEnumValues * sizeof(sal_Int32) );
    1008                 :            : 
    1009                 :       4061 :     (*ppRet)->pWeakRef = (typelib_TypeDescriptionReference *)*ppRet;
    1010                 :            :     // sizeof( void ) not allowed
    1011                 :       4061 :     (*ppRet)->nSize = typelib_typedescription_getAlignedUnoSize( (*ppRet), 0, (*ppRet)->nAlignment );
    1012                 :       4061 :     (*ppRet)->nAlignment = adjustAlignment( (*ppRet)->nAlignment );
    1013                 :       4061 : }
    1014                 :            : 
    1015                 :            : //------------------------------------------------------------------------
    1016                 :          0 : extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_newArray(
    1017                 :            :     typelib_TypeDescription ** ppRet,
    1018                 :            :     typelib_TypeDescriptionReference * pElementTypeRef,
    1019                 :            :     sal_Int32 nDimensions,
    1020                 :            :     sal_Int32 * pDimensions )
    1021                 :            :     SAL_THROW_EXTERN_C ()
    1022                 :            : {
    1023                 :          0 :     OUStringBuffer aBuf( 32 );
    1024         [ #  # ]:          0 :     aBuf.append( pElementTypeRef->pTypeName );
    1025                 :          0 :     sal_Int32 nElements = 1;
    1026         [ #  # ]:          0 :     for (sal_Int32 i=0; i < nDimensions; i++)
    1027                 :            :     {
    1028         [ #  # ]:          0 :         aBuf.appendAscii("[");
    1029         [ #  # ]:          0 :         aBuf.append(pDimensions[i]);
    1030         [ #  # ]:          0 :         aBuf.appendAscii("]");
    1031                 :          0 :         nElements *= pDimensions[i];
    1032                 :            :     }
    1033         [ #  # ]:          0 :     OUString aTypeName( aBuf.makeStringAndClear() );
    1034                 :            : 
    1035                 :            : 
    1036                 :          0 :     typelib_typedescription_newEmpty( ppRet, typelib_TypeClass_ARRAY, aTypeName.pData );
    1037                 :          0 :     typelib_ArrayTypeDescription * pArray = (typelib_ArrayTypeDescription *)*ppRet;
    1038                 :            : 
    1039                 :          0 :     pArray->nDimensions = nDimensions;
    1040                 :          0 :     pArray->nTotalElements = nElements;
    1041         [ #  # ]:          0 :     pArray->pDimensions = new sal_Int32[ nDimensions ];
    1042                 :          0 :     ::memcpy( pArray->pDimensions, pDimensions, nDimensions * sizeof(sal_Int32) );
    1043                 :            : 
    1044                 :          0 :     typelib_typedescriptionreference_acquire(pElementTypeRef);
    1045                 :          0 :     ((typelib_IndirectTypeDescription*)pArray)->pType = pElementTypeRef;
    1046                 :            : 
    1047                 :          0 :     (*ppRet)->pWeakRef = (typelib_TypeDescriptionReference *)*ppRet;
    1048                 :            :     // sizeof( void ) not allowed
    1049                 :          0 :     (*ppRet)->nSize = typelib_typedescription_getAlignedUnoSize( *ppRet, 0, (*ppRet)->nAlignment );
    1050                 :          0 :     (*ppRet)->nAlignment = adjustAlignment( (*ppRet)->nAlignment );
    1051                 :          0 : }
    1052                 :            : 
    1053                 :            : //------------------------------------------------------------------------
    1054                 :        939 : extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_newInterface(
    1055                 :            :     typelib_InterfaceTypeDescription ** ppRet,
    1056                 :            :     rtl_uString * pTypeName,
    1057                 :            :     sal_uInt32 nUik1, sal_uInt16 nUik2, sal_uInt16 nUik3, sal_uInt32 nUik4, sal_uInt32 nUik5,
    1058                 :            :     typelib_TypeDescriptionReference * pBaseInterface,
    1059                 :            :     sal_Int32 nMembers,
    1060                 :            :     typelib_TypeDescriptionReference ** ppMembers )
    1061                 :            :     SAL_THROW_EXTERN_C()
    1062                 :            : {
    1063                 :            :     typelib_typedescription_newMIInterface(
    1064                 :            :         ppRet, pTypeName, nUik1, nUik2, nUik3, nUik4, nUik5,
    1065                 :        939 :         pBaseInterface == 0 ? 0 : 1, &pBaseInterface, nMembers, ppMembers);
    1066                 :        939 : }
    1067                 :            : 
    1068                 :            : //------------------------------------------------------------------------
    1069                 :            : 
    1070                 :            : namespace {
    1071                 :            : 
    1072                 :     214783 : class BaseList {
    1073                 :            : public:
    1074                 :            :     struct Entry {
    1075                 :            :         sal_Int32 memberOffset;
    1076                 :            :         sal_Int32 directBaseIndex;
    1077                 :            :         sal_Int32 directBaseMemberOffset;
    1078                 :            :         typelib_InterfaceTypeDescription const * base;
    1079                 :            :     };
    1080                 :            : 
    1081                 :            :     typedef std::vector< Entry > List;
    1082                 :            : 
    1083                 :            :     BaseList(typelib_InterfaceTypeDescription const * desc);
    1084                 :            : 
    1085                 :     214783 :     List const & getList() const { return list; }
    1086                 :            : 
    1087                 :     428505 :     sal_Int32 getBaseMembers() const { return members; }
    1088                 :            : 
    1089                 :            : private:
    1090                 :            :     typedef std::set< rtl::OUString > Set;
    1091                 :            : 
    1092                 :            :     void calculate(
    1093                 :            :         sal_Int32 directBaseIndex, Set & directBaseSet,
    1094                 :            :         sal_Int32 * directBaseMembers,
    1095                 :            :         typelib_InterfaceTypeDescription const * desc);
    1096                 :            : 
    1097                 :            :     Set set;
    1098                 :            :     List list;
    1099                 :            :     sal_Int32 members;
    1100                 :            : };
    1101                 :            : 
    1102         [ +  - ]:     214783 : BaseList::BaseList(typelib_InterfaceTypeDescription const * desc) {
    1103                 :     214783 :     members = 0;
    1104         [ +  + ]:     391212 :     for (sal_Int32 i = 0; i < desc->nBaseTypes; ++i) {
    1105         [ +  - ]:     176429 :         Set directBaseSet;
    1106                 :     176429 :         sal_Int32 directBaseMembers = 0;
    1107         [ +  - ]:     176429 :         calculate(i, directBaseSet, &directBaseMembers, desc->ppBaseTypes[i]);
    1108                 :     176429 :     }
    1109                 :     214783 : }
    1110                 :            : 
    1111                 :     243669 : void BaseList::calculate(
    1112                 :            :     sal_Int32 directBaseIndex, Set & directBaseSet,
    1113                 :            :     sal_Int32 * directBaseMembers,
    1114                 :            :     typelib_InterfaceTypeDescription const * desc)
    1115                 :            : {
    1116         [ +  + ]:     310909 :     for (sal_Int32 i = 0; i < desc->nBaseTypes; ++i) {
    1117                 :            :         calculate(
    1118                 :            :             directBaseIndex, directBaseSet, directBaseMembers,
    1119                 :      67240 :             desc->ppBaseTypes[i]);
    1120                 :            :     }
    1121 [ +  - ][ +  + ]:     243669 :     if (set.insert(desc->aBase.pTypeName).second) {
    1122                 :            :         Entry e;
    1123                 :     241041 :         e.memberOffset = members;
    1124                 :     241041 :         e.directBaseIndex = directBaseIndex;
    1125                 :     241041 :         e.directBaseMemberOffset = *directBaseMembers;
    1126                 :     241041 :         e.base = desc;
    1127         [ +  - ]:     241041 :         list.push_back(e);
    1128                 :            :         OSL_ASSERT(desc->ppAllMembers != 0);
    1129                 :     241041 :         members += desc->nMembers;
    1130                 :            :     }
    1131 [ +  - ][ +  + ]:     243669 :     if (directBaseSet.insert(desc->aBase.pTypeName).second) {
    1132                 :            :         OSL_ASSERT(desc->ppAllMembers != 0);
    1133                 :     243469 :         *directBaseMembers += desc->nMembers;
    1134                 :            :     }
    1135                 :     243669 : }
    1136                 :            : 
    1137                 :            : }
    1138                 :            : 
    1139                 :     214783 : extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_newMIInterface(
    1140                 :            :     typelib_InterfaceTypeDescription ** ppRet,
    1141                 :            :     rtl_uString * pTypeName,
    1142                 :            :     sal_uInt32 nUik1, sal_uInt16 nUik2, sal_uInt16 nUik3, sal_uInt32 nUik4, sal_uInt32 nUik5,
    1143                 :            :     sal_Int32 nBaseInterfaces,
    1144                 :            :     typelib_TypeDescriptionReference ** ppBaseInterfaces,
    1145                 :            :     sal_Int32 nMembers,
    1146                 :            :     typelib_TypeDescriptionReference ** ppMembers )
    1147                 :            :     SAL_THROW_EXTERN_C()
    1148                 :            : {
    1149         [ -  + ]:     214783 :     if (*ppRet != 0) {
    1150                 :          0 :         typelib_typedescription_release(&(*ppRet)->aBase);
    1151                 :          0 :         *ppRet = 0;
    1152                 :            :     }
    1153                 :            : 
    1154                 :     214783 :     typelib_InterfaceTypeDescription * pITD = 0;
    1155                 :            :     typelib_typedescription_newEmpty(
    1156                 :     214783 :         (typelib_TypeDescription **)&pITD, typelib_TypeClass_INTERFACE, pTypeName );
    1157                 :            : 
    1158                 :     214783 :     pITD->nBaseTypes = nBaseInterfaces;
    1159         [ +  - ]:     214783 :     pITD->ppBaseTypes = new typelib_InterfaceTypeDescription *[nBaseInterfaces];
    1160         [ +  + ]:     391212 :     for (sal_Int32 i = 0; i < nBaseInterfaces; ++i) {
    1161                 :     176429 :         pITD->ppBaseTypes[i] = 0;
    1162                 :            :         typelib_typedescriptionreference_getDescription(
    1163                 :            :             reinterpret_cast< typelib_TypeDescription ** >(
    1164                 :            :                 &pITD->ppBaseTypes[i]),
    1165                 :     176429 :             ppBaseInterfaces[i]);
    1166 [ -  + ][ +  - ]:     352858 :         if (pITD->ppBaseTypes[i] == 0
                 [ +  - ]
    1167                 :            :             || !complete(
    1168                 :            :                 reinterpret_cast< typelib_TypeDescription ** >(
    1169                 :            :                     &pITD->ppBaseTypes[i]),
    1170         [ +  - ]:     176429 :                 false))
    1171                 :            :         {
    1172                 :            :             OSL_ASSERT(false);
    1173                 :     214783 :             return;
    1174                 :            :         }
    1175                 :            :         OSL_ASSERT(pITD->ppBaseTypes[i] != 0);
    1176                 :            :     }
    1177         [ +  + ]:     214783 :     if (nBaseInterfaces > 0) {
    1178                 :     174113 :         pITD->pBaseTypeDescription = pITD->ppBaseTypes[0];
    1179                 :            :     }
    1180                 :            :     // set the
    1181                 :     214783 :     pITD->aUik.m_Data1 = nUik1;
    1182                 :     214783 :     pITD->aUik.m_Data2 = nUik2;
    1183                 :     214783 :     pITD->aUik.m_Data3 = nUik3;
    1184                 :     214783 :     pITD->aUik.m_Data4 = nUik4;
    1185                 :     214783 :     pITD->aUik.m_Data5 = nUik5;
    1186                 :            : 
    1187         [ +  - ]:     214783 :     BaseList aBaseList(pITD);
    1188                 :     214783 :     pITD->nAllMembers = nMembers + aBaseList.getBaseMembers();
    1189                 :     214783 :     pITD->nMembers = nMembers;
    1190                 :            : 
    1191         [ +  - ]:     214783 :     if( pITD->nAllMembers )
    1192                 :            :     {
    1193                 :            :         // at minimum one member exist, allocate the memory
    1194         [ +  - ]:     214783 :         pITD->ppAllMembers = new typelib_TypeDescriptionReference *[ pITD->nAllMembers ];
    1195                 :     214783 :         sal_Int32 n = 0;
    1196                 :            : 
    1197                 :     214783 :         BaseList::List const & rList = aBaseList.getList();
    1198 [ +  - ][ +  + ]:     455824 :         {for (BaseList::List::const_iterator i(rList.begin()); i != rList.end();
    1199                 :            :               ++i)
    1200                 :            :         {
    1201                 :     241041 :             typelib_InterfaceTypeDescription const * pBase = i->base;
    1202                 :            :             typelib_InterfaceTypeDescription const * pDirectBase
    1203                 :     241041 :                 = pITD->ppBaseTypes[i->directBaseIndex];
    1204                 :            :             OSL_ASSERT(pBase->ppAllMembers != 0);
    1205         [ +  + ]:     956697 :             for (sal_Int32 j = 0; j < pBase->nMembers; ++j) {
    1206                 :            :                 typelib_TypeDescriptionReference const * pDirectBaseMember
    1207                 :     715656 :                     = pDirectBase->ppAllMembers[i->directBaseMemberOffset + j];
    1208         [ +  - ]:     715656 :                 rtl::OUStringBuffer aBuf(pDirectBaseMember->pTypeName);
    1209         [ +  - ]:     715656 :                 aBuf.appendAscii(RTL_CONSTASCII_STRINGPARAM(":@"));
    1210         [ +  - ]:     715656 :                 aBuf.append(i->directBaseIndex);
    1211         [ +  - ]:     715656 :                 aBuf.append(static_cast< sal_Unicode >(','));
    1212         [ +  - ]:     715656 :                 aBuf.append(i->memberOffset + j);
    1213         [ +  - ]:     715656 :                 aBuf.append(static_cast< sal_Unicode >(':'));
    1214         [ +  - ]:     715656 :                 aBuf.append(pITD->aBase.pTypeName);
    1215         [ +  - ]:     715656 :                 rtl::OUString aName(aBuf.makeStringAndClear());
    1216                 :     715656 :                 typelib_TypeDescriptionReference * pDerivedMember = 0;
    1217                 :            :                 typelib_typedescriptionreference_new(
    1218                 :            :                     &pDerivedMember, pDirectBaseMember->eTypeClass,
    1219                 :     715656 :                     aName.pData);
    1220                 :     715656 :                 pITD->ppAllMembers[n++] = pDerivedMember;
    1221                 :     715656 :             }
    1222                 :            :         }}
    1223                 :            : 
    1224         [ +  + ]:     214783 :         if( nMembers )
    1225                 :            :         {
    1226                 :     213722 :             pITD->ppMembers = pITD->ppAllMembers + aBaseList.getBaseMembers();
    1227                 :            :         }
    1228                 :            : 
    1229                 :            :         // add own members
    1230         [ +  + ]:     910709 :         {for( sal_Int32 i = 0; i < nMembers; i++ )
    1231                 :            :         {
    1232                 :     695926 :             typelib_typedescriptionreference_acquire( ppMembers[i] );
    1233                 :     695926 :             pITD->ppAllMembers[n++] = ppMembers[i];
    1234                 :            :         }}
    1235                 :            :     }
    1236                 :            : 
    1237                 :     214783 :     typelib_TypeDescription * pTmp = (typelib_TypeDescription *)pITD;
    1238         [ +  - ]:     214783 :     if( !reallyWeak( typelib_TypeClass_INTERFACE ) )
    1239                 :     214783 :         pTmp->pWeakRef = (typelib_TypeDescriptionReference *)pTmp;
    1240                 :     214783 :     pTmp->nSize = typelib_typedescription_getAlignedUnoSize( pTmp, 0, pTmp->nAlignment );
    1241                 :     214783 :     pTmp->nAlignment = adjustAlignment( pTmp->nAlignment );
    1242                 :     214783 :     pTmp->bComplete = sal_False;
    1243                 :            : 
    1244                 :     214783 :     *ppRet = pITD;
    1245                 :            : }
    1246                 :            : 
    1247                 :            : //------------------------------------------------------------------------
    1248                 :            : 
    1249                 :            : namespace {
    1250                 :            : 
    1251                 :     408217 : typelib_TypeDescriptionReference ** copyExceptions(
    1252                 :            :     sal_Int32 count, rtl_uString ** typeNames)
    1253                 :            : {
    1254                 :            :     OSL_ASSERT(count >= 0);
    1255         [ +  + ]:     408217 :     if (count == 0) {
    1256                 :      35850 :         return 0;
    1257                 :            :     }
    1258                 :            :     typelib_TypeDescriptionReference ** p
    1259                 :     372367 :         = new typelib_TypeDescriptionReference *[count];
    1260         [ +  + ]:    1017398 :     for (sal_Int32 i = 0; i < count; ++i) {
    1261                 :     645031 :         p[i] = 0;
    1262                 :            :         typelib_typedescriptionreference_new(
    1263                 :     645031 :             p + i, typelib_TypeClass_EXCEPTION, typeNames[i]);
    1264                 :            :     }
    1265                 :     408217 :     return p;
    1266                 :            : }
    1267                 :            : 
    1268                 :            : }
    1269                 :            : 
    1270                 :     392867 : extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_newInterfaceMethod(
    1271                 :            :     typelib_InterfaceMethodTypeDescription ** ppRet,
    1272                 :            :     sal_Int32 nAbsolutePosition,
    1273                 :            :     sal_Bool bOneWay,
    1274                 :            :     rtl_uString * pTypeName,
    1275                 :            :     typelib_TypeClass eReturnTypeClass,
    1276                 :            :     rtl_uString * pReturnTypeName,
    1277                 :            :     sal_Int32 nParams,
    1278                 :            :     typelib_Parameter_Init * pParams,
    1279                 :            :     sal_Int32 nExceptions,
    1280                 :            :     rtl_uString ** ppExceptionNames )
    1281                 :            :     SAL_THROW_EXTERN_C()
    1282                 :            : {
    1283         [ +  + ]:     392867 :     if (*ppRet != 0) {
    1284                 :     245067 :         typelib_typedescription_release(&(*ppRet)->aBase.aBase);
    1285                 :     245067 :         *ppRet = 0;
    1286                 :            :     }
    1287                 :            :     sal_Int32 nOffset = rtl_ustr_lastIndexOfChar_WithLength(
    1288                 :     392867 :         pTypeName->buffer, pTypeName->length, ':');
    1289 [ +  - ][ +  - ]:     392867 :     if (nOffset <= 0 || pTypeName->buffer[nOffset - 1] != ':') {
    1290                 :            :         OSL_FAIL("Bad interface method type name");
    1291                 :            :         return;
    1292                 :            :     }
    1293                 :     392867 :     rtl::OUString aInterfaceTypeName(pTypeName->buffer, nOffset - 1);
    1294                 :     392867 :     typelib_InterfaceTypeDescription * pInterface = 0;
    1295                 :            :     typelib_typedescription_getByName(
    1296                 :            :         reinterpret_cast< typelib_TypeDescription ** >(&pInterface),
    1297                 :     392867 :         aInterfaceTypeName.pData);
    1298 [ +  - ][ -  + ]:     785734 :     if (pInterface == 0
         [ -  + ][ +  - ]
    1299                 :            :         || pInterface->aBase.eTypeClass != typelib_TypeClass_INTERFACE
    1300                 :            :         || !complete(
    1301         [ +  - ]:     392867 :             reinterpret_cast< typelib_TypeDescription ** >(&pInterface), false))
    1302                 :            :     {
    1303                 :            :         OSL_FAIL("No interface corresponding to interface method");
    1304                 :            :         return;
    1305                 :            :     }
    1306                 :            : 
    1307                 :            :     typelib_typedescription_newEmpty(
    1308                 :     392867 :         (typelib_TypeDescription **)ppRet, typelib_TypeClass_INTERFACE_METHOD, pTypeName );
    1309                 :     392867 :     typelib_TypeDescription * pTmp = (typelib_TypeDescription *)*ppRet;
    1310                 :            : 
    1311                 :            :     rtl_uString_newFromStr_WithLength( &(*ppRet)->aBase.pMemberName,
    1312                 :     392867 :                                        pTypeName->buffer + nOffset +1,
    1313                 :     392867 :                                        pTypeName->length - nOffset -1 );
    1314                 :     392867 :     (*ppRet)->aBase.nPosition = nAbsolutePosition;
    1315                 :     392867 :     (*ppRet)->bOneWay = bOneWay;
    1316                 :     392867 :     typelib_typedescriptionreference_new( &(*ppRet)->pReturnTypeRef, eReturnTypeClass, pReturnTypeName );
    1317                 :     392867 :     (*ppRet)->nParams = nParams;
    1318         [ +  + ]:     392867 :     if( nParams )
    1319                 :            :     {
    1320         [ +  - ]:     217255 :         (*ppRet)->pParams = new typelib_MethodParameter[ nParams ];
    1321                 :            : 
    1322         [ +  + ]:     526961 :         for( sal_Int32 i = 0; i < nParams; i++ )
    1323                 :            :         {
    1324                 :            :             // get the name of the parameter
    1325                 :     309706 :             (*ppRet)->pParams[ i ].pName = 0;
    1326                 :     309706 :             rtl_uString_acquire( (*ppRet)->pParams[ i ].pName = pParams[i].pParamName );
    1327                 :     309706 :             (*ppRet)->pParams[ i ].pTypeRef = 0;
    1328                 :            :             // get the type name of the parameter and create the weak reference
    1329                 :            :             typelib_typedescriptionreference_new(
    1330                 :     309706 :                 &(*ppRet)->pParams[ i ].pTypeRef, pParams[i].eTypeClass, pParams[i].pTypeName );
    1331                 :     309706 :             (*ppRet)->pParams[ i ].bIn = pParams[i].bIn;
    1332                 :     309706 :             (*ppRet)->pParams[ i ].bOut = pParams[i].bOut;
    1333                 :            :         }
    1334                 :            :     }
    1335                 :     392867 :     (*ppRet)->nExceptions = nExceptions;
    1336         [ +  - ]:     392867 :     (*ppRet)->ppExceptions = copyExceptions(nExceptions, ppExceptionNames);
    1337                 :     392867 :     (*ppRet)->pInterface = pInterface;
    1338                 :     392867 :     (*ppRet)->pBaseRef = 0;
    1339                 :            :     OSL_ASSERT(
    1340                 :            :         (nAbsolutePosition >= pInterface->nAllMembers - pInterface->nMembers)
    1341                 :            :         && nAbsolutePosition < pInterface->nAllMembers);
    1342                 :            :     (*ppRet)->nIndex = nAbsolutePosition
    1343                 :     392867 :         - (pInterface->nAllMembers - pInterface->nMembers);
    1344         [ -  + ]:     392867 :     if( !reallyWeak( typelib_TypeClass_INTERFACE_METHOD ) )
    1345         [ +  - ]:     392867 :         pTmp->pWeakRef = (typelib_TypeDescriptionReference *)pTmp;
    1346                 :            : }
    1347                 :            : 
    1348                 :            : 
    1349                 :            : //------------------------------------------------------------------------
    1350                 :          0 : extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_newInterfaceAttribute(
    1351                 :            :     typelib_InterfaceAttributeTypeDescription ** ppRet,
    1352                 :            :     sal_Int32 nAbsolutePosition,
    1353                 :            :     rtl_uString * pTypeName,
    1354                 :            :     typelib_TypeClass eAttributeTypeClass,
    1355                 :            :     rtl_uString * pAttributeTypeName,
    1356                 :            :     sal_Bool bReadOnly )
    1357                 :            :     SAL_THROW_EXTERN_C()
    1358                 :            : {
    1359                 :            :     typelib_typedescription_newExtendedInterfaceAttribute(
    1360                 :            :         ppRet, nAbsolutePosition, pTypeName, eAttributeTypeClass,
    1361                 :          0 :         pAttributeTypeName, bReadOnly, 0, 0, 0, 0);
    1362                 :          0 : }
    1363                 :            : 
    1364                 :            : //------------------------------------------------------------------------
    1365                 :       7675 : extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_newExtendedInterfaceAttribute(
    1366                 :            :     typelib_InterfaceAttributeTypeDescription ** ppRet,
    1367                 :            :     sal_Int32 nAbsolutePosition,
    1368                 :            :     rtl_uString * pTypeName,
    1369                 :            :     typelib_TypeClass eAttributeTypeClass,
    1370                 :            :     rtl_uString * pAttributeTypeName,
    1371                 :            :     sal_Bool bReadOnly,
    1372                 :            :     sal_Int32 nGetExceptions, rtl_uString ** ppGetExceptionNames,
    1373                 :            :     sal_Int32 nSetExceptions, rtl_uString ** ppSetExceptionNames )
    1374                 :            :     SAL_THROW_EXTERN_C()
    1375                 :            : {
    1376         [ -  + ]:       7675 :     if (*ppRet != 0) {
    1377                 :          0 :         typelib_typedescription_release(&(*ppRet)->aBase.aBase);
    1378                 :          0 :         *ppRet = 0;
    1379                 :            :     }
    1380                 :            :     sal_Int32 nOffset = rtl_ustr_lastIndexOfChar_WithLength(
    1381                 :       7675 :         pTypeName->buffer, pTypeName->length, ':');
    1382 [ +  - ][ +  - ]:       7675 :     if (nOffset <= 0 || pTypeName->buffer[nOffset - 1] != ':') {
    1383                 :            :         OSL_FAIL("Bad interface attribute type name");
    1384                 :            :         return;
    1385                 :            :     }
    1386                 :       7675 :     rtl::OUString aInterfaceTypeName(pTypeName->buffer, nOffset - 1);
    1387                 :       7675 :     typelib_InterfaceTypeDescription * pInterface = 0;
    1388                 :            :     typelib_typedescription_getByName(
    1389                 :            :         reinterpret_cast< typelib_TypeDescription ** >(&pInterface),
    1390                 :       7675 :         aInterfaceTypeName.pData);
    1391 [ +  - ][ -  + ]:      15350 :     if (pInterface == 0
         [ -  + ][ +  - ]
    1392                 :            :         || pInterface->aBase.eTypeClass != typelib_TypeClass_INTERFACE
    1393                 :            :         || !complete(
    1394         [ +  - ]:       7675 :             reinterpret_cast< typelib_TypeDescription ** >(&pInterface), false))
    1395                 :            :     {
    1396                 :            :         OSL_FAIL("No interface corresponding to interface attribute");
    1397                 :            :         return;
    1398                 :            :     }
    1399                 :            : 
    1400                 :            :     typelib_typedescription_newEmpty(
    1401                 :       7675 :         (typelib_TypeDescription **)ppRet, typelib_TypeClass_INTERFACE_ATTRIBUTE, pTypeName );
    1402                 :       7675 :     typelib_TypeDescription * pTmp = (typelib_TypeDescription *)*ppRet;
    1403                 :            : 
    1404                 :            :     rtl_uString_newFromStr_WithLength( &(*ppRet)->aBase.pMemberName,
    1405                 :       7675 :                                        pTypeName->buffer + nOffset +1,
    1406                 :       7675 :                                        pTypeName->length - nOffset -1 );
    1407                 :       7675 :     (*ppRet)->aBase.nPosition = nAbsolutePosition;
    1408                 :       7675 :     typelib_typedescriptionreference_new( &(*ppRet)->pAttributeTypeRef, eAttributeTypeClass, pAttributeTypeName );
    1409                 :       7675 :     (*ppRet)->bReadOnly = bReadOnly;
    1410                 :       7675 :     (*ppRet)->pInterface = pInterface;
    1411                 :       7675 :     (*ppRet)->pBaseRef = 0;
    1412                 :            :     OSL_ASSERT(
    1413                 :            :         (nAbsolutePosition >= pInterface->nAllMembers - pInterface->nMembers)
    1414                 :            :         && nAbsolutePosition < pInterface->nAllMembers);
    1415                 :            :     (*ppRet)->nIndex = nAbsolutePosition
    1416                 :       7675 :         - (pInterface->nAllMembers - pInterface->nMembers);
    1417                 :       7675 :     (*ppRet)->nGetExceptions = nGetExceptions;
    1418                 :            :     (*ppRet)->ppGetExceptions = copyExceptions(
    1419         [ +  - ]:       7675 :         nGetExceptions, ppGetExceptionNames);
    1420                 :       7675 :     (*ppRet)->nSetExceptions = nSetExceptions;
    1421                 :            :     (*ppRet)->ppSetExceptions = copyExceptions(
    1422         [ +  - ]:       7675 :         nSetExceptions, ppSetExceptionNames);
    1423         [ -  + ]:       7675 :     if( !reallyWeak( typelib_TypeClass_INTERFACE_ATTRIBUTE ) )
    1424         [ +  - ]:       7675 :         pTmp->pWeakRef = (typelib_TypeDescriptionReference *)pTmp;
    1425                 :            : }
    1426                 :            : 
    1427                 :            : //------------------------------------------------------------------------
    1428                 :    5513205 : extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_acquire(
    1429                 :            :     typelib_TypeDescription * pTypeDescription )
    1430                 :            :     SAL_THROW_EXTERN_C()
    1431                 :            : {
    1432                 :    5513205 :     ::osl_incrementInterlockedCount( &pTypeDescription->nRefCount );
    1433                 :    5513211 : }
    1434                 :            : 
    1435                 :            : //------------------------------------------------------------------------
    1436                 :            : 
    1437                 :            : namespace {
    1438                 :            : 
    1439                 :     376292 : void deleteExceptions(
    1440                 :            :     sal_Int32 count, typelib_TypeDescriptionReference ** exceptions)
    1441                 :            : {
    1442         [ +  + ]:     986236 :     for (sal_Int32 i = 0; i < count; ++i) {
    1443                 :     609944 :         typelib_typedescriptionreference_release(exceptions[i]);
    1444                 :            :     }
    1445         [ +  + ]:     376292 :     delete[] exceptions;
    1446                 :     376292 : }
    1447                 :            : 
    1448                 :            : }
    1449                 :            : 
    1450                 :            : // frees anything except typelib_TypeDescription base!
    1451                 :     702101 : static inline void typelib_typedescription_destructExtendedMembers(
    1452                 :            :     typelib_TypeDescription * pTD )
    1453                 :            :     SAL_THROW(())
    1454                 :            : {
    1455                 :            :     OSL_ASSERT( typelib_TypeClass_TYPEDEF != pTD->eTypeClass );
    1456                 :            : 
    1457   [ -  +  -  +  :     702101 :     switch( pTD->eTypeClass )
          +  +  +  +  +  
                      + ]
    1458                 :            :     {
    1459                 :            :     case typelib_TypeClass_ARRAY:
    1460         [ #  # ]:          0 :         if( ((typelib_IndirectTypeDescription*)pTD)->pType )
    1461                 :          0 :             typelib_typedescriptionreference_release( ((typelib_IndirectTypeDescription*)pTD)->pType );
    1462         [ #  # ]:          0 :         delete [] ((typelib_ArrayTypeDescription *)pTD)->pDimensions;
    1463                 :          0 :         break;
    1464                 :            :     case typelib_TypeClass_SEQUENCE:
    1465         [ +  + ]:      16110 :         if( ((typelib_IndirectTypeDescription*)pTD)->pType )
    1466                 :      15729 :             typelib_typedescriptionreference_release( ((typelib_IndirectTypeDescription*)pTD)->pType );
    1467                 :      16110 :         break;
    1468                 :            :     case typelib_TypeClass_UNION:
    1469                 :            :     {
    1470                 :          0 :         typelib_UnionTypeDescription * pUnionTD = (typelib_UnionTypeDescription *)pTD;
    1471                 :          0 :         typelib_typedescriptionreference_release( pUnionTD->pDiscriminantTypeRef );
    1472                 :          0 :         typelib_typedescriptionreference_release( pUnionTD->pDefaultTypeRef );
    1473                 :            : 
    1474                 :            :         sal_Int32 nPos;
    1475                 :          0 :         typelib_TypeDescriptionReference ** ppTypeRefs = pUnionTD->ppTypeRefs;
    1476         [ #  # ]:          0 :         for ( nPos = pUnionTD->nMembers; nPos--; )
    1477                 :            :         {
    1478                 :          0 :             typelib_typedescriptionreference_release( ppTypeRefs[nPos] );
    1479                 :            :         }
    1480                 :            : 
    1481                 :          0 :         rtl_uString ** ppMemberNames = pUnionTD->ppMemberNames;
    1482         [ #  # ]:          0 :         for ( nPos = pUnionTD->nMembers; nPos--; )
    1483                 :            :         {
    1484                 :          0 :             rtl_uString_release( ppMemberNames[nPos] );
    1485                 :            :         }
    1486         [ #  # ]:          0 :         delete [] pUnionTD->ppMemberNames;
    1487         [ #  # ]:          0 :         delete [] pUnionTD->pDiscriminants;
    1488         [ #  # ]:          0 :         delete [] pUnionTD->ppTypeRefs;
    1489                 :            :     }
    1490                 :          0 :     break;
    1491                 :            :     case typelib_TypeClass_STRUCT:
    1492                 :            :         delete[] reinterpret_cast< typelib_StructTypeDescription * >(pTD)->
    1493         [ +  + ]:      20020 :             pParameterizedTypes;
    1494                 :            :     case typelib_TypeClass_EXCEPTION:
    1495                 :            :     {
    1496                 :      45684 :         typelib_CompoundTypeDescription * pCTD = (typelib_CompoundTypeDescription*)pTD;
    1497         [ +  + ]:      45684 :         if( pCTD->pBaseTypeDescription )
    1498                 :      20005 :             typelib_typedescription_release( (typelib_TypeDescription *)pCTD->pBaseTypeDescription );
    1499                 :            :         sal_Int32 i;
    1500         [ +  + ]:      91210 :         for( i = 0; i < pCTD->nMembers; i++ )
    1501                 :            :         {
    1502                 :      45526 :             typelib_typedescriptionreference_release( pCTD->ppTypeRefs[i] );
    1503                 :            :         }
    1504         [ +  + ]:      45684 :         if (pCTD->ppMemberNames)
    1505                 :            :         {
    1506         [ +  + ]:      56757 :             for ( i = 0; i < pCTD->nMembers; i++ )
    1507                 :            :             {
    1508                 :      44042 :                 rtl_uString_release( pCTD->ppMemberNames[i] );
    1509                 :            :             }
    1510         [ +  - ]:      12715 :             delete [] pCTD->ppMemberNames;
    1511                 :            :         }
    1512         [ +  + ]:      45684 :         delete [] pCTD->ppTypeRefs;
    1513         [ +  + ]:      45684 :         delete [] pCTD->pMemberOffsets;
    1514                 :            :     }
    1515                 :      45684 :     break;
    1516                 :            :     case typelib_TypeClass_INTERFACE:
    1517                 :            :     {
    1518                 :     254785 :         typelib_InterfaceTypeDescription * pITD = (typelib_InterfaceTypeDescription*)pTD;
    1519         [ +  + ]:    1338120 :         {for( sal_Int32 i = 0; i < pITD->nAllMembers; i++ )
    1520                 :            :         {
    1521                 :    1083335 :             typelib_typedescriptionreference_release( pITD->ppAllMembers[i] );
    1522                 :            :         }}
    1523         [ +  + ]:     254785 :         delete [] pITD->ppAllMembers;
    1524         [ +  + ]:     254785 :         delete [] pITD->pMapMemberIndexToFunctionIndex;
    1525         [ +  + ]:     254785 :         delete [] pITD->pMapFunctionIndexToMemberIndex;
    1526         [ +  + ]:     391473 :         {for (sal_Int32 i = 0; i < pITD->nBaseTypes; ++i) {
    1527                 :            :             typelib_typedescription_release(
    1528                 :            :                 reinterpret_cast< typelib_TypeDescription * >(
    1529                 :     136688 :                     pITD->ppBaseTypes[i]));
    1530                 :            :         }}
    1531         [ +  + ]:     254785 :         delete[] pITD->ppBaseTypes;
    1532                 :     254785 :         break;
    1533                 :            :     }
    1534                 :            :     case typelib_TypeClass_INTERFACE_METHOD:
    1535                 :            :     {
    1536                 :     363452 :         typelib_InterfaceMethodTypeDescription * pIMTD = (typelib_InterfaceMethodTypeDescription*)pTD;
    1537         [ +  - ]:     363452 :         if( pIMTD->pReturnTypeRef )
    1538                 :     363452 :             typelib_typedescriptionreference_release( pIMTD->pReturnTypeRef );
    1539         [ +  + ]:     639804 :         for( sal_Int32 i = 0; i < pIMTD->nParams; i++ )
    1540                 :            :         {
    1541                 :     276352 :             rtl_uString_release( pIMTD->pParams[ i ].pName );
    1542                 :     276352 :             typelib_typedescriptionreference_release( pIMTD->pParams[ i ].pTypeRef );
    1543                 :            :         }
    1544         [ +  + ]:     363452 :         delete [] pIMTD->pParams;
    1545                 :     363452 :         deleteExceptions(pIMTD->nExceptions, pIMTD->ppExceptions);
    1546                 :     363452 :         rtl_uString_release( pIMTD->aBase.pMemberName );
    1547                 :     363452 :         typelib_typedescription_release(&pIMTD->pInterface->aBase);
    1548         [ +  + ]:     363452 :         if (pIMTD->pBaseRef != 0) {
    1549                 :       6877 :             typelib_typedescriptionreference_release(pIMTD->pBaseRef);
    1550                 :            :         }
    1551                 :            :     }
    1552                 :     363452 :     break;
    1553                 :            :     case typelib_TypeClass_INTERFACE_ATTRIBUTE:
    1554                 :            :     {
    1555                 :       6420 :         typelib_InterfaceAttributeTypeDescription * pIATD = (typelib_InterfaceAttributeTypeDescription*)pTD;
    1556                 :       6420 :         deleteExceptions(pIATD->nGetExceptions, pIATD->ppGetExceptions);
    1557                 :       6420 :         deleteExceptions(pIATD->nSetExceptions, pIATD->ppSetExceptions);
    1558         [ +  - ]:       6420 :         if( pIATD->pAttributeTypeRef )
    1559                 :       6420 :             typelib_typedescriptionreference_release( pIATD->pAttributeTypeRef );
    1560         [ +  - ]:       6420 :         if( pIATD->aBase.pMemberName )
    1561                 :       6420 :             rtl_uString_release( pIATD->aBase.pMemberName );
    1562                 :       6420 :         typelib_typedescription_release(&pIATD->pInterface->aBase);
    1563         [ +  + ]:       6420 :         if (pIATD->pBaseRef != 0) {
    1564                 :        416 :             typelib_typedescriptionreference_release(pIATD->pBaseRef);
    1565                 :            :         }
    1566                 :            :     }
    1567                 :       6420 :     break;
    1568                 :            :     case typelib_TypeClass_ENUM:
    1569                 :            :     {
    1570                 :       7777 :         typelib_EnumTypeDescription * pEnum = (typelib_EnumTypeDescription *)pTD;
    1571         [ +  + ]:      21745 :         for ( sal_Int32 nPos = pEnum->nEnumValues; nPos--; )
    1572                 :            :         {
    1573                 :      13968 :             rtl_uString_release( pEnum->ppEnumNames[nPos] );
    1574                 :            :         }
    1575         [ +  + ]:       7777 :         delete [] pEnum->ppEnumNames;
    1576         [ +  + ]:       7777 :         delete [] pEnum->pEnumValues;
    1577                 :            :     }
    1578                 :       7777 :     break;
    1579                 :            :     default:
    1580                 :       7873 :     break;
    1581                 :            :     }
    1582                 :     702101 : }
    1583                 :            : 
    1584                 :            : //------------------------------------------------------------------------
    1585                 :  192064903 : extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_release(
    1586                 :            :     typelib_TypeDescription * pTD )
    1587                 :            :     SAL_THROW_EXTERN_C()
    1588                 :            : {
    1589                 :  192064903 :     sal_Int32 ref = ::osl_decrementInterlockedCount( &pTD->nRefCount );
    1590                 :            :     OSL_ASSERT(ref >= 0);
    1591         [ +  + ]:  192065124 :     if (0 == ref)
    1592                 :            :     {
    1593                 :     694000 :         TypeDescriptor_Init_Impl &rInit = Init::get();
    1594         [ +  + ]:     694000 :         if( reallyWeak( pTD->eTypeClass ) )
    1595                 :            :         {
    1596         [ +  + ]:     369872 :             if( pTD->pWeakRef )
    1597                 :            :             {
    1598                 :            :                 {
    1599 [ +  - ][ +  - ]:     101825 :                 MutexGuard aGuard( rInit.getMutex() );
    1600                 :            :                 // remove this description from the weak reference
    1601         [ +  - ]:     101825 :                 pTD->pWeakRef->pType = 0;
    1602                 :            :                 }
    1603                 :     101825 :                 typelib_typedescriptionreference_release( pTD->pWeakRef );
    1604                 :            :             }
    1605                 :            :         }
    1606                 :            :         else
    1607                 :            :         {
    1608                 :            :             // this description is a reference too, so remove it from the hash table
    1609         [ +  - ]:     324128 :             if( rInit.pWeakMap )
    1610                 :            :             {
    1611 [ +  - ][ +  - ]:     324128 :                 MutexGuard aGuard( rInit.getMutex() );
    1612         [ +  - ]:     324128 :                 WeakMap_Impl::iterator aIt = rInit.pWeakMap->find( (sal_Unicode*)pTD->pTypeName->buffer );
    1613 [ +  - ][ +  - ]:     324128 :                 if( aIt != rInit.pWeakMap->end() && (void *)(*aIt).second == (void *)pTD )
         [ +  - ][ +  + ]
                 [ +  - ]
           [ +  +  #  # ]
    1614                 :            :                 {
    1615                 :            :                     // remove only if it contains the same object
    1616         [ +  - ]:     102956 :                     rInit.pWeakMap->erase( aIt );
    1617         [ +  - ]:     324128 :                 }
    1618                 :            :             }
    1619                 :            :         }
    1620                 :            : 
    1621                 :     694000 :         typelib_typedescription_destructExtendedMembers( pTD );
    1622                 :     694000 :         rtl_uString_release( pTD->pTypeName );
    1623                 :            : 
    1624                 :            : #if OSL_DEBUG_LEVEL > 1
    1625                 :            :         switch( pTD->eTypeClass )
    1626                 :            :         {
    1627                 :            :         case typelib_TypeClass_ARRAY:
    1628                 :            :             osl_decrementInterlockedCount( &rInit.nArrayTypeDescriptionCount );
    1629                 :            :             break;
    1630                 :            :         case typelib_TypeClass_SEQUENCE:
    1631                 :            :             osl_decrementInterlockedCount( &rInit.nIndirectTypeDescriptionCount );
    1632                 :            :             break;
    1633                 :            :         case typelib_TypeClass_UNION:
    1634                 :            :             osl_decrementInterlockedCount( &rInit.nUnionTypeDescriptionCount );
    1635                 :            :             break;
    1636                 :            :         case typelib_TypeClass_STRUCT:
    1637                 :            :         case typelib_TypeClass_EXCEPTION:
    1638                 :            :             osl_decrementInterlockedCount( &rInit.nCompoundTypeDescriptionCount );
    1639                 :            :             break;
    1640                 :            :         case typelib_TypeClass_INTERFACE:
    1641                 :            :             osl_decrementInterlockedCount( &rInit.nInterfaceTypeDescriptionCount );
    1642                 :            :             break;
    1643                 :            :         case typelib_TypeClass_INTERFACE_METHOD:
    1644                 :            :             osl_decrementInterlockedCount( &rInit.nInterfaceMethodTypeDescriptionCount );
    1645                 :            :             break;
    1646                 :            :         case typelib_TypeClass_INTERFACE_ATTRIBUTE:
    1647                 :            :             osl_decrementInterlockedCount( &rInit.nInterfaceAttributeTypeDescriptionCount );
    1648                 :            :             break;
    1649                 :            :         case typelib_TypeClass_ENUM:
    1650                 :            :             osl_decrementInterlockedCount( &rInit.nEnumTypeDescriptionCount );
    1651                 :            :             break;
    1652                 :            :         default:
    1653                 :            :             osl_decrementInterlockedCount( &rInit.nTypeDescriptionCount );
    1654                 :            :         }
    1655                 :            : #endif
    1656                 :            : 
    1657                 :     694000 :         delete pTD;
    1658                 :            :     }
    1659                 :  192065124 : }
    1660                 :            : 
    1661                 :            : //------------------------------------------------------------------------
    1662                 :     760005 : extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_register(
    1663                 :            :     typelib_TypeDescription ** ppNewDescription )
    1664                 :            :     SAL_THROW_EXTERN_C()
    1665                 :            : {
    1666                 :            :     // connect the description with the weak reference
    1667                 :     760005 :     TypeDescriptor_Init_Impl &rInit = Init::get();
    1668 [ +  - ][ +  - ]:     760005 :     ClearableMutexGuard aGuard( rInit.getMutex() );
    1669                 :            : 
    1670                 :     760005 :     typelib_TypeDescriptionReference * pTDR = 0;
    1671                 :     760005 :     typelib_typedescriptionreference_getByName( &pTDR, (*ppNewDescription)->pTypeName );
    1672                 :            : 
    1673                 :            :     OSL_ASSERT( (*ppNewDescription)->pWeakRef || reallyWeak( (*ppNewDescription)->eTypeClass ) );
    1674         [ +  + ]:     760005 :     if( pTDR )
    1675                 :            :     {
    1676                 :            :         OSL_ASSERT( (*ppNewDescription)->eTypeClass == pTDR->eTypeClass );
    1677         [ +  + ]:     681392 :         if( pTDR->pType )
    1678                 :            :         {
    1679         [ +  + ]:     489219 :             if (reallyWeak( pTDR->eTypeClass ))
    1680                 :            :             {
    1681                 :            :                 // pRef->pType->pWeakRef == 0 means that the description is empty
    1682         [ +  - ]:     268047 :                 if (pTDR->pType->pWeakRef)
    1683                 :            :                 {
    1684 [ +  - ][ +  - ]:     268047 :                     if (osl_incrementInterlockedCount( &pTDR->pType->nRefCount ) > 1)
    1685                 :            :                     {
    1686                 :            :                         // The refence is incremented. The object cannot be destroyed.
    1687                 :            :                         // Release the guard at the earliest point.
    1688         [ +  - ]:     268047 :                         aGuard.clear();
    1689                 :     268047 :                         ::typelib_typedescription_release( *ppNewDescription );
    1690                 :     268047 :                         *ppNewDescription = pTDR->pType;
    1691                 :     268047 :                         ::typelib_typedescriptionreference_release( pTDR );
    1692                 :            :                         return;
    1693                 :            :                     }
    1694                 :            :                     else
    1695                 :            :                     {
    1696                 :            :                         // destruction of this type in progress (another thread!)
    1697         [ #  # ]:          0 :                         osl_decrementInterlockedCount( &pTDR->pType->nRefCount );
    1698                 :            :                     }
    1699                 :            :                 }
    1700                 :            :                 // take new descr
    1701                 :          0 :                 pTDR->pType = *ppNewDescription;
    1702                 :            :                 OSL_ASSERT( ! (*ppNewDescription)->pWeakRef );
    1703                 :          0 :                 (*ppNewDescription)->pWeakRef = pTDR;
    1704                 :            :                 return;
    1705                 :            :             }
    1706                 :            :             // !reallyWeak
    1707                 :            : 
    1708 [ +  - ][ +  + ]:     221172 :             if (((void *)pTDR != (void *)*ppNewDescription) && // if different
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
                 [ +  - ]
    1709                 :     221172 :                 (!pTDR->pType->pWeakRef || // uninit: ref data only set
    1710                 :            :                  // new one is complete:
    1711                 :     169231 :                  (!pTDR->pType->bComplete && (*ppNewDescription)->bComplete) ||
    1712                 :            :                  // new one may be partly initialized interface (except of tables):
    1713                 :            :                  (typelib_TypeClass_INTERFACE == pTDR->pType->eTypeClass &&
    1714                 :     144061 :                   !((typelib_InterfaceTypeDescription *)pTDR->pType)->ppAllMembers &&
    1715                 :            :                   (*(typelib_InterfaceTypeDescription **)ppNewDescription)->ppAllMembers)))
    1716                 :            :             {
    1717                 :            :                 // uninitialized or incomplete
    1718                 :            : 
    1719         [ +  + ]:      60042 :                 if (pTDR->pType->pWeakRef) // if init
    1720                 :            :                 {
    1721                 :       8101 :                     typelib_typedescription_destructExtendedMembers( pTDR->pType );
    1722                 :            :                 }
    1723                 :            : 
    1724                 :            :                 // pTDR->pType->pWeakRef == 0 means that the description is empty
    1725                 :            :                 // description is not weak and the not the same
    1726                 :      60042 :                 sal_Int32 nSize = getDescriptionSize( (*ppNewDescription)->eTypeClass );
    1727                 :            : 
    1728                 :            :                 // copy all specific data for the descriptions
    1729                 :            :                 memcpy(
    1730                 :      60042 :                     pTDR->pType +1,
    1731                 :            :                     *ppNewDescription +1,
    1732                 :     120084 :                     nSize - sizeof(typelib_TypeDescription) );
    1733                 :            : 
    1734                 :      60042 :                 pTDR->pType->bComplete = (*ppNewDescription)->bComplete;
    1735                 :      60042 :                 pTDR->pType->nSize = (*ppNewDescription)->nSize;
    1736                 :      60042 :                 pTDR->pType->nAlignment = (*ppNewDescription)->nAlignment;
    1737                 :            : 
    1738                 :            :                 memset(
    1739                 :      60042 :                     *ppNewDescription +1,
    1740                 :            :                     0,
    1741                 :     120084 :                     nSize - sizeof( typelib_TypeDescription ) );
    1742                 :            : 
    1743 [ +  + ][ +  + ]:      60042 :                 if( pTDR->pType->bOnDemand && !(*ppNewDescription)->bOnDemand )
    1744                 :            :                 {
    1745                 :            :                     // switch from OnDemand to !OnDemand, so the description must be acquired
    1746                 :       6728 :                     typelib_typedescription_acquire( pTDR->pType );
    1747                 :            :                 }
    1748 [ +  + ][ -  + ]:      53314 :                 else if( !pTDR->pType->bOnDemand && (*ppNewDescription)->bOnDemand )
    1749                 :            :                 {
    1750                 :            :                     // switch from !OnDemand to OnDemand, so the description must be relesed
    1751                 :          0 :                     typelib_typedescription_release( pTDR->pType );
    1752                 :            :                 }
    1753                 :            : 
    1754                 :      60042 :                 pTDR->pType->bOnDemand = (*ppNewDescription)->bOnDemand;
    1755                 :            :                 // initialized
    1756                 :      60042 :                 pTDR->pType->pWeakRef = pTDR;
    1757                 :            :             }
    1758                 :            : 
    1759                 :     221172 :             typelib_typedescription_release( *ppNewDescription );
    1760                 :            :             // pTDR was acquired by getByName(), so it must not be acquired again
    1761                 :     221172 :             *ppNewDescription = pTDR->pType;
    1762                 :            :             return;
    1763                 :            :         }
    1764                 :            :     }
    1765         [ -  + ]:      78613 :     else if( reallyWeak( (*ppNewDescription)->eTypeClass) )
    1766                 :            :     {
    1767                 :            :         typelib_typedescriptionreference_new(
    1768                 :          0 :             &pTDR, (*ppNewDescription)->eTypeClass, (*ppNewDescription)->pTypeName );
    1769                 :            :     }
    1770                 :            :     else
    1771                 :            :     {
    1772                 :      78613 :         pTDR = (typelib_TypeDescriptionReference *)*ppNewDescription;
    1773         [ -  + ]:      78613 :         if( !rInit.pWeakMap )
    1774 [ #  # ][ #  # ]:          0 :             rInit.pWeakMap = new WeakMap_Impl;
    1775                 :            : 
    1776                 :            :         // description is the weak itself, so register it
    1777         [ +  - ]:      78613 :         (*rInit.pWeakMap)[pTDR->pTypeName->buffer] = pTDR;
    1778                 :            :         OSL_ASSERT( (void *)*ppNewDescription == (void *)pTDR );
    1779                 :            :     }
    1780                 :            : 
    1781                 :            :     // By default this reference is not really weak. The reference hold the description
    1782                 :            :     // and the description hold the reference.
    1783         [ +  + ]:     270786 :     if( !(*ppNewDescription)->bOnDemand )
    1784                 :            :     {
    1785                 :            :         // nor OnDemand so the description must be acquired if registered
    1786                 :     173604 :         typelib_typedescription_acquire( *ppNewDescription );
    1787                 :            :     }
    1788                 :            : 
    1789                 :     270786 :     pTDR->pType = *ppNewDescription;
    1790         [ +  + ]:    1030791 :     (*ppNewDescription)->pWeakRef = pTDR;
    1791                 :            :     OSL_ASSERT( rtl_ustr_compare( pTDR->pTypeName->buffer, (*ppNewDescription)->pTypeName->buffer ) == 0 );
    1792         [ +  - ]:     760005 :     OSL_ASSERT( pTDR->eTypeClass == (*ppNewDescription)->eTypeClass );
    1793                 :            : }
    1794                 :            : 
    1795                 :            : //------------------------------------------------------------------------
    1796                 :     479063 : static inline sal_Bool type_equals(
    1797                 :            :     typelib_TypeDescriptionReference * p1, typelib_TypeDescriptionReference * p2 )
    1798                 :            :     SAL_THROW(())
    1799                 :            : {
    1800                 :            :     return (p1 == p2 ||
    1801                 :            :             (p1->eTypeClass == p2->eTypeClass &&
    1802                 :            :              p1->pTypeName->length == p2->pTypeName->length &&
    1803 [ +  + ][ +  + ]:     479063 :              rtl_ustr_compare( p1->pTypeName->buffer, p2->pTypeName->buffer ) == 0));
            [ +  + ][ + ]
    1804                 :            : }
    1805                 :     148384 : extern "C" CPPU_DLLPUBLIC sal_Bool SAL_CALL typelib_typedescription_equals(
    1806                 :            :     const typelib_TypeDescription * p1, const typelib_TypeDescription * p2 )
    1807                 :            :     SAL_THROW_EXTERN_C()
    1808                 :            : {
    1809                 :            :     return type_equals(
    1810                 :     148384 :         (typelib_TypeDescriptionReference *)p1, (typelib_TypeDescriptionReference *)p2 );
    1811                 :            : }
    1812                 :            : 
    1813                 :            : //------------------------------------------------------------------------
    1814                 :     357182 : extern "C" sal_Int32 SAL_CALL typelib_typedescription_getAlignedUnoSize(
    1815                 :            :     const typelib_TypeDescription * pTypeDescription,
    1816                 :            :     sal_Int32 nOffset, sal_Int32 & rMaxIntegralTypeSize )
    1817                 :            :     SAL_THROW_EXTERN_C()
    1818                 :            : {
    1819                 :            :     sal_Int32 nSize;
    1820         [ +  + ]:     357182 :     if( pTypeDescription->nSize )
    1821                 :            :     {
    1822                 :            :         // size and alignment are set
    1823                 :      58169 :         rMaxIntegralTypeSize = pTypeDescription->nAlignment;
    1824                 :      58169 :         nSize = pTypeDescription->nSize;
    1825                 :            :     }
    1826                 :            :     else
    1827                 :            :     {
    1828                 :     299013 :         nSize = 0;
    1829                 :     299013 :         rMaxIntegralTypeSize = 1;
    1830                 :            : 
    1831                 :            :         OSL_ASSERT( typelib_TypeClass_TYPEDEF != pTypeDescription->eTypeClass );
    1832                 :            : 
    1833   [ +  -  +  +  :     299013 :         switch( pTypeDescription->eTypeClass )
          -  +  +  +  +  
          +  +  +  +  +  
             +  +  +  - ]
    1834                 :            :         {
    1835                 :            :             case typelib_TypeClass_INTERFACE:
    1836                 :            :                 // FEATURE_INTERFACE
    1837                 :     219974 :                 nSize = rMaxIntegralTypeSize = (sal_Int32)(sizeof( void * ));
    1838                 :     219974 :                 break;
    1839                 :            :             case typelib_TypeClass_UNION:
    1840                 :            :                 {
    1841                 :          0 :                 nSize = rMaxIntegralTypeSize = (sal_Int32)(sizeof(sal_Int64));
    1842         [ #  # ]:          0 :                 for ( sal_Int32 nPos = ((typelib_UnionTypeDescription *)pTypeDescription)->nMembers; nPos--; )
    1843                 :            :                 {
    1844                 :          0 :                     typelib_TypeDescription * pTD = 0;
    1845 [ #  # ][ #  # ]:          0 :                     TYPELIB_DANGER_GET( &pTD, ((typelib_UnionTypeDescription *)pTypeDescription)->ppTypeRefs[nPos] );
         [ #  # ][ #  # ]
                 [ #  # ]
    1846                 :            :                     sal_Int32 nMaxIntegralTypeSize;
    1847                 :          0 :                     sal_Int32 nMemberSize = typelib_typedescription_getAlignedUnoSize( pTD, (sal_Int32)(sizeof(sal_Int64)), nMaxIntegralTypeSize );
    1848 [ #  # ][ #  # ]:          0 :                     TYPELIB_DANGER_RELEASE( pTD );
    1849         [ #  # ]:          0 :                     if (nSize < nMemberSize)
    1850                 :          0 :                         nSize = nMemberSize;
    1851         [ #  # ]:          0 :                     if (rMaxIntegralTypeSize < nMaxIntegralTypeSize)
    1852                 :          0 :                         rMaxIntegralTypeSize = nMaxIntegralTypeSize;
    1853                 :            :                 }
    1854                 :          0 :                 ((typelib_UnionTypeDescription *)pTypeDescription)->nValueOffset = rMaxIntegralTypeSize;
    1855                 :            :                 }
    1856                 :          0 :                 break;
    1857                 :            :             case typelib_TypeClass_ENUM:
    1858                 :       4399 :                 nSize = rMaxIntegralTypeSize = (sal_Int32)(sizeof( typelib_TypeClass ));
    1859                 :       4399 :                 break;
    1860                 :            :             case typelib_TypeClass_STRUCT:
    1861                 :            :             case typelib_TypeClass_EXCEPTION:
    1862                 :            :                 // FEATURE_EMPTYCLASS
    1863                 :            :                 {
    1864                 :      45583 :                 typelib_CompoundTypeDescription * pTmp = (typelib_CompoundTypeDescription *)pTypeDescription;
    1865                 :      45583 :                 sal_Int32 nStructSize = 0;
    1866         [ +  + ]:      45583 :                 if( pTmp->pBaseTypeDescription )
    1867                 :            :                 {
    1868                 :            :                     // inherit structs extends the base struct.
    1869                 :      30415 :                     nStructSize = pTmp->pBaseTypeDescription->aBase.nSize;
    1870                 :      30415 :                     rMaxIntegralTypeSize = pTmp->pBaseTypeDescription->aBase.nAlignment;
    1871                 :            :                  }
    1872         [ +  + ]:     109670 :                 for( sal_Int32 i = 0; i < pTmp->nMembers; i++ )
    1873                 :            :                 {
    1874                 :      64087 :                     typelib_TypeDescription * pMemberType = 0;
    1875                 :      64087 :                     typelib_TypeDescriptionReference * pMemberRef = pTmp->ppTypeRefs[i];
    1876                 :            : 
    1877                 :            :                     sal_Int32 nMaxIntegral;
    1878 [ +  + ][ +  + ]:      64087 :                     if (pMemberRef->eTypeClass == typelib_TypeClass_INTERFACE
    1879                 :            :                         || pMemberRef->eTypeClass == typelib_TypeClass_SEQUENCE)
    1880                 :            :                     {
    1881                 :       5918 :                         nMaxIntegral = (sal_Int32)(sizeof(void *));
    1882                 :       5918 :                         nStructSize = newAlignedSize( nStructSize, nMaxIntegral, nMaxIntegral );
    1883                 :            :                     }
    1884                 :            :                     else
    1885                 :            :                     {
    1886 [ +  - ][ -  + ]:      58169 :                         TYPELIB_DANGER_GET( &pMemberType, pMemberRef );
         [ +  - ][ -  + ]
                 [ #  # ]
    1887                 :            :                         nStructSize = typelib_typedescription_getAlignedUnoSize(
    1888                 :      58169 :                             pMemberType, nStructSize, nMaxIntegral );
    1889 [ -  + ][ +  - ]:      58169 :                         TYPELIB_DANGER_RELEASE( pMemberType );
    1890                 :            :                     }
    1891         [ +  + ]:      64087 :                     if( nMaxIntegral > rMaxIntegralTypeSize )
    1892                 :      15401 :                         rMaxIntegralTypeSize = nMaxIntegral;
    1893                 :            :                 }
    1894                 :            : #ifdef __m68k__
    1895                 :            :                 // Anything that is at least 16 bits wide is aligned on a 16-bit
    1896                 :            :                 // boundary on the m68k default abi
    1897                 :            :                 sal_Int32 nMaxAlign = (rMaxIntegralTypeSize > 2) ? 2 : rMaxIntegralTypeSize;
    1898                 :            :                 nStructSize = (nStructSize + nMaxAlign -1) / nMaxAlign * nMaxAlign;
    1899                 :            : #else
    1900                 :            :                 // Example: A { double; int; } structure has a size of 16 instead of 10. The
    1901                 :            :                 // compiler must follow this rule if it is possible to access members in arrays through:
    1902                 :            :                 // (Element *)((char *)pArray + sizeof( Element ) * ElementPos)
    1903                 :            :                 nStructSize = (nStructSize + rMaxIntegralTypeSize -1)
    1904                 :      45583 :                                 / rMaxIntegralTypeSize * rMaxIntegralTypeSize;
    1905                 :            : #endif
    1906                 :      45583 :                 nSize += nStructSize;
    1907                 :            :                 }
    1908                 :      45583 :                 break;
    1909                 :            :             case typelib_TypeClass_ARRAY:
    1910                 :            :                 {
    1911                 :          0 :                 typelib_TypeDescription * pTD = 0;
    1912 [ #  # ][ #  # ]:          0 :                 TYPELIB_DANGER_GET( &pTD, ((typelib_IndirectTypeDescription *)pTypeDescription)->pType );
         [ #  # ][ #  # ]
                 [ #  # ]
    1913                 :          0 :                 rMaxIntegralTypeSize = pTD->nSize;
    1914 [ #  # ][ #  # ]:          0 :                 TYPELIB_DANGER_RELEASE( pTD );
    1915                 :          0 :                 nSize = ((typelib_ArrayTypeDescription *)pTypeDescription)->nTotalElements * rMaxIntegralTypeSize;
    1916                 :            :                 }
    1917                 :          0 :                 break;
    1918                 :            :             case typelib_TypeClass_SEQUENCE:
    1919                 :      17804 :                 nSize = rMaxIntegralTypeSize = (sal_Int32)(sizeof( void * ));
    1920                 :      17804 :                 break;
    1921                 :            :             case typelib_TypeClass_ANY:
    1922                 :            :                 // FEATURE_ANY
    1923                 :        772 :                 nSize = (sal_Int32)(sizeof( uno_Any ));
    1924                 :        772 :                 rMaxIntegralTypeSize = (sal_Int32)(sizeof( void * ));
    1925                 :        772 :                 break;
    1926                 :            :             case typelib_TypeClass_TYPE:
    1927                 :        772 :                 nSize = rMaxIntegralTypeSize = (sal_Int32)(sizeof( typelib_TypeDescriptionReference * ));
    1928                 :        772 :                 break;
    1929                 :            :             case typelib_TypeClass_BOOLEAN:
    1930                 :        772 :                 nSize = rMaxIntegralTypeSize = (sal_Int32)(sizeof( sal_Bool ));
    1931                 :        772 :                 break;
    1932                 :            :             case typelib_TypeClass_CHAR:
    1933                 :        772 :                 nSize = rMaxIntegralTypeSize = (sal_Int32)(sizeof( sal_Unicode ));
    1934                 :        772 :                 break;
    1935                 :            :             case typelib_TypeClass_STRING:
    1936                 :            :                 // FEATURE_STRING
    1937                 :        772 :                 nSize = rMaxIntegralTypeSize = (sal_Int32)(sizeof( rtl_uString * ));
    1938                 :        772 :                 break;
    1939                 :            :             case typelib_TypeClass_FLOAT:
    1940                 :        772 :                 nSize = rMaxIntegralTypeSize = (sal_Int32)(sizeof( float ));
    1941                 :        772 :                 break;
    1942                 :            :             case typelib_TypeClass_DOUBLE:
    1943                 :            : #ifdef AIX
    1944                 :            :                 //See previous AIX ifdef comment for an explanation
    1945                 :            :                 nSize = (sal_Int32)(sizeof(double));
    1946                 :            :                 rMaxIntegralTypeSize = (sal_Int32)(sizeof(void*));
    1947                 :            : #else
    1948                 :        778 :                 nSize = rMaxIntegralTypeSize = (sal_Int32)(sizeof( double ));
    1949                 :            : #endif
    1950                 :        778 :                 break;
    1951                 :            :             case typelib_TypeClass_BYTE:
    1952                 :        772 :                 nSize = rMaxIntegralTypeSize = (sal_Int32)(sizeof( sal_Int8 ));
    1953                 :        772 :                 break;
    1954                 :            :             case typelib_TypeClass_SHORT:
    1955                 :            :             case typelib_TypeClass_UNSIGNED_SHORT:
    1956                 :       1544 :                 nSize = rMaxIntegralTypeSize = (sal_Int32)(sizeof( sal_Int16 ));
    1957                 :       1544 :                 break;
    1958                 :            :             case typelib_TypeClass_LONG:
    1959                 :            :             case typelib_TypeClass_UNSIGNED_LONG:
    1960                 :       1983 :                 nSize = rMaxIntegralTypeSize = (sal_Int32)(sizeof( sal_Int32 ));
    1961                 :       1983 :                 break;
    1962                 :            :             case typelib_TypeClass_HYPER:
    1963                 :            :             case typelib_TypeClass_UNSIGNED_HYPER:
    1964                 :       1544 :                 nSize = rMaxIntegralTypeSize = (sal_Int32)(sizeof( sal_Int64 ));
    1965                 :       1544 :                 break;
    1966                 :            :             case typelib_TypeClass_UNKNOWN:
    1967                 :            :             case typelib_TypeClass_SERVICE:
    1968                 :            :             case typelib_TypeClass_MODULE:
    1969                 :            :             default:
    1970                 :            :                 OSL_FAIL( "not convertable type" );
    1971                 :            :         };
    1972                 :            :     }
    1973                 :            : 
    1974                 :     357182 :     return newAlignedSize( nOffset, nSize, rMaxIntegralTypeSize );
    1975                 :            : }
    1976                 :            : 
    1977                 :            : //------------------------------------------------------------------------
    1978                 :            : 
    1979                 :            : namespace {
    1980                 :            : 
    1981                 :      60941 : typelib_TypeDescriptionReference ** copyExceptions(
    1982                 :            :     sal_Int32 count, typelib_TypeDescriptionReference ** source)
    1983                 :            : {
    1984                 :            :     typelib_TypeDescriptionReference ** p
    1985                 :      60941 :         = new typelib_TypeDescriptionReference *[count];
    1986         [ +  + ]:      85474 :     for (sal_Int32 i = 0; i < count; ++i) {
    1987                 :      24533 :         typelib_typedescriptionreference_acquire(p[i] = source[i]);
    1988                 :            :     }
    1989                 :      60941 :     return p;
    1990                 :            : }
    1991                 :            : 
    1992                 :      59678 : bool createDerivedInterfaceMemberDescription(
    1993                 :            :     typelib_TypeDescription ** result, rtl::OUString const & name,
    1994                 :            :     typelib_TypeDescriptionReference * baseRef,
    1995                 :            :     typelib_TypeDescription const * base, typelib_TypeDescription * interface,
    1996                 :            :     sal_Int32 index, sal_Int32 position)
    1997                 :            : {
    1998 [ +  - ][ +  - ]:      59678 :     if (baseRef != 0 && base != 0 && interface != 0) {
                 [ +  - ]
    1999      [ +  +  - ]:      59678 :         switch (base->eTypeClass) {
    2000                 :            :         case typelib_TypeClass_INTERFACE_METHOD:
    2001                 :            :             {
    2002                 :            :                 typelib_typedescription_newEmpty(
    2003                 :      58415 :                     result, typelib_TypeClass_INTERFACE_METHOD, name.pData);
    2004                 :            :                 typelib_InterfaceMethodTypeDescription const * baseMethod
    2005                 :            :                     = reinterpret_cast<
    2006                 :      58415 :                     typelib_InterfaceMethodTypeDescription const * >(base);
    2007                 :            :                 typelib_InterfaceMethodTypeDescription * newMethod
    2008                 :            :                     = reinterpret_cast<
    2009                 :      58415 :                     typelib_InterfaceMethodTypeDescription * >(*result);
    2010                 :      58415 :                 newMethod->aBase.nPosition = position;
    2011                 :            :                 rtl_uString_acquire(
    2012                 :            :                     newMethod->aBase.pMemberName
    2013                 :      58415 :                     = baseMethod->aBase.pMemberName);
    2014                 :            :                 typelib_typedescriptionreference_acquire(
    2015                 :      58415 :                     newMethod->pReturnTypeRef = baseMethod->pReturnTypeRef);
    2016                 :      58415 :                 newMethod->nParams = baseMethod->nParams;
    2017                 :            :                 newMethod->pParams = new typelib_MethodParameter[
    2018                 :      58415 :                     newMethod->nParams];
    2019         [ +  + ]:      81983 :                 for (sal_Int32 i = 0; i < newMethod->nParams; ++i) {
    2020                 :            :                     rtl_uString_acquire(
    2021                 :      23568 :                         newMethod->pParams[i].pName
    2022                 :      23568 :                         = baseMethod->pParams[i].pName);
    2023                 :            :                     typelib_typedescriptionreference_acquire(
    2024                 :      23568 :                         newMethod->pParams[i].pTypeRef
    2025                 :      23568 :                         = baseMethod->pParams[i].pTypeRef);
    2026                 :      23568 :                     newMethod->pParams[i].bIn = baseMethod->pParams[i].bIn;
    2027                 :      23568 :                     newMethod->pParams[i].bOut = baseMethod->pParams[i].bOut;
    2028                 :            :                 }
    2029                 :      58415 :                 newMethod->nExceptions = baseMethod->nExceptions;
    2030                 :            :                 newMethod->ppExceptions = copyExceptions(
    2031                 :      58415 :                     baseMethod->nExceptions, baseMethod->ppExceptions);
    2032                 :      58415 :                 newMethod->bOneWay = baseMethod->bOneWay;
    2033                 :            :                 newMethod->pInterface
    2034                 :            :                     = reinterpret_cast< typelib_InterfaceTypeDescription * >(
    2035                 :      58415 :                         interface);
    2036                 :      58415 :                 newMethod->pBaseRef = baseRef;
    2037                 :      58415 :                 newMethod->nIndex = index;
    2038                 :      58415 :                 return true;
    2039                 :            :             }
    2040                 :            : 
    2041                 :            :         case typelib_TypeClass_INTERFACE_ATTRIBUTE:
    2042                 :            :             {
    2043                 :            :                 typelib_typedescription_newEmpty(
    2044                 :       1263 :                     result, typelib_TypeClass_INTERFACE_ATTRIBUTE, name.pData);
    2045                 :            :                 typelib_InterfaceAttributeTypeDescription const * baseAttribute
    2046                 :            :                     = reinterpret_cast<
    2047                 :       1263 :                     typelib_InterfaceAttributeTypeDescription const * >(base);
    2048                 :            :                 typelib_InterfaceAttributeTypeDescription * newAttribute
    2049                 :            :                     = reinterpret_cast<
    2050                 :       1263 :                     typelib_InterfaceAttributeTypeDescription * >(*result);
    2051                 :       1263 :                 newAttribute->aBase.nPosition = position;
    2052                 :            :                 rtl_uString_acquire(
    2053                 :            :                     newAttribute->aBase.pMemberName
    2054                 :       1263 :                     = baseAttribute->aBase.pMemberName);
    2055                 :       1263 :                 newAttribute->bReadOnly = baseAttribute->bReadOnly;
    2056                 :            :                 typelib_typedescriptionreference_acquire(
    2057                 :            :                     newAttribute->pAttributeTypeRef
    2058                 :       1263 :                     = baseAttribute->pAttributeTypeRef);
    2059                 :            :                 newAttribute->pInterface
    2060                 :            :                     = reinterpret_cast< typelib_InterfaceTypeDescription * >(
    2061                 :       1263 :                         interface);
    2062                 :       1263 :                 newAttribute->pBaseRef = baseRef;
    2063                 :       1263 :                 newAttribute->nIndex = index;
    2064                 :       1263 :                 newAttribute->nGetExceptions = baseAttribute->nGetExceptions;
    2065                 :            :                 newAttribute->ppGetExceptions = copyExceptions(
    2066                 :            :                     baseAttribute->nGetExceptions,
    2067                 :       1263 :                     baseAttribute->ppGetExceptions);
    2068                 :       1263 :                 newAttribute->nSetExceptions = baseAttribute->nSetExceptions;
    2069                 :            :                 newAttribute->ppSetExceptions = copyExceptions(
    2070                 :            :                     baseAttribute->nSetExceptions,
    2071                 :       1263 :                     baseAttribute->ppSetExceptions);
    2072                 :       1263 :                 return true;
    2073                 :            :             }
    2074                 :            : 
    2075                 :            :         default:
    2076                 :          0 :             break;
    2077                 :            :         }
    2078                 :            :     }
    2079                 :      59678 :     return false;
    2080                 :            : }
    2081                 :            : 
    2082                 :            : }
    2083                 :            : 
    2084                 :     700665 : extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_getByName(
    2085                 :            :     typelib_TypeDescription ** ppRet, rtl_uString * pName )
    2086                 :            :     SAL_THROW_EXTERN_C()
    2087                 :            : {
    2088         [ -  + ]:     700665 :     if( *ppRet )
    2089                 :            :     {
    2090                 :          0 :         typelib_typedescription_release( (*ppRet) );
    2091                 :          0 :         *ppRet = 0;
    2092                 :            :     }
    2093                 :            : 
    2094                 :            :     static sal_Bool bInited = sal_False;
    2095                 :     700665 :     TypeDescriptor_Init_Impl &rInit = Init::get();
    2096                 :            : 
    2097         [ +  + ]:     700665 :     if( !bInited )
    2098                 :            :     {
    2099                 :            :         // guard against multi thread access
    2100 [ +  - ][ +  - ]:        772 :         MutexGuard aGuard( rInit.getMutex() );
    2101         [ +  - ]:        772 :         if( !bInited )
    2102                 :            :         {
    2103                 :            :             // avoid recursion during the next ...new calls
    2104                 :        772 :             bInited = sal_True;
    2105                 :            : 
    2106                 :        772 :             rtl_uString * pTypeName = 0;
    2107                 :        772 :             typelib_TypeDescription * pType = 0;
    2108                 :        772 :             rtl_uString_newFromAscii( &pTypeName, "type" );
    2109                 :        772 :             typelib_typedescription_new( &pType, typelib_TypeClass_TYPE, pTypeName, 0, 0, 0 );
    2110                 :        772 :             typelib_typedescription_register( &pType );
    2111                 :        772 :             rtl_uString_newFromAscii( &pTypeName, "void" );
    2112                 :        772 :             typelib_typedescription_new( &pType, typelib_TypeClass_VOID, pTypeName, 0, 0, 0 );
    2113                 :        772 :             typelib_typedescription_register( &pType );
    2114                 :        772 :             rtl_uString_newFromAscii( &pTypeName, "boolean" );
    2115                 :        772 :             typelib_typedescription_new( &pType, typelib_TypeClass_BOOLEAN, pTypeName, 0, 0, 0 );
    2116                 :        772 :             typelib_typedescription_register( &pType );
    2117                 :        772 :             rtl_uString_newFromAscii( &pTypeName, "char" );
    2118                 :        772 :             typelib_typedescription_new( &pType, typelib_TypeClass_CHAR, pTypeName, 0, 0, 0 );
    2119                 :        772 :             typelib_typedescription_register( &pType );
    2120                 :        772 :             rtl_uString_newFromAscii( &pTypeName, "byte" );
    2121                 :        772 :             typelib_typedescription_new( &pType, typelib_TypeClass_BYTE, pTypeName, 0, 0, 0 );
    2122                 :        772 :             typelib_typedescription_register( &pType );
    2123                 :        772 :             rtl_uString_newFromAscii( &pTypeName, "string" );
    2124                 :        772 :             typelib_typedescription_new( &pType, typelib_TypeClass_STRING, pTypeName, 0, 0, 0 );
    2125                 :        772 :             typelib_typedescription_register( &pType );
    2126                 :        772 :             rtl_uString_newFromAscii( &pTypeName, "short" );
    2127                 :        772 :             typelib_typedescription_new( &pType, typelib_TypeClass_SHORT, pTypeName, 0, 0, 0 );
    2128                 :        772 :             typelib_typedescription_register( &pType );
    2129                 :        772 :             rtl_uString_newFromAscii( &pTypeName, "unsigned short" );
    2130                 :        772 :             typelib_typedescription_new( &pType, typelib_TypeClass_UNSIGNED_SHORT, pTypeName, 0, 0, 0 );
    2131                 :        772 :             typelib_typedescription_register( &pType );
    2132                 :        772 :             rtl_uString_newFromAscii( &pTypeName, "long" );
    2133                 :        772 :             typelib_typedescription_new( &pType, typelib_TypeClass_LONG, pTypeName, 0, 0, 0 );
    2134                 :        772 :             typelib_typedescription_register( &pType );
    2135                 :        772 :             rtl_uString_newFromAscii( &pTypeName, "unsigned long" );
    2136                 :        772 :             typelib_typedescription_new( &pType, typelib_TypeClass_UNSIGNED_LONG, pTypeName, 0, 0, 0 );
    2137                 :        772 :             typelib_typedescription_register( &pType );
    2138                 :        772 :             rtl_uString_newFromAscii( &pTypeName, "hyper" );
    2139                 :        772 :             typelib_typedescription_new( &pType, typelib_TypeClass_HYPER, pTypeName, 0, 0, 0 );
    2140                 :        772 :             typelib_typedescription_register( &pType );
    2141                 :        772 :             rtl_uString_newFromAscii( &pTypeName, "unsigned hyper" );
    2142                 :        772 :             typelib_typedescription_new( &pType, typelib_TypeClass_UNSIGNED_HYPER, pTypeName, 0, 0, 0 );
    2143                 :        772 :             typelib_typedescription_register( &pType );
    2144                 :        772 :             rtl_uString_newFromAscii( &pTypeName, "float" );
    2145                 :        772 :             typelib_typedescription_new( &pType, typelib_TypeClass_FLOAT, pTypeName, 0, 0, 0 );
    2146                 :        772 :             typelib_typedescription_register( &pType );
    2147                 :        772 :             rtl_uString_newFromAscii( &pTypeName, "double" );
    2148                 :        772 :             typelib_typedescription_new( &pType, typelib_TypeClass_DOUBLE, pTypeName, 0, 0, 0 );
    2149                 :        772 :             typelib_typedescription_register( &pType );
    2150                 :        772 :             rtl_uString_newFromAscii( &pTypeName, "any" );
    2151                 :        772 :             typelib_typedescription_new( &pType, typelib_TypeClass_ANY, pTypeName, 0, 0, 0 );
    2152                 :        772 :             typelib_typedescription_register( &pType );
    2153                 :        772 :             typelib_typedescription_release( pType );
    2154                 :        772 :             rtl_uString_release( pTypeName );
    2155         [ +  - ]:        772 :         }
    2156                 :            :     }
    2157                 :            : 
    2158                 :     700665 :     typelib_TypeDescriptionReference * pTDR = 0;
    2159                 :     700665 :     typelib_typedescriptionreference_getByName( &pTDR, pName );
    2160         [ +  + ]:     700665 :     if( pTDR )
    2161                 :            :     {
    2162                 :            :         {
    2163                 :            :         // guard against multi thread access
    2164 [ +  - ][ +  - ]:     696718 :         MutexGuard aGuard( rInit.getMutex() );
    2165                 :            :         // pTDR->pType->pWeakRef == 0 means that the description is empty
    2166 [ +  + ][ +  + ]:     696718 :         if( pTDR->pType && pTDR->pType->pWeakRef )
    2167                 :            :         {
    2168                 :     555485 :             typelib_typedescription_acquire( pTDR->pType );
    2169                 :     555485 :             *ppRet = pTDR->pType;
    2170         [ +  - ]:     696718 :         }
    2171                 :            :         }
    2172                 :     696718 :         typelib_typedescriptionreference_release( pTDR );
    2173                 :            :     }
    2174                 :            : 
    2175         [ +  + ]:     700665 :     if (0 == *ppRet)
    2176                 :            :     {
    2177                 :            :         // check for sequence
    2178                 :     145180 :         OUString const & name = *reinterpret_cast< OUString const * >( &pName );
    2179 [ +  - ][ +  + ]:     145180 :         if (2 < name.getLength() && '[' == name[ 0 ])
                 [ +  + ]
    2180                 :            :         {
    2181                 :        209 :             OUString element_name( name.copy( 2 ) );
    2182                 :        209 :             typelib_TypeDescription * element_td = 0;
    2183                 :        209 :             typelib_typedescription_getByName( &element_td, element_name.pData );
    2184         [ +  - ]:        209 :             if (0 != element_td)
    2185                 :            :             {
    2186                 :            :                 typelib_typedescription_new(
    2187                 :        209 :                     ppRet, typelib_TypeClass_SEQUENCE, pName, element_td->pWeakRef, 0, 0 );
    2188                 :            :                 // register?
    2189                 :        209 :                 typelib_typedescription_release( element_td );
    2190                 :        209 :             }
    2191                 :            :         }
    2192         [ +  + ]:     145180 :         if (0 == *ppRet)
    2193                 :            :         {
    2194                 :            :             // Check for derived interface member type:
    2195                 :            :             sal_Int32 i1 = name.lastIndexOf(
    2196         [ +  - ]:     144971 :                 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(":@")));
    2197         [ +  + ]:     144971 :             if (i1 >= 0) {
    2198                 :      59678 :                 sal_Int32 i2 = i1 + RTL_CONSTASCII_LENGTH(":@");
    2199                 :      59678 :                 sal_Int32 i3 = name.indexOf(',', i2);
    2200         [ +  - ]:      59678 :                 if (i3 >= 0) {
    2201                 :      59678 :                     sal_Int32 i4 = name.indexOf(':', i3);
    2202         [ +  - ]:      59678 :                     if (i4 >= 0) {
    2203                 :      59678 :                         typelib_TypeDescriptionReference * pBaseRef = 0;
    2204                 :      59678 :                         typelib_TypeDescription * pBase = 0;
    2205                 :      59678 :                         typelib_TypeDescription * pInterface = 0;
    2206                 :            :                         typelib_typedescriptionreference_getByName(
    2207                 :      59678 :                             &pBaseRef, name.copy(0, i1).pData);
    2208         [ +  - ]:      59678 :                         if (pBaseRef != 0) {
    2209                 :            :                             typelib_typedescriptionreference_getDescription(
    2210                 :      59678 :                                 &pBase, pBaseRef);
    2211                 :            :                         }
    2212                 :            :                         typelib_typedescription_getByName(
    2213                 :      59678 :                             &pInterface, name.copy(i4 + 1).pData);
    2214         [ -  + ]:      59678 :                         if (!createDerivedInterfaceMemberDescription(
    2215                 :            :                                 ppRet, name, pBaseRef, pBase, pInterface,
    2216                 :            :                                 name.copy(i2, i3 - i2).toInt32(),
    2217         [ +  - ]:      59678 :                                 name.copy(i3 + 1, i4 - i3 - 1).toInt32()))
    2218                 :            :                         {
    2219         [ #  # ]:          0 :                             if (pInterface != 0) {
    2220                 :          0 :                                 typelib_typedescription_release(pInterface);
    2221                 :            :                             }
    2222         [ #  # ]:          0 :                             if (pBase != 0) {
    2223                 :          0 :                                 typelib_typedescription_release(pBase);
    2224                 :            :                             }
    2225         [ #  # ]:          0 :                             if (pBaseRef != 0) {
    2226                 :            :                                 typelib_typedescriptionreference_release(
    2227                 :      59678 :                                     pBaseRef);
    2228                 :            :                             }
    2229                 :            :                         }
    2230                 :            :                     }
    2231                 :            :                 }
    2232                 :            :             }
    2233                 :            :         }
    2234         [ +  + ]:     145180 :         if (0 == *ppRet)
    2235                 :            :         {
    2236                 :            :             // on demand access
    2237         [ +  - ]:      85293 :             rInit.callChain( ppRet, pName );
    2238                 :            :         }
    2239                 :            : 
    2240         [ +  + ]:     145180 :         if( *ppRet )
    2241                 :            :         {
    2242                 :            :             // typedescription found
    2243         [ -  + ]:     142370 :             if (typelib_TypeClass_TYPEDEF == (*ppRet)->eTypeClass)
    2244                 :            :             {
    2245                 :          0 :                 typelib_TypeDescription * pTD = 0;
    2246                 :            :                 typelib_typedescriptionreference_getDescription(
    2247                 :          0 :                     &pTD, ((typelib_IndirectTypeDescription *)*ppRet)->pType );
    2248                 :          0 :                 typelib_typedescription_release( *ppRet );
    2249                 :          0 :                 *ppRet = pTD;
    2250                 :            :             }
    2251                 :            :             else
    2252                 :            :             {
    2253                 :            :                 // set to on demand
    2254                 :     142370 :                 (*ppRet)->bOnDemand = sal_True;
    2255                 :            :                 // The type description is hold by the reference until
    2256                 :            :                 // on demand is activated.
    2257                 :     142370 :                 typelib_typedescription_register( ppRet );
    2258                 :            : 
    2259                 :            :                 // insert into the chache
    2260 [ +  - ][ +  - ]:     142370 :                 MutexGuard aGuard( rInit.getMutex() );
    2261         [ +  + ]:     142370 :                 if( !rInit.pCache )
    2262 [ +  - ][ +  - ]:        343 :                     rInit.pCache = new TypeDescriptionList_Impl;
    2263         [ +  + ]:     142370 :                 if( (sal_Int32)rInit.pCache->size() >= nCacheSize )
    2264                 :            :                 {
    2265         [ +  - ]:      88641 :                     typelib_typedescription_release( rInit.pCache->front() );
    2266         [ +  - ]:      88641 :                     rInit.pCache->pop_front();
    2267                 :            :                 }
    2268                 :            :                 // descriptions in the cache must be acquired!
    2269                 :     142370 :                 typelib_typedescription_acquire( *ppRet );
    2270 [ +  - ][ +  - ]:     142370 :                 rInit.pCache->push_back( *ppRet );
    2271                 :            :             }
    2272                 :            :         }
    2273                 :            :     }
    2274                 :     700665 : }
    2275                 :            : 
    2276                 :          0 : extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescriptionreference_newByAsciiName(
    2277                 :            :     typelib_TypeDescriptionReference ** ppTDR,
    2278                 :            :     typelib_TypeClass eTypeClass,
    2279                 :            :     const sal_Char * pTypeName )
    2280                 :            :     SAL_THROW_EXTERN_C()
    2281                 :            : {
    2282                 :          0 :     OUString aTypeName( OUString::createFromAscii( pTypeName ) );
    2283                 :          0 :     typelib_typedescriptionreference_new( ppTDR, eTypeClass, aTypeName.pData );
    2284                 :          0 : }
    2285                 :            : //------------------------------------------------------------------------
    2286                 :    3273123 : extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescriptionreference_new(
    2287                 :            :     typelib_TypeDescriptionReference ** ppTDR,
    2288                 :            :     typelib_TypeClass eTypeClass, rtl_uString * pTypeName )
    2289                 :            :     SAL_THROW_EXTERN_C()
    2290                 :            : {
    2291                 :    3273123 :     TypeDescriptor_Init_Impl &rInit = Init::get();
    2292         [ +  + ]:    3273123 :     if( eTypeClass == typelib_TypeClass_TYPEDEF )
    2293                 :            :     {
    2294                 :            :         // on demand access
    2295                 :        708 :         typelib_TypeDescription * pRet = 0;
    2296         [ +  - ]:        708 :         rInit.callChain( &pRet, pTypeName );
    2297         [ +  - ]:        708 :         if( pRet )
    2298                 :            :         {
    2299                 :            :             // typedescription found
    2300         [ -  + ]:        708 :             if (typelib_TypeClass_TYPEDEF == pRet->eTypeClass)
    2301                 :            :             {
    2302                 :            :                 typelib_typedescriptionreference_acquire(
    2303                 :          0 :                     ((typelib_IndirectTypeDescription *)pRet)->pType );
    2304         [ #  # ]:          0 :                 if (*ppTDR)
    2305                 :          0 :                     typelib_typedescriptionreference_release( *ppTDR );
    2306                 :          0 :                 *ppTDR = ((typelib_IndirectTypeDescription *)pRet)->pType;
    2307                 :          0 :                 typelib_typedescription_release( pRet );
    2308                 :            :             }
    2309                 :            :             else
    2310                 :            :             {
    2311                 :            :                 // set to on demand
    2312                 :        708 :                 pRet->bOnDemand = sal_True;
    2313                 :            :                 // The type description is hold by the reference until
    2314                 :            :                 // on demand is activated.
    2315                 :        708 :                 typelib_typedescription_register( &pRet );
    2316                 :            : 
    2317                 :            :                 // insert into the chache
    2318 [ +  - ][ +  - ]:        708 :                 MutexGuard aGuard( rInit.getMutex() );
    2319         [ -  + ]:        708 :                 if( !rInit.pCache )
    2320 [ #  # ][ #  # ]:          0 :                     rInit.pCache = new TypeDescriptionList_Impl;
    2321         [ +  + ]:        708 :                 if( (sal_Int32)rInit.pCache->size() >= nCacheSize )
    2322                 :            :                 {
    2323         [ +  - ]:        591 :                     typelib_typedescription_release( rInit.pCache->front() );
    2324         [ +  - ]:        591 :                     rInit.pCache->pop_front();
    2325                 :            :                 }
    2326         [ +  - ]:        708 :                 rInit.pCache->push_back( pRet );
    2327                 :            :                 // pRet kept acquired for cache
    2328                 :            : 
    2329                 :        708 :                 typelib_typedescriptionreference_acquire( pRet->pWeakRef );
    2330         [ -  + ]:        708 :                 if (*ppTDR)
    2331                 :          0 :                     typelib_typedescriptionreference_release( *ppTDR );
    2332         [ +  - ]:        708 :                 *ppTDR = pRet->pWeakRef;
    2333                 :            :             }
    2334                 :            :         }
    2335         [ #  # ]:          0 :         else if (*ppTDR)
    2336                 :            :         {
    2337                 :            : #if OSL_DEBUG_LEVEL > 1
    2338                 :            :             OString aStr( rtl::OUStringToOString( pTypeName, RTL_TEXTENCODING_ASCII_US ) );
    2339                 :            :             OSL_ENSURE( !"### typedef not found: ", aStr.getStr() );
    2340                 :            : #endif
    2341                 :          0 :             typelib_typedescriptionreference_release( *ppTDR );
    2342                 :        708 :             *ppTDR = 0;
    2343                 :            :         }
    2344                 :            :         return;
    2345                 :            :     }
    2346                 :            : 
    2347 [ +  - ][ +  - ]:    3272415 :     MutexGuard aGuard( rInit.getMutex() );
    2348                 :    3272415 :     typelib_typedescriptionreference_getByName( ppTDR, pTypeName );
    2349         [ +  + ]:    3272415 :     if( *ppTDR )
    2350                 :            :         return;
    2351                 :            : 
    2352         [ +  + ]:     711193 :     if( reallyWeak( eTypeClass ) )
    2353                 :            :     {
    2354         [ +  - ]:     613345 :         typelib_TypeDescriptionReference * pTDR = new typelib_TypeDescriptionReference();
    2355                 :            : #if OSL_DEBUG_LEVEL > 1
    2356                 :            :         osl_incrementInterlockedCount( &rInit.nTypeDescriptionReferenceCount );
    2357                 :            : #endif
    2358                 :     613345 :         pTDR->nRefCount = 1;
    2359                 :     613345 :         pTDR->nStaticRefCount = 0;
    2360                 :     613345 :         pTDR->eTypeClass = eTypeClass;
    2361                 :     613345 :         pTDR->pUniqueIdentifier = 0;
    2362                 :     613345 :         pTDR->pReserved = 0;
    2363                 :     613345 :         rtl_uString_acquire( pTDR->pTypeName = pTypeName );
    2364                 :     613345 :         pTDR->pType = 0;
    2365                 :     613345 :         *ppTDR = pTDR;
    2366                 :            :     }
    2367                 :            :     else
    2368                 :            :     {
    2369                 :      97848 :         typelib_typedescription_newEmpty( (typelib_TypeDescription ** )ppTDR, eTypeClass, pTypeName );
    2370                 :            :         // description will be registered but not acquired
    2371                 :      97848 :         (*(typelib_TypeDescription ** )ppTDR)->bOnDemand = sal_True;
    2372                 :      97848 :         (*(typelib_TypeDescription ** )ppTDR)->bComplete = sal_False;
    2373                 :            :     }
    2374                 :            : 
    2375         [ +  + ]:     711193 :     if( !rInit.pWeakMap )
    2376 [ +  - ][ +  - ]:        782 :         rInit.pWeakMap = new WeakMap_Impl;
    2377                 :            :     // Heavy hack, the const sal_Unicode * is hold by the typedescription reference
    2378                 :            :     // not registered
    2379 [ +  - ][ +  - ]:    3273123 :     rInit.pWeakMap->operator[]( (*ppTDR)->pTypeName->buffer ) = *ppTDR;
                 [ +  + ]
    2380                 :            : }
    2381                 :            : 
    2382                 :            : //------------------------------------------------------------------------
    2383                 :   73952349 : extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescriptionreference_acquire(
    2384                 :            :     typelib_TypeDescriptionReference * pRef )
    2385                 :            :     SAL_THROW_EXTERN_C()
    2386                 :            : {
    2387                 :   73952349 :     ::osl_incrementInterlockedCount( &pRef->nRefCount );
    2388                 :   73952510 : }
    2389                 :            : 
    2390                 :            : //------------------------------------------------------------------------
    2391                 :  184300914 : extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescriptionreference_release(
    2392                 :            :     typelib_TypeDescriptionReference * pRef )
    2393                 :            :     SAL_THROW_EXTERN_C()
    2394                 :            : {
    2395                 :            :     // Is it a type description?
    2396         [ +  + ]:  184300914 :     if( reallyWeak( pRef->eTypeClass ) )
    2397                 :            :     {
    2398         [ +  + ]:    2893620 :         if( ! ::osl_decrementInterlockedCount( &pRef->nRefCount ) )
    2399                 :            :         {
    2400                 :     285098 :             TypeDescriptor_Init_Impl &rInit = Init::get();
    2401         [ +  - ]:     285098 :             if( rInit.pWeakMap )
    2402                 :            :             {
    2403 [ +  - ][ +  - ]:     285098 :                 MutexGuard aGuard( rInit.getMutex() );
    2404         [ +  - ]:     285098 :                 WeakMap_Impl::iterator aIt = rInit.pWeakMap->find( (sal_Unicode*)pRef->pTypeName->buffer );
    2405 [ +  - ][ +  - ]:     285098 :                 if( !(aIt == rInit.pWeakMap->end()) && (*aIt).second == pRef )
         [ +  - ][ +  - ]
                 [ +  - ]
           [ +  -  #  # ]
    2406                 :            :                 {
    2407                 :            :                     // remove only if it contains the same object
    2408         [ +  - ]:     285098 :                     rInit.pWeakMap->erase( aIt );
    2409         [ +  - ]:     285098 :                 }
    2410                 :            :             }
    2411                 :            : 
    2412                 :     285098 :             rtl_uString_release( pRef->pTypeName );
    2413                 :            :             OSL_ASSERT( pRef->pType == 0 );
    2414                 :            : #if OSL_DEBUG_LEVEL > 1
    2415                 :            :             osl_decrementInterlockedCount( &rInit.nTypeDescriptionReferenceCount );
    2416                 :            : #endif
    2417                 :     285098 :             delete pRef;
    2418                 :            :         }
    2419                 :            :     }
    2420                 :            :     else
    2421                 :            :     {
    2422                 :  181407548 :         typelib_typedescription_release( (typelib_TypeDescription *)pRef );
    2423                 :            :     }
    2424                 :  184301002 : }
    2425                 :            : 
    2426                 :            : //------------------------------------------------------------------------
    2427                 :    4621025 : extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescriptionreference_getDescription(
    2428                 :            :     typelib_TypeDescription ** ppRet, typelib_TypeDescriptionReference * pRef )
    2429                 :            :     SAL_THROW_EXTERN_C()
    2430                 :            : {
    2431         [ -  + ]:    4621025 :     if( *ppRet )
    2432                 :            :     {
    2433                 :          0 :         typelib_typedescription_release( *ppRet );
    2434                 :          0 :         *ppRet = 0;
    2435                 :            :     }
    2436                 :            : 
    2437 [ +  + ][ +  - ]:    4621025 :     if( !reallyWeak( pRef->eTypeClass ) && pRef->pType && pRef->pType->pWeakRef )
         [ +  + ][ +  + ]
    2438                 :            :     {
    2439                 :            :         // reference is a description and initialized
    2440                 :    3506832 :         osl_incrementInterlockedCount( &((typelib_TypeDescription *)pRef)->nRefCount );
    2441                 :    3506832 :         *ppRet = (typelib_TypeDescription *)pRef;
    2442                 :    3506832 :         return;
    2443                 :            :     }
    2444                 :            : 
    2445                 :            :     {
    2446 [ +  - ][ +  - ]:    1114208 :     MutexGuard aGuard( Init::get().getMutex() );
    2447                 :            :     // pRef->pType->pWeakRef == 0 means that the description is empty
    2448 [ +  + ][ +  + ]:    1114209 :     if( pRef->pType && pRef->pType->pWeakRef )
    2449                 :            :     {
    2450         [ +  - ]:     973171 :         sal_Int32 n = ::osl_incrementInterlockedCount( &pRef->pType->nRefCount );
    2451         [ +  - ]:     973171 :         if( n > 1 )
    2452                 :            :         {
    2453                 :            :             // The refence is incremented. The object cannot be destroyed.
    2454                 :            :             // Release the guard at the earliest point.
    2455                 :     973171 :             *ppRet = pRef->pType;
    2456                 :            :             return;
    2457                 :            :         }
    2458                 :            :         else
    2459                 :            :         {
    2460         [ #  # ]:          0 :             ::osl_decrementInterlockedCount( &pRef->pType->nRefCount );
    2461                 :            :             // detruction of this type in progress (another thread!)
    2462                 :            :             // no acces through this weak reference
    2463                 :     141038 :             pRef->pType = 0;
    2464                 :            :         }
    2465 [ +  - ][ +  + ]:    1114209 :     }
    2466                 :            :     }
    2467                 :            : 
    2468                 :     141038 :     typelib_typedescription_getByName( ppRet, pRef->pTypeName );
    2469                 :            :     OSL_ASSERT( !*ppRet || rtl_ustr_compare( pRef->pTypeName->buffer, (*ppRet)->pTypeName->buffer ) == 0 );
    2470                 :            :     OSL_ASSERT( !*ppRet || pRef->eTypeClass == (*ppRet)->eTypeClass );
    2471                 :            :     OSL_ASSERT( !*ppRet || pRef == (*ppRet)->pWeakRef );
    2472                 :    4621041 :     pRef->pType = *ppRet;
    2473                 :            : }
    2474                 :            : 
    2475                 :            : //------------------------------------------------------------------------
    2476                 :    4920264 : extern "C" void SAL_CALL typelib_typedescriptionreference_getByName(
    2477                 :            :     typelib_TypeDescriptionReference ** ppRet, rtl_uString * pName )
    2478                 :            :     SAL_THROW_EXTERN_C()
    2479                 :            : {
    2480         [ -  + ]:    4920264 :     if( *ppRet )
    2481                 :            :     {
    2482                 :          0 :         typelib_typedescriptionreference_release( *ppRet );
    2483                 :          0 :         *ppRet = 0;
    2484                 :            :     }
    2485                 :    4920264 :     TypeDescriptor_Init_Impl &rInit = Init::get();
    2486         [ +  + ]:    4920264 :     if( rInit.pWeakMap )
    2487                 :            :     {
    2488 [ +  - ][ +  - ]:    4919482 :         MutexGuard aGuard( rInit.getMutex() );
    2489         [ +  - ]:    4919482 :         WeakMap_Impl::const_iterator aIt = rInit.pWeakMap->find( (sal_Unicode*)pName->buffer );
    2490 [ +  + ][ +  - ]:    4919482 :         if( !(aIt == rInit.pWeakMap->end()) ) // != failed on msc4.2
    2491                 :            :         {
    2492 [ +  - ][ +  - ]:    4099298 :             sal_Int32 n = ::osl_incrementInterlockedCount( &(*aIt).second->nRefCount );
    2493         [ +  - ]:    4099298 :             if( n > 1 )
    2494                 :            :             {
    2495                 :            :                 // The refence is incremented. The object cannot be destroyed.
    2496                 :            :                 // Release the guard at the earliest point.
    2497         [ +  - ]:    4099298 :                 *ppRet = (*aIt).second;
    2498                 :            :             }
    2499                 :            :             else
    2500                 :            :             {
    2501                 :            :                 // detruction of this type in progress (another thread!)
    2502                 :            :                 // no acces through this weak reference
    2503 [ #  # ][ #  # ]:          0 :                 ::osl_decrementInterlockedCount( &(*aIt).second->nRefCount );
    2504                 :            :             }
    2505         [ +  - ]:    4919482 :         }
    2506                 :            :     }
    2507                 :    4920264 : }
    2508                 :            : 
    2509                 :            : //------------------------------------------------------------------------
    2510                 :   86320897 : extern "C" CPPU_DLLPUBLIC sal_Bool SAL_CALL typelib_typedescriptionreference_equals(
    2511                 :            :     const typelib_TypeDescriptionReference * p1,
    2512                 :            :     const typelib_TypeDescriptionReference * p2 )
    2513                 :            :     SAL_THROW_EXTERN_C()
    2514                 :            : {
    2515                 :            :     return (p1 == p2 ||
    2516                 :            :             (p1->eTypeClass == p2->eTypeClass &&
    2517                 :            :              p1->pTypeName->length == p2->pTypeName->length &&
    2518 [ +  + ][ +  + ]:   86320897 :              rtl_ustr_compare( p1->pTypeName->buffer, p2->pTypeName->buffer ) == 0));
            [ +  + ][ + ]
    2519                 :            : }
    2520                 :            : 
    2521                 :            : //##################################################################################################
    2522                 :    2726610 : extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescriptionreference_assign(
    2523                 :            :     typelib_TypeDescriptionReference ** ppDest,
    2524                 :            :     typelib_TypeDescriptionReference * pSource )
    2525                 :            :     SAL_THROW_EXTERN_C()
    2526                 :            : {
    2527         [ +  + ]:    2726610 :     if (*ppDest != pSource)
    2528                 :            :     {
    2529                 :    2134870 :         ::typelib_typedescriptionreference_acquire( pSource );
    2530                 :    2134870 :         ::typelib_typedescriptionreference_release( *ppDest );
    2531                 :    2134870 :         *ppDest = pSource;
    2532                 :            :     }
    2533                 :    2726610 : }
    2534                 :            : 
    2535                 :            : //##################################################################################################
    2536                 :          0 : extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_setCacheSize( sal_Int32 nNewSize )
    2537                 :            :     SAL_THROW_EXTERN_C()
    2538                 :            : {
    2539                 :            :     OSL_ENSURE( nNewSize >= 0, "### illegal cache size given!" );
    2540         [ #  # ]:          0 :     if (nNewSize >= 0)
    2541                 :            :     {
    2542                 :          0 :         TypeDescriptor_Init_Impl &rInit = Init::get();
    2543 [ #  # ][ #  # ]:          0 :         MutexGuard aGuard( rInit.getMutex() );
    2544 [ #  # ][ #  # ]:          0 :         if ((nNewSize < nCacheSize) && rInit.pCache)
    2545                 :            :         {
    2546         [ #  # ]:          0 :             while ((sal_Int32)rInit.pCache->size() != nNewSize)
    2547                 :            :             {
    2548         [ #  # ]:          0 :                 typelib_typedescription_release( rInit.pCache->front() );
    2549         [ #  # ]:          0 :                 rInit.pCache->pop_front();
    2550                 :            :             }
    2551                 :            :         }
    2552         [ #  # ]:          0 :         nCacheSize = nNewSize;
    2553                 :            :     }
    2554                 :          0 : }
    2555                 :            : 
    2556                 :            : 
    2557                 :            : static sal_Bool s_aAssignableFromTab[11][11] =
    2558                 :            : {
    2559                 :            :                          /* from CH,BO,BY,SH,US,LO,UL,HY,UH,FL,DO */
    2560                 :            : /* TypeClass_CHAR */            { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
    2561                 :            : /* TypeClass_BOOLEAN */         { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
    2562                 :            : /* TypeClass_BYTE */            { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 },
    2563                 :            : /* TypeClass_SHORT */           { 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 },
    2564                 :            : /* TypeClass_UNSIGNED_SHORT */  { 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 },
    2565                 :            : /* TypeClass_LONG */            { 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0 },
    2566                 :            : /* TypeClass_UNSIGNED_LONG */   { 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0 },
    2567                 :            : /* TypeClass_HYPER */           { 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0 },
    2568                 :            : /* TypeClass_UNSIGNED_HYPER */  { 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0 },
    2569                 :            : /* TypeClass_FLOAT */           { 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0 },
    2570                 :            : /* TypeClass_DOUBLE */          { 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1 }
    2571                 :            : };
    2572                 :            : 
    2573                 :            : //##################################################################################################
    2574                 :     335221 : extern "C" CPPU_DLLPUBLIC sal_Bool SAL_CALL typelib_typedescriptionreference_isAssignableFrom(
    2575                 :            :     typelib_TypeDescriptionReference * pAssignable,
    2576                 :            :     typelib_TypeDescriptionReference * pFrom )
    2577                 :            :     SAL_THROW_EXTERN_C()
    2578                 :            : {
    2579    [ +  + ][ + ]:     335221 :     if (pAssignable && pFrom)
    2580                 :            :     {
    2581                 :     335221 :         typelib_TypeClass eAssignable = pAssignable->eTypeClass;
    2582                 :     335221 :         typelib_TypeClass eFrom       = pFrom->eTypeClass;
    2583                 :            : 
    2584         [ -  + ]:     335221 :         if (eAssignable == typelib_TypeClass_ANY) // anything can be assigned to an any .)
    2585                 :          0 :             return sal_True;
    2586         [ +  + ]:     335221 :         if (eAssignable == eFrom)
    2587                 :            :         {
    2588         [ +  + ]:     330679 :             if (type_equals( pAssignable, pFrom )) // first shot
    2589                 :            :             {
    2590                 :     118935 :                 return sal_True;
    2591                 :            :             }
    2592                 :            :             else
    2593                 :            :             {
    2594      [ +  +  - ]:     211745 :                 switch (eAssignable)
    2595                 :            :                 {
    2596                 :            :                 case typelib_TypeClass_STRUCT:
    2597                 :            :                 case typelib_TypeClass_EXCEPTION:
    2598                 :            :                 {
    2599                 :        127 :                     typelib_TypeDescription * pFromDescr = 0;
    2600 [ +  - ][ -  + ]:        127 :                     TYPELIB_DANGER_GET( &pFromDescr, pFrom );
         [ +  - ][ -  + ]
                 [ #  # ]
    2601         [ +  + ]:        127 :                     if (! ((typelib_CompoundTypeDescription *)pFromDescr)->pBaseTypeDescription)
    2602                 :            :                     {
    2603 [ +  - ][ -  + ]:         37 :                         TYPELIB_DANGER_RELEASE( pFromDescr );
    2604                 :         37 :                         return sal_False;
    2605                 :            :                     }
    2606                 :            :                     sal_Bool bRet = typelib_typedescriptionreference_isAssignableFrom(
    2607                 :            :                         pAssignable,
    2608                 :         90 :                         ((typelib_TypeDescription *)((typelib_CompoundTypeDescription *)pFromDescr)->pBaseTypeDescription)->pWeakRef );
    2609 [ -  + ][ +  - ]:         90 :                     TYPELIB_DANGER_RELEASE( pFromDescr );
    2610                 :        127 :                     return bRet;
    2611                 :            :                 }
    2612                 :            :                 case typelib_TypeClass_INTERFACE:
    2613                 :            :                 {
    2614                 :     211618 :                     typelib_TypeDescription * pFromDescr = 0;
    2615 [ +  - ][ -  + ]:     211618 :                     TYPELIB_DANGER_GET( &pFromDescr, pFrom );
         [ +  - ][ +  + ]
                 [ +  - ]
    2616                 :            :                     typelib_InterfaceTypeDescription * pFromIfc
    2617                 :            :                         = reinterpret_cast<
    2618                 :     211618 :                             typelib_InterfaceTypeDescription * >(pFromDescr);
    2619                 :     211618 :                     bool bRet = false;
    2620         [ +  + ]:     319713 :                     for (sal_Int32 i = 0; i < pFromIfc->nBaseTypes; ++i) {
    2621         [ +  + ]:     119691 :                         if (typelib_typedescriptionreference_isAssignableFrom(
    2622                 :            :                                 pAssignable,
    2623                 :     119691 :                                 pFromIfc->ppBaseTypes[i]->aBase.pWeakRef))
    2624                 :            :                         {
    2625                 :      11596 :                             bRet = true;
    2626                 :      11596 :                             break;
    2627                 :            :                         }
    2628                 :            :                     }
    2629 [ +  - ][ -  + ]:     211618 :                     TYPELIB_DANGER_RELEASE( pFromDescr );
    2630                 :     211618 :                     return bRet;
    2631                 :            :                 }
    2632                 :            :                 default:
    2633                 :            :                 {
    2634                 :          0 :                     return sal_False;
    2635                 :            :                 }
    2636                 :            :                 }
    2637                 :            :             }
    2638                 :            :         }
    2639                 :            :         return (eAssignable >= typelib_TypeClass_CHAR && eAssignable <= typelib_TypeClass_DOUBLE &&
    2640                 :            :                 eFrom >= typelib_TypeClass_CHAR && eFrom <= typelib_TypeClass_DOUBLE &&
    2641 [ +  - ][ +  + ]:       4542 :                 s_aAssignableFromTab[eAssignable-1][eFrom-1]);
         [ +  + ][ +  - ]
                 [ +  - ]
    2642                 :            :     }
    2643                 :     335222 :     return sal_False;
    2644                 :            : }
    2645                 :            : //##################################################################################################
    2646                 :      16618 : extern "C" CPPU_DLLPUBLIC sal_Bool SAL_CALL typelib_typedescription_isAssignableFrom(
    2647                 :            :     typelib_TypeDescription * pAssignable,
    2648                 :            :     typelib_TypeDescription * pFrom )
    2649                 :            :     SAL_THROW_EXTERN_C()
    2650                 :            : {
    2651                 :            :     return typelib_typedescriptionreference_isAssignableFrom(
    2652                 :      16618 :         pAssignable->pWeakRef, pFrom->pWeakRef );
    2653                 :            : }
    2654                 :            : 
    2655                 :            : //##################################################################################################
    2656                 :     849737 : extern "C" CPPU_DLLPUBLIC sal_Bool SAL_CALL typelib_typedescription_complete(
    2657                 :            :     typelib_TypeDescription ** ppTypeDescr )
    2658                 :            :     SAL_THROW_EXTERN_C()
    2659                 :            : {
    2660                 :     849737 :     return complete(ppTypeDescr, true);
    2661                 :            : }
    2662                 :            : 
    2663                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10