1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
29 //##################################################################################################
30 //#### copy construction ###########################################################################
31 //##################################################################################################
33 //------------------------------------------------------------------------------
34 inline uno_Sequence
* allocSeq(
35 sal_Int32 nElementSize
, sal_Int32 nElements
)
37 OSL_ASSERT( nElements
>= 0 && nElementSize
>= 0 );
38 uno_Sequence
* pSeq
= 0;
39 sal_uInt32 nSize
= calcSeqMemSize( nElementSize
, nElements
);
42 pSeq
= (uno_Sequence
*) rtl_allocateMemory( nSize
);
47 pSeq
->nElements
= nElements
;
53 //--------------------------------------------------------------------------------------------------
54 void copyConstructStruct(
55 void * pDest
, void * pSource
,
56 typelib_CompoundTypeDescription
* pTypeDescr
,
57 uno_AcquireFunc acquire
, uno_Mapping
* mapping
)
59 //--------------------------------------------------------------------------------------------------
60 inline void _copyConstructStruct(
61 void * pDest
, void * pSource
,
62 typelib_CompoundTypeDescription
* pTypeDescr
,
63 uno_AcquireFunc acquire
, uno_Mapping
* mapping
)
66 if (pTypeDescr
->pBaseTypeDescription
)
69 copyConstructStruct( pDest
, pSource
, pTypeDescr
->pBaseTypeDescription
, acquire
, mapping
);
73 typelib_TypeDescriptionReference
** ppTypeRefs
= pTypeDescr
->ppTypeRefs
;
74 sal_Int32
* pMemberOffsets
= pTypeDescr
->pMemberOffsets
;
75 sal_Int32 nDescr
= pTypeDescr
->nMembers
;
81 ::uno_type_copyAndConvertData(
82 (char *)pDest
+ pMemberOffsets
[nDescr
],
83 (char *)pSource
+ pMemberOffsets
[nDescr
],
84 ppTypeRefs
[nDescr
], mapping
);
92 (char *)pDest
+ pMemberOffsets
[nDescr
],
93 (char *)pSource
+ pMemberOffsets
[nDescr
],
94 ppTypeRefs
[nDescr
], acquire
);
98 //--------------------------------------------------------------------------------------------------
99 inline void _copyConstructArray(
100 void * pDest
, void * pSource
,
101 typelib_ArrayTypeDescription
* pTypeDescr
,
102 uno_AcquireFunc acquire
, uno_Mapping
* mapping
)
104 typelib_TypeDescriptionReference
* pElementTypeRef
= ((typelib_IndirectTypeDescription
*)pTypeDescr
)->pType
;
105 typelib_TypeDescription
* pElementTypeDescr
= NULL
;
106 TYPELIB_DANGER_GET( &pElementTypeDescr
, pElementTypeRef
);
107 sal_Int32 nElementSize
= ((typelib_TypeDescription
*)pElementTypeDescr
)->nSize
;
108 TYPELIB_DANGER_RELEASE( pElementTypeDescr
);
109 sal_Int32 nTotalElements
= pTypeDescr
->nTotalElements
;
113 for(sal_Int32 i
= 0; i
< nTotalElements
; i
++)
115 ::uno_type_copyAndConvertData(
116 (sal_Char
*)pDest
+ i
* nElementSize
,
117 (sal_Char
*)pSource
+ i
* nElementSize
,
118 pElementTypeRef
, mapping
);
123 for(sal_Int32 i
= 0; i
< nTotalElements
; i
++)
126 (sal_Char
*)pDest
+ (i
* nElementSize
),
127 (sal_Char
*)pSource
+ (i
* nElementSize
),
128 pElementTypeRef
, acquire
);
132 //--------------------------------------------------------------------------------------------------
133 inline void _copyConstructUnion(
134 void * pDest
, void * pSource
,
135 typelib_TypeDescription
* pTypeDescr
,
136 uno_AcquireFunc acquire
, uno_Mapping
* mapping
)
139 typelib_TypeDescriptionReference
* pSetType
= _unionGetSetType( pSource
, pTypeDescr
);
142 ::uno_type_copyAndConvertData(
143 (char *)pDest
+ ((typelib_UnionTypeDescription
*)pTypeDescr
)->nValueOffset
,
144 (char *)pSource
+ ((typelib_UnionTypeDescription
*)pTypeDescr
)->nValueOffset
,
150 (char *)pDest
+ ((typelib_UnionTypeDescription
*)pTypeDescr
)->nValueOffset
,
151 (char *)pSource
+ ((typelib_UnionTypeDescription
*)pTypeDescr
)->nValueOffset
,
154 *(sal_Int64
*)pDest
= *(sal_Int64
*)pSource
;
155 typelib_typedescriptionreference_release( pSetType
);
158 //------------------------------------------------------------------------------
159 uno_Sequence
* copyConstructSequence(
160 uno_Sequence
* pSource
,
161 typelib_TypeDescriptionReference
* pElementType
,
162 uno_AcquireFunc acquire
, uno_Mapping
* mapping
);
164 //--------------------------------------------------------------------------------------------------
165 inline void _copyConstructAnyFromData(
166 uno_Any
* pDestAny
, void * pSource
,
167 typelib_TypeDescriptionReference
* pType
, typelib_TypeDescription
* pTypeDescr
,
168 uno_AcquireFunc acquire
, uno_Mapping
* mapping
)
171 TYPE_ACQUIRE( pType
);
172 pDestAny
->pType
= pType
;
174 switch (pType
->eTypeClass
)
176 case typelib_TypeClass_CHAR
:
177 pDestAny
->pData
= &pDestAny
->pReserved
;
178 *(sal_Unicode
*)pDestAny
->pData
= *(sal_Unicode
*)pSource
;
180 case typelib_TypeClass_BOOLEAN
:
181 pDestAny
->pData
= &pDestAny
->pReserved
;
182 *(sal_Bool
*)pDestAny
->pData
= (*(sal_Bool
*)pSource
!= sal_False
);
184 case typelib_TypeClass_BYTE
:
185 pDestAny
->pData
= &pDestAny
->pReserved
;
186 *(sal_Int8
*)pDestAny
->pData
= *(sal_Int8
*)pSource
;
188 case typelib_TypeClass_SHORT
:
189 case typelib_TypeClass_UNSIGNED_SHORT
:
190 pDestAny
->pData
= &pDestAny
->pReserved
;
191 *(sal_Int16
*)pDestAny
->pData
= *(sal_Int16
*)pSource
;
193 case typelib_TypeClass_LONG
:
194 case typelib_TypeClass_UNSIGNED_LONG
:
195 pDestAny
->pData
= &pDestAny
->pReserved
;
196 *(sal_Int32
*)pDestAny
->pData
= *(sal_Int32
*)pSource
;
198 case typelib_TypeClass_HYPER
:
199 case typelib_TypeClass_UNSIGNED_HYPER
:
200 if (sizeof(void *) >= sizeof(sal_Int64
))
201 pDestAny
->pData
= &pDestAny
->pReserved
;
203 pDestAny
->pData
= ::rtl_allocateMemory( sizeof(sal_Int64
) );
204 *(sal_Int64
*)pDestAny
->pData
= *(sal_Int64
*)pSource
;
206 case typelib_TypeClass_FLOAT
:
207 if (sizeof(void *) >= sizeof(float))
208 pDestAny
->pData
= &pDestAny
->pReserved
;
210 pDestAny
->pData
= ::rtl_allocateMemory( sizeof(float) );
211 *(float *)pDestAny
->pData
= *(float *)pSource
;
213 case typelib_TypeClass_DOUBLE
:
214 if (sizeof(void *) >= sizeof(double))
215 pDestAny
->pData
= &pDestAny
->pReserved
;
217 pDestAny
->pData
= ::rtl_allocateMemory( sizeof(double) );
218 *(double *)pDestAny
->pData
= *(double *)pSource
;
220 case typelib_TypeClass_STRING
:
221 ::rtl_uString_acquire( *(rtl_uString
**)pSource
);
222 pDestAny
->pData
= &pDestAny
->pReserved
;
223 *(rtl_uString
**)pDestAny
->pData
= *(rtl_uString
**)pSource
;
225 case typelib_TypeClass_TYPE
:
226 TYPE_ACQUIRE( *(typelib_TypeDescriptionReference
**)pSource
);
227 pDestAny
->pData
= &pDestAny
->pReserved
;
228 *(typelib_TypeDescriptionReference
**)pDestAny
->pData
= *(typelib_TypeDescriptionReference
**)pSource
;
230 case typelib_TypeClass_ANY
:
231 OSL_FAIL( "### unexpected nested any!" );
233 case typelib_TypeClass_ENUM
:
234 pDestAny
->pData
= &pDestAny
->pReserved
;
235 // enum is forced to 32bit long
236 *(sal_Int32
*)pDestAny
->pData
= *(sal_Int32
*)pSource
;
238 case typelib_TypeClass_STRUCT
:
239 case typelib_TypeClass_EXCEPTION
:
242 pDestAny
->pData
= ::rtl_allocateMemory( pTypeDescr
->nSize
);
243 _copyConstructStruct(
244 pDestAny
->pData
, pSource
,
245 (typelib_CompoundTypeDescription
*)pTypeDescr
,
250 TYPELIB_DANGER_GET( &pTypeDescr
, pType
);
251 pDestAny
->pData
= ::rtl_allocateMemory( pTypeDescr
->nSize
);
252 _copyConstructStruct(
253 pDestAny
->pData
, pSource
,
254 (typelib_CompoundTypeDescription
*)pTypeDescr
,
256 TYPELIB_DANGER_RELEASE( pTypeDescr
);
259 case typelib_TypeClass_ARRAY
:
262 pDestAny
->pData
= ::rtl_allocateMemory( pTypeDescr
->nSize
);
264 pDestAny
->pData
, pSource
,
265 (typelib_ArrayTypeDescription
*)pTypeDescr
,
270 TYPELIB_DANGER_GET( &pTypeDescr
, pType
);
271 pDestAny
->pData
= ::rtl_allocateMemory( pTypeDescr
->nSize
);
273 pDestAny
->pData
, pSource
,
274 (typelib_ArrayTypeDescription
*)pTypeDescr
,
276 TYPELIB_DANGER_RELEASE( pTypeDescr
);
279 case typelib_TypeClass_UNION
:
282 pDestAny
->pData
= ::rtl_allocateMemory( pTypeDescr
->nSize
);
283 _copyConstructUnion( pDestAny
->pData
, pSource
, pTypeDescr
, acquire
, mapping
);
287 TYPELIB_DANGER_GET( &pTypeDescr
, pType
);
288 pDestAny
->pData
= ::rtl_allocateMemory( pTypeDescr
->nSize
);
289 _copyConstructUnion( pDestAny
->pData
, pSource
, pTypeDescr
, acquire
, mapping
);
290 TYPELIB_DANGER_RELEASE( pTypeDescr
);
293 case typelib_TypeClass_SEQUENCE
:
294 pDestAny
->pData
= &pDestAny
->pReserved
;
297 *(uno_Sequence
**)pDestAny
->pData
= copyConstructSequence(
298 *(uno_Sequence
**)pSource
,
299 ((typelib_IndirectTypeDescription
*)pTypeDescr
)->pType
,
304 TYPELIB_DANGER_GET( &pTypeDescr
, pType
);
305 *(uno_Sequence
**)pDestAny
->pData
= copyConstructSequence(
306 *(uno_Sequence
**)pSource
,
307 ((typelib_IndirectTypeDescription
*)pTypeDescr
)->pType
,
309 TYPELIB_DANGER_RELEASE( pTypeDescr
);
312 case typelib_TypeClass_INTERFACE
:
313 pDestAny
->pData
= &pDestAny
->pReserved
;
316 pDestAny
->pReserved
= _map( *(void **)pSource
, pType
, pTypeDescr
, mapping
);
320 _acquire( pDestAny
->pReserved
= *(void **)pSource
, acquire
);
328 //--------------------------------------------------------------------------------------------------
329 inline void _copyConstructAny(
330 uno_Any
* pDestAny
, void * pSource
,
331 typelib_TypeDescriptionReference
* pType
, typelib_TypeDescription
* pTypeDescr
,
332 uno_AcquireFunc acquire
, uno_Mapping
* mapping
)
335 if (typelib_TypeClass_VOID
== pType
->eTypeClass
)
337 CONSTRUCT_EMPTY_ANY( pDestAny
);
341 if (typelib_TypeClass_ANY
== pType
->eTypeClass
)
345 pType
= ((uno_Any
*)pSource
)->pType
;
346 if (typelib_TypeClass_VOID
== pType
->eTypeClass
)
348 CONSTRUCT_EMPTY_ANY( pDestAny
);
352 pSource
= ((uno_Any
*)pSource
)->pData
;
356 CONSTRUCT_EMPTY_ANY( pDestAny
);
362 _copyConstructAnyFromData( pDestAny
, pSource
, pType
, pTypeDescr
, acquire
, mapping
);
364 else // default construct
366 TYPE_ACQUIRE( pType
);
367 pDestAny
->pType
= pType
;
368 switch (pType
->eTypeClass
)
370 case typelib_TypeClass_CHAR
:
371 pDestAny
->pData
= &pDestAny
->pReserved
;
372 *(sal_Unicode
*)pDestAny
->pData
= '\0';
374 case typelib_TypeClass_BOOLEAN
:
375 pDestAny
->pData
= &pDestAny
->pReserved
;
376 *(sal_Bool
*)pDestAny
->pData
= sal_False
;
378 case typelib_TypeClass_BYTE
:
379 pDestAny
->pData
= &pDestAny
->pReserved
;
380 *(sal_Int8
*)pDestAny
->pData
= 0;
382 case typelib_TypeClass_SHORT
:
383 case typelib_TypeClass_UNSIGNED_SHORT
:
384 pDestAny
->pData
= &pDestAny
->pReserved
;
385 *(sal_Int16
*)pDestAny
->pData
= 0;
387 case typelib_TypeClass_LONG
:
388 case typelib_TypeClass_UNSIGNED_LONG
:
389 pDestAny
->pData
= &pDestAny
->pReserved
;
390 *(sal_Int32
*)pDestAny
->pData
= 0;
392 case typelib_TypeClass_HYPER
:
393 case typelib_TypeClass_UNSIGNED_HYPER
:
394 if (sizeof(void *) >= sizeof(sal_Int64
))
395 pDestAny
->pData
= &pDestAny
->pReserved
;
397 pDestAny
->pData
= ::rtl_allocateMemory( sizeof(sal_Int64
) );
398 *(sal_Int64
*)pDestAny
->pData
= 0;
400 case typelib_TypeClass_FLOAT
:
401 if (sizeof(void *) >= sizeof(float))
402 pDestAny
->pData
= &pDestAny
->pReserved
;
404 pDestAny
->pData
= ::rtl_allocateMemory( sizeof(float) );
405 *(float *)pDestAny
->pData
= 0.0;
407 case typelib_TypeClass_DOUBLE
:
408 if (sizeof(void *) >= sizeof(double))
409 pDestAny
->pData
= &pDestAny
->pReserved
;
411 pDestAny
->pData
= ::rtl_allocateMemory( sizeof(double) );
412 *(double *)pDestAny
->pData
= 0.0;
414 case typelib_TypeClass_STRING
:
415 pDestAny
->pData
= &pDestAny
->pReserved
;
416 *(rtl_uString
**)pDestAny
->pData
= 0;
417 ::rtl_uString_new( (rtl_uString
**)pDestAny
->pData
);
419 case typelib_TypeClass_TYPE
:
420 pDestAny
->pData
= &pDestAny
->pReserved
;
421 *(typelib_TypeDescriptionReference
**)pDestAny
->pData
= _getVoidType();
423 case typelib_TypeClass_ENUM
:
424 pDestAny
->pData
= &pDestAny
->pReserved
;
427 *(sal_Int32
*)pDestAny
->pData
= ((typelib_EnumTypeDescription
*)pTypeDescr
)->nDefaultEnumValue
;
431 TYPELIB_DANGER_GET( &pTypeDescr
, pType
);
432 *(sal_Int32
*)pDestAny
->pData
= ((typelib_EnumTypeDescription
*)pTypeDescr
)->nDefaultEnumValue
;
433 TYPELIB_DANGER_RELEASE( pTypeDescr
);
436 case typelib_TypeClass_STRUCT
:
437 case typelib_TypeClass_EXCEPTION
:
440 pDestAny
->pData
= ::rtl_allocateMemory( pTypeDescr
->nSize
);
441 _defaultConstructStruct(
442 pDestAny
->pData
, (typelib_CompoundTypeDescription
*)pTypeDescr
);
446 TYPELIB_DANGER_GET( &pTypeDescr
, pType
);
447 pDestAny
->pData
= ::rtl_allocateMemory( pTypeDescr
->nSize
);
448 _defaultConstructStruct(
449 pDestAny
->pData
, (typelib_CompoundTypeDescription
*)pTypeDescr
);
450 TYPELIB_DANGER_RELEASE( pTypeDescr
);
453 case typelib_TypeClass_ARRAY
:
456 pDestAny
->pData
= ::rtl_allocateMemory( pTypeDescr
->nSize
);
457 _defaultConstructArray(
458 pDestAny
->pData
, (typelib_ArrayTypeDescription
*)pTypeDescr
);
462 TYPELIB_DANGER_GET( &pTypeDescr
, pType
);
463 pDestAny
->pData
= ::rtl_allocateMemory( pTypeDescr
->nSize
);
464 _defaultConstructArray(
465 pDestAny
->pData
, (typelib_ArrayTypeDescription
*)pTypeDescr
);
466 TYPELIB_DANGER_RELEASE( pTypeDescr
);
469 case typelib_TypeClass_UNION
:
472 pDestAny
->pData
= ::rtl_allocateMemory( pTypeDescr
->nSize
);
473 _defaultConstructUnion( pDestAny
->pData
, pTypeDescr
);
477 TYPELIB_DANGER_GET( &pTypeDescr
, pType
);
478 pDestAny
->pData
= ::rtl_allocateMemory( pTypeDescr
->nSize
);
479 _defaultConstructUnion( pDestAny
->pData
, pTypeDescr
);
480 TYPELIB_DANGER_RELEASE( pTypeDescr
);
483 case typelib_TypeClass_SEQUENCE
:
484 pDestAny
->pData
= &pDestAny
->pReserved
;
485 *(uno_Sequence
**)pDestAny
->pData
= createEmptySequence();
487 case typelib_TypeClass_INTERFACE
:
488 pDestAny
->pData
= &pDestAny
->pReserved
;
489 pDestAny
->pReserved
= 0; // either cpp or c-uno interface
498 //------------------------------------------------------------------------------
499 inline uno_Sequence
* icopyConstructSequence(
500 uno_Sequence
* pSource
,
501 typelib_TypeDescriptionReference
* pElementType
,
502 uno_AcquireFunc acquire
, uno_Mapping
* mapping
)
504 typelib_TypeClass eTypeClass
= pElementType
->eTypeClass
;
506 (eTypeClass
<= typelib_TypeClass_ENUM
&&
507 eTypeClass
!= typelib_TypeClass_ANY
))
509 osl_atomic_increment( &pSource
->nRefCount
);
512 else // create new sequence
514 uno_Sequence
* pDest
;
515 sal_Int32 nElements
= pSource
->nElements
;
520 case typelib_TypeClass_ANY
:
522 pDest
= allocSeq( sizeof (uno_Any
), nElements
);
525 uno_Any
* pDestElements
= (uno_Any
*)pDest
->elements
;
526 uno_Any
* pSourceElements
= (uno_Any
*)pSource
->elements
;
527 for ( sal_Int32 nPos
= nElements
; nPos
--; )
529 typelib_TypeDescriptionReference
* pType
=
530 pSourceElements
[nPos
].pType
;
531 if (typelib_TypeClass_VOID
== pType
->eTypeClass
)
533 CONSTRUCT_EMPTY_ANY( &pDestElements
[nPos
] );
537 _copyConstructAnyFromData(
538 &pDestElements
[nPos
],
539 pSourceElements
[nPos
].pData
,
547 case typelib_TypeClass_STRUCT
:
548 case typelib_TypeClass_EXCEPTION
:
550 typelib_TypeDescription
* pElementTypeDescr
= 0;
551 TYPELIB_DANGER_GET( &pElementTypeDescr
, pElementType
);
552 sal_Int32 nElementSize
= pElementTypeDescr
->nSize
;
553 char * pSourceElements
= pSource
->elements
;
554 pDest
= allocSeq( nElementSize
, nElements
);
557 char * pElements
= pDest
->elements
;
558 for ( sal_Int32 nPos
= nElements
; nPos
--; )
560 _copyConstructStruct(
561 pElements
+ (nPos
* nElementSize
),
562 pSourceElements
+ (nPos
* nElementSize
),
563 (typelib_CompoundTypeDescription
*)
568 TYPELIB_DANGER_RELEASE( pElementTypeDescr
);
571 case typelib_TypeClass_ARRAY
:
573 typelib_TypeDescription
* pElementTypeDescr
= 0;
574 TYPELIB_DANGER_GET( &pElementTypeDescr
, pElementType
);
575 sal_Int32 nElementSize
= pElementTypeDescr
->nSize
;
576 char * pSourceElements
= pSource
->elements
;
577 pDest
= allocSeq( nElementSize
, nElements
);
580 char * pElements
= pDest
->elements
;
581 for ( sal_Int32 nPos
= nElements
; nPos
--; )
584 pElements
+ (nPos
* nElementSize
),
585 pSourceElements
+ (nPos
* nElementSize
),
586 (typelib_ArrayTypeDescription
*)pElementTypeDescr
,
590 TYPELIB_DANGER_RELEASE( pElementTypeDescr
);
593 case typelib_TypeClass_UNION
:
595 typelib_TypeDescription
* pElementTypeDescr
= 0;
596 TYPELIB_DANGER_GET( &pElementTypeDescr
, pElementType
);
597 sal_Int32 nElementSize
= pElementTypeDescr
->nSize
;
598 sal_Int32 nValueOffset
=
599 ((typelib_UnionTypeDescription
*)
600 pElementTypeDescr
)->nValueOffset
;
601 pDest
= allocSeq( nElementSize
, nElements
);
604 char * pElements
= pDest
->elements
;
605 char * pSourceElements
= pSource
->elements
;
606 for ( sal_Int32 nPos
= nElements
; nPos
--; )
609 pElements
+ (nPos
* nElementSize
);
611 pSourceElements
+ (nPos
* nElementSize
);
613 typelib_TypeDescriptionReference
* pSetType
=
614 _unionGetSetType( pSource2
, pElementTypeDescr
);
615 ::uno_type_copyAndConvertData(
616 pDest2
+ nValueOffset
, pSource2
+ nValueOffset
,
618 *(sal_Int64
*)pDest2
= *(sal_Int64
*)pSource2
;
619 ::typelib_typedescriptionreference_release( pSetType
);
622 TYPELIB_DANGER_RELEASE( pElementTypeDescr
);
625 case typelib_TypeClass_SEQUENCE
: // sequence of sequence
627 pDest
= allocSeq( sizeof (uno_Sequence
*), nElements
);
630 typelib_TypeDescription
* pElementTypeDescr
= 0;
631 TYPELIB_DANGER_GET( &pElementTypeDescr
, pElementType
);
632 typelib_TypeDescriptionReference
* pSeqElementType
=
633 ((typelib_IndirectTypeDescription
*)
634 pElementTypeDescr
)->pType
;
636 uno_Sequence
** pDestElements
=
637 (uno_Sequence
**) pDest
->elements
;
638 uno_Sequence
** pSourceElements
=
639 (uno_Sequence
**) pSource
->elements
;
640 for ( sal_Int32 nPos
= nElements
; nPos
--; )
642 uno_Sequence
* pNew
= copyConstructSequence(
643 pSourceElements
[nPos
],
646 OSL_ASSERT( pNew
!= 0 );
647 // ought never be a memory allocation problem,
648 // because of reference counted sequence handles
649 pDestElements
[ nPos
] = pNew
;
652 TYPELIB_DANGER_RELEASE( pElementTypeDescr
);
656 case typelib_TypeClass_INTERFACE
:
658 pDest
= allocSeq( sizeof (void *), nElements
);
661 char * pElements
= pDest
->elements
;
662 void ** pSourceElements
= (void **)pSource
->elements
;
665 typelib_TypeDescription
* pElementTypeDescr
= 0;
666 TYPELIB_DANGER_GET( &pElementTypeDescr
, pElementType
);
667 for ( sal_Int32 nPos
= nElements
; nPos
--; )
669 ((void **)pElements
)[nPos
] = 0;
670 if (((void **)pSourceElements
)[nPos
])
672 (*mapping
->mapInterface
)(
673 mapping
, (void **)pElements
+ nPos
,
674 pSourceElements
[nPos
],
675 (typelib_InterfaceTypeDescription
*)
679 TYPELIB_DANGER_RELEASE( pElementTypeDescr
);
683 for ( sal_Int32 nPos
= nElements
; nPos
--; )
685 ((void **)pElements
)[nPos
] = pSourceElements
[nPos
];
686 _acquire( ((void **)pElements
)[nPos
], acquire
);
693 OSL_FAIL( "### unexepcted sequence element type!" );
698 else // empty sequence
700 pDest
= allocSeq( 0, 0 );
707 //--------------------------------------------------------------------------------------------------
708 inline void _copyConstructData(
709 void * pDest
, void * pSource
,
710 typelib_TypeDescriptionReference
* pType
, typelib_TypeDescription
* pTypeDescr
,
711 uno_AcquireFunc acquire
, uno_Mapping
* mapping
)
714 switch (pType
->eTypeClass
)
716 case typelib_TypeClass_CHAR
:
717 *(sal_Unicode
*)pDest
= *(sal_Unicode
*)pSource
;
719 case typelib_TypeClass_BOOLEAN
:
720 *(sal_Bool
*)pDest
= (*(sal_Bool
*)pSource
!= sal_False
);
722 case typelib_TypeClass_BYTE
:
723 *(sal_Int8
*)pDest
= *(sal_Int8
*)pSource
;
725 case typelib_TypeClass_SHORT
:
726 case typelib_TypeClass_UNSIGNED_SHORT
:
727 *(sal_Int16
*)pDest
= *(sal_Int16
*)pSource
;
729 case typelib_TypeClass_LONG
:
730 case typelib_TypeClass_UNSIGNED_LONG
:
731 *(sal_Int32
*)pDest
= *(sal_Int32
*)pSource
;
733 case typelib_TypeClass_HYPER
:
734 case typelib_TypeClass_UNSIGNED_HYPER
:
735 *(sal_Int64
*)pDest
= *(sal_Int64
*)pSource
;
737 case typelib_TypeClass_FLOAT
:
738 *(float *)pDest
= *(float *)pSource
;
740 case typelib_TypeClass_DOUBLE
:
741 *(double *)pDest
= *(double *)pSource
;
743 case typelib_TypeClass_STRING
:
744 ::rtl_uString_acquire( *(rtl_uString
**)pSource
);
745 *(rtl_uString
**)pDest
= *(rtl_uString
**)pSource
;
747 case typelib_TypeClass_TYPE
:
748 TYPE_ACQUIRE( *(typelib_TypeDescriptionReference
**)pSource
);
749 *(typelib_TypeDescriptionReference
**)pDest
= *(typelib_TypeDescriptionReference
**)pSource
;
751 case typelib_TypeClass_ANY
:
753 (uno_Any
*)pDest
, ((uno_Any
*)pSource
)->pData
,
754 ((uno_Any
*)pSource
)->pType
, 0,
757 case typelib_TypeClass_ENUM
:
758 *(sal_Int32
*)pDest
= *(sal_Int32
*)pSource
;
760 case typelib_TypeClass_STRUCT
:
761 case typelib_TypeClass_EXCEPTION
:
764 _copyConstructStruct(
766 (typelib_CompoundTypeDescription
*)pTypeDescr
,
771 TYPELIB_DANGER_GET( &pTypeDescr
, pType
);
772 _copyConstructStruct(
774 (typelib_CompoundTypeDescription
*)pTypeDescr
,
776 TYPELIB_DANGER_RELEASE( pTypeDescr
);
779 case typelib_TypeClass_ARRAY
:
784 (typelib_ArrayTypeDescription
*)pTypeDescr
,
789 TYPELIB_DANGER_GET( &pTypeDescr
, pType
);
792 (typelib_ArrayTypeDescription
*)pTypeDescr
,
794 TYPELIB_DANGER_RELEASE( pTypeDescr
);
797 case typelib_TypeClass_UNION
:
800 _copyConstructUnion( pDest
, pSource
, pTypeDescr
, acquire
, mapping
);
804 TYPELIB_DANGER_GET( &pTypeDescr
, pType
);
805 _copyConstructUnion( pDest
, pSource
, pTypeDescr
, acquire
, mapping
);
806 TYPELIB_DANGER_RELEASE( pTypeDescr
);
809 case typelib_TypeClass_SEQUENCE
:
814 *(uno_Sequence
**)pDest
= icopyConstructSequence(
815 *(uno_Sequence
**)pSource
,
816 ((typelib_IndirectTypeDescription
*)pTypeDescr
)->pType
,
821 TYPELIB_DANGER_GET( &pTypeDescr
, pType
);
822 *(uno_Sequence
**)pDest
= icopyConstructSequence(
823 *(uno_Sequence
**)pSource
,
824 ((typelib_IndirectTypeDescription
*)pTypeDescr
)->pType
,
826 TYPELIB_DANGER_RELEASE( pTypeDescr
);
831 osl_atomic_increment( &(*(uno_Sequence
**)pSource
)->nRefCount
);
832 *(uno_Sequence
**)pDest
= *(uno_Sequence
**)pSource
;
835 case typelib_TypeClass_INTERFACE
:
837 *(void **)pDest
= _map( *(void **)pSource
, pType
, pTypeDescr
, mapping
);
839 _acquire( *(void **)pDest
= *(void **)pSource
, acquire
);
850 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */