merge the formfield patch from ooo-build
[ooovba.git] / cppu / source / uno / eq.hxx
blob15629a941c354b4eb9d13398744fdf611f5352a0
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: eq.hxx,v $
10 * $Revision: 1.11 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef EQ_HXX
31 #define EQ_HXX
33 #include <math.h>
34 #include <rtl/memory.h>
36 #include "prim.hxx"
37 #include "destr.hxx"
40 namespace cppu
43 //##################################################################################################
44 //#### equality ####################################################################################
45 //##################################################################################################
47 //--------------------------------------------------------------------------------------------------
48 inline sal_Bool _equalObject(
49 void * pI1, void * pI2,
50 uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
51 SAL_THROW( () )
53 if (pI1 == pI2)
54 return sal_True;
55 if ((0 == pI1) || (0 == pI2))
56 return sal_False;
57 sal_Bool bRet = sal_False;
59 typelib_TypeDescriptionReference * type_XInterface =
60 * typelib_static_type_getByTypeClass( typelib_TypeClass_INTERFACE );
61 if (0 == queryInterface)
62 queryInterface = binuno_queryInterface;
63 pI1 = (*queryInterface)( pI1, type_XInterface );
64 if (0 != pI1)
66 pI2 = (*queryInterface)( pI2, type_XInterface );
67 if (0 != pI2)
69 bRet = (pI1 == pI2);
70 _release( pI2, release );
72 _release( pI1, release );
74 return bRet;
77 //==================================================================================================
78 sal_Bool equalStruct(
79 void * pDest, void *pSource,
80 typelib_CompoundTypeDescription * pTypeDescr,
81 uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
82 SAL_THROW( () );
83 //--------------------------------------------------------------------------------------------------
84 inline sal_Bool _equalStruct(
85 void * pDest, void *pSource,
86 typelib_CompoundTypeDescription * pTypeDescr,
87 uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
88 SAL_THROW( () )
90 if (pTypeDescr->pBaseTypeDescription &&
91 !equalStruct( pDest, pSource, pTypeDescr->pBaseTypeDescription, queryInterface, release ))
93 return sal_False;
96 typelib_TypeDescriptionReference ** ppTypeRefs = pTypeDescr->ppTypeRefs;
97 sal_Int32 * pMemberOffsets = pTypeDescr->pMemberOffsets;
98 sal_Int32 nDescr = pTypeDescr->nMembers;
100 while (nDescr--)
102 sal_Int32 nOffset = pMemberOffsets[nDescr];
103 if (! ::uno_type_equalData( (char *)pDest + nOffset,
104 ppTypeRefs[nDescr],
105 (char *)pSource + nOffset,
106 ppTypeRefs[nDescr],
107 queryInterface, release ))
109 return sal_False;
112 return sal_True;
114 //==================================================================================================
115 sal_Bool equalSequence(
116 uno_Sequence * pDest, uno_Sequence * pSource,
117 typelib_TypeDescriptionReference * pElementType,
118 uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
119 SAL_THROW( () );
120 //--------------------------------------------------------------------------------------------------
121 inline sal_Bool _equalSequence(
122 uno_Sequence * pDest, uno_Sequence * pSource,
123 typelib_TypeDescriptionReference * pElementType,
124 uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
125 SAL_THROW( () )
127 if (pDest == pSource)
128 return sal_True;
129 sal_Int32 nElements = pDest->nElements;
130 if (nElements != pSource->nElements)
131 return sal_False;
132 if (! nElements)
133 return sal_True;
135 void * pDestElements = pDest->elements;
136 void * pSourceElements = pSource->elements;
138 switch (pElementType->eTypeClass)
140 case typelib_TypeClass_CHAR:
141 return (0 == ::rtl_compareMemory( pDestElements, pSourceElements, sizeof(sal_Unicode) * nElements ));
142 case typelib_TypeClass_BOOLEAN:
144 for ( sal_Int32 nPos = nElements; nPos--; )
146 if ((((sal_Bool *)pDestElements)[nPos] != sal_False) !=
147 (((sal_Bool *)pSourceElements)[nPos] != sal_False))
149 return sal_False;
152 return sal_True;
154 case typelib_TypeClass_BYTE:
155 return (0 == ::rtl_compareMemory( pDestElements, pSourceElements, sizeof(sal_Int8) * nElements ));
156 case typelib_TypeClass_SHORT:
157 case typelib_TypeClass_UNSIGNED_SHORT:
158 return (0 == ::rtl_compareMemory( pDestElements, pSourceElements, sizeof(sal_Int16) * nElements ));
159 case typelib_TypeClass_LONG:
160 case typelib_TypeClass_UNSIGNED_LONG:
161 return (0 == ::rtl_compareMemory( pDestElements, pSourceElements, sizeof(sal_Int32) * nElements ));
162 case typelib_TypeClass_HYPER:
163 case typelib_TypeClass_UNSIGNED_HYPER:
164 return (0 == ::rtl_compareMemory( pDestElements, pSourceElements, sizeof(sal_Int64) * nElements ));
165 case typelib_TypeClass_FLOAT:
167 for ( sal_Int32 nPos = nElements; nPos--; )
169 if (((float *)pDestElements)[nPos] != ((float *)pSourceElements)[nPos])
170 return sal_False;
172 return sal_True;
174 case typelib_TypeClass_DOUBLE:
176 for ( sal_Int32 nPos = nElements; nPos--; )
178 if (((double *)pDestElements)[nPos] != ((double *)pSourceElements)[nPos])
179 return sal_False;
181 return sal_True;
183 case typelib_TypeClass_STRING:
185 for ( sal_Int32 nPos = nElements; nPos--; )
187 if (! ((::rtl::OUString *)pDestElements +nPos)->equals( ((const ::rtl::OUString *)pSourceElements)[nPos] ))
188 return sal_False;
190 return sal_True;
192 case typelib_TypeClass_TYPE:
194 for ( sal_Int32 nPos = nElements; nPos--; )
196 if (! _type_equals( ((typelib_TypeDescriptionReference **)pDestElements)[nPos],
197 ((typelib_TypeDescriptionReference **)pSourceElements)[nPos] ))
199 return sal_False;
202 return sal_True;
204 case typelib_TypeClass_ANY:
206 for ( sal_Int32 nPos = nElements; nPos--; )
208 uno_Any * pDest2 = (uno_Any *)pDestElements + nPos;
209 uno_Any * pSource2 = (uno_Any *)pSourceElements + nPos;
210 if (! ::uno_type_equalData( pDest2->pData, pDest2->pType,
211 pSource2->pData, pSource2->pType,
212 queryInterface, release ))
214 return sal_False;
217 return sal_True;
219 case typelib_TypeClass_ENUM:
220 return (0 == ::rtl_compareMemory( pDestElements, pSourceElements, sizeof(sal_Int32) * nElements ));
221 case typelib_TypeClass_STRUCT:
222 case typelib_TypeClass_EXCEPTION:
224 typelib_TypeDescription * pElementTypeDescr = 0;
225 TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
226 sal_Int32 nElementSize = pElementTypeDescr->nSize;
227 for ( sal_Int32 nPos = nElements; nPos--; )
229 if (! _equalStruct( (char *)pDestElements + (nPos * nElementSize),
230 (char *)pSourceElements + (nPos * nElementSize),
231 (typelib_CompoundTypeDescription *)pElementTypeDescr,
232 queryInterface, release ))
234 TYPELIB_DANGER_RELEASE( pElementTypeDescr );
235 return sal_False;
238 TYPELIB_DANGER_RELEASE( pElementTypeDescr );
239 return sal_True;
241 case typelib_TypeClass_UNION:
243 typelib_TypeDescription * pElementTypeDescr = 0;
244 TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
245 sal_Int32 nElementSize = pElementTypeDescr->nSize;
246 sal_Int32 nValueOffset = ((typelib_UnionTypeDescription *)pElementTypeDescr)->nValueOffset;
247 for ( sal_Int32 nPos = nElements; nPos--; )
249 char * pDest2 = (char *)pDestElements + (nPos * nElementSize);
250 char * pSource2 = (char *)pSourceElements + (nPos * nElementSize);
251 typelib_TypeDescriptionReference * pSetType = _unionGetSetType(
252 pDest2, pElementTypeDescr );
253 sal_Bool bRet = ::uno_type_equalData(
254 pDest2 + nValueOffset, pSetType,
255 pSource2 + nValueOffset, pSetType,
256 queryInterface, release );
257 ::typelib_typedescriptionreference_release( pSetType );
258 if (! bRet)
260 TYPELIB_DANGER_RELEASE( pElementTypeDescr );
261 return sal_False;
264 TYPELIB_DANGER_RELEASE( pElementTypeDescr );
265 return sal_True;
267 case typelib_TypeClass_SEQUENCE: // sequence of sequence
269 typelib_TypeDescription * pElementTypeDescr = 0;
270 TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
271 typelib_TypeDescriptionReference * pSeqElementType =
272 ((typelib_IndirectTypeDescription *)pElementTypeDescr)->pType;
273 for ( sal_Int32 nPos = nElements; nPos--; )
275 if (! equalSequence( ((uno_Sequence **)pDestElements)[nPos],
276 ((uno_Sequence **)pSourceElements)[nPos],
277 pSeqElementType, queryInterface, release ))
279 TYPELIB_DANGER_RELEASE( pElementTypeDescr );
280 return sal_False;
283 TYPELIB_DANGER_RELEASE( pElementTypeDescr );
284 return sal_True;
286 case typelib_TypeClass_INTERFACE:
288 for ( sal_Int32 nPos = nElements; nPos--; )
290 if (! _equalObject( ((void **)pDestElements)[nPos], ((void **)pSourceElements)[nPos],
291 queryInterface, release ))
293 return sal_False;
296 return sal_True;
298 default:
299 OSL_ASSERT(false);
300 return sal_False;
303 //--------------------------------------------------------------------------------------------------
304 inline sal_Bool _equalData(
305 void * pDest,
306 typelib_TypeDescriptionReference * pDestType, typelib_TypeDescription * pDestTypeDescr,
307 void * pSource,
308 typelib_TypeDescriptionReference * pSourceType, typelib_TypeDescription * pSourceTypeDescr,
309 uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
310 SAL_THROW( () )
312 typelib_TypeClass eSourceTypeClass, eDestTypeClass;
313 while (typelib_TypeClass_ANY == (eDestTypeClass = pDestType->eTypeClass))
315 pDestTypeDescr = 0;
316 pDestType = ((uno_Any *)pDest)->pType;
317 pDest = ((uno_Any *)pDest)->pData;
319 while (typelib_TypeClass_ANY == (eSourceTypeClass = pSourceType->eTypeClass))
321 pSourceTypeDescr = 0;
322 pSourceType = ((uno_Any *)pSource)->pType;
323 pSource = ((uno_Any *)pSource)->pData;
326 switch (eDestTypeClass)
328 case typelib_TypeClass_VOID:
329 return eSourceTypeClass == typelib_TypeClass_VOID;
330 case typelib_TypeClass_CHAR:
331 return eSourceTypeClass == typelib_TypeClass_CHAR
332 && *(sal_Unicode *)pDest == *(sal_Unicode *)pSource;
333 case typelib_TypeClass_BOOLEAN:
334 return eSourceTypeClass == typelib_TypeClass_BOOLEAN
335 && ((*(sal_Bool *)pDest != sal_False)
336 == (*(sal_Bool *)pSource != sal_False));
337 case typelib_TypeClass_BYTE:
338 switch (eSourceTypeClass)
340 case typelib_TypeClass_BYTE:
341 return (*(sal_Int8 *)pDest == *(sal_Int8 *)pSource);
342 case typelib_TypeClass_SHORT:
343 return ((sal_Int16)*(sal_Int8 *)pDest == *(sal_Int16 *)pSource);
344 case typelib_TypeClass_UNSIGNED_SHORT:
345 return ((sal_Int32)*(sal_Int8 *)pDest == (sal_Int32)*(sal_uInt16 *)pSource);
346 case typelib_TypeClass_LONG:
347 return ((sal_Int32)*(sal_Int8 *)pDest == *(sal_Int32 *)pSource);
348 case typelib_TypeClass_UNSIGNED_LONG:
349 return ((sal_Int64)*(sal_Int8 *)pDest == (sal_Int64)*(sal_uInt32 *)pSource);
350 case typelib_TypeClass_HYPER:
351 return ((sal_Int64)*(sal_Int8 *)pDest == *(sal_Int64 *)pSource);
352 case typelib_TypeClass_UNSIGNED_HYPER:
353 return (*(sal_Int8 *)pDest >= 0 &&
354 (sal_Int64)*(sal_Int8 *)pDest == *(sal_Int64 *)pSource); // same size
355 case typelib_TypeClass_FLOAT:
356 return ((float)*(sal_Int8 *)pDest == *(float *)pSource);
357 case typelib_TypeClass_DOUBLE:
358 return ((double)*(sal_Int8 *)pDest == *(double *)pSource);
359 default:
360 return sal_False;
362 case typelib_TypeClass_SHORT:
363 switch (eSourceTypeClass)
365 case typelib_TypeClass_BYTE:
366 return (*(sal_Int16 *)pDest == (sal_Int16)*(sal_Int8 *)pSource);
367 case typelib_TypeClass_SHORT:
368 return (*(sal_Int16 *)pDest == *(sal_Int16 *)pSource);
369 case typelib_TypeClass_UNSIGNED_SHORT:
370 return ((sal_Int32)*(sal_Int16 *)pDest == (sal_Int32)*(sal_uInt16 *)pSource);
371 case typelib_TypeClass_LONG:
372 return ((sal_Int32)*(sal_Int16 *)pDest == *(sal_Int32 *)pSource);
373 case typelib_TypeClass_UNSIGNED_LONG:
374 return ((sal_Int64)*(sal_Int16 *)pDest == (sal_Int64)*(sal_uInt32 *)pSource);
375 case typelib_TypeClass_HYPER:
376 return ((sal_Int64)*(sal_Int16 *)pDest == *(sal_Int64 *)pSource);
377 case typelib_TypeClass_UNSIGNED_HYPER:
378 return (*(sal_Int16 *)pDest >= 0 &&
379 (sal_Int64)*(sal_Int16 *)pDest == *(sal_Int64 *)pSource); // same size
380 case typelib_TypeClass_FLOAT:
381 return ((float)*(sal_Int16 *)pDest == *(float *)pSource);
382 case typelib_TypeClass_DOUBLE:
383 return ((double)*(sal_Int16 *)pDest == *(double *)pSource);
384 default:
385 return sal_False;
387 case typelib_TypeClass_UNSIGNED_SHORT:
388 switch (eSourceTypeClass)
390 case typelib_TypeClass_BYTE:
391 return ((sal_Int32)*(sal_uInt16 *)pDest == (sal_Int32)*(sal_Int8 *)pSource);
392 case typelib_TypeClass_SHORT:
393 return ((sal_Int32)*(sal_uInt16 *)pDest == (sal_Int32)*(sal_Int16 *)pSource);
394 case typelib_TypeClass_UNSIGNED_SHORT:
395 return (*(sal_uInt16 *)pDest == *(sal_uInt16 *)pSource);
396 case typelib_TypeClass_LONG:
397 return ((sal_Int32)*(sal_uInt16 *)pDest == *(sal_Int32 *)pSource);
398 case typelib_TypeClass_UNSIGNED_LONG:
399 return ((sal_uInt32)*(sal_uInt16 *)pDest == *(sal_uInt32 *)pSource);
400 case typelib_TypeClass_HYPER:
401 return ((sal_Int64)*(sal_uInt16 *)pDest == *(sal_Int64 *)pSource);
402 case typelib_TypeClass_UNSIGNED_HYPER:
403 return ((sal_uInt64)*(sal_uInt16 *)pDest == *(sal_uInt64 *)pSource);
404 case typelib_TypeClass_FLOAT:
405 return ((float)*(sal_uInt16 *)pDest == *(float *)pSource);
406 case typelib_TypeClass_DOUBLE:
407 return ((double)*(sal_uInt16 *)pDest == *(double *)pSource);
408 default:
409 return sal_False;
411 case typelib_TypeClass_LONG:
412 switch (eSourceTypeClass)
414 case typelib_TypeClass_BYTE:
415 return (*(sal_Int32 *)pDest == (sal_Int32)*(sal_Int8 *)pSource);
416 case typelib_TypeClass_SHORT:
417 return (*(sal_Int32 *)pDest == (sal_Int32)*(sal_Int16 *)pSource);
418 case typelib_TypeClass_UNSIGNED_SHORT:
419 return (*(sal_Int32 *)pDest == (sal_Int32)*(sal_uInt16 *)pSource);
420 case typelib_TypeClass_LONG:
421 return (*(sal_Int32 *)pDest == *(sal_Int32 *)pSource);
422 case typelib_TypeClass_UNSIGNED_LONG:
423 return ((sal_Int64)*(sal_Int32 *)pDest == (sal_Int64)*(sal_uInt32 *)pSource);
424 case typelib_TypeClass_HYPER:
425 return ((sal_Int64)*(sal_Int32 *)pDest == *(sal_Int64 *)pSource);
426 case typelib_TypeClass_UNSIGNED_HYPER:
427 return (*(sal_Int32 *)pDest >= 0 &&
428 (sal_Int64)*(sal_Int32 *)pDest == *(sal_Int64 *)pSource); // same size
429 case typelib_TypeClass_FLOAT:
430 return ((float)*(sal_Int32 *)pDest == *(float *)pSource);
431 case typelib_TypeClass_DOUBLE:
432 return ((double)*(sal_Int32 *)pDest == *(double *)pSource);
433 default:
434 return sal_False;
436 case typelib_TypeClass_UNSIGNED_LONG:
437 switch (eSourceTypeClass)
439 case typelib_TypeClass_BYTE:
440 return ((sal_Int64)*(sal_uInt32 *)pDest == (sal_Int64)*(sal_Int8 *)pSource);
441 case typelib_TypeClass_SHORT:
442 return ((sal_Int64)*(sal_uInt32 *)pDest == (sal_Int64)*(sal_Int16 *)pSource);
443 case typelib_TypeClass_UNSIGNED_SHORT:
444 return (*(sal_uInt32 *)pDest == (sal_uInt32)*(sal_uInt16 *)pSource);
445 case typelib_TypeClass_LONG:
446 return ((sal_Int64)*(sal_uInt32 *)pDest == (sal_Int64)*(sal_Int32 *)pSource);
447 case typelib_TypeClass_UNSIGNED_LONG:
448 return (*(sal_uInt32 *)pDest == *(sal_uInt32 *)pSource);
449 case typelib_TypeClass_HYPER:
450 return ((sal_Int64)*(sal_uInt32 *)pDest == *(sal_Int64 *)pSource);
451 case typelib_TypeClass_UNSIGNED_HYPER:
452 return ((sal_uInt64)*(sal_uInt32 *)pDest == *(sal_uInt64 *)pSource);
453 case typelib_TypeClass_FLOAT:
454 return ((float)*(sal_uInt32 *)pDest == *(float *)pSource);
455 case typelib_TypeClass_DOUBLE:
456 return ((double)*(sal_uInt32 *)pDest == *(double *)pSource);
457 default:
458 return sal_False;
460 case typelib_TypeClass_HYPER:
461 switch (eSourceTypeClass)
463 case typelib_TypeClass_BYTE:
464 return (*(sal_Int64 *)pDest == (sal_Int64)*(sal_Int8 *)pSource);
465 case typelib_TypeClass_SHORT:
466 return (*(sal_Int64 *)pDest == (sal_Int64)*(sal_Int16 *)pSource);
467 case typelib_TypeClass_UNSIGNED_SHORT:
468 return (*(sal_Int64 *)pDest == (sal_Int64)*(sal_uInt16 *)pSource);
469 case typelib_TypeClass_LONG:
470 return (*(sal_Int64 *)pDest == (sal_Int64)*(sal_Int32 *)pSource);
471 case typelib_TypeClass_UNSIGNED_LONG:
472 return (*(sal_Int64 *)pDest == (sal_Int64)*(sal_uInt32 *)pSource);
473 case typelib_TypeClass_HYPER:
474 return (*(sal_Int64 *)pDest == *(sal_Int64 *)pSource);
475 case typelib_TypeClass_UNSIGNED_HYPER:
476 return (*(sal_Int64 *)pDest >= 0 &&
477 *(sal_Int64 *)pDest == *(sal_Int64 *)pSource); // same size
478 case typelib_TypeClass_FLOAT:
479 return ((float)*(sal_Int64 *)pDest == *(float *)pSource);
480 case typelib_TypeClass_DOUBLE:
481 return ((double)*(sal_Int64 *)pDest == *(double *)pSource);
482 default:
483 return sal_False;
485 case typelib_TypeClass_UNSIGNED_HYPER:
486 switch (eSourceTypeClass)
488 case typelib_TypeClass_BYTE:
489 return (*(sal_Int8 *)pSource >= 0 &&
490 *(sal_uInt64 *)pDest == (sal_uInt64)*(sal_Int8 *)pSource);
491 case typelib_TypeClass_SHORT:
492 return (*(sal_Int16 *)pSource >= 0 &&
493 *(sal_uInt64 *)pDest == (sal_uInt64)*(sal_Int16 *)pSource);
494 case typelib_TypeClass_UNSIGNED_SHORT:
495 return (*(sal_uInt64 *)pDest == (sal_uInt64)*(sal_uInt16 *)pSource);
496 case typelib_TypeClass_LONG:
497 return (*(sal_Int32 *)pSource >= 0 &&
498 *(sal_uInt64 *)pDest == (sal_uInt64)*(sal_Int32 *)pSource);
499 case typelib_TypeClass_UNSIGNED_LONG:
500 return (*(sal_uInt64 *)pDest == (sal_uInt64)*(sal_uInt32 *)pSource);
501 case typelib_TypeClass_HYPER:
502 return (*(sal_Int64 *)pSource >= 0 &&
503 *(sal_uInt64 *)pDest == (sal_uInt64)*(sal_Int64 *)pSource);
504 case typelib_TypeClass_UNSIGNED_HYPER:
505 return (*(sal_uInt64 *)pDest == *(sal_uInt64 *)pSource);
506 case typelib_TypeClass_FLOAT:
507 if (::floor( *(float *)pSource ) != *(float *)pSource || *(float *)pSource < 0)
508 return sal_False;
509 return (*(sal_uInt64 *)pDest == (sal_uInt64)*(float *)pSource);
510 case typelib_TypeClass_DOUBLE:
511 if (::floor( *(double *)pSource ) != *(double *)pSource || *(double *)pSource < 0)
512 return sal_False;
513 return (*(sal_uInt64 *)pDest == (sal_uInt64)*(double *)pSource);
514 default:
515 return sal_False;
517 case typelib_TypeClass_FLOAT:
518 switch (eSourceTypeClass)
520 case typelib_TypeClass_BYTE:
521 return (*(float *)pDest == (float)*(sal_Int8 *)pSource);
522 case typelib_TypeClass_SHORT:
523 return (*(float *)pDest == (float)*(sal_Int16 *)pSource);
524 case typelib_TypeClass_UNSIGNED_SHORT:
525 return (*(float *)pDest == (float)*(sal_uInt16 *)pSource);
526 case typelib_TypeClass_LONG:
527 return (*(float *)pDest == (float)*(sal_Int32 *)pSource);
528 case typelib_TypeClass_UNSIGNED_LONG:
529 return (*(float *)pDest == (float)*(sal_uInt32 *)pSource);
530 case typelib_TypeClass_HYPER:
531 return (*(float *)pDest == (float)*(sal_Int64 *)pSource);
532 case typelib_TypeClass_UNSIGNED_HYPER:
533 if (::floor( *(float *)pDest ) != *(float *)pDest || *(float *)pDest < 0)
534 return sal_False;
535 return ((sal_uInt64)*(float *)pDest == *(sal_uInt64 *)pSource);
536 case typelib_TypeClass_FLOAT:
537 return (*(float *)pDest == *(float *)pSource);
538 case typelib_TypeClass_DOUBLE:
539 return ((double)*(float *)pDest == *(double *)pSource);
540 default:
541 return sal_False;
543 case typelib_TypeClass_DOUBLE:
544 switch (eSourceTypeClass)
546 case typelib_TypeClass_BYTE:
547 return (*(double *)pDest == (double)*(sal_Int8 *)pSource);
548 case typelib_TypeClass_SHORT:
549 return (*(double *)pDest == (double)*(sal_Int16 *)pSource);
550 case typelib_TypeClass_UNSIGNED_SHORT:
551 return (*(double *)pDest == (double)*(sal_uInt16 *)pSource);
552 case typelib_TypeClass_LONG:
553 return (*(double *)pDest == (double)*(sal_Int32 *)pSource);
554 case typelib_TypeClass_UNSIGNED_LONG:
555 return (*(double *)pDest == (double)*(sal_uInt32 *)pSource);
556 case typelib_TypeClass_HYPER:
557 return (*(double *)pDest == (double)*(sal_Int64 *)pSource);
558 case typelib_TypeClass_UNSIGNED_HYPER:
559 if (::floor( *(double *)pDest ) != *(double *)pDest || *(double *)pDest < 0)
560 return sal_False;
561 return ((sal_uInt64)*(double *)pDest == *(sal_uInt64 *)pSource);
562 case typelib_TypeClass_FLOAT:
563 return (*(double *)pDest == (double)*(float *)pSource);
564 case typelib_TypeClass_DOUBLE:
565 return (*(double *)pDest == *(double *)pSource);
566 default:
567 return sal_False;
569 case typelib_TypeClass_STRING:
570 return eSourceTypeClass == typelib_TypeClass_STRING
571 && ((::rtl::OUString *)pDest)->equals(
572 *(::rtl::OUString const *)pSource );
573 case typelib_TypeClass_TYPE:
574 return eSourceTypeClass == typelib_TypeClass_TYPE
575 && _type_equals(
576 *(typelib_TypeDescriptionReference **)pDest,
577 *(typelib_TypeDescriptionReference **)pSource );
578 case typelib_TypeClass_ENUM:
579 return (_type_equals( pDestType, pSourceType ) &&
580 *(sal_Int32 *)pDest == *(sal_Int32 *)pSource);
581 case typelib_TypeClass_STRUCT:
582 case typelib_TypeClass_EXCEPTION:
583 if (! _type_equals( pDestType, pSourceType ))
584 return sal_False;
585 if (pDestTypeDescr)
587 return _equalStruct(
588 pDest, pSource,
589 (typelib_CompoundTypeDescription *)pDestTypeDescr,
590 queryInterface, release );
592 else
594 TYPELIB_DANGER_GET( &pDestTypeDescr, pDestType );
595 sal_Bool bRet = _equalStruct(
596 pDest, pSource,
597 (typelib_CompoundTypeDescription *)pDestTypeDescr,
598 queryInterface, release );
599 TYPELIB_DANGER_RELEASE( pDestTypeDescr );
600 return bRet;
602 case typelib_TypeClass_UNION:
603 if (_type_equals( pDestType, pSourceType ) &&
604 *(sal_Int64 *)pDest == *(sal_Int64 *)pSource) // same discriminant
606 sal_Bool bRet;
607 if (pDestTypeDescr)
609 typelib_TypeDescriptionReference * pSetType = _unionGetSetType(
610 pDest, pDestTypeDescr );
611 bRet = ::uno_type_equalData(
612 (char *)pDest + ((typelib_UnionTypeDescription *)pDestTypeDescr)->nValueOffset,
613 pSetType,
614 (char *)pSource + ((typelib_UnionTypeDescription *)pDestTypeDescr)->nValueOffset,
615 pSetType,
616 queryInterface, release );
617 typelib_typedescriptionreference_release( pSetType );
619 else
621 TYPELIB_DANGER_GET( &pDestTypeDescr, pDestType );
622 typelib_TypeDescriptionReference * pSetType = _unionGetSetType(
623 pDest, pDestTypeDescr );
624 bRet = ::uno_type_equalData(
625 (char *)pDest + ((typelib_UnionTypeDescription *)pDestTypeDescr)->nValueOffset,
626 pSetType,
627 (char *)pSource + ((typelib_UnionTypeDescription *)pDestTypeDescr)->nValueOffset,
628 pSetType,
629 queryInterface, release );
630 typelib_typedescriptionreference_release( pSetType );
631 TYPELIB_DANGER_RELEASE( pDestTypeDescr );
633 return bRet;
635 return sal_False;
636 case typelib_TypeClass_SEQUENCE:
637 if (_type_equals( pDestType, pSourceType ))
639 if (pDestTypeDescr)
641 return _equalSequence(
642 *(uno_Sequence **)pDest, *(uno_Sequence **)pSource,
643 ((typelib_IndirectTypeDescription *)pDestTypeDescr)->pType,
644 queryInterface, release );
646 else
648 TYPELIB_DANGER_GET( &pDestTypeDescr, pDestType );
649 sal_Bool bRet = _equalSequence(
650 *(uno_Sequence **)pDest, *(uno_Sequence **)pSource,
651 ((typelib_IndirectTypeDescription *)pDestTypeDescr)->pType,
652 queryInterface, release );
653 TYPELIB_DANGER_RELEASE( pDestTypeDescr );
654 return bRet;
657 return sal_False;
658 case typelib_TypeClass_INTERFACE:
659 if (typelib_TypeClass_INTERFACE == eSourceTypeClass)
660 return _equalObject( *(void **)pDest, *(void **)pSource, queryInterface, release );
661 break;
662 default:
663 OSL_ASSERT(false);
664 break;
666 return sal_False;
671 #endif