1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir #ifndef DESTR_HXX 28*cdf0e10cSrcweir #define DESTR_HXX 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir #include "prim.hxx" 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir namespace cppu 34*cdf0e10cSrcweir { 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir //################################################################################################## 37*cdf0e10cSrcweir //#### destruction ################################################################################# 38*cdf0e10cSrcweir //################################################################################################## 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir //-------------------------------------------------------------------------------------------------- 41*cdf0e10cSrcweir inline void _destructUnion( 42*cdf0e10cSrcweir void * pValue, 43*cdf0e10cSrcweir typelib_TypeDescription * pTypeDescr, 44*cdf0e10cSrcweir uno_ReleaseFunc release ) 45*cdf0e10cSrcweir SAL_THROW( () ) 46*cdf0e10cSrcweir { 47*cdf0e10cSrcweir typelib_TypeDescriptionReference * pType = _unionGetSetType( pValue, pTypeDescr ); 48*cdf0e10cSrcweir ::uno_type_destructData( 49*cdf0e10cSrcweir (char *)pValue + ((typelib_UnionTypeDescription *)pTypeDescr)->nValueOffset, 50*cdf0e10cSrcweir pType, release ); 51*cdf0e10cSrcweir ::typelib_typedescriptionreference_release( pType ); 52*cdf0e10cSrcweir } 53*cdf0e10cSrcweir //================================================================================================== 54*cdf0e10cSrcweir void destructStruct( 55*cdf0e10cSrcweir void * pValue, 56*cdf0e10cSrcweir typelib_CompoundTypeDescription * pTypeDescr, 57*cdf0e10cSrcweir uno_ReleaseFunc release ) 58*cdf0e10cSrcweir SAL_THROW( () ); 59*cdf0e10cSrcweir //-------------------------------------------------------------------------------------------------- 60*cdf0e10cSrcweir inline void _destructStruct( 61*cdf0e10cSrcweir void * pValue, 62*cdf0e10cSrcweir typelib_CompoundTypeDescription * pTypeDescr, 63*cdf0e10cSrcweir uno_ReleaseFunc release ) 64*cdf0e10cSrcweir SAL_THROW( () ) 65*cdf0e10cSrcweir { 66*cdf0e10cSrcweir if (pTypeDescr->pBaseTypeDescription) 67*cdf0e10cSrcweir { 68*cdf0e10cSrcweir destructStruct( pValue, pTypeDescr->pBaseTypeDescription, release ); 69*cdf0e10cSrcweir } 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir typelib_TypeDescriptionReference ** ppTypeRefs = pTypeDescr->ppTypeRefs; 72*cdf0e10cSrcweir sal_Int32 * pMemberOffsets = pTypeDescr->pMemberOffsets; 73*cdf0e10cSrcweir sal_Int32 nDescr = pTypeDescr->nMembers; 74*cdf0e10cSrcweir while (nDescr--) 75*cdf0e10cSrcweir { 76*cdf0e10cSrcweir ::uno_type_destructData( 77*cdf0e10cSrcweir (char *)pValue + pMemberOffsets[nDescr], 78*cdf0e10cSrcweir ppTypeRefs[nDescr], release ); 79*cdf0e10cSrcweir } 80*cdf0e10cSrcweir } 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir //-------------------------------------------------------------------------------------------------- 83*cdf0e10cSrcweir inline void _destructArray( 84*cdf0e10cSrcweir void * pValue, 85*cdf0e10cSrcweir typelib_ArrayTypeDescription * pTypeDescr, 86*cdf0e10cSrcweir uno_ReleaseFunc release ) 87*cdf0e10cSrcweir throw () 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir typelib_TypeDescription * pElementType = NULL; 90*cdf0e10cSrcweir TYPELIB_DANGER_GET( &pElementType, ((typelib_IndirectTypeDescription *)pTypeDescr)->pType ); 91*cdf0e10cSrcweir sal_Int32 nElementSize = pElementType->nSize; 92*cdf0e10cSrcweir TYPELIB_DANGER_RELEASE( pElementType ); 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir sal_Int32 nTotalElements = pTypeDescr->nTotalElements; 95*cdf0e10cSrcweir for(sal_Int32 i=0; i < nTotalElements; i++) 96*cdf0e10cSrcweir { 97*cdf0e10cSrcweir ::uno_type_destructData( 98*cdf0e10cSrcweir (sal_Char *)pValue + i * nElementSize, 99*cdf0e10cSrcweir ((typelib_IndirectTypeDescription *)pTypeDescr)->pType, release ); 100*cdf0e10cSrcweir } 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir typelib_typedescriptionreference_release(((typelib_IndirectTypeDescription *)pTypeDescr)->pType); 103*cdf0e10cSrcweir } 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir //============================================================================== 106*cdf0e10cSrcweir void destructSequence( 107*cdf0e10cSrcweir uno_Sequence * pSequence, 108*cdf0e10cSrcweir typelib_TypeDescriptionReference * pType, 109*cdf0e10cSrcweir typelib_TypeDescription * pTypeDescr, 110*cdf0e10cSrcweir uno_ReleaseFunc release ); 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir //-------------------------------------------------------------------------------------------------- 113*cdf0e10cSrcweir inline void _destructAny( 114*cdf0e10cSrcweir uno_Any * pAny, 115*cdf0e10cSrcweir uno_ReleaseFunc release ) 116*cdf0e10cSrcweir SAL_THROW( () ) 117*cdf0e10cSrcweir { 118*cdf0e10cSrcweir typelib_TypeDescriptionReference * pType = pAny->pType; 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir switch (pType->eTypeClass) 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir case typelib_TypeClass_HYPER: 123*cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_HYPER: 124*cdf0e10cSrcweir if (sizeof(void *) < sizeof(sal_Int64)) 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir ::rtl_freeMemory( pAny->pData ); 127*cdf0e10cSrcweir } 128*cdf0e10cSrcweir break; 129*cdf0e10cSrcweir case typelib_TypeClass_FLOAT: 130*cdf0e10cSrcweir if (sizeof(void *) < sizeof(float)) 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir ::rtl_freeMemory( pAny->pData ); 133*cdf0e10cSrcweir } 134*cdf0e10cSrcweir break; 135*cdf0e10cSrcweir case typelib_TypeClass_DOUBLE: 136*cdf0e10cSrcweir if (sizeof(void *) < sizeof(double)) 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir ::rtl_freeMemory( pAny->pData ); 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir break; 141*cdf0e10cSrcweir case typelib_TypeClass_STRING: 142*cdf0e10cSrcweir ::rtl_uString_release( (rtl_uString *)pAny->pReserved ); 143*cdf0e10cSrcweir break; 144*cdf0e10cSrcweir case typelib_TypeClass_TYPE: 145*cdf0e10cSrcweir ::typelib_typedescriptionreference_release( 146*cdf0e10cSrcweir (typelib_TypeDescriptionReference *)pAny->pReserved ); 147*cdf0e10cSrcweir break; 148*cdf0e10cSrcweir case typelib_TypeClass_ANY: 149*cdf0e10cSrcweir OSL_ENSURE( sal_False, "### unexpected nested any!" ); 150*cdf0e10cSrcweir ::uno_any_destruct( (uno_Any *)pAny->pData, release ); 151*cdf0e10cSrcweir ::rtl_freeMemory( pAny->pData ); 152*cdf0e10cSrcweir break; 153*cdf0e10cSrcweir case typelib_TypeClass_TYPEDEF: 154*cdf0e10cSrcweir OSL_ENSURE( 0, "### unexpected typedef!" ); 155*cdf0e10cSrcweir break; 156*cdf0e10cSrcweir case typelib_TypeClass_STRUCT: 157*cdf0e10cSrcweir case typelib_TypeClass_EXCEPTION: 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir typelib_TypeDescription * pTypeDescr = 0; 160*cdf0e10cSrcweir TYPELIB_DANGER_GET( &pTypeDescr, pType ); 161*cdf0e10cSrcweir _destructStruct( pAny->pData, (typelib_CompoundTypeDescription *)pTypeDescr, release ); 162*cdf0e10cSrcweir TYPELIB_DANGER_RELEASE( pTypeDescr ); 163*cdf0e10cSrcweir ::rtl_freeMemory( pAny->pData ); 164*cdf0e10cSrcweir break; 165*cdf0e10cSrcweir } 166*cdf0e10cSrcweir case typelib_TypeClass_UNION: 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir typelib_TypeDescription * pTypeDescr = 0; 169*cdf0e10cSrcweir TYPELIB_DANGER_GET( &pTypeDescr, pType ); 170*cdf0e10cSrcweir _destructUnion( pAny->pData, pTypeDescr, release ); 171*cdf0e10cSrcweir TYPELIB_DANGER_RELEASE( pTypeDescr ); 172*cdf0e10cSrcweir ::rtl_freeMemory( pAny->pData ); 173*cdf0e10cSrcweir break; 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir case typelib_TypeClass_SEQUENCE: 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir destructSequence( 178*cdf0e10cSrcweir *(uno_Sequence **) &pAny->pReserved, pType, 0, release ); 179*cdf0e10cSrcweir break; 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir case typelib_TypeClass_INTERFACE: 182*cdf0e10cSrcweir _release( pAny->pReserved, release ); 183*cdf0e10cSrcweir break; 184*cdf0e10cSrcweir default: 185*cdf0e10cSrcweir break; 186*cdf0e10cSrcweir } 187*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 188*cdf0e10cSrcweir pAny->pData = (void *)0xdeadbeef; 189*cdf0e10cSrcweir #endif 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir ::typelib_typedescriptionreference_release( pType ); 192*cdf0e10cSrcweir } 193*cdf0e10cSrcweir //-------------------------------------------------------------------------------------------------- 194*cdf0e10cSrcweir inline sal_Int32 idestructElements( 195*cdf0e10cSrcweir void * pElements, typelib_TypeDescriptionReference * pElementType, 196*cdf0e10cSrcweir sal_Int32 nStartIndex, sal_Int32 nStopIndex, 197*cdf0e10cSrcweir uno_ReleaseFunc release ) 198*cdf0e10cSrcweir SAL_THROW( () ) 199*cdf0e10cSrcweir { 200*cdf0e10cSrcweir switch (pElementType->eTypeClass) 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir case typelib_TypeClass_CHAR: 203*cdf0e10cSrcweir return (sal_Int32)(sizeof(sal_Unicode)); 204*cdf0e10cSrcweir case typelib_TypeClass_BOOLEAN: 205*cdf0e10cSrcweir return (sal_Int32)(sizeof(sal_Bool)); 206*cdf0e10cSrcweir case typelib_TypeClass_BYTE: 207*cdf0e10cSrcweir return (sal_Int32)(sizeof(sal_Int8)); 208*cdf0e10cSrcweir case typelib_TypeClass_SHORT: 209*cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_SHORT: 210*cdf0e10cSrcweir return (sal_Int32)(sizeof(sal_Int16)); 211*cdf0e10cSrcweir case typelib_TypeClass_LONG: 212*cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_LONG: 213*cdf0e10cSrcweir return (sal_Int32)(sizeof(sal_Int32)); 214*cdf0e10cSrcweir case typelib_TypeClass_HYPER: 215*cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_HYPER: 216*cdf0e10cSrcweir return (sal_Int32)(sizeof(sal_Int64)); 217*cdf0e10cSrcweir case typelib_TypeClass_FLOAT: 218*cdf0e10cSrcweir return (sal_Int32)(sizeof(float)); 219*cdf0e10cSrcweir case typelib_TypeClass_DOUBLE: 220*cdf0e10cSrcweir return (sal_Int32)(sizeof(double)); 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir case typelib_TypeClass_STRING: 223*cdf0e10cSrcweir { 224*cdf0e10cSrcweir rtl_uString ** pDest = (rtl_uString **)pElements; 225*cdf0e10cSrcweir for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos ) 226*cdf0e10cSrcweir { 227*cdf0e10cSrcweir ::rtl_uString_release( pDest[nPos] ); 228*cdf0e10cSrcweir } 229*cdf0e10cSrcweir return (sal_Int32)(sizeof(rtl_uString *)); 230*cdf0e10cSrcweir } 231*cdf0e10cSrcweir case typelib_TypeClass_TYPE: 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir typelib_TypeDescriptionReference ** pDest = (typelib_TypeDescriptionReference **)pElements; 234*cdf0e10cSrcweir for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos ) 235*cdf0e10cSrcweir { 236*cdf0e10cSrcweir ::typelib_typedescriptionreference_release( pDest[nPos] ); 237*cdf0e10cSrcweir } 238*cdf0e10cSrcweir return (sal_Int32)(sizeof(typelib_TypeDescriptionReference *)); 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir case typelib_TypeClass_ANY: 241*cdf0e10cSrcweir { 242*cdf0e10cSrcweir uno_Any * pDest = (uno_Any *)pElements; 243*cdf0e10cSrcweir for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos ) 244*cdf0e10cSrcweir { 245*cdf0e10cSrcweir _destructAny( &pDest[nPos], release ); 246*cdf0e10cSrcweir } 247*cdf0e10cSrcweir return (sal_Int32)(sizeof(uno_Any)); 248*cdf0e10cSrcweir } 249*cdf0e10cSrcweir case typelib_TypeClass_ENUM: 250*cdf0e10cSrcweir return (sal_Int32)(sizeof(sal_Int32)); 251*cdf0e10cSrcweir case typelib_TypeClass_STRUCT: 252*cdf0e10cSrcweir case typelib_TypeClass_EXCEPTION: 253*cdf0e10cSrcweir { 254*cdf0e10cSrcweir typelib_TypeDescription * pElementTypeDescr = 0; 255*cdf0e10cSrcweir TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType ); 256*cdf0e10cSrcweir sal_Int32 nElementSize = pElementTypeDescr->nSize; 257*cdf0e10cSrcweir for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos ) 258*cdf0e10cSrcweir { 259*cdf0e10cSrcweir _destructStruct( 260*cdf0e10cSrcweir (char *)pElements + (nElementSize * nPos), 261*cdf0e10cSrcweir (typelib_CompoundTypeDescription *)pElementTypeDescr, 262*cdf0e10cSrcweir release ); 263*cdf0e10cSrcweir } 264*cdf0e10cSrcweir sal_Int32 nSize = pElementTypeDescr->nSize; 265*cdf0e10cSrcweir TYPELIB_DANGER_RELEASE( pElementTypeDescr ); 266*cdf0e10cSrcweir return nSize; 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir case typelib_TypeClass_UNION: 269*cdf0e10cSrcweir { 270*cdf0e10cSrcweir typelib_TypeDescription * pElementTypeDescr = 0; 271*cdf0e10cSrcweir TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType ); 272*cdf0e10cSrcweir sal_Int32 nElementSize = pElementTypeDescr->nSize; 273*cdf0e10cSrcweir for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos ) 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir _destructUnion( 276*cdf0e10cSrcweir (char *)pElements + (nElementSize * nPos), 277*cdf0e10cSrcweir pElementTypeDescr, 278*cdf0e10cSrcweir release ); 279*cdf0e10cSrcweir } 280*cdf0e10cSrcweir sal_Int32 nSize = pElementTypeDescr->nSize; 281*cdf0e10cSrcweir TYPELIB_DANGER_RELEASE( pElementTypeDescr ); 282*cdf0e10cSrcweir return nSize; 283*cdf0e10cSrcweir } 284*cdf0e10cSrcweir case typelib_TypeClass_SEQUENCE: 285*cdf0e10cSrcweir { 286*cdf0e10cSrcweir typelib_TypeDescription * pElementTypeDescr = 0; 287*cdf0e10cSrcweir TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType ); 288*cdf0e10cSrcweir uno_Sequence ** pDest = (uno_Sequence **)pElements; 289*cdf0e10cSrcweir for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos ) 290*cdf0e10cSrcweir { 291*cdf0e10cSrcweir destructSequence( 292*cdf0e10cSrcweir pDest[nPos], 293*cdf0e10cSrcweir pElementTypeDescr->pWeakRef, pElementTypeDescr, 294*cdf0e10cSrcweir release ); 295*cdf0e10cSrcweir } 296*cdf0e10cSrcweir TYPELIB_DANGER_RELEASE( pElementTypeDescr ); 297*cdf0e10cSrcweir return (sal_Int32)(sizeof(uno_Sequence *)); 298*cdf0e10cSrcweir } 299*cdf0e10cSrcweir case typelib_TypeClass_INTERFACE: 300*cdf0e10cSrcweir { 301*cdf0e10cSrcweir if (release) 302*cdf0e10cSrcweir { 303*cdf0e10cSrcweir for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos ) 304*cdf0e10cSrcweir { 305*cdf0e10cSrcweir void * p = ((void **)pElements)[nPos]; 306*cdf0e10cSrcweir if (p) 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir (*release)( p ); 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir } 311*cdf0e10cSrcweir } 312*cdf0e10cSrcweir else 313*cdf0e10cSrcweir { 314*cdf0e10cSrcweir for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos ) 315*cdf0e10cSrcweir { 316*cdf0e10cSrcweir uno_Interface * p = ((uno_Interface **)pElements)[nPos]; 317*cdf0e10cSrcweir if (p) 318*cdf0e10cSrcweir { 319*cdf0e10cSrcweir (*p->release)( p ); 320*cdf0e10cSrcweir } 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir } 323*cdf0e10cSrcweir return (sal_Int32)(sizeof(void *)); 324*cdf0e10cSrcweir } 325*cdf0e10cSrcweir default: 326*cdf0e10cSrcweir OSL_ASSERT(false); 327*cdf0e10cSrcweir return 0; 328*cdf0e10cSrcweir } 329*cdf0e10cSrcweir } 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir //------------------------------------------------------------------------------ 332*cdf0e10cSrcweir inline void idestructSequence( 333*cdf0e10cSrcweir uno_Sequence * pSeq, 334*cdf0e10cSrcweir typelib_TypeDescriptionReference * pType, 335*cdf0e10cSrcweir typelib_TypeDescription * pTypeDescr, 336*cdf0e10cSrcweir uno_ReleaseFunc release ) 337*cdf0e10cSrcweir { 338*cdf0e10cSrcweir if (::osl_decrementInterlockedCount( &pSeq->nRefCount ) == 0) 339*cdf0e10cSrcweir { 340*cdf0e10cSrcweir if (pSeq->nElements > 0) 341*cdf0e10cSrcweir { 342*cdf0e10cSrcweir if (pTypeDescr) 343*cdf0e10cSrcweir { 344*cdf0e10cSrcweir idestructElements( 345*cdf0e10cSrcweir pSeq->elements, 346*cdf0e10cSrcweir ((typelib_IndirectTypeDescription *) pTypeDescr)->pType, 0, 347*cdf0e10cSrcweir pSeq->nElements, release ); 348*cdf0e10cSrcweir } 349*cdf0e10cSrcweir else 350*cdf0e10cSrcweir { 351*cdf0e10cSrcweir TYPELIB_DANGER_GET( &pTypeDescr, pType ); 352*cdf0e10cSrcweir idestructElements( 353*cdf0e10cSrcweir pSeq->elements, 354*cdf0e10cSrcweir ((typelib_IndirectTypeDescription *) pTypeDescr)->pType, 0, 355*cdf0e10cSrcweir pSeq->nElements, release ); 356*cdf0e10cSrcweir TYPELIB_DANGER_RELEASE( pTypeDescr ); 357*cdf0e10cSrcweir } 358*cdf0e10cSrcweir } 359*cdf0e10cSrcweir ::rtl_freeMemory( pSeq ); 360*cdf0e10cSrcweir } 361*cdf0e10cSrcweir } 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir //-------------------------------------------------------------------------------------------------- 364*cdf0e10cSrcweir inline void _destructData( 365*cdf0e10cSrcweir void * pValue, 366*cdf0e10cSrcweir typelib_TypeDescriptionReference * pType, 367*cdf0e10cSrcweir typelib_TypeDescription * pTypeDescr, 368*cdf0e10cSrcweir uno_ReleaseFunc release ) 369*cdf0e10cSrcweir SAL_THROW( () ) 370*cdf0e10cSrcweir { 371*cdf0e10cSrcweir switch (pType->eTypeClass) 372*cdf0e10cSrcweir { 373*cdf0e10cSrcweir case typelib_TypeClass_STRING: 374*cdf0e10cSrcweir ::rtl_uString_release( *(rtl_uString **)pValue ); 375*cdf0e10cSrcweir break; 376*cdf0e10cSrcweir case typelib_TypeClass_TYPE: 377*cdf0e10cSrcweir ::typelib_typedescriptionreference_release( *(typelib_TypeDescriptionReference **)pValue ); 378*cdf0e10cSrcweir break; 379*cdf0e10cSrcweir case typelib_TypeClass_ANY: 380*cdf0e10cSrcweir _destructAny( (uno_Any *)pValue, release ); 381*cdf0e10cSrcweir break; 382*cdf0e10cSrcweir case typelib_TypeClass_TYPEDEF: 383*cdf0e10cSrcweir OSL_ENSURE( 0, "### unexpected typedef!" ); 384*cdf0e10cSrcweir break; 385*cdf0e10cSrcweir case typelib_TypeClass_STRUCT: 386*cdf0e10cSrcweir case typelib_TypeClass_EXCEPTION: 387*cdf0e10cSrcweir if (pTypeDescr) 388*cdf0e10cSrcweir { 389*cdf0e10cSrcweir _destructStruct( pValue, (typelib_CompoundTypeDescription *)pTypeDescr, release ); 390*cdf0e10cSrcweir } 391*cdf0e10cSrcweir else 392*cdf0e10cSrcweir { 393*cdf0e10cSrcweir TYPELIB_DANGER_GET( &pTypeDescr, pType ); 394*cdf0e10cSrcweir _destructStruct( pValue, (typelib_CompoundTypeDescription *)pTypeDescr, release ); 395*cdf0e10cSrcweir TYPELIB_DANGER_RELEASE( pTypeDescr ); 396*cdf0e10cSrcweir } 397*cdf0e10cSrcweir break; 398*cdf0e10cSrcweir case typelib_TypeClass_ARRAY: 399*cdf0e10cSrcweir if (pTypeDescr) 400*cdf0e10cSrcweir { 401*cdf0e10cSrcweir _destructArray( pValue, (typelib_ArrayTypeDescription *)pTypeDescr, release ); 402*cdf0e10cSrcweir } 403*cdf0e10cSrcweir else 404*cdf0e10cSrcweir { 405*cdf0e10cSrcweir TYPELIB_DANGER_GET( &pTypeDescr, pType ); 406*cdf0e10cSrcweir _destructArray( pValue, (typelib_ArrayTypeDescription *)pTypeDescr, release ); 407*cdf0e10cSrcweir TYPELIB_DANGER_RELEASE( pTypeDescr ); 408*cdf0e10cSrcweir } 409*cdf0e10cSrcweir break; 410*cdf0e10cSrcweir case typelib_TypeClass_UNION: 411*cdf0e10cSrcweir if (pTypeDescr) 412*cdf0e10cSrcweir { 413*cdf0e10cSrcweir _destructUnion( pValue, pTypeDescr, release ); 414*cdf0e10cSrcweir } 415*cdf0e10cSrcweir else 416*cdf0e10cSrcweir { 417*cdf0e10cSrcweir TYPELIB_DANGER_GET( &pTypeDescr, pType ); 418*cdf0e10cSrcweir _destructUnion( pValue, pTypeDescr, release ); 419*cdf0e10cSrcweir TYPELIB_DANGER_RELEASE( pTypeDescr ); 420*cdf0e10cSrcweir } 421*cdf0e10cSrcweir break; 422*cdf0e10cSrcweir case typelib_TypeClass_SEQUENCE: 423*cdf0e10cSrcweir { 424*cdf0e10cSrcweir idestructSequence( 425*cdf0e10cSrcweir *(uno_Sequence **)pValue, pType, pTypeDescr, release ); 426*cdf0e10cSrcweir break; 427*cdf0e10cSrcweir } 428*cdf0e10cSrcweir case typelib_TypeClass_INTERFACE: 429*cdf0e10cSrcweir _release( *(void **)pValue, release ); 430*cdf0e10cSrcweir break; 431*cdf0e10cSrcweir default: 432*cdf0e10cSrcweir break; 433*cdf0e10cSrcweir } 434*cdf0e10cSrcweir } 435*cdf0e10cSrcweir 436*cdf0e10cSrcweir } 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir #endif 439