diff options
author | RĂ¼diger Timm <rt@openoffice.org> | 2006-03-08 07:50:39 +0000 |
---|---|---|
committer | RĂ¼diger Timm <rt@openoffice.org> | 2006-03-08 07:50:39 +0000 |
commit | d2670e854586f8e4ae1e6e3f28d529ebad063802 (patch) | |
tree | 310e4514c5699ad50fa228b6ae1c922274b21915 /bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx | |
parent | 68f89d32e3d8003dbab49f4958c18c89f7e7f8d4 (diff) |
INTEGRATION: CWS sixtyfour03 (1.3.32); FILE MERGED
2006/03/06 11:13:50 kendy 1.3.32.2: #i62810#
x86-64 bridge improvements: code snippet must be in a separate assembler function to have debug info (necessary for exceptions)
2006/03/06 11:08:58 kendy 1.3.32.1: #i62810#
x86-64 bridge improvements: slightly better debug
Diffstat (limited to 'bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx')
-rw-r--r-- | bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx | 81 |
1 files changed, 62 insertions, 19 deletions
diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx index 6db0d2597192..f43588ea1e81 100644 --- a/bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx @@ -4,9 +4,9 @@ * * $RCSfile: except.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: rt $ $Date: 2005-09-07 22:26:31 $ + * last change: $Author: rt $ $Date: 2006-03-08 08:50:39 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -43,7 +43,8 @@ #include <osl/diagnose.h> #include <osl/mutex.hxx> -#include <bridges/cpp_uno/bridge.hxx> +#include <com/sun/star/uno/genfunc.hxx> +#include "com/sun/star/uno/RuntimeException.hpp" #include <typelib/typedescription.hxx> #include <uno/any2.h> @@ -67,7 +68,7 @@ void dummy_can_throw_anything( char const * ) //================================================================================================== static OUString toUNOname( char const * p ) SAL_THROW( () ) { -#ifdef DEBUG +#if OSL_DEBUG_LEVEL > 1 char const * start = p; #endif @@ -92,7 +93,7 @@ static OUString toUNOname( char const * p ) SAL_THROW( () ) buf.append( (sal_Unicode)'.' ); } -#ifdef DEBUG +#if OSL_DEBUG_LEVEL > 1 OUString ret( buf.makeStringAndClear() ); OString c_ret( OUStringToOString( ret, RTL_TEXTENCODING_ASCII_US ) ); fprintf( stderr, "> toUNOname(): %s => %s\n", start, c_ret.getStr() ); @@ -174,7 +175,7 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THR // symbol and rtti-name is nearly identical, // the symbol is prefixed with _ZTI char const * rttiName = symName.getStr() +4; -#ifdef DEBUG +#if OSL_DEBUG_LEVEL > 1 fprintf( stderr,"generated rtti for %s\n", rttiName ); #endif if (pTypeDescr->pBaseTypeDescription) @@ -227,6 +228,13 @@ static void deleteException( void * pExc ) //================================================================================================== void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ) { +#if OSL_DEBUG_LEVEL > 1 + OString cstr( + OUStringToOString( + *reinterpret_cast< OUString const * >( &pUnoExc->pType->pTypeName ), + RTL_TEXTENCODING_ASCII_US ) ); + fprintf( stderr, "> uno exception occured: %s\n", cstr.getStr() ); +#endif void * pCppExc; type_info * rtti; @@ -236,7 +244,12 @@ void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ) TYPELIB_DANGER_GET( &pTypeDescr, pUnoExc->pType ); OSL_ASSERT( pTypeDescr ); if (! pTypeDescr) - terminate(); + { + throw RuntimeException( + OUString( RTL_CONSTASCII_USTRINGPARAM("cannot get typedescription for type ") ) + + *reinterpret_cast< OUString const * >( &pUnoExc->pType->pTypeName ), + Reference< XInterface >() ); + } pCppExc = __cxa_allocate_exception( pTypeDescr->nSize ); ::uno_copyAndConvertData( pCppExc, pUnoExc->pData, pTypeDescr, pUno2Cpp ); @@ -262,29 +275,59 @@ void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ) TYPELIB_DANGER_RELEASE( pTypeDescr ); OSL_ENSURE( rtti, "### no rtti for throwing exception!" ); if (! rtti) - terminate(); + { + throw RuntimeException( + OUString( RTL_CONSTASCII_USTRINGPARAM("no rtti for type ") ) + + *reinterpret_cast< OUString const * >( &pUnoExc->pType->pTypeName ), + Reference< XInterface >() ); + } } __cxa_throw( pCppExc, rtti, deleteException ); } //================================================================================================== -void fillUnoException( __cxa_exception * header, uno_Any * pExc, uno_Mapping * pCpp2Uno ) +void fillUnoException( __cxa_exception * header, uno_Any * pUnoExc, uno_Mapping * pCpp2Uno ) { - OSL_ENSURE( header, "### no exception header!!!" ); if (! header) - terminate(); + { + RuntimeException aRE( + OUString( RTL_CONSTASCII_USTRINGPARAM("no exception header!") ), + Reference< XInterface >() ); + Type const & rType = ::getCppuType( &aRE ); + uno_type_any_constructAndConvert( pUnoExc, &aRE, rType.getTypeLibType(), pCpp2Uno ); +#if OSL_DEBUG_LEVEL > 0 + OString cstr( OUStringToOString( aRE.Message, RTL_TEXTENCODING_ASCII_US ) ); + OSL_ENSURE( 0, cstr.getStr() ); +#endif + return; + } typelib_TypeDescription * pExcTypeDescr = 0; OUString unoName( toUNOname( header->exceptionType->name() ) ); - ::typelib_typedescription_getByName( &pExcTypeDescr, unoName.pData ); - OSL_ENSURE( pExcTypeDescr, "### can not get type description for exception!!!" ); - if (! pExcTypeDescr) - terminate(); - - // construct uno exception any - ::uno_any_constructAndConvert( pExc, header->adjustedPtr, pExcTypeDescr, pCpp2Uno ); - ::typelib_typedescription_release( pExcTypeDescr ); +#if OSL_DEBUG_LEVEL > 1 + OString cstr_unoName( OUStringToOString( unoName, RTL_TEXTENCODING_ASCII_US ) ); + fprintf( stderr, "> c++ exception occured: %s\n", cstr_unoName.getStr() ); +#endif + typelib_typedescription_getByName( &pExcTypeDescr, unoName.pData ); + if (0 == pExcTypeDescr) + { + RuntimeException aRE( + OUString( RTL_CONSTASCII_USTRINGPARAM("exception type not found: ") ) + unoName, + Reference< XInterface >() ); + Type const & rType = ::getCppuType( &aRE ); + uno_type_any_constructAndConvert( pUnoExc, &aRE, rType.getTypeLibType(), pCpp2Uno ); +#if OSL_DEBUG_LEVEL > 0 + OString cstr( OUStringToOString( aRE.Message, RTL_TEXTENCODING_ASCII_US ) ); + OSL_ENSURE( 0, cstr.getStr() ); +#endif + } + else + { + // construct uno exception any + uno_any_constructAndConvert( pUnoExc, header->adjustedPtr, pExcTypeDescr, pCpp2Uno ); + typelib_typedescription_release( pExcTypeDescr ); + } } } |