1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 20 21 #include "uno/mapping.h" 22 23 #include <typeinfo> 24 #include <exception> 25 #include <cstddef> 26 27 namespace CPPU_CURRENT_NAMESPACE 28 { 29 30 void dummy_can_throw_anything( char const * ); 31 32 // Donor types for RTTI synthesis. Their type_info objects are emitted by the 33 // compiler, so they carry the real libc++abi vtables and the platform's own 34 // uniqueness convention. They must stay ordinary namespace-scope classes with 35 // no virtual functions and a single public non-virtual base -- exactly the 36 // shape of a generated UNO exception -- so that typeid(RttiDonorDerived) is a 37 // __si_class_type_info and typeid(RttiDonorBase) a __class_type_info. 38 // Do not move them into an anonymous namespace. 39 struct RttiDonorBase { sal_Int32 dummy; }; 40 struct RttiDonorDerived : public RttiDonorBase { sal_Int32 dummy2; }; 41 42 // Itanium ABI object layouts (http://itanium-cxx-abi.github.io/cxx-abi/abi.html#rtti). 43 // libc++abi does not publish __cxxabiv1::__class_type_info, and declaring a 44 // look-alike class is not an option: it would get its own vtable, and 45 // __class_type_info::can_catch() dynamic_casts the thrown type to the real 46 // libc++abi class, so no typed handler would ever match. We therefore build 47 // raw storage in the ABI layout and install a borrowed, genuine vtable. 48 struct RttiClassLayout { void const * pVtable; sal_uIntPtr nName; }; 49 struct RttiSiClassLayout { void const * pVtable; sal_uIntPtr nName; void const * pBase; }; 50 51 extern "C" void *__cxa_allocate_exception( 52 std::size_t thrown_size ) throw(); 53 extern "C" void __cxa_free_exception( void *thrown_exception ) throw(); 54 extern "C" void __cxa_throw ( 55 void *thrown_exception, std::type_info *tinfo, void (*dest) (void *) ) __attribute__((noreturn)); 56 extern "C" std::type_info *__cxa_current_exception_type(); 57 58 //================================================================================================== 59 void raiseException( 60 uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ); 61 //================================================================================================== 62 void fillUnoException( 63 std::type_info const & type, void * exception, uno_Any *, 64 uno_Mapping * pCpp2Uno ); 65 } 66