LCOV - code coverage report
Current view: top level - cppu/source/typelib - static_types.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 209 255 82.0 %
Date: 2012-08-25 Functions: 11 13 84.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 95 194 49.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : 
      20                 :            : #include "sal/config.h"
      21                 :            : 
      22                 :            : #include <algorithm>
      23                 :            : #include <cassert>
      24                 :            : #include <stdarg.h>
      25                 :            : 
      26                 :            : #include <osl/mutex.hxx>
      27                 :            : #include <osl/interlck.h>
      28                 :            : #include <rtl/ustring.hxx>
      29                 :            : #include <rtl/ustrbuf.hxx>
      30                 :            : #include <rtl/memory.h>
      31                 :            : #include <rtl/instance.hxx>
      32                 :            : 
      33                 :            : #include <typelib/typedescription.h>
      34                 :            : 
      35                 :            : 
      36                 :            : using namespace osl;
      37                 :            : 
      38                 :            : using ::rtl::OUString;
      39                 :            : using ::rtl::OUStringBuffer;
      40                 :            : 
      41                 :            : extern "C"
      42                 :            : {
      43                 :            : 
      44                 :            : //------------------------------------------------------------------------
      45                 :            : sal_Int32 SAL_CALL typelib_typedescription_getAlignedUnoSize(
      46                 :            :     const typelib_TypeDescription * pTypeDescription,
      47                 :            :     sal_Int32 nOffset,
      48                 :            :     sal_Int32 & rMaxIntegralTypeSize )
      49                 :            :     SAL_THROW_EXTERN_C();
      50                 :            : //------------------------------------------------------------------------
      51                 :            : void SAL_CALL typelib_typedescription_newEmpty(
      52                 :            :     typelib_TypeDescription ** ppRet,
      53                 :            :     typelib_TypeClass eTypeClass,
      54                 :            :     rtl_uString * pTypeName )
      55                 :            :     SAL_THROW_EXTERN_C();
      56                 :            : //-----------------------------------------------------------------------------
      57                 :            : void SAL_CALL typelib_typedescriptionreference_getByName(
      58                 :            :     typelib_TypeDescriptionReference ** ppRet,
      59                 :            :     rtl_uString * pName )
      60                 :            :     SAL_THROW_EXTERN_C();
      61                 :            : 
      62                 :            : #ifdef SAL_W32
      63                 :            : #pragma pack(push, 8)
      64                 :            : #endif
      65                 :            : 
      66                 :            : /**
      67                 :            :  * The double member determin the alignment.
      68                 :            :  * Under Os2 and MS-Windows the Alignment is min( 8, sizeof( type ) ).
      69                 :            :  * The aligment of a strukture is min( 8, sizeof( max basic type ) ), the greatest basic type
      70                 :            :  * determine the aligment.
      71                 :            :  */
      72                 :            : struct AlignSize_Impl
      73                 :            : {
      74                 :            :     sal_Int16 nInt16;
      75                 :            : #ifdef AIX
      76                 :            :     //double: doubleword aligned if -qalign=natural/-malign=natural
      77                 :            :     //which isn't the default ABI. Otherwise word aligned, While a long long int
      78                 :            :     //is always doubleword aligned, so use that instead.
      79                 :            :     sal_Int64   dDouble;
      80                 :            : #else
      81                 :            :     double dDouble;
      82                 :            : #endif
      83                 :            : };
      84                 :            : 
      85                 :            : #ifdef SAL_W32
      86                 :            : #pragma pack(pop)
      87                 :            : #endif
      88                 :            : 
      89                 :            : // the value of the maximal alignment
      90                 :            : static sal_Int32 nMaxAlignment = (sal_Int32)( (sal_Size)(&((AlignSize_Impl *) 16)->dDouble) - 16);
      91                 :            : 
      92                 :      11593 : static inline sal_Int32 adjustAlignment( sal_Int32 nRequestedAlignment )
      93                 :            :     SAL_THROW(())
      94                 :            : {
      95         [ -  + ]:      11593 :     if( nRequestedAlignment > nMaxAlignment )
      96                 :          0 :         nRequestedAlignment = nMaxAlignment;
      97                 :      11593 :     return nRequestedAlignment;
      98                 :            : }
      99                 :            : 
     100                 :            : /**
     101                 :            :  * Calculate the new size of the struktur.
     102                 :            :  */
     103                 :       1484 : static inline sal_Int32 newAlignedSize(
     104                 :            :     sal_Int32 OldSize, sal_Int32 ElementSize, sal_Int32 NeededAlignment )
     105                 :            :     SAL_THROW(())
     106                 :            : {
     107                 :       1484 :     NeededAlignment = adjustAlignment( NeededAlignment );
     108                 :       1484 :     return (OldSize + NeededAlignment -1) / NeededAlignment * NeededAlignment + ElementSize;
     109                 :            : }
     110                 :            : 
     111                 :            : //--------------------------------------------------------------------------------------------------
     112                 :            : 
     113                 :            : namespace
     114                 :            : {
     115                 :            :     struct typelib_StaticInitMutex : public rtl::Static< Mutex, typelib_StaticInitMutex > {};
     116                 :            : }
     117                 :            : 
     118                 :            : // !for NOT REALLY WEAK TYPES only!
     119                 :     127501 : static inline typelib_TypeDescriptionReference * igetTypeByName( rtl_uString * pTypeName )
     120                 :            :     SAL_THROW(())
     121                 :            : {
     122                 :     127501 :     typelib_TypeDescriptionReference * pRef = 0;
     123                 :     127501 :     ::typelib_typedescriptionreference_getByName( &pRef, pTypeName );
     124 [ +  - ][ +  + ]:     127501 :     if (pRef && pRef->pType && pRef->pType->pWeakRef) // found initialized td
                 [ +  + ]
     125                 :            :     {
     126                 :     100113 :         return pRef;
     127                 :            :     }
     128                 :            :     else
     129                 :            :     {
     130                 :     127501 :         return 0;
     131                 :            :     }
     132                 :            : }
     133                 :            : 
     134                 :            : extern "C"
     135                 :            : {
     136                 :            : //##################################################################################################
     137                 :   26095694 : CPPU_DLLPUBLIC typelib_TypeDescriptionReference ** SAL_CALL typelib_static_type_getByTypeClass(
     138                 :            :     typelib_TypeClass eTypeClass )
     139                 :            :     SAL_THROW_EXTERN_C()
     140                 :            : {
     141                 :            :     static typelib_TypeDescriptionReference * s_aTypes[] = {
     142                 :            :         0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
     143                 :            :         0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
     144                 :            :         0, 0, 0 };
     145                 :            : 
     146         [ +  + ]:   26095694 :     if (! s_aTypes[eTypeClass])
     147                 :            :     {
     148 [ +  - ][ +  - ]:       5824 :         MutexGuard aGuard( typelib_StaticInitMutex::get() );
     149         [ +  - ]:       5824 :         if (! s_aTypes[eTypeClass])
     150                 :            :         {
     151                 :            :             static const char * s_aTypeNames[] = {
     152                 :            :                 "void", "char", "boolean", "byte",
     153                 :            :                 "short", "unsigned short", "long", "unsigned long",
     154                 :            :                 "hyper", "unsigned hyper", "float", "double",
     155                 :            :                 "string", "type", "any" };
     156                 :            : 
     157         [ +  + ]:       5824 :             switch (eTypeClass)
     158                 :            :             {
     159                 :            :             case typelib_TypeClass_EXCEPTION:
     160                 :            :             case typelib_TypeClass_INTERFACE:
     161                 :            :             {
     162                 :            :                 // type
     163         [ +  + ]:        772 :                 if (! s_aTypes[typelib_TypeClass_TYPE])
     164                 :            :                 {
     165         [ +  - ]:        767 :                     OUString sTypeName( RTL_CONSTASCII_USTRINGPARAM("type") );
     166                 :            :                     ::typelib_typedescriptionreference_new(
     167                 :        767 :                         &s_aTypes[typelib_TypeClass_TYPE], typelib_TypeClass_TYPE, sTypeName.pData );
     168                 :            :                     // another static ref:
     169                 :        767 :                     ++s_aTypes[typelib_TypeClass_TYPE]->nStaticRefCount;
     170                 :            :                 }
     171                 :            :                 // any
     172         [ +  + ]:        772 :                 if (! s_aTypes[typelib_TypeClass_ANY])
     173                 :            :                 {
     174         [ +  - ]:        767 :                     OUString sTypeName( RTL_CONSTASCII_USTRINGPARAM("any") );
     175                 :            :                     ::typelib_typedescriptionreference_new(
     176                 :        767 :                         &s_aTypes[typelib_TypeClass_ANY], typelib_TypeClass_ANY, sTypeName.pData );
     177                 :            :                     // another static ref:
     178                 :        767 :                     ++s_aTypes[typelib_TypeClass_ANY]->nStaticRefCount;
     179                 :            :                 }
     180                 :            :                 // string
     181         [ +  + ]:        772 :                 if (! s_aTypes[typelib_TypeClass_STRING])
     182                 :            :                 {
     183         [ +  - ]:        755 :                     OUString sTypeName( RTL_CONSTASCII_USTRINGPARAM("string") );
     184                 :            :                     ::typelib_typedescriptionreference_new(
     185                 :        755 :                         &s_aTypes[typelib_TypeClass_STRING], typelib_TypeClass_STRING, sTypeName.pData );
     186                 :            :                     // another static ref:
     187                 :        755 :                     ++s_aTypes[typelib_TypeClass_STRING]->nStaticRefCount;
     188                 :            :                 }
     189                 :            :                 // XInterface
     190         [ +  - ]:        772 :                 if (! s_aTypes[typelib_TypeClass_INTERFACE])
     191                 :            :                 {
     192         [ +  - ]:        772 :                     OUString sTypeName( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.XInterface") );
     193                 :            : 
     194                 :        772 :                     typelib_InterfaceTypeDescription * pTD = 0;
     195                 :            : 
     196                 :        772 :                     typelib_TypeDescriptionReference * pMembers[3] = { 0,0,0 };
     197         [ +  - ]:        772 :                     OUString sMethodName0( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.XInterface::queryInterface") );
     198                 :            :                     ::typelib_typedescriptionreference_new(
     199                 :        772 :                         &pMembers[0], typelib_TypeClass_INTERFACE_METHOD, sMethodName0.pData );
     200         [ +  - ]:        772 :                     OUString sMethodName1( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.XInterface::acquire") );
     201                 :            :                     ::typelib_typedescriptionreference_new(
     202                 :        772 :                         &pMembers[1], typelib_TypeClass_INTERFACE_METHOD, sMethodName1.pData );
     203         [ +  - ]:        772 :                     OUString sMethodName2( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.XInterface::release") );
     204                 :            :                     ::typelib_typedescriptionreference_new(
     205                 :        772 :                         &pMembers[2], typelib_TypeClass_INTERFACE_METHOD, sMethodName2.pData );
     206                 :            : 
     207                 :            :                     ::typelib_typedescription_newInterface(
     208                 :            :                         &pTD, sTypeName.pData, 0xe227a391, 0x33d6, 0x11d1, 0xaabe00a0, 0x249d5590,
     209                 :        772 :                         0, 3, pMembers );
     210                 :            : 
     211                 :        772 :                     ::typelib_typedescription_register( (typelib_TypeDescription **)&pTD );
     212                 :            :                     ::typelib_typedescriptionreference_acquire(
     213                 :        772 :                         s_aTypes[typelib_TypeClass_INTERFACE] = ((typelib_TypeDescription *)pTD)->pWeakRef );
     214                 :            :                     // another static ref:
     215                 :        772 :                     ++s_aTypes[typelib_TypeClass_INTERFACE]->nStaticRefCount;
     216                 :        772 :                     ::typelib_typedescription_release( (typelib_TypeDescription*)pTD );
     217                 :            : 
     218                 :        772 :                     ::typelib_typedescriptionreference_release( pMembers[0] );
     219                 :        772 :                     ::typelib_typedescriptionreference_release( pMembers[1] );
     220                 :        772 :                     ::typelib_typedescriptionreference_release( pMembers[2] );
     221                 :            :                     // Exception
     222                 :            :                     assert( ! s_aTypes[typelib_TypeClass_EXCEPTION] );
     223                 :            :                     {
     224                 :        772 :                     typelib_TypeDescription * pTD1 = 0;
     225         [ +  - ]:        772 :                     OUString sTypeName1( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.Exception") );
     226                 :            : 
     227                 :            :                     typelib_CompoundMember_Init aMembers[2];
     228         [ +  - ]:        772 :                     OUString sMemberType0( RTL_CONSTASCII_USTRINGPARAM("string") );
     229         [ +  - ]:        772 :                     OUString sMemberName0( RTL_CONSTASCII_USTRINGPARAM("Message") );
     230                 :        772 :                     aMembers[0].eTypeClass = typelib_TypeClass_STRING;
     231                 :        772 :                     aMembers[0].pTypeName = sMemberType0.pData;
     232                 :        772 :                     aMembers[0].pMemberName = sMemberName0.pData;
     233         [ +  - ]:        772 :                     OUString sMemberType1( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.XInterface") );
     234         [ +  - ]:        772 :                     OUString sMemberName1( RTL_CONSTASCII_USTRINGPARAM("Context") );
     235                 :        772 :                     aMembers[1].eTypeClass = typelib_TypeClass_INTERFACE;
     236                 :        772 :                     aMembers[1].pTypeName = sMemberType1.pData;
     237                 :        772 :                     aMembers[1].pMemberName = sMemberName1.pData;
     238                 :            : 
     239                 :            :                     ::typelib_typedescription_new(
     240                 :        772 :                         &pTD1, typelib_TypeClass_EXCEPTION, sTypeName1.pData, 0, 2, aMembers );
     241                 :        772 :                     typelib_typedescription_register( &pTD1 );
     242                 :            :                     typelib_typedescriptionreference_acquire(
     243                 :        772 :                         s_aTypes[typelib_TypeClass_EXCEPTION] = pTD1->pWeakRef );
     244                 :            :                     // another static ref:
     245                 :        772 :                     ++s_aTypes[typelib_TypeClass_EXCEPTION]->nStaticRefCount;
     246                 :            :                     // RuntimeException
     247         [ +  - ]:        772 :                     OUString sTypeName2( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.RuntimeException") );
     248                 :            :                     ::typelib_typedescription_new(
     249                 :        772 :                         &pTD1, typelib_TypeClass_EXCEPTION, sTypeName2.pData, s_aTypes[typelib_TypeClass_EXCEPTION], 0, 0 );
     250                 :        772 :                     ::typelib_typedescription_register( &pTD1 );
     251                 :        772 :                     ::typelib_typedescription_release( pTD1 );
     252                 :            :                     }
     253                 :            :                     // XInterface members
     254                 :        772 :                     typelib_InterfaceMethodTypeDescription * pMethod = 0;
     255                 :            :                     typelib_Parameter_Init aParameters[1];
     256         [ +  - ]:        772 :                     OUString sParamName0( RTL_CONSTASCII_USTRINGPARAM("aType") );
     257         [ +  - ]:        772 :                     OUString sParamType0( RTL_CONSTASCII_USTRINGPARAM("type") );
     258                 :        772 :                     aParameters[0].pParamName = sParamName0.pData;
     259                 :        772 :                     aParameters[0].eTypeClass = typelib_TypeClass_TYPE;
     260                 :        772 :                     aParameters[0].pTypeName = sParamType0.pData;
     261                 :        772 :                     aParameters[0].bIn = sal_True;
     262                 :        772 :                     aParameters[0].bOut = sal_False;
     263                 :            :                     rtl_uString * pExceptions[1];
     264         [ +  - ]:        772 :                     OUString sExceptionName0( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.RuntimeException") );
     265                 :        772 :                     pExceptions[0] = sExceptionName0.pData;
     266         [ +  - ]:        772 :                     OUString sReturnType0( RTL_CONSTASCII_USTRINGPARAM("any") );
     267                 :            :                     typelib_typedescription_newInterfaceMethod(
     268                 :            :                         &pMethod, 0, sal_False, sMethodName0.pData,
     269                 :            :                         typelib_TypeClass_ANY, sReturnType0.pData,
     270                 :        772 :                         1, aParameters, 1, pExceptions );
     271                 :        772 :                     ::typelib_typedescription_register( (typelib_TypeDescription**)&pMethod );
     272                 :            : 
     273         [ +  - ]:        772 :                     OUString sReturnType1( RTL_CONSTASCII_USTRINGPARAM("void") );
     274                 :            :                     ::typelib_typedescription_newInterfaceMethod(
     275                 :            :                         &pMethod, 1, sal_True, sMethodName1.pData,
     276                 :        772 :                         typelib_TypeClass_VOID, sReturnType1.pData, 0, 0, 0, 0 );
     277                 :        772 :                     ::typelib_typedescription_register( (typelib_TypeDescription**)&pMethod );
     278                 :            : 
     279                 :            :                     ::typelib_typedescription_newInterfaceMethod(
     280                 :            :                         &pMethod, 2, sal_True, sMethodName2.pData,
     281                 :            :                         typelib_TypeClass_VOID, sReturnType1.pData,
     282                 :        772 :                         0, 0, 0, 0 );
     283                 :        772 :                     ::typelib_typedescription_register( (typelib_TypeDescription**)&pMethod );
     284                 :        772 :                     ::typelib_typedescription_release( (typelib_TypeDescription*)pMethod );
     285                 :            :                 }
     286                 :        772 :                 break;
     287                 :            :             }
     288                 :            :             default:
     289                 :            :             {
     290                 :       5052 :                 OUString aTypeName( OUString::createFromAscii( s_aTypeNames[eTypeClass] ) );
     291                 :       5052 :                 ::typelib_typedescriptionreference_new( &s_aTypes[eTypeClass], eTypeClass, aTypeName.pData );
     292                 :            :                 // another static ref:
     293                 :       5824 :                 ++s_aTypes[eTypeClass]->nStaticRefCount;
     294                 :            :             }
     295                 :            :             }
     296         [ +  - ]:       5824 :         }
     297                 :            :     }
     298                 :   26095694 :     return &s_aTypes[eTypeClass];
     299                 :            : }
     300                 :            : 
     301                 :            : //##################################################################################################
     302                 :     244222 : CPPU_DLLPUBLIC void SAL_CALL typelib_static_type_init(
     303                 :            :     typelib_TypeDescriptionReference ** ppRef,
     304                 :            :     typelib_TypeClass eTypeClass, const sal_Char * pTypeName )
     305                 :            :     SAL_THROW_EXTERN_C()
     306                 :            : {
     307         [ +  - ]:     244222 :     if (! *ppRef)
     308                 :            :     {
     309 [ +  - ][ +  - ]:     244222 :         MutexGuard aGuard( typelib_StaticInitMutex::get() );
     310         [ +  - ]:     244222 :         if (! *ppRef)
     311                 :            :         {
     312                 :     244222 :             OUString aTypeName( OUString::createFromAscii( pTypeName ) );
     313                 :     244222 :             ::typelib_typedescriptionreference_new( ppRef, eTypeClass, aTypeName.pData );
     314                 :            : 
     315                 :            :             // another static ref:
     316                 :     244222 :             ++((*ppRef)->nStaticRefCount);
     317         [ +  - ]:     244222 :         }
     318                 :            :     }
     319                 :     244222 : }
     320                 :            : 
     321                 :            : //##################################################################################################
     322                 :     111809 : CPPU_DLLPUBLIC void SAL_CALL typelib_static_sequence_type_init(
     323                 :            :     typelib_TypeDescriptionReference ** ppRef,
     324                 :            :     typelib_TypeDescriptionReference * pElementType )
     325                 :            :     SAL_THROW_EXTERN_C()
     326                 :            : {
     327         [ +  - ]:     111809 :     if (! *ppRef)
     328                 :            :     {
     329 [ +  - ][ +  - ]:     111809 :         MutexGuard aGuard( typelib_StaticInitMutex::get() );
     330         [ +  - ]:     111809 :         if (! *ppRef)
     331                 :            :         {
     332                 :     111809 :             OUStringBuffer aBuf( 32 );
     333         [ +  - ]:     111809 :             aBuf.appendAscii( "[]" );
     334         [ +  - ]:     111809 :             aBuf.append( pElementType->pTypeName );
     335         [ +  - ]:     111809 :             OUString aTypeName( aBuf.makeStringAndClear() );
     336                 :            : 
     337                 :            :             assert( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(typelib_TypeClass_SEQUENCE) );
     338                 :     111809 :             *ppRef = igetTypeByName( aTypeName.pData );
     339         [ +  + ]:     111809 :             if (!*ppRef)
     340                 :            :             {
     341                 :      17279 :                 typelib_TypeDescription * pReg = 0;
     342                 :            :                 ::typelib_typedescription_new(
     343                 :            :                     &pReg, typelib_TypeClass_SEQUENCE,
     344                 :      17279 :                     aTypeName.pData, pElementType, 0, 0 );
     345                 :            : 
     346                 :      17279 :                 ::typelib_typedescription_register( &pReg );
     347                 :      17279 :                 *ppRef = (typelib_TypeDescriptionReference *)pReg;
     348                 :            :                 assert( *ppRef == pReg->pWeakRef );
     349                 :            :             }
     350                 :            :             // another static ref:
     351                 :     111809 :             ++((*ppRef)->nStaticRefCount);
     352         [ +  - ]:     111809 :         }
     353                 :            :     }
     354                 :     111809 : }
     355                 :            : 
     356                 :            : //##################################################################################################
     357                 :            : namespace {
     358                 :            : 
     359                 :       8679 : void init(
     360                 :            :     typelib_TypeDescriptionReference ** ppRef,
     361                 :            :     typelib_TypeClass eTypeClass, const sal_Char * pTypeName,
     362                 :            :     typelib_TypeDescriptionReference * pBaseType,
     363                 :            :     sal_Int32 nMembers, typelib_TypeDescriptionReference ** ppMembers,
     364                 :            :     sal_Bool const * pParameterizedTypes)
     365                 :            : {
     366                 :            :     assert( eTypeClass == typelib_TypeClass_STRUCT || eTypeClass == typelib_TypeClass_EXCEPTION );
     367                 :            : 
     368         [ +  - ]:       8679 :     if (! *ppRef)
     369                 :            :     {
     370 [ +  - ][ +  - ]:       8679 :         MutexGuard aGuard( typelib_StaticInitMutex::get() );
     371         [ +  - ]:       8679 :         if (! *ppRef)
     372                 :            :         {
     373                 :            :             assert( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(eTypeClass) );
     374                 :       8679 :             OUString aTypeName( OUString::createFromAscii( pTypeName ) );
     375                 :       8679 :             *ppRef = igetTypeByName( aTypeName.pData );
     376         [ +  + ]:       8679 :             if (!*ppRef)
     377                 :            :             {
     378                 :       4580 :                 typelib_CompoundTypeDescription * pComp = 0;
     379                 :            :                 ::typelib_typedescription_newEmpty(
     380                 :       4580 :                     (typelib_TypeDescription **)&pComp, eTypeClass, aTypeName.pData );
     381                 :            : 
     382                 :       4580 :                 sal_Int32 nOffset = 0;
     383         [ +  - ]:       4580 :                 if (pBaseType)
     384                 :            :                 {
     385                 :            :                     ::typelib_typedescriptionreference_getDescription(
     386                 :       4580 :                         (typelib_TypeDescription **)&pComp->pBaseTypeDescription, pBaseType );
     387                 :            :                     assert( pComp->pBaseTypeDescription );
     388                 :       4580 :                     nOffset = ((typelib_TypeDescription *)pComp->pBaseTypeDescription)->nSize;
     389                 :            :                     assert( newAlignedSize( 0, ((typelib_TypeDescription *)pComp->pBaseTypeDescription)->nSize, ((typelib_TypeDescription *)pComp->pBaseTypeDescription)->nAlignment ) == ((typelib_TypeDescription *)pComp->pBaseTypeDescription)->nSize ); // unexpected offset
     390                 :            :                 }
     391                 :            : 
     392         [ +  + ]:       4580 :                 if (nMembers)
     393                 :            :                 {
     394                 :       1484 :                     pComp->nMembers = nMembers;
     395         [ +  - ]:       1484 :                     pComp->pMemberOffsets = new sal_Int32[ nMembers ];
     396         [ +  - ]:       1484 :                     pComp->ppTypeRefs = new typelib_TypeDescriptionReference *[ nMembers ];
     397         [ -  + ]:       1484 :                     if (pParameterizedTypes != 0) {
     398                 :            :                         reinterpret_cast< typelib_StructTypeDescription * >(
     399                 :            :                             pComp)->pParameterizedTypes
     400         [ #  # ]:          0 :                             = new sal_Bool[nMembers];
     401                 :            :                     }
     402         [ +  + ]:       2968 :                     for ( sal_Int32 i = 0 ; i < nMembers; ++i )
     403                 :            :                     {
     404                 :            :                         ::typelib_typedescriptionreference_acquire(
     405                 :       1484 :                             pComp->ppTypeRefs[i] = ppMembers[i] );
     406                 :            :                         // write offset
     407                 :       1484 :                         typelib_TypeDescription * pTD = 0;
     408 [ -  + ][ +  - ]:       1484 :                         TYPELIB_DANGER_GET( &pTD, pComp->ppTypeRefs[i] );
         [ -  + ][ #  # ]
                 [ +  - ]
     409                 :            :                         assert( pTD->nSize ); // void member?
     410                 :       1484 :                         nOffset = newAlignedSize( nOffset, pTD->nSize, pTD->nAlignment );
     411                 :       1484 :                         pComp->pMemberOffsets[i] = nOffset - pTD->nSize;
     412 [ -  + ][ +  - ]:       1484 :                         TYPELIB_DANGER_RELEASE( pTD );
     413                 :            : 
     414         [ -  + ]:       1484 :                         if (pParameterizedTypes != 0) {
     415                 :            :                             reinterpret_cast< typelib_StructTypeDescription * >(
     416                 :          0 :                                 pComp)->pParameterizedTypes[i]
     417                 :          0 :                                 = pParameterizedTypes[i];
     418                 :            :                         }
     419                 :            :                     }
     420                 :            :                 }
     421                 :            : 
     422                 :       4580 :                 typelib_TypeDescription * pReg = (typelib_TypeDescription *)pComp;
     423                 :       4580 :                 pReg->pWeakRef = (typelib_TypeDescriptionReference *)pReg;
     424                 :            :                 // sizeof( void ) not allowed
     425                 :       4580 :                 pReg->nSize = ::typelib_typedescription_getAlignedUnoSize( pReg, 0, pReg->nAlignment );
     426                 :       4580 :                 pReg->nAlignment = adjustAlignment( pReg->nAlignment );
     427                 :       4580 :                 pReg->bComplete = sal_False;
     428                 :            : 
     429                 :       4580 :                 ::typelib_typedescription_register( &pReg );
     430                 :       4580 :                 *ppRef = (typelib_TypeDescriptionReference *)pReg;
     431                 :            :                 assert( *ppRef == pReg->pWeakRef );
     432                 :            :             }
     433                 :            :             // another static ref:
     434                 :       8679 :             ++((*ppRef)->nStaticRefCount);
     435         [ +  - ]:       8679 :         }
     436                 :            :     }
     437                 :       8679 : }
     438                 :            : 
     439                 :            : }
     440                 :            : 
     441                 :       7604 : CPPU_DLLPUBLIC void SAL_CALL typelib_static_compound_type_init(
     442                 :            :     typelib_TypeDescriptionReference ** ppRef,
     443                 :            :     typelib_TypeClass eTypeClass, const sal_Char * pTypeName,
     444                 :            :     typelib_TypeDescriptionReference * pBaseType,
     445                 :            :     sal_Int32 nMembers, typelib_TypeDescriptionReference ** ppMembers )
     446                 :            :     SAL_THROW_EXTERN_C()
     447                 :            : {
     448                 :       7604 :     init(ppRef, eTypeClass, pTypeName, pBaseType, nMembers, ppMembers, 0);
     449                 :       7604 : }
     450                 :            : 
     451                 :       1075 : CPPU_DLLPUBLIC void SAL_CALL typelib_static_struct_type_init(
     452                 :            :     typelib_TypeDescriptionReference ** ppRef, const sal_Char * pTypeName,
     453                 :            :     typelib_TypeDescriptionReference * pBaseType,
     454                 :            :     sal_Int32 nMembers, typelib_TypeDescriptionReference ** ppMembers,
     455                 :            :     sal_Bool const * pParameterizedTypes )
     456                 :            :     SAL_THROW_EXTERN_C()
     457                 :            : {
     458                 :            :     init(
     459                 :            :         ppRef, typelib_TypeClass_STRUCT, pTypeName, pBaseType, nMembers,
     460                 :       1075 :         ppMembers, pParameterizedTypes);
     461                 :       1075 : }
     462                 :            : 
     463                 :            : //##################################################################################################
     464                 :          0 : CPPU_DLLPUBLIC void SAL_CALL typelib_static_interface_type_init(
     465                 :            :     typelib_TypeDescriptionReference ** ppRef,
     466                 :            :     const sal_Char * pTypeName,
     467                 :            :     typelib_TypeDescriptionReference * pBaseType )
     468                 :            :     SAL_THROW_EXTERN_C()
     469                 :            : {
     470                 :            :     typelib_static_mi_interface_type_init(
     471                 :          0 :         ppRef, pTypeName, pBaseType == 0 ? 0 : 1, &pBaseType);
     472                 :          0 : }
     473                 :            : 
     474                 :            : //##################################################################################################
     475                 :       5191 : CPPU_DLLPUBLIC void SAL_CALL typelib_static_mi_interface_type_init(
     476                 :            :     typelib_TypeDescriptionReference ** ppRef,
     477                 :            :     const sal_Char * pTypeName,
     478                 :            :     sal_Int32 nBaseTypes,
     479                 :            :     typelib_TypeDescriptionReference ** ppBaseTypes )
     480                 :            :     SAL_THROW_EXTERN_C()
     481                 :            : {
     482         [ +  - ]:       5191 :     if (! *ppRef)
     483                 :            :     {
     484 [ +  - ][ +  - ]:       5191 :         MutexGuard aGuard( typelib_StaticInitMutex::get() );
     485         [ +  - ]:       5191 :         if (! *ppRef)
     486                 :            :         {
     487                 :            :             assert( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(typelib_TypeClass_INTERFACE) );
     488                 :       5191 :             OUString aTypeName( OUString::createFromAscii( pTypeName ) );
     489                 :       5191 :             *ppRef = igetTypeByName( aTypeName.pData );
     490         [ +  - ]:       5191 :             if (!*ppRef)
     491                 :            :             {
     492                 :       5191 :                 typelib_InterfaceTypeDescription * pIface = 0;
     493                 :            :                 ::typelib_typedescription_newEmpty(
     494                 :       5191 :                     (typelib_TypeDescription **)&pIface, typelib_TypeClass_INTERFACE, aTypeName.pData );
     495                 :            : 
     496         [ +  - ]:       5191 :                 pIface->nBaseTypes = std::max< sal_Int32 >(nBaseTypes, 1);
     497                 :            :                 pIface->ppBaseTypes = new typelib_InterfaceTypeDescription *[
     498         [ +  - ]:       5191 :                     pIface->nBaseTypes];
     499         [ +  + ]:       5191 :                 if (nBaseTypes > 0)
     500                 :            :                 {
     501         [ +  + ]:       3770 :                     for (sal_Int32 i = 0; i < nBaseTypes; ++i) {
     502                 :       1885 :                         pIface->ppBaseTypes[i] = 0;
     503                 :            :                         ::typelib_typedescriptionreference_getDescription(
     504                 :       1885 :                             (typelib_TypeDescription **)&pIface->ppBaseTypes[i], ppBaseTypes[i] );
     505                 :            :                         assert( pIface->ppBaseTypes[i] );
     506                 :            :                     }
     507                 :            :                 }
     508                 :            :                 else
     509                 :            :                 {
     510                 :       3306 :                     pIface->ppBaseTypes[0] = 0;
     511                 :            :                     ::typelib_typedescriptionreference_getDescription(
     512                 :            :                         (typelib_TypeDescription **)&pIface->ppBaseTypes[0],
     513                 :       3306 :                         * ::typelib_static_type_getByTypeClass( typelib_TypeClass_INTERFACE ) );
     514                 :            :                     assert( pIface->ppBaseTypes[0] );
     515                 :            :                 }
     516                 :       5191 :                 pIface->pBaseTypeDescription = pIface->ppBaseTypes[0];
     517                 :            :                 typelib_typedescription_acquire(
     518                 :       5191 :                     &pIface->pBaseTypeDescription->aBase);
     519                 :            : 
     520                 :       5191 :                 typelib_TypeDescription * pReg = (typelib_TypeDescription *)pIface;
     521                 :       5191 :                 pReg->pWeakRef = (typelib_TypeDescriptionReference *)pReg;
     522                 :            :                 // sizeof( void ) not allowed
     523                 :       5191 :                 pReg->nSize = ::typelib_typedescription_getAlignedUnoSize( pReg, 0, pReg->nAlignment );
     524                 :            : 
     525                 :       5191 :                 pReg->nAlignment = adjustAlignment( pReg->nAlignment );
     526                 :       5191 :                 pReg->bComplete = sal_False;
     527                 :            : 
     528                 :       5191 :                 ::typelib_typedescription_register( &pReg );
     529                 :       5191 :                 *ppRef = (typelib_TypeDescriptionReference *)pReg;
     530                 :            :                 assert( *ppRef == pReg->pWeakRef );
     531                 :            :             }
     532                 :            :             // another static ref:
     533                 :       5191 :             ++((*ppRef)->nStaticRefCount);
     534         [ +  - ]:       5191 :         }
     535                 :            :     }
     536                 :       5191 : }
     537                 :            : 
     538                 :            : //##################################################################################################
     539                 :       1822 : CPPU_DLLPUBLIC void SAL_CALL typelib_static_enum_type_init(
     540                 :            :     typelib_TypeDescriptionReference ** ppRef,
     541                 :            :     const sal_Char * pTypeName,
     542                 :            :     sal_Int32 nDefaultValue )
     543                 :            :     SAL_THROW_EXTERN_C()
     544                 :            : {
     545         [ +  - ]:       1822 :     if (! *ppRef)
     546                 :            :     {
     547 [ +  - ][ +  - ]:       1822 :         MutexGuard aGuard( typelib_StaticInitMutex::get() );
     548         [ +  - ]:       1822 :         if (! *ppRef)
     549                 :            :         {
     550                 :            :             assert( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(typelib_TypeClass_ENUM) );
     551                 :       1822 :             OUString aTypeName( OUString::createFromAscii( pTypeName ) );
     552                 :       1822 :             *ppRef = igetTypeByName( aTypeName.pData );
     553         [ +  + ]:       1822 :             if (!*ppRef)
     554                 :            :             {
     555                 :        338 :                 typelib_TypeDescription * pReg = 0;
     556                 :            :                 ::typelib_typedescription_newEmpty(
     557                 :        338 :                     &pReg, typelib_TypeClass_ENUM, aTypeName.pData );
     558                 :        338 :                 typelib_EnumTypeDescription * pEnum = (typelib_EnumTypeDescription *)pReg;
     559                 :            : 
     560                 :        338 :                 pEnum->nDefaultEnumValue = nDefaultValue;
     561                 :            : 
     562                 :        338 :                 pReg->pWeakRef = (typelib_TypeDescriptionReference *)pReg;
     563                 :            :                 // sizeof( void ) not allowed
     564                 :        338 :                 pReg->nSize = ::typelib_typedescription_getAlignedUnoSize( pReg, 0, pReg->nAlignment );
     565                 :        338 :                 pReg->nAlignment = ::adjustAlignment( pReg->nAlignment );
     566                 :        338 :                 pReg->bComplete = sal_False;
     567                 :            : 
     568                 :        338 :                 ::typelib_typedescription_register( &pReg );
     569                 :        338 :                 *ppRef = (typelib_TypeDescriptionReference *)pReg;
     570                 :            :                 assert( *ppRef == pReg->pWeakRef );
     571                 :            :             }
     572                 :            :             // another static ref:
     573                 :       1822 :             ++((*ppRef)->nStaticRefCount);
     574         [ +  - ]:       1822 :         }
     575                 :            :     }
     576                 :       1822 : }
     577                 :            : 
     578                 :            : //##################################################################################################
     579                 :          0 : CPPU_DLLPUBLIC void SAL_CALL typelib_static_array_type_init(
     580                 :            :     typelib_TypeDescriptionReference ** ppRef,
     581                 :            :     typelib_TypeDescriptionReference * pElementTypeRef,
     582                 :            :     sal_Int32 nDimensions, ... )
     583                 :            :     SAL_THROW_EXTERN_C()
     584                 :            : {
     585         [ #  # ]:          0 :     if (! *ppRef)
     586                 :            :     {
     587 [ #  # ][ #  # ]:          0 :         MutexGuard aGuard( typelib_StaticInitMutex::get() );
     588         [ #  # ]:          0 :         if (! *ppRef)
     589                 :            :         {
     590                 :          0 :             OUStringBuffer aBuf( 32 );
     591         [ #  # ]:          0 :             aBuf.append( pElementTypeRef->pTypeName );
     592                 :            : 
     593                 :            :             va_list dimArgs;
     594                 :          0 :             va_start( dimArgs, nDimensions );
     595                 :          0 :             sal_Int32 dim = 0;
     596                 :          0 :             sal_Int32 nElements = 1;
     597         [ #  # ]:          0 :             sal_Int32* pDimensions = new sal_Int32[nDimensions];
     598         [ #  # ]:          0 :             for (sal_Int32 i=0; i < nDimensions; i++)
     599                 :            :             {
     600                 :          0 :                 dim = va_arg( dimArgs, int);
     601                 :          0 :                 pDimensions[i] = dim;
     602         [ #  # ]:          0 :                 aBuf.appendAscii("[");
     603         [ #  # ]:          0 :                 aBuf.append(dim);
     604         [ #  # ]:          0 :                 aBuf.appendAscii("]");
     605                 :          0 :                 nElements *= dim;
     606                 :            :             }
     607                 :          0 :             va_end( dimArgs );
     608         [ #  # ]:          0 :             OUString aTypeName( aBuf.makeStringAndClear() );
     609                 :            : 
     610                 :            :             assert( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(typelib_TypeClass_ARRAY) );
     611                 :          0 :             *ppRef = igetTypeByName( aTypeName.pData );
     612         [ #  # ]:          0 :             if (!*ppRef)
     613                 :            :             {
     614                 :          0 :                 typelib_TypeDescription * pReg = 0;
     615                 :            :                 ::typelib_typedescription_newEmpty(
     616                 :          0 :                     &pReg, typelib_TypeClass_ARRAY, aTypeName.pData );
     617                 :          0 :                 typelib_ArrayTypeDescription * pArray = (typelib_ArrayTypeDescription *)pReg;
     618                 :            : 
     619                 :          0 :                 pArray->nDimensions = nDimensions;
     620                 :          0 :                 pArray->nTotalElements = nElements;
     621                 :          0 :                 pArray->pDimensions = pDimensions;
     622                 :            : 
     623                 :          0 :                 typelib_typedescriptionreference_acquire(pElementTypeRef);
     624                 :          0 :                 ((typelib_IndirectTypeDescription*)pArray)->pType = pElementTypeRef;
     625                 :            : 
     626                 :          0 :                 pReg->pWeakRef = (typelib_TypeDescriptionReference *)pReg;
     627                 :            :                 // sizeof( void ) not allowed
     628                 :          0 :                 pReg->nSize = ::typelib_typedescription_getAlignedUnoSize( pReg, 0, pReg->nAlignment );
     629                 :          0 :                 pReg->nAlignment = ::adjustAlignment( pReg->nAlignment );
     630                 :          0 :                 pReg->bComplete = sal_True;
     631                 :            : 
     632                 :          0 :                 ::typelib_typedescription_register( &pReg );
     633                 :          0 :                 *ppRef = (typelib_TypeDescriptionReference *)pReg;
     634                 :            :                 assert( *ppRef == pReg->pWeakRef );
     635                 :            :             } else
     636         [ #  # ]:          0 :                 delete [] pDimensions;
     637                 :            :             // another static ref:
     638                 :          0 :             ++((*ppRef)->nStaticRefCount);
     639         [ #  # ]:          0 :         }
     640                 :            :     }
     641                 :          0 : }
     642                 :            : 
     643                 :            : } // extern "C"
     644                 :            : 
     645                 :            : }
     646                 :            : 
     647                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10