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 24 #include "uno/mapping.h" 25 26 #include <typeinfo> 27 #include <exception> 28 #include <cstddef> 29 30 namespace CPPU_CURRENT_NAMESPACE 31 { 32 33 void dummy_can_throw_anything( char const * ); 34 35 // Donor types for RTTI synthesis. Their type_info objects are emitted by the 36 // compiler, so they carry the real libc++abi vtables and the platform's own 37 // uniqueness convention. They must stay ordinary namespace-scope classes with 38 // no virtual functions and a single public non-virtual base -- exactly the 39 // shape of a generated UNO exception -- so that typeid(RttiDonorDerived) is a 40 // __si_class_type_info and typeid(RttiDonorBase) a __class_type_info. 41 // Do not move them into an anonymous namespace. 42 struct RttiDonorBase { sal_Int32 dummy; }; 43 struct RttiDonorDerived : public RttiDonorBase { sal_Int32 dummy2; }; 44 45 // Itanium ABI object layouts (http://itanium-cxx-abi.github.io/cxx-abi/abi.html#rtti). 46 // libc++abi does not publish __cxxabiv1::__class_type_info, and declaring a 47 // look-alike class is not an option: it would get its own vtable, and 48 // __class_type_info::can_catch() dynamic_casts the thrown type to the real 49 // libc++abi class, so no typed handler would ever match. We therefore build 50 // raw storage in the ABI layout and install a borrowed, genuine vtable. 51 struct RttiClassLayout { void const * pVtable; sal_uIntPtr nName; }; 52 struct RttiSiClassLayout { void const * pVtable; sal_uIntPtr nName; void const * pBase; }; 53 54 extern "C" void *__cxa_allocate_exception( 55 std::size_t thrown_size ) throw(); 56 extern "C" void __cxa_free_exception( void *thrown_exception ) throw(); 57 extern "C" void __cxa_throw ( 58 void *thrown_exception, std::type_info *tinfo, void (*dest) (void *) ) __attribute__((noreturn)); 59 extern "C" std::type_info *__cxa_current_exception_type(); 60 61 //================================================================================================== 62 void raiseException( 63 uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ); 64 //================================================================================================== 65 void fillUnoException( 66 std::type_info const & type, void * exception, uno_Any *, 67 uno_Mapping * pCpp2Uno ); 68 } 69