diff options
author | Jörg Budischewski <jbu@openoffice.org> | 2003-05-24 22:31:19 +0000 |
---|---|---|
committer | Jörg Budischewski <jbu@openoffice.org> | 2003-05-24 22:31:19 +0000 |
commit | 1e25103fb8b994f2588bf3ac08bd741187c0761f (patch) | |
tree | f781ab9c5eb0f3019bf3e039fc28a36d4c88e70d /pyuno | |
parent | 796a2d2dd1c559e49f4860c8be486848a8c2bb92 (diff) |
#i12504# added conversion mode, fixed a leak for struct/exception conversion
Diffstat (limited to 'pyuno')
-rw-r--r-- | pyuno/source/module/pyuno_runtime.cxx | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/pyuno/source/module/pyuno_runtime.cxx b/pyuno/source/module/pyuno_runtime.cxx index c9697137a3ad..e65e7b1ea56f 100644 --- a/pyuno/source/module/pyuno_runtime.cxx +++ b/pyuno/source/module/pyuno_runtime.cxx @@ -2,9 +2,9 @@ * * $RCSfile: pyuno_runtime.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: jbu $ $Date: 2003-03-30 13:32:01 $ + * last change: $Author: jbu $ $Date: 2003-05-24 23:31:19 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -456,7 +456,7 @@ PyRef Runtime::any2PyObject (const Any &a ) const PyRef value = PyRef( PyUNO_new_UNCHECKED (a, getImpl()->cargo->xInvocation), SAL_NO_ACQUIRE); PyRef argsTuple( PyTuple_New( 1 ) , SAL_NO_ACQUIRE ); PyTuple_SetItem( argsTuple.get() , 0 , value.getAcquired() ); - PyRef ret( PyObject_CallObject( excClass.get() , argsTuple.getAcquired() ), SAL_NO_ACQUIRE ); + PyRef ret( PyObject_CallObject( excClass.get() , argsTuple.get() ), SAL_NO_ACQUIRE ); if( ! ret.is() ) { OUStringBuffer buf; @@ -572,7 +572,7 @@ static Sequence< Type > invokeGetTypes( const Runtime & r , PyObject * o ) return ret; } -Any Runtime::pyObject2Any ( const PyRef & source ) const +Any Runtime::pyObject2Any ( const PyRef & source, enum ConversionMode mode ) const throw ( com::sun::star::uno::RuntimeException ) { if( ! impl->cargo->valid ) @@ -691,7 +691,7 @@ Any Runtime::pyObject2Any ( const PyRef & source ) const Sequence<Any> s (PyTuple_Size (o)); for (int i = 0; i < PyTuple_Size (o); i++) { - s[i] = pyObject2Any (PyTuple_GetItem (o, i)); + s[i] = pyObject2Any (PyTuple_GetItem (o, i), mode ); } a <<= s; } @@ -764,6 +764,32 @@ Any Runtime::pyObject2Any ( const PyRef & source ) const sal_Unicode c = PyChar2Unicode( o,runtime ); a.setValue( &c, getCharCppuType( )); } + 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( com::sun::star::uno::Exception & e ) + { + throw RuntimeException( e.Message, e.Context ); + } + } + else + { + throw RuntimeException( + OUString( RTL_CONSTASCII_USTRINGPARAM( + "uno.Any instance not accepted during method call, " + "use uno.invoke instead" ) ), + Reference< XInterface > () ); + } + } else { Reference< XInterface > mappedObject; |