From 229efd7754227277b9b4ec050783b7ca9b17b9a5 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 29 Sep 2011 15:51:54 +0300 Subject: Make the C++/UNO bridge compile against the MacOSX 10.7 SDK Old work in progress by sberg, committed by tml. --- .../source/cpp_uno/gcc3_macosx_intel/except.cxx | 65 +++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) (limited to 'bridges') diff --git a/bridges/source/cpp_uno/gcc3_macosx_intel/except.cxx b/bridges/source/cpp_uno/gcc3_macosx_intel/except.cxx index 888e6f8d0519..b5ba92accc1d 100644 --- a/bridges/source/cpp_uno/gcc3_macosx_intel/except.cxx +++ b/bridges/source/cpp_uno/gcc3_macosx_intel/except.cxx @@ -31,7 +31,11 @@ #include #include +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 #include +#else +#include +#endif #include #include @@ -52,12 +56,62 @@ using namespace ::std; using namespace ::osl; using namespace ::rtl; using namespace ::com::sun::star::uno; +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 using namespace ::__cxxabiv1; - +#endif namespace CPPU_CURRENT_NAMESPACE { +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 + +// MacOSX10.4u.sdk/usr/include/c++/4.0.0/cxxabi.h defined +// __cxxabiv1::__class_type_info and __cxxabiv1::__si_class_type_info but +// MacOSX10.7.sdk/usr/include/cxxabi.h no longer does, so instances of those +// classes need to be created manually: + +// std::type_info defined in offers a protected ctor: +struct FAKE_type_info: public std::type_info { + FAKE_type_info(char const * name): type_info(name) {} +}; + +// Modeled after __cxxabiv1::__si_class_type_info defined in +// MacOSX10.4u.sdk/usr/include/c++/4.0.0/cxxabi.h (i.e., +// abi::__si_class_type_info documented at +// ): +struct FAKE_si_class_type_info: public FAKE_type_info { + FAKE_si_class_type_info(char const * name, std::type_info const * theBase): + FAKE_type_info(name), base(theBase) {} + + std::type_info const * base; + // actually a __cxxabiv1::__class_type_info pointer +}; + +struct Base {}; +struct Derived: Base {}; + +std::type_info * create_FAKE_class_type_info(char const * name) { + std::type_info * p = new FAKE_type_info(name); + // cxxabiv1::__class_type_info has no data members in addition to + // std::type_info + *reinterpret_cast< void ** >(p) = *reinterpret_cast< void * const * >( + &typeid(Base)); + // copy correct __cxxabiv1::__class_type_info vtable into place + return p; +} + +std::type_info * create_FAKE_si_class_type_info( + char const * name, std::type_info const * base) +{ + std::type_info * p = new FAKE_si_class_type_info(name, base); + *reinterpret_cast< void ** >(p) = *reinterpret_cast< void * const * >( + &typeid(Derived)); + // copy correct __cxxabiv1::__si_class_type_info vtable into place + return p; +} + +#endif + void dummy_can_throw_anything( char const * ) { } @@ -180,13 +234,22 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THR // ensure availability of base type_info * base_rtti = getRTTI( (typelib_CompoundTypeDescription *)pTypeDescr->pBaseTypeDescription ); +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 rtti = new __si_class_type_info( strdup( rttiName ), (__class_type_info *)base_rtti ); +#else + rtti = create_FAKE_si_class_type_info( + strdup( rttiName ), base_rtti ); +#endif } else { // this class has no base class +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 rtti = new __class_type_info( strdup( rttiName ) ); +#else + rtti = create_FAKE_class_type_info( strdup( rttiName ) ); +#endif } pair< t_rtti_map::iterator, bool > insertion( -- cgit