loplugin:flatten in cppu

Change-Id: I202698a0310bd26b98c1f744c8f21288f87643f9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92450
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2020-04-17 15:42:46 +02:00
parent dbda099d19
commit c12a5e8380
5 changed files with 422 additions and 422 deletions

View File

@@ -126,23 +126,23 @@ extern "C" {
static void delete_IdContainer( void * p ) static void delete_IdContainer( void * p )
{ {
if (p) if (!p)
return;
IdContainer * pId = static_cast< IdContainer * >( p );
if (pId->pCurrentContext)
{ {
IdContainer * pId = static_cast< IdContainer * >( p ); (*pId->pCurrentContextEnv->releaseInterface)(
if (pId->pCurrentContext) pId->pCurrentContextEnv, pId->pCurrentContext );
{ (*pId->pCurrentContextEnv->aBase.release)(
(*pId->pCurrentContextEnv->releaseInterface)( &pId->pCurrentContextEnv->aBase );
pId->pCurrentContextEnv, pId->pCurrentContext );
(*pId->pCurrentContextEnv->aBase.release)(
&pId->pCurrentContextEnv->aBase );
}
if (pId->bInit)
{
::rtl_byte_sequence_release( pId->pLocalThreadId );
::rtl_byte_sequence_release( pId->pCurrentId );
}
delete pId;
} }
if (pId->bInit)
{
::rtl_byte_sequence_release( pId->pLocalThreadId );
::rtl_byte_sequence_release( pId->pCurrentId );
}
delete pId;
} }
} }

View File

