[Libreoffice-commits] core.git: cppu/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Sat Apr 18 07:57:04 UTC 2020
cppu/source/threadpool/current.cxx | 30 +-
cppu/source/typelib/static_types.cxx | 324 ++++++++++++++---------------
cppu/source/typelib/typelib.cxx | 382 +++++++++++++++++------------------
cppu/source/uno/lbenv.cxx | 38 +--
cppu/source/uno/lbmap.cxx | 44 ++--
5 files changed, 409 insertions(+), 409 deletions(-)
New commits:
commit c12a5e83802699615d4226c83c2e6f135a3485b4
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Apr 17 15:42:46 2020 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Apr 18 09:56:28 2020 +0200
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 at collabora.co.uk>
diff --git a/cppu/source/threadpool/current.cxx b/cppu/source/threadpool/current.cxx
index 665f1b7c636e..7dbfc9050488 100644
--- a/cppu/source/threadpool/current.cxx
+++ b/cppu/source/threadpool/current.cxx
@@ -126,23 +126,23 @@ extern "C" {
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 );
- if (pId->pCurrentContext)
- {
- (*pId->pCurrentContextEnv->releaseInterface)(
- 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;
+ (*pId->pCurrentContextEnv->releaseInterface)(
+ 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;
}
}
diff --git a/cppu/source/typelib/static_types.cxx b/cppu/source/typelib/static_types.cxx
index 77f443a6a637..6ff99b1f4ae0 100644
--- a/cppu/source/typelib/static_types.cxx
+++ b/cppu/source/typelib/static_types.cxx
@@ -297,30 +297,30 @@ void SAL_CALL typelib_static_sequence_type_init(
typelib_TypeDescriptionReference * pElementType )
SAL_THROW_EXTERN_C()
{
- if (! *ppRef)
- {
- MutexGuard aGuard( typelib_StaticInitMutex::get() );
- if (! *ppRef)
- {
- OUString aTypeName = "[]" + OUString::unacquired(&pElementType->pTypeName);
+ if ( *ppRef)
+ return;
- static_assert( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(typelib_TypeClass_SEQUENCE) );
- *ppRef = igetTypeByName( aTypeName.pData );
- if (!*ppRef)
- {
- 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);
- }
+ 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)
+ {
+ 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);
}
@@ -335,76 +335,76 @@ void init(
{
assert( eTypeClass == typelib_TypeClass_STRUCT || eTypeClass == typelib_TypeClass_EXCEPTION );
- if (! *ppRef)
- {
- MutexGuard aGuard( typelib_StaticInitMutex::get() );
- if (! *ppRef)
- {
- assert( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(eTypeClass) );
- OUString aTypeName( OUString::createFromAscii( pTypeName ) );
- *ppRef = igetTypeByName( aTypeName.pData );
- if (!*ppRef)
- {
- typelib_CompoundTypeDescription * pComp = nullptr;
- ::typelib_typedescription_newEmpty(
- reinterpret_cast<typelib_TypeDescription **>(&pComp), eTypeClass, aTypeName.pData );
+ if ( *ppRef)
+ return;
- 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
- }
+ MutexGuard aGuard( typelib_StaticInitMutex::get() );
+ if ( *ppRef)
+ return;
- 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];
- }
- }
- }
+ assert( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(eTypeClass) );
+ OUString aTypeName( OUString::createFromAscii( pTypeName ) );
+ *ppRef = igetTypeByName( aTypeName.pData );
+ if (!*ppRef)
+ {
+ typelib_CompoundTypeDescription * pComp = nullptr;
+ ::typelib_typedescription_newEmpty(
+ reinterpret_cast<typelib_TypeDescription **>(&pComp), eTypeClass, aTypeName.pData );
- 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;
+ 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
+ }
- ::typelib_typedescription_register( &pReg );
- *ppRef = reinterpret_cast<typelib_TypeDescriptionReference *>(pReg);
- assert( *ppRef == pReg->pWeakRef );
+ 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];
+ }
}
- // another static ref:
- ++((*ppRef)->nStaticRefCount);
}
+
+ 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 )
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() );
- if (! *ppRef)
+ 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)
{
- static_assert( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(typelib_TypeClass_INTERFACE) );
- OUString aTypeName( OUString::createFromAscii( pTypeName ) );
- *ppRef = igetTypeByName( aTypeName.pData );
- if (!*ppRef)
- {
- 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);
+ 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 );
+ 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;
+ 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);
- }
+ ::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_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() );
- if (! *ppRef)
- {
- static_assert( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(typelib_TypeClass_ENUM) );
- 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;
-
- 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);
- }
+ typelib_TypeDescription * pReg = nullptr;
+ ::typelib_typedescription_newEmpty(
+ &pReg, typelib_TypeClass_ENUM, aTypeName.pData );
+ typelib_EnumTypeDescription * pEnum = reinterpret_cast<typelib_EnumTypeDescription *>(pReg);
+
+ pEnum->nDefaultEnumValue = nDefaultValue;
+
+ 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);
}
} // extern "C"
diff --git a/cppu/source/typelib/typelib.cxx b/cppu/source/typelib/typelib.cxx
index 92a7e6ca5120..339f470077af 100644
--- a/cppu/source/typelib/typelib.cxx
+++ b/cppu/source/typelib/typelib.cxx
@@ -362,42 +362,42 @@ static void typelib_typedescription_initTables(
}
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++ )
{
- // 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])
{
- // 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++;
- }
+ // a read/write attribute
+ nAdditionalOffset++;
}
+ }
- // 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++ )
+ // 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])
{
- // 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;
- }
+ // 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;
}
+ // must be the last action after all initialization is done
+ pITD->nMapFunctionIndexToMemberIndex = pITD->nAllMembers + nAdditionalOffset;
+ pTD->bComplete = true;
}
namespace {
@@ -1363,68 +1363,68 @@ extern "C" void SAL_CALL typelib_typedescription_release(
{
sal_Int32 ref = osl_atomic_decrement( &pTD->nRefCount );
OSL_ASSERT(ref >= 0);
- if (0 == ref)
+ if (0 != ref)
+ return;
+
+ TypeDescriptor_Init_Impl &rInit = Init::get();
+ if( TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK( pTD->eTypeClass ) )
{
- TypeDescriptor_Init_Impl &rInit = Init::get();
- if( TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK( pTD->eTypeClass ) )
+ if( pTD->pWeakRef )
{
- if( pTD->pWeakRef )
{
- {
- MutexGuard aGuard( rInit.getMutex() );
- // remove this description from the weak reference
- pTD->pWeakRef->pType = nullptr;
- }
- typelib_typedescriptionreference_release( pTD->pWeakRef );
+ MutexGuard aGuard( rInit.getMutex() );
+ // remove this description from the weak reference
+ pTD->pWeakRef->pType = nullptr;
}
+ typelib_typedescriptionreference_release( pTD->pWeakRef );
}
- else
+ }
+ else
+ {
+ // this description is a reference too, so remove it from the hash table
+ if( rInit.pWeakMap )
{
- // 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) )
{
- 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 );
- }
+ // remove only if it contains the same object
+ rInit.pWeakMap->erase( aIt );
}
}
+ }
- typelib_typedescription_destructExtendedMembers( pTD );
- rtl_uString_release( pTD->pTypeName );
+ typelib_typedescription_destructExtendedMembers( pTD );
+ rtl_uString_release( pTD->pTypeName );
#if OSL_DEBUG_LEVEL > 0
- switch( pTD->eTypeClass )
- {
- case typelib_TypeClass_SEQUENCE:
- osl_atomic_decrement( &rInit.nIndirectTypeDescriptionCount );
- break;
- case typelib_TypeClass_STRUCT:
- case typelib_TypeClass_EXCEPTION:
- osl_atomic_decrement( &rInit.nCompoundTypeDescriptionCount );
- break;
- case typelib_TypeClass_INTERFACE:
- osl_atomic_decrement( &rInit.nInterfaceTypeDescriptionCount );
- break;
- case typelib_TypeClass_INTERFACE_METHOD:
- osl_atomic_decrement( &rInit.nInterfaceMethodTypeDescriptionCount );
- break;
- case typelib_TypeClass_INTERFACE_ATTRIBUTE:
- osl_atomic_decrement( &rInit.nInterfaceAttributeTypeDescriptionCount );
- break;
- case typelib_TypeClass_ENUM:
- osl_atomic_decrement( &rInit.nEnumTypeDescriptionCount );
- break;
- default:
- osl_atomic_decrement( &rInit.nTypeDescriptionCount );
- }
+ switch( pTD->eTypeClass )
+ {
+ case typelib_TypeClass_SEQUENCE:
+ osl_atomic_decrement( &rInit.nIndirectTypeDescriptionCount );
+ break;
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ osl_atomic_decrement( &rInit.nCompoundTypeDescriptionCount );
+ break;
+ case typelib_TypeClass_INTERFACE:
+ osl_atomic_decrement( &rInit.nInterfaceTypeDescriptionCount );
+ break;
+ case typelib_TypeClass_INTERFACE_METHOD:
+ osl_atomic_decrement( &rInit.nInterfaceMethodTypeDescriptionCount );
+ break;
+ case typelib_TypeClass_INTERFACE_ATTRIBUTE:
+ osl_atomic_decrement( &rInit.nInterfaceAttributeTypeDescriptionCount );
+ break;
+ case typelib_TypeClass_ENUM:
+ osl_atomic_decrement( &rInit.nEnumTypeDescriptionCount );
+ break;
+ default:
+ osl_atomic_decrement( &rInit.nTypeDescriptionCount );
+ }
#endif
- freeTypeDescription(pTD);
- }
+ freeTypeDescription(pTD);
}
@@ -1899,103 +1899,103 @@ extern "C" void SAL_CALL typelib_typedescription_getByName(
typelib_typedescriptionreference_release( pTDR );
}
- if (nullptr == *ppRet)
+ if (nullptr != *ppRet)
+ return;
+
+ // check for sequence
+ OUString const & name = OUString::unacquired( &pName );
+ if (2 < name.getLength() && '[' == name[ 0 ])
{
- // 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)
{
- 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 );
- }
+ typelib_typedescription_new(
+ ppRet, typelib_TypeClass_SEQUENCE, pName, element_td->pWeakRef, 0, nullptr );
+ // register?
+ typelib_typedescription_release( element_td );
}
- if (nullptr == *ppRet)
- {
- // Check for derived interface member type:
- sal_Int32 i1 = name.lastIndexOf(":@");
- if (i1 >= 0) {
- sal_Int32 i2 = i1 + RTL_CONSTASCII_LENGTH(":@");
- sal_Int32 i3 = name.indexOf(',', i2);
- if (i3 >= 0) {
- sal_Int32 i4 = name.indexOf(':', i3);
- if (i4 >= 0) {
- typelib_TypeDescriptionReference * pBaseRef = nullptr;
- 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);
+ }
+ if (nullptr == *ppRet)
+ {
+ // Check for derived interface member type:
+ sal_Int32 i1 = name.lastIndexOf(":@");
+ if (i1 >= 0) {
+ sal_Int32 i2 = i1 + RTL_CONSTASCII_LENGTH(":@");
+ sal_Int32 i3 = name.indexOf(',', i2);
+ if (i3 >= 0) {
+ sal_Int32 i4 = name.indexOf(':', i3);
+ if (i4 >= 0) {
+ typelib_TypeDescriptionReference * pBaseRef = nullptr;
+ 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(
+ &pInterface, name.copy(i4 + 1).pData);
+ if (!createDerivedInterfaceMemberDescription(
+ ppRet, name, pBaseRef, pBase, pInterface,
+ name.copy(i2, i3 - i2).toInt32(),
+ name.copy(i3 + 1, i4 - i3 - 1).toInt32()))
+ {
+ if (pInterface != nullptr) {
+ typelib_typedescription_release(pInterface);
}
- typelib_typedescription_getByName(
- &pInterface, name.copy(i4 + 1).pData);
- if (!createDerivedInterfaceMemberDescription(
- ppRet, name, pBaseRef, pBase, pInterface,
- name.copy(i2, i3 - i2).toInt32(),
- name.copy(i3 + 1, i4 - i3 - 1).toInt32()))
- {
- if (pInterface != nullptr) {
- typelib_typedescription_release(pInterface);
- }
- if (pBase != nullptr) {
- typelib_typedescription_release(pBase);
- }
- if (pBaseRef != nullptr) {
- typelib_typedescriptionreference_release(
- pBaseRef);
- }
+ if (pBase != nullptr) {
+ typelib_typedescription_release(pBase);
+ }
+ if (pBaseRef != nullptr) {
+ typelib_typedescriptionreference_release(
+ pBaseRef);
}
}
}
}
}
- if (nullptr == *ppRet)
- {
- // on demand access
- rInit.callChain( ppRet, pName );
- }
+ }
+ if (nullptr == *ppRet)
+ {
+ // on demand access
+ rInit.callChain( ppRet, pName );
+ }
- if( *ppRet )
- {
- // 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 );
+ if( !(*ppRet) )
+ return;
- // 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 );
- }
+ // 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
+ 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;
}
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() );
- WeakMap_Impl::const_iterator aIt = rInit.pWeakMap->find( pName->buffer );
- if( aIt != rInit.pWeakMap->end() )
- {
- sal_Int32 n = osl_atomic_increment( &(*aIt).second->nRefCount );
- if( n > 1 )
- {
- // The reference is incremented. The object cannot be destroyed.
- // Release the guard at the earliest point.
- *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 );
- }
- }
+ // The reference is incremented. The object cannot be destroyed.
+ // Release the guard at the earliest point.
+ *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()
{
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();
- MutexGuard aGuard( rInit.getMutex() );
- if ((nNewSize < nCacheSize) && rInit.pCache)
+ while (static_cast<sal_Int32>(rInit.pCache->size()) != nNewSize)
{
- 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;
}
diff --git a/cppu/source/uno/lbenv.cxx b/cppu/source/uno/lbenv.cxx
index aeac8b7ddd8a..c67d47dc948a 100644
--- a/cppu/source/uno/lbenv.cxx
+++ b/cppu/source/uno/lbenv.cxx
@@ -844,25 +844,25 @@ static void unoenv_computeObjectIdentifier(
::cppu::binuno_queryInterface(
pInterface, *typelib_static_type_getByTypeClass(
typelib_TypeClass_INTERFACE ) ));
- if (nullptr != pUnoI)
- {
- (*pUnoI->release)( pUnoI );
- // interface
- OUStringBuffer oid( 64 );
- oid.append( reinterpret_cast< sal_Int64 >(pUnoI), 16 );
- oid.append( ';' );
- // environment[context]
- oid.append( pEnv->aBase.pTypeName );
- oid.append( '[' );
- oid.append( reinterpret_cast< sal_Int64 >(
- reinterpret_cast<
- uno_Environment * >(pEnv)->pContext ), 16 );
- // process;good guid
- oid.append( unoenv_getStaticOIdPart() );
- OUString aStr( oid.makeStringAndClear() );
- *ppOId = aStr.pData;
- ::rtl_uString_acquire( *ppOId );
- }
+ if (nullptr == pUnoI)
+ return;
+
+ (*pUnoI->release)( pUnoI );
+ // interface
+ OUStringBuffer oid( 64 );
+ oid.append( reinterpret_cast< sal_Int64 >(pUnoI), 16 );
+ oid.append( ';' );
+ // environment[context]
+ oid.append( pEnv->aBase.pTypeName );
+ oid.append( '[' );
+ oid.append( reinterpret_cast< sal_Int64 >(
+ reinterpret_cast<
+ uno_Environment * >(pEnv)->pContext ), 16 );
+ // process;good guid
+ oid.append( unoenv_getStaticOIdPart() );
+ OUString aStr( oid.makeStringAndClear() );
+ *ppOId = aStr.pData;
+ ::rtl_uString_acquire( *ppOId );
}
diff --git a/cppu/source/uno/lbmap.cxx b/cppu/source/uno/lbmap.cxx
index ad27087b9b02..5fc1ab82eb9c 100644
--- a/cppu/source/uno/lbmap.cxx
+++ b/cppu/source/uno/lbmap.cxx
@@ -236,32 +236,32 @@ static void mediate_mapInterface(
typelib_InterfaceTypeDescription * pInterfaceTypeDescr )
{
OSL_ENSURE( pMapping && ppOut, "### null ptr!" );
- if (pMapping && ppOut)
- {
- uno_Mediate_Mapping * that = static_cast< uno_Mediate_Mapping * >( pMapping );
- uno_Mapping * pFrom2Uno = that->aFrom2Uno.get();
+ if (!(pMapping && ppOut))
+ return;
- uno_Interface * pUnoI = nullptr;
- (*pFrom2Uno->mapInterface)( pFrom2Uno, reinterpret_cast<void **>(&pUnoI), pInterface, pInterfaceTypeDescr );
- if (nullptr == pUnoI)
- {
- void * pOut = *ppOut;
- if (nullptr != pOut)
- {
- uno_ExtEnvironment * pTo = that->aTo.get()->pExtEnv;
- OSL_ENSURE( nullptr != pTo, "### cannot release out interface: leaking!" );
- if (nullptr != pTo)
- (*pTo->releaseInterface)( pTo, pOut );
- *ppOut = nullptr; // set to 0 anyway, because mapping was not successful!
- }
- }
- else
+ uno_Mediate_Mapping * that = static_cast< uno_Mediate_Mapping * >( pMapping );
+ uno_Mapping * pFrom2Uno = that->aFrom2Uno.get();
+
+ uno_Interface * pUnoI = nullptr;
+ (*pFrom2Uno->mapInterface)( pFrom2Uno, reinterpret_cast<void **>(&pUnoI), pInterface, pInterfaceTypeDescr );
+ if (nullptr == pUnoI)
+ {
+ void * pOut = *ppOut;
+ if (nullptr != pOut)
{
- uno_Mapping * pUno2To = that->aUno2To.get();
- (*pUno2To->mapInterface)( pUno2To, ppOut, pUnoI, pInterfaceTypeDescr );
- (*pUnoI->release)( pUnoI );
+ uno_ExtEnvironment * pTo = that->aTo.get()->pExtEnv;
+ OSL_ENSURE( nullptr != pTo, "### cannot release out interface: leaking!" );
+ 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 );
+ }
}
}
More information about the Libreoffice-commits
mailing list