summaryrefslogtreecommitdiff
path: root/cppu
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-12-21 13:42:35 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-12-21 15:55:46 +0100
commit25298930bc86d1a449a7e5b139d65e49f695f8c1 (patch)
treeb3f28ef6b18b12347694a637b6785ecb5eedc1fe /cppu
parent1edaee2f03bce0efa409c592919458658d0aa751 (diff)
loplugin:flatten in canvas..cui
Change-Id: I208767eaa60d913fe2882403f1f9351eb08256f7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127224 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'cppu')
-rw-r--r--cppu/source/threadpool/current.cxx34
-rw-r--r--cppu/source/typelib/typelib.cxx398
2 files changed, 216 insertions, 216 deletions
diff --git a/cppu/source/threadpool/current.cxx b/cppu/source/threadpool/current.cxx
index d085cb4a5092..64e6bfb8f64c 100644
--- a/cppu/source/threadpool/current.cxx
+++ b/cppu/source/threadpool/current.cxx
@@ -133,31 +133,31 @@ extern "C" sal_Bool SAL_CALL uno_setCurrentContext(
id.pCurrentContext = nullptr;
}
- if (pCurrentContext)
+ if (!pCurrentContext)
+ return true;
+
+ uno_Environment * pEnv = nullptr;
+ ::uno_getEnvironment( &pEnv, pEnvTypeName, pEnvContext );
+ OSL_ASSERT( pEnv && pEnv->pExtEnv );
+ if (pEnv)
{
- uno_Environment * pEnv = nullptr;
- ::uno_getEnvironment( &pEnv, pEnvTypeName, pEnvContext );
- OSL_ASSERT( pEnv && pEnv->pExtEnv );
- if (pEnv)
+ if (pEnv->pExtEnv)
{
- if (pEnv->pExtEnv)
- {
- id.pCurrentContextEnv = pEnv->pExtEnv;
- (*id.pCurrentContextEnv->acquireInterface)(
- id.pCurrentContextEnv, pCurrentContext );
- id.pCurrentContext = pCurrentContext;
- }
- else
- {
- (*pEnv->release)( pEnv );
- return false;
- }
+ id.pCurrentContextEnv = pEnv->pExtEnv;
+ (*id.pCurrentContextEnv->acquireInterface)(
+ id.pCurrentContextEnv, pCurrentContext );
+ id.pCurrentContext = pCurrentContext;
}
else
{
+ (*pEnv->release)( pEnv );
return false;
}
}
+ else
+ {
+ return false;
+ }
return true;
}
diff --git a/cppu/source/typelib/typelib.cxx b/cppu/source/typelib/typelib.cxx
index 8ae7ca64865e..36b815492e3b 100644
--- a/cppu/source/typelib/typelib.cxx
+++ b/cppu/source/typelib/typelib.cxx
@@ -392,84 +392,84 @@ void freeTypeDescription(typelib_TypeDescription const * desc) {
// description. The parameter initTables controls whether or not to call
// typelib_typedescription_initTables in those situations.
bool complete(typelib_TypeDescription ** ppTypeDescr, bool initTables) {
- if (! (*ppTypeDescr)->bComplete)
+ if ((*ppTypeDescr)->bComplete)
+ return true;
+
+ OSL_ASSERT( (typelib_TypeClass_STRUCT == (*ppTypeDescr)->eTypeClass ||
+ typelib_TypeClass_EXCEPTION == (*ppTypeDescr)->eTypeClass ||
+ typelib_TypeClass_ENUM == (*ppTypeDescr)->eTypeClass ||
+ typelib_TypeClass_INTERFACE == (*ppTypeDescr)->eTypeClass) &&
+ !TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK( (*ppTypeDescr)->eTypeClass ) );
+
+ if (typelib_TypeClass_INTERFACE == (*ppTypeDescr)->eTypeClass &&
+ reinterpret_cast<typelib_InterfaceTypeDescription *>(*ppTypeDescr)->ppAllMembers)
{
- OSL_ASSERT( (typelib_TypeClass_STRUCT == (*ppTypeDescr)->eTypeClass ||
- typelib_TypeClass_EXCEPTION == (*ppTypeDescr)->eTypeClass ||
- typelib_TypeClass_ENUM == (*ppTypeDescr)->eTypeClass ||
- typelib_TypeClass_INTERFACE == (*ppTypeDescr)->eTypeClass) &&
- !TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK( (*ppTypeDescr)->eTypeClass ) );
-
- if (typelib_TypeClass_INTERFACE == (*ppTypeDescr)->eTypeClass &&
- reinterpret_cast<typelib_InterfaceTypeDescription *>(*ppTypeDescr)->ppAllMembers)
- {
- if (initTables) {
- typelib_typedescription_initTables( *ppTypeDescr );
- }
- return true;
+ if (initTables) {
+ typelib_typedescription_initTables( *ppTypeDescr );
}
+ return true;
+ }
- typelib_TypeDescription * pTD = nullptr;
- // on demand access of complete td
- TypeDescriptor_Init_Impl &rInit = Init();
- rInit.callChain( &pTD, (*ppTypeDescr)->pTypeName );
- if (pTD)
+ typelib_TypeDescription * pTD = nullptr;
+ // on demand access of complete td
+ TypeDescriptor_Init_Impl &rInit = Init();
+ rInit.callChain( &pTD, (*ppTypeDescr)->pTypeName );
+ if (pTD)
+ {
+ if (typelib_TypeClass_TYPEDEF == pTD->eTypeClass)
{
- if (typelib_TypeClass_TYPEDEF == pTD->eTypeClass)
- {
- typelib_typedescriptionreference_getDescription(
- &pTD, reinterpret_cast<typelib_IndirectTypeDescription *>(pTD)->pType );
- OSL_ASSERT( pTD );
- if (! pTD)
- return false;
- }
-
- OSL_ASSERT( typelib_TypeClass_TYPEDEF != pTD->eTypeClass );
- // typedescription found
- // set to on demand
- pTD->bOnDemand = true;
-
- if (pTD->eTypeClass == typelib_TypeClass_INTERFACE
- && !pTD->bComplete && initTables)
- {
- // mandatory info from callback chain
- OSL_ASSERT( reinterpret_cast<typelib_InterfaceTypeDescription *>(pTD)->ppAllMembers );
- // complete except of tables init
- typelib_typedescription_initTables( pTD );
- pTD->bComplete = true;
- }
+ typelib_typedescriptionreference_getDescription(
+ &pTD, reinterpret_cast<typelib_IndirectTypeDescription *>(pTD)->pType );
+ OSL_ASSERT( pTD );
+ if (! pTD)
+ return false;
+ }
- // The type description is hold by the reference until
- // on demand is activated.
- ::typelib_typedescription_register( &pTD ); // replaces incomplete one
- OSL_ASSERT( pTD == *ppTypeDescr ); // has to merge into existing one
+ OSL_ASSERT( typelib_TypeClass_TYPEDEF != pTD->eTypeClass );
+ // typedescription found
+ // set to on demand
+ pTD->bOnDemand = true;
- // insert into the cache
- MutexGuard aGuard( rInit.maMutex );
- if( static_cast<sal_Int32>(rInit.maCache.size()) >= nCacheSize )
- {
- typelib_typedescription_release( rInit.maCache.front() );
- rInit.maCache.pop_front();
- }
- // descriptions in the cache must be acquired!
- typelib_typedescription_acquire( pTD );
- rInit.maCache.push_back( pTD );
+ if (pTD->eTypeClass == typelib_TypeClass_INTERFACE
+ && !pTD->bComplete && initTables)
+ {
+ // mandatory info from callback chain
+ OSL_ASSERT( reinterpret_cast<typelib_InterfaceTypeDescription *>(pTD)->ppAllMembers );
+ // complete except of tables init
+ typelib_typedescription_initTables( pTD );
+ pTD->bComplete = true;
+ }
- OSL_ASSERT(
- pTD->bComplete
- || (pTD->eTypeClass == typelib_TypeClass_INTERFACE
- && !initTables));
+ // The type description is hold by the reference until
+ // on demand is activated.
+ ::typelib_typedescription_register( &pTD ); // replaces incomplete one
+ OSL_ASSERT( pTD == *ppTypeDescr ); // has to merge into existing one
- ::typelib_typedescription_release( *ppTypeDescr );
- *ppTypeDescr = pTD;
- }
- else
+ // insert into the cache
+ MutexGuard aGuard( rInit.maMutex );
+ if( static_cast<sal_Int32>(rInit.maCache.size()) >= nCacheSize )
{
- SAL_INFO(
- "cppu.typelib",
- "type cannot be completed: " << OUString::unacquired(&(*ppTypeDescr)->pTypeName));
- return false;
+ typelib_typedescription_release( rInit.maCache.front() );
+ rInit.maCache.pop_front();
}
+ // descriptions in the cache must be acquired!
+ typelib_typedescription_acquire( pTD );
+ rInit.maCache.push_back( pTD );
+
+ OSL_ASSERT(
+ pTD->bComplete
+ || (pTD->eTypeClass == typelib_TypeClass_INTERFACE
+ && !initTables));
+
+ ::typelib_typedescription_release( *ppTypeDescr );
+ *ppTypeDescr = pTD;
+ }
+ else
+ {
+ SAL_INFO(
+ "cppu.typelib",
+ "type cannot be completed: " << OUString::unacquired(&(*ppTypeDescr)->pTypeName));
+ return false;
}
return true;
}
@@ -1779,90 +1779,91 @@ bool createDerivedInterfaceMemberDescription(
typelib_TypeDescription const * base, typelib_TypeDescription * interface,
sal_Int32 index, sal_Int32 position)
{
- if (baseRef != nullptr && base != nullptr && interface != nullptr) {
- switch (base->eTypeClass) {
- case typelib_TypeClass_INTERFACE_METHOD:
- {
- typelib_typedescription_newEmpty(
- result, typelib_TypeClass_INTERFACE_METHOD, name.pData);
- typelib_InterfaceMethodTypeDescription const * baseMethod
- = reinterpret_cast<
- typelib_InterfaceMethodTypeDescription const * >(base);
- typelib_InterfaceMethodTypeDescription * newMethod
- = reinterpret_cast<
- typelib_InterfaceMethodTypeDescription * >(*result);
- newMethod->aBase.nPosition = position;
- newMethod->aBase.pMemberName
- = baseMethod->aBase.pMemberName;
+ if (!baseRef || !base || !interface)
+ return false;
+
+ switch (base->eTypeClass) {
+ case typelib_TypeClass_INTERFACE_METHOD:
+ {
+ typelib_typedescription_newEmpty(
+ result, typelib_TypeClass_INTERFACE_METHOD, name.pData);
+ typelib_InterfaceMethodTypeDescription const * baseMethod
+ = reinterpret_cast<
+ typelib_InterfaceMethodTypeDescription const * >(base);
+ typelib_InterfaceMethodTypeDescription * newMethod
+ = reinterpret_cast<
+ typelib_InterfaceMethodTypeDescription * >(*result);
+ newMethod->aBase.nPosition = position;
+ newMethod->aBase.pMemberName
+ = baseMethod->aBase.pMemberName;
+ rtl_uString_acquire(
+ newMethod->aBase.pMemberName);
+ newMethod->pReturnTypeRef = baseMethod->pReturnTypeRef;
+ typelib_typedescriptionreference_acquire(
+ newMethod->pReturnTypeRef);
+ newMethod->nParams = baseMethod->nParams;
+ newMethod->pParams = new typelib_MethodParameter[
+ newMethod->nParams];
+ for (sal_Int32 i = 0; i < newMethod->nParams; ++i) {
+ newMethod->pParams[i].pName
+ = baseMethod->pParams[i].pName;
rtl_uString_acquire(
- newMethod->aBase.pMemberName);
- newMethod->pReturnTypeRef = baseMethod->pReturnTypeRef;
+ newMethod->pParams[i].pName);
+ newMethod->pParams[i].pTypeRef
+ = baseMethod->pParams[i].pTypeRef;
typelib_typedescriptionreference_acquire(
- newMethod->pReturnTypeRef);
- newMethod->nParams = baseMethod->nParams;
- newMethod->pParams = new typelib_MethodParameter[
- newMethod->nParams];
- for (sal_Int32 i = 0; i < newMethod->nParams; ++i) {
- newMethod->pParams[i].pName
- = baseMethod->pParams[i].pName;
- rtl_uString_acquire(
- newMethod->pParams[i].pName);
- newMethod->pParams[i].pTypeRef
- = baseMethod->pParams[i].pTypeRef;
- typelib_typedescriptionreference_acquire(
- newMethod->pParams[i].pTypeRef);
- newMethod->pParams[i].bIn = baseMethod->pParams[i].bIn;
- newMethod->pParams[i].bOut = baseMethod->pParams[i].bOut;
- }
- newMethod->nExceptions = baseMethod->nExceptions;
- newMethod->ppExceptions = copyExceptions(
- baseMethod->nExceptions, baseMethod->ppExceptions);
- newMethod->bOneWay = baseMethod->bOneWay;
- newMethod->pInterface
- = reinterpret_cast< typelib_InterfaceTypeDescription * >(
- interface);
- newMethod->pBaseRef = baseRef;
- newMethod->nIndex = index;
- return true;
- }
-
- case typelib_TypeClass_INTERFACE_ATTRIBUTE:
- {
- typelib_typedescription_newEmpty(
- result, typelib_TypeClass_INTERFACE_ATTRIBUTE, name.pData);
- typelib_InterfaceAttributeTypeDescription const * baseAttribute
- = reinterpret_cast<
- typelib_InterfaceAttributeTypeDescription const * >(base);
- typelib_InterfaceAttributeTypeDescription * newAttribute
- = reinterpret_cast<
- typelib_InterfaceAttributeTypeDescription * >(*result);
- newAttribute->aBase.nPosition = position;
- newAttribute->aBase.pMemberName
- = baseAttribute->aBase.pMemberName;
- rtl_uString_acquire(newAttribute->aBase.pMemberName);
- newAttribute->bReadOnly = baseAttribute->bReadOnly;
- newAttribute->pAttributeTypeRef
- = baseAttribute->pAttributeTypeRef;
- typelib_typedescriptionreference_acquire(newAttribute->pAttributeTypeRef);
- newAttribute->pInterface
- = reinterpret_cast< typelib_InterfaceTypeDescription * >(
- interface);
- newAttribute->pBaseRef = baseRef;
- newAttribute->nIndex = index;
- newAttribute->nGetExceptions = baseAttribute->nGetExceptions;
- newAttribute->ppGetExceptions = copyExceptions(
- baseAttribute->nGetExceptions,
- baseAttribute->ppGetExceptions);
- newAttribute->nSetExceptions = baseAttribute->nSetExceptions;
- newAttribute->ppSetExceptions = copyExceptions(
- baseAttribute->nSetExceptions,
- baseAttribute->ppSetExceptions);
- return true;
+ newMethod->pParams[i].pTypeRef);
+ newMethod->pParams[i].bIn = baseMethod->pParams[i].bIn;
+ newMethod->pParams[i].bOut = baseMethod->pParams[i].bOut;
}
+ newMethod->nExceptions = baseMethod->nExceptions;
+ newMethod->ppExceptions = copyExceptions(
+ baseMethod->nExceptions, baseMethod->ppExceptions);
+ newMethod->bOneWay = baseMethod->bOneWay;
+ newMethod->pInterface
+ = reinterpret_cast< typelib_InterfaceTypeDescription * >(
+ interface);
+ newMethod->pBaseRef = baseRef;
+ newMethod->nIndex = index;
+ return true;
+ }
- default:
- break;
+ case typelib_TypeClass_INTERFACE_ATTRIBUTE:
+ {
+ typelib_typedescription_newEmpty(
+ result, typelib_TypeClass_INTERFACE_ATTRIBUTE, name.pData);
+ typelib_InterfaceAttributeTypeDescription const * baseAttribute
+ = reinterpret_cast<
+ typelib_InterfaceAttributeTypeDescription const * >(base);
+ typelib_InterfaceAttributeTypeDescription * newAttribute
+ = reinterpret_cast<
+ typelib_InterfaceAttributeTypeDescription * >(*result);
+ newAttribute->aBase.nPosition = position;
+ newAttribute->aBase.pMemberName
+ = baseAttribute->aBase.pMemberName;
+ rtl_uString_acquire(newAttribute->aBase.pMemberName);
+ newAttribute->bReadOnly = baseAttribute->bReadOnly;
+ newAttribute->pAttributeTypeRef
+ = baseAttribute->pAttributeTypeRef;
+ typelib_typedescriptionreference_acquire(newAttribute->pAttributeTypeRef);
+ newAttribute->pInterface
+ = reinterpret_cast< typelib_InterfaceTypeDescription * >(
+ interface);
+ newAttribute->pBaseRef = baseRef;
+ newAttribute->nIndex = index;
+ newAttribute->nGetExceptions = baseAttribute->nGetExceptions;
+ newAttribute->ppGetExceptions = copyExceptions(
+ baseAttribute->nGetExceptions,
+ baseAttribute->ppGetExceptions);
+ newAttribute->nSetExceptions = baseAttribute->nSetExceptions;
+ newAttribute->ppSetExceptions = copyExceptions(
+ baseAttribute->nSetExceptions,
+ baseAttribute->ppSetExceptions);
+ return true;
}
+
+ default:
+ break;
}
return false;
}
@@ -2330,68 +2331,67 @@ extern "C" sal_Bool SAL_CALL typelib_typedescriptionreference_isAssignableFrom(
typelib_TypeDescriptionReference * pFrom )
SAL_THROW_EXTERN_C()
{
- if (pAssignable && pFrom)
- {
- typelib_TypeClass eAssignable = pAssignable->eTypeClass;
- typelib_TypeClass eFrom = pFrom->eTypeClass;
+ if (!pAssignable || !pFrom)
+ return false;
- if (eAssignable == typelib_TypeClass_ANY) // anything can be assigned to an any .)
+ typelib_TypeClass eAssignable = pAssignable->eTypeClass;
+ typelib_TypeClass eFrom = pFrom->eTypeClass;
+
+ if (eAssignable == typelib_TypeClass_ANY) // anything can be assigned to an any .)
+ return true;
+ if (eAssignable == eFrom)
+ {
+ if (type_equals( pAssignable, pFrom )) // first shot
+ {
return true;
- if (eAssignable == eFrom)
+ }
+ switch (eAssignable)
{
- if (type_equals( pAssignable, pFrom )) // first shot
- {
- return true;
- }
- switch (eAssignable)
- {
- case typelib_TypeClass_STRUCT:
- case typelib_TypeClass_EXCEPTION:
- {
- typelib_TypeDescription * pFromDescr = nullptr;
- TYPELIB_DANGER_GET( &pFromDescr, pFrom );
- if (!reinterpret_cast<typelib_CompoundTypeDescription *>(pFromDescr)->pBaseTypeDescription)
- {
- TYPELIB_DANGER_RELEASE( pFromDescr );
- return false;
- }
- bool bRet = typelib_typedescriptionreference_isAssignableFrom(
- pAssignable,
- reinterpret_cast<typelib_CompoundTypeDescription *>(pFromDescr)->pBaseTypeDescription->aBase.pWeakRef );
- TYPELIB_DANGER_RELEASE( pFromDescr );
- return bRet;
- }
- case typelib_TypeClass_INTERFACE:
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ {
+ typelib_TypeDescription * pFromDescr = nullptr;
+ TYPELIB_DANGER_GET( &pFromDescr, pFrom );
+ if (!reinterpret_cast<typelib_CompoundTypeDescription *>(pFromDescr)->pBaseTypeDescription)
{
- typelib_TypeDescription * pFromDescr = nullptr;
- TYPELIB_DANGER_GET( &pFromDescr, pFrom );
- typelib_InterfaceTypeDescription * pFromIfc
- = reinterpret_cast<
- typelib_InterfaceTypeDescription * >(pFromDescr);
- bool bRet = false;
- for (sal_Int32 i = 0; i < pFromIfc->nBaseTypes; ++i) {
- if (typelib_typedescriptionreference_isAssignableFrom(
- pAssignable,
- pFromIfc->ppBaseTypes[i]->aBase.pWeakRef))
- {
- bRet = true;
- break;
- }
- }
TYPELIB_DANGER_RELEASE( pFromDescr );
- return bRet;
- }
- default:
- {
return false;
}
+ bool bRet = typelib_typedescriptionreference_isAssignableFrom(
+ pAssignable,
+ reinterpret_cast<typelib_CompoundTypeDescription *>(pFromDescr)->pBaseTypeDescription->aBase.pWeakRef );
+ TYPELIB_DANGER_RELEASE( pFromDescr );
+ return bRet;
+ }
+ case typelib_TypeClass_INTERFACE:
+ {
+ typelib_TypeDescription * pFromDescr = nullptr;
+ TYPELIB_DANGER_GET( &pFromDescr, pFrom );
+ typelib_InterfaceTypeDescription * pFromIfc
+ = reinterpret_cast<
+ typelib_InterfaceTypeDescription * >(pFromDescr);
+ bool bRet = false;
+ for (sal_Int32 i = 0; i < pFromIfc->nBaseTypes; ++i) {
+ if (typelib_typedescriptionreference_isAssignableFrom(
+ pAssignable,
+ pFromIfc->ppBaseTypes[i]->aBase.pWeakRef))
+ {
+ bRet = true;
+ break;
+ }
}
+ TYPELIB_DANGER_RELEASE( pFromDescr );
+ return bRet;
+ }
+ default:
+ {
+ return false;
+ }
}
- return (eAssignable >= typelib_TypeClass_CHAR && eAssignable <= typelib_TypeClass_DOUBLE &&
- eFrom >= typelib_TypeClass_CHAR && eFrom <= typelib_TypeClass_DOUBLE &&
- s_aAssignableFromTab[eAssignable-1][eFrom-1]);
}
- return false;
+ return (eAssignable >= typelib_TypeClass_CHAR && eAssignable <= typelib_TypeClass_DOUBLE &&
+ eFrom >= typelib_TypeClass_CHAR && eFrom <= typelib_TypeClass_DOUBLE &&
+ s_aAssignableFromTab[eAssignable-1][eFrom-1]);
}
extern "C" sal_Bool SAL_CALL typelib_typedescription_isAssignableFrom(