1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #include "uno/mapping.h"
28 #include <typeinfo>
29 #include <exception>
30 #include <cstddef>
31 namespace CPPU_CURRENT_NAMESPACE
32 {
33 void dummy_can_throw_anything( char const * );
34 // ----- following decl from libstdc++-v3/libsupc++/unwind-cxx.h and unwind.h
35 
36 struct _Unwind_Exception
37 {
38     unsigned exception_class __attribute__((__mode__(__DI__)));
39     void * exception_cleanup;
40     unsigned private_1 __attribute__((__mode__(__word__)));
41     unsigned private_2 __attribute__((__mode__(__word__)));
42 } __attribute__((__aligned__));
43 
44 struct __cxa_exception
45 {
46     ::std::type_info *exceptionType;
47     void (*exceptionDestructor)(void *);
48 
49     ::std::unexpected_handler unexpectedHandler;
50     ::std::terminate_handler terminateHandler;
51 
52     __cxa_exception *nextException;
53 
54     int handlerCount;
55 
56     int handlerSwitchValue;
57     const unsigned char *actionRecord;
58     const unsigned char *languageSpecificData;
59     void *catchTemp;
60     void *adjustedPtr;
61 
62     _Unwind_Exception unwindHeader;
63 };
64 
65 extern "C" void *__cxa_allocate_exception(
66     std::size_t thrown_size ) throw();
67 extern "C" void __cxa_throw (
68     void *thrown_exception, std::type_info *tinfo, void (*dest) (void *) ) __attribute__((noreturn));
69 
70 struct __cxa_eh_globals
71 {
72     __cxa_exception *caughtExceptions;
73     unsigned int uncaughtExceptions;
74 };
75 extern "C" __cxa_eh_globals *__cxa_get_globals () throw();
76 
77 //==================================================================================================
78 void raiseException(
79     uno_Any * pUnoExc, uno_Mapping * pUno2Cpp );
80 //==================================================================================================
81 void fillUnoException(
82     __cxa_exception * header, uno_Any *, uno_Mapping * pCpp2Uno );
83 
84 inline char* adjustPointer( char* pIn, typelib_TypeDescription* pType )
85 {
86 	switch( pType->nSize )
87 	{
88 		case 1: return pIn + 3;
89 		case 2: return pIn + 2;
90 		case 3: return pIn + 1;
91 			// Huh ? perhaps a char[3] ? Though that would be a pointer
92 			// well, we have it anyway for symmetry
93 	}
94 	return pIn;
95 }
96 
97 }
98