LCOV - code coverage report
Current view: top level - cppu/source/uno - copy.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 79 270 29.3 %
Date: 2014-04-14 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

          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 COPY_HXX
      20             : #define COPY_HXX
      21             : 
      22             : #include "prim.hxx"
      23             : #include "constr.hxx"
      24             : 
      25             : 
      26             : namespace cppu
      27             : {
      28             : 
      29             : 
      30             : //#### copy construction ###########################################################################
      31             : 
      32             : 
      33             : 
      34         131 : inline uno_Sequence * allocSeq(
      35             :     sal_Int32 nElementSize, sal_Int32 nElements )
      36             : {
      37             :     OSL_ASSERT( nElements >= 0 && nElementSize >= 0 );
      38         131 :     uno_Sequence * pSeq = 0;
      39         131 :     sal_uInt32 nSize = calcSeqMemSize( nElementSize, nElements );
      40         131 :     if (nSize > 0)
      41             :     {
      42         131 :         pSeq = (uno_Sequence *) rtl_allocateMemory( nSize );
      43         131 :         if (pSeq != 0)
      44             :         {
      45             :             // header init
      46         131 :             pSeq->nRefCount = 1;
      47         131 :             pSeq->nElements = nElements;
      48             :         }
      49             :     }
      50         131 :     return pSeq;
      51             : }
      52             : 
      53             : 
      54             : void copyConstructStruct(
      55             :     void * pDest, void * pSource,
      56             :     typelib_CompoundTypeDescription * pTypeDescr,
      57             :     uno_AcquireFunc acquire, uno_Mapping * mapping )
      58             :     SAL_THROW (());
      59             : 
      60           3 : inline void _copyConstructStruct(
      61             :     void * pDest, void * pSource,
      62             :     typelib_CompoundTypeDescription * pTypeDescr,
      63             :     uno_AcquireFunc acquire, uno_Mapping * mapping )
      64             :     SAL_THROW (())
      65             : {
      66           3 :     if (pTypeDescr->pBaseTypeDescription)
      67             :     {
      68             :         // copy base value
      69           0 :         copyConstructStruct( pDest, pSource, pTypeDescr->pBaseTypeDescription, acquire, mapping );
      70             :     }
      71             : 
      72             :     // then copy members
      73           3 :     typelib_TypeDescriptionReference ** ppTypeRefs = pTypeDescr->ppTypeRefs;
      74           3 :     sal_Int32 * pMemberOffsets = pTypeDescr->pMemberOffsets;
      75           3 :     sal_Int32 nDescr = pTypeDescr->nMembers;
      76             : 
      77           3 :     if (mapping)
      78             :     {
      79           0 :         while (nDescr--)
      80             :         {
      81             :             ::uno_type_copyAndConvertData(
      82           0 :                 (char *)pDest + pMemberOffsets[nDescr],
      83           0 :                 (char *)pSource + pMemberOffsets[nDescr],
      84           0 :                 ppTypeRefs[nDescr], mapping );
      85             :         }
      86             :     }
      87             :     else
      88             :     {
      89          12 :         while (nDescr--)
      90             :         {
      91             :             ::uno_type_copyData(
      92          12 :                 (char *)pDest + pMemberOffsets[nDescr],
      93          12 :                 (char *)pSource + pMemberOffsets[nDescr],
      94          24 :                 ppTypeRefs[nDescr], acquire );
      95             :         }
      96             :     }
      97           3 : }
      98             : 
      99             : 
     100             : uno_Sequence * copyConstructSequence(
     101             :     uno_Sequence * pSource,
     102             :     typelib_TypeDescriptionReference * pElementType,
     103             :     uno_AcquireFunc acquire, uno_Mapping * mapping );
     104             : 
     105             : 
     106       66742 : inline void _copyConstructAnyFromData(
     107             :     uno_Any * pDestAny, void * pSource,
     108             :     typelib_TypeDescriptionReference * pType, typelib_TypeDescription * pTypeDescr,
     109             :     uno_AcquireFunc acquire, uno_Mapping * mapping )
     110             :     SAL_THROW (())
     111             : {
     112       66742 :     TYPE_ACQUIRE( pType );
     113       66742 :     pDestAny->pType = pType;
     114             : 
     115       66742 :     switch (pType->eTypeClass)
     116             :     {
     117             :     case typelib_TypeClass_CHAR:
     118           0 :         pDestAny->pData = &pDestAny->pReserved;
     119           0 :         *(sal_Unicode *)pDestAny->pData = *(sal_Unicode *)pSource;
     120           0 :         break;
     121             :     case typelib_TypeClass_BOOLEAN:
     122        9995 :         pDestAny->pData = &pDestAny->pReserved;
     123        9995 :         *(sal_Bool *)pDestAny->pData = (*(sal_Bool *)pSource != sal_False);
     124        9995 :         break;
     125             :     case typelib_TypeClass_BYTE:
     126           0 :         pDestAny->pData = &pDestAny->pReserved;
     127           0 :         *(sal_Int8 *)pDestAny->pData = *(sal_Int8 *)pSource;
     128           0 :         break;
     129             :     case typelib_TypeClass_SHORT:
     130             :     case typelib_TypeClass_UNSIGNED_SHORT:
     131         280 :         pDestAny->pData = &pDestAny->pReserved;
     132         280 :         *(sal_Int16 *)pDestAny->pData = *(sal_Int16 *)pSource;
     133         280 :         break;
     134             :     case typelib_TypeClass_LONG:
     135             :     case typelib_TypeClass_UNSIGNED_LONG:
     136       13709 :         pDestAny->pData = &pDestAny->pReserved;
     137       13709 :         *(sal_Int32 *)pDestAny->pData = *(sal_Int32 *)pSource;
     138       13709 :         break;
     139             :     case typelib_TypeClass_HYPER:
     140             :     case typelib_TypeClass_UNSIGNED_HYPER:
     141             :         if (sizeof(void *) >= sizeof(sal_Int64))
     142             :             pDestAny->pData = &pDestAny->pReserved;
     143             :         else
     144          87 :             pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Int64) );
     145          87 :         *(sal_Int64 *)pDestAny->pData = *(sal_Int64 *)pSource;
     146          87 :         break;
     147             :     case typelib_TypeClass_FLOAT:
     148             :         if (sizeof(void *) >= sizeof(float))
     149           0 :             pDestAny->pData = &pDestAny->pReserved;
     150             :         else
     151             :             pDestAny->pData = ::rtl_allocateMemory( sizeof(float) );
     152           0 :         *(float *)pDestAny->pData = *(float *)pSource;
     153           0 :         break;
     154             :     case typelib_TypeClass_DOUBLE:
     155             :         if (sizeof(void *) >= sizeof(double))
     156             :             pDestAny->pData = &pDestAny->pReserved;
     157             :         else
     158         237 :             pDestAny->pData = ::rtl_allocateMemory( sizeof(double) );
     159         237 :         *(double *)pDestAny->pData = *(double *)pSource;
     160         237 :         break;
     161             :     case typelib_TypeClass_STRING:
     162       38599 :         ::rtl_uString_acquire( *(rtl_uString **)pSource );
     163       38599 :         pDestAny->pData = &pDestAny->pReserved;
     164       38599 :         *(rtl_uString **)pDestAny->pData = *(rtl_uString **)pSource;
     165       38599 :         break;
     166             :     case typelib_TypeClass_TYPE:
     167           0 :         TYPE_ACQUIRE( *(typelib_TypeDescriptionReference **)pSource );
     168           0 :         pDestAny->pData = &pDestAny->pReserved;
     169           0 :         *(typelib_TypeDescriptionReference **)pDestAny->pData = *(typelib_TypeDescriptionReference **)pSource;
     170           0 :         break;
     171             :     case typelib_TypeClass_ANY:
     172             :         OSL_FAIL( "### unexpected nested any!" );
     173           0 :         break;
     174             :     case typelib_TypeClass_ENUM:
     175           0 :         pDestAny->pData = &pDestAny->pReserved;
     176             :         // enum is forced to 32bit long
     177           0 :         *(sal_Int32 *)pDestAny->pData = *(sal_Int32 *)pSource;
     178           0 :         break;
     179             :     case typelib_TypeClass_STRUCT:
     180             :     case typelib_TypeClass_EXCEPTION:
     181           3 :         if (pTypeDescr)
     182             :         {
     183           0 :             pDestAny->pData = ::rtl_allocateMemory( pTypeDescr->nSize );
     184             :             _copyConstructStruct(
     185             :                 pDestAny->pData, pSource,
     186             :                 (typelib_CompoundTypeDescription *)pTypeDescr,
     187           0 :                 acquire, mapping );
     188             :         }
     189             :         else
     190             :         {
     191           3 :             TYPELIB_DANGER_GET( &pTypeDescr, pType );
     192           3 :             pDestAny->pData = ::rtl_allocateMemory( pTypeDescr->nSize );
     193             :             _copyConstructStruct(
     194             :                 pDestAny->pData, pSource,
     195             :                 (typelib_CompoundTypeDescription *)pTypeDescr,
     196           3 :                 acquire, mapping );
     197           3 :             TYPELIB_DANGER_RELEASE( pTypeDescr );
     198             :         }
     199           3 :         break;
     200             :     case typelib_TypeClass_SEQUENCE:
     201        3553 :         pDestAny->pData = &pDestAny->pReserved;
     202        3553 :         if (pTypeDescr)
     203             :         {
     204             :             *(uno_Sequence **)pDestAny->pData = copyConstructSequence(
     205             :                 *(uno_Sequence **)pSource,
     206             :                 ((typelib_IndirectTypeDescription *)pTypeDescr)->pType,
     207           0 :                 acquire, mapping );
     208             :         }
     209             :         else
     210             :         {
     211        3553 :             TYPELIB_DANGER_GET( &pTypeDescr, pType );
     212             :             *(uno_Sequence **)pDestAny->pData = copyConstructSequence(
     213             :                 *(uno_Sequence **)pSource,
     214             :                 ((typelib_IndirectTypeDescription *)pTypeDescr)->pType,
     215        3553 :                 acquire, mapping );
     216        3553 :             TYPELIB_DANGER_RELEASE( pTypeDescr );
     217             :         }
     218        3553 :         break;
     219             :     case typelib_TypeClass_INTERFACE:
     220         279 :         pDestAny->pData = &pDestAny->pReserved;
     221         279 :         if (mapping)
     222             :         {
     223          20 :             pDestAny->pReserved = _map( *(void **)pSource, pType, pTypeDescr, mapping );
     224             :         }
     225             :         else
     226             :         {
     227         259 :             _acquire( pDestAny->pReserved = *(void **)pSource, acquire );
     228             :         }
     229         279 :         break;
     230             :     default:
     231             :         OSL_ASSERT(false);
     232           0 :         break;
     233             :     }
     234       66742 : }
     235             : 
     236       82243 : inline void _copyConstructAny(
     237             :     uno_Any * pDestAny, void * pSource,
     238             :     typelib_TypeDescriptionReference * pType, typelib_TypeDescription * pTypeDescr,
     239             :     uno_AcquireFunc acquire, uno_Mapping * mapping )
     240             :     SAL_THROW (())
     241             : {
     242       82243 :     if (typelib_TypeClass_VOID == pType->eTypeClass)
     243             :     {
     244       15501 :         CONSTRUCT_EMPTY_ANY( pDestAny );
     245             :     }
     246             :     else
     247             :     {
     248       66742 :         if (typelib_TypeClass_ANY == pType->eTypeClass)
     249             :         {
     250           0 :             if (pSource)
     251             :             {
     252           0 :                 pType = ((uno_Any *)pSource)->pType;
     253           0 :                 if (typelib_TypeClass_VOID == pType->eTypeClass)
     254             :                 {
     255           0 :                     CONSTRUCT_EMPTY_ANY( pDestAny );
     256           0 :                     return;
     257             :                 }
     258           0 :                 pTypeDescr = 0;
     259           0 :                 pSource = ((uno_Any *)pSource)->pData;
     260             :             }
     261             :             else
     262             :             {
     263           0 :                 CONSTRUCT_EMPTY_ANY( pDestAny );
     264           0 :                 return;
     265             :             }
     266             :         }
     267       66742 :         if (pSource)
     268             :         {
     269       66742 :             _copyConstructAnyFromData( pDestAny, pSource, pType, pTypeDescr, acquire, mapping );
     270             :         }
     271             :         else // default construct
     272             :         {
     273           0 :             TYPE_ACQUIRE( pType );
     274           0 :             pDestAny->pType = pType;
     275           0 :             switch (pType->eTypeClass)
     276             :             {
     277             :             case typelib_TypeClass_CHAR:
     278           0 :                 pDestAny->pData = &pDestAny->pReserved;
     279           0 :                 *(sal_Unicode *)pDestAny->pData = '\0';
     280           0 :                 break;
     281             :             case typelib_TypeClass_BOOLEAN:
     282           0 :                 pDestAny->pData = &pDestAny->pReserved;
     283           0 :                 *(sal_Bool *)pDestAny->pData = sal_False;
     284           0 :                 break;
     285             :             case typelib_TypeClass_BYTE:
     286           0 :                 pDestAny->pData = &pDestAny->pReserved;
     287           0 :                 *(sal_Int8 *)pDestAny->pData = 0;
     288           0 :                 break;
     289             :             case typelib_TypeClass_SHORT:
     290             :             case typelib_TypeClass_UNSIGNED_SHORT:
     291           0 :                 pDestAny->pData = &pDestAny->pReserved;
     292           0 :                 *(sal_Int16 *)pDestAny->pData = 0;
     293           0 :                 break;
     294             :             case typelib_TypeClass_LONG:
     295             :             case typelib_TypeClass_UNSIGNED_LONG:
     296           0 :                 pDestAny->pData = &pDestAny->pReserved;
     297           0 :                 *(sal_Int32 *)pDestAny->pData = 0;
     298           0 :                 break;
     299             :             case typelib_TypeClass_HYPER:
     300             :             case typelib_TypeClass_UNSIGNED_HYPER:
     301             :                 if (sizeof(void *) >= sizeof(sal_Int64))
     302             :                     pDestAny->pData = &pDestAny->pReserved;
     303             :                 else
     304           0 :                     pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Int64) );
     305           0 :                 *(sal_Int64 *)pDestAny->pData = 0;
     306           0 :                 break;
     307             :             case typelib_TypeClass_FLOAT:
     308             :                 if (sizeof(void *) >= sizeof(float))
     309           0 :                     pDestAny->pData = &pDestAny->pReserved;
     310             :                 else
     311             :                     pDestAny->pData = ::rtl_allocateMemory( sizeof(float) );
     312           0 :                 *(float *)pDestAny->pData = 0.0;
     313           0 :                 break;
     314             :             case typelib_TypeClass_DOUBLE:
     315             :                 if (sizeof(void *) >= sizeof(double))
     316             :                     pDestAny->pData = &pDestAny->pReserved;
     317             :                 else
     318           0 :                     pDestAny->pData = ::rtl_allocateMemory( sizeof(double) );
     319           0 :                 *(double *)pDestAny->pData = 0.0;
     320           0 :                 break;
     321             :             case typelib_TypeClass_STRING:
     322           0 :                 pDestAny->pData = &pDestAny->pReserved;
     323           0 :                 *(rtl_uString **)pDestAny->pData = 0;
     324           0 :                 ::rtl_uString_new( (rtl_uString **)pDestAny->pData );
     325           0 :                 break;
     326             :             case typelib_TypeClass_TYPE:
     327           0 :                 pDestAny->pData = &pDestAny->pReserved;
     328           0 :                 *(typelib_TypeDescriptionReference **)pDestAny->pData = _getVoidType();
     329           0 :                 break;
     330             :             case typelib_TypeClass_ENUM:
     331           0 :                 pDestAny->pData = &pDestAny->pReserved;
     332           0 :                 if (pTypeDescr)
     333             :                 {
     334           0 :                     *(sal_Int32 *)pDestAny->pData = ((typelib_EnumTypeDescription *)pTypeDescr)->nDefaultEnumValue;
     335             :                 }
     336             :                 else
     337             :                 {
     338           0 :                     TYPELIB_DANGER_GET( &pTypeDescr, pType );
     339           0 :                     *(sal_Int32 *)pDestAny->pData = ((typelib_EnumTypeDescription *)pTypeDescr)->nDefaultEnumValue;
     340           0 :                     TYPELIB_DANGER_RELEASE( pTypeDescr );
     341             :                 }
     342           0 :                 break;
     343             :             case typelib_TypeClass_STRUCT:
     344             :             case typelib_TypeClass_EXCEPTION:
     345           0 :                 if (pTypeDescr)
     346             :                 {
     347           0 :                     pDestAny->pData = ::rtl_allocateMemory( pTypeDescr->nSize );
     348             :                     _defaultConstructStruct(
     349           0 :                         pDestAny->pData, (typelib_CompoundTypeDescription *)pTypeDescr );
     350             :                 }
     351             :                 else
     352             :                 {
     353           0 :                     TYPELIB_DANGER_GET( &pTypeDescr, pType );
     354           0 :                     pDestAny->pData = ::rtl_allocateMemory( pTypeDescr->nSize );
     355             :                     _defaultConstructStruct(
     356           0 :                         pDestAny->pData, (typelib_CompoundTypeDescription *)pTypeDescr );
     357           0 :                     TYPELIB_DANGER_RELEASE( pTypeDescr );
     358             :                 }
     359           0 :                 break;
     360             :             case typelib_TypeClass_SEQUENCE:
     361           0 :                 pDestAny->pData = &pDestAny->pReserved;
     362           0 :                 *(uno_Sequence **)pDestAny->pData = createEmptySequence();
     363           0 :                 break;
     364             :             case typelib_TypeClass_INTERFACE:
     365           0 :                 pDestAny->pData = &pDestAny->pReserved;
     366           0 :                 pDestAny->pReserved = 0; // either cpp or c-uno interface
     367           0 :                 break;
     368             :             default:
     369             :                 OSL_ASSERT(false);
     370           0 :                 break;
     371             :             }
     372             :         }
     373             :     }
     374             : }
     375             : 
     376        3553 : inline uno_Sequence * icopyConstructSequence(
     377             :     uno_Sequence * pSource,
     378             :     typelib_TypeDescriptionReference * pElementType,
     379             :     uno_AcquireFunc acquire, uno_Mapping * mapping )
     380             : {
     381        3553 :     typelib_TypeClass eTypeClass = pElementType->eTypeClass;
     382        3553 :     if (!mapping ||
     383           0 :         (eTypeClass <= typelib_TypeClass_ENUM &&
     384             :          eTypeClass != typelib_TypeClass_ANY))
     385             :     {
     386        3553 :         osl_atomic_increment( &pSource->nRefCount );
     387        3553 :         return pSource;
     388             :     }
     389             :     else // create new sequence
     390             :     {
     391             :         uno_Sequence * pDest;
     392           0 :         sal_Int32 nElements = pSource->nElements;
     393           0 :         if (nElements)
     394             :         {
     395           0 :             switch (eTypeClass)
     396             :             {
     397             :             case typelib_TypeClass_ANY:
     398             :             {
     399           0 :                 pDest = allocSeq( sizeof (uno_Any), nElements );
     400           0 :                 if (pDest != 0)
     401             :                 {
     402           0 :                     uno_Any * pDestElements = (uno_Any *)pDest->elements;
     403           0 :                     uno_Any * pSourceElements = (uno_Any *)pSource->elements;
     404           0 :                     for ( sal_Int32 nPos = nElements; nPos--; )
     405             :                     {
     406             :                         typelib_TypeDescriptionReference * pType =
     407           0 :                             pSourceElements[nPos].pType;
     408           0 :                         if (typelib_TypeClass_VOID == pType->eTypeClass)
     409             :                         {
     410           0 :                             CONSTRUCT_EMPTY_ANY( &pDestElements[nPos] );
     411             :                         }
     412             :                         else
     413             :                         {
     414             :                             _copyConstructAnyFromData(
     415             :                                 &pDestElements[nPos],
     416           0 :                                 pSourceElements[nPos].pData,
     417             :                                 pType, 0,
     418           0 :                                 acquire, mapping );
     419             :                         }
     420             :                     }
     421             :                 }
     422           0 :                 break;
     423             :             }
     424             :             case typelib_TypeClass_STRUCT:
     425             :             case typelib_TypeClass_EXCEPTION:
     426             :             {
     427           0 :                 typelib_TypeDescription * pElementTypeDescr = 0;
     428           0 :                 TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
     429           0 :                 sal_Int32 nElementSize = pElementTypeDescr->nSize;
     430           0 :                 char * pSourceElements = pSource->elements;
     431           0 :                 pDest = allocSeq( nElementSize, nElements );
     432           0 :                 if (pDest != 0)
     433             :                 {
     434           0 :                     char * pElements = pDest->elements;
     435           0 :                     for ( sal_Int32 nPos = nElements; nPos--; )
     436             :                     {
     437             :                         _copyConstructStruct(
     438           0 :                             pElements + (nPos * nElementSize),
     439           0 :                             pSourceElements + (nPos * nElementSize),
     440             :                             (typelib_CompoundTypeDescription *)
     441             :                             pElementTypeDescr,
     442           0 :                             acquire, mapping );
     443             :                     }
     444             :                 }
     445           0 :                 TYPELIB_DANGER_RELEASE( pElementTypeDescr );
     446           0 :                 break;
     447             :             }
     448             :             case typelib_TypeClass_SEQUENCE: // sequence of sequence
     449             :             {
     450           0 :                 pDest = allocSeq( sizeof (uno_Sequence *), nElements );
     451           0 :                 if (pDest != 0)
     452             :                 {
     453           0 :                     typelib_TypeDescription * pElementTypeDescr = 0;
     454           0 :                     TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
     455             :                     typelib_TypeDescriptionReference * pSeqElementType =
     456             :                         ((typelib_IndirectTypeDescription *)
     457           0 :                          pElementTypeDescr)->pType;
     458             : 
     459             :                     uno_Sequence ** pDestElements =
     460           0 :                         (uno_Sequence **) pDest->elements;
     461             :                     uno_Sequence ** pSourceElements =
     462           0 :                         (uno_Sequence **) pSource->elements;
     463           0 :                     for ( sal_Int32 nPos = nElements; nPos--; )
     464             :                     {
     465             :                         uno_Sequence * pNew = copyConstructSequence(
     466           0 :                             pSourceElements[nPos],
     467             :                             pSeqElementType,
     468           0 :                             acquire, mapping );
     469             :                         OSL_ASSERT( pNew != 0 );
     470             :                         // ought never be a memory allocation problem,
     471             :                         // because of reference counted sequence handles
     472           0 :                         pDestElements[ nPos ] = pNew;
     473             :                     }
     474             : 
     475           0 :                     TYPELIB_DANGER_RELEASE( pElementTypeDescr );
     476             :                 }
     477           0 :                 break;
     478             :             }
     479             :             case typelib_TypeClass_INTERFACE:
     480             :             {
     481           0 :                 pDest = allocSeq( sizeof (void *), nElements );
     482           0 :                 if (pDest != 0)
     483             :                 {
     484           0 :                     char * pElements = pDest->elements;
     485           0 :                     void ** pSourceElements = (void **)pSource->elements;
     486           0 :                     typelib_TypeDescription * pElementTypeDescr = 0;
     487           0 :                     TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
     488           0 :                     for ( sal_Int32 nPos = nElements; nPos--; )
     489             :                     {
     490           0 :                         ((void **)pElements)[nPos] = 0;
     491           0 :                         if (((void **)pSourceElements)[nPos])
     492             :                         {
     493             :                             (*mapping->mapInterface)(
     494             :                                 mapping, (void **)pElements + nPos,
     495           0 :                                 pSourceElements[nPos],
     496             :                                 (typelib_InterfaceTypeDescription *)
     497           0 :                                 pElementTypeDescr );
     498             :                         }
     499             :                     }
     500           0 :                     TYPELIB_DANGER_RELEASE( pElementTypeDescr );
     501             :                 }
     502           0 :                 break;
     503             :             }
     504             :             default:
     505             :                 OSL_FAIL( "### unexepcted sequence element type!" );
     506           0 :                 pDest = 0;
     507           0 :                 break;
     508             :             }
     509             :         }
     510             :         else // empty sequence
     511             :         {
     512           0 :             pDest = allocSeq( 0, 0 );
     513             :         }
     514             : 
     515           0 :         return pDest;
     516             :     }
     517             : }
     518             : 
     519             : 
     520           6 : inline void _copyConstructData(
     521             :     void * pDest, void * pSource,
     522             :     typelib_TypeDescriptionReference * pType, typelib_TypeDescription * pTypeDescr,
     523             :     uno_AcquireFunc acquire, uno_Mapping * mapping )
     524             :     SAL_THROW (())
     525             : {
     526           6 :     switch (pType->eTypeClass)
     527             :     {
     528             :     case typelib_TypeClass_CHAR:
     529           0 :         *(sal_Unicode *)pDest = *(sal_Unicode *)pSource;
     530           0 :         break;
     531             :     case typelib_TypeClass_BOOLEAN:
     532           3 :         *(sal_Bool *)pDest = (*(sal_Bool *)pSource != sal_False);
     533           3 :         break;
     534             :     case typelib_TypeClass_BYTE:
     535           0 :         *(sal_Int8 *)pDest = *(sal_Int8 *)pSource;
     536           0 :         break;
     537             :     case typelib_TypeClass_SHORT:
     538             :     case typelib_TypeClass_UNSIGNED_SHORT:
     539           0 :         *(sal_Int16 *)pDest = *(sal_Int16 *)pSource;
     540           0 :         break;
     541             :     case typelib_TypeClass_LONG:
     542             :     case typelib_TypeClass_UNSIGNED_LONG:
     543           0 :         *(sal_Int32 *)pDest = *(sal_Int32 *)pSource;
     544           0 :         break;
     545             :     case typelib_TypeClass_HYPER:
     546             :     case typelib_TypeClass_UNSIGNED_HYPER:
     547           0 :         *(sal_Int64 *)pDest = *(sal_Int64 *)pSource;
     548           0 :         break;
     549             :     case typelib_TypeClass_FLOAT:
     550           0 :         *(float *)pDest = *(float *)pSource;
     551           0 :         break;
     552             :     case typelib_TypeClass_DOUBLE:
     553           0 :         *(double *)pDest = *(double *)pSource;
     554           0 :         break;
     555             :     case typelib_TypeClass_STRING:
     556           0 :         ::rtl_uString_acquire( *(rtl_uString **)pSource );
     557           0 :         *(rtl_uString **)pDest = *(rtl_uString **)pSource;
     558           0 :         break;
     559             :     case typelib_TypeClass_TYPE:
     560           0 :         TYPE_ACQUIRE( *(typelib_TypeDescriptionReference **)pSource );
     561           0 :         *(typelib_TypeDescriptionReference **)pDest = *(typelib_TypeDescriptionReference **)pSource;
     562           0 :         break;
     563             :     case typelib_TypeClass_ANY:
     564             :         _copyConstructAny(
     565             :             (uno_Any *)pDest, ((uno_Any *)pSource)->pData,
     566             :             ((uno_Any *)pSource)->pType, 0,
     567           3 :             acquire, mapping );
     568           3 :         break;
     569             :     case typelib_TypeClass_ENUM:
     570           0 :         *(sal_Int32 *)pDest = *(sal_Int32 *)pSource;
     571           0 :         break;
     572             :     case typelib_TypeClass_STRUCT:
     573             :     case typelib_TypeClass_EXCEPTION:
     574           0 :         if (pTypeDescr)
     575             :         {
     576             :             _copyConstructStruct(
     577             :                 pDest, pSource,
     578             :                 (typelib_CompoundTypeDescription *)pTypeDescr,
     579           0 :                 acquire, mapping );
     580             :         }
     581             :         else
     582             :         {
     583           0 :             TYPELIB_DANGER_GET( &pTypeDescr, pType );
     584             :             _copyConstructStruct(
     585             :                 pDest, pSource,
     586             :                 (typelib_CompoundTypeDescription *)pTypeDescr,
     587           0 :                 acquire, mapping );
     588           0 :             TYPELIB_DANGER_RELEASE( pTypeDescr );
     589             :         }
     590           0 :         break;
     591             :     case typelib_TypeClass_SEQUENCE:
     592           0 :         if (mapping)
     593             :         {
     594           0 :             if (pTypeDescr)
     595             :             {
     596             :                 *(uno_Sequence **)pDest = icopyConstructSequence(
     597             :                     *(uno_Sequence **)pSource,
     598             :                     ((typelib_IndirectTypeDescription *)pTypeDescr)->pType,
     599           0 :                     acquire, mapping );
     600             :             }
     601             :             else
     602             :             {
     603           0 :                 TYPELIB_DANGER_GET( &pTypeDescr, pType );
     604             :                 *(uno_Sequence **)pDest = icopyConstructSequence(
     605             :                     *(uno_Sequence **)pSource,
     606             :                     ((typelib_IndirectTypeDescription *)pTypeDescr)->pType,
     607           0 :                     acquire, mapping );
     608           0 :                 TYPELIB_DANGER_RELEASE( pTypeDescr );
     609             :             }
     610             :         }
     611             :         else
     612             :         {
     613           0 :             osl_atomic_increment( &(*(uno_Sequence **)pSource)->nRefCount );
     614           0 :             *(uno_Sequence **)pDest = *(uno_Sequence **)pSource;
     615             :         }
     616           0 :         break;
     617             :     case typelib_TypeClass_INTERFACE:
     618           0 :         if (mapping)
     619           0 :             *(void **)pDest = _map( *(void **)pSource, pType, pTypeDescr, mapping );
     620             :         else
     621           0 :             _acquire( *(void **)pDest = *(void **)pSource, acquire );
     622           0 :         break;
     623             :     default:
     624           0 :         break;
     625             :     }
     626           6 : }
     627             : 
     628             : }
     629             : 
     630             : #endif
     631             : 
     632             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10