1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
37 //##################################################################################################
38 //#### copy construction ###########################################################################
39 //##################################################################################################
41 //------------------------------------------------------------------------------
42 inline uno_Sequence
* allocSeq(
43 sal_Int32 nElementSize
, sal_Int32 nElements
)
45 OSL_ASSERT( nElements
>= 0 && nElementSize
>= 0 );
46 uno_Sequence
* pSeq
= 0;
47 sal_uInt32 nSize
= calcSeqMemSize( nElementSize
, nElements
);
50 pSeq
= (uno_Sequence
*) rtl_allocateMemory( nSize
);
55 pSeq
->nElements
= nElements
;
61 //--------------------------------------------------------------------------------------------------
62 void copyConstructStruct(
63 void * pDest
, void * pSource
,
64 typelib_CompoundTypeDescription
* pTypeDescr
,
65 uno_AcquireFunc acquire
, uno_Mapping
* mapping
)
67 //--------------------------------------------------------------------------------------------------
68 inline void _copyConstructStruct(
69 void * pDest
, void * pSource
,
70 typelib_CompoundTypeDescription
* pTypeDescr
,
71 uno_AcquireFunc acquire
, uno_Mapping
* mapping
)
74 if (pTypeDescr
->pBaseTypeDescription
)
77 copyConstructStruct( pDest
, pSource
, pTypeDescr
->pBaseTypeDescription
, acquire
, mapping
);
81 typelib_TypeDescriptionReference
** ppTypeRefs
= pTypeDescr
->ppTypeRefs
;
82 sal_Int32
* pMemberOffsets
= pTypeDescr
->pMemberOffsets
;
83 sal_Int32 nDescr
= pTypeDescr
->nMembers
;
89 ::uno_type_copyAndConvertData(
90 (char *)pDest
+ pMemberOffsets
[nDescr
],
91 (char *)pSource
+ pMemberOffsets
[nDescr
],
92 ppTypeRefs
[nDescr
], mapping
);
100 (char *)pDest
+ pMemberOffsets
[nDescr
],
101 (char *)pSource
+ pMemberOffsets
[nDescr
],
102 ppTypeRefs
[nDescr
], acquire
);
106 //--------------------------------------------------------------------------------------------------
107 inline void _copyConstructArray(
108 void * pDest
, void * pSource
,
109 typelib_ArrayTypeDescription
* pTypeDescr
,
110 uno_AcquireFunc acquire
, uno_Mapping
* mapping
)
112 typelib_TypeDescriptionReference
* pElementTypeRef
= ((typelib_IndirectTypeDescription
*)pTypeDescr
)->pType
;
113 typelib_TypeDescription
* pElementTypeDescr
= NULL
;
114 TYPELIB_DANGER_GET( &pElementTypeDescr
, pElementTypeRef
);
115 sal_Int32 nElementSize
= ((typelib_TypeDescription
*)pElementTypeDescr
)->nSize
;
116 TYPELIB_DANGER_RELEASE( pElementTypeDescr
);
117 sal_Int32 nTotalElements
= pTypeDescr
->nTotalElements
;
121 for(sal_Int32 i
= 0; i
< nTotalElements
; i
++)
123 ::uno_type_copyAndConvertData(
124 (sal_Char
*)pDest
+ i
* nElementSize
,
125 (sal_Char
*)pSource
+ i
* nElementSize
,
126 pElementTypeRef
, mapping
);
131 for(sal_Int32 i
= 0; i
< nTotalElements
; i
++)
134 (sal_Char
*)pDest
+ (i
* nElementSize
),
135 (sal_Char
*)pSource
+ (i
* nElementSize
),
136 pElementTypeRef
, acquire
);
140 //--------------------------------------------------------------------------------------------------
141 inline void _copyConstructUnion(
142 void * pDest
, void * pSource
,
143 typelib_TypeDescription
* pTypeDescr
,
144 uno_AcquireFunc acquire
, uno_Mapping
* mapping
)
147 typelib_TypeDescriptionReference
* pSetType
= _unionGetSetType( pSource
, pTypeDescr
);
150 ::uno_type_copyAndConvertData(
151 (char *)pDest
+ ((typelib_UnionTypeDescription
*)pTypeDescr
)->nValueOffset
,
152 (char *)pSource
+ ((typelib_UnionTypeDescription
*)pTypeDescr
)->nValueOffset
,
158 (char *)pDest
+ ((typelib_UnionTypeDescription
*)pTypeDescr
)->nValueOffset
,
159 (char *)pSource
+ ((typelib_UnionTypeDescription
*)pTypeDescr
)->nValueOffset
,
162 *(sal_Int64
*)pDest
= *(sal_Int64
*)pSource
;
163 typelib_typedescriptionreference_release( pSetType
);
166 //------------------------------------------------------------------------------
167 uno_Sequence
* copyConstructSequence(
168 uno_Sequence
* pSource
,
169 typelib_TypeDescriptionReference
* pElementType
,
170 uno_AcquireFunc acquire
, uno_Mapping
* mapping
);
172 //--------------------------------------------------------------------------------------------------
173 inline void _copyConstructAnyFromData(
174 uno_Any
* pDestAny
, void * pSource
,
175 typelib_TypeDescriptionReference
* pType
, typelib_TypeDescription
* pTypeDescr
,
176 uno_AcquireFunc acquire
, uno_Mapping
* mapping
)
179 TYPE_ACQUIRE( pType
);
180 pDestAny
->pType
= pType
;
182 switch (pType
->eTypeClass
)
184 case typelib_TypeClass_CHAR
:
185 pDestAny
->pData
= &pDestAny
->pReserved
;
186 *(sal_Unicode
*)&pDestAny
->pReserved
= *(sal_Unicode
*)pSource
;
188 case typelib_TypeClass_BOOLEAN
:
189 pDestAny
->pData
= &pDestAny
->pReserved
;
190 *(sal_Bool
*)&pDestAny
->pReserved
= (*(sal_Bool
*)pSource
!= sal_False
);
192 case typelib_TypeClass_BYTE
:
193 pDestAny
->pData
= &pDestAny
->pReserved
;
194 *(sal_Int8
*)&pDestAny
->pReserved
= *(sal_Int8
*)pSource
;
196 case typelib_TypeClass_SHORT
:
197 case typelib_TypeClass_UNSIGNED_SHORT
:
198 pDestAny
->pData
= &pDestAny
->pReserved
;
199 *(sal_Int16
*)&pDestAny
->pReserved
= *(sal_Int16
*)pSource
;
201 case typelib_TypeClass_LONG
:
202 case typelib_TypeClass_UNSIGNED_LONG
:
203 pDestAny
->pData
= &pDestAny
->pReserved
;
204 *(sal_Int32
*)&pDestAny
->pReserved
= *(sal_Int32
*)pSource
;
206 case typelib_TypeClass_HYPER
:
207 case typelib_TypeClass_UNSIGNED_HYPER
:
208 if (sizeof(void *) >= sizeof(sal_Int64
))
210 pDestAny
->pData
= &pDestAny
->pReserved
;
211 *(sal_Int64
*)&pDestAny
->pReserved
= *(sal_Int64
*)pSource
;
215 pDestAny
->pData
= ::rtl_allocateMemory( sizeof(sal_Int64
) );
216 *(sal_Int64
*)pDestAny
->pData
= *(sal_Int64
*)pSource
;
219 case typelib_TypeClass_FLOAT
:
220 if (sizeof(void *) >= sizeof(float))
222 pDestAny
->pData
= &pDestAny
->pReserved
;
223 *(float *)&pDestAny
->pReserved
= *(float *)pSource
;
227 pDestAny
->pData
= ::rtl_allocateMemory( sizeof(float) );
228 *(float *)pDestAny
->pData
= *(float *)pSource
;
231 case typelib_TypeClass_DOUBLE
:
232 if (sizeof(void *) >= sizeof(double))
234 pDestAny
->pData
= &pDestAny
->pReserved
;
235 *(double *)&pDestAny
->pReserved
= *(double *)pSource
;
239 pDestAny
->pData
= ::rtl_allocateMemory( sizeof(double) );
240 *(double *)pDestAny
->pData
= *(double *)pSource
;
243 case typelib_TypeClass_STRING
:
244 ::rtl_uString_acquire( *(rtl_uString
**)pSource
);
245 pDestAny
->pData
= &pDestAny
->pReserved
;
246 *(rtl_uString
**)&pDestAny
->pReserved
= *(rtl_uString
**)pSource
;
248 case typelib_TypeClass_TYPE
:
249 TYPE_ACQUIRE( *(typelib_TypeDescriptionReference
**)pSource
);
250 pDestAny
->pData
= &pDestAny
->pReserved
;
251 *(typelib_TypeDescriptionReference
**)&pDestAny
->pReserved
= *(typelib_TypeDescriptionReference
**)pSource
;
253 case typelib_TypeClass_ANY
:
254 OSL_ENSURE( 0, "### unexpected nested any!" );
256 case typelib_TypeClass_ENUM
:
257 pDestAny
->pData
= &pDestAny
->pReserved
;
258 // enum is forced to 32bit long
259 *(sal_Int32
*)&pDestAny
->pReserved
= *(sal_Int32
*)pSource
;
261 case typelib_TypeClass_STRUCT
:
262 case typelib_TypeClass_EXCEPTION
:
265 pDestAny
->pData
= ::rtl_allocateMemory( pTypeDescr
->nSize
);
266 _copyConstructStruct(
267 pDestAny
->pData
, pSource
,
268 (typelib_CompoundTypeDescription
*)pTypeDescr
,
273 TYPELIB_DANGER_GET( &pTypeDescr
, pType
);
274 pDestAny
->pData
= ::rtl_allocateMemory( pTypeDescr
->nSize
);
275 _copyConstructStruct(
276 pDestAny
->pData
, pSource
,
277 (typelib_CompoundTypeDescription
*)pTypeDescr
,
279 TYPELIB_DANGER_RELEASE( pTypeDescr
);
282 case typelib_TypeClass_ARRAY
:
285 pDestAny
->pData
= ::rtl_allocateMemory( pTypeDescr
->nSize
);
287 pDestAny
->pData
, pSource
,
288 (typelib_ArrayTypeDescription
*)pTypeDescr
,
293 TYPELIB_DANGER_GET( &pTypeDescr
, pType
);
294 pDestAny
->pData
= ::rtl_allocateMemory( pTypeDescr
->nSize
);
296 pDestAny
->pData
, pSource
,
297 (typelib_ArrayTypeDescription
*)pTypeDescr
,
299 TYPELIB_DANGER_RELEASE( pTypeDescr
);
302 case typelib_TypeClass_UNION
:
305 pDestAny
->pData
= ::rtl_allocateMemory( pTypeDescr
->nSize
);
306 _copyConstructUnion( pDestAny
->pData
, pSource
, pTypeDescr
, acquire
, mapping
);
310 TYPELIB_DANGER_GET( &pTypeDescr
, pType
);
311 pDestAny
->pData
= ::rtl_allocateMemory( pTypeDescr
->nSize
);
312 _copyConstructUnion( pDestAny
->pData
, pSource
, pTypeDescr
, acquire
, mapping
);
313 TYPELIB_DANGER_RELEASE( pTypeDescr
);
316 case typelib_TypeClass_SEQUENCE
:
317 pDestAny
->pData
= &pDestAny
->pReserved
;
320 *(uno_Sequence
**)&pDestAny
->pReserved
= copyConstructSequence(
321 *(uno_Sequence
**)pSource
,
322 ((typelib_IndirectTypeDescription
*)pTypeDescr
)->pType
,
327 TYPELIB_DANGER_GET( &pTypeDescr
, pType
);
328 *(uno_Sequence
**)&pDestAny
->pReserved
= copyConstructSequence(
329 *(uno_Sequence
**)pSource
,
330 ((typelib_IndirectTypeDescription
*)pTypeDescr
)->pType
,
332 TYPELIB_DANGER_RELEASE( pTypeDescr
);
335 case typelib_TypeClass_INTERFACE
:
336 pDestAny
->pData
= &pDestAny
->pReserved
;
339 pDestAny
->pReserved
= _map( *(void **)pSource
, pType
, pTypeDescr
, mapping
);
343 _acquire( pDestAny
->pReserved
= *(void **)pSource
, acquire
);
351 //--------------------------------------------------------------------------------------------------
352 inline void _copyConstructAny(
353 uno_Any
* pDestAny
, void * pSource
,
354 typelib_TypeDescriptionReference
* pType
, typelib_TypeDescription
* pTypeDescr
,
355 uno_AcquireFunc acquire
, uno_Mapping
* mapping
)
358 if (typelib_TypeClass_VOID
== pType
->eTypeClass
)
360 CONSTRUCT_EMPTY_ANY( pDestAny
);
364 if (typelib_TypeClass_ANY
== pType
->eTypeClass
)
368 pType
= ((uno_Any
*)pSource
)->pType
;
369 if (typelib_TypeClass_VOID
== pType
->eTypeClass
)
371 CONSTRUCT_EMPTY_ANY( pDestAny
);
375 pSource
= ((uno_Any
*)pSource
)->pData
;
379 CONSTRUCT_EMPTY_ANY( pDestAny
);
385 _copyConstructAnyFromData( pDestAny
, pSource
, pType
, pTypeDescr
, acquire
, mapping
);
387 else // default construct
389 TYPE_ACQUIRE( pType
);
390 pDestAny
->pType
= pType
;
391 switch (pType
->eTypeClass
)
393 case typelib_TypeClass_CHAR
:
394 pDestAny
->pData
= &pDestAny
->pReserved
;
395 *(sal_Unicode
*)&pDestAny
->pReserved
= '\0';
397 case typelib_TypeClass_BOOLEAN
:
398 pDestAny
->pData
= &pDestAny
->pReserved
;
399 *(sal_Bool
*)&pDestAny
->pReserved
= sal_False
;
401 case typelib_TypeClass_BYTE
:
402 pDestAny
->pData
= &pDestAny
->pReserved
;
403 *(sal_Int8
*)&pDestAny
->pReserved
= 0;
405 case typelib_TypeClass_SHORT
:
406 case typelib_TypeClass_UNSIGNED_SHORT
:
407 pDestAny
->pData
= &pDestAny
->pReserved
;
408 *(sal_Int16
*)&pDestAny
->pReserved
= 0;
410 case typelib_TypeClass_LONG
:
411 case typelib_TypeClass_UNSIGNED_LONG
:
412 pDestAny
->pData
= &pDestAny
->pReserved
;
413 *(sal_Int32
*)&pDestAny
->pReserved
= 0;
415 case typelib_TypeClass_HYPER
:
416 case typelib_TypeClass_UNSIGNED_HYPER
:
417 if (sizeof(void *) >= sizeof(sal_Int64
))
419 pDestAny
->pData
= &pDestAny
->pReserved
;
420 *(sal_Int64
*)&pDestAny
->pReserved
= 0;
424 pDestAny
->pData
= ::rtl_allocateMemory( sizeof(sal_Int64
) );
425 *(sal_Int64
*)pDestAny
->pData
= 0;
428 case typelib_TypeClass_FLOAT
:
429 if (sizeof(void *) >= sizeof(float))
431 pDestAny
->pData
= &pDestAny
->pReserved
;
432 *(float *)&pDestAny
->pReserved
= 0.0;
436 pDestAny
->pData
= ::rtl_allocateMemory( sizeof(float) );
437 *(float *)pDestAny
->pData
= 0.0;
440 case typelib_TypeClass_DOUBLE
:
441 if (sizeof(void *) >= sizeof(double))
443 pDestAny
->pData
= &pDestAny
->pReserved
;
444 *(double *)&pDestAny
->pReserved
= 0.0;
448 pDestAny
->pData
= ::rtl_allocateMemory( sizeof(double) );
449 *(double *)pDestAny
->pData
= 0.0;
452 case typelib_TypeClass_STRING
:
453 pDestAny
->pData
= &pDestAny
->pReserved
;
454 *(rtl_uString
**)&pDestAny
->pReserved
= 0;
455 ::rtl_uString_new( (rtl_uString
**)&pDestAny
->pReserved
);
457 case typelib_TypeClass_TYPE
:
458 pDestAny
->pData
= &pDestAny
->pReserved
;
459 *(typelib_TypeDescriptionReference
**)&pDestAny
->pReserved
= _getVoidType();
461 case typelib_TypeClass_ENUM
:
462 pDestAny
->pData
= &pDestAny
->pReserved
;
465 *(sal_Int32
*)&pDestAny
->pReserved
= ((typelib_EnumTypeDescription
*)pTypeDescr
)->nDefaultEnumValue
;
469 TYPELIB_DANGER_GET( &pTypeDescr
, pType
);
470 *(sal_Int32
*)&pDestAny
->pReserved
= ((typelib_EnumTypeDescription
*)pTypeDescr
)->nDefaultEnumValue
;
471 TYPELIB_DANGER_RELEASE( pTypeDescr
);
474 case typelib_TypeClass_STRUCT
:
475 case typelib_TypeClass_EXCEPTION
:
478 pDestAny
->pData
= ::rtl_allocateMemory( pTypeDescr
->nSize
);
479 _defaultConstructStruct(
480 pDestAny
->pData
, (typelib_CompoundTypeDescription
*)pTypeDescr
);
484 TYPELIB_DANGER_GET( &pTypeDescr
, pType
);
485 pDestAny
->pData
= ::rtl_allocateMemory( pTypeDescr
->nSize
);
486 _defaultConstructStruct(
487 pDestAny
->pData
, (typelib_CompoundTypeDescription
*)pTypeDescr
);
488 TYPELIB_DANGER_RELEASE( pTypeDescr
);
491 case typelib_TypeClass_ARRAY
:
494 pDestAny
->pData
= ::rtl_allocateMemory( pTypeDescr
->nSize
);
495 _defaultConstructArray(
496 pDestAny
->pData
, (typelib_ArrayTypeDescription
*)pTypeDescr
);
500 TYPELIB_DANGER_GET( &pTypeDescr
, pType
);
501 pDestAny
->pData
= ::rtl_allocateMemory( pTypeDescr
->nSize
);
502 _defaultConstructArray(
503 pDestAny
->pData
, (typelib_ArrayTypeDescription
*)pTypeDescr
);
504 TYPELIB_DANGER_RELEASE( pTypeDescr
);
507 case typelib_TypeClass_UNION
:
510 pDestAny
->pData
= ::rtl_allocateMemory( pTypeDescr
->nSize
);
511 _defaultConstructUnion( pDestAny
->pData
, pTypeDescr
);
515 TYPELIB_DANGER_GET( &pTypeDescr
, pType
);
516 pDestAny
->pData
= ::rtl_allocateMemory( pTypeDescr
->nSize
);
517 _defaultConstructUnion( pDestAny
->pData
, pTypeDescr
);
518 TYPELIB_DANGER_RELEASE( pTypeDescr
);
521 case typelib_TypeClass_SEQUENCE
:
522 pDestAny
->pData
= &pDestAny
->pReserved
;
523 *(uno_Sequence
**)&pDestAny
->pReserved
= createEmptySequence();
525 case typelib_TypeClass_INTERFACE
:
526 pDestAny
->pData
= &pDestAny
->pReserved
;
527 pDestAny
->pReserved
= 0; // either cpp or c-uno interface
536 //------------------------------------------------------------------------------
537 inline uno_Sequence
* icopyConstructSequence(
538 uno_Sequence
* pSource
,
539 typelib_TypeDescriptionReference
* pElementType
,
540 uno_AcquireFunc acquire
, uno_Mapping
* mapping
)
542 typelib_TypeClass eTypeClass
= pElementType
->eTypeClass
;
544 (eTypeClass
<= typelib_TypeClass_ENUM
&&
545 eTypeClass
!= typelib_TypeClass_ANY
))
547 ::osl_incrementInterlockedCount( &pSource
->nRefCount
);
550 else // create new sequence
552 uno_Sequence
* pDest
;
553 sal_Int32 nElements
= pSource
->nElements
;
558 case typelib_TypeClass_ANY
:
560 pDest
= allocSeq( sizeof (uno_Any
), nElements
);
563 uno_Any
* pDestElements
= (uno_Any
*)pDest
->elements
;
564 uno_Any
* pSourceElements
= (uno_Any
*)pSource
->elements
;
565 for ( sal_Int32 nPos
= nElements
; nPos
--; )
567 typelib_TypeDescriptionReference
* pType
=
568 pSourceElements
[nPos
].pType
;
569 if (typelib_TypeClass_VOID
== pType
->eTypeClass
)
571 CONSTRUCT_EMPTY_ANY( &pDestElements
[nPos
] );
575 _copyConstructAnyFromData(
576 &pDestElements
[nPos
],
577 pSourceElements
[nPos
].pData
,
585 case typelib_TypeClass_STRUCT
:
586 case typelib_TypeClass_EXCEPTION
:
588 typelib_TypeDescription
* pElementTypeDescr
= 0;
589 TYPELIB_DANGER_GET( &pElementTypeDescr
, pElementType
);
590 sal_Int32 nElementSize
= pElementTypeDescr
->nSize
;
591 char * pSourceElements
= pSource
->elements
;
592 pDest
= allocSeq( nElementSize
, nElements
);
595 char * pElements
= pDest
->elements
;
596 for ( sal_Int32 nPos
= nElements
; nPos
--; )
598 _copyConstructStruct(
599 pElements
+ (nPos
* nElementSize
),
600 pSourceElements
+ (nPos
* nElementSize
),
601 (typelib_CompoundTypeDescription
*)
606 TYPELIB_DANGER_RELEASE( pElementTypeDescr
);
609 case typelib_TypeClass_ARRAY
:
611 typelib_TypeDescription
* pElementTypeDescr
= 0;
612 TYPELIB_DANGER_GET( &pElementTypeDescr
, pElementType
);
613 sal_Int32 nElementSize
= pElementTypeDescr
->nSize
;
614 char * pSourceElements
= pSource
->elements
;
615 pDest
= allocSeq( nElementSize
, nElements
);
618 char * pElements
= pDest
->elements
;
619 for ( sal_Int32 nPos
= nElements
; nPos
--; )
622 pElements
+ (nPos
* nElementSize
),
623 pSourceElements
+ (nPos
* nElementSize
),
624 (typelib_ArrayTypeDescription
*)pElementTypeDescr
,
628 TYPELIB_DANGER_RELEASE( pElementTypeDescr
);
631 case typelib_TypeClass_UNION
:
633 typelib_TypeDescription
* pElementTypeDescr
= 0;
634 TYPELIB_DANGER_GET( &pElementTypeDescr
, pElementType
);
635 sal_Int32 nElementSize
= pElementTypeDescr
->nSize
;
636 sal_Int32 nValueOffset
=
637 ((typelib_UnionTypeDescription
*)
638 pElementTypeDescr
)->nValueOffset
;
639 pDest
= allocSeq( nElementSize
, nElements
);
642 char * pElements
= pDest
->elements
;
643 char * pSourceElements
= pSource
->elements
;
644 for ( sal_Int32 nPos
= nElements
; nPos
--; )
647 pElements
+ (nPos
* nElementSize
);
649 pSourceElements
+ (nPos
* nElementSize
);
651 typelib_TypeDescriptionReference
* pSetType
=
652 _unionGetSetType( pSource2
, pElementTypeDescr
);
653 ::uno_type_copyAndConvertData(
654 pDest2
+ nValueOffset
, pSource2
+ nValueOffset
,
656 *(sal_Int64
*)pDest2
= *(sal_Int64
*)pSource2
;
657 ::typelib_typedescriptionreference_release( pSetType
);
660 TYPELIB_DANGER_RELEASE( pElementTypeDescr
);
663 case typelib_TypeClass_SEQUENCE
: // sequence of sequence
665 pDest
= allocSeq( sizeof (uno_Sequence
*), nElements
);
668 typelib_TypeDescription
* pElementTypeDescr
= 0;
669 TYPELIB_DANGER_GET( &pElementTypeDescr
, pElementType
);
670 typelib_TypeDescriptionReference
* pSeqElementType
=
671 ((typelib_IndirectTypeDescription
*)
672 pElementTypeDescr
)->pType
;
674 uno_Sequence
** pDestElements
=
675 (uno_Sequence
**) pDest
->elements
;
676 uno_Sequence
** pSourceElements
=
677 (uno_Sequence
**) pSource
->elements
;
678 for ( sal_Int32 nPos
= nElements
; nPos
--; )
680 uno_Sequence
* pNew
= copyConstructSequence(
681 pSourceElements
[nPos
],
684 OSL_ASSERT( pNew
!= 0 );
685 // ought never be a memory allocation problem,
686 // because of reference counted sequence handles
687 pDestElements
[ nPos
] = pNew
;
690 TYPELIB_DANGER_RELEASE( pElementTypeDescr
);
694 case typelib_TypeClass_INTERFACE
:
696 pDest
= allocSeq( sizeof (void *), nElements
);
699 char * pElements
= pDest
->elements
;
700 void ** pSourceElements
= (void **)pSource
->elements
;
703 typelib_TypeDescription
* pElementTypeDescr
= 0;
704 TYPELIB_DANGER_GET( &pElementTypeDescr
, pElementType
);
705 for ( sal_Int32 nPos
= nElements
; nPos
--; )
707 ((void **)pElements
)[nPos
] = 0;
708 if (((void **)pSourceElements
)[nPos
])
710 (*mapping
->mapInterface
)(
711 mapping
, (void **)pElements
+ nPos
,
712 pSourceElements
[nPos
],
713 (typelib_InterfaceTypeDescription
*)
717 TYPELIB_DANGER_RELEASE( pElementTypeDescr
);
721 for ( sal_Int32 nPos
= nElements
; nPos
--; )
723 ((void **)pElements
)[nPos
] = pSourceElements
[nPos
];
724 _acquire( ((void **)pElements
)[nPos
], acquire
);
731 OSL_ENSURE( 0, "### unexepcted sequence element type!" );
736 else // empty sequence
738 pDest
= allocSeq( 0, 0 );
745 //--------------------------------------------------------------------------------------------------
746 inline void _copyConstructData(
747 void * pDest
, void * pSource
,
748 typelib_TypeDescriptionReference
* pType
, typelib_TypeDescription
* pTypeDescr
,
749 uno_AcquireFunc acquire
, uno_Mapping
* mapping
)
752 switch (pType
->eTypeClass
)
754 case typelib_TypeClass_CHAR
:
755 *(sal_Unicode
*)pDest
= *(sal_Unicode
*)pSource
;
757 case typelib_TypeClass_BOOLEAN
:
758 *(sal_Bool
*)pDest
= (*(sal_Bool
*)pSource
!= sal_False
);
760 case typelib_TypeClass_BYTE
:
761 *(sal_Int8
*)pDest
= *(sal_Int8
*)pSource
;
763 case typelib_TypeClass_SHORT
:
764 case typelib_TypeClass_UNSIGNED_SHORT
:
765 *(sal_Int16
*)pDest
= *(sal_Int16
*)pSource
;
767 case typelib_TypeClass_LONG
:
768 case typelib_TypeClass_UNSIGNED_LONG
:
769 *(sal_Int32
*)pDest
= *(sal_Int32
*)pSource
;
771 case typelib_TypeClass_HYPER
:
772 case typelib_TypeClass_UNSIGNED_HYPER
:
773 *(sal_Int64
*)pDest
= *(sal_Int64
*)pSource
;
775 case typelib_TypeClass_FLOAT
:
776 *(float *)pDest
= *(float *)pSource
;
778 case typelib_TypeClass_DOUBLE
:
779 *(double *)pDest
= *(double *)pSource
;
781 case typelib_TypeClass_STRING
:
782 ::rtl_uString_acquire( *(rtl_uString
**)pSource
);
783 *(rtl_uString
**)pDest
= *(rtl_uString
**)pSource
;
785 case typelib_TypeClass_TYPE
:
786 TYPE_ACQUIRE( *(typelib_TypeDescriptionReference
**)pSource
);
787 *(typelib_TypeDescriptionReference
**)pDest
= *(typelib_TypeDescriptionReference
**)pSource
;
789 case typelib_TypeClass_ANY
:
791 (uno_Any
*)pDest
, ((uno_Any
*)pSource
)->pData
,
792 ((uno_Any
*)pSource
)->pType
, 0,
795 case typelib_TypeClass_ENUM
:
796 *(sal_Int32
*)pDest
= *(sal_Int32
*)pSource
;
798 case typelib_TypeClass_STRUCT
:
799 case typelib_TypeClass_EXCEPTION
:
802 _copyConstructStruct(
804 (typelib_CompoundTypeDescription
*)pTypeDescr
,
809 TYPELIB_DANGER_GET( &pTypeDescr
, pType
);
810 _copyConstructStruct(
812 (typelib_CompoundTypeDescription
*)pTypeDescr
,
814 TYPELIB_DANGER_RELEASE( pTypeDescr
);
817 case typelib_TypeClass_ARRAY
:
822 (typelib_ArrayTypeDescription
*)pTypeDescr
,
827 TYPELIB_DANGER_GET( &pTypeDescr
, pType
);
830 (typelib_ArrayTypeDescription
*)pTypeDescr
,
832 TYPELIB_DANGER_RELEASE( pTypeDescr
);
835 case typelib_TypeClass_UNION
:
838 _copyConstructUnion( pDest
, pSource
, pTypeDescr
, acquire
, mapping
);
842 TYPELIB_DANGER_GET( &pTypeDescr
, pType
);
843 _copyConstructUnion( pDest
, pSource
, pTypeDescr
, acquire
, mapping
);
844 TYPELIB_DANGER_RELEASE( pTypeDescr
);
847 case typelib_TypeClass_SEQUENCE
:
852 *(uno_Sequence
**)pDest
= icopyConstructSequence(
853 *(uno_Sequence
**)pSource
,
854 ((typelib_IndirectTypeDescription
*)pTypeDescr
)->pType
,
859 TYPELIB_DANGER_GET( &pTypeDescr
, pType
);
860 *(uno_Sequence
**)pDest
= icopyConstructSequence(
861 *(uno_Sequence
**)pSource
,
862 ((typelib_IndirectTypeDescription
*)pTypeDescr
)->pType
,
864 TYPELIB_DANGER_RELEASE( pTypeDescr
);
869 ::osl_incrementInterlockedCount( &(*(uno_Sequence
**)pSource
)->nRefCount
);
870 *(uno_Sequence
**)pDest
= *(uno_Sequence
**)pSource
;
873 case typelib_TypeClass_INTERFACE
:
875 *(void **)pDest
= _map( *(void **)pSource
, pType
, pTypeDescr
, mapping
);
877 _acquire( *(void **)pDest
= *(void **)pSource
, acquire
);