@@ -297,30 +297,30 @@ void SAL_CALL typelib_static_sequence_type_init(
typelib_TypeDescriptionReference * pElementType ) typelib_TypeDescriptionReference * pElementType )
SAL_THROW_EXTERN_C() SAL_THROW_EXTERN_C()
{ {
if (! *ppRef) if ( *ppRef)
return;
MutexGuard aGuard( typelib_StaticInitMutex::get() );
if ( *ppRef)
return;
OUString aTypeName = "[]" + OUString::unacquired(&pElementType->pTypeName);
static_assert( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(typelib_TypeClass_SEQUENCE) );
*ppRef = igetTypeByName( aTypeName.pData );
if (!*ppRef)
{ {
MutexGuard aGuard( typelib_StaticInitMutex::get() ); typelib_TypeDescription * pReg = nullptr;
if (! *ppRef) ::typelib_typedescription_new(
{ &pReg, typelib_TypeClass_SEQUENCE,
OUString aTypeName = "[]" + OUString::unacquired(&pElementType->pTypeName); aTypeName.pData, pElementType, 0, nullptr );
static_assert( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(typelib_TypeClass_SEQUENCE) ); ::typelib_typedescription_register( &pReg );
*ppRef = igetTypeByName( aTypeName.pData ); *ppRef = reinterpret_cast<typelib_TypeDescriptionReference *>(pReg);
if (!*ppRef) assert( *ppRef == pReg->pWeakRef );
{
typelib_TypeDescription * pReg = nullptr;
::typelib_typedescription_new(
&pReg, typelib_TypeClass_SEQUENCE,
aTypeName.pData, pElementType, 0, nullptr );
::typelib_typedescription_register( &pReg );
*ppRef = reinterpret_cast<typelib_TypeDescriptionReference *>(pReg);
assert( *ppRef == pReg->pWeakRef );
}
// another static ref:
++((*ppRef)->nStaticRefCount);
}
} }
// another static ref:
++((*ppRef)->nStaticRefCount);
} }
@@ -335,76 +335,76 @@ void init(
{ {
assert( eTypeClass == typelib_TypeClass_STRUCT || eTypeClass == typelib_TypeClass_EXCEPTION ); assert( eTypeClass == typelib_TypeClass_STRUCT || eTypeClass == typelib_TypeClass_EXCEPTION );
if (! *ppRef) if ( *ppRef)
return;
MutexGuard aGuard( typelib_StaticInitMutex::get() );
if ( *ppRef)
return;
assert( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(eTypeClass) );
OUString aTypeName( OUString::createFromAscii( pTypeName ) );
*ppRef = igetTypeByName( aTypeName.pData );
if (!*ppRef)
{ {
MutexGuard aGuard( typelib_StaticInitMutex::get() ); typelib_CompoundTypeDescription * pComp = nullptr;
if (! *ppRef) ::typelib_typedescription_newEmpty(
reinterpret_cast<typelib_TypeDescription **>(&pComp), eTypeClass, aTypeName.pData );
sal_Int32 nOffset = 0;
if (pBaseType)
{ {
assert( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(eTypeClass) ); ::typelib_typedescriptionreference_getDescription(
OUString aTypeName( OUString::createFromAscii( pTypeName ) ); reinterpret_cast<typelib_TypeDescription **>(&pComp->pBaseTypeDescription), pBaseType );
*ppRef = igetTypeByName( aTypeName.pData ); assert( pComp->pBaseTypeDescription );
if (!*ppRef) nOffset = pComp->pBaseTypeDescription->aBase.nSize;
{ assert( newAlignedSize( 0, pComp->pBaseTypeDescription->aBase.nSize, pComp->pBaseTypeDescription->aBase.nAlignment ) == pComp->pBaseTypeDescription->aBase.nSize ); // unexpected offset
typelib_CompoundTypeDescription * pComp = nullptr;
::typelib_typedescription_newEmpty(
reinterpret_cast<typelib_TypeDescription **>(&pComp), eTypeClass, aTypeName.pData );
sal_Int32 nOffset = 0;
if (pBaseType)
{
::typelib_typedescriptionreference_getDescription(
reinterpret_cast<typelib_TypeDescription **>(&pComp->pBaseTypeDescription), pBaseType );
assert( pComp->pBaseTypeDescription );
nOffset = pComp->pBaseTypeDescription->aBase.nSize;
assert( newAlignedSize( 0, pComp->pBaseTypeDescription->aBase.nSize, pComp->pBaseTypeDescription->aBase.nAlignment ) == pComp->pBaseTypeDescription->aBase.nSize ); // unexpected offset
}
if (nMembers)
{
pComp->nMembers = nMembers;
pComp->pMemberOffsets = new sal_Int32[ nMembers ];
pComp->ppTypeRefs = new typelib_TypeDescriptionReference *[ nMembers ];
if (pParameterizedTypes != nullptr) {
reinterpret_cast< typelib_StructTypeDescription * >(
pComp)->pParameterizedTypes
= new sal_Bool[nMembers];
}
for ( sal_Int32 i = 0 ; i < nMembers; ++i )
{
pComp->ppTypeRefs[i] = ppMembers[i];
::typelib_typedescriptionreference_acquire(
pComp->ppTypeRefs[i] );
// write offset
typelib_TypeDescription * pTD = nullptr;
TYPELIB_DANGER_GET( &pTD, pComp->ppTypeRefs[i] );
assert( pTD->nSize ); // void member?
nOffset = newAlignedSize( nOffset, pTD->nSize, pTD->nAlignment );
pComp->pMemberOffsets[i] = nOffset - pTD->nSize;
TYPELIB_DANGER_RELEASE( pTD );
if (pParameterizedTypes != nullptr) {
reinterpret_cast< typelib_StructTypeDescription * >(
pComp)->pParameterizedTypes[i]
= pParameterizedTypes[i];
}
}
}
typelib_TypeDescription * pReg = &pComp->aBase;
pReg->pWeakRef = reinterpret_cast<typelib_TypeDescriptionReference *>(pReg);
// sizeof(void) not allowed
pReg->nSize = ::typelib_typedescription_getAlignedUnoSize( pReg, 0, pReg->nAlignment );
pReg->nAlignment = adjustAlignment( pReg->nAlignment );
pReg->bComplete = false;
::typelib_typedescription_register( &pReg );
*ppRef = reinterpret_cast<typelib_TypeDescriptionReference *>(pReg);
assert( *ppRef == pReg->pWeakRef );
}
// another static ref:
++((*ppRef)->nStaticRefCount);
} }
if (nMembers)
{
pComp->nMembers = nMembers;
pComp->pMemberOffsets = new sal_Int32[ nMembers ];
pComp->ppTypeRefs = new typelib_TypeDescriptionReference *[ nMembers ];
if (pParameterizedTypes != nullptr) {
reinterpret_cast< typelib_StructTypeDescription * >(
pComp)->pParameterizedTypes
= new sal_Bool[nMembers];
}
for ( sal_Int32 i = 0 ; i < nMembers; ++i )
{
pComp->ppTypeRefs[i] = ppMembers[i];
::typelib_typedescriptionreference_acquire(
pComp->ppTypeRefs[i] );
// write offset
typelib_TypeDescription * pTD = nullptr;
TYPELIB_DANGER_GET( &pTD, pComp->ppTypeRefs[i] );
assert( pTD->nSize ); // void member?
nOffset = newAlignedSize( nOffset, pTD->nSize, pTD->nAlignment );
pComp->pMemberOffsets[i] = nOffset - pTD->nSize;
TYPELIB_DANGER_RELEASE( pTD );
if (pParameterizedTypes != nullptr) {
reinterpret_cast< typelib_StructTypeDescription * >(
pComp)->pParameterizedTypes[i]
= pParameterizedTypes[i];
}
}
}
typelib_TypeDescription * pReg = &pComp->aBase;
pReg->pWeakRef = reinterpret_cast<typelib_TypeDescriptionReference *>(pReg);
// sizeof(void) not allowed
pReg->nSize = ::typelib_typedescription_getAlignedUnoSize( pReg, 0, pReg->nAlignment );
pReg->nAlignment = adjustAlignment( pReg->nAlignment );
pReg->bComplete = false;
::typelib_typedescription_register( &pReg );
*ppRef = reinterpret_cast<typelib_TypeDescriptionReference *>(pReg);
assert( *ppRef == pReg->pWeakRef );
} }
// another static ref:
++((*ppRef)->nStaticRefCount);
} }
} }
@@ -449,60 +449,60 @@ void SAL_CALL typelib_static_mi_interface_type_init(
typelib_TypeDescriptionReference ** ppBaseTypes ) typelib_TypeDescriptionReference ** ppBaseTypes )
SAL_THROW_EXTERN_C() SAL_THROW_EXTERN_C()
{ {
if (! *ppRef) if ( *ppRef)
return;
MutexGuard aGuard( typelib_StaticInitMutex::get() );
if ( *ppRef)
return;
static_assert( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(typelib_TypeClass_INTERFACE) );
OUString aTypeName( OUString::createFromAscii( pTypeName ) );
*ppRef = igetTypeByName( aTypeName.pData );
if (!*ppRef)
{ {
MutexGuard aGuard( typelib_StaticInitMutex::get() ); typelib_InterfaceTypeDescription * pIface = nullptr;
if (! *ppRef) ::typelib_typedescription_newEmpty(
reinterpret_cast<typelib_TypeDescription **>(&pIface), typelib_TypeClass_INTERFACE, aTypeName.pData );
pIface->nBaseTypes = std::max< sal_Int32 >(nBaseTypes, 1);
pIface->ppBaseTypes = new typelib_InterfaceTypeDescription *[
pIface->nBaseTypes];
if (nBaseTypes > 0)
{ {
static_assert( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(typelib_TypeClass_INTERFACE) ); for (sal_Int32 i = 0; i < nBaseTypes; ++i) {
OUString aTypeName( OUString::createFromAscii( pTypeName ) ); pIface->ppBaseTypes[i] = nullptr;
*ppRef = igetTypeByName( aTypeName.pData ); ::typelib_typedescriptionreference_getDescription(
if (!*ppRef) reinterpret_cast<typelib_TypeDescription **>(&pIface->ppBaseTypes[i]), ppBaseTypes[i] );
{ assert( pIface->ppBaseTypes[i] );
typelib_InterfaceTypeDescription * pIface = nullptr;
::typelib_typedescription_newEmpty(
reinterpret_cast<typelib_TypeDescription **>(&pIface), typelib_TypeClass_INTERFACE, aTypeName.pData );
pIface->nBaseTypes = std::max< sal_Int32 >(nBaseTypes, 1);
pIface->ppBaseTypes = new typelib_InterfaceTypeDescription *[
pIface->nBaseTypes];
if (nBaseTypes > 0)
{
for (sal_Int32 i = 0; i < nBaseTypes; ++i) {
pIface->ppBaseTypes[i] = nullptr;
::typelib_typedescriptionreference_getDescription(
reinterpret_cast<typelib_TypeDescription **>(&pIface->ppBaseTypes[i]), ppBaseTypes[i] );
assert( pIface->ppBaseTypes[i] );
}
}
else
{
pIface->ppBaseTypes[0] = nullptr;
::typelib_typedescriptionreference_getDescription(
reinterpret_cast<typelib_TypeDescription **>(&pIface->ppBaseTypes[0]),
* ::typelib_static_type_getByTypeClass( typelib_TypeClass_INTERFACE ) );
assert( pIface->ppBaseTypes[0] );
}
pIface->pBaseTypeDescription = pIface->ppBaseTypes[0];
typelib_typedescription_acquire(
&pIface->pBaseTypeDescription->aBase);
typelib_TypeDescription * pReg = &pIface->aBase;
pReg->pWeakRef = reinterpret_cast<typelib_TypeDescriptionReference *>(pReg);
// sizeof(void) not allowed
pReg->nSize = ::typelib_typedescription_getAlignedUnoSize( pReg, 0, pReg->nAlignment );
pReg->nAlignment = adjustAlignment( pReg->nAlignment );
pReg->bComplete = false;
::typelib_typedescription_register( &pReg );
*ppRef = reinterpret_cast<typelib_TypeDescriptionReference *>(pReg);
assert( *ppRef == pReg->pWeakRef );
} }
// another static ref:
++((*ppRef)->nStaticRefCount);
} }
else
{
pIface->ppBaseTypes[0] = nullptr;
::typelib_typedescriptionreference_getDescription(
reinterpret_cast<typelib_TypeDescription **>(&pIface->ppBaseTypes[0]),
* ::typelib_static_type_getByTypeClass( typelib_TypeClass_INTERFACE ) );
assert( pIface->ppBaseTypes[0] );
}
pIface->pBaseTypeDescription = pIface->ppBaseTypes[0];
typelib_typedescription_acquire(
&pIface->pBaseTypeDescription->aBase);
typelib_TypeDescription * pReg = &pIface->aBase;
pReg->pWeakRef = reinterpret_cast<typelib_TypeDescriptionReference *>(pReg);
// sizeof(void) not allowed
pReg->nSize = ::typelib_typedescription_getAlignedUnoSize( pReg, 0, pReg->nAlignment );
pReg->nAlignment = adjustAlignment( pReg->nAlignment );
pReg->bComplete = false;
::typelib_typedescription_register( &pReg );
*ppRef = reinterpret_cast<typelib_TypeDescriptionReference *>(pReg);
assert( *ppRef == pReg->pWeakRef );
} }
// another static ref:
++((*ppRef)->nStaticRefCount);
} }
@@ -512,37 +512,37 @@ void SAL_CALL typelib_static_enum_type_init(
sal_Int32 nDefaultValue ) sal_Int32 nDefaultValue )
SAL_THROW_EXTERN_C() SAL_THROW_EXTERN_C()
{ {
if (! *ppRef) if ( *ppRef)
return;
MutexGuard aGuard( typelib_StaticInitMutex::get() );
if ( *ppRef)
return;
static_assert( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(typelib_TypeClass_ENUM) );
OUString aTypeName( OUString::createFromAscii( pTypeName ) );
*ppRef = igetTypeByName( aTypeName.pData );
if (!*ppRef)
{ {
MutexGuard aGuard( typelib_StaticInitMutex::get() ); typelib_TypeDescription * pReg = nullptr;
if (! *ppRef) ::typelib_typedescription_newEmpty(
{ &pReg, typelib_TypeClass_ENUM, aTypeName.pData );
static_assert( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(typelib_TypeClass_ENUM) ); typelib_EnumTypeDescription * pEnum = reinterpret_cast<typelib_EnumTypeDescription *>(pReg);
OUString aTypeName( OUString::createFromAscii( pTypeName ) );
*ppRef = igetTypeByName( aTypeName.pData );
if (!*ppRef)
{
typelib_TypeDescription * pReg = nullptr;
::typelib_typedescription_newEmpty(
&pReg, typelib_TypeClass_ENUM, aTypeName.pData );
typelib_EnumTypeDescription * pEnum = reinterpret_cast<typelib_EnumTypeDescription *>(pReg);
pEnum->nDefaultEnumValue = nDefaultValue; pEnum->nDefaultEnumValue = nDefaultValue;
pReg->pWeakRef = reinterpret_cast<typelib_TypeDescriptionReference *>(pReg); pReg->pWeakRef = reinterpret_cast<typelib_TypeDescriptionReference *>(pReg);
// sizeof(void) not allowed // sizeof(void) not allowed
pReg->nSize = ::typelib_typedescription_getAlignedUnoSize( pReg, 0, pReg->nAlignment ); pReg->nSize = ::typelib_typedescription_getAlignedUnoSize( pReg, 0, pReg->nAlignment );
pReg->nAlignment = ::adjustAlignment( pReg->nAlignment ); pReg->nAlignment = ::adjustAlignment( pReg->nAlignment );
pReg->bComplete = false; pReg->bComplete = false;
::typelib_typedescription_register( &pReg ); ::typelib_typedescription_register( &pReg );
*ppRef = reinterpret_cast<typelib_TypeDescriptionReference *>(pReg); *ppRef = reinterpret_cast<typelib_TypeDescriptionReference *>(pReg);
assert( *ppRef == pReg->pWeakRef ); assert( *ppRef == pReg->pWeakRef );
}
// another static ref:
++((*ppRef)->nStaticRefCount);
}
} }
// another static ref:
++((*ppRef)->nStaticRefCount);
} }
} // extern "C" } // extern "C"

