25#include <rtl/strbuf.hxx>
26#include <rtl/ustrbuf.hxx>
27#include <osl/mutex.hxx>
29#include <com/sun/star/uno/genfunc.hxx>
30#include <typelib/typedescription.hxx>
32#include <unordered_map>
51#if OSL_DEBUG_LEVEL > 1
57 OUStringBuffer buf( 64 );
64 long n = (*
p++ -
'0');
65 while (
'0' <= *
p &&
'9' >= *
p)
70 buf.appendAscii(
p,
n );
76#if OSL_DEBUG_LEVEL > 1
77 OUString ret( buf.makeStringAndClear() );
79 fprintf( stderr,
"> toUNOname(): %s => %s\n",
start, c_ret.getStr() );
82 return buf.makeStringAndClear();
88 typedef std::unordered_map< OUString, type_info * >
t_rtti_map;
100 type_info *
getRTTI( typelib_CompoundTypeDescription * );
104 :
m_hApp( dlopen( 0, RTLD_LAZY ) )
114type_info *
RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr )
118 OUString
const & unoName = *(OUString
const *)&pTypeDescr->aBase.pTypeName;
121 t_rtti_map::const_iterator iRttiFind(
m_rttis.find( unoName ) );
122 if (iRttiFind ==
m_rttis.end())
125 OStringBuffer buf( 64 );
126 buf.append(
"_ZTIN" );
130 OUString token( unoName.getToken( 0,
'.', index ) );
131 buf.append( token.getLength() );
133 buf.append( c_token );
138 OString symName( buf.makeStringAndClear() );
139 rtti = (type_info *)dlsym(
m_hApp, symName.getStr() );
143 pair< t_rtti_map::iterator, bool > insertion(
144 m_rttis.insert( t_rtti_map::value_type( unoName, rtti ) ) );
145 assert( insertion.second &&
"### inserting new rtti failed?!");
156 char const * rttiName = symName.getStr() +4;
157#if OSL_DEBUG_LEVEL > 1
158 fprintf( stderr,
"generated rtti for %s\n", rttiName );
160 if (pTypeDescr->pBaseTypeDescription)
163 type_info * base_rtti =
getRTTI(
164 (typelib_CompoundTypeDescription *)pTypeDescr->pBaseTypeDescription );
165 rtti =
new __si_class_type_info(
166 strdup( rttiName ), (__class_type_info *)base_rtti );
171 rtti =
new __class_type_info( strdup( rttiName ) );
174 pair< t_rtti_map::iterator, bool > insertion(
176 assert(insertion.second &&
"### inserting new generated rtti failed?!");
180 rtti = iFind->second;
186 rtti = iRttiFind->second;
198 ::typelib_typedescription_getByName( &pTD, unoName.pData );
199 assert(pTD &&
"### unknown exception type! leaving out destruction => leaking!!!");
202 ::uno_destructData( pExc, pTD, cpp_release );
203 ::typelib_typedescription_release( pTD );
215 TYPELIB_DANGER_GET( &pTypeDescr, pUnoExc->pType );
221 ::uno_copyAndConvertData( pCppExc, pUnoExc->pData, pTypeDescr, pUno2Cpp );
224 ::uno_any_destruct( pUnoExc, 0 );
226 static RTTI rtti_data;
227 rtti = (type_info*)rtti_data.getRTTI((typelib_CompoundTypeDescription*)pTypeDescr);
228 TYPELIB_DANGER_RELEASE( pTypeDescr );
245 OUString unoName(
toUNOname( exceptionType->name() ) );
246 ::typelib_typedescription_getByName( &pExcTypeDescr, unoName.pData );
251 ::uno_any_constructAndConvert( pExc,
header->adjustedPtr, pExcTypeDescr, pCpp2Uno );
252 ::typelib_typedescription_release( pExcTypeDescr );
constexpr sal_Int8 header[]
std::type_info * getRTTI(typelib_CompoundTypeDescription *)
type_info * getRTTI(typelib_CompoundTypeDescription *)
std::unordered_map< OUString, type_info * > t_rtti_map
std::unordered_map< OUString, std::type_info *, OUStringHash > t_rtti_map
t_rtti_map m_generatedRttis
struct _uno_Mapping uno_Mapping
struct _typelib_TypeDescription typelib_TypeDescription
static void deleteException(void *pExc)
__cxa_eh_globals * __cxa_get_globals()
void __cxa_throw(void *thrown_exception, std::type_info *tinfo, void(*dest)(void *)) __attribute__((noreturn))
void dummy_can_throw_anything(char const *)
void * __cxa_allocate_exception(std::size_t thrown_size)
void fillUnoException(uno_Any *pUnoExc, uno_Mapping *pCpp2Uno)
std::type_info * __cxa_current_exception_type()
static OUString toUNOname(char const *p)
void raiseException(uno_Any *pUnoExc, uno_Mapping *pUno2Cpp)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
__cxa_exception * caughtExceptions