Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / cppu / source / uno / copy.hxx
blob6a71d413faeedbe54c9101ee0a5fbc86e97ca60a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #pragma once
21 #include "prim.hxx"
22 #include "constr.hxx"
23 #include <cassert>
24 #include <cstddef>
25 #include <cstdlib>
26 #include <type_traits>
28 namespace cppu
32 //#### copy construction ###########################################################################
34 namespace {
36 // The non-dynamic prefix of sal_Sequence (aka uno_Sequence):
37 struct SequencePrefix {
38 sal_Int32 nRefCount;
39 sal_Int32 nElements;
41 static_assert(sizeof (SequencePrefix) < sizeof (uno_Sequence));
42 static_assert(offsetof(SequencePrefix, nRefCount) == offsetof(uno_Sequence, nRefCount));
43 static_assert(
44 std::is_same_v<decltype(SequencePrefix::nRefCount), decltype(uno_Sequence::nRefCount)>);
45 static_assert(offsetof(SequencePrefix, nElements) == offsetof(uno_Sequence, nElements));
46 static_assert(
47 std::is_same_v<decltype(SequencePrefix::nElements), decltype(uno_Sequence::nElements)>);
51 inline uno_Sequence * allocSeq(
52 sal_Int32 nElementSize, sal_Int32 nElements )
54 OSL_ASSERT( nElements >= 0 && nElementSize >= 0 );
55 uno_Sequence * pSeq = nullptr;
56 sal_uInt32 nSize = calcSeqMemSize( nElementSize, nElements );
57 if (nSize > 0)
59 pSeq = static_cast<uno_Sequence *>(std::malloc( nSize ));
60 if (pSeq != nullptr)
62 // header init, going via SequencePrefix to avoid UBSan insufficient-object-size
63 // warnings when `nElements == 0` and thus `nSize < sizeof (uno_Sequence)`:
64 auto const header = reinterpret_cast<SequencePrefix *>(pSeq);
65 header->nRefCount = 1;
66 header->nElements = nElements;
69 return pSeq;
73 void copyConstructStruct(
74 void * pDest, void * pSource,
75 typelib_CompoundTypeDescription * pTypeDescr,
76 uno_AcquireFunc acquire, uno_Mapping * mapping );
78 inline void _copyConstructStruct(
79 void * pDest, void * pSource,
80 typelib_CompoundTypeDescription * pTypeDescr,
81 uno_AcquireFunc acquire, uno_Mapping * mapping )
83 if (pTypeDescr->pBaseTypeDescription)
85 // copy base value
86 copyConstructStruct( pDest, pSource, pTypeDescr->pBaseTypeDescription, acquire, mapping );
89 // then copy members
90 typelib_TypeDescriptionReference ** ppTypeRefs = pTypeDescr->ppTypeRefs;
91 sal_Int32 * pMemberOffsets = pTypeDescr->pMemberOffsets;
92 sal_Int32 nDescr = pTypeDescr->nMembers;
94 if (mapping)
96 while (nDescr--)
98 ::uno_type_copyAndConvertData(
99 static_cast<char *>(pDest) + pMemberOffsets[nDescr],
100 static_cast<char *>(pSource) + pMemberOffsets[nDescr],
101 ppTypeRefs[nDescr], mapping );
104 else
106 while (nDescr--)
108 ::uno_type_copyData(
109 static_cast<char *>(pDest) + pMemberOffsets[nDescr],
110 static_cast<char *>(pSource) + pMemberOffsets[nDescr],
111 ppTypeRefs[nDescr], acquire );
117 uno_Sequence * copyConstructSequence(
118 uno_Sequence * pSource,
119 typelib_TypeDescriptionReference * pElementType,
120 uno_AcquireFunc acquire, uno_Mapping * mapping );
123 inline void _copyConstructAnyFromData(
124 uno_Any * pDestAny, void * pSource,
125 typelib_TypeDescriptionReference * pType, typelib_TypeDescription * pTypeDescr,
126 uno_AcquireFunc acquire, uno_Mapping * mapping )
128 TYPE_ACQUIRE( pType );
129 pDestAny->pType = pType;
131 switch (pType->eTypeClass)
133 case typelib_TypeClass_CHAR:
134 pDestAny->pData = &pDestAny->pReserved;
135 *static_cast<sal_Unicode *>(pDestAny->pData) = *static_cast<sal_Unicode *>(pSource);
136 break;
137 case typelib_TypeClass_BOOLEAN:
138 pDestAny->pData = &pDestAny->pReserved;
139 *static_cast<sal_Bool *>(pDestAny->pData) = bool(*static_cast<sal_Bool *>(pSource));
140 break;
141 case typelib_TypeClass_BYTE:
142 pDestAny->pData = &pDestAny->pReserved;
143 *static_cast<sal_Int8 *>(pDestAny->pData) = *static_cast<sal_Int8 *>(pSource);
144 break;
145 case typelib_TypeClass_SHORT:
146 case typelib_TypeClass_UNSIGNED_SHORT:
147 pDestAny->pData = &pDestAny->pReserved;
148 *static_cast<sal_Int16 *>(pDestAny->pData) = *static_cast<sal_Int16 *>(pSource);
149 break;
150 case typelib_TypeClass_LONG:
151 case typelib_TypeClass_UNSIGNED_LONG:
152 pDestAny->pData = &pDestAny->pReserved;
153 *static_cast<sal_Int32 *>(pDestAny->pData) = *static_cast<sal_Int32 *>(pSource);
154 break;
155 case typelib_TypeClass_HYPER:
156 case typelib_TypeClass_UNSIGNED_HYPER:
157 if (sizeof(void *) >= sizeof(sal_Int64))
158 pDestAny->pData = &pDestAny->pReserved;
159 else
160 pDestAny->pData = std::malloc( sizeof(sal_Int64) );
161 assert(pDestAny->pData);
162 *static_cast<sal_Int64 *>(pDestAny->pData) = *static_cast<sal_Int64 *>(pSource);
163 break;
164 case typelib_TypeClass_FLOAT:
165 if (sizeof(void *) >= sizeof(float))
166 pDestAny->pData = &pDestAny->pReserved;
167 else
168 pDestAny->pData = std::malloc( sizeof(float) );
169 assert(pDestAny->pData);
170 *static_cast<float *>(pDestAny->pData) = *static_cast<float *>(pSource);
171 break;
172 case typelib_TypeClass_DOUBLE:
173 if (sizeof(void *) >= sizeof(double))
174 pDestAny->pData = &pDestAny->pReserved;
175 else
176 pDestAny->pData = std::malloc( sizeof(double) );
177 assert(pDestAny->pData);
178 *static_cast<double *>(pDestAny->pData) = *static_cast<double *>(pSource);
179 break;
180 case typelib_TypeClass_STRING:
181 ::rtl_uString_acquire( *static_cast<rtl_uString **>(pSource) );
182 pDestAny->pData = &pDestAny->pReserved;
183 *static_cast<rtl_uString **>(pDestAny->pData) = *static_cast<rtl_uString **>(pSource);
184 break;
185 case typelib_TypeClass_TYPE:
186 TYPE_ACQUIRE( *static_cast<typelib_TypeDescriptionReference **>(pSource) );
187 pDestAny->pData = &pDestAny->pReserved;
188 *static_cast<typelib_TypeDescriptionReference **>(pDestAny->pData) = *static_cast<typelib_TypeDescriptionReference **>(pSource);
189 break;
190 case typelib_TypeClass_ANY:
191 OSL_FAIL( "### unexpected nested any!" );
192 break;
193 case typelib_TypeClass_ENUM:
194 pDestAny->pData = &pDestAny->pReserved;
195 // enum is forced to 32bit long
196 *static_cast<sal_Int32 *>(pDestAny->pData) = *static_cast<sal_Int32 *>(pSource);
197 break;
198 case typelib_TypeClass_STRUCT:
199 case typelib_TypeClass_EXCEPTION:
200 if (pTypeDescr)
202 pDestAny->pData = std::malloc( pTypeDescr->nSize );
203 _copyConstructStruct(
204 pDestAny->pData, pSource,
205 reinterpret_cast<typelib_CompoundTypeDescription *>(pTypeDescr),
206 acquire, mapping );
208 else
210 TYPELIB_DANGER_GET( &pTypeDescr, pType );
211 pDestAny->pData = std::malloc( pTypeDescr->nSize );
212 _copyConstructStruct(
213 pDestAny->pData, pSource,
214 reinterpret_cast<typelib_CompoundTypeDescription *>(pTypeDescr),
215 acquire, mapping );
216 TYPELIB_DANGER_RELEASE( pTypeDescr );
218 break;
219 case typelib_TypeClass_SEQUENCE:
220 pDestAny->pData = &pDestAny->pReserved;
221 if (pTypeDescr)
223 *static_cast<uno_Sequence **>(pDestAny->pData) = copyConstructSequence(
224 *static_cast<uno_Sequence **>(pSource),
225 reinterpret_cast<typelib_IndirectTypeDescription *>(pTypeDescr)->pType,
226 acquire, mapping );
228 else
230 TYPELIB_DANGER_GET( &pTypeDescr, pType );
231 *static_cast<uno_Sequence **>(pDestAny->pData) = copyConstructSequence(
232 *static_cast<uno_Sequence **>(pSource),
233 reinterpret_cast<typelib_IndirectTypeDescription *>(pTypeDescr)->pType,
234 acquire, mapping );
235 TYPELIB_DANGER_RELEASE( pTypeDescr );
237 break;
238 case typelib_TypeClass_INTERFACE:
239 pDestAny->pData = &pDestAny->pReserved;
240 if (mapping)
242 pDestAny->pReserved = _map( *static_cast<void **>(pSource), pType, pTypeDescr, mapping );
244 else
246 pDestAny->pReserved = *static_cast<void **>(pSource);
247 _acquire( pDestAny->pReserved, acquire );
249 break;
250 default:
251 OSL_ASSERT(false);
252 break;
256 inline void _copyConstructAny(
257 uno_Any * pDestAny, void * pSource,
258 typelib_TypeDescriptionReference * pType, typelib_TypeDescription * pTypeDescr,
259 uno_AcquireFunc acquire, uno_Mapping * mapping )
261 if (typelib_TypeClass_VOID == pType->eTypeClass)
263 CONSTRUCT_EMPTY_ANY( pDestAny );
265 else
267 if (typelib_TypeClass_ANY == pType->eTypeClass)
269 if (pSource)
271 pType = static_cast<uno_Any *>(pSource)->pType;
272 if (typelib_TypeClass_VOID == pType->eTypeClass)
274 CONSTRUCT_EMPTY_ANY( pDestAny );
275 return;
277 pTypeDescr = nullptr;
278 pSource = static_cast<uno_Any *>(pSource)->pData;
280 else
282 CONSTRUCT_EMPTY_ANY( pDestAny );
283 return;
286 if (pSource)
288 _copyConstructAnyFromData( pDestAny, pSource, pType, pTypeDescr, acquire, mapping );
290 else // default construct
292 TYPE_ACQUIRE( pType );
293 pDestAny->pType = pType;
294 switch (pType->eTypeClass)
296 case typelib_TypeClass_CHAR:
297 pDestAny->pData = &pDestAny->pReserved;
298 *static_cast<sal_Unicode *>(pDestAny->pData) = '\0';
299 break;
300 case typelib_TypeClass_BOOLEAN:
301 pDestAny->pData = &pDestAny->pReserved;
302 *static_cast<sal_Bool *>(pDestAny->pData) = false;
303 break;
304 case typelib_TypeClass_BYTE:
305 pDestAny->pData = &pDestAny->pReserved;
306 *static_cast<sal_Int8 *>(pDestAny->pData) = 0;
307 break;
308 case typelib_TypeClass_SHORT:
309 case typelib_TypeClass_UNSIGNED_SHORT:
310 pDestAny->pData = &pDestAny->pReserved;
311 *static_cast<sal_Int16 *>(pDestAny->pData) = 0;
312 break;
313 case typelib_TypeClass_LONG:
314 case typelib_TypeClass_UNSIGNED_LONG:
315 pDestAny->pData = &pDestAny->pReserved;
316 *static_cast<sal_Int32 *>(pDestAny->pData) = 0;
317 break;
318 case typelib_TypeClass_HYPER:
319 case typelib_TypeClass_UNSIGNED_HYPER:
320 if (sizeof(void *) >= sizeof(sal_Int64))
321 pDestAny->pData = &pDestAny->pReserved;
322 else
323 pDestAny->pData = std::malloc( sizeof(sal_Int64) );
324 assert(pDestAny->pData);
325 *static_cast<sal_Int64 *>(pDestAny->pData) = 0;
326 break;
327 case typelib_TypeClass_FLOAT:
328 if (sizeof(void *) >= sizeof(float))
329 pDestAny->pData = &pDestAny->pReserved;
330 else
331 pDestAny->pData = std::malloc( sizeof(float) );
332 assert(pDestAny->pData);
333 *static_cast<float *>(pDestAny->pData) = 0.0;
334 break;
335 case typelib_TypeClass_DOUBLE:
336 if (sizeof(void *) >= sizeof(double))
337 pDestAny->pData = &pDestAny->pReserved;
338 else
339 pDestAny->pData = std::malloc( sizeof(double) );
340 assert(pDestAny->pData);
341 *static_cast<double *>(pDestAny->pData) = 0.0;
342 break;
343 case typelib_TypeClass_STRING:
344 pDestAny->pData = &pDestAny->pReserved;
345 *static_cast<rtl_uString **>(pDestAny->pData) = nullptr;
346 ::rtl_uString_new( static_cast<rtl_uString **>(pDestAny->pData) );
347 break;
348 case typelib_TypeClass_TYPE:
349 pDestAny->pData = &pDestAny->pReserved;
350 *static_cast<typelib_TypeDescriptionReference **>(pDestAny->pData) = _getVoidType();
351 break;
352 case typelib_TypeClass_ENUM:
353 pDestAny->pData = &pDestAny->pReserved;
354 if (pTypeDescr)
356 *static_cast<sal_Int32 *>(pDestAny->pData) = reinterpret_cast<typelib_EnumTypeDescription *>(pTypeDescr)->nDefaultEnumValue;
358 else
360 TYPELIB_DANGER_GET( &pTypeDescr, pType );
361 *static_cast<sal_Int32 *>(pDestAny->pData) = reinterpret_cast<typelib_EnumTypeDescription *>(pTypeDescr)->nDefaultEnumValue;
362 TYPELIB_DANGER_RELEASE( pTypeDescr );
364 break;
365 case typelib_TypeClass_STRUCT:
366 case typelib_TypeClass_EXCEPTION:
367 if (pTypeDescr)
369 pDestAny->pData = std::malloc( pTypeDescr->nSize );
370 _defaultConstructStruct(
371 pDestAny->pData, reinterpret_cast<typelib_CompoundTypeDescription *>(pTypeDescr) );
373 else
375 TYPELIB_DANGER_GET( &pTypeDescr, pType );
376 pDestAny->pData = std::malloc( pTypeDescr->nSize );
377 _defaultConstructStruct(
378 pDestAny->pData, reinterpret_cast<typelib_CompoundTypeDescription *>(pTypeDescr) );
379 TYPELIB_DANGER_RELEASE( pTypeDescr );
381 break;
382 case typelib_TypeClass_SEQUENCE:
383 pDestAny->pData = &pDestAny->pReserved;
384 *static_cast<uno_Sequence **>(pDestAny->pData) = createEmptySequence();
385 break;
386 case typelib_TypeClass_INTERFACE:
387 pDestAny->pData = &pDestAny->pReserved;
388 pDestAny->pReserved = nullptr; // either cpp or c-uno interface
389 break;
390 default:
391 OSL_ASSERT(false);
392 break;
398 inline uno_Sequence * icopyConstructSequence(
399 uno_Sequence * pSource,
400 typelib_TypeDescriptionReference * pElementType,
401 uno_AcquireFunc acquire, uno_Mapping * mapping )
403 typelib_TypeClass eTypeClass = pElementType->eTypeClass;
404 if (!mapping ||
405 (eTypeClass <= typelib_TypeClass_ENUM &&
406 eTypeClass != typelib_TypeClass_ANY))
408 osl_atomic_increment( &pSource->nRefCount );
409 return pSource;
411 else // create new sequence
413 uno_Sequence * pDest;
414 sal_Int32 nElements = pSource->nElements;
415 if (nElements)
417 switch (eTypeClass)
419 case typelib_TypeClass_ANY:
421 pDest = allocSeq( sizeof (uno_Any), nElements );
422 if (pDest != nullptr)
424 uno_Any * pDestElements = reinterpret_cast<uno_Any *>(pDest->elements);
425 uno_Any * pSourceElements = reinterpret_cast<uno_Any *>(pSource->elements);
426 for ( sal_Int32 nPos = nElements; nPos--; )
428 typelib_TypeDescriptionReference * pType =
429 pSourceElements[nPos].pType;
430 if (typelib_TypeClass_VOID == pType->eTypeClass)
432 CONSTRUCT_EMPTY_ANY( &pDestElements[nPos] );
434 else
436 _copyConstructAnyFromData(
437 &pDestElements[nPos],
438 pSourceElements[nPos].pData,
439 pType, nullptr,
440 acquire, mapping );
444 break;
446 case typelib_TypeClass_STRUCT:
447 case typelib_TypeClass_EXCEPTION:
449 typelib_TypeDescription * pElementTypeDescr = nullptr;
450 TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
451 sal_Int32 nElementSize = pElementTypeDescr->nSize;
452 char * pSourceElements = pSource->elements;
453 pDest = allocSeq( nElementSize, nElements );
454 if (pDest != nullptr)
456 char * pElements = pDest->elements;
457 for ( sal_Int32 nPos = nElements; nPos--; )
459 _copyConstructStruct(
460 pElements + (nPos * nElementSize),
461 pSourceElements + (nPos * nElementSize),
462 reinterpret_cast<typelib_CompoundTypeDescription *>(
463 pElementTypeDescr),
464 acquire, mapping );
467 TYPELIB_DANGER_RELEASE( pElementTypeDescr );
468 break;
470 case typelib_TypeClass_SEQUENCE: // sequence of sequence
472 // coverity[suspicious_sizeof] - sizeof(uno_Sequence*) is correct here
473 pDest = allocSeq( sizeof (uno_Sequence *), nElements );
474 if (pDest != nullptr)
476 typelib_TypeDescription * pElementTypeDescr = nullptr;
477 TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
478 typelib_TypeDescriptionReference * pSeqElementType =
479 reinterpret_cast<typelib_IndirectTypeDescription *>(
480 pElementTypeDescr)->pType;
482 uno_Sequence ** pDestElements =
483 reinterpret_cast<uno_Sequence **>(pDest->elements);
484 uno_Sequence ** pSourceElements =
485 reinterpret_cast<uno_Sequence **>(pSource->elements);
486 for ( sal_Int32 nPos = nElements; nPos--; )
488 uno_Sequence * pNew = copyConstructSequence(
489 pSourceElements[nPos],
490 pSeqElementType,
491 acquire, mapping );
492 OSL_ASSERT( pNew != nullptr );
493 // ought never be a memory allocation problem,
494 // because of reference counted sequence handles
495 pDestElements[ nPos ] = pNew;
498 TYPELIB_DANGER_RELEASE( pElementTypeDescr );
500 break;
502 case typelib_TypeClass_INTERFACE:
504 pDest = allocSeq( sizeof (void *), nElements );
505 if (pDest != nullptr)
507 char * pElements = pDest->elements;
508 void ** pSourceElements = reinterpret_cast<void **>(pSource->elements);
509 typelib_TypeDescription * pElementTypeDescr = nullptr;
510 TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
511 for ( sal_Int32 nPos = nElements; nPos--; )
513 reinterpret_cast<void **>(pElements)[nPos] = nullptr;
514 if (pSourceElements[nPos])
516 (*mapping->mapInterface)(
517 mapping, reinterpret_cast<void **>(pElements) + nPos,
518 pSourceElements[nPos],
519 reinterpret_cast<typelib_InterfaceTypeDescription *>(
520 pElementTypeDescr) );
523 TYPELIB_DANGER_RELEASE( pElementTypeDescr );
525 break;
527 default:
528 OSL_FAIL( "### unexpected sequence element type!" );
529 pDest = nullptr;
530 break;
533 else // empty sequence
535 pDest = allocSeq( 0, 0 );
538 return pDest;
543 inline void _copyConstructData(
544 void * pDest, void * pSource,
545 typelib_TypeDescriptionReference * pType, typelib_TypeDescription * pTypeDescr,
546 uno_AcquireFunc acquire, uno_Mapping * mapping )
548 switch (pType->eTypeClass)
550 case typelib_TypeClass_CHAR:
551 *static_cast<sal_Unicode *>(pDest) = *static_cast<sal_Unicode *>(pSource);
552 break;
553 case typelib_TypeClass_BOOLEAN:
554 *static_cast<sal_Bool *>(pDest) = bool(*static_cast<sal_Bool *>(pSource));
555 break;
556 case typelib_TypeClass_BYTE:
557 *static_cast<sal_Int8 *>(pDest) = *static_cast<sal_Int8 *>(pSource);
558 break;
559 case typelib_TypeClass_SHORT:
560 case typelib_TypeClass_UNSIGNED_SHORT:
561 *static_cast<sal_Int16 *>(pDest) = *static_cast<sal_Int16 *>(pSource);
562 break;
563 case typelib_TypeClass_LONG:
564 case typelib_TypeClass_UNSIGNED_LONG:
565 *static_cast<sal_Int32 *>(pDest) = *static_cast<sal_Int32 *>(pSource);
566 break;
567 case typelib_TypeClass_HYPER:
568 case typelib_TypeClass_UNSIGNED_HYPER:
569 *static_cast<sal_Int64 *>(pDest) = *static_cast<sal_Int64 *>(pSource);
570 break;
571 case typelib_TypeClass_FLOAT:
572 *static_cast<float *>(pDest) = *static_cast<float *>(pSource);
573 break;
574 case typelib_TypeClass_DOUBLE:
575 *static_cast<double *>(pDest) = *static_cast<double *>(pSource);
576 break;
577 case typelib_TypeClass_STRING:
578 ::rtl_uString_acquire( *static_cast<rtl_uString **>(pSource) );
579 *static_cast<rtl_uString **>(pDest) = *static_cast<rtl_uString **>(pSource);
580 break;
581 case typelib_TypeClass_TYPE:
582 TYPE_ACQUIRE( *static_cast<typelib_TypeDescriptionReference **>(pSource) );
583 *static_cast<typelib_TypeDescriptionReference **>(pDest) = *static_cast<typelib_TypeDescriptionReference **>(pSource);
584 break;
585 case typelib_TypeClass_ANY:
586 _copyConstructAny(
587 static_cast<uno_Any *>(pDest), static_cast<uno_Any *>(pSource)->pData,
588 static_cast<uno_Any *>(pSource)->pType, nullptr,
589 acquire, mapping );
590 break;
591 case typelib_TypeClass_ENUM:
592 *static_cast<sal_Int32 *>(pDest) = *static_cast<sal_Int32 *>(pSource);
593 break;
594 case typelib_TypeClass_STRUCT:
595 case typelib_TypeClass_EXCEPTION:
596 if (pTypeDescr)
598 _copyConstructStruct(
599 pDest, pSource,
600 reinterpret_cast<typelib_CompoundTypeDescription *>(pTypeDescr),
601 acquire, mapping );
603 else
605 TYPELIB_DANGER_GET( &pTypeDescr, pType );
606 _copyConstructStruct(
607 pDest, pSource,
608 reinterpret_cast<typelib_CompoundTypeDescription *>(pTypeDescr),
609 acquire, mapping );
610 TYPELIB_DANGER_RELEASE( pTypeDescr );
612 break;
613 case typelib_TypeClass_SEQUENCE:
614 if (mapping)
616 if (pTypeDescr)
618 *static_cast<uno_Sequence **>(pDest) = icopyConstructSequence(
619 *static_cast<uno_Sequence **>(pSource),
620 reinterpret_cast<typelib_IndirectTypeDescription *>(pTypeDescr)->pType,
621 acquire, mapping );
623 else
625 TYPELIB_DANGER_GET( &pTypeDescr, pType );
626 *static_cast<uno_Sequence **>(pDest) = icopyConstructSequence(
627 *static_cast<uno_Sequence **>(pSource),
628 reinterpret_cast<typelib_IndirectTypeDescription *>(pTypeDescr)->pType,
629 acquire, mapping );
630 TYPELIB_DANGER_RELEASE( pTypeDescr );
633 else
635 osl_atomic_increment( &(*static_cast<uno_Sequence **>(pSource))->nRefCount );
636 *static_cast<uno_Sequence **>(pDest) = *static_cast<uno_Sequence **>(pSource);
638 break;
639 case typelib_TypeClass_INTERFACE:
640 if (mapping)
641 *static_cast<void **>(pDest) = _map( *static_cast<void **>(pSource), pType, pTypeDescr, mapping );
642 else
644 *static_cast<void **>(pDest) = *static_cast<void **>(pSource);
645 _acquire( *static_cast<void **>(pDest), acquire );
647 break;
648 default:
649 break;
655 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */