LCOV - code coverage report
Current view: top level - stoc/source/tdmanager - tdmgr_check.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 288 0.0 %
Date: 2012-08-25 Functions: 0 23 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 1220 0.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                 :            : 
      21                 :            : #include "tdmgr_common.hxx"
      22                 :            : #include "rtl/ustrbuf.hxx"
      23                 :            : #include "typelib/typedescription.h"
      24                 :            : #include "com/sun/star/beans/PropertyAttribute.hpp"
      25                 :            : #include "com/sun/star/reflection/XConstantsTypeDescription.hpp"
      26                 :            : #include "com/sun/star/reflection/XIndirectTypeDescription.hpp"
      27                 :            : #include "com/sun/star/reflection/XEnumTypeDescription.hpp"
      28                 :            : #include "com/sun/star/reflection/XStructTypeDescription.hpp"
      29                 :            : #include "com/sun/star/reflection/XInterfaceTypeDescription2.hpp"
      30                 :            : #include "com/sun/star/reflection/XInterfaceMethodTypeDescription.hpp"
      31                 :            : #include "com/sun/star/reflection/XInterfaceAttributeTypeDescription2.hpp"
      32                 :            : #include "com/sun/star/reflection/XServiceTypeDescription2.hpp"
      33                 :            : #include "com/sun/star/reflection/XSingletonTypeDescription2.hpp"
      34                 :            : 
      35                 :            : 
      36                 :            : using ::rtl::OUString;
      37                 :            : using ::rtl::OUStringBuffer;
      38                 :            : using namespace ::com::sun::star;
      39                 :            : using namespace ::com::sun::star::uno;
      40                 :            : using namespace ::stoc_tdmgr;
      41                 :            : 
      42                 :            : namespace {
      43                 :            : 
      44                 :          0 : OUString getTypeClassName( TypeClass tc )
      45                 :            : {
      46                 :          0 :     typelib_EnumTypeDescription * typeDescr = 0;
      47         [ #  # ]:          0 :     OUString name = OUSTR("com.sun.star.uno.TypeClass");
      48                 :            :     typelib_typedescription_getByName(
      49                 :          0 :         reinterpret_cast<typelib_TypeDescription **>(&typeDescr), name.pData );
      50                 :            :     OSL_ASSERT( typeDescr != 0 );
      51         [ #  # ]:          0 :     if (typeDescr == 0)
      52         [ #  # ]:          0 :         return OUSTR("Cannot get type description of ") + name;
      53                 :            :     typelib_typedescription_complete(
      54                 :          0 :         reinterpret_cast<typelib_TypeDescription **>(&typeDescr) );
      55                 :            : 
      56                 :          0 :     sal_Int32 const * pValues = typeDescr->pEnumValues;
      57                 :          0 :     sal_Int32 nPos = typeDescr->nEnumValues;
      58         [ #  # ]:          0 :     while (nPos--)
      59                 :            :     {
      60         [ #  # ]:          0 :         if (pValues[ nPos ] == (sal_Int32) tc)
      61                 :          0 :             break;
      62                 :            :     }
      63         [ #  # ]:          0 :     if (nPos >= 0)
      64                 :          0 :         name = typeDescr->ppEnumNames[ nPos ];
      65                 :            :     else
      66                 :            :         name = OUSTR("unknown TypeClass value: ") +
      67         [ #  # ]:          0 :             OUString::valueOf( (sal_Int32) tc );
      68                 :            : 
      69                 :            :     typelib_typedescription_release(
      70                 :          0 :         reinterpret_cast<typelib_TypeDescription *>(typeDescr) );
      71                 :          0 :     return name;
      72                 :            : }
      73                 :            : 
      74                 :          0 : OUString getPropertyFlagsAsString( sal_Int16 attributes )
      75                 :            : {
      76                 :          0 :     OUStringBuffer buf;
      77         [ #  # ]:          0 :     if ((attributes & beans::PropertyAttribute::MAYBEVOID) != 0)
      78         [ #  # ]:          0 :         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("MAYBEVOID, ") );
      79         [ #  # ]:          0 :     if ((attributes & beans::PropertyAttribute::BOUND) != 0)
      80         [ #  # ]:          0 :         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("BOUND, ") );
      81         [ #  # ]:          0 :     if ((attributes & beans::PropertyAttribute::CONSTRAINED) != 0)
      82         [ #  # ]:          0 :         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("CONSTRAINED, ") );
      83         [ #  # ]:          0 :     if ((attributes & beans::PropertyAttribute::TRANSIENT) != 0)
      84         [ #  # ]:          0 :         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("TRANSIENT, ") );
      85         [ #  # ]:          0 :     if ((attributes & beans::PropertyAttribute::READONLY) != 0)
      86         [ #  # ]:          0 :         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("READONLY, ") );
      87         [ #  # ]:          0 :     if ((attributes & beans::PropertyAttribute::MAYBEAMBIGUOUS) != 0)
      88         [ #  # ]:          0 :         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("MAYBEAMBIGUOUS, ") );
      89         [ #  # ]:          0 :     if ((attributes & beans::PropertyAttribute::MAYBEDEFAULT) != 0)
      90         [ #  # ]:          0 :         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("MAYBEDEFAULT, ") );
      91         [ #  # ]:          0 :     if ((attributes & beans::PropertyAttribute::REMOVEABLE) != 0)
      92         [ #  # ]:          0 :         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("REMOVEABLE, ") );
      93         [ #  # ]:          0 :     if ((attributes & beans::PropertyAttribute::OPTIONAL) != 0)
      94         [ #  # ]:          0 :         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("OPTIONAL") );
      95         [ #  # ]:          0 :     else if (buf.getLength() > 0)
      96         [ #  # ]:          0 :         buf.setLength( buf.getLength() - 2 ); // truncate ", "
      97         [ #  # ]:          0 :     return buf.makeStringAndClear();
      98                 :            : }
      99                 :            : 
     100                 :          0 : void typeError( OUString const & msg, OUString const & context )
     101                 :            : {
     102                 :          0 :     OUStringBuffer buf;
     103         [ #  # ]:          0 :     if (!context.isEmpty()) {
     104         [ #  # ]:          0 :         buf.append( static_cast<sal_Unicode>('[') );
     105         [ #  # ]:          0 :         buf.append( context );
     106         [ #  # ]:          0 :         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("] ") );
     107                 :            :     }
     108         [ #  # ]:          0 :     buf.append( msg );
     109         [ #  # ]:          0 :     throw IncompatibleTypeException( buf.makeStringAndClear() );
     110                 :            : }
     111                 :            : 
     112                 :            : template<typename T>
     113                 :          0 : void checkSeq( Sequence< Reference<T> > const & newTypes,
     114                 :            :             Sequence< Reference<T> > const & existingTypes,
     115                 :            :             OUString const & context,
     116                 :            :             bool optionalMode = false )
     117                 :            : {
     118                 :          0 :     sal_Int32 len = newTypes.getLength();
     119   [ #  #  #  #  :          0 :     if (len != existingTypes.getLength())
          #  #  #  #  #  
             #  #  #  #  
                      # ]
     120                 :            :     {
     121 [ #  # ][ #  # ]:          0 :         if (!optionalMode || len < newTypes.getLength())
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     122 [ #  # ][ #  # ]:          0 :             typeError( OUSTR("Different number of types!"), context );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     123                 :          0 :         len = existingTypes.getLength();
     124                 :            :     }
     125                 :            : 
     126                 :          0 :     Reference<T> const * pNewTypes = newTypes.getConstArray();
     127                 :          0 :     Reference<T> const * pExistingTypes = existingTypes.getConstArray();
     128 [ #  # ][ #  # ]:          0 :     for ( sal_Int32 pos = 0; pos < len; ++pos )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     129                 :            :     {
     130                 :          0 :         OUStringBuffer buf;
     131   [ #  #  #  #  :          0 :         buf.append( context );
          #  #  #  #  #  
             #  #  #  #  
                      # ]
     132 [ #  # ][ #  # ]:          0 :         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(", position ") );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     133 [ #  # ][ #  # ]:          0 :         buf.append( pos );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     134 [ #  # ][ #  # ]:          0 :         check( pNewTypes[pos].get(), pExistingTypes[pos].get(),
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     135                 :            :                buf.makeStringAndClear() );
     136                 :            :     }
     137                 :          0 : }
     138                 :            : 
     139                 :          0 : void checkEnum(
     140                 :            :     Reference<reflection::XEnumTypeDescription> const & xNewTD,
     141                 :            :     Reference<reflection::XEnumTypeDescription> const & xExistingTD )
     142                 :            : {
     143 [ #  # ][ #  # ]:          0 :     if (xNewTD->getEnumNames() != xExistingTD->getEnumNames())
         [ #  # ][ #  # ]
                 [ #  # ]
     144 [ #  # ][ #  # ]:          0 :         typeError( OUSTR("ENUM names don't match!"), xNewTD->getName() );
     145 [ #  # ][ #  # ]:          0 :     if (xNewTD->getEnumValues() != xExistingTD->getEnumValues())
         [ #  # ][ #  # ]
                 [ #  # ]
     146 [ #  # ][ #  # ]:          0 :         typeError( OUSTR("ENUM values don't match!"), xNewTD->getName() );
     147                 :          0 : }
     148                 :            : 
     149                 :          0 : void checkStruct(
     150                 :            :     Reference<reflection::XCompoundTypeDescription> const & xNewTD,
     151                 :            :     Reference<reflection::XCompoundTypeDescription> const & xExistingTD )
     152                 :            : {
     153 [ #  # ][ #  # ]:          0 :     check( xNewTD->getBaseType(), xExistingTD->getBaseType(),
     154 [ #  # ][ #  # ]:          0 :            xNewTD->getName() + OUSTR(", base type") );
         [ #  # ][ #  # ]
                 [ #  # ]
     155 [ #  # ][ #  # ]:          0 :     checkSeq( xNewTD->getMemberTypes(), xExistingTD->getMemberTypes(),
     156 [ #  # ][ #  # ]:          0 :               xNewTD->getName() + OUSTR(", member types") );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     157                 :            : 
     158 [ #  # ][ #  # ]:          0 :     if (xNewTD->getMemberNames() != xExistingTD->getMemberNames())
         [ #  # ][ #  # ]
                 [ #  # ]
     159 [ #  # ][ #  # ]:          0 :         typeError( OUSTR("Different member names!"), xNewTD->getName() );
     160                 :            : 
     161         [ #  # ]:          0 :     if (xNewTD->getTypeClass() == TypeClass_STRUCT)
     162                 :            :     {
     163                 :            :         Reference<reflection::XStructTypeDescription> xNewStructTD(
     164         [ #  # ]:          0 :             xNewTD, UNO_QUERY );
     165                 :            :         Reference<reflection::XStructTypeDescription> xExistingStructTD(
     166         [ #  # ]:          0 :             xExistingTD, UNO_QUERY );
     167 [ #  # ][ #  # ]:          0 :         if (xNewStructTD.is() && xExistingStructTD.is())
                 [ #  # ]
     168                 :            :         {
     169 [ #  # ][ #  # ]:          0 :             if (xNewStructTD->getTypeParameters() !=
     170 [ #  # ][ #  # ]:          0 :                 xExistingStructTD->getTypeParameters())
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     171                 :            :                 typeError( OUSTR("Different type parameters of instantiated "
     172 [ #  # ][ #  # ]:          0 :                                  "polymorphic STRUCT!"), xNewTD->getName() );
         [ #  # ][ #  # ]
     173         [ #  # ]:          0 :             checkSeq( xNewStructTD->getTypeArguments(),
     174         [ #  # ]:          0 :                       xExistingStructTD->getTypeArguments(),
     175 [ #  # ][ #  # ]:          0 :                       xNewTD->getName() + OUSTR(", argument types") );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     176                 :            :         }
     177 [ #  # ][ #  # ]:          0 :         else if (xNewStructTD.is() || xExistingStructTD.is())
                 [ #  # ]
     178                 :            :             typeError( OUSTR("Mixing polymorphic STRUCT types "
     179 [ #  # ][ #  # ]:          0 :                              "with non-polymorphic!"), xNewTD->getName() );
         [ #  # ][ #  # ]
     180                 :            :     }
     181                 :          0 : }
     182                 :            : 
     183                 :          0 : void checkInterface(
     184                 :            :     Reference<reflection::XInterfaceTypeDescription2> const & xNewTD,
     185                 :            :     Reference<reflection::XInterfaceTypeDescription2> const & xExistingTD )
     186                 :            : {
     187 [ #  # ][ #  # ]:          0 :     checkSeq( xNewTD->getBaseTypes(), xExistingTD->getBaseTypes(),
     188 [ #  # ][ #  # ]:          0 :               xNewTD->getName() + OUSTR(", base types") );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     189 [ #  # ][ #  # ]:          0 :     checkSeq(xNewTD->getOptionalBaseTypes(),xExistingTD->getOptionalBaseTypes(),
     190 [ #  # ][ #  # ]:          0 :              xNewTD->getName() + OUSTR(", optional base types") );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     191 [ #  # ][ #  # ]:          0 :     checkSeq( xNewTD->getMembers(), xExistingTD->getMembers(),
     192 [ #  # ][ #  # ]:          0 :               xNewTD->getName() + OUSTR(", members") );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     193                 :          0 : }
     194                 :            : 
     195                 :          0 : void checkRestParam( Reference<reflection::XParameter> const & xNewParam,
     196                 :            :                      Reference<reflection::XParameter> const & xExistingParam,
     197                 :            :                      OUString const & context )
     198                 :            : {
     199         [ #  # ]:          0 :     if (xNewParam->isRestParameter() != xExistingParam->isRestParameter())
     200         [ #  # ]:          0 :         typeError( OUSTR("Different ... parameters specified!"), context );
     201                 :          0 : }
     202                 :            : 
     203                 :          0 : void checkRestParam(
     204                 :            :     SAL_UNUSED_PARAMETER Reference<reflection::XMethodParameter> const &,
     205                 :            :     SAL_UNUSED_PARAMETER Reference<reflection::XMethodParameter> const &,
     206                 :            :     SAL_UNUSED_PARAMETER OUString const & )
     207                 :          0 : {}
     208                 :            : 
     209                 :            : template<typename T>
     210                 :          0 : void checkParameters( Sequence< Reference<T> > const & newParams,
     211                 :            :                       Sequence< Reference<T> > const & existingParams,
     212                 :            :                       OUString const & context_ )
     213                 :            : {
     214                 :          0 :     sal_Int32 len = newParams.getLength();
     215   [ #  #  #  # ]:          0 :     if (len != existingParams.getLength())
     216 [ #  # ][ #  # ]:          0 :         typeError( OUSTR("Different number of parameters!"), context_ );
     217                 :          0 :     Reference<T> const * pNewParams = newParams.getConstArray();
     218                 :          0 :     Reference<T> const * pExistingParams = existingParams.getConstArray();
     219 [ #  # ][ #  # ]:          0 :     for ( sal_Int32 pos = 0; pos < len; ++pos )
     220                 :            :     {
     221                 :          0 :         Reference<T> const & xNewParam = pNewParams[pos];
     222                 :          0 :         Reference<T> const & xExistingParam = pExistingParams[pos];
     223                 :            : 
     224                 :          0 :         OUStringBuffer buf;
     225   [ #  #  #  # ]:          0 :         buf.append( context_ );
     226 [ #  # ][ #  # ]:          0 :         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(", parameter ") );
     227 [ #  # ][ #  # ]:          0 :         buf.append( pos );
     228                 :            :         OSL_ASSERT( pos == xNewParam->getPosition() &&
     229                 :            :                     pos == xExistingParam->getPosition() );
     230 [ #  # ][ #  # ]:          0 :         OUString context( buf.makeStringAndClear() );
     231                 :            : 
     232 [ #  # ][ #  # ]:          0 :         if (xNewParam->getName() != xExistingParam->getName())
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     233                 :            :         {
     234 [ #  # ][ #  # ]:          0 :             buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("Name differs: ") );
     235 [ #  # ][ #  # ]:          0 :             buf.append( xNewParam->getName() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     236   [ #  #  #  # ]:          0 :             buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(", ") );
     237 [ #  # ][ #  # ]:          0 :             buf.append( xExistingParam->getName() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     238 [ #  # ][ #  # ]:          0 :             typeError( buf.makeStringAndClear(), context );
         [ #  # ][ #  # ]
     239                 :            :         }
     240 [ #  # ][ #  # ]:          0 :         check( xNewParam->getType(), xExistingParam->getType(), context );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     241                 :            : 
     242 [ #  # ][ #  # ]:          0 :         if (xNewParam->isIn() != xExistingParam->isIn())
                 [ #  # ]
           [ #  #  #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     243 [ #  # ][ #  # ]:          0 :             typeError( OUSTR("IN attribute differs!"), context );
         [ #  # ][ #  # ]
     244 [ #  # ][ #  # ]:          0 :         if (xNewParam->isOut() != xExistingParam->isOut())
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     245 [ #  # ][ #  # ]:          0 :             typeError( OUSTR("OUT attribute differs!"), context );
         [ #  # ][ #  # ]
     246         [ #  # ]:          0 :         checkRestParam( xNewParam, xExistingParam, context );
     247                 :            :     }
     248                 :          0 : }
     249                 :            : 
     250                 :          0 : static void checkMethod(
     251                 :            :     Reference<reflection::XInterfaceMethodTypeDescription> const & xNewTD,
     252                 :            :     Reference<reflection::XInterfaceMethodTypeDescription> const & xExistingTD )
     253                 :            : {
     254 [ #  # ][ #  # ]:          0 :     check( xNewTD->getReturnType(), xExistingTD->getReturnType(),
     255 [ #  # ][ #  # ]:          0 :            xNewTD->getName() );
                 [ #  # ]
     256                 :            : 
     257         [ #  # ]:          0 :     if (xNewTD->isOneway() != xExistingTD->isOneway())
     258                 :            :         typeError( OUSTR("Methods have differing OneWay attribute!"),
     259 [ #  # ][ #  # ]:          0 :                    xNewTD->getName() );
     260                 :            : 
     261 [ #  # ][ #  # ]:          0 :     checkParameters( xNewTD->getParameters(), xExistingTD->getParameters(),
     262 [ #  # ][ #  # ]:          0 :                      xNewTD->getName() );
         [ #  # ][ #  # ]
                 [ #  # ]
     263                 :            : 
     264 [ #  # ][ #  # ]:          0 :     checkSeq( xNewTD->getExceptions(), xExistingTD->getExceptions(),
     265 [ #  # ][ #  # ]:          0 :               xNewTD->getName() + OUSTR(", declared exceptions") );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     266                 :          0 : }
     267                 :            : 
     268                 :          0 : void checkAttribute(
     269                 :            :     Reference<reflection::XInterfaceAttributeTypeDescription2> const & xNewTD,
     270                 :            :     Reference<reflection::XInterfaceAttributeTypeDescription2>
     271                 :            :     const & xExistingTD )
     272                 :            : {
     273         [ #  # ]:          0 :     if (xNewTD->isReadOnly() != xExistingTD->isReadOnly())
     274 [ #  # ][ #  # ]:          0 :         typeError( OUSTR("ReadOnly attribute differs!"), xNewTD->getName() );
     275                 :            : 
     276 [ #  # ][ #  # ]:          0 :     check( xNewTD->getType(), xExistingTD->getType(),
     277 [ #  # ][ #  # ]:          0 :            xNewTD->getName() + OUSTR(", attribute type") );
         [ #  # ][ #  # ]
                 [ #  # ]
     278                 :            : 
     279         [ #  # ]:          0 :     if (xNewTD->isBound() != xExistingTD->isBound())
     280 [ #  # ][ #  # ]:          0 :         typeError( OUSTR("Bound attribute differs!"), xNewTD->getName() );
     281                 :            : 
     282 [ #  # ][ #  # ]:          0 :     checkSeq( xNewTD->getGetExceptions(), xExistingTD->getGetExceptions(),
     283 [ #  # ][ #  # ]:          0 :               xNewTD->getName() + OUSTR(", getter exceptions") );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     284 [ #  # ][ #  # ]:          0 :     checkSeq( xNewTD->getSetExceptions(), xExistingTD->getSetExceptions(),
     285 [ #  # ][ #  # ]:          0 :               xNewTD->getName() + OUSTR(", setter exceptions") );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     286                 :          0 : }
     287                 :            : 
     288                 :          0 : void checkProperty(
     289                 :            :     Reference<reflection::XPropertyTypeDescription> const & xNewTD,
     290                 :            :     Reference<reflection::XPropertyTypeDescription> const & xExistingTD )
     291                 :            : {
     292         [ #  # ]:          0 :     if (xNewTD->getPropertyFlags() != xExistingTD->getPropertyFlags())
     293                 :            :     {
     294                 :          0 :         OUStringBuffer buf;
     295                 :            :         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(
     296         [ #  # ]:          0 :                              "Different set of property flags: { ") );
     297                 :            :         buf.append( getPropertyFlagsAsString(
     298 [ #  # ][ #  # ]:          0 :                         xNewTD->getPropertyFlags() ) );
         [ #  # ][ #  # ]
     299         [ #  # ]:          0 :         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" } (new), { ") );
     300                 :            :         buf.append( getPropertyFlagsAsString(
     301 [ #  # ][ #  # ]:          0 :                         xExistingTD->getPropertyFlags() ) );
         [ #  # ][ #  # ]
     302         [ #  # ]:          0 :         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" } (existing)!") );
     303 [ #  # ][ #  # ]:          0 :         typeError( buf.makeStringAndClear(), xNewTD->getName() );
         [ #  # ][ #  # ]
     304                 :            :     }
     305                 :            : 
     306         [ #  # ]:          0 :     check( xNewTD->getPropertyTypeDescription(),
     307         [ #  # ]:          0 :            xExistingTD->getPropertyTypeDescription(),
     308 [ #  # ][ #  # ]:          0 :            xNewTD->getName() );
                 [ #  # ]
     309                 :          0 : }
     310                 :            : 
     311                 :          0 : void checkSingleton(
     312                 :            :     Reference<reflection::XSingletonTypeDescription2> const & xNewTD,
     313                 :            :     Reference<reflection::XSingletonTypeDescription2> const & xExistingTD )
     314                 :            : {
     315                 :          0 :     sal_Bool ifaceBased = xNewTD->isInterfaceBased();
     316         [ #  # ]:          0 :     if (ifaceBased != xExistingTD->isInterfaceBased())
     317                 :            :         typeError(
     318                 :            :             OUSTR("Mixing interface and NON-interface based singletons!"),
     319 [ #  # ][ #  # ]:          0 :             xNewTD->getName() );
     320         [ #  # ]:          0 :     if (ifaceBased)
     321 [ #  # ][ #  # ]:          0 :         check( xNewTD->getInterface(), xExistingTD->getInterface(),
     322 [ #  # ][ #  # ]:          0 :                xNewTD->getName() );
                 [ #  # ]
     323                 :            :     else
     324 [ #  # ][ #  # ]:          0 :         check( xNewTD->getService().get(), xExistingTD->getService().get(),
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     325 [ #  # ][ #  # ]:          0 :                xNewTD->getName() );
                 [ #  # ]
     326                 :          0 : }
     327                 :            : 
     328                 :          0 : void checkService(
     329                 :            :     Reference<reflection::XServiceTypeDescription2> const & xNewTD,
     330                 :            :     Reference<reflection::XServiceTypeDescription2> const & xExistingTD )
     331                 :            : {
     332                 :          0 :     sal_Bool singleIfaceBased = xNewTD->isSingleInterfaceBased();
     333         [ #  # ]:          0 :     if (singleIfaceBased != xExistingTD->isSingleInterfaceBased())
     334                 :            :         typeError( OUSTR("Mixing interface and NON-interface based services!"),
     335 [ #  # ][ #  # ]:          0 :                    xNewTD->getName() );
     336         [ #  # ]:          0 :     if (singleIfaceBased)
     337                 :            :     {
     338 [ #  # ][ #  # ]:          0 :         check( xNewTD->getInterface(), xExistingTD->getInterface(),
     339 [ #  # ][ #  # ]:          0 :                xNewTD->getName() );
         [ #  # ][ #  # ]
                 [ #  # ]
     340                 :            :         Sequence< Reference<reflection::XServiceConstructorDescription> >
     341 [ #  # ][ #  # ]:          0 :             newCtors( xNewTD->getConstructors() );
     342                 :            :         Sequence< Reference<reflection::XServiceConstructorDescription> >
     343 [ #  # ][ #  # ]:          0 :             existingCtors( xExistingTD->getConstructors() );
     344                 :          0 :         sal_Int32 len = newCtors.getLength();
     345         [ #  # ]:          0 :         if (len != existingCtors.getLength())
     346                 :            :             typeError( OUSTR("Different number of service constructors!"),
     347 [ #  # ][ #  # ]:          0 :                        xNewTD->getName() );
         [ #  # ][ #  # ]
     348                 :            :         Reference<reflection::XServiceConstructorDescription> const *
     349                 :          0 :             pNewCtors = newCtors.getConstArray();
     350                 :            :         Reference<reflection::XServiceConstructorDescription> const *
     351                 :          0 :             pExistingCtors = existingCtors.getConstArray();
     352         [ #  # ]:          0 :         for ( sal_Int32 pos = 0; pos < len; ++pos )
     353                 :            :         {
     354                 :            :             Reference<reflection::XServiceConstructorDescription> const &
     355                 :          0 :                 xNewCtor = pNewCtors[pos];
     356                 :            :             Reference<reflection::XServiceConstructorDescription> const &
     357                 :          0 :                 xExistingCtor = pExistingCtors[pos];
     358                 :            : 
     359 [ #  # ][ #  # ]:          0 :             if (xNewCtor->getName() != xExistingCtor->getName())
         [ #  # ][ #  # ]
                 [ #  # ]
     360                 :            :             {
     361                 :          0 :                 OUStringBuffer buf;
     362                 :            :                 buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(
     363         [ #  # ]:          0 :                                      "Different constructor names: ") );
     364 [ #  # ][ #  # ]:          0 :                 buf.append( xNewCtor->getName() );
                 [ #  # ]
     365         [ #  # ]:          0 :                 buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" (new), ") );
     366 [ #  # ][ #  # ]:          0 :                 buf.append( xExistingCtor->getName() );
                 [ #  # ]
     367         [ #  # ]:          0 :                 buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" (existing)!") );
     368 [ #  # ][ #  # ]:          0 :                 typeError( buf.makeStringAndClear(), xNewTD->getName() );
         [ #  # ][ #  # ]
     369                 :            :             }
     370                 :            : 
     371                 :          0 :             OUStringBuffer buf;
     372 [ #  # ][ #  # ]:          0 :             buf.append( xNewTD->getName() );
                 [ #  # ]
     373         [ #  # ]:          0 :             buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(", constructor ") );
     374 [ #  # ][ #  # ]:          0 :             buf.append( xNewCtor->getName() );
                 [ #  # ]
     375         [ #  # ]:          0 :             OUString context( buf.makeStringAndClear() );
     376         [ #  # ]:          0 :             checkParameters( xNewCtor->getParameters(),
     377         [ #  # ]:          0 :                              xExistingCtor->getParameters(),
     378 [ #  # ][ #  # ]:          0 :                              context );
         [ #  # ][ #  # ]
                 [ #  # ]
     379 [ #  # ][ #  # ]:          0 :             checkSeq( xNewCtor->getExceptions(), xExistingCtor->getExceptions(),
     380 [ #  # ][ #  # ]:          0 :                       context + OUSTR(", exceptions") );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     381 [ #  # ][ #  # ]:          0 :         }
     382                 :            :     }
     383                 :            :     else // old-style service descriptions:
     384                 :            :     {
     385         [ #  # ]:          0 :         checkSeq( xNewTD->getMandatoryServices(),
     386         [ #  # ]:          0 :                   xExistingTD->getMandatoryServices(),
     387 [ #  # ][ #  # ]:          0 :                   xNewTD->getName() + OUSTR(", mandatory services") );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     388         [ #  # ]:          0 :         checkSeq( xNewTD->getOptionalServices(),
     389         [ #  # ]:          0 :                   xExistingTD->getOptionalServices(),
     390         [ #  # ]:          0 :                   xNewTD->getName() + OUSTR(", optional services"),
     391 [ #  # ][ #  # ]:          0 :                   true /* optionalMode */ );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     392         [ #  # ]:          0 :         checkSeq( xNewTD->getMandatoryInterfaces(),
     393         [ #  # ]:          0 :                   xExistingTD->getMandatoryInterfaces(),
     394 [ #  # ][ #  # ]:          0 :                   xNewTD->getName() + OUSTR(", mandatory interfaces") );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     395         [ #  # ]:          0 :         checkSeq( xNewTD->getOptionalInterfaces(),
     396         [ #  # ]:          0 :                   xExistingTD->getOptionalInterfaces(),
     397         [ #  # ]:          0 :                   xNewTD->getName() + OUSTR(", optional interfaces"),
     398 [ #  # ][ #  # ]:          0 :                   true /* optionalMode */ );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     399                 :            : 
     400                 :            :         Sequence< Reference<reflection::XPropertyTypeDescription> >
     401 [ #  # ][ #  # ]:          0 :             newProperties( xNewTD->getProperties() );
     402                 :            :         Sequence< Reference<reflection::XPropertyTypeDescription> >
     403 [ #  # ][ #  # ]:          0 :             existingProperties( xExistingTD->getProperties() );
     404                 :            :         checkSeq( newProperties, existingProperties,
     405         [ #  # ]:          0 :                   xNewTD->getName() + OUSTR(", properties"),
     406 [ #  # ][ #  # ]:          0 :                   true /* optionalMode */ );
                 [ #  # ]
     407         [ #  # ]:          0 :         if (newProperties.getLength() > existingProperties.getLength())
     408                 :            :         {
     409                 :            :             // check whether all added properties are OPTIONAL:
     410                 :            :             Reference<reflection::XPropertyTypeDescription> const *
     411                 :          0 :                 pNewProperties = newProperties.getConstArray();
     412         [ #  # ]:          0 :             for ( sal_Int32 pos = existingProperties.getLength() + 1;
     413                 :          0 :                   pos < newProperties.getLength(); ++pos )
     414                 :            :             {
     415 [ #  # ][ #  # ]:          0 :                 if ((pNewProperties[pos]->getPropertyFlags() &
                 [ #  # ]
     416                 :            :                      beans::PropertyAttribute::OPTIONAL) == 0)
     417                 :            :                     typeError( OUSTR("New property is not OPTIONAL!"),
     418 [ #  # ][ #  # ]:          0 :                                pNewProperties[pos]->getName() );
         [ #  # ][ #  # ]
     419                 :            :             }
     420 [ #  # ][ #  # ]:          0 :         }
     421                 :            :     }
     422                 :          0 : }
     423                 :            : 
     424                 :            : }
     425                 :            : 
     426                 :            : namespace stoc_tdmgr {
     427                 :            : 
     428                 :          0 : void check( Reference<reflection::XTypeDescription> const & xNewTD,
     429                 :            :             Reference<reflection::XTypeDescription> const & xExistingTD,
     430                 :            :             OUString const & context )
     431                 :            : {
     432         [ #  # ]:          0 :     if (xNewTD == xExistingTD)
     433                 :          0 :         return;
     434 [ #  # ][ #  # ]:          0 :     if (xNewTD->getName() != xExistingTD->getName())
                 [ #  # ]
     435                 :            :     {
     436                 :          0 :         OUStringBuffer buf;
     437         [ #  # ]:          0 :         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("Different type names: ") );
     438 [ #  # ][ #  # ]:          0 :         buf.append( xNewTD->getName() );
                 [ #  # ]
     439         [ #  # ]:          0 :         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" (new), ") );
     440 [ #  # ][ #  # ]:          0 :         buf.append( xExistingTD->getName() );
                 [ #  # ]
     441         [ #  # ]:          0 :         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" (existing)!") );
     442 [ #  # ][ #  # ]:          0 :         typeError( buf.makeStringAndClear(), context );
     443                 :            :     }
     444                 :            : 
     445                 :          0 :     TypeClass tc = xNewTD->getTypeClass();
     446         [ #  # ]:          0 :     if (tc != xExistingTD->getTypeClass())
     447                 :            :     {
     448                 :          0 :         OUStringBuffer buf;
     449 [ #  # ][ #  # ]:          0 :         buf.append( xNewTD->getName() );
                 [ #  # ]
     450                 :            :         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(
     451         [ #  # ]:          0 :                              " has different type classes: ") );
     452 [ #  # ][ #  # ]:          0 :         buf.append( getTypeClassName( tc ) );
     453         [ #  # ]:          0 :         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" (new), ") );
     454 [ #  # ][ #  # ]:          0 :         buf.append( getTypeClassName( xExistingTD->getTypeClass() ) );
         [ #  # ][ #  # ]
     455         [ #  # ]:          0 :         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" (existing)!") );
     456 [ #  # ][ #  # ]:          0 :         typeError( buf.makeStringAndClear(), context );
     457                 :            :     }
     458                 :            : 
     459   [ #  #  #  #  :          0 :     switch (tc)
          #  #  #  #  #  
                #  #  # ]
     460                 :            :     {
     461                 :            :     case TypeClass_ENUM:
     462                 :            :         checkEnum( Reference<reflection::XEnumTypeDescription>(
     463                 :            :                        xNewTD, UNO_QUERY_THROW ),
     464                 :            :                    Reference<reflection::XEnumTypeDescription>(
     465 [ #  # ][ #  # ]:          0 :                        xExistingTD, UNO_QUERY_THROW ) );
     466                 :          0 :         break;
     467                 :            : 
     468                 :            :     case TypeClass_TYPEDEF:
     469                 :            :     case TypeClass_SEQUENCE:
     470                 :            :         check( Reference<reflection::XIndirectTypeDescription>(
     471 [ #  # ][ #  # ]:          0 :                    xNewTD, UNO_QUERY_THROW )->getReferencedType(),
     472                 :            :                Reference<reflection::XIndirectTypeDescription>(
     473 [ #  # ][ #  # ]:          0 :                    xExistingTD, UNO_QUERY_THROW )->getReferencedType() );
         [ #  # ][ #  # ]
                 [ #  # ]
     474                 :          0 :         break;
     475                 :            : 
     476                 :            :     case TypeClass_STRUCT:
     477                 :            :     case TypeClass_EXCEPTION:
     478                 :            :         checkStruct( Reference<reflection::XCompoundTypeDescription>(
     479                 :            :                          xNewTD, UNO_QUERY_THROW ),
     480                 :            :                      Reference<reflection::XCompoundTypeDescription>(
     481 [ #  # ][ #  # ]:          0 :                          xExistingTD, UNO_QUERY_THROW ) );
     482                 :          0 :         break;
     483                 :            : 
     484                 :            :     case TypeClass_INTERFACE:
     485                 :            :         checkInterface( Reference<reflection::XInterfaceTypeDescription2>(
     486                 :            :                             xNewTD, UNO_QUERY_THROW ),
     487                 :            :                         Reference<reflection::XInterfaceTypeDescription2>(
     488 [ #  # ][ #  # ]:          0 :                             xExistingTD, UNO_QUERY_THROW ) );
     489                 :          0 :         break;
     490                 :            : 
     491                 :            :     case TypeClass_SERVICE:
     492                 :            :         checkService( Reference<reflection::XServiceTypeDescription2>(
     493                 :            :                           xNewTD, UNO_QUERY_THROW ),
     494                 :            :                       Reference<reflection::XServiceTypeDescription2>(
     495 [ #  # ][ #  # ]:          0 :                           xExistingTD, UNO_QUERY_THROW ) );
     496                 :          0 :         break;
     497                 :            : 
     498                 :            :     case TypeClass_INTERFACE_METHOD:
     499                 :            :         checkMethod( Reference<reflection::XInterfaceMethodTypeDescription>(
     500                 :            :                          xNewTD, UNO_QUERY_THROW ),
     501                 :            :                      Reference<reflection::XInterfaceMethodTypeDescription>(
     502 [ #  # ][ #  # ]:          0 :                          xExistingTD, UNO_QUERY_THROW ) );
     503                 :          0 :         break;
     504                 :            :     case TypeClass_INTERFACE_ATTRIBUTE:
     505                 :            :         checkAttribute(
     506                 :            :             Reference<reflection::XInterfaceAttributeTypeDescription2>(
     507                 :            :                 xNewTD, UNO_QUERY_THROW ),
     508                 :            :             Reference<reflection::XInterfaceAttributeTypeDescription2>(
     509 [ #  # ][ #  # ]:          0 :                 xExistingTD, UNO_QUERY_THROW ) );
     510                 :          0 :         break;
     511                 :            : 
     512                 :            :     case TypeClass_PROPERTY:
     513                 :            :         checkProperty( Reference<reflection::XPropertyTypeDescription>(
     514                 :            :                            xNewTD, UNO_QUERY_THROW ),
     515                 :            :                        Reference<reflection::XPropertyTypeDescription>(
     516 [ #  # ][ #  # ]:          0 :                            xExistingTD, UNO_QUERY_THROW ) );
     517                 :          0 :         break;
     518                 :            : 
     519                 :            :     case TypeClass_CONSTANT:
     520         [ #  # ]:          0 :         if (Reference<reflection::XConstantTypeDescription>(
     521 [ #  # ][ #  # ]:          0 :                 xNewTD, UNO_QUERY_THROW )->getConstantValue() !=
     522                 :            :             Reference<reflection::XConstantTypeDescription>(
     523 [ #  # ][ #  # ]:          0 :                 xExistingTD, UNO_QUERY_THROW )->getConstantValue())
                 [ #  # ]
     524 [ #  # ][ #  # ]:          0 :             typeError( OUSTR("Different constant value!"), xNewTD->getName() );
     525                 :          0 :         break;
     526                 :            :     case TypeClass_CONSTANTS:
     527                 :            :         checkSeq( Reference<reflection::XConstantsTypeDescription>(
     528 [ #  # ][ #  # ]:          0 :                       xNewTD, UNO_QUERY_THROW )->getConstants(),
     529                 :            :                   Reference<reflection::XConstantsTypeDescription>(
     530 [ #  # ][ #  # ]:          0 :                       xExistingTD, UNO_QUERY_THROW )->getConstants(),
     531 [ #  # ][ #  # ]:          0 :                   xNewTD->getName() );
                 [ #  # ]
           [ #  #  #  # ]
     532                 :          0 :         break;
     533                 :            : 
     534                 :            :     case TypeClass_SINGLETON:
     535                 :            :         checkSingleton( Reference<reflection::XSingletonTypeDescription2>(
     536                 :            :                             xNewTD, UNO_QUERY_THROW ),
     537                 :            :                         Reference<reflection::XSingletonTypeDescription2>(
     538 [ #  # ][ #  # ]:          0 :                             xExistingTD, UNO_QUERY_THROW ) );
     539                 :          0 :         break;
     540                 :            : 
     541                 :            :     default:
     542                 :          0 :         break;
     543                 :            :     }
     544                 :            : }
     545                 :            : 
     546                 :            : }
     547                 :            : 
     548                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10