1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  *   Licensed to the Apache Software Foundation (ASF) under one or more
12  *   contributor license agreements. See the NOTICE file distributed
13  *   with this work for additional information regarding copyright
14  *   ownership. The ASF licenses this file to you under the Apache
15  *   License, Version 2.0 (the "License"); you may not use this file
16  *   except in compliance with the License. You may obtain a copy of
17  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 #pragma once
20 
21 #include "uno/mapping.h"
22 #include <typeinfo>
23 #include <exception>
24 #include <cstddef>
25 namespace CPPU_CURRENT_NAMESPACE
26 {
27 void dummy_can_throw_anything( char const * );
28 // ----- following decl from libstdc++-v3/libsupc++/unwind-cxx.h and unwind.h
29 
30 struct _Unwind_Exception
31 {
32     unsigned exception_class __attribute__((__mode__(__DI__)));
33     void * exception_cleanup;
34     unsigned private_1 __attribute__((__mode__(__word__)));
35     unsigned private_2 __attribute__((__mode__(__word__)));
36 } __attribute__((__aligned__));
37 
38 struct __cxa_exception
39 {
40     std::type_info *exceptionType;
41     void (*exceptionDestructor)(void *);
42 
43     void (*unexpectedHandler)(); // std::unexpected_handler dropped from C++17
44     std::terminate_handler terminateHandler;
45 
46     __cxa_exception *nextException;
47 
48     int handlerCount;
49 
50     int handlerSwitchValue;
51     const unsigned char *actionRecord;
52     const unsigned char *languageSpecificData;
53     void *catchTemp;
54     void *adjustedPtr;
55 
56     _Unwind_Exception unwindHeader;
57 };
58 
59 extern "C" void *__cxa_allocate_exception(
60     std::size_t thrown_size ) throw();
61 extern "C" void __cxa_throw (
62     void *thrown_exception, std::type_info *tinfo, void (*dest) (void *) ) __attribute__((noreturn));
63 
64 struct __cxa_eh_globals
65 {
66     __cxa_exception *caughtExceptions;
67     unsigned int uncaughtExceptions;
68 };
69 extern "C" __cxa_eh_globals *__cxa_get_globals () throw();
70 extern "C" std::type_info *__cxa_current_exception_type() throw();
71 
72 void raiseException(
73     uno_Any * pUnoExc, uno_Mapping * pUno2Cpp );
74 
75 void fillUnoException(uno_Any *, uno_Mapping * pCpp2Uno);
76 
adjustPointer(char * pIn,typelib_TypeDescription * pType)77 inline char* adjustPointer( char* pIn, typelib_TypeDescription* pType )
78 {
79     switch( pType->nSize )
80     {
81         case 1: return pIn + 3;
82         case 2: return pIn + 2;
83         case 3: return pIn + 1;
84             // Huh ? perhaps a char[3] ? Though that would be a pointer
85             // well, we have it anyway for symmetry
86     }
87     return pIn;
88 }
89 
90 }
91 
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
93