LCOV - code coverage report
Current view: top level - solver/unxlngi6.pro/inc/com/sun/star/uno - Sequence.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 62 66 93.9 %
Date: 2012-08-25 Functions: 1388 2010 69.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 224 334 67.1 %

           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                 :            : #ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
      20                 :            : #define _COM_SUN_STAR_UNO_SEQUENCE_HXX_
      21                 :            : 
      22                 :            : #include "osl/diagnose.h"
      23                 :            : #include "osl/interlck.h"
      24                 :            : #include "com/sun/star/uno/Sequence.h"
      25                 :            : #include "typelib/typedescription.h"
      26                 :            : #include "uno/data.h"
      27                 :            : #include "com/sun/star/uno/genfunc.hxx"
      28                 :            : #include "cppu/unotype.hxx"
      29                 :            : 
      30                 :            : namespace com
      31                 :            : {
      32                 :            : namespace sun
      33                 :            : {
      34                 :            : namespace star
      35                 :            : {
      36                 :            : namespace uno
      37                 :            : {
      38                 :            : 
      39                 :            : /// @cond INTERNAL
      40                 :            : template< class E >
      41                 :            : typelib_TypeDescriptionReference * Sequence< E >::s_pType = 0;
      42                 :            : /// @endcond
      43                 :            : 
      44                 :            : //______________________________________________________________________________
      45                 :            : template< class E >
      46                 :   11876338 : inline Sequence< E >::Sequence() SAL_THROW(())
      47                 :            : {
      48                 :   11876338 :     const Type & rType = ::cppu::getTypeFavourUnsigned( this );
      49                 :            :     ::uno_type_sequence_construct(
      50                 :            :         &_pSequence, rType.getTypeLibType(),
      51                 :   11876338 :         0, 0, (uno_AcquireFunc)cpp_acquire );
      52                 :            :     // no bad_alloc, because empty sequence is statically allocated in cppu
      53                 :   11876338 : }
      54                 :            : 
      55                 :            : //______________________________________________________________________________
      56                 :            : template< class E >
      57                 :    6692021 : inline Sequence< E >::Sequence( const Sequence< E > & rSeq ) SAL_THROW(())
      58                 :            : {
      59                 :    6692021 :     ::osl_incrementInterlockedCount( &rSeq._pSequence->nRefCount );
      60                 :    6692021 :     _pSequence = rSeq._pSequence;
      61                 :    6692021 : }
      62                 :            : 
      63                 :            : //______________________________________________________________________________
      64                 :            : template< class E >
      65                 :       4356 : inline Sequence< E >::Sequence(
      66                 :            :     uno_Sequence * pSequence, __sal_NoAcquire ) SAL_THROW(())
      67                 :       4356 :         : _pSequence( pSequence )
      68                 :            : {
      69                 :       4356 : }
      70                 :            : 
      71                 :            : //______________________________________________________________________________
      72                 :            : template< class E >
      73                 :     895455 : inline Sequence< E >::Sequence( const E * pElements, sal_Int32 len )
      74                 :            : {
      75                 :     895455 :     const Type & rType = ::cppu::getTypeFavourUnsigned( this );
      76                 :            : #if ! defined EXCEPTIONS_OFF
      77                 :            :     sal_Bool success =
      78                 :            : #endif
      79                 :            :     ::uno_type_sequence_construct(
      80                 :            :         &_pSequence, rType.getTypeLibType(),
      81                 :     895455 :         const_cast< E * >( pElements ), len, (uno_AcquireFunc)cpp_acquire );
      82                 :            : #if ! defined EXCEPTIONS_OFF
      83   [ -  +  -  +  :     895455 :     if (! success)
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
             +  -  +  -  
                      + ]
      84                 :          0 :         throw ::std::bad_alloc();
      85                 :            : #endif
      86                 :     895455 : }
      87                 :            : 
      88                 :            : //______________________________________________________________________________
      89                 :            : template< class E >
      90                 :    5966327 : inline Sequence< E >::Sequence( sal_Int32 len )
      91                 :            : {
      92                 :    5966327 :     const Type & rType = ::cppu::getTypeFavourUnsigned( this );
      93                 :            : #if ! defined EXCEPTIONS_OFF
      94                 :            :     sal_Bool success =
      95                 :            : #endif
      96                 :            :     ::uno_type_sequence_construct(
      97                 :            :         &_pSequence, rType.getTypeLibType(),
      98                 :    5966327 :         0, len, (uno_AcquireFunc)cpp_acquire );
      99                 :            : #if ! defined EXCEPTIONS_OFF
     100   [ -  +  -  +  :    5966327 :     if (! success)
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
                      + ]
     101                 :          0 :         throw ::std::bad_alloc();
     102                 :            : #endif
     103                 :    5966327 : }
     104                 :            : 
     105                 :            : //______________________________________________________________________________
     106                 :            : template< class E >
     107                 :   25376786 : inline Sequence< E >::~Sequence() SAL_THROW(())
     108                 :            : {
     109                 :   25376786 :     const Type & rType = ::cppu::getTypeFavourUnsigned( this );
     110                 :   25376787 :     ::uno_type_destructData(
     111                 :            :         this, rType.getTypeLibType(), (uno_ReleaseFunc)cpp_release );
     112                 :   25376787 : }
     113                 :            : 
     114                 :            : //______________________________________________________________________________
     115                 :            : template< class E >
     116                 :    2955783 : inline Sequence< E > & Sequence< E >::operator = ( const Sequence< E > & rSeq ) SAL_THROW(())
     117                 :            : {
     118                 :    2955783 :     const Type & rType = ::cppu::getTypeFavourUnsigned( this );
     119                 :    2955783 :     ::uno_type_sequence_assign(
     120                 :            :         &_pSequence, rSeq._pSequence, rType.getTypeLibType(), (uno_ReleaseFunc)cpp_release );
     121                 :    2955783 :     return *this;
     122                 :            : }
     123                 :            : 
     124                 :            : //______________________________________________________________________________
     125                 :            : template< class E >
     126                 :     199885 : inline sal_Bool Sequence< E >::operator == ( const Sequence< E > & rSeq ) const
     127                 :            :     SAL_THROW(())
     128                 :            : {
     129 [ +  + ][ -  + ]:     199885 :     if (_pSequence == rSeq._pSequence)
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ -  + ]
         [ +  + ][ +  + ]
                 [ -  + ]
     130                 :     180136 :         return sal_True;
     131                 :      19749 :     const Type & rType = ::cppu::getTypeFavourUnsigned( this );
     132                 :            :     return ::uno_type_equalData(
     133                 :            :         const_cast< Sequence< E > * >( this ), rType.getTypeLibType(),
     134                 :            :         const_cast< Sequence< E > * >( &rSeq ), rType.getTypeLibType(),
     135                 :            :         (uno_QueryInterfaceFunc)cpp_queryInterface,
     136                 :     199885 :         (uno_ReleaseFunc)cpp_release );
     137                 :            : }
     138                 :            : 
     139                 :            : //______________________________________________________________________________
     140                 :            : template< class E >
     141                 :        490 : inline sal_Bool Sequence< E >::operator != ( const Sequence< E > & rSeq ) const
     142                 :            :     SAL_THROW(())
     143                 :            : {
     144                 :        490 :     return (! operator == ( rSeq ));
     145                 :            : }
     146                 :            : 
     147                 :            : //______________________________________________________________________________
     148                 :            : template< class E >
     149                 :   52484665 : inline E * Sequence< E >::getArray()
     150                 :            : {
     151                 :   52484665 :     const Type & rType = ::cppu::getTypeFavourUnsigned( this );
     152                 :            : #if ! defined EXCEPTIONS_OFF
     153                 :            :     sal_Bool success =
     154                 :            : #endif
     155                 :            :     ::uno_type_sequence_reference2One(
     156                 :            :         &_pSequence, rType.getTypeLibType(),
     157                 :   52484665 :         (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
     158                 :            : #if ! defined EXCEPTIONS_OFF
     159   [ -  +  -  +  :   52484665 :     if (! success)
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
                +  -  + ]
     160                 :          0 :         throw ::std::bad_alloc();
     161                 :            : #endif
     162                 :   52484665 :     return reinterpret_cast< E * >( _pSequence->elements );
     163                 :            : }
     164                 :            : 
     165                 :            : //______________________________________________________________________________
     166                 :            : template< class E >
     167                 :   45674065 : inline E & Sequence< E >::operator [] ( sal_Int32 nIndex )
     168                 :            : {
     169                 :            :     OSL_ENSURE(
     170                 :            :         nIndex >= 0 && nIndex < getLength(),
     171                 :            :         "### illegal index of sequence!" );
     172                 :   45674065 :     return getArray()[ nIndex ];
     173                 :            : }
     174                 :            : 
     175                 :            : //______________________________________________________________________________
     176                 :            : template< class E >
     177                 :   10811282 : inline const E & Sequence< E >::operator [] ( sal_Int32 nIndex ) const
     178                 :            :     SAL_THROW(())
     179                 :            : {
     180                 :            :     OSL_ENSURE(
     181                 :            :         nIndex >= 0 && nIndex < getLength(),
     182                 :            :         "### illegal index of sequence!" );
     183                 :   10811282 :     return reinterpret_cast< const E * >( _pSequence->elements )[ nIndex ];
     184                 :            : }
     185                 :            : 
     186                 :            : //______________________________________________________________________________
     187                 :            : template< class E >
     188                 :    5048595 : inline void Sequence< E >::realloc( sal_Int32 nSize )
     189                 :            : {
     190                 :    5048595 :     const Type & rType = ::cppu::getTypeFavourUnsigned( this );
     191                 :            : #if !defined EXCEPTIONS_OFF
     192                 :            :     sal_Bool success =
     193                 :            : #endif
     194                 :            :     ::uno_type_sequence_realloc(
     195                 :            :         &_pSequence, rType.getTypeLibType(), nSize,
     196                 :    5048595 :         (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
     197                 :            : #if !defined EXCEPTIONS_OFF
     198   [ -  +  -  +  :    5048595 :     if (!success)
          -  +  -  +  -  
          +  -  +  -  +  
                   -  + ]
     199                 :          0 :         throw ::std::bad_alloc();
     200                 :            : #endif
     201                 :    5048595 : }
     202                 :            : 
     203                 :            : //------------------------------------------------------------------------------
     204                 :      88388 : inline ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL toUnoSequence(
     205                 :            :     const ::rtl::ByteSequence & rByteSequence ) SAL_THROW(())
     206                 :            : {
     207                 :            :     return ::com::sun::star::uno::Sequence< sal_Int8 >(
     208                 :      88388 :         * reinterpret_cast< const ::com::sun::star::uno::Sequence< sal_Int8 > * >( &rByteSequence ) );
     209                 :            : }
     210                 :            : 
     211                 :            : }
     212                 :            : }
     213                 :            : }
     214                 :            : }
     215                 :            : 
     216                 :            : namespace cppu {
     217                 :            : 
     218                 :            : template< typename T > inline ::com::sun::star::uno::Type const &
     219                 :  108258614 : getTypeFavourUnsigned(
     220                 :            :     SAL_UNUSED_PARAMETER ::com::sun::star::uno::Sequence< T > const *)
     221                 :            : {
     222 [ +  + ][ +  + ]:  108258614 :     if (::com::sun::star::uno::Sequence< T >::s_pType == 0) {
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
                 [ +  + ]
     223                 :      51575 :         ::typelib_static_sequence_type_init(
     224                 :            :             &::com::sun::star::uno::Sequence< T >::s_pType,
     225                 :            :             (::cppu::getTypeFavourUnsigned(
     226                 :            :                 static_cast<
     227                 :            :                 typename ::com::sun::star::uno::Sequence< T >::ElementType * >(
     228                 :            :                     0)).
     229                 :            :              getTypeLibType()));
     230                 :            :     }
     231                 :            :     return detail::getTypeFromTypeDescriptionReference(
     232                 :  108258614 :         &::com::sun::star::uno::Sequence< T >::s_pType);
     233                 :            : }
     234                 :            : 
     235                 :            : template< typename T > inline ::com::sun::star::uno::Type const &
     236                 :        147 : getTypeFavourChar(
     237                 :            :     SAL_UNUSED_PARAMETER ::com::sun::star::uno::Sequence< T > const *)
     238                 :            : {
     239                 :            :     //TODO  On certain platforms with weak memory models, the following code can
     240                 :            :     // result in some threads observing that td points to garbage:
     241                 :            :     static typelib_TypeDescriptionReference * td = 0;
     242 [ +  + ][ +  + ]:        147 :     if (td == 0) {
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  + ][ +  + ]
         [ +  - ][ +  - ]
         [ +  + ][ +  + ]
                 [ +  - ]
     243                 :        114 :         ::typelib_static_sequence_type_init(
     244                 :            :             &td,
     245                 :            :             (::cppu::getTypeFavourChar(
     246                 :            :                 static_cast<
     247                 :            :                 typename ::com::sun::star::uno::Sequence< T >::ElementType * >(
     248                 :            :                     0)).
     249                 :            :              getTypeLibType()));
     250                 :            :     }
     251                 :        147 :     return detail::getTypeFromTypeDescriptionReference(&td);
     252                 :            : }
     253                 :            : 
     254                 :            : }
     255                 :            : 
     256                 :            : // generic sequence template
     257                 :            : template< class E >
     258                 :            : inline const ::com::sun::star::uno::Type &
     259                 :     106383 : SAL_CALL getCppuType(
     260                 :            :     SAL_UNUSED_PARAMETER const ::com::sun::star::uno::Sequence< E > * )
     261                 :            :     SAL_THROW(())
     262                 :            : {
     263                 :            :     return ::cppu::getTypeFavourUnsigned(
     264                 :     106383 :         static_cast< ::com::sun::star::uno::Sequence< E > * >(0));
     265                 :            : }
     266                 :            : 
     267                 :            : // generic sequence template for given element type (e.g. C++ arrays)
     268                 :            : template< class E >
     269                 :            : inline const ::com::sun::star::uno::Type &
     270                 :            : SAL_CALL getCppuSequenceType( const ::com::sun::star::uno::Type & rElementType )
     271                 :            :     SAL_THROW(())
     272                 :            : {
     273                 :            :     if (! ::com::sun::star::uno::Sequence< E >::s_pType)
     274                 :            :     {
     275                 :            :         ::typelib_static_sequence_type_init(
     276                 :            :             & ::com::sun::star::uno::Sequence< E >::s_pType,
     277                 :            :             rElementType.getTypeLibType() );
     278                 :            :     }
     279                 :            :     return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
     280                 :            :         & ::com::sun::star::uno::Sequence< E >::s_pType );
     281                 :            : }
     282                 :            : 
     283                 :            : #if (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500))
     284                 :            : static typelib_TypeDescriptionReference * s_pType_com_sun_star_uno_Sequence_Char = 0;
     285                 :            : #endif
     286                 :            : 
     287                 :            : // char sequence
     288                 :            : inline const ::com::sun::star::uno::Type &
     289                 :            : SAL_CALL getCharSequenceCppuType() SAL_THROW(())
     290                 :            : {
     291                 :            : #if !( defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500))
     292                 :            :     static typelib_TypeDescriptionReference * s_pType_com_sun_star_uno_Sequence_Char = 0;
     293                 :            : #endif
     294                 :            :     if (! s_pType_com_sun_star_uno_Sequence_Char)
     295                 :            :     {
     296                 :            :         const ::com::sun::star::uno::Type & rElementType = ::getCharCppuType();
     297                 :            :         ::typelib_static_sequence_type_init(
     298                 :            :             & s_pType_com_sun_star_uno_Sequence_Char,
     299                 :            :             rElementType.getTypeLibType() );
     300                 :            :     }
     301                 :            :     return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
     302                 :            :         & s_pType_com_sun_star_uno_Sequence_Char );
     303                 :            : }
     304                 :            : 
     305                 :            : #endif
     306                 :            : 
     307                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10