22#include <osl/diagnose.h>
38 typelib_CompoundTypeDescription * pTypeDescr,
39 uno_ReleaseFunc release );
43 typelib_CompoundTypeDescription * pTypeDescr,
44 uno_ReleaseFunc release )
46 if (pTypeDescr->pBaseTypeDescription)
48 destructStruct( pValue, pTypeDescr->pBaseTypeDescription, release );
51 typelib_TypeDescriptionReference ** ppTypeRefs = pTypeDescr->ppTypeRefs;
52 sal_Int32 * pMemberOffsets = pTypeDescr->pMemberOffsets;
53 sal_Int32 nDescr = pTypeDescr->nMembers;
57 static_cast<char *
>(pValue) + pMemberOffsets[nDescr],
58 ppTypeRefs[nDescr], release );
64 uno_Sequence * pSequence,
65 typelib_TypeDescriptionReference * pType,
67 uno_ReleaseFunc release );
72 uno_ReleaseFunc release )
74 typelib_TypeDescriptionReference * pType = pAny->pType;
76 switch (pType->eTypeClass)
78 case typelib_TypeClass_HYPER:
79 case typelib_TypeClass_UNSIGNED_HYPER:
80 if (
sizeof(
void *) <
sizeof(sal_Int64))
82 std::free( pAny->pData );
85 case typelib_TypeClass_FLOAT:
86 if (
sizeof(
void *) <
sizeof(
float))
88 std::free( pAny->pData );
91 case typelib_TypeClass_DOUBLE:
92 if (
sizeof(
void *) <
sizeof(
double))
94 std::free( pAny->pData );
97 case typelib_TypeClass_STRING:
98 ::rtl_uString_release(
static_cast<rtl_uString *
>(pAny->pReserved) );
100 case typelib_TypeClass_TYPE:
102 static_cast<typelib_TypeDescriptionReference *
>(pAny->pReserved) );
104 case typelib_TypeClass_ANY:
105 OSL_FAIL(
"### unexpected nested any!" );
107 std::free( pAny->pData );
109 case typelib_TypeClass_TYPEDEF:
110 OSL_FAIL(
"### unexpected typedef!" );
112 case typelib_TypeClass_STRUCT:
113 case typelib_TypeClass_EXCEPTION:
116 TYPELIB_DANGER_GET( &pTypeDescr, pType );
117 _destructStruct( pAny->pData,
reinterpret_cast<typelib_CompoundTypeDescription *
>(pTypeDescr), release );
118 TYPELIB_DANGER_RELEASE( pTypeDescr );
119 std::free( pAny->pData );
122 case typelib_TypeClass_SEQUENCE:
125 static_cast<uno_Sequence *
>(pAny->pReserved), pType,
nullptr, release );
128 case typelib_TypeClass_INTERFACE:
129 _release( pAny->pReserved, release );
134#if OSL_DEBUG_LEVEL > 0
135 pAny->pData =
reinterpret_cast<void *
>(uintptr_t(0xdeadbeef));
142 void * pElements, typelib_TypeDescriptionReference * pElementType,
143 sal_Int32 nStartIndex, sal_Int32 nStopIndex,
144 uno_ReleaseFunc release )
146 switch (pElementType->eTypeClass)
148 case typelib_TypeClass_CHAR:
150 case typelib_TypeClass_BOOLEAN:
152 case typelib_TypeClass_BYTE:
154 case typelib_TypeClass_SHORT:
155 case typelib_TypeClass_UNSIGNED_SHORT:
156 return sal_Int32(
sizeof(sal_Int16));
157 case typelib_TypeClass_LONG:
158 case typelib_TypeClass_UNSIGNED_LONG:
159 return sal_Int32(
sizeof(sal_Int32));
160 case typelib_TypeClass_HYPER:
161 case typelib_TypeClass_UNSIGNED_HYPER:
162 return sal_Int32(
sizeof(sal_Int64));
163 case typelib_TypeClass_FLOAT:
164 return sal_Int32(
sizeof(
float));
165 case typelib_TypeClass_DOUBLE:
166 return sal_Int32(
sizeof(
double));
168 case typelib_TypeClass_STRING:
170 rtl_uString ** pDest =
static_cast<rtl_uString **
>(pElements);
171 for ( sal_Int32
nPos = nStartIndex;
nPos < nStopIndex; ++
nPos )
173 ::rtl_uString_release( pDest[
nPos] );
175 return sal_Int32(
sizeof(rtl_uString *));
177 case typelib_TypeClass_TYPE:
179 typelib_TypeDescriptionReference ** pDest =
static_cast<typelib_TypeDescriptionReference **
>(pElements);
180 for ( sal_Int32
nPos = nStartIndex;
nPos < nStopIndex; ++
nPos )
184 return sal_Int32(
sizeof(typelib_TypeDescriptionReference *));
186 case typelib_TypeClass_ANY:
189 for ( sal_Int32
nPos = nStartIndex;
nPos < nStopIndex; ++
nPos )
193 return sal_Int32(
sizeof(
uno_Any));
195 case typelib_TypeClass_ENUM:
196 return sal_Int32(
sizeof(sal_Int32));
197 case typelib_TypeClass_STRUCT:
198 case typelib_TypeClass_EXCEPTION:
201 TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
202 sal_Int32 nElementSize = pElementTypeDescr->nSize;
203 for ( sal_Int32
nPos = nStartIndex;
nPos < nStopIndex; ++
nPos )
206 static_cast<char *
>(pElements) + (nElementSize *
nPos),
207 reinterpret_cast<typelib_CompoundTypeDescription *
>(pElementTypeDescr),
210 sal_Int32 nSize = pElementTypeDescr->nSize;
211 TYPELIB_DANGER_RELEASE( pElementTypeDescr );
214 case typelib_TypeClass_SEQUENCE:
217 TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
218 uno_Sequence ** pDest =
static_cast<uno_Sequence **
>(pElements);
219 for ( sal_Int32
nPos = nStartIndex;
nPos < nStopIndex; ++
nPos )
223 pElementTypeDescr->pWeakRef, pElementTypeDescr,
226 TYPELIB_DANGER_RELEASE( pElementTypeDescr );
227 return sal_Int32(
sizeof(uno_Sequence *));
229 case typelib_TypeClass_INTERFACE:
233 for ( sal_Int32
nPos = nStartIndex;
nPos < nStopIndex; ++
nPos )
235 void *
p =
static_cast<void **
>(pElements)[
nPos];
244 for ( sal_Int32
nPos = nStartIndex;
nPos < nStopIndex; ++
nPos )
246 uno_Interface *
p =
static_cast<uno_Interface **
>(pElements)[
nPos];
253 return sal_Int32(
sizeof(
void *));
263 typelib_TypeDescriptionReference * pType,
265 uno_ReleaseFunc release )
267 assert(pSeq !=
nullptr);
268 assert(pSeq->nRefCount == 0);
269 if (pSeq->nElements > 0)
275 reinterpret_cast<typelib_IndirectTypeDescription *
>(pTypeDescr)->pType, 0,
276 pSeq->nElements, release );
280 TYPELIB_DANGER_GET( &pTypeDescr, pType );
283 reinterpret_cast<typelib_IndirectTypeDescription *
>(pTypeDescr)->pType, 0,
284 pSeq->nElements, release );
285 TYPELIB_DANGER_RELEASE( pTypeDescr );
293 typelib_TypeDescriptionReference * pType,
295 uno_ReleaseFunc release )
297 if (osl_atomic_decrement( &pSeq->nRefCount ) == 0)
305 typelib_TypeDescriptionReference * pType,
307 uno_ReleaseFunc release )
309 switch (pType->eTypeClass)
311 case typelib_TypeClass_STRING:
312 ::rtl_uString_release( *
static_cast<rtl_uString **
>(pValue) );
314 case typelib_TypeClass_TYPE:
317 case typelib_TypeClass_ANY:
320 case typelib_TypeClass_TYPEDEF:
321 OSL_FAIL(
"### unexpected typedef!" );
323 case typelib_TypeClass_STRUCT:
324 case typelib_TypeClass_EXCEPTION:
327 _destructStruct( pValue,
reinterpret_cast<typelib_CompoundTypeDescription *
>(pTypeDescr), release );
331 TYPELIB_DANGER_GET( &pTypeDescr, pType );
332 _destructStruct( pValue,
reinterpret_cast<typelib_CompoundTypeDescription *
>(pTypeDescr), release );
333 TYPELIB_DANGER_RELEASE( pTypeDescr );
336 case typelib_TypeClass_SEQUENCE:
339 *
static_cast<uno_Sequence **
>(pValue), pType, pTypeDescr, release );
342 case typelib_TypeClass_INTERFACE:
343 _release( *
static_cast<void **
>(pValue), release );
void SAL_CALL uno_any_destruct(uno_Any *pValue, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
void SAL_CALL uno_type_destructData(void *pValue, typelib_TypeDescriptionReference *pType, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
struct _typelib_TypeDescription typelib_TypeDescription
void _release(void *p, uno_ReleaseFunc release)
void _destructData(void *pValue, typelib_TypeDescriptionReference *pType, typelib_TypeDescription *pTypeDescr, uno_ReleaseFunc release)
void _destructStruct(void *pValue, typelib_CompoundTypeDescription *pTypeDescr, uno_ReleaseFunc release)
void destructSequence(uno_Sequence *pSequence, typelib_TypeDescriptionReference *pType, typelib_TypeDescription *pTypeDescr, uno_ReleaseFunc release)
sal_Int32 idestructElements(void *pElements, typelib_TypeDescriptionReference *pElementType, sal_Int32 nStartIndex, sal_Int32 nStopIndex, uno_ReleaseFunc release)
void idestructSequence(uno_Sequence *pSeq, typelib_TypeDescriptionReference *pType, typelib_TypeDescription *pTypeDescr, uno_ReleaseFunc release)
void idestroySequence(uno_Sequence *pSeq, typelib_TypeDescriptionReference *pType, typelib_TypeDescription *pTypeDescr, uno_ReleaseFunc release)
void destructStruct(void *pValue, typelib_CompoundTypeDescription *pTypeDescr, uno_ReleaseFunc release)
void _destructAny(uno_Any *pAny, uno_ReleaseFunc release)
void SAL_CALL typelib_typedescriptionreference_release(typelib_TypeDescriptionReference *pRef) SAL_THROW_EXTERN_C()