161dff127SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
361dff127SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
461dff127SAndrew Rist * or more contributor license agreements. See the NOTICE file
561dff127SAndrew Rist * distributed with this work for additional information
661dff127SAndrew Rist * regarding copyright ownership. The ASF licenses this file
761dff127SAndrew Rist * to you under the Apache License, Version 2.0 (the
861dff127SAndrew Rist * "License"); you may not use this file except in compliance
961dff127SAndrew Rist * with the License. You may obtain a copy of the License at
1061dff127SAndrew Rist *
1161dff127SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
1261dff127SAndrew Rist *
1361dff127SAndrew Rist * Unless required by applicable law or agreed to in writing,
1461dff127SAndrew Rist * software distributed under the License is distributed on an
1561dff127SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1661dff127SAndrew Rist * KIND, either express or implied. See the License for the
1761dff127SAndrew Rist * specific language governing permissions and limitations
1861dff127SAndrew Rist * under the License.
1961dff127SAndrew Rist *
2061dff127SAndrew Rist *************************************************************/
2161dff127SAndrew Rist
2261dff127SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_bridges.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <cstddef>
28cdf0e10cSrcweir #include <dlfcn.h>
29cdf0e10cSrcweir #include <new.h>
30cdf0e10cSrcweir #include <typeinfo>
31cdf0e10cSrcweir #include <list>
32cdf0e10cSrcweir #include <map>
33cdf0e10cSrcweir #include <rtl/alloc.h>
34cdf0e10cSrcweir #include <osl/diagnose.h>
35cdf0e10cSrcweir
36cdf0e10cSrcweir #include <rtl/strbuf.hxx>
37cdf0e10cSrcweir #include <typelib/typedescription.hxx>
38cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
39cdf0e10cSrcweir
40cdf0e10cSrcweir #include "bridges/cpp_uno/shared/arraypointer.hxx"
41cdf0e10cSrcweir
42cdf0e10cSrcweir #include "cc50_solaris_intel.hxx"
43cdf0e10cSrcweir
44cdf0e10cSrcweir #include <hash.cxx>
45cdf0e10cSrcweir
46cdf0e10cSrcweir // need a += operator for OString and sal_Char
47cdf0e10cSrcweir namespace rtl
48cdf0e10cSrcweir {
operator +=(OString & rString,sal_Char cAdd)49cdf0e10cSrcweir inline OString& operator+=( OString& rString, sal_Char cAdd )
50cdf0e10cSrcweir {
51cdf0e10cSrcweir sal_Char add[2];
52cdf0e10cSrcweir add[0] = cAdd;
53cdf0e10cSrcweir add[1] = 0;
54cdf0e10cSrcweir return rString += add;
55cdf0e10cSrcweir }
56cdf0e10cSrcweir }
57cdf0e10cSrcweir
58cdf0e10cSrcweir using namespace std;
59cdf0e10cSrcweir using namespace osl;
60cdf0e10cSrcweir using namespace rtl;
61cdf0e10cSrcweir using namespace com::sun::star::uno;
62cdf0e10cSrcweir
63cdf0e10cSrcweir namespace CPPU_CURRENT_NAMESPACE
64cdf0e10cSrcweir {
65cdf0e10cSrcweir
toUNOname(const OString & rRTTIname)66cdf0e10cSrcweir static OString toUNOname( const OString & rRTTIname )
67cdf0e10cSrcweir {
68cdf0e10cSrcweir OString aRet;
69cdf0e10cSrcweir
70cdf0e10cSrcweir const sal_Char* pRTTI = rRTTIname.getStr();
71cdf0e10cSrcweir const sal_Char* pOrg = pRTTI;
72cdf0e10cSrcweir const sal_Char* pLast = pRTTI;
73cdf0e10cSrcweir
74cdf0e10cSrcweir while( 1 )
75cdf0e10cSrcweir {
76cdf0e10cSrcweir if( *pRTTI == ':' || ! *pRTTI )
77cdf0e10cSrcweir {
78*0848378bSHerbert Dürr if( !aRet.isEmpty() )
79cdf0e10cSrcweir aRet += ".";
80cdf0e10cSrcweir aRet += rRTTIname.copy( pLast - pOrg, pRTTI - pLast );
81cdf0e10cSrcweir while( *pRTTI == ':' )
82cdf0e10cSrcweir pRTTI++;
83cdf0e10cSrcweir pLast = pRTTI;
84cdf0e10cSrcweir if( ! *pRTTI )
85cdf0e10cSrcweir break;
86cdf0e10cSrcweir }
87cdf0e10cSrcweir else
88cdf0e10cSrcweir pRTTI++;
89cdf0e10cSrcweir }
90cdf0e10cSrcweir
91cdf0e10cSrcweir return aRet;
92cdf0e10cSrcweir }
93cdf0e10cSrcweir //==================================================================================================
toRTTIname(const OString & rUNOname)94cdf0e10cSrcweir static OString toRTTIname( const OString & rUNOname )
95cdf0e10cSrcweir {
96cdf0e10cSrcweir OStringBuffer aRet( rUNOname.getLength()*2 );
97cdf0e10cSrcweir
98cdf0e10cSrcweir sal_Int32 nIndex = 0;
99cdf0e10cSrcweir do
100cdf0e10cSrcweir {
101cdf0e10cSrcweir if( nIndex > 0 )
102cdf0e10cSrcweir aRet.append( "::" );
103cdf0e10cSrcweir aRet.append( rUNOname.getToken( 0, '.', nIndex ) );
104cdf0e10cSrcweir } while( nIndex != -1 );
105cdf0e10cSrcweir
106cdf0e10cSrcweir return aRet.makeStringAndClear();
107cdf0e10cSrcweir }
108cdf0e10cSrcweir //==================================================================================================
109cdf0e10cSrcweir
toRTTImangledname(const OString & rRTTIname)110cdf0e10cSrcweir static OString toRTTImangledname( const OString & rRTTIname )
111cdf0e10cSrcweir {
112*0848378bSHerbert Dürr if( rRTTIname.isEmpty() )
113cdf0e10cSrcweir return OString();
114cdf0e10cSrcweir
115cdf0e10cSrcweir OStringBuffer aRet( rRTTIname.getLength()*2 );
116cdf0e10cSrcweir
117cdf0e10cSrcweir aRet.append( "__1n" );
118cdf0e10cSrcweir sal_Int32 nIndex = 0;
119cdf0e10cSrcweir do
120cdf0e10cSrcweir {
121cdf0e10cSrcweir OString aToken( rRTTIname.getToken( 0, ':', nIndex ) );
122cdf0e10cSrcweir int nBytes = aToken.getLength();
123cdf0e10cSrcweir if( nBytes )
124cdf0e10cSrcweir {
125cdf0e10cSrcweir if( nBytes > 25 )
126cdf0e10cSrcweir {
127cdf0e10cSrcweir aRet.append( (sal_Char)( nBytes/26 + 'a' ) );
128cdf0e10cSrcweir aRet.append( (sal_Char)( nBytes%26 + 'A' ) );
129cdf0e10cSrcweir }
130cdf0e10cSrcweir else
131cdf0e10cSrcweir aRet.append( (sal_Char)( nBytes + 'A' ) );
132cdf0e10cSrcweir for (sal_Int32 i = 0; i < aToken.getLength(); ++i) {
133cdf0e10cSrcweir char c = aToken[i];
134cdf0e10cSrcweir if (c == 'Q') {
135cdf0e10cSrcweir aRet.append("QdD");
136cdf0e10cSrcweir } else {
137cdf0e10cSrcweir aRet.append(c);
138cdf0e10cSrcweir }
139cdf0e10cSrcweir }
140cdf0e10cSrcweir }
141cdf0e10cSrcweir } while( nIndex != -1 );
142cdf0e10cSrcweir
143cdf0e10cSrcweir aRet.append( '_' );
144cdf0e10cSrcweir
145cdf0e10cSrcweir return aRet.makeStringAndClear();
146cdf0e10cSrcweir }
147cdf0e10cSrcweir
148cdf0e10cSrcweir //##################################################################################################
149cdf0e10cSrcweir //#### RTTI simulation #############################################################################
150cdf0e10cSrcweir //##################################################################################################
151cdf0e10cSrcweir
152cdf0e10cSrcweir class RTTIHolder
153cdf0e10cSrcweir {
154cdf0e10cSrcweir std::map< OString, void* > aAllRTTI;
155cdf0e10cSrcweir public:
156cdf0e10cSrcweir ~RTTIHolder();
157cdf0e10cSrcweir
158cdf0e10cSrcweir void* getRTTI( const OString& rTypename );
getRTTI_UnoName(const OString & rUnoTypename)159cdf0e10cSrcweir void* getRTTI_UnoName( const OString& rUnoTypename )
160cdf0e10cSrcweir { return getRTTI( toRTTIname( rUnoTypename ) ); }
161cdf0e10cSrcweir
162cdf0e10cSrcweir void* insertRTTI( const OString& rTypename );
insertRTTI_UnoName(const OString & rTypename)163cdf0e10cSrcweir void* insertRTTI_UnoName( const OString& rTypename )
164cdf0e10cSrcweir { return insertRTTI( toRTTIname( rTypename ) ); }
165cdf0e10cSrcweir void* generateRTTI( typelib_CompoundTypeDescription* pCompTypeDescr );
166cdf0e10cSrcweir };
167cdf0e10cSrcweir
~RTTIHolder()168cdf0e10cSrcweir RTTIHolder::~RTTIHolder()
169cdf0e10cSrcweir {
170cdf0e10cSrcweir for ( std::map< OString, void* >::const_iterator iPos( aAllRTTI.begin() );
171cdf0e10cSrcweir iPos != aAllRTTI.end(); ++iPos )
172cdf0e10cSrcweir {
173cdf0e10cSrcweir delete[] static_cast< char * >(iPos->second);
174cdf0e10cSrcweir }
175cdf0e10cSrcweir }
176cdf0e10cSrcweir
177cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
178cdf0e10cSrcweir #include <stdio.h>
179cdf0e10cSrcweir #endif
180cdf0e10cSrcweir
getRTTI(const OString & rTypename)181cdf0e10cSrcweir void* RTTIHolder::getRTTI( const OString& rTypename )
182cdf0e10cSrcweir {
183cdf0e10cSrcweir std::map< OString, void* >::iterator element;
184cdf0e10cSrcweir
185cdf0e10cSrcweir element = aAllRTTI.find( rTypename );
186cdf0e10cSrcweir if( element != aAllRTTI.end() )
187cdf0e10cSrcweir return (*element).second;
188cdf0e10cSrcweir
189cdf0e10cSrcweir // create rtti structure
190cdf0e10cSrcweir element = aAllRTTI.find( rTypename );
191cdf0e10cSrcweir if( element != aAllRTTI.end() )
192cdf0e10cSrcweir return (*element).second;
193cdf0e10cSrcweir
194cdf0e10cSrcweir return NULL;
195cdf0e10cSrcweir }
196cdf0e10cSrcweir
197cdf0e10cSrcweir static long nMagicId = 1;
198cdf0e10cSrcweir
insertRTTI(const OString & rTypename)199cdf0e10cSrcweir void* RTTIHolder::insertRTTI( const OString& rTypename )
200cdf0e10cSrcweir {
201cdf0e10cSrcweir OString aMangledName( toRTTImangledname( rTypename ) );
202cdf0e10cSrcweir NIST_Hash aHash( aMangledName.getStr(), aMangledName.getLength() );
203cdf0e10cSrcweir
204cdf0e10cSrcweir
205cdf0e10cSrcweir // rSuperTypename MUST exist !!!
206cdf0e10cSrcweir std::size_t const RTTI_SIZE = 19; // 14???
207cdf0e10cSrcweir void** pRTTI = reinterpret_cast< void ** >(
208cdf0e10cSrcweir new char[RTTI_SIZE * sizeof (void *) + strlen(rTypename.getStr()) + 1]);
209cdf0e10cSrcweir pRTTI[ 0 ] = reinterpret_cast< void * >(RTTI_SIZE * sizeof (void *));
210cdf0e10cSrcweir pRTTI[ 1 ] = NULL;
211cdf0e10cSrcweir pRTTI[ 2 ] = (void*)(7*sizeof(void*));
212cdf0e10cSrcweir pRTTI[ 3 ] = (void*)aHash.getHash()[0];
213cdf0e10cSrcweir pRTTI[ 4 ] = (void*)aHash.getHash()[1];
214cdf0e10cSrcweir pRTTI[ 5 ] = (void*)aHash.getHash()[2];
215cdf0e10cSrcweir pRTTI[ 6 ] = (void*)aHash.getHash()[3];
216cdf0e10cSrcweir pRTTI[ 7 ] = NULL;
217cdf0e10cSrcweir pRTTI[ 8 ] = NULL;
218cdf0e10cSrcweir
219cdf0e10cSrcweir pRTTI[ 9 ] = pRTTI[ 3 ];
220cdf0e10cSrcweir pRTTI[ 10 ] = pRTTI[ 4 ];
221cdf0e10cSrcweir pRTTI[ 11 ] = pRTTI[ 5 ];
222cdf0e10cSrcweir pRTTI[ 12 ] = pRTTI[ 6 ];
223cdf0e10cSrcweir pRTTI[ 13 ] = (void*)0x80000000;
224cdf0e10cSrcweir strcpy(reinterpret_cast< char * >(pRTTI + RTTI_SIZE), rTypename.getStr());
225cdf0e10cSrcweir
226cdf0e10cSrcweir aAllRTTI[ rTypename ] = (void*)pRTTI;
227cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
228cdf0e10cSrcweir fprintf( stderr,
229cdf0e10cSrcweir "generating base RTTI for type %s:\n"
230cdf0e10cSrcweir " mangled: %s\n"
231cdf0e10cSrcweir " hash: %.8x %.8x %.8x %.8x\n",
232cdf0e10cSrcweir rTypename.getStr(),
233cdf0e10cSrcweir aMangledName.getStr(),
234cdf0e10cSrcweir pRTTI[ 3 ], pRTTI[ 4 ], pRTTI[ 5 ], pRTTI[ 6 ]
235cdf0e10cSrcweir );
236cdf0e10cSrcweir #endif
237cdf0e10cSrcweir return pRTTI;
238cdf0e10cSrcweir }
239cdf0e10cSrcweir
generateRTTI(typelib_CompoundTypeDescription * pCompTypeDescr)240cdf0e10cSrcweir void* RTTIHolder::generateRTTI( typelib_CompoundTypeDescription * pCompTypeDescr )
241cdf0e10cSrcweir {
242cdf0e10cSrcweir OString aUNOCompTypeName( OUStringToOString( pCompTypeDescr->aBase.pTypeName, RTL_TEXTENCODING_ASCII_US ) );
243cdf0e10cSrcweir OString aRTTICompTypeName( toRTTIname( aUNOCompTypeName ) );
244cdf0e10cSrcweir
245cdf0e10cSrcweir void* pHaveRTTI = getRTTI( aRTTICompTypeName );
246cdf0e10cSrcweir if( pHaveRTTI )
247cdf0e10cSrcweir return pHaveRTTI;
248cdf0e10cSrcweir
249cdf0e10cSrcweir if( ! pCompTypeDescr->pBaseTypeDescription )
250cdf0e10cSrcweir // this is a base type
251cdf0e10cSrcweir return insertRTTI( aRTTICompTypeName );
252cdf0e10cSrcweir
253cdf0e10cSrcweir // get base class RTTI
254cdf0e10cSrcweir void* pSuperRTTI = generateRTTI( pCompTypeDescr->pBaseTypeDescription );
255cdf0e10cSrcweir OSL_ENSURE( pSuperRTTI, "could not generate RTTI for supertype !" );
256cdf0e10cSrcweir
257cdf0e10cSrcweir // find out the size to allocate for RTTI
258cdf0e10cSrcweir void** pInherit = (void**)((sal_uInt32)pSuperRTTI + ((sal_uInt32*)pSuperRTTI)[2] + 8);
259cdf0e10cSrcweir int nInherit;
260cdf0e10cSrcweir for( nInherit = 1; pInherit[ nInherit*5-1 ] != (void*)0x80000000; nInherit++ )
261cdf0e10cSrcweir ;
262cdf0e10cSrcweir
263cdf0e10cSrcweir OString aMangledName( toRTTImangledname( aRTTICompTypeName ) );
264cdf0e10cSrcweir NIST_Hash aHash( aMangledName.getStr(), aMangledName.getLength() );
265cdf0e10cSrcweir
266cdf0e10cSrcweir std::size_t const rttiSize = 14 + nInherit * 5;
267cdf0e10cSrcweir void** pRTTI = reinterpret_cast< void ** >(
268cdf0e10cSrcweir new char[
269cdf0e10cSrcweir rttiSize * sizeof (void *)
270cdf0e10cSrcweir + strlen(aRTTICompTypeName.getStr()) + 1]);
271cdf0e10cSrcweir pRTTI[ 0 ] = reinterpret_cast< void * >(rttiSize * sizeof (void *));
272cdf0e10cSrcweir pRTTI[ 1 ] = NULL;
273cdf0e10cSrcweir pRTTI[ 2 ] = (void*)(7*sizeof(void*));
274cdf0e10cSrcweir pRTTI[ 3 ] = (void*)aHash.getHash()[0];
275cdf0e10cSrcweir pRTTI[ 4 ] = (void*)aHash.getHash()[1];
276cdf0e10cSrcweir pRTTI[ 5 ] = (void*)aHash.getHash()[2];
277cdf0e10cSrcweir pRTTI[ 6 ] = (void*)aHash.getHash()[3];
278cdf0e10cSrcweir pRTTI[ 7 ] = NULL;
279cdf0e10cSrcweir pRTTI[ 8 ] = NULL;
280cdf0e10cSrcweir
281cdf0e10cSrcweir memcpy( pRTTI+9, pInherit, 4*nInherit*5 );
282cdf0e10cSrcweir pRTTI[ 8 +nInherit*5 ] = NULL;
283cdf0e10cSrcweir pRTTI[ 9 +nInherit*5 ] = pRTTI[ 3 ];
284cdf0e10cSrcweir pRTTI[ 10+nInherit*5 ] = pRTTI[ 4 ];
285cdf0e10cSrcweir pRTTI[ 11+nInherit*5 ] = pRTTI[ 5 ];
286cdf0e10cSrcweir pRTTI[ 12+nInherit*5 ] = pRTTI[ 6 ];
287cdf0e10cSrcweir pRTTI[ 13+nInherit*5 ] = (void*)0x80000000;
288cdf0e10cSrcweir strcpy(
289cdf0e10cSrcweir reinterpret_cast< char * >(pRTTI + rttiSize),
290cdf0e10cSrcweir aRTTICompTypeName.getStr());
291cdf0e10cSrcweir
292cdf0e10cSrcweir aAllRTTI[ aRTTICompTypeName ] = (void*)pRTTI;
293cdf0e10cSrcweir
294cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
295cdf0e10cSrcweir fprintf( stderr,
296cdf0e10cSrcweir "generating struct RTTI for type %s:\n"
297cdf0e10cSrcweir " mangled: %s\n"
298cdf0e10cSrcweir " hash: %.8x %.8x %.8X %.8x\n",
299cdf0e10cSrcweir aRTTICompTypeName.getStr(),
300cdf0e10cSrcweir aMangledName.getStr(),
301cdf0e10cSrcweir pRTTI[ 3 ], pRTTI[ 4 ], pRTTI[ 5 ], pRTTI[ 6 ]
302cdf0e10cSrcweir );
303cdf0e10cSrcweir #endif
304cdf0e10cSrcweir
305cdf0e10cSrcweir return pRTTI;
306cdf0e10cSrcweir }
307cdf0e10cSrcweir
308cdf0e10cSrcweir //__________________________________________________________________________________________________
309cdf0e10cSrcweir
deleteException(void * pExc,unsigned char * thunk,typelib_TypeDescription * pType)310cdf0e10cSrcweir static void deleteException(
311cdf0e10cSrcweir void* pExc, unsigned char* thunk, typelib_TypeDescription* pType )
312cdf0e10cSrcweir {
313cdf0e10cSrcweir uno_destructData(
314cdf0e10cSrcweir pExc, pType, reinterpret_cast< uno_ReleaseFunc >(cpp_release) );
315cdf0e10cSrcweir typelib_typedescription_release( pType );
316cdf0e10cSrcweir delete[] thunk;
317cdf0e10cSrcweir }
318cdf0e10cSrcweir
319cdf0e10cSrcweir //__________________________________________________________________________________________________
320cdf0e10cSrcweir
321cdf0e10cSrcweir //##################################################################################################
322cdf0e10cSrcweir //#### exported ####################################################################################
323cdf0e10cSrcweir //##################################################################################################
324cdf0e10cSrcweir
cc50_solaris_intel_raiseException(uno_Any * pUnoExc,uno_Mapping * pUno2Cpp)325cdf0e10cSrcweir void cc50_solaris_intel_raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp )
326cdf0e10cSrcweir {
327cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
328cdf0e10cSrcweir OString cstr(
329cdf0e10cSrcweir OUStringToOString(
330cdf0e10cSrcweir *reinterpret_cast< OUString const * >( &pUnoExc->pType->pTypeName ),
331cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ) );
332cdf0e10cSrcweir fprintf( stderr, "> uno exception occured: %s\n", cstr.getStr() );
333cdf0e10cSrcweir #endif
334cdf0e10cSrcweir bridges::cpp_uno::shared::ArrayPointer< unsigned char > thunkPtr(
335cdf0e10cSrcweir new unsigned char[24]);
336cdf0e10cSrcweir typelib_TypeDescription * pTypeDescr = 0;
337cdf0e10cSrcweir // will be released by deleteException
338cdf0e10cSrcweir typelib_typedescriptionreference_getDescription( &pTypeDescr, pUnoExc->pType );
339cdf0e10cSrcweir
340cdf0e10cSrcweir void* pRTTI;
341cdf0e10cSrcweir {
342cdf0e10cSrcweir static ::osl::Mutex aMutex;
343cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > guard( aMutex );
344cdf0e10cSrcweir
345cdf0e10cSrcweir static RTTIHolder * s_pRTTI = 0;
346cdf0e10cSrcweir if (! s_pRTTI)
347cdf0e10cSrcweir {
348cdf0e10cSrcweir #ifdef LEAK_STATIC_DATA
349cdf0e10cSrcweir s_pRTTI = new RTTIHolder();
350cdf0e10cSrcweir #else
351cdf0e10cSrcweir static RTTIHolder s_aRTTI;
352cdf0e10cSrcweir s_pRTTI = &s_aRTTI;
353cdf0e10cSrcweir #endif
354cdf0e10cSrcweir }
355cdf0e10cSrcweir
356cdf0e10cSrcweir pRTTI = s_pRTTI->generateRTTI( (typelib_CompoundTypeDescription *)pTypeDescr );
357cdf0e10cSrcweir }
358cdf0e10cSrcweir
359cdf0e10cSrcweir // a must be
360cdf0e10cSrcweir OSL_ENSURE( sizeof(sal_Int32) == sizeof(void *), "### pointer size differs from sal_Int32!" );
361cdf0e10cSrcweir
362cdf0e10cSrcweir void * pCppExc = __Crun::ex_alloc( pTypeDescr->nSize );
363cdf0e10cSrcweir uno_copyAndConvertData( pCppExc, pUnoExc->pData, pTypeDescr, pUno2Cpp );
364cdf0e10cSrcweir
365cdf0e10cSrcweir // destruct uno exception
366cdf0e10cSrcweir uno_any_destruct( pUnoExc, 0 );
367cdf0e10cSrcweir
368cdf0e10cSrcweir unsigned char * thunk = thunkPtr.release();
369cdf0e10cSrcweir // movl %esp, %ecx:
370cdf0e10cSrcweir thunk[0] = 0x8B;
371cdf0e10cSrcweir thunk[1] = 0xCC;
372cdf0e10cSrcweir // pushl pTypeDescr:
373cdf0e10cSrcweir thunk[2] = 0x68;
374cdf0e10cSrcweir *reinterpret_cast< void ** >(thunk + 3) = pTypeDescr;
375cdf0e10cSrcweir // pushl thunk:
376cdf0e10cSrcweir thunk[7] = 0x68;
377cdf0e10cSrcweir *reinterpret_cast< void ** >(thunk + 8) = thunk;
378cdf0e10cSrcweir // pushl 4(%ecx):
379cdf0e10cSrcweir thunk[12] = 0xFF;
380cdf0e10cSrcweir thunk[13] = 0x71;
381cdf0e10cSrcweir thunk[14] = 0x04;
382cdf0e10cSrcweir // call deleteException:
383cdf0e10cSrcweir thunk[15] = 0xE8;
384cdf0e10cSrcweir #pragma disable_warn
385cdf0e10cSrcweir void * d = reinterpret_cast< void * >(deleteException);
386cdf0e10cSrcweir #pragma enable_warn
387cdf0e10cSrcweir *reinterpret_cast< std::ptrdiff_t * >(thunk + 16) =
388cdf0e10cSrcweir static_cast< unsigned char * >(d) - (thunk + 20);
389cdf0e10cSrcweir // addl $12, %esp:
390cdf0e10cSrcweir thunk[20] = 0x83;
391cdf0e10cSrcweir thunk[21] = 0xC4;
392cdf0e10cSrcweir thunk[22] = 0x0C;
393cdf0e10cSrcweir // ret:
394cdf0e10cSrcweir thunk[23] = 0xC3;
395cdf0e10cSrcweir
396cdf0e10cSrcweir #pragma disable_warn
397cdf0e10cSrcweir void (* f)(void *) = reinterpret_cast< void (*)(void *) >(thunk);
398cdf0e10cSrcweir #pragma enable_warn
399cdf0e10cSrcweir __Crun::ex_throw(pCppExc, (const __Crun::static_type_info*)pRTTI, f);
400cdf0e10cSrcweir }
401cdf0e10cSrcweir
cc50_solaris_intel_fillUnoException(void * pCppExc,const char * pInfo,uno_Any * pUnoExc,uno_Mapping * pCpp2Uno)402cdf0e10cSrcweir void cc50_solaris_intel_fillUnoException(
403cdf0e10cSrcweir void* pCppExc,
404cdf0e10cSrcweir const char* pInfo,
405cdf0e10cSrcweir uno_Any* pUnoExc,
406cdf0e10cSrcweir uno_Mapping * pCpp2Uno )
407cdf0e10cSrcweir {
408cdf0e10cSrcweir OSL_ASSERT( pInfo != 0 );
409cdf0e10cSrcweir OString uno_name( toUNOname( pInfo ) );
410cdf0e10cSrcweir OUString aName( OStringToOUString(
411cdf0e10cSrcweir uno_name, RTL_TEXTENCODING_ASCII_US ) );
412cdf0e10cSrcweir typelib_TypeDescription * pExcTypeDescr = 0;
413cdf0e10cSrcweir typelib_typedescription_getByName( &pExcTypeDescr, aName.pData );
414cdf0e10cSrcweir
415cdf0e10cSrcweir if (pExcTypeDescr == 0) // the thing that should not be
416cdf0e10cSrcweir {
417cdf0e10cSrcweir RuntimeException aRE(
418cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM(
419cdf0e10cSrcweir "exception type not found: ") ) + aName,
420cdf0e10cSrcweir Reference< XInterface >() );
421cdf0e10cSrcweir Type const & rType = ::getCppuType( &aRE );
422cdf0e10cSrcweir uno_type_any_constructAndConvert(
423cdf0e10cSrcweir pUnoExc, &aRE, rType.getTypeLibType(), pCpp2Uno );
424cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
425cdf0e10cSrcweir OString cstr( OUStringToOString(
426cdf0e10cSrcweir aRE.Message, RTL_TEXTENCODING_ASCII_US ) );
427cdf0e10cSrcweir OSL_ENSURE( 0, cstr.getStr() );
428cdf0e10cSrcweir #endif
429cdf0e10cSrcweir return;
430cdf0e10cSrcweir }
431cdf0e10cSrcweir
432cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
433cdf0e10cSrcweir fprintf( stderr, "> c++ exception occured: %s\n",
434cdf0e10cSrcweir ::rtl::OUStringToOString(
435cdf0e10cSrcweir pExcTypeDescr->pTypeName,
436cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ).getStr() );
437cdf0e10cSrcweir #endif
438cdf0e10cSrcweir // construct uno exception any
439cdf0e10cSrcweir uno_any_constructAndConvert(
440cdf0e10cSrcweir pUnoExc, pCppExc, pExcTypeDescr, pCpp2Uno );
441cdf0e10cSrcweir typelib_typedescription_release( pExcTypeDescr );
442cdf0e10cSrcweir }
443cdf0e10cSrcweir
444cdf0e10cSrcweir }
445cdf0e10cSrcweir
446