diff options
Diffstat (limited to 'cppu/source')
-rw-r--r-- | cppu/source/uno/assign.hxx | 12 | ||||
-rw-r--r-- | cppu/source/uno/constr.hxx | 12 | ||||
-rw-r--r-- | cppu/source/uno/copy.hxx | 214 | ||||
-rw-r--r-- | cppu/source/uno/data.cxx | 168 | ||||
-rw-r--r-- | cppu/source/uno/destr.hxx | 127 | ||||
-rw-r--r-- | cppu/source/uno/eq.hxx | 36 | ||||
-rw-r--r-- | cppu/source/uno/prim.hxx | 21 | ||||
-rw-r--r-- | cppu/source/uno/sequence.cxx | 27 |
8 files changed, 367 insertions, 250 deletions
diff --git a/cppu/source/uno/assign.hxx b/cppu/source/uno/assign.hxx index 284914789..66985d937 100644 --- a/cppu/source/uno/assign.hxx +++ b/cppu/source/uno/assign.hxx @@ -2,9 +2,9 @@ * * $RCSfile: assign.hxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: dbo $ $Date: 2001-06-25 08:32:01 $ + * last change: $Author: dbo $ $Date: 2001-06-29 11:06:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -243,7 +243,7 @@ inline sal_Bool __assignArray( for (i=0; i < nTotalElements; i++) { ::typelib_typedescriptionreference_release( *((typelib_TypeDescriptionReference **)pDest + i) ); - TYPE_ACQUIRE( + __TYPE_ACQUIRE( *((typelib_TypeDescriptionReference **)pDest + i) = *((typelib_TypeDescriptionReference **)pSource + i) ); } @@ -261,7 +261,7 @@ inline sal_Bool __assignArray( case typelib_TypeClass_ENUM: for (i=0; i < nTotalElements; i++) { - *((int *)pDest + i) = *((int *)pSource + i); + *((sal_Int32 *)pDest + i) = *((sal_Int32 *)pSource + i); } bRet = sal_True; break; @@ -540,7 +540,7 @@ inline sal_Bool __assignData( { case typelib_TypeClass_TYPE: ::typelib_typedescriptionreference_release( *(typelib_TypeDescriptionReference **)pDest ); - TYPE_ACQUIRE( + __TYPE_ACQUIRE( *(typelib_TypeDescriptionReference **)pDest = *(typelib_TypeDescriptionReference **)pSource ); return sal_True; } @@ -552,7 +552,7 @@ inline sal_Bool __assignData( case typelib_TypeClass_ENUM: if (__type_equals( pDestType, pSourceType )) { - *(int *)pDest = *(int *)pSource; + *(sal_Int32 *)pDest = *(sal_Int32 *)pSource; return sal_True; } return sal_False; diff --git a/cppu/source/uno/constr.hxx b/cppu/source/uno/constr.hxx index e3b09443a..a11232726 100644 --- a/cppu/source/uno/constr.hxx +++ b/cppu/source/uno/constr.hxx @@ -2,9 +2,9 @@ * * $RCSfile: constr.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: pl $ $Date: 2001-05-10 20:12:55 $ + * last change: $Author: dbo $ $Date: 2001-06-29 11:06:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -158,7 +158,7 @@ inline void __defaultConstructArray( case typelib_TypeClass_ENUM: for (i=0; i < nTotalElements; i++) { - *((int *)pMem + i) = ((typelib_EnumTypeDescription *)pElementType)->nDefaultEnumValue; + *((sal_Int32 *)pMem + i) = ((typelib_EnumTypeDescription *)pElementType)->nDefaultEnumValue; } break; #ifdef CPPU_ASSERTIONS @@ -228,7 +228,7 @@ inline void __defaultConstructData( break; case typelib_TypeClass_STRING: *(rtl_uString **)pMem = 0; - rtl_uString_new( (rtl_uString **)pMem ); + ::rtl_uString_new( (rtl_uString **)pMem ); break; case typelib_TypeClass_TYPE: *(typelib_TypeDescriptionReference **)pMem = __getVoidType(); @@ -239,12 +239,12 @@ inline void __defaultConstructData( case typelib_TypeClass_ENUM: if (pTypeDescr) { - *(int *)pMem = ((typelib_EnumTypeDescription *)pTypeDescr)->nDefaultEnumValue; + *(sal_Int32 *)pMem = ((typelib_EnumTypeDescription *)pTypeDescr)->nDefaultEnumValue; } else { TYPELIB_DANGER_GET( &pTypeDescr, pType ); - *(int *)pMem = ((typelib_EnumTypeDescription *)pTypeDescr)->nDefaultEnumValue; + *(sal_Int32 *)pMem = ((typelib_EnumTypeDescription *)pTypeDescr)->nDefaultEnumValue; TYPELIB_DANGER_RELEASE( pTypeDescr ); } break; diff --git a/cppu/source/uno/copy.hxx b/cppu/source/uno/copy.hxx index d108e40c2..d12b55683 100644 --- a/cppu/source/uno/copy.hxx +++ b/cppu/source/uno/copy.hxx @@ -2,9 +2,9 @@ * * $RCSfile: copy.hxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: pl $ $Date: 2001-05-10 20:12:55 $ + * last change: $Author: dbo $ $Date: 2001-06-29 11:06:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -101,18 +101,20 @@ inline void __copyConstructStruct( { while (nDescr--) { - ::uno_type_copyAndConvertData( (char *)pDest + pMemberOffsets[nDescr], - (char *)pSource + pMemberOffsets[nDescr], - ppTypeRefs[nDescr], mapping ); + ::uno_type_copyAndConvertData( + (char *)pDest + pMemberOffsets[nDescr], + (char *)pSource + pMemberOffsets[nDescr], + ppTypeRefs[nDescr], mapping ); } } else { while (nDescr--) { - ::uno_type_copyData( (char *)pDest + pMemberOffsets[nDescr], - (char *)pSource + pMemberOffsets[nDescr], - ppTypeRefs[nDescr], acquire ); + ::uno_type_copyData( + (char *)pDest + pMemberOffsets[nDescr], + (char *)pSource + pMemberOffsets[nDescr], + ppTypeRefs[nDescr], acquire ); } } } @@ -133,18 +135,20 @@ inline void __copyConstructArray( { for(sal_Int32 i = 0; i < nTotalElements; i++) { - ::uno_type_copyAndConvertData( (sal_Char *)pDest + i * nElementSize, - (sal_Char *)pSource + i * nElementSize, - pElementTypeRef, mapping ); + ::uno_type_copyAndConvertData( + (sal_Char *)pDest + i * nElementSize, + (sal_Char *)pSource + i * nElementSize, + pElementTypeRef, mapping ); } } else { for(sal_Int32 i = 0; i < nTotalElements; i++) { - ::uno_type_copyData( (sal_Char *)pDest + (i * nElementSize), - (sal_Char *)pSource + (i * nElementSize), - pElementTypeRef, acquire ); + ::uno_type_copyData( + (sal_Char *)pDest + (i * nElementSize), + (sal_Char *)pSource + (i * nElementSize), + pElementTypeRef, acquire ); } } } @@ -186,55 +190,79 @@ inline void __copyConstructAnyFromData( uno_AcquireFunc acquire, uno_Mapping * mapping ) SAL_THROW ( () ) { - TYPE_ACQUIRE( pType ); + __TYPE_ACQUIRE( pType ); pDestAny->pType = pType; switch (pType->eTypeClass) { case typelib_TypeClass_CHAR: - pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Unicode) ); - *(sal_Unicode *)pDestAny->pData = *(sal_Unicode *)pSource; + pDestAny->pData = &pDestAny->pReserved; + *(sal_Unicode *)&pDestAny->pReserved = *(sal_Unicode *)pSource; break; case typelib_TypeClass_BOOLEAN: - pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Bool) ); - *(sal_Bool *)pDestAny->pData = (*(sal_Bool *)pSource != sal_False); + pDestAny->pData = &pDestAny->pReserved; + *(sal_Bool *)&pDestAny->pReserved = (*(sal_Bool *)pSource != sal_False); break; case typelib_TypeClass_BYTE: - pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Int8) ); - *(sal_Int8 *)pDestAny->pData = *(sal_Int8 *)pSource; + pDestAny->pData = &pDestAny->pReserved; + *(sal_Int8 *)&pDestAny->pReserved = *(sal_Int8 *)pSource; break; case typelib_TypeClass_SHORT: case typelib_TypeClass_UNSIGNED_SHORT: - pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Int16) ); - *(sal_Int16 *)pDestAny->pData = *(sal_Int16 *)pSource; + pDestAny->pData = &pDestAny->pReserved; + *(sal_Int16 *)&pDestAny->pReserved = *(sal_Int16 *)pSource; break; case typelib_TypeClass_LONG: case typelib_TypeClass_UNSIGNED_LONG: - pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Int32) ); - *(sal_Int32 *)pDestAny->pData = *(sal_Int32 *)pSource; + pDestAny->pData = &pDestAny->pReserved; + *(sal_Int32 *)&pDestAny->pReserved = *(sal_Int32 *)pSource; break; case typelib_TypeClass_HYPER: case typelib_TypeClass_UNSIGNED_HYPER: - pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Int64) ); - *(sal_Int64 *)pDestAny->pData = *(sal_Int64 *)pSource; + if (sizeof(void *) >= sizeof(sal_Int64)) + { + pDestAny->pData = &pDestAny->pReserved; + *(sal_Int64 *)&pDestAny->pReserved = *(sal_Int64 *)pSource; + } + else + { + pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Int64) ); + *(sal_Int64 *)pDestAny->pData = *(sal_Int64 *)pSource; + } break; case typelib_TypeClass_FLOAT: - pDestAny->pData = ::rtl_allocateMemory( sizeof(float) ); - *(float *)pDestAny->pData = *(float *)pSource; + if (sizeof(void *) >= sizeof(float)) + { + pDestAny->pData = &pDestAny->pReserved; + *(float *)&pDestAny->pReserved = *(float *)pSource; + } + else + { + pDestAny->pData = ::rtl_allocateMemory( sizeof(float) ); + *(float *)pDestAny->pData = *(float *)pSource; + } break; case typelib_TypeClass_DOUBLE: - pDestAny->pData = ::rtl_allocateMemory( sizeof(double) ); - *(double *)pDestAny->pData = *(double *)pSource; + if (sizeof(void *) >= sizeof(double)) + { + pDestAny->pData = &pDestAny->pReserved; + *(double *)&pDestAny->pReserved = *(double *)pSource; + } + else + { + pDestAny->pData = ::rtl_allocateMemory( sizeof(double) ); + *(double *)pDestAny->pData = *(double *)pSource; + } break; case typelib_TypeClass_STRING: ::rtl_uString_acquire( *(rtl_uString **)pSource ); - pDestAny->pData = ::rtl_allocateMemory( sizeof(rtl_uString *) ); - *(rtl_uString **)pDestAny->pData = *(rtl_uString **)pSource; + pDestAny->pData = &pDestAny->pReserved; + *(rtl_uString **)&pDestAny->pReserved = *(rtl_uString **)pSource; break; case typelib_TypeClass_TYPE: - TYPE_ACQUIRE( *(typelib_TypeDescriptionReference **)pSource ); - pDestAny->pData = ::rtl_allocateMemory( sizeof(typelib_TypeDescriptionReference *) ); - *(typelib_TypeDescriptionReference **)pDestAny->pData = *(typelib_TypeDescriptionReference **)pSource; + __TYPE_ACQUIRE( *(typelib_TypeDescriptionReference **)pSource ); + pDestAny->pData = &pDestAny->pReserved; + *(typelib_TypeDescriptionReference **)&pDestAny->pReserved = *(typelib_TypeDescriptionReference **)pSource; break; #ifdef CPPU_ASSERTIONS case typelib_TypeClass_ANY: @@ -242,8 +270,9 @@ inline void __copyConstructAnyFromData( break; #endif case typelib_TypeClass_ENUM: - pDestAny->pData = ::rtl_allocateMemory( sizeof(int) ); - *(int *)pDestAny->pData = *(int *)pSource; + pDestAny->pData = &pDestAny->pReserved; + // enum is forced to 32bit long + *(sal_Int32 *)&pDestAny->pReserved = *(sal_Int32 *)pSource; break; #ifdef CPPU_ASSERTIONS case typelib_TypeClass_TYPEDEF: @@ -306,11 +335,11 @@ inline void __copyConstructAnyFromData( } break; case typelib_TypeClass_SEQUENCE: - pDestAny->pData = ::rtl_allocateMemory( sizeof(uno_Sequence *) ); + pDestAny->pData = &pDestAny->pReserved; if (pTypeDescr) { copyConstructSequence( - (uno_Sequence **)pDestAny->pData, *(uno_Sequence **)pSource, + (uno_Sequence **)&pDestAny->pReserved, *(uno_Sequence **)pSource, ((typelib_IndirectTypeDescription *)pTypeDescr)->pType, acquire, mapping ); } @@ -318,21 +347,21 @@ inline void __copyConstructAnyFromData( { TYPELIB_DANGER_GET( &pTypeDescr, pType ); copyConstructSequence( - (uno_Sequence **)pDestAny->pData, *(uno_Sequence **)pSource, + (uno_Sequence **)&pDestAny->pReserved, *(uno_Sequence **)pSource, ((typelib_IndirectTypeDescription *)pTypeDescr)->pType, acquire, mapping ); TYPELIB_DANGER_RELEASE( pTypeDescr ); } break; case typelib_TypeClass_INTERFACE: - pDestAny->pData = ::rtl_allocateMemory( sizeof(void *) ); + pDestAny->pData = &pDestAny->pReserved; if (mapping) { - *(void **)pDestAny->pData = __map( *(void **)pSource, pType, pTypeDescr, mapping ); + pDestAny->pReserved = __map( *(void **)pSource, pType, pTypeDescr, mapping ); } else { - __acquire( *(void **)pDestAny->pData = *(void **)pSource, acquire ); + __acquire( pDestAny->pReserved = *(void **)pSource, acquire ); } break; } @@ -375,64 +404,88 @@ inline void __copyConstructAny( } else // default construct { - TYPE_ACQUIRE( pType ); + __TYPE_ACQUIRE( pType ); pDestAny->pType = pType; switch (pType->eTypeClass) { case typelib_TypeClass_CHAR: - pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Unicode) ); - *(sal_Unicode *)pDestAny->pData = '\0'; + pDestAny->pData = &pDestAny->pReserved; + *(sal_Unicode *)&pDestAny->pReserved = '\0'; break; case typelib_TypeClass_BOOLEAN: - pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Bool) ); - *(sal_Bool *)pDestAny->pData = sal_False; + pDestAny->pData = &pDestAny->pReserved; + *(sal_Bool *)&pDestAny->pReserved = sal_False; break; case typelib_TypeClass_BYTE: - pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Int8) ); - *(sal_Int8 *)pDestAny->pData = 0; + pDestAny->pData = &pDestAny->pReserved; + *(sal_Int8 *)&pDestAny->pReserved = 0; break; case typelib_TypeClass_SHORT: case typelib_TypeClass_UNSIGNED_SHORT: - pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Int16) ); - *(sal_Int16 *)pDestAny->pData = 0; + pDestAny->pData = &pDestAny->pReserved; + *(sal_Int16 *)&pDestAny->pReserved = 0; break; case typelib_TypeClass_LONG: case typelib_TypeClass_UNSIGNED_LONG: - pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Int32) ); - *(sal_Int32 *)pDestAny->pData = 0; + pDestAny->pData = &pDestAny->pReserved; + *(sal_Int32 *)&pDestAny->pReserved = 0; break; case typelib_TypeClass_HYPER: case typelib_TypeClass_UNSIGNED_HYPER: - pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Int64) ); - *(sal_Int64 *)pDestAny->pData = 0; + if (sizeof(void *) >= sizeof(sal_Int64)) + { + pDestAny->pData = &pDestAny->pReserved; + *(sal_Int64 *)&pDestAny->pReserved = 0; + } + else + { + pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Int64) ); + *(sal_Int64 *)pDestAny->pData = 0; + } break; case typelib_TypeClass_FLOAT: - pDestAny->pData = ::rtl_allocateMemory( sizeof(float) ); - *(float *)pDestAny->pData = 0.0; + if (sizeof(void *) >= sizeof(float)) + { + pDestAny->pData = &pDestAny->pReserved; + *(float *)&pDestAny->pReserved = 0.0; + } + else + { + pDestAny->pData = ::rtl_allocateMemory( sizeof(float) ); + *(float *)pDestAny->pData = 0.0; + } break; case typelib_TypeClass_DOUBLE: - pDestAny->pData = ::rtl_allocateMemory( sizeof(double) ); - *(double *)pDestAny->pData = 0.0; + if (sizeof(void *) >= sizeof(double)) + { + pDestAny->pData = &pDestAny->pReserved; + *(double *)&pDestAny->pReserved = 0.0; + } + else + { + pDestAny->pData = ::rtl_allocateMemory( sizeof(double) ); + *(double *)pDestAny->pData = 0.0; + } break; case typelib_TypeClass_STRING: - pDestAny->pData = ::rtl_allocateMemory( sizeof(rtl_uString *) ); - *(rtl_uString **)pDestAny->pData = 0; - rtl_uString_new( (rtl_uString **)pDestAny->pData ); + pDestAny->pData = &pDestAny->pReserved; + *(rtl_uString **)&pDestAny->pReserved = 0; + ::rtl_uString_new( (rtl_uString **)&pDestAny->pReserved ); break; case typelib_TypeClass_TYPE: - pDestAny->pData = ::rtl_allocateMemory( sizeof(typelib_TypeDescriptionReference *) ); - *(typelib_TypeDescriptionReference **)pDestAny->pData = __getVoidType(); + pDestAny->pData = &pDestAny->pReserved; + *(typelib_TypeDescriptionReference **)&pDestAny->pReserved = __getVoidType(); break; case typelib_TypeClass_ENUM: - pDestAny->pData = ::rtl_allocateMemory( sizeof(int) ); + pDestAny->pData = &pDestAny->pReserved; if (pTypeDescr) { - *(int *)pDestAny->pData = ((typelib_EnumTypeDescription *)pTypeDescr)->nDefaultEnumValue; + *(sal_Int32 *)&pDestAny->pReserved = ((typelib_EnumTypeDescription *)pTypeDescr)->nDefaultEnumValue; } else { TYPELIB_DANGER_GET( &pTypeDescr, pType ); - *(int *)pDestAny->pData = ((typelib_EnumTypeDescription *)pTypeDescr)->nDefaultEnumValue; + *(sal_Int32 *)&pDestAny->pReserved = ((typelib_EnumTypeDescription *)pTypeDescr)->nDefaultEnumValue; TYPELIB_DANGER_RELEASE( pTypeDescr ); } break; @@ -489,12 +542,12 @@ inline void __copyConstructAny( } break; case typelib_TypeClass_SEQUENCE: - pDestAny->pData = ::rtl_allocateMemory( sizeof(uno_Sequence *) ); - *(uno_Sequence **)pDestAny->pData = __getEmptySequence(); + pDestAny->pData = &pDestAny->pReserved; + *(uno_Sequence **)&pDestAny->pReserved = __getEmptySequence(); break; case typelib_TypeClass_INTERFACE: - pDestAny->pData = ::rtl_allocateMemory( sizeof(void *) ); - *(void **)pDestAny->pData = 0; // either cpp or c-uno interface + pDestAny->pData = &pDestAny->pReserved; + pDestAny->pReserved = 0; // either cpp or c-uno interface break; } } @@ -508,8 +561,7 @@ inline void __copyConstructSequence( SAL_THROW ( () ) { typelib_TypeClass eTypeClass = pElementType->eTypeClass; - if (!mapping || - (eTypeClass <= typelib_TypeClass_ENUM && eTypeClass != typelib_TypeClass_ANY)) + if (!mapping || (eTypeClass <= typelib_TypeClass_ENUM && eTypeClass != typelib_TypeClass_ANY)) { ::osl_incrementInterlockedCount( &pSource->nRefCount ); *ppDest = pSource; @@ -601,9 +653,11 @@ inline void __copyConstructSequence( char * pDest = pElements + (nPos * nElementSize); char * pSource = pSourceElements + (nPos * nElementSize); - typelib_TypeDescriptionReference * pSetType = __unionGetSetType( pSource, pElementTypeDescr ); - ::uno_type_copyAndConvertData( pDest + nValueOffset, pSource + nValueOffset, - pSetType, mapping ); + typelib_TypeDescriptionReference * pSetType = __unionGetSetType( + pSource, pElementTypeDescr ); + ::uno_type_copyAndConvertData( + pDest + nValueOffset, pSource + nValueOffset, + pSetType, mapping ); *(sal_Int64 *)pDest = *(sal_Int64 *)pSource; ::typelib_typedescriptionreference_release( pSetType ); } @@ -723,7 +777,7 @@ inline void __copyConstructData( *(rtl_uString **)pDest = *(rtl_uString **)pSource; break; case typelib_TypeClass_TYPE: - TYPE_ACQUIRE( *(typelib_TypeDescriptionReference **)pSource ); + __TYPE_ACQUIRE( *(typelib_TypeDescriptionReference **)pSource ); *(typelib_TypeDescriptionReference **)pDest = *(typelib_TypeDescriptionReference **)pSource; break; case typelib_TypeClass_ANY: @@ -733,7 +787,7 @@ inline void __copyConstructData( acquire, mapping ); break; case typelib_TypeClass_ENUM: - *(int *)pDest = *(int *)pSource; + *(sal_Int32 *)pDest = *(sal_Int32 *)pSource; break; #ifdef CPPU_ASSERTIONS case typelib_TypeClass_TYPEDEF: diff --git a/cppu/source/uno/data.cxx b/cppu/source/uno/data.cxx index 92247fbe7..2b9df950a 100644 --- a/cppu/source/uno/data.cxx +++ b/cppu/source/uno/data.cxx @@ -2,9 +2,9 @@ * * $RCSfile: data.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: dbo $ $Date: 2001-03-28 10:46:10 $ + * last change: $Author: dbo $ $Date: 2001-06-29 11:06:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -144,7 +144,9 @@ void destructSequence( { if (pSequence->nElements) { - __destructElements( pSequence->elements, pElementType, 0, pSequence->nElements, release ); + __destructElements( + pSequence->elements, pElementType, + 0, pSequence->nElements, release ); } ::rtl_freeMemory( pSequence ); } @@ -235,9 +237,10 @@ sal_Bool SAL_CALL uno_type_equalData( uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release ) SAL_THROW_EXTERN_C() { - return __equalData( pVal1, pVal1Type, 0, - pVal2, pVal2Type, 0, - queryInterface, release ); + return __equalData( + pVal1, pVal1Type, 0, + pVal2, pVal2Type, 0, + queryInterface, release ); } //################################################################################################## sal_Bool SAL_CALL uno_equalData( @@ -246,9 +249,10 @@ sal_Bool SAL_CALL uno_equalData( uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release ) SAL_THROW_EXTERN_C() { - return __equalData( pVal1, pVal1TD->pWeakRef, pVal1TD, - pVal2, pVal2TD->pWeakRef, pVal2TD, - queryInterface, release ); + return __equalData( + pVal1, pVal1TD->pWeakRef, pVal1TD, + pVal2, pVal2TD->pWeakRef, pVal2TD, + queryInterface, release ); } //################################################################################################## sal_Bool SAL_CALL uno_type_assignData( @@ -257,9 +261,10 @@ sal_Bool SAL_CALL uno_type_assignData( uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release ) SAL_THROW_EXTERN_C() { - return __assignData( pDest, pDestType, 0, - pSource, pSourceType, 0, - queryInterface, acquire, release ); + return __assignData( + pDest, pDestType, 0, + pSource, pSourceType, 0, + queryInterface, acquire, release ); } //################################################################################################## sal_Bool SAL_CALL uno_assignData( @@ -268,9 +273,10 @@ sal_Bool SAL_CALL uno_assignData( uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release ) SAL_THROW_EXTERN_C() { - return __assignData( pDest, pDestTD->pWeakRef, pDestTD, - pSource, pSourceTD->pWeakRef, pSourceTD, - queryInterface, acquire, release ); + return __assignData( + pDest, pDestTD->pWeakRef, pDestTD, + pSource, pSourceTD->pWeakRef, pSourceTD, + queryInterface, acquire, release ); } } @@ -320,67 +326,87 @@ struct second : public empty class BinaryCompatible_Impl { public: - BinaryCompatible_Impl() + BinaryCompatible_Impl(); +}; +BinaryCompatible_Impl::BinaryCompatible_Impl() +{ + // sequence + if ((SAL_SEQUENCE_HEADER_SIZE % 8) != 0) { - if ((SAL_SEQUENCE_HEADER_SIZE % 8) != 0) - abort(); - - /* - If the feature failed search FEATURE_ and correct it. - */ - // the sizeof enum must be the size of an integer - // FEATURE_ENUM - if( sizeof( TypeClass ) != sizeof( int ) ) - abort(); - - // the sizeof any must be sizeof( void * ) * 2, - // the first is a pointer to typelib_TypeDescription, the second is the pointer to the data - // FEATURE_ANY - if( sizeof( Any ) != sizeof( uno_Any ) ) - abort(); - if( sizeof( Any ) != sizeof( void * ) * 2 ) - abort(); - if( (sal_Int32)&((Any *) 16)->pType != 16 ) - abort(); - if( (sal_Int32)&((Any *) 16)->pData != 16 + sizeof( void * ) ) - abort(); - - // All types can moved from one one memory location to another - // without calling the copy constructor and the destructor. - // FEATURE_MEMORYMOVE_INVARIANT - - // All types can moved from one one memory location to another - // without calling the copy constructor and the destructor. - // FEATURE_ZEROCONSTRUCTOR - - // The reference class must be a pointer to XInterface or a subclass of XInterface - // FEATURE_INTERFACE - if( sizeof( Reference< XInterface > ) != sizeof( XInterface * ) ) - abort(); - - // The reference class must be a pointer to XInterface or a subclass of XInterface - // FEATURE_WSTRING - if( sizeof( OUString ) != sizeof( rtl_uString * ) ) - abort(); - - // The reference class must be a pointer to XInterface or a subclass of XInterface - // FEATURE_ALIGN - if( sizeof( M ) != 8 || sizeof( N ) != 12 || sizeof( O ) != 16 ) - abort(); - + OSL_ENSURE( 0, "### sal sequence header size not aligned to 8?!" ); + abort(); + } + // enum + if( sizeof( TypeClass ) != sizeof( sal_Int32 ) ) + { + OSL_ENSURE( 0, "### enum not 32bit?!" ); + abort(); + } + // any + if (sizeof(void *) < sizeof(sal_Int32)) + { + OSL_ENSURE( 0, "### size of pointer less than 32bit?!" ); + abort(); + } + if( sizeof( Any ) != sizeof( uno_Any ) ) + { + OSL_ENSURE( 0, "### Any inheritance adds space to uno_Any?!" ); + abort(); + } + if( sizeof( Any ) != sizeof( void * ) * 3 ) + { + OSL_ENSURE( 0, "### sizeof( Any ) != sizeof( void * ) * 3 ?!" ); + abort(); + } + if( (sal_Int32)&((Any *) 16)->pType != 16 ) + { + OSL_ENSURE( 0, "### (sal_Int32)&((Any *) 16)->pType != 16 ?!" ); + abort(); + } + if( (sal_Int32)&((Any *) 16)->pData != 16 + sizeof( void * ) ) + { + OSL_ENSURE( 0, "### (sal_Int32)&((Any *) 16)->pData != 16 + sizeof( void * ) ?!" ); + abort(); + } + if( (sal_Int32)&((Any *) 16)->pReserved != 16 + (2* sizeof( void * )) ) + { + OSL_ENSURE( 0, "### (sal_Int32)&((Any *) 16)->pReserved != 16 + (2* sizeof( void * )) ?!" ); + abort(); + } + // interface + if( sizeof( Reference< XInterface > ) != sizeof( XInterface * ) ) + { + OSL_ENSURE( 0, "### unexpected size of interface reference?!" ); + abort(); + } + // string + if( sizeof( OUString ) != sizeof( rtl_uString * ) ) + { + OSL_ENSURE( 0, "### unexpected size of string?!" ); + abort(); + } + // struct + if( sizeof( M ) != 8 || sizeof( N ) != 12 || sizeof( O ) != 16 ) + { + OSL_ENSURE( 0, "### unexpected struct alignment?!" ); + abort(); + } #ifdef SAL_W32 - if( sizeof( P ) != 24 ) - abort(); + if( sizeof( P ) != 24 ) + { + OSL_ENSURE( 0, "### [win] unexpected struct alignment?!" ); + abort(); + } #endif - #ifndef __GNUC__ - // An empty superclass have a size of 0 except for gcc - // FEATURE_EMPTYCLASS - if( sizeof( second ) != sizeof( int ) ) - abort(); -#endif + if( sizeof( second ) != sizeof( int ) ) + { + OSL_ENSURE( 0, "### unexpected struct size?!" ); + abort(); } -}; +#endif +} + #ifdef SAL_W32 # pragma pack(pop) #elif defined(SAL_OS2) diff --git a/cppu/source/uno/destr.hxx b/cppu/source/uno/destr.hxx index e0932fc4a..9b440ffc6 100644 --- a/cppu/source/uno/destr.hxx +++ b/cppu/source/uno/destr.hxx @@ -2,9 +2,9 @@ * * $RCSfile: destr.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: jsc $ $Date: 2001-03-30 13:41:39 $ + * last change: $Author: dbo $ $Date: 2001-06-29 11:06:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -109,7 +109,8 @@ inline void __destructStruct( while (nDescr--) { ::uno_type_destructData( - (char *)pValue + pMemberOffsets[nDescr], ppTypeRefs[nDescr], release ); + (char *)pValue + pMemberOffsets[nDescr], + ppTypeRefs[nDescr], release ); } } //-------------------------------------------------------------------------------------------------- @@ -127,7 +128,8 @@ inline void __destructArray( sal_Int32 nTotalElements = pTypeDescr->nTotalElements; for(sal_Int32 i=0; i < nTotalElements; i++) { - ::uno_type_destructData((sal_Char *)pValue + i * nElementSize, + ::uno_type_destructData( + (sal_Char *)pValue + i * nElementSize, ((typelib_IndirectTypeDescription *)pTypeDescr)->pType, release ); } @@ -147,62 +149,81 @@ inline void __destructAny( { typelib_TypeDescriptionReference * pType = pAny->pType; - if (typelib_TypeClass_VOID != pType->eTypeClass) + switch (pType->eTypeClass) { - switch (pType->eTypeClass) - { - case typelib_TypeClass_STRING: - ::rtl_uString_release( *(rtl_uString **)pAny->pData ); - break; - case typelib_TypeClass_TYPE: - ::typelib_typedescriptionreference_release( *(typelib_TypeDescriptionReference **)pAny->pData ); - break; - case typelib_TypeClass_ANY: - OSL_ENSURE( sal_False, "### unexpected nested any!" ); - ::uno_any_destruct( (uno_Any *)pAny->pData, release ); - break; -#ifdef CPPU_ASSERTIONS - case typelib_TypeClass_TYPEDEF: - OSL_ENSURE( sal_False, "### unexpected typedef!" ); - break; -#endif - case typelib_TypeClass_STRUCT: - case typelib_TypeClass_EXCEPTION: + case typelib_TypeClass_HYPER: + case typelib_TypeClass_UNSIGNED_HYPER: + if (sizeof(void *) < sizeof(sal_Int64)) { - typelib_TypeDescription * pTypeDescr = 0; - TYPELIB_DANGER_GET( &pTypeDescr, pType ); - __destructStruct( pAny->pData, (typelib_CompoundTypeDescription *)pTypeDescr, release ); - TYPELIB_DANGER_RELEASE( pTypeDescr ); - break; + ::rtl_freeMemory( pAny->pData ); } - case typelib_TypeClass_UNION: + break; + case typelib_TypeClass_FLOAT: + if (sizeof(void *) < sizeof(float)) { - typelib_TypeDescription * pTypeDescr = 0; - TYPELIB_DANGER_GET( &pTypeDescr, pType ); - __destructUnion( pAny->pData, pTypeDescr, release ); - TYPELIB_DANGER_RELEASE( pTypeDescr ); - break; + ::rtl_freeMemory( pAny->pData ); } - case typelib_TypeClass_SEQUENCE: + break; + case typelib_TypeClass_DOUBLE: + if (sizeof(void *) < sizeof(double)) { - typelib_TypeDescription * pTypeDescr = 0; - TYPELIB_DANGER_GET( &pTypeDescr, pType ); - destructSequence( - (uno_Sequence **)pAny->pData, - ((typelib_IndirectTypeDescription *)pTypeDescr)->pType, - release ); - TYPELIB_DANGER_RELEASE( pTypeDescr ); - break; - } - case typelib_TypeClass_INTERFACE: - __releaseRef( (void **)pAny->pData, release ); - break; + ::rtl_freeMemory( pAny->pData ); } + break; + case typelib_TypeClass_STRING: + ::rtl_uString_release( (rtl_uString *)pAny->pReserved ); + break; + case typelib_TypeClass_TYPE: + ::typelib_typedescriptionreference_release( + (typelib_TypeDescriptionReference *)pAny->pReserved ); + break; + case typelib_TypeClass_ANY: + OSL_ENSURE( sal_False, "### unexpected nested any!" ); + ::uno_any_destruct( (uno_Any *)pAny->pData, release ); ::rtl_freeMemory( pAny->pData ); -#ifdef _DEBUG - pAny->pData = (void *)0xdeadbeef; + break; +#ifdef CPPU_ASSERTIONS + case typelib_TypeClass_TYPEDEF: + OSL_ENSURE( sal_False, "### unexpected typedef!" ); + break; #endif + case typelib_TypeClass_STRUCT: + case typelib_TypeClass_EXCEPTION: + { + typelib_TypeDescription * pTypeDescr = 0; + TYPELIB_DANGER_GET( &pTypeDescr, pType ); + __destructStruct( pAny->pData, (typelib_CompoundTypeDescription *)pTypeDescr, release ); + TYPELIB_DANGER_RELEASE( pTypeDescr ); + ::rtl_freeMemory( pAny->pData ); + break; } + case typelib_TypeClass_UNION: + { + typelib_TypeDescription * pTypeDescr = 0; + TYPELIB_DANGER_GET( &pTypeDescr, pType ); + __destructUnion( pAny->pData, pTypeDescr, release ); + TYPELIB_DANGER_RELEASE( pTypeDescr ); + ::rtl_freeMemory( pAny->pData ); + break; + } + case typelib_TypeClass_SEQUENCE: + { + typelib_TypeDescription * pTypeDescr = 0; + TYPELIB_DANGER_GET( &pTypeDescr, pType ); + destructSequence( + (uno_Sequence **)&pAny->pReserved, + ((typelib_IndirectTypeDescription *)pTypeDescr)->pType, + release ); + TYPELIB_DANGER_RELEASE( pTypeDescr ); + break; + } + case typelib_TypeClass_INTERFACE: + __releaseRef( &pAny->pReserved, release ); + break; + } +#ifdef _DEBUG + pAny->pData = (void *)0xdeadbeef; +#endif ::typelib_typedescriptionreference_release( pType ); } @@ -263,7 +284,7 @@ inline sal_Int32 __destructElements( return sizeof(uno_Any); } case typelib_TypeClass_ENUM: - return sizeof(int); + return sizeof(sal_Int32); #ifdef CPPU_ASSERTIONS case typelib_TypeClass_TYPEDEF: OSL_ENSURE( sal_False, "### unexpected typedef!" ); @@ -330,7 +351,9 @@ inline sal_Int32 __destructElements( { void * p = ((void **)pElements)[nPos]; if (p) + { (*release)( p ); + } } } else @@ -339,7 +362,9 @@ inline sal_Int32 __destructElements( { uno_Interface * p = ((uno_Interface **)pElements)[nPos]; if (p) + { (*p->release)( p ); + } } } return sizeof(void *); diff --git a/cppu/source/uno/eq.hxx b/cppu/source/uno/eq.hxx index bd1963a80..330d091e3 100644 --- a/cppu/source/uno/eq.hxx +++ b/cppu/source/uno/eq.hxx @@ -2,9 +2,9 @@ * * $RCSfile: eq.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: jl $ $Date: 2001-03-12 13:27:08 $ + * last change: $Author: dbo $ $Date: 2001-06-29 11:06:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -189,11 +189,11 @@ inline sal_Bool __equalStruct( while (nDescr--) { sal_Int32 nOffset = pMemberOffsets[nDescr]; - if (! uno_type_equalData( (char *)pDest + nOffset, - ppTypeRefs[nDescr], - (char *)pSource + nOffset, - ppTypeRefs[nDescr], - queryInterface, release )) + if (! ::uno_type_equalData( (char *)pDest + nOffset, + ppTypeRefs[nDescr], + (char *)pSource + nOffset, + ppTypeRefs[nDescr], + queryInterface, release )) { return sal_False; } @@ -306,7 +306,7 @@ inline sal_Bool __equalSequence( return sal_True; } case typelib_TypeClass_ENUM: - return (0 == ::rtl_compareMemory( pDestElements, pSourceElements, sizeof(int) * nElements )); + return (0 == ::rtl_compareMemory( pDestElements, pSourceElements, sizeof(sal_Int32) * nElements )); case typelib_TypeClass_STRUCT: case typelib_TypeClass_EXCEPTION: { @@ -338,9 +338,10 @@ inline sal_Bool __equalSequence( char * pDest = (char *)pDestElements + (nPos * nElementSize); char * pSource = (char *)pSourceElements + (nPos * nElementSize); typelib_TypeDescriptionReference * pSetType = __unionGetSetType( pDest, pElementTypeDescr ); - sal_Bool bRet = uno_type_equalData( pDest + nValueOffset, pSetType, - pSource + nValueOffset, pSetType, - queryInterface, release ); + sal_Bool bRet = ::uno_type_equalData( + pDest + nValueOffset, pSetType, + pSource + nValueOffset, pSetType, + queryInterface, release ); ::typelib_typedescriptionreference_release( pSetType ); if (! bRet) { @@ -658,20 +659,21 @@ inline sal_Bool __equalData( switch (eSourceTypeClass) { case typelib_TypeClass_STRING: - return ((::rtl::OUString *)pDest)->equals( *(::rtl::OUString *)pSource ); + return ((::rtl::OUString *)pDest)->equals( *(::rtl::OUString const *)pSource ); } return sal_False; case typelib_TypeClass_TYPE: switch (eSourceTypeClass) { case typelib_TypeClass_TYPE: - return __type_equals( *(typelib_TypeDescriptionReference **)pDest, - *(typelib_TypeDescriptionReference **)pSource ); + return __type_equals( + *(typelib_TypeDescriptionReference **)pDest, + *(typelib_TypeDescriptionReference **)pSource ); } return sal_False; case typelib_TypeClass_ENUM: return (__type_equals( pDestType, pSourceType ) && - *(int *)pDest == *(int *)pSource); + *(sal_Int32 *)pDest == *(sal_Int32 *)pSource); #ifdef CPPU_ASSERTIONS case typelib_TypeClass_TYPEDEF: OSL_ENSURE( sal_False, "### unexpected typedef!" ); @@ -706,7 +708,7 @@ inline sal_Bool __equalData( if (pDestTypeDescr) { typelib_TypeDescriptionReference * pSetType = __unionGetSetType( pDest, pDestTypeDescr ); - bRet = uno_type_equalData( + bRet = ::uno_type_equalData( (char *)pDest + ((typelib_UnionTypeDescription *)pDestTypeDescr)->nValueOffset, pSetType, (char *)pSource + ((typelib_UnionTypeDescription *)pDestTypeDescr)->nValueOffset, pSetType, queryInterface, release ); @@ -716,7 +718,7 @@ inline sal_Bool __equalData( { TYPELIB_DANGER_GET( &pDestTypeDescr, pDestType ); typelib_TypeDescriptionReference * pSetType = __unionGetSetType( pDest, pDestTypeDescr ); - bRet = uno_type_equalData( + bRet = ::uno_type_equalData( (char *)pDest + ((typelib_UnionTypeDescription *)pDestTypeDescr)->nValueOffset, pSetType, (char *)pSource + ((typelib_UnionTypeDescription *)pDestTypeDescr)->nValueOffset, pSetType, queryInterface, release ); diff --git a/cppu/source/uno/prim.hxx b/cppu/source/uno/prim.hxx index f0357d3f9..c268348ae 100644 --- a/cppu/source/uno/prim.hxx +++ b/cppu/source/uno/prim.hxx @@ -2,9 +2,9 @@ * * $RCSfile: prim.hxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: dbo $ $Date: 2001-06-25 08:32:01 $ + * last change: $Author: dbo $ $Date: 2001-06-29 11:06:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -138,21 +138,30 @@ inline void __acquire( void * p, uno_AcquireFunc acquire ) if (p) { if (acquire) + { (*acquire)( p ); + } else + { (*((uno_Interface *)p)->acquire)( (uno_Interface *)p ); + } } } //-------------------------------------------------------------------------------------------------- inline void __releaseRef( void ** pRef, uno_ReleaseFunc release ) SAL_THROW( () ) { - if (*pRef) + void * p = *pRef; + if (p) { if (release) - (*release)( *pRef ); + { + (*release)( p ); + } else - (*((uno_Interface *)*pRef)->release)( (uno_Interface *)*pRef ); + { + (*((uno_Interface *)p)->release)( (uno_Interface *)p ); + } } } @@ -200,7 +209,7 @@ inline typelib_TypeDescriptionReference * __getVoidType() #endif //-------------------------------------------------------------------------------------------------- -#define TYPE_ACQUIRE( pType ) \ +#define __TYPE_ACQUIRE( pType ) \ ::osl_incrementInterlockedCount( &(pType)->nRefCount ); //-------------------------------------------------------------------------------------------------- diff --git a/cppu/source/uno/sequence.cxx b/cppu/source/uno/sequence.cxx index bdd058e36..a998b1b9a 100644 --- a/cppu/source/uno/sequence.cxx +++ b/cppu/source/uno/sequence.cxx @@ -2,9 +2,9 @@ * * $RCSfile: sequence.cxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: pl $ $Date: 2001-05-10 20:12:55 $ + * last change: $Author: dbo $ $Date: 2001-06-29 11:06:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -217,14 +217,14 @@ static inline void __defaultConstructElements( } case typelib_TypeClass_ENUM: { - allocSeq( ppSequence, sizeof(int), nAlloc ); + allocSeq( ppSequence, sizeof(sal_Int32), nAlloc ); typelib_TypeDescription * pElementTypeDescr = 0; TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType ); - int eEnum = ((typelib_EnumTypeDescription *)pElementTypeDescr)->nDefaultEnumValue; + sal_Int32 eEnum = ((typelib_EnumTypeDescription *)pElementTypeDescr)->nDefaultEnumValue; TYPELIB_DANGER_RELEASE( pElementTypeDescr ); - int * pElements = (int *)(*ppSequence)->elements; + sal_Int32 * pElements = (sal_Int32 *)(*ppSequence)->elements; for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos ) { pElements[nPos] = eEnum; @@ -390,11 +390,11 @@ static inline void __copyConstructElements( sizeof(double) * (nStopIndex - nStartIndex) ); break; case typelib_TypeClass_ENUM: - allocSeq( ppSequence, sizeof(int), nAlloc ); + allocSeq( ppSequence, sizeof(sal_Int32), nAlloc ); ::rtl_copyMemory( - (*ppSequence)->elements + (sizeof(int) * nStartIndex), - (char *)pSourceElements + (sizeof(int) * nStartIndex), - sizeof(int) * (nStopIndex - nStartIndex) ); + (*ppSequence)->elements + (sizeof(sal_Int32) * nStartIndex), + (char *)pSourceElements + (sizeof(sal_Int32) * nStartIndex), + sizeof(sal_Int32) * (nStopIndex - nStartIndex) ); break; case typelib_TypeClass_STRING: { @@ -416,7 +416,7 @@ static inline void __copyConstructElements( (typelib_TypeDescriptionReference **)(*ppSequence)->elements; for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos ) { - TYPE_ACQUIRE( ((typelib_TypeDescriptionReference **)pSourceElements)[nPos] ); + __TYPE_ACQUIRE( ((typelib_TypeDescriptionReference **)pSourceElements)[nPos] ); pDestElements[nPos] = ((typelib_TypeDescriptionReference **)pSourceElements)[nPos]; } break; @@ -498,9 +498,10 @@ static inline void __copyConstructElements( char * pSource = (char *)pSourceElements + (nElementSize * nPos); typelib_TypeDescriptionReference * pSetType = __unionGetSetType( pSource, pElementTypeDescr ); - uno_type_copyData( pDest + nValueOffset, - pSource + nValueOffset, - pSetType, acquire ); + ::uno_type_copyData( + pDest + nValueOffset, + pSource + nValueOffset, + pSetType, acquire ); *(sal_Int64 *)pDest = *(sal_Int64 *)pSource; typelib_typedescriptionreference_release( pSetType ); } |