2000-09-18 14:29:57 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-07 21:17:14 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 14:29:57 +00:00
|
|
|
*
|
2005-09-07 21:17:14 +00:00
|
|
|
* $RCSfile: except.cxx,v $
|
2000-09-18 14:29:57 +00:00
|
|
|
*
|
2005-09-07 21:17:14 +00:00
|
|
|
* $Revision: 1.14 $
|
2000-09-18 14:29:57 +00:00
|
|
|
*
|
2005-09-07 21:17:14 +00:00
|
|
|
* last change: $Author: rt $ $Date: 2005-09-07 22:17:13 $
|
2000-09-18 14:29:57 +00:00
|
|
|
*
|
2005-09-07 21:17:14 +00:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2000-09-18 14:29:57 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-07 21:17:14 +00:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2000-09-18 14:29:57 +00:00
|
|
|
*
|
2005-09-07 21:17:14 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2000-09-18 14:29:57 +00:00
|
|
|
*
|
2005-09-07 21:17:14 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2000-09-18 14:29:57 +00:00
|
|
|
*
|
2005-09-07 21:17:14 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2000-09-18 14:29:57 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2005-07-01 11:15:52 +00:00
|
|
|
#include <cstddef>
|
2000-09-18 14:29:57 +00:00
|
|
|
#include <dlfcn.h>
|
|
|
|
#include <new.h>
|
|
|
|
#include <typeinfo>
|
2001-02-06 21:20:37 +00:00
|
|
|
#include <list>
|
|
|
|
#include <map>
|
2000-09-18 14:29:57 +00:00
|
|
|
#ifndef _RTL_ALLOC_H_
|
|
|
|
#include <rtl/alloc.h>
|
|
|
|
#endif
|
|
|
|
#ifndef _OSL_DIAGNOSE_H_
|
|
|
|
#include <osl/diagnose.h>
|
|
|
|
#endif
|
|
|
|
|
2001-05-15 10:16:21 +00:00
|
|
|
#include <rtl/strbuf.hxx>
|
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
#ifndef _TYPELIB_TYPEDESCRIPTION_HXX_
|
|
|
|
#include <typelib/typedescription.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UNO_ANY_HXX_
|
|
|
|
#include <com/sun/star/uno/Any.hxx>
|
|
|
|
#endif
|
|
|
|
|
2005-07-01 11:15:52 +00:00
|
|
|
#include "bridges/cpp_uno/shared/arraypointer.hxx"
|
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
#include "cc50_solaris_intel.hxx"
|
|
|
|
|
2001-06-21 09:11:26 +00:00
|
|
|
#include <hash.cxx>
|
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
// need a += operator for OString and sal_Char
|
|
|
|
namespace rtl
|
|
|
|
{
|
|
|
|
inline OString& operator+=( OString& rString, sal_Char cAdd )
|
|
|
|
{
|
|
|
|
sal_Char add[2];
|
|
|
|
add[0] = cAdd;
|
|
|
|
add[1] = 0;
|
|
|
|
return rString += add;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace osl;
|
|
|
|
using namespace rtl;
|
|
|
|
using namespace com::sun::star::uno;
|
|
|
|
|
|
|
|
namespace CPPU_CURRENT_NAMESPACE
|
|
|
|
{
|
|
|
|
|
|
|
|
static OString toUNOname( const OString & rRTTIname )
|
|
|
|
{
|
|
|
|
OString aRet;
|
|
|
|
|
|
|
|
const sal_Char* pRTTI = rRTTIname.getStr();
|
|
|
|
const sal_Char* pOrg = pRTTI;
|
|
|
|
const sal_Char* pLast = pRTTI;
|
|
|
|
|
|
|
|
while( 1 )
|
|
|
|
{
|
2001-06-21 09:11:26 +00:00
|
|
|
if( *pRTTI == ':' || ! *pRTTI )
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
|
|
|
if( aRet.getLength() )
|
|
|
|
aRet += ".";
|
|
|
|
aRet += rRTTIname.copy( pLast - pOrg, pRTTI - pLast );
|
|
|
|
while( *pRTTI == ':' )
|
|
|
|
pRTTI++;
|
|
|
|
pLast = pRTTI;
|
|
|
|
if( ! *pRTTI )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pRTTI++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
//==================================================================================================
|
|
|
|
static OString toRTTIname( const OString & rUNOname )
|
|
|
|
{
|
2001-06-21 09:11:26 +00:00
|
|
|
OStringBuffer aRet( rUNOname.getLength()*2 );
|
2000-09-18 14:29:57 +00:00
|
|
|
|
2001-05-15 10:16:21 +00:00
|
|
|
sal_Int32 nIndex = 0;
|
|
|
|
do
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
2001-06-21 09:11:26 +00:00
|
|
|
if( nIndex > 0 )
|
|
|
|
aRet.append( "::" );
|
|
|
|
aRet.append( rUNOname.getToken( 0, '.', nIndex ) );
|
|
|
|
} while( nIndex != -1 );
|
2000-09-18 14:29:57 +00:00
|
|
|
|
2001-06-21 09:11:26 +00:00
|
|
|
return aRet.makeStringAndClear();
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
//==================================================================================================
|
|
|
|
|
2001-06-21 09:11:26 +00:00
|
|
|
static OString toRTTImangledname( const OString & rRTTIname )
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
|
|
|
if( ! rRTTIname.getLength() )
|
|
|
|
return OString();
|
|
|
|
|
2001-06-21 09:11:26 +00:00
|
|
|
OStringBuffer aRet( rRTTIname.getLength()*2 );
|
2000-09-18 14:29:57 +00:00
|
|
|
|
2001-06-21 09:11:26 +00:00
|
|
|
aRet.append( "__1n" );
|
2001-05-15 10:16:21 +00:00
|
|
|
sal_Int32 nIndex = 0;
|
|
|
|
do
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
2001-05-15 10:16:21 +00:00
|
|
|
OString aToken( rRTTIname.getToken( 0, ':', nIndex ) );
|
2000-09-18 14:29:57 +00:00
|
|
|
int nBytes = aToken.getLength();
|
|
|
|
if( nBytes )
|
|
|
|
{
|
2001-06-21 09:11:26 +00:00
|
|
|
if( nBytes > 25 )
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
2001-06-21 09:11:26 +00:00
|
|
|
aRet.append( (sal_Char)( nBytes/26 + 'a' ) );
|
|
|
|
aRet.append( (sal_Char)( nBytes%26 + 'A' ) );
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
else
|
2001-06-21 09:11:26 +00:00
|
|
|
aRet.append( (sal_Char)( nBytes + 'A' ) );
|
|
|
|
aRet.append( aToken );
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
2001-06-21 09:11:26 +00:00
|
|
|
} while( nIndex != -1 );
|
2000-09-18 14:29:57 +00:00
|
|
|
|
2001-06-21 09:11:26 +00:00
|
|
|
aRet.append( '_' );
|
2000-09-18 14:29:57 +00:00
|
|
|
|
2001-06-21 09:11:26 +00:00
|
|
|
return aRet.makeStringAndClear();
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//##################################################################################################
|
|
|
|
//#### RTTI simulation #############################################################################
|
|
|
|
//##################################################################################################
|
|
|
|
|
|
|
|
class RTTIHolder
|
|
|
|
{
|
2001-06-21 09:11:26 +00:00
|
|
|
std::map< OString, void* > aAllRTTI;
|
2000-09-18 14:29:57 +00:00
|
|
|
public:
|
2001-06-21 09:11:26 +00:00
|
|
|
~RTTIHolder();
|
|
|
|
|
|
|
|
void* getRTTI( const OString& rTypename );
|
|
|
|
void* getRTTI_UnoName( const OString& rUnoTypename )
|
2000-09-18 14:29:57 +00:00
|
|
|
{ return getRTTI( toRTTIname( rUnoTypename ) ); }
|
|
|
|
|
2001-06-21 09:11:26 +00:00
|
|
|
void* insertRTTI( const OString& rTypename );
|
|
|
|
void* insertRTTI_UnoName( const OString& rTypename )
|
2000-09-18 14:29:57 +00:00
|
|
|
{ return insertRTTI( toRTTIname( rTypename ) ); }
|
2001-06-21 09:11:26 +00:00
|
|
|
void* generateRTTI( typelib_CompoundTypeDescription* pCompTypeDescr );
|
2000-09-18 14:29:57 +00:00
|
|
|
};
|
|
|
|
|
2001-06-21 09:11:26 +00:00
|
|
|
RTTIHolder::~RTTIHolder()
|
|
|
|
{
|
|
|
|
for ( std::map< OString, void* >::const_iterator iPos( aAllRTTI.begin() );
|
|
|
|
iPos != aAllRTTI.end(); ++iPos )
|
|
|
|
{
|
2005-07-01 11:15:52 +00:00
|
|
|
delete[] static_cast< char * >(iPos->second);
|
2001-06-21 09:11:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-04-15 15:23:52 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2001-06-21 09:11:26 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#endif
|
2000-09-18 14:29:57 +00:00
|
|
|
|
|
|
|
void* RTTIHolder::getRTTI( const OString& rTypename )
|
|
|
|
{
|
|
|
|
std::map< OString, void* >::iterator element;
|
|
|
|
|
|
|
|
element = aAllRTTI.find( rTypename );
|
|
|
|
if( element != aAllRTTI.end() )
|
|
|
|
return (*element).second;
|
|
|
|
|
2001-06-21 09:11:26 +00:00
|
|
|
// create rtti structure
|
|
|
|
element = aAllRTTI.find( rTypename );
|
|
|
|
if( element != aAllRTTI.end() )
|
|
|
|
return (*element).second;
|
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static long nMagicId = 1;
|
|
|
|
|
|
|
|
void* RTTIHolder::insertRTTI( const OString& rTypename )
|
|
|
|
{
|
2001-06-21 09:11:26 +00:00
|
|
|
OString aMangledName( toRTTImangledname( rTypename ) );
|
|
|
|
NIST_Hash aHash( aMangledName.getStr(), aMangledName.getLength() );
|
|
|
|
|
|
|
|
|
|
|
|
// rSuperTypename MUST exist !!!
|
2005-07-01 11:15:52 +00:00
|
|
|
std::size_t const RTTI_SIZE = 19; // 14???
|
|
|
|
void** pRTTI = reinterpret_cast< void ** >(
|
|
|
|
new char[RTTI_SIZE * sizeof (void *) + strlen(rTypename.getStr()) + 1]);
|
|
|
|
pRTTI[ 0 ] = reinterpret_cast< void * >(RTTI_SIZE * sizeof (void *));
|
2001-06-21 09:11:26 +00:00
|
|
|
pRTTI[ 1 ] = NULL;
|
2000-09-18 14:29:57 +00:00
|
|
|
pRTTI[ 2 ] = (void*)(7*sizeof(void*));
|
2001-06-21 09:11:26 +00:00
|
|
|
pRTTI[ 3 ] = (void*)aHash.getHash()[0];
|
|
|
|
pRTTI[ 4 ] = (void*)aHash.getHash()[1];
|
|
|
|
pRTTI[ 5 ] = (void*)aHash.getHash()[2];
|
|
|
|
pRTTI[ 6 ] = (void*)aHash.getHash()[3];
|
|
|
|
pRTTI[ 7 ] = NULL;
|
|
|
|
pRTTI[ 8 ] = NULL;
|
2000-09-18 14:29:57 +00:00
|
|
|
|
|
|
|
pRTTI[ 9 ] = pRTTI[ 3 ];
|
|
|
|
pRTTI[ 10 ] = pRTTI[ 4 ];
|
|
|
|
pRTTI[ 11 ] = pRTTI[ 5 ];
|
|
|
|
pRTTI[ 12 ] = pRTTI[ 6 ];
|
|
|
|
pRTTI[ 13 ] = (void*)0x80000000;
|
2005-07-01 11:15:52 +00:00
|
|
|
strcpy(reinterpret_cast< char * >(pRTTI + RTTI_SIZE), rTypename.getStr());
|
2000-09-18 14:29:57 +00:00
|
|
|
|
|
|
|
aAllRTTI[ rTypename ] = (void*)pRTTI;
|
2003-04-15 15:23:52 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2001-06-21 09:11:26 +00:00
|
|
|
fprintf( stderr,
|
|
|
|
"generating base RTTI for type %s:\n"
|
|
|
|
" mangled: %s\n"
|
|
|
|
" hash: %.8x %.8x %.8x %.8x\n",
|
|
|
|
rTypename.getStr(),
|
|
|
|
aMangledName.getStr(),
|
|
|
|
pRTTI[ 3 ], pRTTI[ 4 ], pRTTI[ 5 ], pRTTI[ 6 ]
|
|
|
|
);
|
|
|
|
#endif
|
2000-09-18 14:29:57 +00:00
|
|
|
return pRTTI;
|
|
|
|
}
|
|
|
|
|
2001-06-21 09:11:26 +00:00
|
|
|
void* RTTIHolder::generateRTTI( typelib_CompoundTypeDescription * pCompTypeDescr )
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
2001-06-21 09:11:26 +00:00
|
|
|
OString aUNOCompTypeName( OUStringToOString( pCompTypeDescr->aBase.pTypeName, RTL_TEXTENCODING_ASCII_US ) );
|
|
|
|
OString aRTTICompTypeName( toRTTIname( aUNOCompTypeName ) );
|
2000-09-18 14:29:57 +00:00
|
|
|
|
2001-06-21 09:11:26 +00:00
|
|
|
void* pHaveRTTI = getRTTI( aRTTICompTypeName );
|
|
|
|
if( pHaveRTTI )
|
|
|
|
return pHaveRTTI;
|
2000-09-18 14:29:57 +00:00
|
|
|
|
2001-06-21 09:11:26 +00:00
|
|
|
if( ! pCompTypeDescr->pBaseTypeDescription )
|
|
|
|
// this is a base type
|
|
|
|
return insertRTTI( aRTTICompTypeName );
|
2000-09-18 14:29:57 +00:00
|
|
|
|
2001-06-21 09:11:26 +00:00
|
|
|
// get base class RTTI
|
|
|
|
void* pSuperRTTI = generateRTTI( pCompTypeDescr->pBaseTypeDescription );
|
|
|
|
OSL_ENSURE( pSuperRTTI, "could not generate RTTI for supertype !" );
|
2000-09-18 14:29:57 +00:00
|
|
|
|
2001-06-21 09:11:26 +00:00
|
|
|
// find out the size to allocate for RTTI
|
|
|
|
void** pInherit = (void**)((sal_uInt32)pSuperRTTI + ((sal_uInt32*)pSuperRTTI)[2] + 8);
|
|
|
|
int nInherit;
|
|
|
|
for( nInherit = 1; pInherit[ nInherit*5-1 ] != (void*)0x80000000; nInherit++ )
|
|
|
|
;
|
2000-09-18 14:29:57 +00:00
|
|
|
|
2001-06-21 09:11:26 +00:00
|
|
|
OString aMangledName( toRTTImangledname( aRTTICompTypeName ) );
|
|
|
|
NIST_Hash aHash( aMangledName.getStr(), aMangledName.getLength() );
|
2000-09-18 14:29:57 +00:00
|
|
|
|
2005-07-01 11:15:52 +00:00
|
|
|
std::size_t const rttiSize = 14 + nInherit * 5;
|
|
|
|
void** pRTTI = reinterpret_cast< void ** >(
|
|
|
|
new char[
|
|
|
|
rttiSize * sizeof (void *)
|
|
|
|
+ strlen(aRTTICompTypeName.getStr()) + 1]);
|
|
|
|
pRTTI[ 0 ] = reinterpret_cast< void * >(rttiSize * sizeof (void *));
|
2001-06-21 09:11:26 +00:00
|
|
|
pRTTI[ 1 ] = NULL;
|
|
|
|
pRTTI[ 2 ] = (void*)(7*sizeof(void*));
|
|
|
|
pRTTI[ 3 ] = (void*)aHash.getHash()[0];
|
|
|
|
pRTTI[ 4 ] = (void*)aHash.getHash()[1];
|
|
|
|
pRTTI[ 5 ] = (void*)aHash.getHash()[2];
|
|
|
|
pRTTI[ 6 ] = (void*)aHash.getHash()[3];
|
|
|
|
pRTTI[ 7 ] = NULL;
|
|
|
|
pRTTI[ 8 ] = NULL;
|
|
|
|
|
|
|
|
memcpy( pRTTI+9, pInherit, 4*nInherit*5 );
|
|
|
|
pRTTI[ 8 +nInherit*5 ] = NULL;
|
|
|
|
pRTTI[ 9 +nInherit*5 ] = pRTTI[ 3 ];
|
|
|
|
pRTTI[ 10+nInherit*5 ] = pRTTI[ 4 ];
|
|
|
|
pRTTI[ 11+nInherit*5 ] = pRTTI[ 5 ];
|
|
|
|
pRTTI[ 12+nInherit*5 ] = pRTTI[ 6 ];
|
|
|
|
pRTTI[ 13+nInherit*5 ] = (void*)0x80000000;
|
2005-07-01 11:15:52 +00:00
|
|
|
strcpy(
|
|
|
|
reinterpret_cast< char * >(pRTTI + rttiSize),
|
|
|
|
aRTTICompTypeName.getStr());
|
2001-06-21 09:11:26 +00:00
|
|
|
|
|
|
|
aAllRTTI[ aRTTICompTypeName ] = (void*)pRTTI;
|
|
|
|
|
2003-04-15 15:23:52 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2001-06-21 09:11:26 +00:00
|
|
|
fprintf( stderr,
|
|
|
|
"generating struct RTTI for type %s:\n"
|
|
|
|
" mangled: %s\n"
|
|
|
|
" hash: %.8x %.8x %.8X %.8x\n",
|
|
|
|
aRTTICompTypeName.getStr(),
|
|
|
|
aMangledName.getStr(),
|
|
|
|
pRTTI[ 3 ], pRTTI[ 4 ], pRTTI[ 5 ], pRTTI[ 6 ]
|
|
|
|
);
|
|
|
|
#endif
|
2000-09-18 14:29:57 +00:00
|
|
|
|
2001-06-21 09:11:26 +00:00
|
|
|
return pRTTI;
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
|
2001-06-21 09:11:26 +00:00
|
|
|
//__________________________________________________________________________________________________
|
2000-09-18 14:29:57 +00:00
|
|
|
|
2005-07-01 11:15:52 +00:00
|
|
|
static void deleteException(
|
|
|
|
void* pExc, unsigned char* thunk, typelib_TypeDescription* pType )
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
2001-06-21 09:11:26 +00:00
|
|
|
uno_destructData( pExc, pType, cpp_release );
|
|
|
|
typelib_typedescription_release( pType );
|
2005-07-01 11:15:52 +00:00
|
|
|
delete[] thunk;
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//__________________________________________________________________________________________________
|
|
|
|
|
|
|
|
//##################################################################################################
|
|
|
|
//#### exported ####################################################################################
|
|
|
|
//##################################################################################################
|
|
|
|
|
|
|
|
void cc50_solaris_intel_raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp )
|
|
|
|
{
|
2003-04-15 15:23:52 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2003-03-18 18:07:19 +00:00
|
|
|
OString cstr(
|
|
|
|
OUStringToOString(
|
|
|
|
*reinterpret_cast< OUString const * >( &pUnoExc->pType->pTypeName ),
|
|
|
|
RTL_TEXTENCODING_ASCII_US ) );
|
|
|
|
fprintf( stderr, "> uno exception occured: %s\n", cstr.getStr() );
|
|
|
|
#endif
|
2005-07-01 11:15:52 +00:00
|
|
|
bridges::cpp_uno::shared::ArrayPointer< unsigned char > thunkPtr(
|
|
|
|
new unsigned char[24]);
|
2000-09-18 14:29:57 +00:00
|
|
|
typelib_TypeDescription * pTypeDescr = 0;
|
2001-06-21 09:11:26 +00:00
|
|
|
// will be released by deleteException
|
2001-03-22 13:53:27 +00:00
|
|
|
typelib_typedescriptionreference_getDescription( &pTypeDescr, pUnoExc->pType );
|
2000-09-18 14:29:57 +00:00
|
|
|
|
2001-06-21 09:11:26 +00:00
|
|
|
void* pRTTI;
|
|
|
|
{
|
|
|
|
static ::osl::Mutex aMutex;
|
|
|
|
::osl::Guard< ::osl::Mutex > guard( aMutex );
|
2000-09-18 14:29:57 +00:00
|
|
|
|
2001-06-21 09:11:26 +00:00
|
|
|
static RTTIHolder * s_pRTTI = 0;
|
|
|
|
if (! s_pRTTI)
|
|
|
|
{
|
|
|
|
#ifdef LEAK_STATIC_DATA
|
|
|
|
s_pRTTI = new RTTIHolder();
|
|
|
|
#else
|
|
|
|
static RTTIHolder s_aRTTI;
|
|
|
|
s_pRTTI = &s_aRTTI;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
pRTTI = s_pRTTI->generateRTTI( (typelib_CompoundTypeDescription *)pTypeDescr );
|
|
|
|
}
|
2000-09-18 14:29:57 +00:00
|
|
|
|
|
|
|
// a must be
|
2001-03-12 13:43:35 +00:00
|
|
|
OSL_ENSURE( sizeof(sal_Int32) == sizeof(void *), "### pointer size differs from sal_Int32!" );
|
2000-09-18 14:29:57 +00:00
|
|
|
|
2005-07-01 11:15:52 +00:00
|
|
|
void * pCppExc = __Crun::ex_alloc( pTypeDescr->nSize );
|
2001-06-21 09:11:26 +00:00
|
|
|
uno_copyAndConvertData( pCppExc, pUnoExc->pData, pTypeDescr, pUno2Cpp );
|
2000-09-18 14:29:57 +00:00
|
|
|
|
2001-06-21 09:11:26 +00:00
|
|
|
// destruct uno exception
|
|
|
|
uno_any_destruct( pUnoExc, 0 );
|
2000-09-18 14:29:57 +00:00
|
|
|
|
2005-07-01 11:15:52 +00:00
|
|
|
unsigned char * thunk = thunkPtr.release();
|
|
|
|
// movl %esp, %ecx:
|
|
|
|
thunk[0] = 0x8B;
|
|
|
|
thunk[1] = 0xCC;
|
|
|
|
// pushl pTypeDescr:
|
|
|
|
thunk[2] = 0x68;
|
|
|
|
*reinterpret_cast< void ** >(thunk + 3) = pTypeDescr;
|
|
|
|
// pushl thunk:
|
|
|
|
thunk[7] = 0x68;
|
|
|
|
*reinterpret_cast< void ** >(thunk + 8) = thunk;
|
|
|
|
// pushl 4(%ecx):
|
|
|
|
thunk[12] = 0xFF;
|
|
|
|
thunk[13] = 0x71;
|
|
|
|
thunk[14] = 0x04;
|
|
|
|
// call deleteException:
|
|
|
|
thunk[15] = 0xE8;
|
|
|
|
*reinterpret_cast< std::ptrdiff_t * >(thunk + 16) =
|
|
|
|
reinterpret_cast< unsigned char * >(deleteException) - (thunk + 20);
|
|
|
|
// addl $12, %esp:
|
|
|
|
thunk[20] = 0x83;
|
|
|
|
thunk[21] = 0xC4;
|
|
|
|
thunk[22] = 0x0C;
|
|
|
|
// ret:
|
|
|
|
thunk[23] = 0xC3;
|
|
|
|
|
|
|
|
__Crun::ex_throw(
|
|
|
|
pCppExc, (const __Crun::static_type_info*)pRTTI,
|
|
|
|
reinterpret_cast< void (*)(void *) >(thunk) );
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void cc50_solaris_intel_fillUnoException(
|
|
|
|
void* pCppExc,
|
|
|
|
const char* pInfo,
|
2003-03-18 18:07:19 +00:00
|
|
|
uno_Any* pUnoExc,
|
2000-09-18 14:29:57 +00:00
|
|
|
uno_Mapping * pCpp2Uno )
|
|
|
|
{
|
2005-07-01 11:15:52 +00:00
|
|
|
OSL_ASSERT( pInfo != 0 );
|
|
|
|
OString uno_name( toUNOname( pInfo ) );
|
|
|
|
OUString aName( OStringToOUString(
|
|
|
|
uno_name, RTL_TEXTENCODING_ASCII_US ) );
|
|
|
|
typelib_TypeDescription * pExcTypeDescr = 0;
|
|
|
|
typelib_typedescription_getByName( &pExcTypeDescr, aName.pData );
|
|
|
|
|
|
|
|
if (pExcTypeDescr == 0) // the thing that should not be
|
2003-03-18 18:07:19 +00:00
|
|
|
{
|
2005-07-01 11:15:52 +00:00
|
|
|
RuntimeException aRE(
|
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM(
|
|
|
|
"exception type not found: ") ) + aName,
|
|
|
|
Reference< XInterface >() );
|
|
|
|
Type const & rType = ::getCppuType( &aRE );
|
|
|
|
uno_type_any_constructAndConvert(
|
|
|
|
pUnoExc, &aRE, rType.getTypeLibType(), pCpp2Uno );
|
2003-04-15 15:23:52 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 0
|
2005-07-01 11:15:52 +00:00
|
|
|
OString cstr( OUStringToOString(
|
|
|
|
aRE.Message, RTL_TEXTENCODING_ASCII_US ) );
|
|
|
|
OSL_ENSURE( 0, cstr.getStr() );
|
2003-03-18 18:07:19 +00:00
|
|
|
#endif
|
2005-07-01 11:15:52 +00:00
|
|
|
return;
|
2003-03-18 18:07:19 +00:00
|
|
|
}
|
2004-05-19 12:09:22 +00:00
|
|
|
|
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
|
|
|
fprintf( stderr, "> c++ exception occured: %s\n",
|
|
|
|
::rtl::OUStringToOString(
|
|
|
|
pExcTypeDescr->pTypeName,
|
|
|
|
RTL_TEXTENCODING_ASCII_US ).getStr() );
|
|
|
|
#endif
|
|
|
|
// construct uno exception any
|
|
|
|
uno_any_constructAndConvert(
|
|
|
|
pUnoExc, pCppExc, pExcTypeDescr, pCpp2Uno );
|
2005-07-01 11:15:52 +00:00
|
|
|
typelib_typedescription_release( pExcTypeDescr );
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|