Kaydet (Commit) 116b969f authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Clean up C-style casts from pointers to void

Change-Id: I2ac79c757d9116d35436ae1adc0e11e7040e725d
üst 8b2779bf
......@@ -403,11 +403,11 @@ inline bool coerce_assign(
css::uno::Reference< css::uno::XInterface > xVal;
if (extract( rSource, reinterpret_cast<typelib_InterfaceTypeDescription *>(pTD), xVal, pRefl ))
{
if (*(css::uno::XInterface **)pDest)
(*(css::uno::XInterface **)pDest)->release();
*(css::uno::XInterface **)pDest = xVal.get();
if (*(css::uno::XInterface **)pDest)
(*(css::uno::XInterface **)pDest)->acquire();
if (*static_cast<css::uno::XInterface **>(pDest))
(*static_cast<css::uno::XInterface **>(pDest))->release();
*static_cast<css::uno::XInterface **>(pDest) = xVal.get();
if (*static_cast<css::uno::XInterface **>(pDest))
(*static_cast<css::uno::XInterface **>(pDest))->acquire();
return true;
}
return false;
......
......@@ -94,7 +94,7 @@ void ArrayIdlClassImpl::realloc( Any & rArray, sal_Int32 nLen )
(XWeak *)(OWeakObject *)this, 1 );
}
uno_Sequence ** ppSeq = (uno_Sequence **)rArray.getValue();
uno_Sequence ** ppSeq = const_cast<uno_Sequence **>(static_cast<uno_Sequence * const *>(rArray.getValue()));
uno_sequence_realloc( ppSeq, &getTypeDescr()->aBase,
nLen,
reinterpret_cast< uno_AcquireFunc >(cpp_acquire),
......@@ -113,7 +113,7 @@ sal_Int32 ArrayIdlClassImpl::getLen( const Any & rArray )
(XWeak *)(OWeakObject *)this, 0 );
}
return (*(uno_Sequence **)rArray.getValue())->nElements;
return (*static_cast<uno_Sequence * const *>(rArray.getValue()))->nElements;
}
Any ArrayIdlClassImpl::get( const Any & rArray, sal_Int32 nIndex )
......@@ -127,7 +127,7 @@ Any ArrayIdlClassImpl::get( const Any & rArray, sal_Int32 nIndex )
(XWeak *)(OWeakObject *)this, 0 );
}
uno_Sequence * pSeq = *(uno_Sequence **)rArray.getValue();
uno_Sequence * pSeq = *static_cast<uno_Sequence * const *>(rArray.getValue());
if (pSeq->nElements <= nIndex)
{
throw ArrayIndexOutOfBoundsException(
......@@ -158,7 +158,7 @@ void ArrayIdlClassImpl::set( Any & rArray, sal_Int32 nIndex, const Any & rNewVal
(XWeak *)(OWeakObject *)this, 0 );
}
uno_Sequence * pSeq = *(uno_Sequence **)rArray.getValue();
uno_Sequence * pSeq = *static_cast<uno_Sequence * const *>(rArray.getValue());
if (pSeq->nElements <= nIndex)
{
throw ArrayIndexOutOfBoundsException(
......@@ -166,7 +166,7 @@ void ArrayIdlClassImpl::set( Any & rArray, sal_Int32 nIndex, const Any & rNewVal
(XWeak *)(OWeakObject *)this );
}
uno_Sequence ** ppSeq = (uno_Sequence **)rArray.getValue();
uno_Sequence ** ppSeq = const_cast<uno_Sequence **>(static_cast<uno_Sequence * const *>(rArray.getValue()));
uno_sequence_reference2One(
ppSeq, &getTypeDescr()->aBase,
reinterpret_cast< uno_AcquireFunc >(cpp_acquire),
......
......@@ -190,7 +190,7 @@ Any IdlCompFieldImpl::get( const Any & rObj )
uno_any_destruct(
&aRet, reinterpret_cast< uno_ReleaseFunc >(cpp_release) );
uno_any_construct(
&aRet, (char *)rObj.getValue() + _nOffset, getTypeDescr(),
&aRet, const_cast<char *>(static_cast<char const *>(rObj.getValue()) + _nOffset), getTypeDescr(),
reinterpret_cast< uno_AcquireFunc >(cpp_acquire) );
return aRet;
}
......@@ -219,7 +219,7 @@ void IdlCompFieldImpl::set( const Any & rObj, const Any & rValue )
if (pTD)
{
TYPELIB_DANGER_RELEASE( pObjTD );
if (coerce_assign( (char *)rObj.getValue() + _nOffset, getTypeDescr(), rValue, getReflection() ))
if (coerce_assign( const_cast<char *>(static_cast<char const *>(rObj.getValue()) + _nOffset), getTypeDescr(), rValue, getReflection() ))
{
return;
}
......@@ -256,7 +256,7 @@ void IdlCompFieldImpl::set( Any & rObj, const Any & rValue )
if (pTD)
{
TYPELIB_DANGER_RELEASE( pObjTD );
if (coerce_assign( (char *)rObj.getValue() + _nOffset, getTypeDescr(), rValue, getReflection() ))
if (coerce_assign( const_cast<char *>(static_cast<char const *>(rObj.getValue()) + _nOffset), getTypeDescr(), rValue, getReflection() ))
{
return;
}
......
......@@ -231,7 +231,7 @@ Reference< XIdlClass > IdlReflectionServiceImpl::forName( const OUString & rType
if (aAny.hasValue())
{
if (aAny.getValueTypeClass() == TypeClass_INTERFACE)
xRet = *(const Reference< XIdlClass > *)aAny.getValue();
xRet = *static_cast<const Reference< XIdlClass > *>(aAny.getValue());
}
else
{
......@@ -261,7 +261,7 @@ Any IdlReflectionServiceImpl::getByHierarchicalName( const OUString & rName )
if (aRet.getValueTypeClass() == TypeClass_INTERFACE)
{
// type retrieved from tdmgr
OSL_ASSERT( (*(Reference< XInterface > *)aRet.getValue())->queryInterface(
OSL_ASSERT( (*static_cast<Reference< XInterface > const *>(aRet.getValue()))->queryInterface(
cppu::UnoType<XTypeDescription>::get()).hasValue() );
css::uno::Reference< css::reflection::XConstantTypeDescription >
......@@ -329,7 +329,7 @@ Reference< XIdlClass > IdlReflectionServiceImpl::forType( typelib_TypeDescriptio
if (aAny.hasValue())
{
if (aAny.getValueTypeClass() == TypeClass_INTERFACE)
xRet = *(const Reference< XIdlClass > *)aAny.getValue();
xRet = *static_cast<const Reference< XIdlClass > *>(aAny.getValue());
}
else
{
......@@ -409,7 +409,7 @@ uno_Interface * IdlReflectionServiceImpl::mapToUno(
{
Reference< XInterface > xObj;
if (extract( rObj, pTo, xObj, this ))
return (uno_Interface *)getCpp2Uno().mapInterface( xObj.get(), pTo );
return static_cast<uno_Interface *>(getCpp2Uno().mapInterface( xObj.get(), pTo ));
throw RuntimeException(
"illegal object given!",
......
......@@ -247,7 +247,7 @@ void IdlAttributeFieldImpl::set( Any & rObj, const Any & rValue )
getReflection() );
if (bAssign)
{
*(void **)pArg = getReflection()->getCpp2Uno().mapInterface(
*static_cast<void **>(pArg) = getReflection()->getCpp2Uno().mapInterface(
xObj.get(), reinterpret_cast<typelib_InterfaceTypeDescription *>(pTD) );
}
}
......@@ -287,7 +287,7 @@ void IdlAttributeFieldImpl::set( Any & rObj, const Any & rValue )
throw IllegalArgumentException(
"illegal value given!",
*(const Reference< XInterface > *)rObj.getValue(), 1 );
*static_cast<const Reference< XInterface > *>(rObj.getValue()), 1 );
}
throw IllegalArgumentException(
"illegal destination object given!",
......@@ -586,13 +586,13 @@ Any SAL_CALL IdlInterfaceMethodImpl::invoke( const Any & rObj, Sequence< Any > &
if (rtl_ustr_ascii_compare( getTypeDescr()->pTypeName->buffer,
"com.sun.star.uno.XInterface::acquire" ) == 0)
{
(*(const Reference< XInterface > *)rObj.getValue())->acquire();
(*static_cast<const Reference< XInterface > *>(rObj.getValue()))->acquire();
return Any();
}
else if (rtl_ustr_ascii_compare( getTypeDescr()->pTypeName->buffer,
"com.sun.star.uno.XInterface::release" ) == 0)
{
(*(const Reference< XInterface > *)rObj.getValue())->release();
(*static_cast<const Reference< XInterface > *>(rObj.getValue()))->release();
return Any();
}
}
......@@ -608,7 +608,7 @@ Any SAL_CALL IdlInterfaceMethodImpl::invoke( const Any & rObj, Sequence< Any > &
(*pUnoI->release)( pUnoI );
throw IllegalArgumentException(
"arguments len differ!",
*(const Reference< XInterface > *)rObj.getValue(), 1 );
*static_cast<const Reference< XInterface > *>(rObj.getValue()), 1 );
}
Any * pCppArgs = rArgs.getArray();
......@@ -618,8 +618,8 @@ Any SAL_CALL IdlInterfaceMethodImpl::invoke( const Any & rObj, Sequence< Any > &
&pReturnType, getMethodTypeDescr()->pReturnTypeRef );
void * pUnoReturn = alloca( pReturnType->nSize );
void ** ppUnoArgs = (void **)alloca( sizeof(void *) * nParams *2 );
typelib_TypeDescription ** ppParamTypes = (typelib_TypeDescription **)(ppUnoArgs + nParams);
void ** ppUnoArgs = static_cast<void **>(alloca( sizeof(void *) * nParams *2 ));
typelib_TypeDescription ** ppParamTypes = reinterpret_cast<typelib_TypeDescription **>(ppUnoArgs + nParams);
// convert arguments
for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
......@@ -643,7 +643,7 @@ Any SAL_CALL IdlInterfaceMethodImpl::invoke( const Any & rObj, Sequence< Any > &
else if (pTD->eTypeClass == typelib_TypeClass_ANY)
{
uno_type_any_constructAndConvert(
(uno_Any *)ppUnoArgs[nPos], (void *)pCppArgs[nPos].getValue(),
static_cast<uno_Any *>(ppUnoArgs[nPos]), (void *)pCppArgs[nPos].getValue(),
pCppArgs[nPos].getValueTypeRef(), getReflection()->getCpp2Uno().get() );
bAssign = true;
}
......@@ -655,7 +655,7 @@ Any SAL_CALL IdlInterfaceMethodImpl::invoke( const Any & rObj, Sequence< Any > &
xDest, getReflection() );
if (bAssign)
{
*(void **)ppUnoArgs[nPos] = getReflection()->getCpp2Uno().mapInterface(
*static_cast<void **>(ppUnoArgs[nPos]) = getReflection()->getCpp2Uno().mapInterface(
xDest.get(), reinterpret_cast<typelib_InterfaceTypeDescription *>(pTD) );
}
}
......@@ -682,7 +682,7 @@ Any SAL_CALL IdlInterfaceMethodImpl::invoke( const Any & rObj, Sequence< Any > &
{
IllegalArgumentException aExc(
"cannot coerce argument type during corereflection call!",
*(const Reference< XInterface > *)rObj.getValue(), (sal_Int16)nPos );
*static_cast<const Reference< XInterface > *>(rObj.getValue()), (sal_Int16)nPos );
// cleanup
while (nPos--)
......@@ -719,7 +719,7 @@ Any SAL_CALL IdlInterfaceMethodImpl::invoke( const Any & rObj, Sequence< Any > &
TYPELIB_DANGER_RELEASE( pReturnType );
InvocationTargetException aExc;
aExc.Context = *(const Reference< XInterface > *)rObj.getValue();
aExc.Context = *static_cast<const Reference< XInterface > *>(rObj.getValue());
aExc.Message = "exception occurred during invocation!";
uno_any_destruct(
&aExc.TargetException,
......
......@@ -382,7 +382,7 @@ void IntrospectionAccessStatic_Impl::setPropertyValueByIndex(const Any& obj, sal
Reference<XInterface> xInterface;
if( eObjType == TypeClass_INTERFACE )
{
xInterface = *( Reference<XInterface>*)obj.getValue();
xInterface = *static_cast<Reference<XInterface> const *>(obj.getValue());
}
else if( nSequenceIndex >= mnPropCount || ( eObjType != TypeClass_STRUCT && eObjType != TypeClass_EXCEPTION ) )
{
......@@ -417,7 +417,7 @@ void IntrospectionAccessStatic_Impl::setPropertyValueByIndex(const Any& obj, sal
//Reference<XIdlClass> xPropClass = rProp.Type;
if( xPropClass.is() && xPropClass->getTypeClass() == TypeClass_INTERFACE )
{
Reference<XInterface> valInterface = *(Reference<XInterface>*)aValue.getValue();
Reference<XInterface> valInterface = *static_cast<Reference<XInterface> const *>(aValue.getValue());
if( valInterface.is() )
{
//Any queryInterface( const Type& rType );
......@@ -526,7 +526,7 @@ Any IntrospectionAccessStatic_Impl::getPropertyValueByIndex(const Any& obj, sal_
Reference<XInterface> xInterface;
if( eObjType == TypeClass_INTERFACE )
{
xInterface = *(Reference<XInterface>*)obj.getValue();
xInterface = *static_cast<Reference<XInterface> const *>(obj.getValue());
}
else if( nSequenceIndex >= mnPropCount || ( eObjType != TypeClass_STRUCT && eObjType != TypeClass_EXCEPTION ) )
{
......@@ -735,7 +735,7 @@ ImplIntrospectionAccess::ImplIntrospectionAccess
// Objekt als Interface merken, wenn moeglich
TypeClass eType = maInspectedObject.getValueType().getTypeClass();
if( eType == TypeClass_INTERFACE )
mxIface = *(Reference<XInterface>*)maInspectedObject.getValue();
mxIface = *static_cast<Reference<XInterface> const *>(maInspectedObject.getValue());
mnLastPropertyConcept = -1;
mnLastMethodConcept = -1;
......@@ -869,7 +869,7 @@ ImplIntrospectionAdapter::ImplIntrospectionAdapter( ImplIntrospectionAccess* pAc
TypeClass eType = mrInspectedObject.getValueType().getTypeClass();
if( eType == TypeClass_INTERFACE )
{
mxIface = *( Reference< XInterface >*)mrInspectedObject.getValue();
mxIface = *static_cast<Reference< XInterface > const *>(mrInspectedObject.getValue());
mxObjElementAccess = Reference<XElementAccess>::query( mxIface );
mxObjNameAccess = Reference<XNameAccess>::query( mxIface );
......@@ -1602,7 +1602,7 @@ css::uno::Reference<css::beans::XIntrospectionAccess> Implementation::inspect(
if( eType == TypeClass_INTERFACE )
{
// Interface aus dem Any besorgen
x = *(Reference<XInterface>*)aToInspectObj.getValue();
x = *static_cast<Reference<XInterface> const *>(aToInspectObj.getValue());
if( !x.is() )
return css::uno::Reference<css::beans::XIntrospectionAccess>();
}
......
......@@ -359,7 +359,7 @@ void Invocation_Impl::setMaterial( const Any& rMaterial )
Reference<XInterface> xObj;
if (rMaterial.getValueType().getTypeClass() == TypeClass_INTERFACE)
xObj = *(Reference<XInterface>*)rMaterial.getValue();
xObj = *static_cast<Reference<XInterface> const *>(rMaterial.getValue());
_aMaterial = rMaterial;
// Ersteinmal alles ausserhalb des guards machen
......
......@@ -237,7 +237,7 @@ bool AdapterImpl::coerce_assign(
if (typelib_TypeClass_ANY == pType->eTypeClass)
{
::uno_type_any_assign(
(uno_Any *)pDest, pSource->pData, pSource->pType, 0, 0 );
static_cast<uno_Any *>(pDest), pSource->pData, pSource->pType, 0, 0 );
return true;
}
if (::uno_type_assignData(
......@@ -340,7 +340,7 @@ static void handleInvokExc( uno_Any * pDest, uno_Any * pSource )
if (typelib_TypeClass_EXCEPTION == pSource->pType->eTypeClass)
{
constructRuntimeException(
pDest, ((Exception const *)pSource->pData)->Message );
pDest, static_cast<Exception const *>(pSource->pData)->Message );
}
else
{
......@@ -576,7 +576,7 @@ static void SAL_CALL adapter_dispatch(
static_cast< InterfaceAdapterImpl * >( pUnoI )->m_pAdapter;
*ppException = 0; // no exc
typelib_TypeDescriptionReference * pDemanded =
*(typelib_TypeDescriptionReference **)pArgs[0];
*static_cast<typelib_TypeDescriptionReference **>(pArgs[0]);
// pInterfaces[0] is XInterface
for ( sal_Int32 nPos = 0; nPos < that->m_nInterfaces; ++nPos )
{
......@@ -588,14 +588,14 @@ static void SAL_CALL adapter_dispatch(
{
uno_Interface * pUnoI2 = &that->m_pInterfaces[nPos];
::uno_any_construct(
(uno_Any *)pReturn, &pUnoI2,
static_cast<uno_Any *>(pReturn), &pUnoI2,
&pTD->aBase, 0 );
return;
}
pTD = pTD->pBaseTypeDescription;
}
}
::uno_any_construct( (uno_Any *)pReturn, 0, 0, 0 ); // clear()
::uno_any_construct( static_cast<uno_Any *>(pReturn), 0, 0, 0 ); // clear()
break;
}
case 1: // acquire()
......@@ -664,8 +664,8 @@ AdapterImpl::AdapterImpl(
}
// map receiver
m_pReceiver = (uno_Interface *)m_pFactory->m_aCpp2Uno.mapInterface(
xReceiver.get(), ::getCppuType( &xReceiver ) );
m_pReceiver = static_cast<uno_Interface *>(m_pFactory->m_aCpp2Uno.mapInterface(
xReceiver.get(), ::getCppuType( &xReceiver ) ));
OSL_ASSERT( 0 != m_pReceiver );
if (! m_pReceiver)
{
......@@ -698,8 +698,8 @@ FactoryImpl::FactoryImpl( Reference< XComponentContext > const & xContext )
OUString("com.sun.star.script.Converter"),
xContext ),
UNO_QUERY_THROW );
m_pConverter = (uno_Interface *)m_aCpp2Uno.mapInterface(
xConverter.get(), ::getCppuType( &xConverter ) );
m_pConverter = static_cast<uno_Interface *>(m_aCpp2Uno.mapInterface(
xConverter.get(), ::getCppuType( &xConverter ) ));
OSL_ASSERT( 0 != m_pConverter );
// some type info:
......
......@@ -1198,7 +1198,7 @@ void OServiceManager::insert( const Any & Element )
for( sal_Int32 i = 0; i < aServiceNames.getLength(); i++ )
{
m_ServiceMap.insert( HashMultimap_OWString_Interface::value_type(
pArray[i], *(Reference<XInterface > *)Element.getValue() ) );
pArray[i], *static_cast<Reference<XInterface > const *>(Element.getValue()) ) );
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment