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>
37 using namespace ::
std;
38 using namespace ::
osl;
59 OUStringBuffer buf( 64 );
66 long n = (*p++ -
'0');
67 while (
'0' <= *p &&
'9' >= *p)
72 buf.appendAscii( p, n );
79 OUString ret( buf.makeStringAndClear() );
81 fprintf( stderr,
"> toUNOname(): %s => %s\n", start, c_ret.getStr() );
84 return buf.makeStringAndClear();
91 typedef std::unordered_map< OUString, type_info * >
t_rtti_map;
103 type_info *
getRTTI( typelib_CompoundTypeDescription * );
107 :
m_hApp( dlopen( 0, RTLD_LAZY ) )
121 OUString
const & unoName = *(OUString
const *)&pTypeDescr->aBase.pTypeName;
124 t_rtti_map::const_iterator iFind(
m_rttis.find( unoName ) );
128 OStringBuffer buf( 64 );
129 buf.append(
"_ZTIN" );
133 OUString token( unoName.getToken( 0,
'.', index ) );
134 buf.append( token.getLength() );
136 buf.append( c_token );
141 OString symName( buf.makeStringAndClear() );
142 rtti = (type_info *)dlsym(
m_hApp, symName.getStr() );
146 pair< t_rtti_map::iterator, bool > insertion(
147 m_rttis.insert( t_rtti_map::value_type( unoName, rtti ) ) );
148 assert(insertion.second);
159 char const * rttiName = symName.getStr() +4;
161 fprintf( stderr,
"generated rtti for %s\n", rttiName );
163 if (pTypeDescr->pBaseTypeDescription)
166 type_info * base_rtti =
getRTTI(
167 (typelib_CompoundTypeDescription *)pTypeDescr->pBaseTypeDescription );
168 rtti =
new __si_class_type_info(
169 strdup( rttiName ), (__class_type_info *)base_rtti );
174 rtti =
new __class_type_info( strdup( rttiName ) );
177 pair< t_rtti_map::iterator, bool > insertion(
179 assert(insertion.second);
183 rtti = iiFind->second;
189 rtti = iFind->second;
200 ::typelib_typedescription_getByName( &pTD, unoName.pData );
201 assert(pTD &&
"### unknown exception type! leaving out destruction => leaking!!!");
204 ::uno_destructData( pExc, pTD, cpp_release );
205 ::typelib_typedescription_release( pTD );
218 TYPELIB_DANGER_GET( &pTypeDescr, pUnoExc->pType );
223 ::uno_copyAndConvertData( pCppExc, pUnoExc->pData, pTypeDescr, pUno2Cpp );
226 ::uno_any_destruct( pUnoExc, 0 );
228 static RTTI rtti_data;
229 rtti = (type_info*)rtti_data.
getRTTI((typelib_CompoundTypeDescription*)pTypeDescr);
230 TYPELIB_DANGER_RELEASE( pTypeDescr );
248 OUString unoName(
toUNOname( exceptionType->name() ) );
249 ::typelib_typedescription_getByName( &pExcTypeDescr, unoName.pData );
254 ::uno_any_constructAndConvert( pExc, header->
adjustedPtr, pExcTypeDescr, pCpp2Uno );
255 ::typelib_typedescription_release( pExcTypeDescr );
static void deleteException(void *pExc)
static OUString toUNOname(char const *p)
struct _uno_Mapping uno_Mapping
void fillUnoException(uno_Any *pExc, uno_Mapping *pCpp2Uno)
void * __cxa_allocate_exception(std::size_t thrown_size)
std::type_info * exceptionType
std::type_info * __cxa_current_exception_type()
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
__cxa_exception * caughtExceptions
type_info * getRTTI(typelib_CompoundTypeDescription *)
t_rtti_map m_generatedRttis
struct _typelib_TypeDescription typelib_TypeDescription
void __cxa_throw(void *thrown_exception, std::type_info *tinfo, void(*dest)(void *)) __attribute__((noreturn))
std::unordered_map< OUString, type_info * > t_rtti_map
void raiseException(uno_Any *pUnoExc, uno_Mapping *pUno2Cpp)
__cxa_eh_globals * __cxa_get_globals()
void dummy_can_throw_anything(char const *)