diff options
author | Juergen Schmidt <jsc@openoffice.org> | 2001-03-30 12:41:39 +0000 |
---|---|---|
committer | Juergen Schmidt <jsc@openoffice.org> | 2001-03-30 12:41:39 +0000 |
commit | 9d46c93ef0b041260ae33366e5bf227279f5993e (patch) | |
tree | c576b6036d0d75fb8765bbb5c1d94c441e9624bb /cppu | |
parent | 13c013b16a77355a5f8c84b4b80a1d8d2255d5e5 (diff) |
insert/modify for handling of array types
Diffstat (limited to 'cppu')
-rw-r--r-- | cppu/source/uno/assign.hxx | 145 | ||||
-rw-r--r-- | cppu/source/uno/constr.hxx | 100 | ||||
-rw-r--r-- | cppu/source/uno/copy.hxx | 110 | ||||
-rw-r--r-- | cppu/source/uno/destr.hxx | 37 | ||||
-rw-r--r-- | cppu/source/uno/sequence.cxx | 22 |
5 files changed, 403 insertions, 11 deletions
diff --git a/cppu/source/uno/assign.hxx b/cppu/source/uno/assign.hxx index d24f07d214bb..dad60609b0c7 100644 --- a/cppu/source/uno/assign.hxx +++ b/cppu/source/uno/assign.hxx @@ -2,9 +2,9 @@ * * $RCSfile: assign.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: jl $ $Date: 2001-03-12 13:27:08 $ + * last change: $Author: jsc $ $Date: 2001-03-30 13:41:39 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -197,6 +197,126 @@ inline sal_Bool __assignStruct( return sal_True; } //-------------------------------------------------------------------------------------------------- +inline sal_Bool __assignArray( + void * pDest, void * pSource, + typelib_ArrayTypeDescription * pTypeDescr, + uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release ) +{ + typelib_TypeDescriptionReference * pElementTypeRef = ((typelib_IndirectTypeDescription *)pTypeDescr)->pType; + typelib_TypeDescription * pElementTypeDescr = NULL; + TYPELIB_DANGER_GET( &pElementTypeDescr, pElementTypeRef ); + sal_Int32 nTotalElements = pTypeDescr->nTotalElements; + sal_Int32 nElementSize = pElementTypeDescr->nSize; + sal_Int32 i; + sal_Bool bRet = sal_False; + + switch ( pElementTypeRef->eTypeClass ) + { + case typelib_TypeClass_CHAR: + case typelib_TypeClass_BOOLEAN: + case typelib_TypeClass_BYTE: + case typelib_TypeClass_SHORT: + case typelib_TypeClass_UNSIGNED_SHORT: + case typelib_TypeClass_LONG: + case typelib_TypeClass_UNSIGNED_LONG: + case typelib_TypeClass_HYPER: + case typelib_TypeClass_UNSIGNED_HYPER: + case typelib_TypeClass_FLOAT: + case typelib_TypeClass_DOUBLE: + for (i=0; i < nTotalElements; i++) + { + ::rtl_copyMemory((sal_Char *)pDest + i * nElementSize, + (sal_Char *)pSource + i * nElementSize, + nElementSize); + } + bRet = sal_True; + break; + case typelib_TypeClass_STRING: + for (i=0; i < nTotalElements; i++) + { + ::rtl_uString_assign( (rtl_uString **)pDest + i, + ((rtl_uString **)pSource)[i] ); + } + bRet = sal_True; + break; + case typelib_TypeClass_TYPE: + for (i=0; i < nTotalElements; i++) + { + ::typelib_typedescriptionreference_release( *((typelib_TypeDescriptionReference **)pDest + i) ); + TYPE_ACQUIRE( + *((typelib_TypeDescriptionReference **)pDest + i) = *((typelib_TypeDescriptionReference **)pSource + i) ); + + } + bRet = sal_True; + break; + case typelib_TypeClass_ANY: + for (i=0; i < nTotalElements; i++) + { + __destructAny( (uno_Any *)pDest + i, release ); + __copyConstructAny( (uno_Any *)pDest + i, (uno_Any *)pSource + i, + pElementTypeRef, pElementTypeDescr, acquire, 0 ); + } + bRet = sal_True; + break; + case typelib_TypeClass_ENUM: + for (i=0; i < nTotalElements; i++) + { + *((int *)pDest + i) = *((int *)pSource + i); + } + bRet = sal_True; + break; +#ifdef CPPU_ASSERTIONS + case typelib_TypeClass_TYPEDEF: + OSL_ENSURE( sal_False, "### unexpected typedef!" ); + break; +#endif + case typelib_TypeClass_STRUCT: + case typelib_TypeClass_EXCEPTION: + for (i=0; i < nTotalElements; i++) + { + bRet = __assignStruct( (sal_Char *)pDest + i * nElementSize, + (sal_Char *)pSource + i * nElementSize, + (typelib_CompoundTypeDescription *)pElementTypeDescr, + queryInterface, acquire, release ); + if ( !bRet ) + break; + } + bRet = sal_True; + break; + case typelib_TypeClass_UNION: + for (i=0; i < nTotalElements; i++) + { + __destructUnion( (sal_Char*)pDest + i * nElementSize, pElementTypeDescr, release ); + __copyConstructUnion( (sal_Char*)pDest + i * nElementSize, + (sal_Char*)pSource + i * nElementSize, + pElementTypeDescr, acquire, 0 ); + } + bRet = sal_True; + break; + case typelib_TypeClass_SEQUENCE: + for (i=0; i < nTotalElements; i++) + { + __destructSequence( *((uno_Sequence **)pDest + i), pElementTypeRef, pElementTypeDescr, release ); + ::osl_incrementInterlockedCount( &(*((uno_Sequence **)pSource + i))->nRefCount ); + *((uno_Sequence **)pDest + i) = *((uno_Sequence **)pSource + i); + } + bRet = sal_True; + break; + case typelib_TypeClass_INTERFACE: + for (i=0; i < nTotalElements; i++) + { + __assignInterface( (void **)((sal_Char*)pDest + i * nElementSize), + *(void **)((sal_Char*)pSource + i * nElementSize), + acquire, release ); + } + bRet = sal_True; + break; + } + + TYPELIB_DANGER_RELEASE( pElementTypeDescr ); + return bRet; +} +//-------------------------------------------------------------------------------------------------- inline sal_Bool __assignData( void * pDest, typelib_TypeDescriptionReference * pDestType, typelib_TypeDescription * pDestTypeDescr, @@ -470,6 +590,27 @@ inline sal_Bool __assignData( return bRet; } return sal_False; + case typelib_TypeClass_ARRAY: + { + sal_Bool bRet = sal_False; + if (pSourceTypeDescr) + { + typelib_ArrayTypeDescription * pTypeDescr = + (typelib_ArrayTypeDescription *)pSourceTypeDescr; + bRet = __assignArray( pDest, pSource, pTypeDescr, queryInterface, acquire, release ); + } + else + { + TYPELIB_DANGER_GET( &pSourceTypeDescr, pSourceType ); + typelib_ArrayTypeDescription * pTypeDescr = + (typelib_ArrayTypeDescription *)pSourceTypeDescr; + if ( pTypeDescr ) + bRet = __assignArray( pDest, pSource, pTypeDescr, queryInterface, acquire, release ); + TYPELIB_DANGER_RELEASE( pSourceTypeDescr ); + } + return bRet; + } + return sal_False; case typelib_TypeClass_UNION: if (__type_equals( pDestType, pSourceType )) { diff --git a/cppu/source/uno/constr.hxx b/cppu/source/uno/constr.hxx index 6cbe478a046e..03627e136246 100644 --- a/cppu/source/uno/constr.hxx +++ b/cppu/source/uno/constr.hxx @@ -2,9 +2,9 @@ * * $RCSfile: constr.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jl $ $Date: 2001-03-12 13:27:08 $ + * last change: $Author: jsc $ $Date: 2001-03-30 13:41:39 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -70,7 +70,6 @@ namespace cppu //#### construction ################################################################################ //################################################################################################## - //-------------------------------------------------------------------------------------------------- inline void __defaultConstructUnion( void * pMem, @@ -109,6 +108,89 @@ inline void __defaultConstructStruct( } //-------------------------------------------------------------------------------------------------- +inline void __defaultConstructArray( + void * pMem, + typelib_ArrayTypeDescription * pTypeDescr ) +{ + typelib_TypeDescription * pElementType = NULL; + TYPELIB_DANGER_GET( &pElementType, ((typelib_IndirectTypeDescription *)pTypeDescr)->pType ); + sal_Int32 nTotalElements = pTypeDescr->nTotalElements; + sal_Int32 nElementSize = pElementType->nSize; + sal_Int32 i; + switch ( pElementType->eTypeClass ) + { + case typelib_TypeClass_CHAR: + case typelib_TypeClass_BOOLEAN: + case typelib_TypeClass_BYTE: + case typelib_TypeClass_SHORT: + case typelib_TypeClass_UNSIGNED_SHORT: + case typelib_TypeClass_LONG: + case typelib_TypeClass_UNSIGNED_LONG: + case typelib_TypeClass_HYPER: + case typelib_TypeClass_UNSIGNED_HYPER: + case typelib_TypeClass_FLOAT: + case typelib_TypeClass_DOUBLE: + case typelib_TypeClass_INTERFACE: + ::rtl_zeroMemory(pMem, nElementSize * nTotalElements); + break; + + case typelib_TypeClass_STRING: + for (i=0; i < nTotalElements; i++) + { + rtl_uString** ppElement = (rtl_uString **)pMem + i; + *ppElement = 0; + RTL_USTRING_NEW( ppElement); + } + break; + case typelib_TypeClass_TYPE: + for (i=0; i < nTotalElements; i++) + { + typelib_TypeDescriptionReference** ppElement = (typelib_TypeDescriptionReference **)pMem + i; + *ppElement = __getVoidType(); + } + break; + case typelib_TypeClass_ANY: + for (i=0; i < nTotalElements; i++) + { + __CONSTRUCT_EMPTY_ANY( (uno_Any *)pMem + i ); + } + break; + case typelib_TypeClass_ENUM: + for (i=0; i < nTotalElements; i++) + { + *((int *)pMem + i) = ((typelib_EnumTypeDescription *)pElementType)->nDefaultEnumValue; + } + break; +#ifdef CPPU_ASSERTIONS + case typelib_TypeClass_TYPEDEF: + OSL_ENSURE( sal_False, "### unexpected typedef!" ); + break; +#endif + case typelib_TypeClass_STRUCT: + case typelib_TypeClass_EXCEPTION: + for (i=0; i < nTotalElements; i++) + { + __defaultConstructStruct( (sal_Char*)pMem + i * nElementSize, (typelib_CompoundTypeDescription *)pElementType ); + } + break; + case typelib_TypeClass_UNION: + for (i=0; i < nTotalElements; i++) + { + __defaultConstructUnion( (sal_Char*)pMem + i * nElementSize, pElementType ); + } + break; + case typelib_TypeClass_SEQUENCE: + for (i=0; i < nTotalElements; i++) + { + uno_Sequence** ppElement = (uno_Sequence **)pMem + i; + *ppElement = __getEmptySequence(); + } + break; + } + TYPELIB_DANGER_RELEASE( pElementType ); +} + +//-------------------------------------------------------------------------------------------------- inline void __defaultConstructData( void * pMem, typelib_TypeDescriptionReference * pType, @@ -184,6 +266,18 @@ inline void __defaultConstructData( TYPELIB_DANGER_RELEASE( pTypeDescr ); } break; + case typelib_TypeClass_ARRAY: + if (pTypeDescr) + { + __defaultConstructArray( pMem, (typelib_ArrayTypeDescription *)pTypeDescr ); + } + else + { + TYPELIB_DANGER_GET( &pTypeDescr, pType ); + __defaultConstructArray( pMem, (typelib_ArrayTypeDescription *)pTypeDescr ); + TYPELIB_DANGER_RELEASE( pTypeDescr ); + } + break; case typelib_TypeClass_UNION: if (pTypeDescr) { diff --git a/cppu/source/uno/copy.hxx b/cppu/source/uno/copy.hxx index 76d35ae318fa..9788aef34dde 100644 --- a/cppu/source/uno/copy.hxx +++ b/cppu/source/uno/copy.hxx @@ -2,9 +2,9 @@ * * $RCSfile: copy.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: jl $ $Date: 2001-03-12 13:27:08 $ + * last change: $Author: jsc $ $Date: 2001-03-30 13:41:39 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -117,6 +117,38 @@ inline void __copyConstructStruct( } } //-------------------------------------------------------------------------------------------------- +inline void __copyConstructArray( + void * pDest, void * pSource, + typelib_ArrayTypeDescription * pTypeDescr, + uno_AcquireFunc acquire, uno_Mapping * mapping ) +{ + typelib_TypeDescriptionReference * pElementTypeRef = ((typelib_IndirectTypeDescription *)pTypeDescr)->pType; + typelib_TypeDescription * pElementTypeDescr = NULL; + TYPELIB_DANGER_GET( &pElementTypeDescr, pElementTypeRef ); + sal_Int32 nElementSize = ((typelib_TypeDescription*)pElementTypeDescr)->nSize; + TYPELIB_DANGER_RELEASE( pElementTypeDescr ); + sal_Int32 nTotalElements = pTypeDescr->nTotalElements; + + if (mapping) + { + for(sal_Int32 i = 0; i < nTotalElements; i++) + { + ::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 ); + } + } +} +//-------------------------------------------------------------------------------------------------- inline void __copyConstructUnion( void * pDest, void * pSource, typelib_TypeDescription * pTypeDescr, @@ -239,6 +271,26 @@ inline void __copyConstructAnyFromData( TYPELIB_DANGER_RELEASE( pTypeDescr ); } break; + case typelib_TypeClass_ARRAY: + if (pTypeDescr) + { + pDestAny->pData = ::rtl_allocateMemory( pTypeDescr->nSize ); + __copyConstructArray( + pDestAny->pData, pSource, + (typelib_ArrayTypeDescription *)pTypeDescr, + acquire, mapping ); + } + else + { + TYPELIB_DANGER_GET( &pTypeDescr, pType ); + pDestAny->pData = ::rtl_allocateMemory( pTypeDescr->nSize ); + __copyConstructArray( + pDestAny->pData, pSource, + (typelib_ArrayTypeDescription *)pTypeDescr, + acquire, mapping ); + TYPELIB_DANGER_RELEASE( pTypeDescr ); + } + break; case typelib_TypeClass_UNION: if (pTypeDescr) { @@ -406,6 +458,22 @@ inline void __copyConstructAny( TYPELIB_DANGER_RELEASE( pTypeDescr ); } break; + case typelib_TypeClass_ARRAY: + if (pTypeDescr) + { + pDestAny->pData = ::rtl_allocateMemory( pTypeDescr->nSize ); + __defaultConstructArray( + pDestAny->pData, (typelib_ArrayTypeDescription *)pTypeDescr ); + } + else + { + TYPELIB_DANGER_GET( &pTypeDescr, pType ); + pDestAny->pData = ::rtl_allocateMemory( pTypeDescr->nSize ); + __defaultConstructArray( + pDestAny->pData, (typelib_ArrayTypeDescription *)pTypeDescr ); + TYPELIB_DANGER_RELEASE( pTypeDescr ); + } + break; case typelib_TypeClass_UNION: if (pTypeDescr) { @@ -498,6 +566,26 @@ inline void __copyConstructSequence( TYPELIB_DANGER_RELEASE( pElementTypeDescr ); break; } + case typelib_TypeClass_ARRAY: + { + typelib_TypeDescription * pElementTypeDescr = 0; + TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType ); + sal_Int32 nElementSize = pElementTypeDescr->nSize; + char * pSourceElements = pSource->elements; + pDest = (uno_Sequence *)::rtl_allocateMemory( + SAL_SEQUENCE_HEADER_SIZE + (nElements * nElementSize) ); + char * pElements = pDest->elements; + for ( sal_Int32 nPos = nElements; nPos--; ) + { + __copyConstructArray( + pElements + (nPos * nElementSize), + pSourceElements + (nPos * nElementSize), + (typelib_ArrayTypeDescription *)pElementTypeDescr, + acquire, mapping ); + } + TYPELIB_DANGER_RELEASE( pElementTypeDescr ); + break; + } case typelib_TypeClass_UNION: { typelib_TypeDescription * pElementTypeDescr = 0; @@ -671,6 +759,24 @@ inline void __copyConstructData( TYPELIB_DANGER_RELEASE( pTypeDescr ); } break; + case typelib_TypeClass_ARRAY: + if (pTypeDescr) + { + __copyConstructArray( + pDest, pSource, + (typelib_ArrayTypeDescription *)pTypeDescr, + acquire, mapping ); + } + else + { + TYPELIB_DANGER_GET( &pTypeDescr, pType ); + __copyConstructArray( + pDest, pSource, + (typelib_ArrayTypeDescription *)pTypeDescr, + acquire, mapping ); + TYPELIB_DANGER_RELEASE( pTypeDescr ); + } + break; case typelib_TypeClass_UNION: if (pTypeDescr) { diff --git a/cppu/source/uno/destr.hxx b/cppu/source/uno/destr.hxx index d8b2f70bfc47..cadf310d00a9 100644 --- a/cppu/source/uno/destr.hxx +++ b/cppu/source/uno/destr.hxx @@ -2,9 +2,9 @@ * * $RCSfile: destr.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: jl $ $Date: 2001-03-12 13:27:08 $ + * last change: $Author: jsc $ $Date: 2001-03-30 13:41:39 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -112,6 +112,27 @@ inline void __destructStruct( (char *)pValue + pMemberOffsets[nDescr], ppTypeRefs[nDescr], release ); } } +//-------------------------------------------------------------------------------------------------- +inline void __destructArray( + void * pValue, + typelib_ArrayTypeDescription * pTypeDescr, + uno_ReleaseFunc release ) + throw () +{ + typelib_TypeDescription * pElementType = NULL; + TYPELIB_DANGER_GET( &pElementType, ((typelib_IndirectTypeDescription *)pTypeDescr)->pType ); + sal_Int32 nElementSize = pElementType->nSize; + TYPELIB_DANGER_RELEASE( pElementType ); + + sal_Int32 nTotalElements = pTypeDescr->nTotalElements; + for(sal_Int32 i=0; i < nTotalElements; i++) + { + ::uno_type_destructData((sal_Char *)pValue + i * nElementSize, + ((typelib_IndirectTypeDescription *)pTypeDescr)->pType, release ); + } + + typelib_typedescriptionreference_release(((typelib_IndirectTypeDescription *)pTypeDescr)->pType); +} //================================================================================================== void destructSequence( uno_Sequence ** ppSequence, @@ -393,6 +414,18 @@ inline void __destructData( TYPELIB_DANGER_RELEASE( pTypeDescr ); } break; + case typelib_TypeClass_ARRAY: + if (pTypeDescr) + { + __destructArray( pValue, (typelib_ArrayTypeDescription *)pTypeDescr, release ); + } + else + { + TYPELIB_DANGER_GET( &pTypeDescr, pType ); + __destructArray( pValue, (typelib_ArrayTypeDescription *)pTypeDescr, release ); + TYPELIB_DANGER_RELEASE( pTypeDescr ); + } + break; case typelib_TypeClass_UNION: if (pTypeDescr) { diff --git a/cppu/source/uno/sequence.cxx b/cppu/source/uno/sequence.cxx index 529a31045a8b..d84ceb10ee37 100644 --- a/cppu/source/uno/sequence.cxx +++ b/cppu/source/uno/sequence.cxx @@ -2,9 +2,9 @@ * * $RCSfile: sequence.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: dbo $ $Date: 2001-03-28 10:46:10 $ + * last change: $Author: jsc $ $Date: 2001-03-30 13:41:39 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -255,6 +255,24 @@ static inline void __defaultConstructElements( TYPELIB_DANGER_RELEASE( pElementTypeDescr ); break; } + case typelib_TypeClass_ARRAY: + { + typelib_TypeDescription * pElementTypeDescr = 0; + TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType ); + sal_Int32 nElementSize = pElementTypeDescr->nSize; + + allocSeq( ppSequence, nElementSize, nAlloc ); + + char * pElements = (*ppSequence)->elements; + for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos ) + { + __defaultConstructArray( + pElements + (nElementSize * nPos), + (typelib_ArrayTypeDescription *)pElementTypeDescr ); + } + TYPELIB_DANGER_RELEASE( pElementTypeDescr ); + break; + } case typelib_TypeClass_UNION: { typelib_TypeDescription * pElementTypeDescr = 0; |