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