1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23 #include "uno/mapping.h"
24 #include <typeinfo>
25 #include <exception>
26 #include <cstddef>
27 namespace CPPU_CURRENT_NAMESPACE
28 {
29 void dummy_can_throw_anything( char const * );
30 // ----- following decl from libstdc++-v3/libsupc++/unwind-cxx.h and unwind.h
31
32 struct _Unwind_Exception
33 {
34 unsigned exception_class __attribute__((__mode__(__DI__)));
35 void * exception_cleanup;
36 unsigned private_1 __attribute__((__mode__(__word__)));
37 unsigned private_2 __attribute__((__mode__(__word__)));
38 } __attribute__((__aligned__));
39
40 struct __cxa_exception
41 {
42 ::std::type_info *exceptionType;
43 void (*exceptionDestructor)(void *);
44
45 ::std::unexpected_handler unexpectedHandler;
46 ::std::terminate_handler terminateHandler;
47
48 __cxa_exception *nextException;
49
50 int handlerCount;
51
52 int handlerSwitchValue;
53 const unsigned char *actionRecord;
54 const unsigned char *languageSpecificData;
55 void *catchTemp;
56 void *adjustedPtr;
57
58 _Unwind_Exception unwindHeader;
59 };
60
61 extern "C" void *__cxa_allocate_exception(
62 std::size_t thrown_size ) throw();
63 extern "C" void __cxa_throw (
64 void *thrown_exception, std::type_info *tinfo, void (*dest) (void *) ) __attribute__((noreturn));
65
66 struct __cxa_eh_globals
67 {
68 __cxa_exception *caughtExceptions;
69 unsigned int uncaughtExceptions;
70 };
71 extern "C" __cxa_eh_globals *__cxa_get_globals () throw();
72
73 //==================================================================================================
74 void raiseException(
75 uno_Any * pUnoExc, uno_Mapping * pUno2Cpp );
76 //==================================================================================================
77 void fillUnoException(
78 __cxa_exception * header, uno_Any *, uno_Mapping * pCpp2Uno );
79
adjustPointer(char * pIn,typelib_TypeDescription * pType)80 inline char* adjustPointer( char* pIn, typelib_TypeDescription* pType )
81 {
82 switch( pType->nSize )
83 {
84 case 1: return pIn + 3;
85 case 2: return pIn + 2;
86 case 3: return pIn + 1;
87 // Huh ? perhaps a char[3] ? Though that would be a pointer
88 // well, we have it anyway for symmetry
89 }
90 return pIn;
91 }
92
93 }
94