View File

@@ -362,42 +362,42 @@ static void typelib_typedescription_initTables(
} }
MutexGuard aGuard( Init::get().getMutex() ); MutexGuard aGuard( Init::get().getMutex() );
if( !pTD->bComplete ) if( pTD->bComplete )
{ return;
// create the index table from member to function table
pITD->pMapMemberIndexToFunctionIndex = new sal_Int32[ pITD->nAllMembers ];
sal_Int32 nAdditionalOffset = 0; // +1 for read/write attributes
sal_Int32 i;
for( i = 0; i < pITD->nAllMembers; i++ )
{
// index to the get method of the attribute
pITD->pMapMemberIndexToFunctionIndex[i] = i + nAdditionalOffset;
// extra offset if it is a read/write attribute?
if (aReadWriteAttributes[i])
{
// a read/write attribute
nAdditionalOffset++;
}
}
// create the index table from function to member table // create the index table from member to function table
pITD->pMapFunctionIndexToMemberIndex = new sal_Int32[ pITD->nAllMembers + nAdditionalOffset ]; pITD->pMapMemberIndexToFunctionIndex = new sal_Int32[ pITD->nAllMembers ];
nAdditionalOffset = 0; // +1 for read/write attributes sal_Int32 nAdditionalOffset = 0; // +1 for read/write attributes
for( i = 0; i < pITD->nAllMembers; i++ ) sal_Int32 i;
for( i = 0; i < pITD->nAllMembers; i++ )
{
// index to the get method of the attribute
pITD->pMapMemberIndexToFunctionIndex[i] = i + nAdditionalOffset;
// extra offset if it is a read/write attribute?
if (aReadWriteAttributes[i])
{ {
// index to the get method of the attribute // a read/write attribute
pITD->pMapFunctionIndexToMemberIndex[i + nAdditionalOffset] = i; nAdditionalOffset++;
// extra offset if it is a read/write attribute?
if (aReadWriteAttributes[i])
{
// a read/write attribute
pITD->pMapFunctionIndexToMemberIndex[i + ++nAdditionalOffset] = i;
}
} }
// must be the last action after all initialization is done
pITD->nMapFunctionIndexToMemberIndex = pITD->nAllMembers + nAdditionalOffset;
pTD->bComplete = true;
} }
// create the index table from function to member table
pITD->pMapFunctionIndexToMemberIndex = new sal_Int32[ pITD->nAllMembers + nAdditionalOffset ];
nAdditionalOffset = 0; // +1 for read/write attributes
for( i = 0; i < pITD->nAllMembers; i++ )
{
// index to the get method of the attribute
pITD->pMapFunctionIndexToMemberIndex[i + nAdditionalOffset] = i;
// extra offset if it is a read/write attribute?
if (aReadWriteAttributes[i])
{
// a read/write attribute
pITD->pMapFunctionIndexToMemberIndex[i + ++nAdditionalOffset] = i;
}
}
// must be the last action after all initialization is done
pITD->nMapFunctionIndexToMemberIndex = pITD->nAllMembers + nAdditionalOffset;
pTD->bComplete = true;
} }
namespace { namespace {
@@ -1363,68 +1363,68 @@ extern "C" void SAL_CALL typelib_typedescription_release(
{ {
sal_Int32 ref = osl_atomic_decrement( &pTD->nRefCount ); sal_Int32 ref = osl_atomic_decrement( &pTD->nRefCount );
OSL_ASSERT(ref >= 0); OSL_ASSERT(ref >= 0);
if (0 == ref) if (0 != ref)
{ return;
TypeDescriptor_Init_Impl &rInit = Init::get();
if( TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK( pTD->eTypeClass ) )
{
if( pTD->pWeakRef )
{
{
MutexGuard aGuard( rInit.getMutex() );
// remove this description from the weak reference
pTD->pWeakRef->pType = nullptr;
}
typelib_typedescriptionreference_release( pTD->pWeakRef );
}
}
else
{
// this description is a reference too, so remove it from the hash table
if( rInit.pWeakMap )
{
MutexGuard aGuard( rInit.getMutex() );
WeakMap_Impl::iterator aIt = rInit.pWeakMap->find( pTD->pTypeName->buffer );
if( aIt != rInit.pWeakMap->end() && static_cast<void *>((*aIt).second) == static_cast<void *>(pTD) )
{
// remove only if it contains the same object
rInit.pWeakMap->erase( aIt );
}
}
}
typelib_typedescription_destructExtendedMembers( pTD ); TypeDescriptor_Init_Impl &rInit = Init::get();
rtl_uString_release( pTD->pTypeName ); if( TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK( pTD->eTypeClass ) )
{
if( pTD->pWeakRef )
{
{
MutexGuard aGuard( rInit.getMutex() );
// remove this description from the weak reference
pTD->pWeakRef->pType = nullptr;
}
typelib_typedescriptionreference_release( pTD->pWeakRef );
}
}
else
{
// this description is a reference too, so remove it from the hash table
if( rInit.pWeakMap )
{
MutexGuard aGuard( rInit.getMutex() );
WeakMap_Impl::iterator aIt = rInit.pWeakMap->find( pTD->pTypeName->buffer );
if( aIt != rInit.pWeakMap->end() && static_cast<void *>((*aIt).second) == static_cast<void *>(pTD) )
{
// remove only if it contains the same object
rInit.pWeakMap->erase( aIt );
}
}
}
typelib_typedescription_destructExtendedMembers( pTD );
rtl_uString_release( pTD->pTypeName );
#if OSL_DEBUG_LEVEL > 0 #if OSL_DEBUG_LEVEL > 0
switch( pTD->eTypeClass ) switch( pTD->eTypeClass )
{ {
case typelib_TypeClass_SEQUENCE: case typelib_TypeClass_SEQUENCE:
osl_atomic_decrement( &rInit.nIndirectTypeDescriptionCount ); osl_atomic_decrement( &rInit.nIndirectTypeDescriptionCount );
break; break;
case typelib_TypeClass_STRUCT: case typelib_TypeClass_STRUCT:
case typelib_TypeClass_EXCEPTION: case typelib_TypeClass_EXCEPTION:
osl_atomic_decrement( &rInit.nCompoundTypeDescriptionCount ); osl_atomic_decrement( &rInit.nCompoundTypeDescriptionCount );
break; break;
case typelib_TypeClass_INTERFACE: case typelib_TypeClass_INTERFACE:
osl_atomic_decrement( &rInit.nInterfaceTypeDescriptionCount ); osl_atomic_decrement( &rInit.nInterfaceTypeDescriptionCount );
break; break;
case typelib_TypeClass_INTERFACE_METHOD: case typelib_TypeClass_INTERFACE_METHOD:
osl_atomic_decrement( &rInit.nInterfaceMethodTypeDescriptionCount ); osl_atomic_decrement( &rInit.nInterfaceMethodTypeDescriptionCount );
break; break;
case typelib_TypeClass_INTERFACE_ATTRIBUTE: case typelib_TypeClass_INTERFACE_ATTRIBUTE:
osl_atomic_decrement( &rInit.nInterfaceAttributeTypeDescriptionCount ); osl_atomic_decrement( &rInit.nInterfaceAttributeTypeDescriptionCount );
break; break;
case typelib_TypeClass_ENUM: case typelib_TypeClass_ENUM:
osl_atomic_decrement( &rInit.nEnumTypeDescriptionCount ); osl_atomic_decrement( &rInit.nEnumTypeDescriptionCount );
break; break;
default: default:
osl_atomic_decrement( &rInit.nTypeDescriptionCount ); osl_atomic_decrement( &rInit.nTypeDescriptionCount );
} }
#endif #endif
freeTypeDescription(pTD); freeTypeDescription(pTD);
}
} }
@@ -1899,103 +1899,103 @@ extern "C" void SAL_CALL typelib_typedescription_getByName(
typelib_typedescriptionreference_release( pTDR ); typelib_typedescriptionreference_release( pTDR );
} }
if (nullptr != *ppRet)
return;
// check for sequence
OUString const & name = OUString::unacquired( &pName );
if (2 < name.getLength() && '[' == name[ 0 ])
{
OUString element_name( name.copy( 2 ) );
typelib_TypeDescription * element_td = nullptr;
typelib_typedescription_getByName( &element_td, element_name.pData );
if (nullptr != element_td)
{
typelib_typedescription_new(
ppRet, typelib_TypeClass_SEQUENCE, pName, element_td->pWeakRef, 0, nullptr );
// register?
typelib_typedescription_release( element_td );
}
}
if (nullptr == *ppRet) if (nullptr == *ppRet)
{ {
// check for sequence // Check for derived interface member type:
OUString const & name = OUString::unacquired( &pName ); sal_Int32 i1 = name.lastIndexOf(":@");
if (2 < name.getLength() && '[' == name[ 0 ]) if (i1 >= 0) {
{ sal_Int32 i2 = i1 + RTL_CONSTASCII_LENGTH(":@");
OUString element_name( name.copy( 2 ) ); sal_Int32 i3 = name.indexOf(',', i2);
typelib_TypeDescription * element_td = nullptr; if (i3 >= 0) {
typelib_typedescription_getByName( &element_td, element_name.pData ); sal_Int32 i4 = name.indexOf(':', i3);
if (nullptr != element_td) if (i4 >= 0) {
{ typelib_TypeDescriptionReference * pBaseRef = nullptr;
typelib_typedescription_new( typelib_TypeDescription * pBase = nullptr;
ppRet, typelib_TypeClass_SEQUENCE, pName, element_td->pWeakRef, 0, nullptr ); typelib_TypeDescription * pInterface = nullptr;
// register? typelib_typedescriptionreference_getByName(
typelib_typedescription_release( element_td ); &pBaseRef, name.copy(0, i1).pData);
} if (pBaseRef != nullptr) {
} typelib_typedescriptionreference_getDescription(
if (nullptr == *ppRet) &pBase, pBaseRef);
{ }
// Check for derived interface member type: typelib_typedescription_getByName(
sal_Int32 i1 = name.lastIndexOf(":@"); &pInterface, name.copy(i4 + 1).pData);
if (i1 >= 0) { if (!createDerivedInterfaceMemberDescription(
sal_Int32 i2 = i1 + RTL_CONSTASCII_LENGTH(":@"); ppRet, name, pBaseRef, pBase, pInterface,
sal_Int32 i3 = name.indexOf(',', i2); name.copy(i2, i3 - i2).toInt32(),
if (i3 >= 0) { name.copy(i3 + 1, i4 - i3 - 1).toInt32()))
sal_Int32 i4 = name.indexOf(':', i3); {
if (i4 >= 0) { if (pInterface != nullptr) {
typelib_TypeDescriptionReference * pBaseRef = nullptr; typelib_typedescription_release(pInterface);
typelib_TypeDescription * pBase = nullptr;
typelib_TypeDescription * pInterface = nullptr;
typelib_typedescriptionreference_getByName(
&pBaseRef, name.copy(0, i1).pData);
if (pBaseRef != nullptr) {
typelib_typedescriptionreference_getDescription(
&pBase, pBaseRef);
} }
typelib_typedescription_getByName( if (pBase != nullptr) {
&pInterface, name.copy(i4 + 1).pData); typelib_typedescription_release(pBase);
if (!createDerivedInterfaceMemberDescription( }
ppRet, name, pBaseRef, pBase, pInterface, if (pBaseRef != nullptr) {
name.copy(i2, i3 - i2).toInt32(), typelib_typedescriptionreference_release(
name.copy(i3 + 1, i4 - i3 - 1).toInt32())) pBaseRef);
{
if (pInterface != nullptr) {
typelib_typedescription_release(pInterface);
}
if (pBase != nullptr) {
typelib_typedescription_release(pBase);
}
if (pBaseRef != nullptr) {
typelib_typedescriptionreference_release(
pBaseRef);
}
} }
} }
} }
} }
} }
if (nullptr == *ppRet) }
{ if (nullptr == *ppRet)
// on demand access {
rInit.callChain( ppRet, pName ); // on demand access
} rInit.callChain( ppRet, pName );
}
if( *ppRet ) if( !(*ppRet) )
{ return;
// typedescription found
if (typelib_TypeClass_TYPEDEF == (*ppRet)->eTypeClass)
{
typelib_TypeDescription * pTD = nullptr;
typelib_typedescriptionreference_getDescription(
&pTD, reinterpret_cast<typelib_IndirectTypeDescription *>(*ppRet)->pType );
typelib_typedescription_release( *ppRet );
*ppRet = pTD;
}
else
{
// set to on demand
(*ppRet)->bOnDemand = true;
// The type description is hold by the reference until
// on demand is activated.
typelib_typedescription_register( ppRet );
// insert into the cache // typedescription found
MutexGuard aGuard( rInit.getMutex() ); if (typelib_TypeClass_TYPEDEF == (*ppRet)->eTypeClass)
if( !rInit.pCache ) {
rInit.pCache.reset( new TypeDescriptionList_Impl ); typelib_TypeDescription * pTD = nullptr;
if( static_cast<sal_Int32>(rInit.pCache->size()) >= nCacheSize ) typelib_typedescriptionreference_getDescription(
{ &pTD, reinterpret_cast<typelib_IndirectTypeDescription *>(*ppRet)->pType );
typelib_typedescription_release( rInit.pCache->front() ); typelib_typedescription_release( *ppRet );
rInit.pCache->pop_front(); *ppRet = pTD;
} }
// descriptions in the cache must be acquired! else
typelib_typedescription_acquire( *ppRet ); {
rInit.pCache->push_back( *ppRet ); // set to on demand
} (*ppRet)->bOnDemand = true;
// The type description is hold by the reference until
// on demand is activated.
typelib_typedescription_register( ppRet );
// insert into the cache
MutexGuard aGuard( rInit.getMutex() );
if( !rInit.pCache )
rInit.pCache.reset( new TypeDescriptionList_Impl );
if( static_cast<sal_Int32>(rInit.pCache->size()) >= nCacheSize )
{
typelib_typedescription_release( rInit.pCache->front() );
rInit.pCache->pop_front();
} }
// descriptions in the cache must be acquired!
typelib_typedescription_acquire( *ppRet );
rInit.pCache->push_back( *ppRet );
} }
} }
@@ -2204,26 +2204,26 @@ extern "C" void typelib_typedescriptionreference_getByName(
*ppRet = nullptr; *ppRet = nullptr;
} }
TypeDescriptor_Init_Impl &rInit = Init::get(); TypeDescriptor_Init_Impl &rInit = Init::get();
if( rInit.pWeakMap ) if( !rInit.pWeakMap )
return;
MutexGuard aGuard( rInit.getMutex() );
WeakMap_Impl::const_iterator aIt = rInit.pWeakMap->find( pName->buffer );
if( aIt == rInit.pWeakMap->end() )
return;
sal_Int32 n = osl_atomic_increment( &(*aIt).second->nRefCount );
if( n > 1 )
{ {
MutexGuard aGuard( rInit.getMutex() ); // The reference is incremented. The object cannot be destroyed.
WeakMap_Impl::const_iterator aIt = rInit.pWeakMap->find( pName->buffer ); // Release the guard at the earliest point.
if( aIt != rInit.pWeakMap->end() ) *ppRet = (*aIt).second;
{ }
sal_Int32 n = osl_atomic_increment( &(*aIt).second->nRefCount ); else
if( n > 1 ) {
{ // destruction of this type in progress (another thread!)
// The reference is incremented. The object cannot be destroyed. // no access through this weak reference
// Release the guard at the earliest point. (void)osl_atomic_decrement( &(*aIt).second->nRefCount );
*ppRet = (*aIt).second;
}
else
{
// destruction of this type in progress (another thread!)
// no access through this weak reference
(void)osl_atomic_decrement( &(*aIt).second->nRefCount );
}
}
} }
} }
@@ -2258,20 +2258,20 @@ extern "C" void SAL_CALL typelib_setCacheSize( sal_Int32 nNewSize )
SAL_THROW_EXTERN_C() SAL_THROW_EXTERN_C()
{ {
OSL_ENSURE( nNewSize >= 0, "### illegal cache size given!" ); OSL_ENSURE( nNewSize >= 0, "### illegal cache size given!" );
if (nNewSize >= 0) if (nNewSize < 0)
return;
TypeDescriptor_Init_Impl &rInit = Init::get();
MutexGuard aGuard( rInit.getMutex() );
if ((nNewSize < nCacheSize) && rInit.pCache)
{ {
TypeDescriptor_Init_Impl &rInit = Init::get(); while (static_cast<sal_Int32>(rInit.pCache->size()) != nNewSize)
MutexGuard aGuard( rInit.getMutex() );
if ((nNewSize < nCacheSize) && rInit.pCache)
{ {
while (static_cast<sal_Int32>(rInit.pCache->size()) != nNewSize) typelib_typedescription_release( rInit.pCache->front() );
{ rInit.pCache->pop_front();
typelib_typedescription_release( rInit.pCache->front() );
rInit.pCache->pop_front();
}
} }
nCacheSize = nNewSize;
} }
nCacheSize = nNewSize;
} }

