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 #include <typelib/typedescription.hxx>
36cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
37cdf0e10cSrcweir #include "com/sun/star/uno/RuntimeException.hpp"
38cdf0e10cSrcweir
39cdf0e10cSrcweir #include "cc50_solaris_sparc.hxx"
40cdf0e10cSrcweir #include "flushcode.hxx"
41cdf0e10cSrcweir #include <rtl/strbuf.hxx>
42cdf0e10cSrcweir
43cdf0e10cSrcweir #include "bridges/cpp_uno/shared/arraypointer.hxx"
44cdf0e10cSrcweir
45cdf0e10cSrcweir #include <hash.cxx>
46cdf0e10cSrcweir
47cdf0e10cSrcweir // need a += operator for OString and sal_Char
48cdf0e10cSrcweir namespace rtl
49cdf0e10cSrcweir {
operator +=(OString & rString,sal_Char cAdd)50cdf0e10cSrcweir inline OString& operator+=( OString& rString, sal_Char cAdd )
51cdf0e10cSrcweir {
52cdf0e10cSrcweir sal_Char add[2];
53cdf0e10cSrcweir add[0] = cAdd;
54cdf0e10cSrcweir add[1] = 0;
55cdf0e10cSrcweir return rString += add;
56cdf0e10cSrcweir }
57cdf0e10cSrcweir }
58cdf0e10cSrcweir
59cdf0e10cSrcweir using namespace std;
60cdf0e10cSrcweir using namespace osl;
61cdf0e10cSrcweir using namespace rtl;
62cdf0e10cSrcweir using namespace com::sun::star::uno;
63cdf0e10cSrcweir
64cdf0e10cSrcweir namespace CPPU_CURRENT_NAMESPACE
65cdf0e10cSrcweir {
66cdf0e10cSrcweir
67cdf0e10cSrcweir //==================================================================================================
toUNOname(const OString & rRTTIname)68cdf0e10cSrcweir static OString toUNOname( const OString & rRTTIname )
69cdf0e10cSrcweir {
70cdf0e10cSrcweir OString aRet;
71cdf0e10cSrcweir
72cdf0e10cSrcweir const sal_Char* pRTTI = rRTTIname.getStr();
73cdf0e10cSrcweir const sal_Char* pOrg = pRTTI;
74cdf0e10cSrcweir const sal_Char* pLast = pRTTI;
75cdf0e10cSrcweir
76cdf0e10cSrcweir while( 1 )
77cdf0e10cSrcweir {
78cdf0e10cSrcweir if( *pRTTI == ':' || ! *pRTTI )
79cdf0e10cSrcweir {
80*0848378bSHerbert Dürr if( !aRet.isEmpty() )
81cdf0e10cSrcweir aRet += ".";
82cdf0e10cSrcweir aRet += rRTTIname.copy( pLast - pOrg, pRTTI - pLast );
83cdf0e10cSrcweir while( *pRTTI == ':' )
84cdf0e10cSrcweir pRTTI++;
85cdf0e10cSrcweir pLast = pRTTI;
86cdf0e10cSrcweir if( ! *pRTTI )
87cdf0e10cSrcweir break;
88cdf0e10cSrcweir }
89cdf0e10cSrcweir else
90cdf0e10cSrcweir pRTTI++;
91cdf0e10cSrcweir }
92cdf0e10cSrcweir
93cdf0e10cSrcweir return aRet;
94cdf0e10cSrcweir }
95cdf0e10cSrcweir //==================================================================================================
toRTTIname(const OString & rUNOname)96cdf0e10cSrcweir static OString toRTTIname( const OString & rUNOname )
97cdf0e10cSrcweir {
98cdf0e10cSrcweir OStringBuffer aRet( rUNOname.getLength()*2 );
99cdf0e10cSrcweir
100cdf0e10cSrcweir sal_Int32 nIndex = 0;
101cdf0e10cSrcweir do
102cdf0e10cSrcweir {
103cdf0e10cSrcweir if( nIndex > 0 )
104cdf0e10cSrcweir aRet.append( "::" );
105cdf0e10cSrcweir aRet.append( rUNOname.getToken( 0, '.', nIndex ) );
106cdf0e10cSrcweir } while( nIndex != -1 );
107cdf0e10cSrcweir
108cdf0e10cSrcweir return aRet.makeStringAndClear();
109cdf0e10cSrcweir }
110cdf0e10cSrcweir //==================================================================================================
111cdf0e10cSrcweir
toRTTImangledname(const OString & rRTTIname)112cdf0e10cSrcweir static OString toRTTImangledname( const OString & rRTTIname )
113cdf0e10cSrcweir {
114*0848378bSHerbert Dürr if( rRTTIname.isEmpty() )
115cdf0e10cSrcweir return OString();
116cdf0e10cSrcweir
117cdf0e10cSrcweir OStringBuffer aRet( rRTTIname.getLength()*2 );
118cdf0e10cSrcweir
119cdf0e10cSrcweir aRet.append( "__1n" );
120cdf0e10cSrcweir sal_Int32 nIndex = 0;
121cdf0e10cSrcweir do
122cdf0e10cSrcweir {
123cdf0e10cSrcweir OString aToken( rRTTIname.getToken( 0, ':', nIndex ) );
124cdf0e10cSrcweir int nBytes = aToken.getLength();
125cdf0e10cSrcweir if( nBytes )
126cdf0e10cSrcweir {
127cdf0e10cSrcweir if( nBytes > 25 )
128cdf0e10cSrcweir {
129cdf0e10cSrcweir aRet.append( (sal_Char)( nBytes/26 + 'a' ) );
130cdf0e10cSrcweir aRet.append( (sal_Char)( nBytes%26 + 'A' ) );
131cdf0e10cSrcweir }
132cdf0e10cSrcweir else
133cdf0e10cSrcweir aRet.append( (sal_Char)( nBytes + 'A' ) );
134cdf0e10cSrcweir for (sal_Int32 i = 0; i < aToken.getLength(); ++i) {
135cdf0e10cSrcweir char c = aToken[i];
136cdf0e10cSrcweir if (c == 'Q') {
137cdf0e10cSrcweir aRet.append("QdD");
138cdf0e10cSrcweir } else {
139cdf0e10cSrcweir aRet.append(c);
140cdf0e10cSrcweir }
141cdf0e10cSrcweir }
142cdf0e10cSrcweir }
143cdf0e10cSrcweir } while( nIndex != -1 );
144cdf0e10cSrcweir
145cdf0e10cSrcweir aRet.append( '_' );
146cdf0e10cSrcweir
147cdf0e10cSrcweir return aRet.makeStringAndClear();
148cdf0e10cSrcweir }
149cdf0e10cSrcweir
150cdf0e10cSrcweir
151cdf0e10cSrcweir //##################################################################################################
152cdf0e10cSrcweir //#### RTTI simulation #############################################################################
153cdf0e10cSrcweir //##################################################################################################
154cdf0e10cSrcweir
155cdf0e10cSrcweir class RTTIHolder
156cdf0e10cSrcweir {
157cdf0e10cSrcweir std::map< OString, void* > aAllRTTI;
158cdf0e10cSrcweir public:
159cdf0e10cSrcweir ~RTTIHolder();
160cdf0e10cSrcweir
161cdf0e10cSrcweir void* getRTTI( const OString& rTypename );
getRTTI_UnoName(const OString & rUnoTypename)162cdf0e10cSrcweir void* getRTTI_UnoName( const OString& rUnoTypename )
163cdf0e10cSrcweir { return getRTTI( toRTTIname( rUnoTypename ) ); }
164cdf0e10cSrcweir
165cdf0e10cSrcweir void* insertRTTI( const OString& rTypename );
insertRTTI_UnoName(const OString & rTypename)166cdf0e10cSrcweir void* insertRTTI_UnoName( const OString& rTypename )
167cdf0e10cSrcweir { return insertRTTI( toRTTIname( rTypename ) ); }
168cdf0e10cSrcweir void* generateRTTI( typelib_CompoundTypeDescription* pCompTypeDescr );
169cdf0e10cSrcweir };
170cdf0e10cSrcweir
~RTTIHolder()171cdf0e10cSrcweir RTTIHolder::~RTTIHolder()
172cdf0e10cSrcweir {
173cdf0e10cSrcweir for ( std::map< OString, void* >::const_iterator iPos( aAllRTTI.begin() );
174cdf0e10cSrcweir iPos != aAllRTTI.end(); ++iPos )
175cdf0e10cSrcweir {
176cdf0e10cSrcweir delete[] static_cast< char * >(iPos->second);
177cdf0e10cSrcweir }
178cdf0e10cSrcweir }
179cdf0e10cSrcweir
180cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
181cdf0e10cSrcweir #include <stdio.h>
182cdf0e10cSrcweir #endif
183cdf0e10cSrcweir
getRTTI(const OString & rTypename)184cdf0e10cSrcweir void* RTTIHolder::getRTTI( const OString& rTypename )
185cdf0e10cSrcweir {
186cdf0e10cSrcweir std::map< OString, void* >::iterator element;
187cdf0e10cSrcweir
188cdf0e10cSrcweir element = aAllRTTI.find( rTypename );
189cdf0e10cSrcweir if( element != aAllRTTI.end() )
190cdf0e10cSrcweir return (*element).second;
191cdf0e10cSrcweir
192cdf0e10cSrcweir // create rtti structure
193cdf0e10cSrcweir element = aAllRTTI.find( rTypename );
194cdf0e10cSrcweir if( element != aAllRTTI.end() )
195cdf0e10cSrcweir return (*element).second;
196cdf0e10cSrcweir
197cdf0e10cSrcweir return NULL;
198cdf0e10cSrcweir }
199cdf0e10cSrcweir
insertRTTI(const OString & rTypename)200cdf0e10cSrcweir void* RTTIHolder::insertRTTI( const OString& rTypename )
201cdf0e10cSrcweir {
202cdf0e10cSrcweir OString aMangledName( toRTTImangledname( rTypename ) );
203cdf0e10cSrcweir NIST_Hash aHash( aMangledName.getStr(), aMangledName.getLength() );
204cdf0e10cSrcweir
205cdf0e10cSrcweir std::size_t const RTTI_SIZE = 19; // 14???
206cdf0e10cSrcweir void** pRTTI = reinterpret_cast< void ** >(
207cdf0e10cSrcweir new char[RTTI_SIZE * sizeof (void *) + strlen(rTypename.getStr()) + 1]);
208cdf0e10cSrcweir pRTTI[ 0 ] = reinterpret_cast< void * >(RTTI_SIZE * sizeof (void *));
209cdf0e10cSrcweir pRTTI[ 1 ] = NULL;
210cdf0e10cSrcweir pRTTI[ 2 ] = (void*)(7*sizeof(void*));
211cdf0e10cSrcweir pRTTI[ 3 ] = (void*)aHash.getHash()[0];
212cdf0e10cSrcweir pRTTI[ 4 ] = (void*)aHash.getHash()[1];
213cdf0e10cSrcweir pRTTI[ 5 ] = (void*)aHash.getHash()[2];
214cdf0e10cSrcweir pRTTI[ 6 ] = (void*)aHash.getHash()[3];
215cdf0e10cSrcweir pRTTI[ 7 ] = NULL;
216cdf0e10cSrcweir pRTTI[ 8 ] = NULL;
217cdf0e10cSrcweir
218cdf0e10cSrcweir pRTTI[ 9 ] = pRTTI[ 3 ];
219cdf0e10cSrcweir pRTTI[ 10 ] = pRTTI[ 4 ];
220cdf0e10cSrcweir pRTTI[ 11 ] = pRTTI[ 5 ];
221cdf0e10cSrcweir pRTTI[ 12 ] = pRTTI[ 6 ];
222cdf0e10cSrcweir pRTTI[ 13 ] = (void*)0x80000000;
223cdf0e10cSrcweir strcpy(reinterpret_cast< char * >(pRTTI + RTTI_SIZE), rTypename.getStr());
224cdf0e10cSrcweir
225cdf0e10cSrcweir aAllRTTI[ rTypename ] = (void*)pRTTI;
226cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
227cdf0e10cSrcweir fprintf( stderr,
228cdf0e10cSrcweir "generating base RTTI for type %s:\n"
229cdf0e10cSrcweir " mangled: %s\n"
230cdf0e10cSrcweir " hash: %.8x %.8x %.8x %.8x\n",
231cdf0e10cSrcweir rTypename.getStr(),
232cdf0e10cSrcweir aMangledName.getStr(),
233cdf0e10cSrcweir pRTTI[ 3 ], pRTTI[ 4 ], pRTTI[ 5 ], pRTTI[ 6 ]
234cdf0e10cSrcweir );
235cdf0e10cSrcweir #endif
236cdf0e10cSrcweir return pRTTI;
237cdf0e10cSrcweir }
238cdf0e10cSrcweir
239cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------
240cdf0e10cSrcweir
generateRTTI(typelib_CompoundTypeDescription * pCompTypeDescr)241cdf0e10cSrcweir void* RTTIHolder::generateRTTI( typelib_CompoundTypeDescription * pCompTypeDescr )
242cdf0e10cSrcweir {
243cdf0e10cSrcweir OString aUNOCompTypeName( OUStringToOString( pCompTypeDescr->aBase.pTypeName, RTL_TEXTENCODING_ASCII_US ) );
244cdf0e10cSrcweir OString aRTTICompTypeName( toRTTIname( aUNOCompTypeName ) );
245cdf0e10cSrcweir
246cdf0e10cSrcweir void* pHaveRTTI = getRTTI( aRTTICompTypeName );
247cdf0e10cSrcweir if( pHaveRTTI )
248cdf0e10cSrcweir return pHaveRTTI;
249cdf0e10cSrcweir
250cdf0e10cSrcweir if( ! pCompTypeDescr->pBaseTypeDescription )
251cdf0e10cSrcweir // this is a base type
252cdf0e10cSrcweir return insertRTTI( aRTTICompTypeName );
253cdf0e10cSrcweir
254cdf0e10cSrcweir // get base class RTTI
255cdf0e10cSrcweir void* pSuperRTTI = generateRTTI( pCompTypeDescr->pBaseTypeDescription );
256cdf0e10cSrcweir OSL_ENSURE( pSuperRTTI, "could not generate RTTI for supertype !" );
257cdf0e10cSrcweir
258cdf0e10cSrcweir // find out the size to allocate for RTTI
259cdf0e10cSrcweir void** pInherit = (void**)((sal_uInt32)pSuperRTTI + ((sal_uInt32*)pSuperRTTI)[2] + 8);
260cdf0e10cSrcweir int nInherit;
261cdf0e10cSrcweir for( nInherit = 1; pInherit[ nInherit*5-1 ] != (void*)0x80000000; nInherit++ )
262cdf0e10cSrcweir ;
263cdf0e10cSrcweir
264cdf0e10cSrcweir OString aMangledName( toRTTImangledname( aRTTICompTypeName ) );
265cdf0e10cSrcweir NIST_Hash aHash( aMangledName.getStr(), aMangledName.getLength() );
266cdf0e10cSrcweir
267cdf0e10cSrcweir std::size_t const rttiSize = 14 + nInherit * 5;
268cdf0e10cSrcweir void** pRTTI = reinterpret_cast< void ** >(
269cdf0e10cSrcweir new char[
270cdf0e10cSrcweir rttiSize * sizeof (void *)
271cdf0e10cSrcweir + strlen(aRTTICompTypeName.getStr()) + 1]);
272cdf0e10cSrcweir pRTTI[ 0 ] = reinterpret_cast< void * >(rttiSize * sizeof (void *));
273cdf0e10cSrcweir pRTTI[ 1 ] = NULL;
274cdf0e10cSrcweir pRTTI[ 2 ] = (void*)(7*sizeof(void*));
275cdf0e10cSrcweir pRTTI[ 3 ] = (void*)aHash.getHash()[0];
276cdf0e10cSrcweir pRTTI[ 4 ] = (void*)aHash.getHash()[1];
277cdf0e10cSrcweir pRTTI[ 5 ] = (void*)aHash.getHash()[2];
278cdf0e10cSrcweir pRTTI[ 6 ] = (void*)aHash.getHash()[3];
279cdf0e10cSrcweir pRTTI[ 7 ] = NULL;
280cdf0e10cSrcweir pRTTI[ 8 ] = NULL;
281cdf0e10cSrcweir
282cdf0e10cSrcweir memcpy( pRTTI+9, pInherit, 4*nInherit*5 );
283cdf0e10cSrcweir pRTTI[ 8 +nInherit*5 ] = NULL;
284cdf0e10cSrcweir pRTTI[ 9 +nInherit*5 ] = pRTTI[ 3 ];
285cdf0e10cSrcweir pRTTI[ 10+nInherit*5 ] = pRTTI[ 4 ];
286cdf0e10cSrcweir pRTTI[ 11+nInherit*5 ] = pRTTI[ 5 ];
287cdf0e10cSrcweir pRTTI[ 12+nInherit*5 ] = pRTTI[ 6 ];
288cdf0e10cSrcweir pRTTI[ 13+nInherit*5 ] = (void*)0x80000000;
289cdf0e10cSrcweir strcpy(
290cdf0e10cSrcweir reinterpret_cast< char * >(pRTTI + rttiSize),
291cdf0e10cSrcweir aRTTICompTypeName.getStr());
292cdf0e10cSrcweir
293cdf0e10cSrcweir aAllRTTI[ aRTTICompTypeName ] = (void*)pRTTI;
294cdf0e10cSrcweir
295cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
296cdf0e10cSrcweir fprintf( stderr,
297cdf0e10cSrcweir "generating struct RTTI for type %s:\n"
298cdf0e10cSrcweir " mangled: %s\n"
299cdf0e10cSrcweir " hash: %.8x %.8x %.8X %.8x\n",
300cdf0e10cSrcweir aRTTICompTypeName.getStr(),
301cdf0e10cSrcweir aMangledName.getStr(),
302cdf0e10cSrcweir pRTTI[ 3 ], pRTTI[ 4 ], pRTTI[ 5 ], pRTTI[ 6 ]
303cdf0e10cSrcweir );
304cdf0e10cSrcweir #endif
305cdf0e10cSrcweir
306cdf0e10cSrcweir return pRTTI;
307cdf0e10cSrcweir }
308cdf0e10cSrcweir
309cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------
310cdf0e10cSrcweir
deleteException(void * pExc,unsigned int * thunk,typelib_TypeDescription * pType)311cdf0e10cSrcweir static void deleteException(
312cdf0e10cSrcweir void* pExc, unsigned int* thunk, typelib_TypeDescription* pType )
313cdf0e10cSrcweir {
314cdf0e10cSrcweir uno_destructData(
315cdf0e10cSrcweir pExc, pType, reinterpret_cast< uno_ReleaseFunc >(cpp_release) );
316cdf0e10cSrcweir typelib_typedescription_release( pType );
317cdf0e10cSrcweir delete[] thunk;
318cdf0e10cSrcweir }
319cdf0e10cSrcweir
320cdf0e10cSrcweir //__________________________________________________________________________________________________
321cdf0e10cSrcweir
322cdf0e10cSrcweir //##################################################################################################
323cdf0e10cSrcweir //#### exported ####################################################################################
324cdf0e10cSrcweir //##################################################################################################
325cdf0e10cSrcweir
cc50_solaris_sparc_raiseException(uno_Any * pUnoExc,uno_Mapping * pUno2Cpp)326cdf0e10cSrcweir void cc50_solaris_sparc_raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp )
327cdf0e10cSrcweir {
328cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
329cdf0e10cSrcweir OString cstr(
330cdf0e10cSrcweir OUStringToOString(
331cdf0e10cSrcweir *reinterpret_cast< OUString const * >( &pUnoExc->pType->pTypeName ),
332cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ) );
333cdf0e10cSrcweir fprintf( stderr, "> uno exception occured: %s\n", cstr.getStr() );
334cdf0e10cSrcweir #endif
335cdf0e10cSrcweir bridges::cpp_uno::shared::ArrayPointer< unsigned int > thunkPtr(
336cdf0e10cSrcweir new unsigned int[6]);
337cdf0e10cSrcweir
338cdf0e10cSrcweir typelib_TypeDescription * pTypeDescr = 0;
339cdf0e10cSrcweir // will be released by deleteException
340cdf0e10cSrcweir typelib_typedescriptionreference_getDescription( &pTypeDescr, pUnoExc->pType );
341cdf0e10cSrcweir
342cdf0e10cSrcweir void* pRTTI;
343cdf0e10cSrcweir {
344cdf0e10cSrcweir static ::osl::Mutex aMutex;
345cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > guard( aMutex );
346cdf0e10cSrcweir
347cdf0e10cSrcweir static RTTIHolder * s_pRTTI = 0;
348cdf0e10cSrcweir if (! s_pRTTI)
349cdf0e10cSrcweir {
350cdf0e10cSrcweir #ifdef LEAK_STATIC_DATA
351cdf0e10cSrcweir s_pRTTI = new RTTIHolder();
352cdf0e10cSrcweir #else
353cdf0e10cSrcweir static RTTIHolder s_aRTTI;
354cdf0e10cSrcweir s_pRTTI = &s_aRTTI;
355cdf0e10cSrcweir #endif
356cdf0e10cSrcweir }
357cdf0e10cSrcweir
358cdf0e10cSrcweir pRTTI = s_pRTTI->generateRTTI( (typelib_CompoundTypeDescription *)pTypeDescr );
359cdf0e10cSrcweir }
360cdf0e10cSrcweir
361cdf0e10cSrcweir // a must be
362cdf0e10cSrcweir OSL_ENSURE( sizeof(sal_Int32) == sizeof(void *), "### pointer size differs from sal_Int32!" );
363cdf0e10cSrcweir
364cdf0e10cSrcweir void * pCppExc = __Crun::ex_alloc( pTypeDescr->nSize );
365cdf0e10cSrcweir uno_copyAndConvertData( pCppExc, pUnoExc->pData, pTypeDescr, pUno2Cpp );
366cdf0e10cSrcweir
367cdf0e10cSrcweir // destruct uno exception
368cdf0e10cSrcweir uno_any_destruct( pUnoExc, 0 );
369cdf0e10cSrcweir
370cdf0e10cSrcweir unsigned int * thunk = thunkPtr.release();
371cdf0e10cSrcweir // sethi %hi(thunk), %o1:
372cdf0e10cSrcweir thunk[0] = 0x13000000 | (reinterpret_cast< unsigned int >(thunk) >> 10);
373cdf0e10cSrcweir // or %o1, %lo(thunk), %o1:
374cdf0e10cSrcweir thunk[1] = 0x92126000 | (reinterpret_cast< unsigned int >(thunk) & 0x3FF);
375cdf0e10cSrcweir // sethi %hi(pTypeDescr), %o2:
376cdf0e10cSrcweir thunk[2] = 0x15000000
377cdf0e10cSrcweir | (reinterpret_cast< unsigned int >(pTypeDescr) >> 10);
378cdf0e10cSrcweir // sethi %hi(deleteException), %o3
379cdf0e10cSrcweir thunk[3] = 0x17000000
380cdf0e10cSrcweir | (reinterpret_cast< unsigned int >(deleteException) >> 10);
381cdf0e10cSrcweir // jmpl %o3, %lo(deleteException), %g0
382cdf0e10cSrcweir thunk[4] = 0x81C2E000
383cdf0e10cSrcweir | (reinterpret_cast< unsigned int >(deleteException) & 0x3FF);
384cdf0e10cSrcweir // or %o2, %lo(pTypeDescr), %o2:
385cdf0e10cSrcweir thunk[5] = 0x9412A000
386cdf0e10cSrcweir | (reinterpret_cast< unsigned int >(pTypeDescr) & 0x3FF);
387cdf0e10cSrcweir bridges::cpp_uno::cc50_solaris_sparc::flushCode(thunk, thunk + 6);
388cdf0e10cSrcweir
389cdf0e10cSrcweir #pragma disable_warn
390cdf0e10cSrcweir void (* f)(void *) = reinterpret_cast< void (*)(void *) >(thunk);
391cdf0e10cSrcweir #pragma enable_warn
392cdf0e10cSrcweir __Crun::ex_throw(pCppExc, (const __Crun::static_type_info*)pRTTI, f);
393cdf0e10cSrcweir }
394cdf0e10cSrcweir
cc50_solaris_sparc_fillUnoException(void * pCppExc,const char * pInfo,uno_Any * pUnoExc,uno_Mapping * pCpp2Uno)395cdf0e10cSrcweir void cc50_solaris_sparc_fillUnoException(
396cdf0e10cSrcweir void* pCppExc,
397cdf0e10cSrcweir const char* pInfo,
398cdf0e10cSrcweir uno_Any* pUnoExc,
399cdf0e10cSrcweir uno_Mapping * pCpp2Uno )
400cdf0e10cSrcweir {
401cdf0e10cSrcweir OSL_ASSERT( pInfo != 0 );
402cdf0e10cSrcweir OString uno_name( toUNOname( pInfo ) );
403cdf0e10cSrcweir OUString aName( OStringToOUString(
404cdf0e10cSrcweir uno_name, RTL_TEXTENCODING_ASCII_US ) );
405cdf0e10cSrcweir typelib_TypeDescription * pExcTypeDescr = 0;
406cdf0e10cSrcweir typelib_typedescription_getByName( &pExcTypeDescr, aName.pData );
407cdf0e10cSrcweir
408cdf0e10cSrcweir if (pExcTypeDescr == 0) // the thing that should not be
409cdf0e10cSrcweir {
410cdf0e10cSrcweir RuntimeException aRE(
411cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM(
412cdf0e10cSrcweir "exception type not found: ") ) + aName,
413cdf0e10cSrcweir Reference< XInterface >() );
414cdf0e10cSrcweir Type const & rType = ::getCppuType( &aRE );
415cdf0e10cSrcweir uno_type_any_constructAndConvert(
416cdf0e10cSrcweir pUnoExc, &aRE, rType.getTypeLibType(), pCpp2Uno );
417cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
418cdf0e10cSrcweir OString cstr( OUStringToOString(
419cdf0e10cSrcweir aRE.Message, RTL_TEXTENCODING_ASCII_US ) );
420cdf0e10cSrcweir OSL_ENSURE( 0, cstr.getStr() );
421cdf0e10cSrcweir #endif
422cdf0e10cSrcweir return;
423cdf0e10cSrcweir }
424cdf0e10cSrcweir
425cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
426cdf0e10cSrcweir fprintf( stderr, "> c++ exception occured: %s\n",
427cdf0e10cSrcweir ::rtl::OUStringToOString(
428cdf0e10cSrcweir pExcTypeDescr->pTypeName,
429cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ).getStr() );
430cdf0e10cSrcweir #endif
431cdf0e10cSrcweir // construct uno exception any
432cdf0e10cSrcweir uno_any_constructAndConvert(
433cdf0e10cSrcweir pUnoExc, pCppExc, pExcTypeDescr, pCpp2Uno );
434cdf0e10cSrcweir typelib_typedescription_release( pExcTypeDescr );
435cdf0e10cSrcweir }
436cdf0e10cSrcweir
437cdf0e10cSrcweir }
438cdf0e10cSrcweir
439cdf0e10cSrcweir
440cdf0e10cSrcweir
441cdf0e10cSrcweir
442