merged tag ooo/DEV300_m102
[LibreOffice.git] / cppu / source / uno / eq.hxx
blob45bc0e79cfaa85723e40eba30b6f05c4eb54e394
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 ************************************************************************/
27 #ifndef EQ_HXX
28 #define EQ_HXX
30 #include <math.h>
31 #include <rtl/memory.h>
33 #include "prim.hxx"
34 #include "destr.hxx"
37 namespace cppu
40 //##################################################################################################
41 //#### equality ####################################################################################
42 //##################################################################################################
44 //--------------------------------------------------------------------------------------------------
45 inline sal_Bool _equalObject(
46 void * pI1, void * pI2,
47 uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
48 SAL_THROW( () )
50 if (pI1 == pI2)
51 return sal_True;
52 if ((0 == pI1) || (0 == pI2))
53 return sal_False;
54 sal_Bool bRet = sal_False;
56 typelib_TypeDescriptionReference * type_XInterface =
57 * typelib_static_type_getByTypeClass( typelib_TypeClass_INTERFACE );
58 if (0 == queryInterface)
59 queryInterface = binuno_queryInterface;
60 pI1 = (*queryInterface)( pI1, type_XInterface );
61 if (0 != pI1)
63 pI2 = (*queryInterface)( pI2, type_XInterface );
64 if (0 != pI2)
66 bRet = (pI1 == pI2);
67 _release( pI2, release );
69 _release( pI1, release );
71 return bRet;
74 //==================================================================================================
75 sal_Bool equalStruct(
76 void * pDest, void *pSource,
77 typelib_CompoundTypeDescription * pTypeDescr,
78 uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
79 SAL_THROW( () );
80 //--------------------------------------------------------------------------------------------------
81 inline sal_Bool _equalStruct(
82 void * pDest, void *pSource,
83 typelib_CompoundTypeDescription * pTypeDescr,
84 uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
85 SAL_THROW( () )
87 if (pTypeDescr->pBaseTypeDescription &&
88 !equalStruct( pDest, pSource, pTypeDescr->pBaseTypeDescription, queryInterface, release ))
90 return sal_False;
93 typelib_TypeDescriptionReference ** ppTypeRefs = pTypeDescr->ppTypeRefs;
94 sal_Int32 * pMemberOffsets = pTypeDescr->pMemberOffsets;
95 sal_Int32 nDescr = pTypeDescr->nMembers;
97 while (nDescr--)
99 sal_Int32 nOffset = pMemberOffsets[nDescr];
100 if (! ::uno_type_equalData( (char *)pDest + nOffset,
101 ppTypeRefs[nDescr],
102 (char *)pSource + nOffset,
103 ppTypeRefs[nDescr],
104 queryInterface, release ))
106 return sal_False;
109 return sal_True;
111 //==================================================================================================
112 sal_Bool equalSequence(
113 uno_Sequence * pDest, uno_Sequence * pSource,
114 typelib_TypeDescriptionReference * pElementType,
115 uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
116 SAL_THROW( () );
117 //--------------------------------------------------------------------------------------------------
118 inline sal_Bool _equalSequence(
119 uno_Sequence * pDest, uno_Sequence * pSource,
120 typelib_TypeDescriptionReference * pElementType,
121 uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
122 SAL_THROW( () )
124 if (pDest == pSource)
125 return sal_True;
126 sal_Int32 nElements = pDest->nElements;
127 if (nElements != pSource->nElements)
128 return sal_False;
129 if (! nElements)
130 return sal_True;
132 void * pDestElements = pDest->elements;
133 void * pSourceElements = pSource->elements;
135 switch (pElementType->eTypeClass)
137 case typelib_TypeClass_CHAR:
138 return (0 == ::rtl_compareMemory( pDestElements, pSourceElements, sizeof(sal_Unicode) * nElements ));
139 case typelib_TypeClass_BOOLEAN:
141 for ( sal_Int32 nPos = nElements; nPos--; )
143 if ((((sal_Bool *)pDestElements)[nPos] != sal_False) !=
144 (((sal_Bool *)pSourceElements)[nPos] != sal_False))
146 return sal_False;
149 return sal_True;
151 case typelib_TypeClass_BYTE:
152 return (0 == ::rtl_compareMemory( pDestElements, pSourceElements, sizeof(sal_Int8) * nElements ));
153 case typelib_TypeClass_SHORT:
154 case typelib_TypeClass_UNSIGNED_SHORT:
155 return (0 == ::rtl_compareMemory( pDestElements, pSourceElements, sizeof(sal_Int16) * nElements ));
156 case typelib_TypeClass_LONG:
157 case typelib_TypeClass_UNSIGNED_LONG:
158 return (0 == ::rtl_compareMemory( pDestElements, pSourceElements, sizeof(sal_Int32) * nElements ));
159 case typelib_TypeClass_HYPER:
160 case typelib_TypeClass_UNSIGNED_HYPER:
161 return (0 == ::rtl_compareMemory( pDestElements, pSourceElements, sizeof(sal_Int64) * nElements ));
162 case typelib_TypeClass_FLOAT:
164 for ( sal_Int32 nPos = nElements; nPos--; )
166 if (((float *)pDestElements)[nPos] != ((float *)pSourceElements)[nPos])
167 return sal_False;
169 return sal_True;
171 case typelib_TypeClass_DOUBLE:
173 for ( sal_Int32 nPos = nElements; nPos--; )
175 if (((double *)pDestElements)[nPos] != ((double *)pSourceElements)[nPos])
176 return sal_False;
178 return sal_True;
180 case typelib_TypeClass_STRING:
182 for ( sal_Int32 nPos = nElements; nPos--; )
184 if (! ((::rtl::OUString *)pDestElements +nPos)->equals( ((const ::rtl::OUString *)pSourceElements)[nPos] ))
185 return sal_False;
187 return sal_True;
189 case typelib_TypeClass_TYPE:
191 for ( sal_Int32 nPos = nElements; nPos--; )
193 if (! _type_equals( ((typelib_TypeDescriptionReference **)pDestElements)[nPos],
194 ((typelib_TypeDescriptionReference **)pSourceElements)[nPos] ))
196 return sal_False;
199 return sal_True;
201 case typelib_TypeClass_ANY:
203 for ( sal_Int32 nPos = nElements; nPos--; )
205 uno_Any * pDest2 = (uno_Any *)pDestElements + nPos;
206 uno_Any * pSource2 = (uno_Any *)pSourceElements + nPos;
207 if (! ::uno_type_equalData( pDest2->pData, pDest2->pType,
208 pSource2->pData, pSource2->pType,
209 queryInterface, release ))
211 return sal_False;
214 return sal_True;
216 case typelib_TypeClass_ENUM:
217 return (0 == ::rtl_compareMemory( pDestElements, pSourceElements, sizeof(sal_Int32) * nElements ));
218 case typelib_TypeClass_STRUCT:
219 case typelib_TypeClass_EXCEPTION:
221 typelib_TypeDescription * pElementTypeDescr = 0;
222 TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
223 sal_Int32 nElementSize = pElementTypeDescr->nSize;
224 for ( sal_Int32 nPos = nElements; nPos--; )
226 if (! _equalStruct( (char *)pDestElements + (nPos * nElementSize),
227 (char *)pSourceElements + (nPos * nElementSize),
228 (typelib_CompoundTypeDescription *)pElementTypeDescr,
229 queryInterface, release ))
231 TYPELIB_DANGER_RELEASE( pElementTypeDescr );
232 return sal_False;
235 TYPELIB_DANGER_RELEASE( pElementTypeDescr );
236 return sal_True;
238 case typelib_TypeClass_UNION:
240 typelib_TypeDescription * pElementTypeDescr = 0;
241 TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
242 sal_Int32 nElementSize = pElementTypeDescr->nSize;
243 sal_Int32 nValueOffset = ((typelib_UnionTypeDescription *)pElementTypeDescr)->nValueOffset;
244 for ( sal_Int32 nPos = nElements; nPos--; )
246 char * pDest2 = (char *)pDestElements + (nPos * nElementSize);
247 char * pSource2 = (char *)pSourceElements + (nPos * nElementSize);
248 typelib_TypeDescriptionReference * pSetType = _unionGetSetType(
249 pDest2, pElementTypeDescr );
250 sal_Bool bRet = ::uno_type_equalData(
251 pDest2 + nValueOffset, pSetType,
252 pSource2 + nValueOffset, pSetType,
253 queryInterface, release );
254 ::typelib_typedescriptionreference_release( pSetType );
255 if (! bRet)
257 TYPELIB_DANGER_RELEASE( pElementTypeDescr );
258 return sal_False;
261 TYPELIB_DANGER_RELEASE( pElementTypeDescr );
262 return sal_True;
264 case typelib_TypeClass_SEQUENCE: // sequence of sequence
266 typelib_TypeDescription * pElementTypeDescr = 0;
267 TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
268 typelib_TypeDescriptionReference * pSeqElementType =
269 ((typelib_IndirectTypeDescription *)pElementTypeDescr)->pType;
270 for ( sal_Int32 nPos = nElements; nPos--; )
272 if (! equalSequence( ((uno_Sequence **)pDestElements)[nPos],
273 ((uno_Sequence **)pSourceElements)[nPos],
274 pSeqElementType, queryInterface, release ))
276 TYPELIB_DANGER_RELEASE( pElementTypeDescr );
277 return sal_False;
280 TYPELIB_DANGER_RELEASE( pElementTypeDescr );
281 return sal_True;
283 case typelib_TypeClass_INTERFACE:
285 for ( sal_Int32 nPos = nElements; nPos--; )
287 if (! _equalObject( ((void **)pDestElements)[nPos], ((void **)pSourceElements)[nPos],
288 queryInterface, release ))
290 return sal_False;
293 return sal_True;
295 default:
296 OSL_ASSERT(false);
297 return sal_False;
300 //--------------------------------------------------------------------------------------------------
301 inline sal_Bool _equalData(
302 void * pDest,
303 typelib_TypeDescriptionReference * pDestType, typelib_TypeDescription * pDestTypeDescr,
304 void * pSource,
305 typelib_TypeDescriptionReference * pSourceType, typelib_TypeDescription * pSourceTypeDescr,
306 uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
307 SAL_THROW( () )
309 typelib_TypeClass eSourceTypeClass, eDestTypeClass;
310 while (typelib_TypeClass_ANY == (eDestTypeClass = pDestType->eTypeClass))
312 pDestTypeDescr = 0;
313 pDestType = ((uno_Any *)pDest)->pType;
314 pDest = ((uno_Any *)pDest)->pData;
316 while (typelib_TypeClass_ANY == (eSourceTypeClass = pSourceType->eTypeClass))
318 pSourceTypeDescr = 0;
319 pSourceType = ((uno_Any *)pSource)->pType;
320 pSource = ((uno_Any *)pSource)->pData;
323 switch (eDestTypeClass)
325 case typelib_TypeClass_VOID:
326 return eSourceTypeClass == typelib_TypeClass_VOID;
327 case typelib_TypeClass_CHAR:
328 return eSourceTypeClass == typelib_TypeClass_CHAR
329 && *(sal_Unicode *)pDest == *(sal_Unicode *)pSource;
330 case typelib_TypeClass_BOOLEAN:
331 return eSourceTypeClass == typelib_TypeClass_BOOLEAN
332 && ((*(sal_Bool *)pDest != sal_False)
333 == (*(sal_Bool *)pSource != sal_False));
334 case typelib_TypeClass_BYTE:
335 switch (eSourceTypeClass)
337 case typelib_TypeClass_BYTE:
338 return (*(sal_Int8 *)pDest == *(sal_Int8 *)pSource);
339 case typelib_TypeClass_SHORT:
340 return ((sal_Int16)*(sal_Int8 *)pDest == *(sal_Int16 *)pSource);
341 case typelib_TypeClass_UNSIGNED_SHORT:
342 return ((sal_Int32)*(sal_Int8 *)pDest == (sal_Int32)*(sal_uInt16 *)pSource);
343 case typelib_TypeClass_LONG:
344 return ((sal_Int32)*(sal_Int8 *)pDest == *(sal_Int32 *)pSource);
345 case typelib_TypeClass_UNSIGNED_LONG:
346 return ((sal_Int64)*(sal_Int8 *)pDest == (sal_Int64)*(sal_uInt32 *)pSource);
347 case typelib_TypeClass_HYPER:
348 return ((sal_Int64)*(sal_Int8 *)pDest == *(sal_Int64 *)pSource);
349 case typelib_TypeClass_UNSIGNED_HYPER:
350 return (*(sal_Int8 *)pDest >= 0 &&
351 (sal_Int64)*(sal_Int8 *)pDest == *(sal_Int64 *)pSource); // same size
352 case typelib_TypeClass_FLOAT:
353 return ((float)*(sal_Int8 *)pDest == *(float *)pSource);
354 case typelib_TypeClass_DOUBLE:
355 return ((double)*(sal_Int8 *)pDest == *(double *)pSource);
356 default:
357 return sal_False;
359 case typelib_TypeClass_SHORT:
360 switch (eSourceTypeClass)
362 case typelib_TypeClass_BYTE:
363 return (*(sal_Int16 *)pDest == (sal_Int16)*(sal_Int8 *)pSource);
364 case typelib_TypeClass_SHORT:
365 return (*(sal_Int16 *)pDest == *(sal_Int16 *)pSource);
366 case typelib_TypeClass_UNSIGNED_SHORT:
367 return ((sal_Int32)*(sal_Int16 *)pDest == (sal_Int32)*(sal_uInt16 *)pSource);
368 case typelib_TypeClass_LONG:
369 return ((sal_Int32)*(sal_Int16 *)pDest == *(sal_Int32 *)pSource);
370 case typelib_TypeClass_UNSIGNED_LONG:
371 return ((sal_Int64)*(sal_Int16 *)pDest == (sal_Int64)*(sal_uInt32 *)pSource);
372 case typelib_TypeClass_HYPER:
373 return ((sal_Int64)*(sal_Int16 *)pDest == *(sal_Int64 *)pSource);
374 case typelib_TypeClass_UNSIGNED_HYPER:
375 return (*(sal_Int16 *)pDest >= 0 &&
376 (sal_Int64)*(sal_Int16 *)pDest == *(sal_Int64 *)pSource); // same size
377 case typelib_TypeClass_FLOAT:
378 return ((float)*(sal_Int16 *)pDest == *(float *)pSource);
379 case typelib_TypeClass_DOUBLE:
380 return ((double)*(sal_Int16 *)pDest == *(double *)pSource);
381 default:
382 return sal_False;
384 case typelib_TypeClass_UNSIGNED_SHORT:
385 switch (eSourceTypeClass)
387 case typelib_TypeClass_BYTE:
388 return ((sal_Int32)*(sal_uInt16 *)pDest == (sal_Int32)*(sal_Int8 *)pSource);
389 case typelib_TypeClass_SHORT:
390 return ((sal_Int32)*(sal_uInt16 *)pDest == (sal_Int32)*(sal_Int16 *)pSource);
391 case typelib_TypeClass_UNSIGNED_SHORT:
392 return (*(sal_uInt16 *)pDest == *(sal_uInt16 *)pSource);
393 case typelib_TypeClass_LONG:
394 return ((sal_Int32)*(sal_uInt16 *)pDest == *(sal_Int32 *)pSource);
395 case typelib_TypeClass_UNSIGNED_LONG:
396 return ((sal_uInt32)*(sal_uInt16 *)pDest == *(sal_uInt32 *)pSource);
397 case typelib_TypeClass_HYPER:
398 return ((sal_Int64)*(sal_uInt16 *)pDest == *(sal_Int64 *)pSource);
399 case typelib_TypeClass_UNSIGNED_HYPER:
400 return ((sal_uInt64)*(sal_uInt16 *)pDest == *(sal_uInt64 *)pSource);
401 case typelib_TypeClass_FLOAT:
402 return ((float)*(sal_uInt16 *)pDest == *(float *)pSource);
403 case typelib_TypeClass_DOUBLE:
404 return ((double)*(sal_uInt16 *)pDest == *(double *)pSource);
405 default:
406 return sal_False;
408 case typelib_TypeClass_LONG:
409 switch (eSourceTypeClass)
411 case typelib_TypeClass_BYTE:
412 return (*(sal_Int32 *)pDest == (sal_Int32)*(sal_Int8 *)pSource);
413 case typelib_TypeClass_SHORT:
414 return (*(sal_Int32 *)pDest == (sal_Int32)*(sal_Int16 *)pSource);
415 case typelib_TypeClass_UNSIGNED_SHORT:
416 return (*(sal_Int32 *)pDest == (sal_Int32)*(sal_uInt16 *)pSource);
417 case typelib_TypeClass_LONG:
418 return (*(sal_Int32 *)pDest == *(sal_Int32 *)pSource);
419 case typelib_TypeClass_UNSIGNED_LONG:
420 return ((sal_Int64)*(sal_Int32 *)pDest == (sal_Int64)*(sal_uInt32 *)pSource);
421 case typelib_TypeClass_HYPER:
422 return ((sal_Int64)*(sal_Int32 *)pDest == *(sal_Int64 *)pSource);
423 case typelib_TypeClass_UNSIGNED_HYPER:
424 return (*(sal_Int32 *)pDest >= 0 &&
425 (sal_Int64)*(sal_Int32 *)pDest == *(sal_Int64 *)pSource); // same size
426 case typelib_TypeClass_FLOAT:
427 return ((float)*(sal_Int32 *)pDest == *(float *)pSource);
428 case typelib_TypeClass_DOUBLE:
429 return ((double)*(sal_Int32 *)pDest == *(double *)pSource);
430 default:
431 return sal_False;
433 case typelib_TypeClass_UNSIGNED_LONG:
434 switch (eSourceTypeClass)
436 case typelib_TypeClass_BYTE:
437 return ((sal_Int64)*(sal_uInt32 *)pDest == (sal_Int64)*(sal_Int8 *)pSource);
438 case typelib_TypeClass_SHORT:
439 return ((sal_Int64)*(sal_uInt32 *)pDest == (sal_Int64)*(sal_Int16 *)pSource);
440 case typelib_TypeClass_UNSIGNED_SHORT:
441 return (*(sal_uInt32 *)pDest == (sal_uInt32)*(sal_uInt16 *)pSource);
442 case typelib_TypeClass_LONG:
443 return ((sal_Int64)*(sal_uInt32 *)pDest == (sal_Int64)*(sal_Int32 *)pSource);
444 case typelib_TypeClass_UNSIGNED_LONG:
445 return (*(sal_uInt32 *)pDest == *(sal_uInt32 *)pSource);
446 case typelib_TypeClass_HYPER:
447 return ((sal_Int64)*(sal_uInt32 *)pDest == *(sal_Int64 *)pSource);
448 case typelib_TypeClass_UNSIGNED_HYPER:
449 return ((sal_uInt64)*(sal_uInt32 *)pDest == *(sal_uInt64 *)pSource);
450 case typelib_TypeClass_FLOAT:
451 return ((float)*(sal_uInt32 *)pDest == *(float *)pSource);
452 case typelib_TypeClass_DOUBLE:
453 return ((double)*(sal_uInt32 *)pDest == *(double *)pSource);
454 default:
455 return sal_False;
457 case typelib_TypeClass_HYPER:
458 switch (eSourceTypeClass)
460 case typelib_TypeClass_BYTE:
461 return (*(sal_Int64 *)pDest == (sal_Int64)*(sal_Int8 *)pSource);
462 case typelib_TypeClass_SHORT:
463 return (*(sal_Int64 *)pDest == (sal_Int64)*(sal_Int16 *)pSource);
464 case typelib_TypeClass_UNSIGNED_SHORT:
465 return (*(sal_Int64 *)pDest == (sal_Int64)*(sal_uInt16 *)pSource);
466 case typelib_TypeClass_LONG:
467 return (*(sal_Int64 *)pDest == (sal_Int64)*(sal_Int32 *)pSource);
468 case typelib_TypeClass_UNSIGNED_LONG:
469 return (*(sal_Int64 *)pDest == (sal_Int64)*(sal_uInt32 *)pSource);
470 case typelib_TypeClass_HYPER:
471 return (*(sal_Int64 *)pDest == *(sal_Int64 *)pSource);
472 case typelib_TypeClass_UNSIGNED_HYPER:
473 return (*(sal_Int64 *)pDest >= 0 &&
474 *(sal_Int64 *)pDest == *(sal_Int64 *)pSource); // same size
475 case typelib_TypeClass_FLOAT:
476 return ((float)*(sal_Int64 *)pDest == *(float *)pSource);
477 case typelib_TypeClass_DOUBLE:
478 return ((double)*(sal_Int64 *)pDest == *(double *)pSource);
479 default:
480 return sal_False;
482 case typelib_TypeClass_UNSIGNED_HYPER:
483 switch (eSourceTypeClass)
485 case typelib_TypeClass_BYTE:
486 return (*(sal_Int8 *)pSource >= 0 &&
487 *(sal_uInt64 *)pDest == (sal_uInt64)*(sal_Int8 *)pSource);
488 case typelib_TypeClass_SHORT:
489 return (*(sal_Int16 *)pSource >= 0 &&
490 *(sal_uInt64 *)pDest == (sal_uInt64)*(sal_Int16 *)pSource);
491 case typelib_TypeClass_UNSIGNED_SHORT:
492 return (*(sal_uInt64 *)pDest == (sal_uInt64)*(sal_uInt16 *)pSource);
493 case typelib_TypeClass_LONG:
494 return (*(sal_Int32 *)pSource >= 0 &&
495 *(sal_uInt64 *)pDest == (sal_uInt64)*(sal_Int32 *)pSource);
496 case typelib_TypeClass_UNSIGNED_LONG:
497 return (*(sal_uInt64 *)pDest == (sal_uInt64)*(sal_uInt32 *)pSource);
498 case typelib_TypeClass_HYPER:
499 return (*(sal_Int64 *)pSource >= 0 &&
500 *(sal_uInt64 *)pDest == (sal_uInt64)*(sal_Int64 *)pSource);
501 case typelib_TypeClass_UNSIGNED_HYPER:
502 return (*(sal_uInt64 *)pDest == *(sal_uInt64 *)pSource);
503 case typelib_TypeClass_FLOAT:
504 if (::floor( *(float *)pSource ) != *(float *)pSource || *(float *)pSource < 0)
505 return sal_False;
506 return (*(sal_uInt64 *)pDest == (sal_uInt64)*(float *)pSource);
507 case typelib_TypeClass_DOUBLE:
508 if (::floor( *(double *)pSource ) != *(double *)pSource || *(double *)pSource < 0)
509 return sal_False;
510 return (*(sal_uInt64 *)pDest == (sal_uInt64)*(double *)pSource);
511 default:
512 return sal_False;
514 case typelib_TypeClass_FLOAT:
515 switch (eSourceTypeClass)
517 case typelib_TypeClass_BYTE:
518 return (*(float *)pDest == (float)*(sal_Int8 *)pSource);
519 case typelib_TypeClass_SHORT:
520 return (*(float *)pDest == (float)*(sal_Int16 *)pSource);
521 case typelib_TypeClass_UNSIGNED_SHORT:
522 return (*(float *)pDest == (float)*(sal_uInt16 *)pSource);
523 case typelib_TypeClass_LONG:
524 return (*(float *)pDest == (float)*(sal_Int32 *)pSource);
525 case typelib_TypeClass_UNSIGNED_LONG:
526 return (*(float *)pDest == (float)*(sal_uInt32 *)pSource);
527 case typelib_TypeClass_HYPER:
528 return (*(float *)pDest == (float)*(sal_Int64 *)pSource);
529 case typelib_TypeClass_UNSIGNED_HYPER:
530 if (::floor( *(float *)pDest ) != *(float *)pDest || *(float *)pDest < 0)
531 return sal_False;
532 return ((sal_uInt64)*(float *)pDest == *(sal_uInt64 *)pSource);
533 case typelib_TypeClass_FLOAT:
534 return (*(float *)pDest == *(float *)pSource);
535 case typelib_TypeClass_DOUBLE:
536 return ((double)*(float *)pDest == *(double *)pSource);
537 default:
538 return sal_False;
540 case typelib_TypeClass_DOUBLE:
541 switch (eSourceTypeClass)
543 case typelib_TypeClass_BYTE:
544 return (*(double *)pDest == (double)*(sal_Int8 *)pSource);
545 case typelib_TypeClass_SHORT:
546 return (*(double *)pDest == (double)*(sal_Int16 *)pSource);
547 case typelib_TypeClass_UNSIGNED_SHORT:
548 return (*(double *)pDest == (double)*(sal_uInt16 *)pSource);
549 case typelib_TypeClass_LONG:
550 return (*(double *)pDest == (double)*(sal_Int32 *)pSource);
551 case typelib_TypeClass_UNSIGNED_LONG:
552 return (*(double *)pDest == (double)*(sal_uInt32 *)pSource);
553 case typelib_TypeClass_HYPER:
554 return (*(double *)pDest == (double)*(sal_Int64 *)pSource);
555 case typelib_TypeClass_UNSIGNED_HYPER:
556 if (::floor( *(double *)pDest ) != *(double *)pDest || *(double *)pDest < 0)
557 return sal_False;
558 return ((sal_uInt64)*(double *)pDest == *(sal_uInt64 *)pSource);
559 case typelib_TypeClass_FLOAT:
560 return (*(double *)pDest == (double)*(float *)pSource);
561 case typelib_TypeClass_DOUBLE:
562 return (*(double *)pDest == *(double *)pSource);
563 default:
564 return sal_False;
566 case typelib_TypeClass_STRING:
567 return eSourceTypeClass == typelib_TypeClass_STRING
568 && ((::rtl::OUString *)pDest)->equals(
569 *(::rtl::OUString const *)pSource );
570 case typelib_TypeClass_TYPE:
571 return eSourceTypeClass == typelib_TypeClass_TYPE
572 && _type_equals(
573 *(typelib_TypeDescriptionReference **)pDest,
574 *(typelib_TypeDescriptionReference **)pSource );
575 case typelib_TypeClass_ENUM:
576 return (_type_equals( pDestType, pSourceType ) &&
577 *(sal_Int32 *)pDest == *(sal_Int32 *)pSource);
578 case typelib_TypeClass_STRUCT:
579 case typelib_TypeClass_EXCEPTION:
580 if (! _type_equals( pDestType, pSourceType ))
581 return sal_False;
582 if (pDestTypeDescr)
584 return _equalStruct(
585 pDest, pSource,
586 (typelib_CompoundTypeDescription *)pDestTypeDescr,
587 queryInterface, release );
589 else
591 TYPELIB_DANGER_GET( &pDestTypeDescr, pDestType );
592 sal_Bool bRet = _equalStruct(
593 pDest, pSource,
594 (typelib_CompoundTypeDescription *)pDestTypeDescr,
595 queryInterface, release );
596 TYPELIB_DANGER_RELEASE( pDestTypeDescr );
597 return bRet;
599 case typelib_TypeClass_UNION:
600 if (_type_equals( pDestType, pSourceType ) &&
601 *(sal_Int64 *)pDest == *(sal_Int64 *)pSource) // same discriminant
603 sal_Bool bRet;
604 if (pDestTypeDescr)
606 typelib_TypeDescriptionReference * pSetType = _unionGetSetType(
607 pDest, pDestTypeDescr );
608 bRet = ::uno_type_equalData(
609 (char *)pDest + ((typelib_UnionTypeDescription *)pDestTypeDescr)->nValueOffset,
610 pSetType,
611 (char *)pSource + ((typelib_UnionTypeDescription *)pDestTypeDescr)->nValueOffset,
612 pSetType,
613 queryInterface, release );
614 typelib_typedescriptionreference_release( pSetType );
616 else
618 TYPELIB_DANGER_GET( &pDestTypeDescr, pDestType );
619 typelib_TypeDescriptionReference * pSetType = _unionGetSetType(
620 pDest, pDestTypeDescr );
621 bRet = ::uno_type_equalData(
622 (char *)pDest + ((typelib_UnionTypeDescription *)pDestTypeDescr)->nValueOffset,
623 pSetType,
624 (char *)pSource + ((typelib_UnionTypeDescription *)pDestTypeDescr)->nValueOffset,
625 pSetType,
626 queryInterface, release );
627 typelib_typedescriptionreference_release( pSetType );
628 TYPELIB_DANGER_RELEASE( pDestTypeDescr );
630 return bRet;
632 return sal_False;
633 case typelib_TypeClass_SEQUENCE:
634 if (_type_equals( pDestType, pSourceType ))
636 if (pDestTypeDescr)
638 return _equalSequence(
639 *(uno_Sequence **)pDest, *(uno_Sequence **)pSource,
640 ((typelib_IndirectTypeDescription *)pDestTypeDescr)->pType,
641 queryInterface, release );
643 else
645 TYPELIB_DANGER_GET( &pDestTypeDescr, pDestType );
646 sal_Bool bRet = _equalSequence(
647 *(uno_Sequence **)pDest, *(uno_Sequence **)pSource,
648 ((typelib_IndirectTypeDescription *)pDestTypeDescr)->pType,
649 queryInterface, release );
650 TYPELIB_DANGER_RELEASE( pDestTypeDescr );
651 return bRet;
654 return sal_False;
655 case typelib_TypeClass_INTERFACE:
656 if (typelib_TypeClass_INTERFACE == eSourceTypeClass)
657 return _equalObject( *(void **)pDest, *(void **)pSource, queryInterface, release );
658 break;
659 default:
660 OSL_ASSERT(false);
661 break;
663 return sal_False;
668 #endif