1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
--- ../bridges/source/cpp_uno/gcc3_freebsd_intel.orig/except.cxx Tue Mar 11 18:14:16 2003
+++ ../bridges/source/cpp_uno/gcc3_freebsd_intel/except.cxx Tue Mar 11 18:15:40 2003
@@ -253,6 +253,13 @@
//==================================================================================================
void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp )
{
+#if defined DEBUG
+ OString cstr(
+ OUStringToOString(
+ *reinterpret_cast< OUString const * >( &pUnoExc->pType->pTypeName ),
+ RTL_TEXTENCODING_ASCII_US ) );
+ fprintf( stderr, "> uno exception occured: %s\n", cstr.getStr() );
+#endif
void * pCppExc;
type_info * rtti;
@@ -262,7 +269,12 @@
TYPELIB_DANGER_GET( &pTypeDescr, pUnoExc->pType );
OSL_ASSERT( pTypeDescr );
if (! pTypeDescr)
- terminate();
+ {
+ throw RuntimeException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("cannot get typedescription for type ") ) +
+ *reinterpret_cast< OUString const * >( &pUnoExc->pType->pTypeName ),
+ Reference< XInterface >() );
+ }
pCppExc = __cxa_allocate_exception( pTypeDescr->nSize );
::uno_copyAndConvertData( pCppExc, pUnoExc->pData, pTypeDescr, pUno2Cpp );
@@ -288,29 +300,59 @@
TYPELIB_DANGER_RELEASE( pTypeDescr );
OSL_ENSURE( rtti, "### no rtti for throwing exception!" );
if (! rtti)
- terminate();
+ {
+ throw RuntimeException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("no rtti for type ") ) +
+ *reinterpret_cast< OUString const * >( &pUnoExc->pType->pTypeName ),
+ Reference< XInterface >() );
+ }
}
__cxa_throw( pCppExc, rtti, deleteException );
}
//==================================================================================================
-void fillUnoException( __cxa_exception * header, uno_Any * pExc, uno_Mapping * pCpp2Uno )
+void fillUnoException( __cxa_exception * header, uno_Any * pUnoExc, uno_Mapping * pCpp2Uno )
{
- OSL_ENSURE( header, "### no exception header!!!" );
if (! header)
- terminate();
+ {
+ RuntimeException aRE(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("no exception header!") ),
+ Reference< XInterface >() );
+ Type const & rType = ::getCppuType( &aRE );
+ uno_type_any_constructAndConvert( pUnoExc, &aRE, rType.getTypeLibType(), pCpp2Uno );
+#if defined _DEBUG
+ OString cstr( OUStringToOString( aRE.Message, RTL_TEXTENCODING_ASCII_US ) );
+ OSL_ENSURE( 0, cstr.getStr() );
+#endif
+ return;
+ }
typelib_TypeDescription * pExcTypeDescr = 0;
OUString unoName( toUNOname( header->exceptionType->name() ) );
- ::typelib_typedescription_getByName( &pExcTypeDescr, unoName.pData );
- OSL_ENSURE( pExcTypeDescr, "### can not get type description for exception!!!" );
- if (! pExcTypeDescr)
- terminate();
-
- // construct uno exception any
- ::uno_any_constructAndConvert( pExc, header->adjustedPtr, pExcTypeDescr, pCpp2Uno );
- ::typelib_typedescription_release( pExcTypeDescr );
+#if defined DEBUG
+ OString cstr_unoName( OUStringToOString( unoName, RTL_TEXTENCODING_ASCII_US ) );
+ fprintf( stderr, "> c++ exception occured: %s\n", cstr_unoName.getStr() );
+#endif
+ typelib_typedescription_getByName( &pExcTypeDescr, unoName.pData );
+ if (0 == pExcTypeDescr)
+ {
+ RuntimeException aRE(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("exception type not found: ") ) + unoName,
+ Reference< XInterface >() );
+ Type const & rType = ::getCppuType( &aRE );
+ uno_type_any_constructAndConvert( pUnoExc, &aRE, rType.getTypeLibType(), pCpp2Uno );
+#if defined _DEBUG
+ OString cstr( OUStringToOString( aRE.Message, RTL_TEXTENCODING_ASCII_US ) );
+ OSL_ENSURE( 0, cstr.getStr() );
+#endif
+ }
+ else
+ {
+ // construct uno exception any
+ uno_any_constructAndConvert( pUnoExc, header->adjustedPtr, pExcTypeDescr, pCpp2Uno );
+ typelib_typedescription_release( pExcTypeDescr );
+ }
}
}
--- ../bridges/source/cpp_uno/gcc3_freebsd_intel/uno2cpp.cxx.orig Thu Mar 27 22:05:43 2003
+++ ../bridges/source/cpp_uno/gcc3_freebsd_intel/uno2cpp.cxx Thu Mar 27 22:08:18 2003
@@ -97,7 +97,9 @@
if (! pThis) dummy_can_throw_anything("xxx"); // address something
volatile long edx = 0, eax = 0; // for register returns
+ void * stackptr;
asm volatile (
+ "mov %%esp, %6\n\t"
// copy values
"mov %0, %%eax\n\t"
"mov %%eax, %%edx\n\t"
@@ -121,13 +123,11 @@
"mov %%eax, %4\n\t"
"mov %%edx, %5\n\t"
// cleanup stack
- "mov %0, %%eax\n\t"
- "shl $2, %%eax\n\t"
- "add %%eax, %%esp\n\t"
+ "mov %6, %%esp\n\t"
:
- : "m"(nStackLongs), "m"(pStackLongs), "m"(pThis), "m"(nVtableIndex), "m"(eax), "m"(edx)
+ : "m"(nStackLongs), "m"(pStackLongs), "m"(pThis), "m"(nVtableIndex),
+ "m"(eax), "m"(edx), "m"(stackptr)
: "eax", "edx" );
-
switch( eReturnType )
{
case typelib_TypeClass_HYPER:
|