summaryrefslogtreecommitdiff
path: root/pyuno
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-09-22 08:50:20 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-09-22 13:48:25 +0200
commita7ce8404befaf59df5f1a476c8dd414633bbf823 (patch)
treedc617344e2ac5a1b144614421a87d27a17ee0f36 /pyuno
parent5c54b6523f74db4f79540361fc1630aaee06bcd5 (diff)
loplugin:flatten in pyuno..sc
Change-Id: I7ddc0b76532d26910f78642200750459508c2861 Reviewed-on: https://gerrit.libreoffice.org/42617 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'pyuno')
-rw-r--r--pyuno/source/module/pyuno_runtime.cxx40
-rw-r--r--pyuno/source/module/pyuno_type.cxx47
2 files changed, 43 insertions, 44 deletions
diff --git a/pyuno/source/module/pyuno_runtime.cxx b/pyuno/source/module/pyuno_runtime.cxx
index 1a47db8999bd..0955326f61fc 100644
--- a/pyuno/source/module/pyuno_runtime.cxx
+++ b/pyuno/source/module/pyuno_runtime.cxx
@@ -764,13 +764,14 @@ Any Runtime::pyObject2Any ( const PyRef & source, enum ConversionMode mode ) con
PyRef struc(PyObject_GetAttrString( o , "value" ),SAL_NO_ACQUIRE);
PyUNO * obj = reinterpret_cast<PyUNO*>(struc.get());
Reference< XMaterialHolder > holder( obj->members->xInvocation, UNO_QUERY );
- if( holder.is( ) )
- a = holder->getMaterial();
- else
+ if( !holder.is( ) )
{
throw RuntimeException(
"struct or exception wrapper does not support XMaterialHolder" );
}
+
+ a = holder->getMaterial();
+
}
else if( PyObject_IsInstance( o, getPyUnoClass().get() ) )
{
@@ -789,28 +790,27 @@ Any Runtime::pyObject2Any ( const PyRef & source, enum ConversionMode mode ) con
}
else if( PyObject_IsInstance( o, getAnyClass( runtime ).get() ) )
{
- if( ACCEPT_UNO_ANY == mode )
- {
- a = pyObject2Any( PyRef( PyObject_GetAttrString( o , "value" ), SAL_NO_ACQUIRE) );
- Type t;
- pyObject2Any( PyRef( PyObject_GetAttrString( o, "type" ), SAL_NO_ACQUIRE ) ) >>= t;
-
- try
- {
- a = getImpl()->cargo->xTypeConverter->convertTo( a, t );
- }
- catch( const css::uno::Exception & e )
- {
- throw WrappedTargetRuntimeException(
- e.Message, e.Context, makeAny(e));
- }
- }
- else
+ if( !(ACCEPT_UNO_ANY == mode) )
{
throw RuntimeException(
"uno.Any instance not accepted during method call, "
"use uno.invoke instead" );
}
+
+ a = pyObject2Any( PyRef( PyObject_GetAttrString( o , "value" ), SAL_NO_ACQUIRE) );
+ Type t;
+ pyObject2Any( PyRef( PyObject_GetAttrString( o, "type" ), SAL_NO_ACQUIRE ) ) >>= t;
+
+ try
+ {
+ a = getImpl()->cargo->xTypeConverter->convertTo( a, t );
+ }
+ catch( const css::uno::Exception & e )
+ {
+ throw WrappedTargetRuntimeException(
+ e.Message, e.Context, makeAny(e));
+ }
+
}
else
{
diff --git a/pyuno/source/module/pyuno_type.cxx b/pyuno/source/module/pyuno_type.cxx
index b09c78de1205..e54400ba6d8d 100644
--- a/pyuno/source/module/pyuno_type.cxx
+++ b/pyuno/source/module/pyuno_type.cxx
@@ -160,38 +160,37 @@ Any PyEnum2Enum( PyObject *obj )
char *stringValue = PyStr_AsString( value.get() );
TypeDescription desc( strTypeName );
- if( desc.is() )
+ if( !desc.is() )
{
- if(desc.get()->eTypeClass != typelib_TypeClass_ENUM )
- {
- throw RuntimeException( "pyuno.checkEnum: " + strTypeName + "is a " +
- OUString::createFromAscii(typeClassToString( (css::uno::TypeClass) desc.get()->eTypeClass)) +
- ", expected ENUM" );
- }
+ throw RuntimeException( "enum " + OUString::createFromAscii( PyStr_AsString(typeName.get()) ) + " is unknown" );
+ }
+
+ if(desc.get()->eTypeClass != typelib_TypeClass_ENUM )
+ {
+ throw RuntimeException( "pyuno.checkEnum: " + strTypeName + "is a " +
+ OUString::createFromAscii(typeClassToString( (css::uno::TypeClass) desc.get()->eTypeClass)) +
+ ", expected ENUM" );
+ }
- desc.makeComplete();
+ desc.makeComplete();
- typelib_EnumTypeDescription *pEnumDesc = reinterpret_cast<typelib_EnumTypeDescription*>(desc.get());
- int i = 0;
- for( i = 0; i < pEnumDesc->nEnumValues ; i ++ )
- {
- if( OUString::unacquired(&pEnumDesc->ppEnumNames[i]).equalsAscii( stringValue ) )
- {
- break;
- }
- }
- if( i == pEnumDesc->nEnumValues )
+ typelib_EnumTypeDescription *pEnumDesc = reinterpret_cast<typelib_EnumTypeDescription*>(desc.get());
+ int i = 0;
+ for( i = 0; i < pEnumDesc->nEnumValues ; i ++ )
+ {
+ if( OUString::unacquired(&pEnumDesc->ppEnumNames[i]).equalsAscii( stringValue ) )
{
- throw RuntimeException( "value " + OUString::createFromAscii( stringValue ) +
- "is unknown in enum " +
- OUString::createFromAscii( PyStr_AsString( typeName.get() ) ) );
+ break;
}
- ret = Any( &pEnumDesc->pEnumValues[i], desc.get()->pWeakRef );
}
- else
+ if( i == pEnumDesc->nEnumValues )
{
- throw RuntimeException( "enum " + OUString::createFromAscii( PyStr_AsString(typeName.get()) ) + " is unknown" );
+ throw RuntimeException( "value " + OUString::createFromAscii( stringValue ) +
+ "is unknown in enum " +
+ OUString::createFromAscii( PyStr_AsString( typeName.get() ) ) );
}
+ ret = Any( &pEnumDesc->pEnumValues[i], desc.get()->pWeakRef );
+
return ret;
}