Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef INCLUDED_CPPU_SOURCE_UNO_EQ_HXX
20 : #define INCLUDED_CPPU_SOURCE_UNO_EQ_HXX
21 :
22 : #include <math.h>
23 :
24 : #include "prim.hxx"
25 : #include "destr.hxx"
26 :
27 :
28 : namespace cppu
29 : {
30 :
31 :
32 : //#### equality ####################################################################################
33 :
34 :
35 :
36 8640 : inline bool _equalObject(
37 : void * pI1, void * pI2,
38 : uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
39 : {
40 8640 : if (pI1 == pI2)
41 5918 : return true;
42 2722 : if ((0 == pI1) || (0 == pI2))
43 214 : return false;
44 2508 : bool bRet = false;
45 :
46 : typelib_TypeDescriptionReference * type_XInterface =
47 2508 : * typelib_static_type_getByTypeClass( typelib_TypeClass_INTERFACE );
48 2508 : if (0 == queryInterface)
49 0 : queryInterface = binuno_queryInterface;
50 2508 : pI1 = (*queryInterface)( pI1, type_XInterface );
51 2508 : if (0 != pI1)
52 : {
53 2508 : pI2 = (*queryInterface)( pI2, type_XInterface );
54 2508 : if (0 != pI2)
55 : {
56 2508 : bRet = (pI1 == pI2);
57 2508 : _release( pI2, release );
58 : }
59 2508 : _release( pI1, release );
60 : }
61 2508 : return bRet;
62 : }
63 :
64 :
65 : bool equalStruct(
66 : void * pDest, void *pSource,
67 : typelib_CompoundTypeDescription * pTypeDescr,
68 : uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release );
69 :
70 1003430 : inline bool _equalStruct(
71 : void * pDest, void *pSource,
72 : typelib_CompoundTypeDescription * pTypeDescr,
73 : uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
74 : {
75 1003948 : if (pTypeDescr->pBaseTypeDescription &&
76 518 : !equalStruct( pDest, pSource, pTypeDescr->pBaseTypeDescription, queryInterface, release ))
77 : {
78 22 : return false;
79 : }
80 :
81 1003408 : typelib_TypeDescriptionReference ** ppTypeRefs = pTypeDescr->ppTypeRefs;
82 1003408 : sal_Int32 * pMemberOffsets = pTypeDescr->pMemberOffsets;
83 1003408 : sal_Int32 nDescr = pTypeDescr->nMembers;
84 :
85 4726100 : while (nDescr--)
86 : {
87 3040149 : sal_Int32 nOffset = pMemberOffsets[nDescr];
88 6080298 : if (! ::uno_type_equalData( (char *)pDest + nOffset,
89 3040149 : ppTypeRefs[nDescr],
90 3040149 : (char *)pSource + nOffset,
91 3040149 : ppTypeRefs[nDescr],
92 9120447 : queryInterface, release ))
93 : {
94 320865 : return false;
95 : }
96 : }
97 682543 : return true;
98 : }
99 :
100 : bool equalSequence(
101 : uno_Sequence * pDest, uno_Sequence * pSource,
102 : typelib_TypeDescriptionReference * pElementType,
103 : uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release );
104 :
105 497091 : inline bool _equalSequence(
106 : uno_Sequence * pDest, uno_Sequence * pSource,
107 : typelib_TypeDescriptionReference * pElementType,
108 : uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
109 : {
110 497091 : if (pDest == pSource)
111 99070 : return true;
112 398021 : sal_Int32 nElements = pDest->nElements;
113 398021 : if (nElements != pSource->nElements)
114 129496 : return false;
115 268525 : if (! nElements)
116 312 : return true;
117 :
118 268213 : void * pDestElements = pDest->elements;
119 268213 : void * pSourceElements = pSource->elements;
120 :
121 268213 : switch (pElementType->eTypeClass)
122 : {
123 : case typelib_TypeClass_CHAR:
124 0 : return (0 == memcmp( pDestElements, pSourceElements, sizeof(sal_Unicode) * nElements ));
125 : case typelib_TypeClass_BOOLEAN:
126 : {
127 20 : for ( sal_Int32 nPos = nElements; nPos--; )
128 : {
129 24 : if ((((sal_Bool *)pDestElements)[nPos] != sal_False) !=
130 12 : (((sal_Bool *)pSourceElements)[nPos] != sal_False))
131 : {
132 0 : return false;
133 : }
134 : }
135 4 : return true;
136 : }
137 : case typelib_TypeClass_BYTE:
138 48 : return (0 == memcmp( pDestElements, pSourceElements, sizeof(sal_Int8) * nElements ));
139 : case typelib_TypeClass_SHORT:
140 : case typelib_TypeClass_UNSIGNED_SHORT:
141 104 : return (0 == memcmp( pDestElements, pSourceElements, sizeof(sal_Int16) * nElements ));
142 : case typelib_TypeClass_LONG:
143 : case typelib_TypeClass_UNSIGNED_LONG:
144 760 : return (0 == memcmp( pDestElements, pSourceElements, sizeof(sal_Int32) * nElements ));
145 : case typelib_TypeClass_HYPER:
146 : case typelib_TypeClass_UNSIGNED_HYPER:
147 8 : return (0 == memcmp( pDestElements, pSourceElements, sizeof(sal_Int64) * nElements ));
148 : case typelib_TypeClass_FLOAT:
149 : {
150 20 : for ( sal_Int32 nPos = nElements; nPos--; )
151 : {
152 12 : if (((float *)pDestElements)[nPos] != ((float *)pSourceElements)[nPos])
153 0 : return false;
154 : }
155 4 : return true;
156 : }
157 : case typelib_TypeClass_DOUBLE:
158 : {
159 20 : for ( sal_Int32 nPos = nElements; nPos--; )
160 : {
161 12 : if (((double *)pDestElements)[nPos] != ((double *)pSourceElements)[nPos])
162 0 : return false;
163 : }
164 4 : return true;
165 : }
166 : case typelib_TypeClass_STRING:
167 : {
168 5514 : for ( sal_Int32 nPos = nElements; nPos--; )
169 : {
170 4272 : if (! ((::rtl::OUString *)pDestElements +nPos)->equals( ((const ::rtl::OUString *)pSourceElements)[nPos] ))
171 6 : return false;
172 : }
173 618 : return true;
174 : }
175 : case typelib_TypeClass_TYPE:
176 : {
177 0 : for ( sal_Int32 nPos = nElements; nPos--; )
178 : {
179 0 : if (! _type_equals( ((typelib_TypeDescriptionReference **)pDestElements)[nPos],
180 0 : ((typelib_TypeDescriptionReference **)pSourceElements)[nPos] ))
181 : {
182 0 : return false;
183 : }
184 : }
185 0 : return true;
186 : }
187 : case typelib_TypeClass_ANY:
188 : {
189 444 : for ( sal_Int32 nPos = nElements; nPos--; )
190 : {
191 229 : uno_Any * pDest2 = (uno_Any *)pDestElements + nPos;
192 229 : uno_Any * pSource2 = (uno_Any *)pSourceElements + nPos;
193 229 : if (! ::uno_type_equalData( pDest2->pData, pDest2->pType,
194 : pSource2->pData, pSource2->pType,
195 229 : queryInterface, release ))
196 : {
197 19 : return false;
198 : }
199 : }
200 98 : return true;
201 : }
202 : case typelib_TypeClass_ENUM:
203 4 : return (0 == memcmp( pDestElements, pSourceElements, sizeof(sal_Int32) * nElements ));
204 : case typelib_TypeClass_STRUCT:
205 : case typelib_TypeClass_EXCEPTION:
206 : {
207 261098 : typelib_TypeDescription * pElementTypeDescr = 0;
208 261098 : TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
209 261098 : sal_Int32 nElementSize = pElementTypeDescr->nSize;
210 1019920 : for ( sal_Int32 nPos = nElements; nPos--; )
211 : {
212 2122398 : if (! _equalStruct( (char *)pDestElements + (nPos * nElementSize),
213 1414932 : (char *)pSourceElements + (nPos * nElementSize),
214 : (typelib_CompoundTypeDescription *)pElementTypeDescr,
215 2829864 : queryInterface, release ))
216 : {
217 209742 : TYPELIB_DANGER_RELEASE( pElementTypeDescr );
218 209742 : return false;
219 : }
220 : }
221 51356 : TYPELIB_DANGER_RELEASE( pElementTypeDescr );
222 51356 : return true;
223 : }
224 : case typelib_TypeClass_SEQUENCE: // sequence of sequence
225 : {
226 2566 : typelib_TypeDescription * pElementTypeDescr = 0;
227 2566 : TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
228 : typelib_TypeDescriptionReference * pSeqElementType =
229 2566 : ((typelib_IndirectTypeDescription *)pElementTypeDescr)->pType;
230 5558 : for ( sal_Int32 nPos = nElements; nPos--; )
231 : {
232 5244 : if (! equalSequence( ((uno_Sequence **)pDestElements)[nPos],
233 2622 : ((uno_Sequence **)pSourceElements)[nPos],
234 5244 : pSeqElementType, queryInterface, release ))
235 : {
236 2196 : TYPELIB_DANGER_RELEASE( pElementTypeDescr );
237 2196 : return false;
238 : }
239 : }
240 370 : TYPELIB_DANGER_RELEASE( pElementTypeDescr );
241 370 : return true;
242 : }
243 : case typelib_TypeClass_INTERFACE:
244 : {
245 6958 : for ( sal_Int32 nPos = nElements; nPos--; )
246 : {
247 10458 : if (! _equalObject( ((void **)pDestElements)[nPos], ((void **)pSourceElements)[nPos],
248 6972 : queryInterface, release ))
249 : {
250 2272 : return false;
251 : }
252 : }
253 600 : return true;
254 : }
255 : default:
256 : OSL_ASSERT(false);
257 0 : return false;
258 : }
259 : }
260 :
261 4906894 : inline bool _equalData(
262 : void * pDest,
263 : typelib_TypeDescriptionReference * pDestType, typelib_TypeDescription * pDestTypeDescr,
264 : void * pSource,
265 : typelib_TypeDescriptionReference * pSourceType,
266 : uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
267 : {
268 : typelib_TypeClass eSourceTypeClass, eDestTypeClass;
269 10548380 : while (typelib_TypeClass_ANY == (eDestTypeClass = pDestType->eTypeClass))
270 : {
271 734592 : pDestTypeDescr = 0;
272 734592 : pDestType = ((uno_Any *)pDest)->pType;
273 734592 : pDest = ((uno_Any *)pDest)->pData;
274 : }
275 10548380 : while (typelib_TypeClass_ANY == (eSourceTypeClass = pSourceType->eTypeClass))
276 : {
277 734592 : pSourceType = ((uno_Any *)pSource)->pType;
278 734592 : pSource = ((uno_Any *)pSource)->pData;
279 : }
280 :
281 4906894 : switch (eDestTypeClass)
282 : {
283 : case typelib_TypeClass_VOID:
284 48148 : return eSourceTypeClass == typelib_TypeClass_VOID;
285 : case typelib_TypeClass_CHAR:
286 : return eSourceTypeClass == typelib_TypeClass_CHAR
287 60 : && *(sal_Unicode *)pDest == *(sal_Unicode *)pSource;
288 : case typelib_TypeClass_BOOLEAN:
289 : return eSourceTypeClass == typelib_TypeClass_BOOLEAN
290 450088 : && ((*(sal_Bool *)pDest != sal_False)
291 450088 : == (*(sal_Bool *)pSource != sal_False));
292 : case typelib_TypeClass_BYTE:
293 2130 : switch (eSourceTypeClass)
294 : {
295 : case typelib_TypeClass_BYTE:
296 2130 : return (*(sal_Int8 *)pDest == *(sal_Int8 *)pSource);
297 : case typelib_TypeClass_SHORT:
298 0 : return ((sal_Int16)*(sal_Int8 *)pDest == *(sal_Int16 *)pSource);
299 : case typelib_TypeClass_UNSIGNED_SHORT:
300 0 : return ((sal_Int32)*(sal_Int8 *)pDest == (sal_Int32)*(sal_uInt16 *)pSource);
301 : case typelib_TypeClass_LONG:
302 0 : return ((sal_Int32)*(sal_Int8 *)pDest == *(sal_Int32 *)pSource);
303 : case typelib_TypeClass_UNSIGNED_LONG:
304 0 : return ((sal_Int64)*(sal_Int8 *)pDest == (sal_Int64)*(sal_uInt32 *)pSource);
305 : case typelib_TypeClass_HYPER:
306 0 : return ((sal_Int64)*(sal_Int8 *)pDest == *(sal_Int64 *)pSource);
307 : case typelib_TypeClass_UNSIGNED_HYPER:
308 0 : return (*(sal_Int8 *)pDest >= 0 &&
309 0 : (sal_Int64)*(sal_Int8 *)pDest == *(sal_Int64 *)pSource); // same size
310 : case typelib_TypeClass_FLOAT:
311 0 : return ((float)*(sal_Int8 *)pDest == *(float *)pSource);
312 : case typelib_TypeClass_DOUBLE:
313 0 : return ((double)*(sal_Int8 *)pDest == *(double *)pSource);
314 : default:
315 0 : return false;
316 : }
317 : case typelib_TypeClass_SHORT:
318 222376 : switch (eSourceTypeClass)
319 : {
320 : case typelib_TypeClass_BYTE:
321 0 : return (*(sal_Int16 *)pDest == (sal_Int16)*(sal_Int8 *)pSource);
322 : case typelib_TypeClass_SHORT:
323 222368 : return (*(sal_Int16 *)pDest == *(sal_Int16 *)pSource);
324 : case typelib_TypeClass_UNSIGNED_SHORT:
325 0 : return ((sal_Int32)*(sal_Int16 *)pDest == (sal_Int32)*(sal_uInt16 *)pSource);
326 : case typelib_TypeClass_LONG:
327 0 : return ((sal_Int32)*(sal_Int16 *)pDest == *(sal_Int32 *)pSource);
328 : case typelib_TypeClass_UNSIGNED_LONG:
329 0 : return ((sal_Int64)*(sal_Int16 *)pDest == (sal_Int64)*(sal_uInt32 *)pSource);
330 : case typelib_TypeClass_HYPER:
331 0 : return ((sal_Int64)*(sal_Int16 *)pDest == *(sal_Int64 *)pSource);
332 : case typelib_TypeClass_UNSIGNED_HYPER:
333 0 : return (*(sal_Int16 *)pDest >= 0 &&
334 0 : (sal_Int64)*(sal_Int16 *)pDest == *(sal_Int64 *)pSource); // same size
335 : case typelib_TypeClass_FLOAT:
336 0 : return ((float)*(sal_Int16 *)pDest == *(float *)pSource);
337 : case typelib_TypeClass_DOUBLE:
338 0 : return ((double)*(sal_Int16 *)pDest == *(double *)pSource);
339 : default:
340 8 : return false;
341 : }
342 : case typelib_TypeClass_UNSIGNED_SHORT:
343 90 : switch (eSourceTypeClass)
344 : {
345 : case typelib_TypeClass_BYTE:
346 0 : return ((sal_Int32)*(sal_uInt16 *)pDest == (sal_Int32)*(sal_Int8 *)pSource);
347 : case typelib_TypeClass_SHORT:
348 0 : return ((sal_Int32)*(sal_uInt16 *)pDest == (sal_Int32)*(sal_Int16 *)pSource);
349 : case typelib_TypeClass_UNSIGNED_SHORT:
350 90 : return (*(sal_uInt16 *)pDest == *(sal_uInt16 *)pSource);
351 : case typelib_TypeClass_LONG:
352 0 : return ((sal_Int32)*(sal_uInt16 *)pDest == *(sal_Int32 *)pSource);
353 : case typelib_TypeClass_UNSIGNED_LONG:
354 0 : return ((sal_uInt32)*(sal_uInt16 *)pDest == *(sal_uInt32 *)pSource);
355 : case typelib_TypeClass_HYPER:
356 0 : return ((sal_Int64)*(sal_uInt16 *)pDest == *(sal_Int64 *)pSource);
357 : case typelib_TypeClass_UNSIGNED_HYPER:
358 0 : return ((sal_uInt64)*(sal_uInt16 *)pDest == *(sal_uInt64 *)pSource);
359 : case typelib_TypeClass_FLOAT:
360 0 : return ((float)*(sal_uInt16 *)pDest == *(float *)pSource);
361 : case typelib_TypeClass_DOUBLE:
362 0 : return ((double)*(sal_uInt16 *)pDest == *(double *)pSource);
363 : default:
364 0 : return false;
365 : }
366 : case typelib_TypeClass_LONG:
367 1710612 : switch (eSourceTypeClass)
368 : {
369 : case typelib_TypeClass_BYTE:
370 0 : return (*(sal_Int32 *)pDest == (sal_Int32)*(sal_Int8 *)pSource);
371 : case typelib_TypeClass_SHORT:
372 0 : return (*(sal_Int32 *)pDest == (sal_Int32)*(sal_Int16 *)pSource);
373 : case typelib_TypeClass_UNSIGNED_SHORT:
374 0 : return (*(sal_Int32 *)pDest == (sal_Int32)*(sal_uInt16 *)pSource);
375 : case typelib_TypeClass_LONG:
376 1699152 : return (*(sal_Int32 *)pDest == *(sal_Int32 *)pSource);
377 : case typelib_TypeClass_UNSIGNED_LONG:
378 1676 : return ((sal_Int64)*(sal_Int32 *)pDest == (sal_Int64)*(sal_uInt32 *)pSource);
379 : case typelib_TypeClass_HYPER:
380 0 : return ((sal_Int64)*(sal_Int32 *)pDest == *(sal_Int64 *)pSource);
381 : case typelib_TypeClass_UNSIGNED_HYPER:
382 0 : return (*(sal_Int32 *)pDest >= 0 &&
383 0 : (sal_Int64)*(sal_Int32 *)pDest == *(sal_Int64 *)pSource); // same size
384 : case typelib_TypeClass_FLOAT:
385 0 : return ((float)*(sal_Int32 *)pDest == *(float *)pSource);
386 : case typelib_TypeClass_DOUBLE:
387 0 : return ((double)*(sal_Int32 *)pDest == *(double *)pSource);
388 : default:
389 9784 : return false;
390 : }
391 : case typelib_TypeClass_UNSIGNED_LONG:
392 876 : switch (eSourceTypeClass)
393 : {
394 : case typelib_TypeClass_BYTE:
395 0 : return ((sal_Int64)*(sal_uInt32 *)pDest == (sal_Int64)*(sal_Int8 *)pSource);
396 : case typelib_TypeClass_SHORT:
397 0 : return ((sal_Int64)*(sal_uInt32 *)pDest == (sal_Int64)*(sal_Int16 *)pSource);
398 : case typelib_TypeClass_UNSIGNED_SHORT:
399 0 : return (*(sal_uInt32 *)pDest == (sal_uInt32)*(sal_uInt16 *)pSource);
400 : case typelib_TypeClass_LONG:
401 258 : return ((sal_Int64)*(sal_uInt32 *)pDest == (sal_Int64)*(sal_Int32 *)pSource);
402 : case typelib_TypeClass_UNSIGNED_LONG:
403 618 : return (*(sal_uInt32 *)pDest == *(sal_uInt32 *)pSource);
404 : case typelib_TypeClass_HYPER:
405 0 : return ((sal_Int64)*(sal_uInt32 *)pDest == *(sal_Int64 *)pSource);
406 : case typelib_TypeClass_UNSIGNED_HYPER:
407 0 : return ((sal_uInt64)*(sal_uInt32 *)pDest == *(sal_uInt64 *)pSource);
408 : case typelib_TypeClass_FLOAT:
409 0 : return ((float)*(sal_uInt32 *)pDest == *(float *)pSource);
410 : case typelib_TypeClass_DOUBLE:
411 0 : return ((double)*(sal_uInt32 *)pDest == *(double *)pSource);
412 : default:
413 0 : return false;
414 : }
415 : case typelib_TypeClass_HYPER:
416 1333 : switch (eSourceTypeClass)
417 : {
418 : case typelib_TypeClass_BYTE:
419 0 : return (*(sal_Int64 *)pDest == (sal_Int64)*(sal_Int8 *)pSource);
420 : case typelib_TypeClass_SHORT:
421 0 : return (*(sal_Int64 *)pDest == (sal_Int64)*(sal_Int16 *)pSource);
422 : case typelib_TypeClass_UNSIGNED_SHORT:
423 0 : return (*(sal_Int64 *)pDest == (sal_Int64)*(sal_uInt16 *)pSource);
424 : case typelib_TypeClass_LONG:
425 0 : return (*(sal_Int64 *)pDest == (sal_Int64)*(sal_Int32 *)pSource);
426 : case typelib_TypeClass_UNSIGNED_LONG:
427 0 : return (*(sal_Int64 *)pDest == (sal_Int64)*(sal_uInt32 *)pSource);
428 : case typelib_TypeClass_HYPER:
429 1333 : return (*(sal_Int64 *)pDest == *(sal_Int64 *)pSource);
430 : case typelib_TypeClass_UNSIGNED_HYPER:
431 0 : return (*(sal_Int64 *)pDest >= 0 &&
432 0 : *(sal_Int64 *)pDest == *(sal_Int64 *)pSource); // same size
433 : case typelib_TypeClass_FLOAT:
434 0 : return ((float)*(sal_Int64 *)pDest == *(float *)pSource);
435 : case typelib_TypeClass_DOUBLE:
436 0 : return ((double)*(sal_Int64 *)pDest == *(double *)pSource);
437 : default:
438 0 : return false;
439 : }
440 : case typelib_TypeClass_UNSIGNED_HYPER:
441 60 : switch (eSourceTypeClass)
442 : {
443 : case typelib_TypeClass_BYTE:
444 0 : return (*(sal_Int8 *)pSource >= 0 &&
445 0 : *(sal_uInt64 *)pDest == (sal_uInt64)*(sal_Int8 *)pSource);
446 : case typelib_TypeClass_SHORT:
447 0 : return (*(sal_Int16 *)pSource >= 0 &&
448 0 : *(sal_uInt64 *)pDest == (sal_uInt64)*(sal_Int16 *)pSource);
449 : case typelib_TypeClass_UNSIGNED_SHORT:
450 0 : return (*(sal_uInt64 *)pDest == (sal_uInt64)*(sal_uInt16 *)pSource);
451 : case typelib_TypeClass_LONG:
452 0 : return (*(sal_Int32 *)pSource >= 0 &&
453 0 : *(sal_uInt64 *)pDest == (sal_uInt64)*(sal_Int32 *)pSource);
454 : case typelib_TypeClass_UNSIGNED_LONG:
455 0 : return (*(sal_uInt64 *)pDest == (sal_uInt64)*(sal_uInt32 *)pSource);
456 : case typelib_TypeClass_HYPER:
457 0 : return (*(sal_Int64 *)pSource >= 0 &&
458 0 : *(sal_uInt64 *)pDest == (sal_uInt64)*(sal_Int64 *)pSource);
459 : case typelib_TypeClass_UNSIGNED_HYPER:
460 60 : return (*(sal_uInt64 *)pDest == *(sal_uInt64 *)pSource);
461 : case typelib_TypeClass_FLOAT:
462 0 : if (::floor( *(float *)pSource ) != *(float *)pSource || *(float *)pSource < 0)
463 0 : return false;
464 0 : return (*(sal_uInt64 *)pDest == (sal_uInt64)*(float *)pSource);
465 : case typelib_TypeClass_DOUBLE:
466 0 : if (::floor( *(double *)pSource ) != *(double *)pSource || *(double *)pSource < 0)
467 0 : return false;
468 0 : return (*(sal_uInt64 *)pDest == (sal_uInt64)*(double *)pSource);
469 : default:
470 0 : return false;
471 : }
472 : case typelib_TypeClass_FLOAT:
473 42400 : switch (eSourceTypeClass)
474 : {
475 : case typelib_TypeClass_BYTE:
476 0 : return (*(float *)pDest == (float)*(sal_Int8 *)pSource);
477 : case typelib_TypeClass_SHORT:
478 0 : return (*(float *)pDest == (float)*(sal_Int16 *)pSource);
479 : case typelib_TypeClass_UNSIGNED_SHORT:
480 0 : return (*(float *)pDest == (float)*(sal_uInt16 *)pSource);
481 : case typelib_TypeClass_LONG:
482 0 : return (*(float *)pDest == (float)*(sal_Int32 *)pSource);
483 : case typelib_TypeClass_UNSIGNED_LONG:
484 0 : return (*(float *)pDest == (float)*(sal_uInt32 *)pSource);
485 : case typelib_TypeClass_HYPER:
486 0 : return (*(float *)pDest == (float)*(sal_Int64 *)pSource);
487 : case typelib_TypeClass_UNSIGNED_HYPER:
488 0 : if (::floor( *(float *)pDest ) != *(float *)pDest || *(float *)pDest < 0)
489 0 : return false;
490 0 : return ((sal_uInt64)*(float *)pDest == *(sal_uInt64 *)pSource);
491 : case typelib_TypeClass_FLOAT:
492 42400 : return (*(float *)pDest == *(float *)pSource);
493 : case typelib_TypeClass_DOUBLE:
494 0 : return ((double)*(float *)pDest == *(double *)pSource);
495 : default:
496 0 : return false;
497 : }
498 : case typelib_TypeClass_DOUBLE:
499 37818 : switch (eSourceTypeClass)
500 : {
501 : case typelib_TypeClass_BYTE:
502 0 : return (*(double *)pDest == (double)*(sal_Int8 *)pSource);
503 : case typelib_TypeClass_SHORT:
504 0 : return (*(double *)pDest == (double)*(sal_Int16 *)pSource);
505 : case typelib_TypeClass_UNSIGNED_SHORT:
506 0 : return (*(double *)pDest == (double)*(sal_uInt16 *)pSource);
507 : case typelib_TypeClass_LONG:
508 0 : return (*(double *)pDest == (double)*(sal_Int32 *)pSource);
509 : case typelib_TypeClass_UNSIGNED_LONG:
510 0 : return (*(double *)pDest == (double)*(sal_uInt32 *)pSource);
511 : case typelib_TypeClass_HYPER:
512 0 : return (*(double *)pDest == (double)*(sal_Int64 *)pSource);
513 : case typelib_TypeClass_UNSIGNED_HYPER:
514 0 : if (::floor( *(double *)pDest ) != *(double *)pDest || *(double *)pDest < 0)
515 0 : return false;
516 0 : return ((sal_uInt64)*(double *)pDest == *(sal_uInt64 *)pSource);
517 : case typelib_TypeClass_FLOAT:
518 0 : return (*(double *)pDest == (double)*(float *)pSource);
519 : case typelib_TypeClass_DOUBLE:
520 26154 : return (*(double *)pDest == *(double *)pSource);
521 : default:
522 11664 : return false;
523 : }
524 : case typelib_TypeClass_STRING:
525 : return eSourceTypeClass == typelib_TypeClass_STRING
526 2140800 : && ((::rtl::OUString *)pDest)->equals(
527 2140800 : *(::rtl::OUString const *)pSource );
528 : case typelib_TypeClass_TYPE:
529 : return eSourceTypeClass == typelib_TypeClass_TYPE
530 4 : && _type_equals(
531 : *(typelib_TypeDescriptionReference **)pDest,
532 4 : *(typelib_TypeDescriptionReference **)pSource );
533 : case typelib_TypeClass_ENUM:
534 1468990 : return (_type_equals( pDestType, pSourceType ) &&
535 1468990 : *(sal_Int32 *)pDest == *(sal_Int32 *)pSource);
536 : case typelib_TypeClass_STRUCT:
537 : case typelib_TypeClass_EXCEPTION:
538 296272 : if (! _type_equals( pDestType, pSourceType ))
539 826 : return false;
540 295446 : if (pDestTypeDescr)
541 : {
542 : return _equalStruct(
543 : pDest, pSource,
544 : (typelib_CompoundTypeDescription *)pDestTypeDescr,
545 0 : queryInterface, release );
546 : }
547 : else
548 : {
549 295446 : TYPELIB_DANGER_GET( &pDestTypeDescr, pDestType );
550 : bool bRet = _equalStruct(
551 : pDest, pSource,
552 : (typelib_CompoundTypeDescription *)pDestTypeDescr,
553 295446 : queryInterface, release );
554 295446 : TYPELIB_DANGER_RELEASE( pDestTypeDescr );
555 295446 : return bRet;
556 : }
557 : case typelib_TypeClass_SEQUENCE:
558 505643 : if (_type_equals( pDestType, pSourceType ))
559 : {
560 494469 : if (pDestTypeDescr)
561 : {
562 : return _equalSequence(
563 : *(uno_Sequence **)pDest, *(uno_Sequence **)pSource,
564 : ((typelib_IndirectTypeDescription *)pDestTypeDescr)->pType,
565 0 : queryInterface, release );
566 : }
567 : else
568 : {
569 494469 : TYPELIB_DANGER_GET( &pDestTypeDescr, pDestType );
570 : bool bRet = _equalSequence(
571 : *(uno_Sequence **)pDest, *(uno_Sequence **)pSource,
572 : ((typelib_IndirectTypeDescription *)pDestTypeDescr)->pType,
573 494469 : queryInterface, release );
574 494469 : TYPELIB_DANGER_RELEASE( pDestTypeDescr );
575 494469 : return bRet;
576 : }
577 : }
578 11174 : return false;
579 : case typelib_TypeClass_INTERFACE:
580 5741 : if (typelib_TypeClass_INTERFACE == eSourceTypeClass)
581 5154 : return _equalObject( *(void **)pDest, *(void **)pSource, queryInterface, release );
582 587 : break;
583 : default:
584 : OSL_ASSERT(false);
585 0 : break;
586 : }
587 587 : return false;
588 : }
589 :
590 : }
591 :
592 : #endif
593 :
594 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|