From 13c013b16a77355a5f8c84b4b80a1d8d2255d5e5 Mon Sep 17 00:00:00 2001 From: Juergen Schmidt Date: Fri, 30 Mar 2001 12:39:19 +0000 Subject: insert typelib functions for arrays --- cppu/source/typelib/static_types.cxx | 75 +++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 2 deletions(-) (limited to 'cppu/source/typelib/static_types.cxx') diff --git a/cppu/source/typelib/static_types.cxx b/cppu/source/typelib/static_types.cxx index dd490835a4bf..8f57f6165ff8 100644 --- a/cppu/source/typelib/static_types.cxx +++ b/cppu/source/typelib/static_types.cxx @@ -2,9 +2,9 @@ * * $RCSfile: static_types.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: dbo $ $Date: 2001-03-28 10:46:09 $ + * last change: $Author: jsc $ $Date: 2001-03-30 13:39:19 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -58,6 +58,11 @@ * * ************************************************************************/ +#ifdef SOLARIS +#include +#else +#include +#endif #include #include @@ -565,6 +570,72 @@ void SAL_CALL typelib_static_enum_type_init( *ppRef = (typelib_TypeDescriptionReference *)pReg; OSL_ASSERT( *ppRef == pReg->pWeakRef ); } +#ifndef CPPU_LEAK_STATIC_DATA + // another static ref + ++(*(sal_Int32 *)&(*ppRef)->pReserved); +#endif + } + } +} + +//################################################################################################## +void SAL_CALL typelib_static_array_type_init( + typelib_TypeDescriptionReference ** ppRef, + typelib_TypeDescriptionReference * pElementTypeRef, + sal_Int32 nDimensions, ... ) + SAL_THROW_EXTERN_C() +{ + if (! *ppRef) + { + MutexGuard aGuard( typelib_getStaticInitMutex() ); + if (! *ppRef) + { + OUStringBuffer aBuf( 32 ); + aBuf.append( pElementTypeRef->pTypeName ); + + va_list dimArgs; + va_start( dimArgs, nDimensions ); + sal_Int32 dim = 0; + sal_Int32 nElements = 1; + sal_Int32* pDimensions = new sal_Int32[nDimensions]; + for (sal_Int32 i=0; i < nDimensions; i++) + { + dim = va_arg( dimArgs, int); + pDimensions[i] = dim; + aBuf.appendAscii("["); + aBuf.append(dim); + aBuf.appendAscii("]"); + nElements *= dim; + } + va_end( dimArgs ); + OUString aTypeName( aBuf.makeStringAndClear() ); + + OSL_ASSERT( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(typelib_TypeClass_ARRAY) ); + if (! (*ppRef = __getTypeByName( aTypeName.pData ))) + { + typelib_TypeDescription * pReg = 0; + ::typelib_typedescription_newEmpty( + &pReg, typelib_TypeClass_ARRAY, aTypeName.pData ); + typelib_ArrayTypeDescription * pArray = (typelib_ArrayTypeDescription *)pReg; + + pArray->nDimensions = nDimensions; + pArray->nTotalElements = nElements; + pArray->pDimensions = pDimensions; + + typelib_typedescriptionreference_acquire(pElementTypeRef); + ((typelib_IndirectTypeDescription*)pArray)->pType = pElementTypeRef; + + pReg->pWeakRef = (typelib_TypeDescriptionReference *)pReg; + // sizeof( void ) not allowed + pReg->nSize = ::typelib_typedescription_getAlignedUnoSize( pReg, 0, pReg->nAlignment ); + pReg->nAlignment = ::adjustAlignment( pReg->nAlignment ); + pReg->bComplete = sal_True; + + ::typelib_typedescription_register( &pReg ); + *ppRef = (typelib_TypeDescriptionReference *)pReg; + OSL_ASSERT( *ppRef == pReg->pWeakRef ); + } else + delete [] pDimensions; #ifndef CPPU_LEAK_STATIC_DATA // another static ref ++((*ppRef)->nStaticRefCount); -- cgit v1.2.3