View File

@@ -844,25 +844,25 @@ static void unoenv_computeObjectIdentifier(
::cppu::binuno_queryInterface( ::cppu::binuno_queryInterface(
pInterface, *typelib_static_type_getByTypeClass( pInterface, *typelib_static_type_getByTypeClass(
typelib_TypeClass_INTERFACE ) )); typelib_TypeClass_INTERFACE ) ));
if (nullptr != pUnoI) if (nullptr == pUnoI)
{ return;
(*pUnoI->release)( pUnoI );
// interface (*pUnoI->release)( pUnoI );
OUStringBuffer oid( 64 ); // interface
oid.append( reinterpret_cast< sal_Int64 >(pUnoI), 16 ); OUStringBuffer oid( 64 );
oid.append( ';' ); oid.append( reinterpret_cast< sal_Int64 >(pUnoI), 16 );
// environment[context] oid.append( ';' );
oid.append( pEnv->aBase.pTypeName ); // environment[context]
oid.append( '[' ); oid.append( pEnv->aBase.pTypeName );
oid.append( reinterpret_cast< sal_Int64 >( oid.append( '[' );
reinterpret_cast< oid.append( reinterpret_cast< sal_Int64 >(
uno_Environment * >(pEnv)->pContext ), 16 ); reinterpret_cast<
// process;good guid uno_Environment * >(pEnv)->pContext ), 16 );
oid.append( unoenv_getStaticOIdPart() ); // process;good guid
OUString aStr( oid.makeStringAndClear() ); oid.append( unoenv_getStaticOIdPart() );
*ppOId = aStr.pData; OUString aStr( oid.makeStringAndClear() );
::rtl_uString_acquire( *ppOId ); *ppOId = aStr.pData;
} ::rtl_uString_acquire( *ppOId );
} }

