1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23 #ifndef EQ_HXX
24 #define EQ_HXX
25
26 #include <math.h>
27 #include <rtl/memory.h>
28
29 #include "prim.hxx"
30 #include "destr.hxx"
31
32
33 namespace cppu
34 {
35
36 //##################################################################################################
37 //#### equality ####################################################################################
38 //##################################################################################################
39
40 //--------------------------------------------------------------------------------------------------
_equalObject(void * pI1,void * pI2,uno_QueryInterfaceFunc queryInterface,uno_ReleaseFunc release)41 inline sal_Bool _equalObject(
42 void * pI1, void * pI2,
43 uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
44 SAL_THROW( () )
45 {
46 if (pI1 == pI2)
47 return sal_True;
48 if ((0 == pI1) || (0 == pI2))
49 return sal_False;
50 sal_Bool bRet = sal_False;
51
52 typelib_TypeDescriptionReference * type_XInterface =
53 * typelib_static_type_getByTypeClass( typelib_TypeClass_INTERFACE );
54 if (0 == queryInterface)
55 queryInterface = binuno_queryInterface;
56 pI1 = (*queryInterface)( pI1, type_XInterface );
57 if (0 != pI1)
58 {
59 pI2 = (*queryInterface)( pI2, type_XInterface );
60 if (0 != pI2)
61 {
62 bRet = (pI1 == pI2);
63 _release( pI2, release );
64 }
65 _release( pI1, release );
66 }
67 return bRet;
68 }
69
70 //==================================================================================================
71 sal_Bool equalStruct(
72 void * pDest, void *pSource,
73 typelib_CompoundTypeDescription * pTypeDescr,
74 uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
75 SAL_THROW( () );
76 //--------------------------------------------------------------------------------------------------
_equalStruct(void * pDest,void * pSource,typelib_CompoundTypeDescription * pTypeDescr,uno_QueryInterfaceFunc queryInterface,uno_ReleaseFunc release)77 inline sal_Bool _equalStruct(
78 void * pDest, void *pSource,
79 typelib_CompoundTypeDescription * pTypeDescr,
80 uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
81 SAL_THROW( () )
82 {
83 if (pTypeDescr->pBaseTypeDescription &&
84 !equalStruct( pDest, pSource, pTypeDescr->pBaseTypeDescription, queryInterface, release ))
85 {
86 return sal_False;
87 }
88
89 typelib_TypeDescriptionReference ** ppTypeRefs = pTypeDescr->ppTypeRefs;
90 sal_Int32 * pMemberOffsets = pTypeDescr->pMemberOffsets;
91 sal_Int32 nDescr = pTypeDescr->nMembers;
92
93 while (nDescr--)
94 {
95 sal_Int32 nOffset = pMemberOffsets[nDescr];
96 if (! ::uno_type_equalData( (char *)pDest + nOffset,
97 ppTypeRefs[nDescr],
98 (char *)pSource + nOffset,
99 ppTypeRefs[nDescr],
100 queryInterface, release ))
101 {
102 return sal_False;
103 }
104 }
105 return sal_True;
106 }
107 //==================================================================================================
108 sal_Bool equalSequence(
109 uno_Sequence * pDest, uno_Sequence * pSource,
110 typelib_TypeDescriptionReference * pElementType,
111 uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
112 SAL_THROW( () );
113 //--------------------------------------------------------------------------------------------------
_equalSequence(uno_Sequence * pDest,uno_Sequence * pSource,typelib_TypeDescriptionReference * pElementType,uno_QueryInterfaceFunc queryInterface,uno_ReleaseFunc release)114 inline sal_Bool _equalSequence(
115 uno_Sequence * pDest, uno_Sequence * pSource,
116 typelib_TypeDescriptionReference * pElementType,
117 uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
118 SAL_THROW( () )
119 {
120 if (pDest == pSource)
121 return sal_True;
122 sal_Int32 nElements = pDest->nElements;
123 if (nElements != pSource->nElements)
124 return sal_False;
125 if (! nElements)
126 return sal_True;
127
128 void * pDestElements = pDest->elements;
129 void * pSourceElements = pSource->elements;
130
131 switch (pElementType->eTypeClass)
132 {
133 case typelib_TypeClass_CHAR:
134 return (0 == ::rtl_compareMemory( pDestElements, pSourceElements, sizeof(sal_Unicode) * nElements ));
135 case typelib_TypeClass_BOOLEAN:
136 {
137 for ( sal_Int32 nPos = nElements; nPos--; )
138 {
139 if ((((sal_Bool *)pDestElements)[nPos] != sal_False) !=
140 (((sal_Bool *)pSourceElements)[nPos] != sal_False))
141 {
142 return sal_False;
143 }
144 }
145 return sal_True;
146 }
147 case typelib_TypeClass_BYTE:
148 return (0 == ::rtl_compareMemory( pDestElements, pSourceElements, sizeof(sal_Int8) * nElements ));
149 case typelib_TypeClass_SHORT:
150 case typelib_TypeClass_UNSIGNED_SHORT:
151 return (0 == ::rtl_compareMemory( pDestElements, pSourceElements, sizeof(sal_Int16) * nElements ));
152 case typelib_TypeClass_LONG:
153 case typelib_TypeClass_UNSIGNED_LONG:
154 return (0 == ::rtl_compareMemory( pDestElements, pSourceElements, sizeof(sal_Int32) * nElements ));
155 case typelib_TypeClass_HYPER:
156 case typelib_TypeClass_UNSIGNED_HYPER:
157 return (0 == ::rtl_compareMemory( pDestElements, pSourceElements, sizeof(sal_Int64) * nElements ));
158 case typelib_TypeClass_FLOAT:
159 {
160 for ( sal_Int32 nPos = nElements; nPos--; )
161 {
162 if (((float *)pDestElements)[nPos] != ((float *)pSourceElements)[nPos])
163 return sal_False;
164 }
165 return sal_True;
166 }
167 case typelib_TypeClass_DOUBLE:
168 {
169 for ( sal_Int32 nPos = nElements; nPos--; )
170 {
171 if (((double *)pDestElements)[nPos] != ((double *)pSourceElements)[nPos])
172 return sal_False;
173 }
174 return sal_True;
175 }
176 case typelib_TypeClass_STRING:
177 {
178 for ( sal_Int32 nPos = nElements; nPos--; )
179 {
180 if (! ((::rtl::OUString *)pDestElements +nPos)->equals( ((const ::rtl::OUString *)pSourceElements)[nPos] ))
181 return sal_False;
182 }
183 return sal_True;
184 }
185 case typelib_TypeClass_TYPE:
186 {
187 for ( sal_Int32 nPos = nElements; nPos--; )
188 {
189 if (! _type_equals( ((typelib_TypeDescriptionReference **)pDestElements)[nPos],
190 ((typelib_TypeDescriptionReference **)pSourceElements)[nPos] ))
191 {
192 return sal_False;
193 }
194 }
195 return sal_True;
196 }
197 case typelib_TypeClass_ANY:
198 {
199 for ( sal_Int32 nPos = nElements; nPos--; )
200 {
201 uno_Any * pDest2 = (uno_Any *)pDestElements + nPos;
202 uno_Any * pSource2 = (uno_Any *)pSourceElements + nPos;
203 if (! ::uno_type_equalData( pDest2->pData, pDest2->pType,
204 pSource2->pData, pSource2->pType,
205 queryInterface, release ))
206 {
207 return sal_False;
208 }
209 }
210 return sal_True;
211 }
212 case typelib_TypeClass_ENUM:
213 return (0 == ::rtl_compareMemory( pDestElements, pSourceElements, sizeof(sal_Int32) * nElements ));
214 case typelib_TypeClass_STRUCT:
215 case typelib_TypeClass_EXCEPTION:
216 {
217 typelib_TypeDescription * pElementTypeDescr = 0;
218 TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
219 sal_Int32 nElementSize = pElementTypeDescr->nSize;
220 for ( sal_Int32 nPos = nElements; nPos--; )
221 {
222 if (! _equalStruct( (char *)pDestElements + (nPos * nElementSize),
223 (char *)pSourceElements + (nPos * nElementSize),
224 (typelib_CompoundTypeDescription *)pElementTypeDescr,
225 queryInterface, release ))
226 {
227 TYPELIB_DANGER_RELEASE( pElementTypeDescr );
228 return sal_False;
229 }
230 }
231 TYPELIB_DANGER_RELEASE( pElementTypeDescr );
232 return sal_True;
233 }
234 case typelib_TypeClass_UNION:
235 {
236 typelib_TypeDescription * pElementTypeDescr = 0;
237 TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
238 sal_Int32 nElementSize = pElementTypeDescr->nSize;
239 sal_Int32 nValueOffset = ((typelib_UnionTypeDescription *)pElementTypeDescr)->nValueOffset;
240 for ( sal_Int32 nPos = nElements; nPos--; )
241 {
242 char * pDest2 = (char *)pDestElements + (nPos * nElementSize);
243 char * pSource2 = (char *)pSourceElements + (nPos * nElementSize);
244 typelib_TypeDescriptionReference * pSetType = _unionGetSetType(
245 pDest2, pElementTypeDescr );
246 sal_Bool bRet = ::uno_type_equalData(
247 pDest2 + nValueOffset, pSetType,
248 pSource2 + nValueOffset, pSetType,
249 queryInterface, release );
250 ::typelib_typedescriptionreference_release( pSetType );
251 if (! bRet)
252 {
253 TYPELIB_DANGER_RELEASE( pElementTypeDescr );
254 return sal_False;
255 }
256 }
257 TYPELIB_DANGER_RELEASE( pElementTypeDescr );
258 return sal_True;
259 }
260 case typelib_TypeClass_SEQUENCE: // sequence of sequence
261 {
262 typelib_TypeDescription * pElementTypeDescr = 0;
263 TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
264 typelib_TypeDescriptionReference * pSeqElementType =
265 ((typelib_IndirectTypeDescription *)pElementTypeDescr)->pType;
266 for ( sal_Int32 nPos = nElements; nPos--; )
267 {
268 if (! equalSequence( ((uno_Sequence **)pDestElements)[nPos],
269 ((uno_Sequence **)pSourceElements)[nPos],
270 pSeqElementType, queryInterface, release ))
271 {
272 TYPELIB_DANGER_RELEASE( pElementTypeDescr );
273 return sal_False;
274 }
275 }
276 TYPELIB_DANGER_RELEASE( pElementTypeDescr );
277 return sal_True;
278 }
279 case typelib_TypeClass_INTERFACE:
280 {
281 for ( sal_Int32 nPos = nElements; nPos--; )
282 {
283 if (! _equalObject( ((void **)pDestElements)[nPos], ((void **)pSourceElements)[nPos],
284 queryInterface, release ))
285 {
286 return sal_False;
287 }
288 }
289 return sal_True;
290 }
291 default:
292 OSL_ASSERT(false);
293 return sal_False;
294 }
295 }
296 //--------------------------------------------------------------------------------------------------
_equalData(void * pDest,typelib_TypeDescriptionReference * pDestType,typelib_TypeDescription * pDestTypeDescr,void * pSource,typelib_TypeDescriptionReference * pSourceType,typelib_TypeDescription * pSourceTypeDescr,uno_QueryInterfaceFunc queryInterface,uno_ReleaseFunc release)297 inline sal_Bool _equalData(
298 void * pDest,
299 typelib_TypeDescriptionReference * pDestType, typelib_TypeDescription * pDestTypeDescr,
300 void * pSource,
301 typelib_TypeDescriptionReference * pSourceType, typelib_TypeDescription * pSourceTypeDescr,
302 uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
303 SAL_THROW( () )
304 {
305 typelib_TypeClass eSourceTypeClass, eDestTypeClass;
306 while (typelib_TypeClass_ANY == (eDestTypeClass = pDestType->eTypeClass))
307 {
308 pDestTypeDescr = 0;
309 pDestType = ((uno_Any *)pDest)->pType;
310 pDest = ((uno_Any *)pDest)->pData;
311 }
312 while (typelib_TypeClass_ANY == (eSourceTypeClass = pSourceType->eTypeClass))
313 {
314 pSourceTypeDescr = 0;
315 pSourceType = ((uno_Any *)pSource)->pType;
316 pSource = ((uno_Any *)pSource)->pData;
317 }
318
319 switch (eDestTypeClass)
320 {
321 case typelib_TypeClass_VOID:
322 return eSourceTypeClass == typelib_TypeClass_VOID;
323 case typelib_TypeClass_CHAR:
324 return eSourceTypeClass == typelib_TypeClass_CHAR
325 && *(sal_Unicode *)pDest == *(sal_Unicode *)pSource;
326 case typelib_TypeClass_BOOLEAN:
327 return eSourceTypeClass == typelib_TypeClass_BOOLEAN
328 && ((*(sal_Bool *)pDest != sal_False)
329 == (*(sal_Bool *)pSource != sal_False));
330 case typelib_TypeClass_BYTE:
331 switch (eSourceTypeClass)
332 {
333 case typelib_TypeClass_BYTE:
334 return (*(sal_Int8 *)pDest == *(sal_Int8 *)pSource);
335 case typelib_TypeClass_SHORT:
336 return ((sal_Int16)*(sal_Int8 *)pDest == *(sal_Int16 *)pSource);
337 case typelib_TypeClass_UNSIGNED_SHORT:
338 return ((sal_Int32)*(sal_Int8 *)pDest == (sal_Int32)*(sal_uInt16 *)pSource);
339 case typelib_TypeClass_LONG:
340 return ((sal_Int32)*(sal_Int8 *)pDest == *(sal_Int32 *)pSource);
341 case typelib_TypeClass_UNSIGNED_LONG:
342 return ((sal_Int64)*(sal_Int8 *)pDest == (sal_Int64)*(sal_uInt32 *)pSource);
343 case typelib_TypeClass_HYPER:
344 return ((sal_Int64)*(sal_Int8 *)pDest == *(sal_Int64 *)pSource);
345 case typelib_TypeClass_UNSIGNED_HYPER:
346 return (*(sal_Int8 *)pDest >= 0 &&
347 (sal_Int64)*(sal_Int8 *)pDest == *(sal_Int64 *)pSource); // same size
348 case typelib_TypeClass_FLOAT:
349 return ((float)*(sal_Int8 *)pDest == *(float *)pSource);
350 case typelib_TypeClass_DOUBLE:
351 return ((double)*(sal_Int8 *)pDest == *(double *)pSource);
352 default:
353 return sal_False;
354 }
355 case typelib_TypeClass_SHORT:
356 switch (eSourceTypeClass)
357 {
358 case typelib_TypeClass_BYTE:
359 return (*(sal_Int16 *)pDest == (sal_Int16)*(sal_Int8 *)pSource);
360 case typelib_TypeClass_SHORT:
361 return (*(sal_Int16 *)pDest == *(sal_Int16 *)pSource);
362 case typelib_TypeClass_UNSIGNED_SHORT:
363 return ((sal_Int32)*(sal_Int16 *)pDest == (sal_Int32)*(sal_uInt16 *)pSource);
364 case typelib_TypeClass_LONG:
365 return ((sal_Int32)*(sal_Int16 *)pDest == *(sal_Int32 *)pSource);
366 case typelib_TypeClass_UNSIGNED_LONG:
367 return ((sal_Int64)*(sal_Int16 *)pDest == (sal_Int64)*(sal_uInt32 *)pSource);
368 case typelib_TypeClass_HYPER:
369 return ((sal_Int64)*(sal_Int16 *)pDest == *(sal_Int64 *)pSource);
370 case typelib_TypeClass_UNSIGNED_HYPER:
371 return (*(sal_Int16 *)pDest >= 0 &&
372 (sal_Int64)*(sal_Int16 *)pDest == *(sal_Int64 *)pSource); // same size
373 case typelib_TypeClass_FLOAT:
374 return ((float)*(sal_Int16 *)pDest == *(float *)pSource);
375 case typelib_TypeClass_DOUBLE:
376 return ((double)*(sal_Int16 *)pDest == *(double *)pSource);
377 default:
378 return sal_False;
379 }
380 case typelib_TypeClass_UNSIGNED_SHORT:
381 switch (eSourceTypeClass)
382 {
383 case typelib_TypeClass_BYTE:
384 return ((sal_Int32)*(sal_uInt16 *)pDest == (sal_Int32)*(sal_Int8 *)pSource);
385 case typelib_TypeClass_SHORT:
386 return ((sal_Int32)*(sal_uInt16 *)pDest == (sal_Int32)*(sal_Int16 *)pSource);
387 case typelib_TypeClass_UNSIGNED_SHORT:
388 return (*(sal_uInt16 *)pDest == *(sal_uInt16 *)pSource);
389 case typelib_TypeClass_LONG:
390 return ((sal_Int32)*(sal_uInt16 *)pDest == *(sal_Int32 *)pSource);
391 case typelib_TypeClass_UNSIGNED_LONG:
392 return ((sal_uInt32)*(sal_uInt16 *)pDest == *(sal_uInt32 *)pSource);
393 case typelib_TypeClass_HYPER:
394 return ((sal_Int64)*(sal_uInt16 *)pDest == *(sal_Int64 *)pSource);
395 case typelib_TypeClass_UNSIGNED_HYPER:
396 return ((sal_uInt64)*(sal_uInt16 *)pDest == *(sal_uInt64 *)pSource);
397 case typelib_TypeClass_FLOAT:
398 return ((float)*(sal_uInt16 *)pDest == *(float *)pSource);
399 case typelib_TypeClass_DOUBLE:
400 return ((double)*(sal_uInt16 *)pDest == *(double *)pSource);
401 default:
402 return sal_False;
403 }
404 case typelib_TypeClass_LONG:
405 switch (eSourceTypeClass)
406 {
407 case typelib_TypeClass_BYTE:
408 return (*(sal_Int32 *)pDest == (sal_Int32)*(sal_Int8 *)pSource);
409 case typelib_TypeClass_SHORT:
410 return (*(sal_Int32 *)pDest == (sal_Int32)*(sal_Int16 *)pSource);
411 case typelib_TypeClass_UNSIGNED_SHORT:
412 return (*(sal_Int32 *)pDest == (sal_Int32)*(sal_uInt16 *)pSource);
413 case typelib_TypeClass_LONG:
414 return (*(sal_Int32 *)pDest == *(sal_Int32 *)pSource);
415 case typelib_TypeClass_UNSIGNED_LONG:
416 return ((sal_Int64)*(sal_Int32 *)pDest == (sal_Int64)*(sal_uInt32 *)pSource);
417 case typelib_TypeClass_HYPER:
418 return ((sal_Int64)*(sal_Int32 *)pDest == *(sal_Int64 *)pSource);
419 case typelib_TypeClass_UNSIGNED_HYPER:
420 return (*(sal_Int32 *)pDest >= 0 &&
421 (sal_Int64)*(sal_Int32 *)pDest == *(sal_Int64 *)pSource); // same size
422 case typelib_TypeClass_FLOAT:
423 return ((float)*(sal_Int32 *)pDest == *(float *)pSource);
424 case typelib_TypeClass_DOUBLE:
425 return ((double)*(sal_Int32 *)pDest == *(double *)pSource);
426 default:
427 return sal_False;
428 }
429 case typelib_TypeClass_UNSIGNED_LONG:
430 switch (eSourceTypeClass)
431 {
432 case typelib_TypeClass_BYTE:
433 return ((sal_Int64)*(sal_uInt32 *)pDest == (sal_Int64)*(sal_Int8 *)pSource);
434 case typelib_TypeClass_SHORT:
435 return ((sal_Int64)*(sal_uInt32 *)pDest == (sal_Int64)*(sal_Int16 *)pSource);
436 case typelib_TypeClass_UNSIGNED_SHORT:
437 return (*(sal_uInt32 *)pDest == (sal_uInt32)*(sal_uInt16 *)pSource);
438 case typelib_TypeClass_LONG:
439 return ((sal_Int64)*(sal_uInt32 *)pDest == (sal_Int64)*(sal_Int32 *)pSource);
440 case typelib_TypeClass_UNSIGNED_LONG:
441 return (*(sal_uInt32 *)pDest == *(sal_uInt32 *)pSource);
442 case typelib_TypeClass_HYPER:
443 return ((sal_Int64)*(sal_uInt32 *)pDest == *(sal_Int64 *)pSource);
444 case typelib_TypeClass_UNSIGNED_HYPER:
445 return ((sal_uInt64)*(sal_uInt32 *)pDest == *(sal_uInt64 *)pSource);
446 case typelib_TypeClass_FLOAT:
447 return ((float)*(sal_uInt32 *)pDest == *(float *)pSource);
448 case typelib_TypeClass_DOUBLE:
449 return ((double)*(sal_uInt32 *)pDest == *(double *)pSource);
450 default:
451 return sal_False;
452 }
453 case typelib_TypeClass_HYPER:
454 switch (eSourceTypeClass)
455 {
456 case typelib_TypeClass_BYTE:
457 return (*(sal_Int64 *)pDest == (sal_Int64)*(sal_Int8 *)pSource);
458 case typelib_TypeClass_SHORT:
459 return (*(sal_Int64 *)pDest == (sal_Int64)*(sal_Int16 *)pSource);
460 case typelib_TypeClass_UNSIGNED_SHORT:
461 return (*(sal_Int64 *)pDest == (sal_Int64)*(sal_uInt16 *)pSource);
462 case typelib_TypeClass_LONG:
463 return (*(sal_Int64 *)pDest == (sal_Int64)*(sal_Int32 *)pSource);
464 case typelib_TypeClass_UNSIGNED_LONG:
465 return (*(sal_Int64 *)pDest == (sal_Int64)*(sal_uInt32 *)pSource);
466 case typelib_TypeClass_HYPER:
467 return (*(sal_Int64 *)pDest == *(sal_Int64 *)pSource);
468 case typelib_TypeClass_UNSIGNED_HYPER:
469 return (*(sal_Int64 *)pDest >= 0 &&
470 *(sal_Int64 *)pDest == *(sal_Int64 *)pSource); // same size
471 case typelib_TypeClass_FLOAT:
472 return ((float)*(sal_Int64 *)pDest == *(float *)pSource);
473 case typelib_TypeClass_DOUBLE:
474 return ((double)*(sal_Int64 *)pDest == *(double *)pSource);
475 default:
476 return sal_False;
477 }
478 case typelib_TypeClass_UNSIGNED_HYPER:
479 switch (eSourceTypeClass)
480 {
481 case typelib_TypeClass_BYTE:
482 return (*(sal_Int8 *)pSource >= 0 &&
483 *(sal_uInt64 *)pDest == (sal_uInt64)*(sal_Int8 *)pSource);
484 case typelib_TypeClass_SHORT:
485 return (*(sal_Int16 *)pSource >= 0 &&
486 *(sal_uInt64 *)pDest == (sal_uInt64)*(sal_Int16 *)pSource);
487 case typelib_TypeClass_UNSIGNED_SHORT:
488 return (*(sal_uInt64 *)pDest == (sal_uInt64)*(sal_uInt16 *)pSource);
489 case typelib_TypeClass_LONG:
490 return (*(sal_Int32 *)pSource >= 0 &&
491 *(sal_uInt64 *)pDest == (sal_uInt64)*(sal_Int32 *)pSource);
492 case typelib_TypeClass_UNSIGNED_LONG:
493 return (*(sal_uInt64 *)pDest == (sal_uInt64)*(sal_uInt32 *)pSource);
494 case typelib_TypeClass_HYPER:
495 return (*(sal_Int64 *)pSource >= 0 &&
496 *(sal_uInt64 *)pDest == (sal_uInt64)*(sal_Int64 *)pSource);
497 case typelib_TypeClass_UNSIGNED_HYPER:
498 return (*(sal_uInt64 *)pDest == *(sal_uInt64 *)pSource);
499 case typelib_TypeClass_FLOAT:
500 if (::floor( *(float *)pSource ) != *(float *)pSource || *(float *)pSource < 0)
501 return sal_False;
502 return (*(sal_uInt64 *)pDest == (sal_uInt64)*(float *)pSource);
503 case typelib_TypeClass_DOUBLE:
504 if (::floor( *(double *)pSource ) != *(double *)pSource || *(double *)pSource < 0)
505 return sal_False;
506 return (*(sal_uInt64 *)pDest == (sal_uInt64)*(double *)pSource);
507 default:
508 return sal_False;
509 }
510 case typelib_TypeClass_FLOAT:
511 switch (eSourceTypeClass)
512 {
513 case typelib_TypeClass_BYTE:
514 return (*(float *)pDest == (float)*(sal_Int8 *)pSource);
515 case typelib_TypeClass_SHORT:
516 return (*(float *)pDest == (float)*(sal_Int16 *)pSource);
517 case typelib_TypeClass_UNSIGNED_SHORT:
518 return (*(float *)pDest == (float)*(sal_uInt16 *)pSource);
519 case typelib_TypeClass_LONG:
520 return (*(float *)pDest == (float)*(sal_Int32 *)pSource);
521 case typelib_TypeClass_UNSIGNED_LONG:
522 return (*(float *)pDest == (float)*(sal_uInt32 *)pSource);
523 case typelib_TypeClass_HYPER:
524 return (*(float *)pDest == (float)*(sal_Int64 *)pSource);
525 case typelib_TypeClass_UNSIGNED_HYPER:
526 if (::floor( *(float *)pDest ) != *(float *)pDest || *(float *)pDest < 0)
527 return sal_False;
528 return ((sal_uInt64)*(float *)pDest == *(sal_uInt64 *)pSource);
529 case typelib_TypeClass_FLOAT:
530 return (*(float *)pDest == *(float *)pSource);
531 case typelib_TypeClass_DOUBLE:
532 return ((double)*(float *)pDest == *(double *)pSource);
533 default:
534 return sal_False;
535 }
536 case typelib_TypeClass_DOUBLE:
537 switch (eSourceTypeClass)
538 {
539 case typelib_TypeClass_BYTE:
540 return (*(double *)pDest == (double)*(sal_Int8 *)pSource);
541 case typelib_TypeClass_SHORT:
542 return (*(double *)pDest == (double)*(sal_Int16 *)pSource);
543 case typelib_TypeClass_UNSIGNED_SHORT:
544 return (*(double *)pDest == (double)*(sal_uInt16 *)pSource);
545 case typelib_TypeClass_LONG:
546 return (*(double *)pDest == (double)*(sal_Int32 *)pSource);
547 case typelib_TypeClass_UNSIGNED_LONG:
548 return (*(double *)pDest == (double)*(sal_uInt32 *)pSource);
549 case typelib_TypeClass_HYPER:
550 return (*(double *)pDest == (double)*(sal_Int64 *)pSource);
551 case typelib_TypeClass_UNSIGNED_HYPER:
552 if (::floor( *(double *)pDest ) != *(double *)pDest || *(double *)pDest < 0)
553 return sal_False;
554 return ((sal_uInt64)*(double *)pDest == *(sal_uInt64 *)pSource);
555 case typelib_TypeClass_FLOAT:
556 return (*(double *)pDest == (double)*(float *)pSource);
557 case typelib_TypeClass_DOUBLE:
558 return (*(double *)pDest == *(double *)pSource);
559 default:
560 return sal_False;
561 }
562 case typelib_TypeClass_STRING:
563 return eSourceTypeClass == typelib_TypeClass_STRING
564 && ((::rtl::OUString *)pDest)->equals(
565 *(::rtl::OUString const *)pSource );
566 case typelib_TypeClass_TYPE:
567 return eSourceTypeClass == typelib_TypeClass_TYPE
568 && _type_equals(
569 *(typelib_TypeDescriptionReference **)pDest,
570 *(typelib_TypeDescriptionReference **)pSource );
571 case typelib_TypeClass_ENUM:
572 return (_type_equals( pDestType, pSourceType ) &&
573 *(sal_Int32 *)pDest == *(sal_Int32 *)pSource);
574 case typelib_TypeClass_STRUCT:
575 case typelib_TypeClass_EXCEPTION:
576 if (! _type_equals( pDestType, pSourceType ))
577 return sal_False;
578 if (pDestTypeDescr)
579 {
580 return _equalStruct(
581 pDest, pSource,
582 (typelib_CompoundTypeDescription *)pDestTypeDescr,
583 queryInterface, release );
584 }
585 else
586 {
587 TYPELIB_DANGER_GET( &pDestTypeDescr, pDestType );
588 sal_Bool bRet = _equalStruct(
589 pDest, pSource,
590 (typelib_CompoundTypeDescription *)pDestTypeDescr,
591 queryInterface, release );
592 TYPELIB_DANGER_RELEASE( pDestTypeDescr );
593 return bRet;
594 }
595 case typelib_TypeClass_UNION:
596 if (_type_equals( pDestType, pSourceType ) &&
597 *(sal_Int64 *)pDest == *(sal_Int64 *)pSource) // same discriminant
598 {
599 sal_Bool bRet;
600 if (pDestTypeDescr)
601 {
602 typelib_TypeDescriptionReference * pSetType = _unionGetSetType(
603 pDest, pDestTypeDescr );
604 bRet = ::uno_type_equalData(
605 (char *)pDest + ((typelib_UnionTypeDescription *)pDestTypeDescr)->nValueOffset,
606 pSetType,
607 (char *)pSource + ((typelib_UnionTypeDescription *)pDestTypeDescr)->nValueOffset,
608 pSetType,
609 queryInterface, release );
610 typelib_typedescriptionreference_release( pSetType );
611 }
612 else
613 {
614 TYPELIB_DANGER_GET( &pDestTypeDescr, pDestType );
615 typelib_TypeDescriptionReference * pSetType = _unionGetSetType(
616 pDest, pDestTypeDescr );
617 bRet = ::uno_type_equalData(
618 (char *)pDest + ((typelib_UnionTypeDescription *)pDestTypeDescr)->nValueOffset,
619 pSetType,
620 (char *)pSource + ((typelib_UnionTypeDescription *)pDestTypeDescr)->nValueOffset,
621 pSetType,
622 queryInterface, release );
623 typelib_typedescriptionreference_release( pSetType );
624 TYPELIB_DANGER_RELEASE( pDestTypeDescr );
625 }
626 return bRet;
627 }
628 return sal_False;
629 case typelib_TypeClass_SEQUENCE:
630 if (_type_equals( pDestType, pSourceType ))
631 {
632 if (pDestTypeDescr)
633 {
634 return _equalSequence(
635 *(uno_Sequence **)pDest, *(uno_Sequence **)pSource,
636 ((typelib_IndirectTypeDescription *)pDestTypeDescr)->pType,
637 queryInterface, release );
638 }
639 else
640 {
641 TYPELIB_DANGER_GET( &pDestTypeDescr, pDestType );
642 sal_Bool bRet = _equalSequence(
643 *(uno_Sequence **)pDest, *(uno_Sequence **)pSource,
644 ((typelib_IndirectTypeDescription *)pDestTypeDescr)->pType,
645 queryInterface, release );
646 TYPELIB_DANGER_RELEASE( pDestTypeDescr );
647 return bRet;
648 }
649 }
650 return sal_False;
651 case typelib_TypeClass_INTERFACE:
652 if (typelib_TypeClass_INTERFACE == eSourceTypeClass)
653 return _equalObject( *(void **)pDest, *(void **)pSource, queryInterface, release );
654 break;
655 default:
656 OSL_ASSERT(false);
657 break;
658 }
659 return sal_False;
660 }
661
662 }
663
664 #endif
665