View File

@@ -236,32 +236,32 @@ static void mediate_mapInterface(
typelib_InterfaceTypeDescription * pInterfaceTypeDescr ) typelib_InterfaceTypeDescription * pInterfaceTypeDescr )
{ {
OSL_ENSURE( pMapping && ppOut, "### null ptr!" ); OSL_ENSURE( pMapping && ppOut, "### null ptr!" );
if (pMapping && ppOut) if (!(pMapping && ppOut))
{ return;
uno_Mediate_Mapping * that = static_cast< uno_Mediate_Mapping * >( pMapping );
uno_Mapping * pFrom2Uno = that->aFrom2Uno.get();
uno_Interface * pUnoI = nullptr; uno_Mediate_Mapping * that = static_cast< uno_Mediate_Mapping * >( pMapping );
(*pFrom2Uno->mapInterface)( pFrom2Uno, reinterpret_cast<void **>(&pUnoI), pInterface, pInterfaceTypeDescr ); uno_Mapping * pFrom2Uno = that->aFrom2Uno.get();
if (nullptr == pUnoI)
uno_Interface * pUnoI = nullptr;
(*pFrom2Uno->mapInterface)( pFrom2Uno, reinterpret_cast<void **>(&pUnoI), pInterface, pInterfaceTypeDescr );
if (nullptr == pUnoI)
{
void * pOut = *ppOut;
if (nullptr != pOut)
{ {
void * pOut = *ppOut; uno_ExtEnvironment * pTo = that->aTo.get()->pExtEnv;
if (nullptr != pOut) OSL_ENSURE( nullptr != pTo, "### cannot release out interface: leaking!" );
{ if (nullptr != pTo)
uno_ExtEnvironment * pTo = that->aTo.get()->pExtEnv; (*pTo->releaseInterface)( pTo, pOut );
OSL_ENSURE( nullptr != pTo, "### cannot release out interface: leaking!" ); *ppOut = nullptr; // set to 0 anyway, because mapping was not successful!
if (nullptr != pTo)
(*pTo->releaseInterface)( pTo, pOut );
*ppOut = nullptr; // set to 0 anyway, because mapping was not successful!
}
}
else
{
uno_Mapping * pUno2To = that->aUno2To.get();
(*pUno2To->mapInterface)( pUno2To, ppOut, pUnoI, pInterfaceTypeDescr );
(*pUnoI->release)( pUnoI );
} }
} }
else
{
uno_Mapping * pUno2To = that->aUno2To.get();
(*pUno2To->mapInterface)( pUno2To, ppOut, pUnoI, pInterfaceTypeDescr );
(*pUnoI->release)( pUnoI );
}
} }
} }