Rebased ref, commits from common ancestor: commit 3e19d8bca3d4960558cd2468aac7c73bdbe545a2 Author: Douglas Mencken <dougmenc...@gmail.com> Date: Thu Oct 30 12:55:14 2014 -0400
toolkit: include <objc/objc-api.h> when OBJC_EXPORT is not defined Change-Id: I5b1abae5bace4f831baa2e69d46e75c7cb638095 diff --git a/toolkit/source/awt/vclxwindow1.cxx b/toolkit/source/awt/vclxwindow1.cxx index 46b2e72..f2cc331 100644 --- a/toolkit/source/awt/vclxwindow1.cxx +++ b/toolkit/source/awt/vclxwindow1.cxx @@ -28,6 +28,9 @@ #include <postwin.h> #elif defined ( MACOSX ) #include "premac.h" +#ifndef OBJC_EXPORT +#include <objc/objc-api.h> +#endif #include <Cocoa/Cocoa.h> #include "postmac.h" #endif commit 9344514842efe8050f7aaf8e2e2f4dcf963e5207 Author: Douglas Mencken <dougmenc...@gmail.com> Date: Sat Oct 25 11:03:56 2014 -0400 workarounds for `objc_msgSend' on 10.5 (vcl/osx/salframe.cxx, vcl/osx/salmenu.cxx) plus, move conditional includes in salframe.cxx down a bit Change-Id: I39886b4590f227ec69042fed0f5240ba0b0fd7f2 diff --git a/vcl/osx/salframe.cxx b/vcl/osx/salframe.cxx index ce3e371..dacf9fe 100644 --- a/vcl/osx/salframe.cxx +++ b/vcl/osx/salframe.cxx @@ -37,11 +37,6 @@ #include "osx/a11yfactory.h" #include "quartz/utils.h" -#if MACOSX_SDK_VERSION < 1060 -#include "vcl/timer.hxx" -#include "osx/saltimer.h" -#endif - #include "salwtype.hxx" #include "premac.h" @@ -54,6 +49,11 @@ #include <Carbon/Carbon.h> #include "postmac.h" +#if MACOSX_SDK_VERSION < 1060 +#include "vcl/timer.hxx" +#include "osx/saltimer.h" +#endif + using namespace std; AquaSalFrame* AquaSalFrame::s_pCaptureFrame = NULL; @@ -201,16 +201,16 @@ void AquaSalFrame::initWindowAndView() [mpNSWindow setAcceptsMouseMovedEvents: YES]; [mpNSWindow setHasShadow: YES]; -#if MACOSX_SDK_VERSION < 1060 - objc_msgSend(mpNSWindow, @selector(setDelegate:), mpNSWindow); -#else +#if MACOSX_SDK_VERSION >= 1070 + /* objc_msgSend(mpNSWindow, @selector(setDelegate:), mpNSWindow); */ [mpNSWindow setDelegate: static_cast<id<NSWindowDelegate> >(mpNSWindow)]; -#endif if( [mpNSWindow respondsToSelector: @selector(setRestorable:)]) { objc_msgSend(mpNSWindow, @selector(setRestorable:), NO); } +#endif + const NSRect aRect = { NSZeroPoint, NSMakeSize( maGeometry.nWidth, maGeometry.nHeight )}; mnTrackingRectTag = [mpNSView addTrackingRect: aRect owner: mpNSView userData: nil assumeInside: NO]; diff --git a/vcl/osx/salmenu.cxx b/vcl/osx/salmenu.cxx index 315c025..d670933 100644 --- a/vcl/osx/salmenu.cxx +++ b/vcl/osx/salmenu.cxx @@ -246,9 +246,8 @@ AquaSalMenu::AquaSalMenu( bool bMenuBar ) : if( ! mbMenuBar ) { mpMenu = [[SalNSMenu alloc] initWithMenu: this]; -#if MACOSX_SDK_VERSION < 1060 - objc_msgSend(mpMenu, @selector(setDelegate:), mpMenu); -#else +#if MACOSX_SDK_VERSION >= 1060 + /* objc_msgSend(mpMenu, @selector(setDelegate:), mpMenu); */ [mpMenu setDelegate: (id<NSMenuDelegate>)mpMenu]; #endif } commit 5c21d45c9f614a5d28a451a1398c3c20171a2a6b Author: Douglas Mencken <dougmenc...@gmail.com> Date: Sun Oct 26 06:38:10 2014 -0400 vcl: fix some "cannot convert 'objc_object*' to..." issues Change-Id: I4b0e32c412937da4b2ea4bf350be32ea31362b3c diff --git a/vcl/osx/a11ywrapper.mm b/vcl/osx/a11ywrapper.mm index 4e19e1d..f821da7 100644 --- a/vcl/osx/a11ywrapper.mm +++ b/vcl/osx/a11ywrapper.mm @@ -160,7 +160,7 @@ static std::ostream &operator<<(std::ostream &s, NSPoint point) { // (getter with parameter) attributeNameHereAttributeForParameter: // (setter) setAttributeNameHereAttributeForElement:to: -(SEL)selectorForAttribute:(NSString *)attribute asGetter:(BOOL)asGetter withGetterParameter:(BOOL)withGetterParameter { - SEL selector = nil; + SEL selector = (SEL)nil; NSAutoreleasePool * pool = [ [ NSAutoreleasePool alloc ] init ]; @try { // step 1: create method name from attribute name @@ -186,7 +186,7 @@ static std::ostream &operator<<(std::ostream &s, NSPoint point) { // step 2: create selector selector = NSSelectorFromString ( methodName ); } @catch ( id exception ) { - selector = nil; + selector = (SEL)nil; } [ pool release ]; return selector; diff --git a/vcl/osx/salframeview.mm b/vcl/osx/salframeview.mm index 2cf0136..ea14c09 100644 --- a/vcl/osx/salframeview.mm +++ b/vcl/osx/salframeview.mm @@ -482,7 +482,7 @@ static AquaSalFrame* getMouseContainerFrame() mpFrame = pFrame; mMarkedRange = NSMakeRange(NSNotFound, 0); mSelectedRange = NSMakeRange(NSNotFound, 0); - mpReferenceWrapper = nil; + mpReferenceWrapper = (ReferenceWrapper*)nil; mpMouseEventListener = nil; mpLastSuperEvent = nil; } @@ -1788,7 +1788,7 @@ private: // some frames never become visible .. ::vcl::Window *pWindow = mpFrame -> GetWindow(); if ( ! pWindow ) - return nil; + return (::com::sun::star::accessibility::XAccessibleContext*)nil; mpReferenceWrapper = new ReferenceWrapper; mpReferenceWrapper -> rAccessibleContext = pWindow -> /*GetAccessibleChildWindow( 0 ) ->*/ GetAccessible() -> getAccessibleContext(); diff --git a/vcl/osx/salnativewidgets.cxx b/vcl/osx/salnativewidgets.cxx index ce3ab41..69f7753 100644 --- a/vcl/osx/salnativewidgets.cxx +++ b/vcl/osx/salnativewidgets.cxx @@ -558,7 +558,7 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType, [NSNumber numberWithBool:NO], @"kCUIWindowFrameDrawTitleSeparatorKey", [NSNumber numberWithBool:YES], @"is.flipped", nil], - nil);; + (const __CFDictionary**)nil);; } else { commit 8db153ffc68943f7da340657a881f3fc42abb41f Author: Douglas Mencken <dougmenc...@gmail.com> Date: Tue Oct 28 13:18:59 2014 -0400 fix "trying to encode non-integer type as a bitfield" this problem arises when you compile with GCC (GNU objective-C mode) Change-Id: Ifa4ff252ae5a7b71320d41873a2c412a32dd0333 diff --git a/vcl/inc/osx/salframe.h b/vcl/inc/osx/salframe.h index 47c1c91..d4dcd43 100644 --- a/vcl/inc/osx/salframe.h +++ b/vcl/inc/osx/salframe.h @@ -62,13 +62,13 @@ public: int mnMaxWidth; // max. client width in pixels int mnMaxHeight; // max. client height in pixels NSRect maFullScreenRect; // old window size when in FullScreen - bool mbGraphics:1; // is Graphics used? - bool mbFullScreen:1; // is Window in FullScreen? - bool mbShown:1; - bool mbInitShow:1; - bool mbPositioned:1; - bool mbSized:1; - bool mbPresentation:1; + int mbGraphics:1; // is Graphics used? + int mbFullScreen:1; // is Window in FullScreen? + int mbShown:1; + int mbInitShow:1; + int mbPositioned:1; + int mbSized:1; + int mbPresentation:1; sal_uLong mnStyle; unsigned int mnStyleMask; // our style mask from NSWindow creation commit 7b6190fb646f135c0f77987ee4808db51e1d2f41 Author: Douglas Mencken <dougmenc...@gmail.com> Date: Sun Oct 26 03:06:31 2014 -0400 apple_remote: include <objc/objc-api.h> when OBJC_EXPORT is not defined Change-Id: Idc37a663f8a5abad30464a0f38d66237c7de39b4 diff --git a/apple_remote/source/AppleRemote.h b/apple_remote/source/AppleRemote.h index 0e4187f..9e2e7fa 100644 --- a/apple_remote/source/AppleRemote.h +++ b/apple_remote/source/AppleRemote.h @@ -29,6 +29,9 @@ * *****************************************************************************/ +#ifndef OBJC_EXPORT +#include <objc/objc-api.h> +#endif #import <Cocoa/Cocoa.h> #import "HIDRemoteControlDevice.h" diff --git a/apple_remote/source/KeyspanFrontRowControl.h b/apple_remote/source/KeyspanFrontRowControl.h index c75e86b..fa527bb 100644 --- a/apple_remote/source/KeyspanFrontRowControl.h +++ b/apple_remote/source/KeyspanFrontRowControl.h @@ -29,6 +29,9 @@ * *****************************************************************************/ +#ifndef OBJC_EXPORT +#include <objc/objc-api.h> +#endif #import <Cocoa/Cocoa.h> #import "HIDRemoteControlDevice.h" diff --git a/include/apple_remote/RemoteControl.h b/include/apple_remote/RemoteControl.h index 04fab5a..589cfd9 100644 --- a/include/apple_remote/RemoteControl.h +++ b/include/apple_remote/RemoteControl.h @@ -31,6 +31,9 @@ #include <sal/config.h> +#ifndef OBJC_EXPORT +#include <objc/objc-api.h> +#endif #import <Cocoa/Cocoa.h> #include <sal/types.h> diff --git a/include/apple_remote/RemoteMainController.h b/include/apple_remote/RemoteMainController.h index c4ee0ac..158ba6d 100644 --- a/include/apple_remote/RemoteMainController.h +++ b/include/apple_remote/RemoteMainController.h @@ -31,6 +31,9 @@ #include <sal/config.h> +#ifndef OBJC_EXPORT +#include <objc/objc-api.h> +#endif #import <Cocoa/Cocoa.h> #include <sal/types.h> commit 7c3932d727a84dc059ab417bb47f1acbc66f9ed5 Author: Douglas Mencken <dougmenc...@gmail.com> Date: Sun Oct 26 03:17:10 2014 -0400 vcl: include <objc/objc-api.h> when OBJC_EXPORT is not defined Change-Id: I6fbfff670fb9d83e950e7eac60000ef3e0130f8c diff --git a/vcl/inc/osx/a11yfactory.h b/vcl/inc/osx/a11yfactory.h index c739f3e..4e92126 100644 --- a/vcl/inc/osx/a11yfactory.h +++ b/vcl/inc/osx/a11yfactory.h @@ -20,6 +20,10 @@ #ifndef INCLUDED_VCL_INC_OSX_A11YFACTORY_H #define INCLUDED_VCL_INC_OSX_A11YFACTORY_H +#ifndef OBJC_EXPORT +#include <objc/objc-api.h> +#endif + #include "osxvcltypes.h" #include "a11ywrapper.h" #include <com/sun/star/accessibility/XAccessibleContext.hpp> diff --git a/vcl/inc/osx/osxvcltypes.h b/vcl/inc/osx/osxvcltypes.h index f1659c4..96edccc 100644 --- a/vcl/inc/osx/osxvcltypes.h +++ b/vcl/inc/osx/osxvcltypes.h @@ -21,6 +21,9 @@ #define INCLUDED_VCL_INC_OSX_OSXVCLTYPES_H #include "premac.h" +#ifndef OBJC_EXPORT +#include <objc/objc-api.h> +#endif #import <Cocoa/Cocoa.h> #import <AppKit/NSEvent.h> #include "postmac.h" diff --git a/vcl/inc/osx/printview.h b/vcl/inc/osx/printview.h index e396bd8..b63900b 100644 --- a/vcl/inc/osx/printview.h +++ b/vcl/inc/osx/printview.h @@ -21,6 +21,9 @@ #define INCLUDED_VCL_INC_OSX_PRINTVIEW_H #include "premac.h" +#ifndef OBJC_EXPORT +#include <objc/objc-api.h> +#endif #include <Cocoa/Cocoa.h> #include "postmac.h" diff --git a/vcl/inc/osx/saldata.hxx b/vcl/inc/osx/saldata.hxx index 413754b..1665b06 100644 --- a/vcl/inc/osx/saldata.hxx +++ b/vcl/inc/osx/saldata.hxx @@ -23,6 +23,9 @@ #include <config_features.h> #include "premac.h" +#ifndef OBJC_EXPORT +#include <objc/objc-api.h> +#endif #include <Cocoa/Cocoa.h> #include "postmac.h" diff --git a/vcl/inc/osx/salinst.h b/vcl/inc/osx/salinst.h index 8a88a26..4efcbe0 100644 --- a/vcl/inc/osx/salinst.h +++ b/vcl/inc/osx/salinst.h @@ -25,6 +25,9 @@ #include "osl/conditn.h" #ifdef MACOSX +#ifndef OBJC_EXPORT +#include <objc/objc-api.h> +#endif #include "osx/osxvcltypes.h" #endif diff --git a/vcl/inc/osx/saltimer.h b/vcl/inc/osx/saltimer.h index b751a81..e663c65 100644 --- a/vcl/inc/osx/saltimer.h +++ b/vcl/inc/osx/saltimer.h @@ -21,6 +21,9 @@ #define INCLUDED_VCL_INC_OSX_SALTIMER_H #include "premac.h" +#ifndef OBJC_EXPORT +#include <objc/objc-api.h> +#endif #include <Cocoa/Cocoa.h> #include "postmac.h" diff --git a/vcl/inc/osx/vclnsapp.h b/vcl/inc/osx/vclnsapp.h index 541b509..675cacc 100644 --- a/vcl/inc/osx/vclnsapp.h +++ b/vcl/inc/osx/vclnsapp.h @@ -23,6 +23,9 @@ #include <config_features.h> #include "premac.h" +#ifndef OBJC_EXPORT +#include <objc/objc-api.h> +#endif #include "Cocoa/Cocoa.h" #include "postmac.h" diff --git a/vcl/inc/quartz/utils.h b/vcl/inc/quartz/utils.h index e408250..ac264ec 100644 --- a/vcl/inc/quartz/utils.h +++ b/vcl/inc/quartz/utils.h @@ -23,6 +23,9 @@ #include <iostream> #include <premac.h> +#ifndef OBJC_EXPORT +#include <objc/objc-api.h> +#endif #include <CoreFoundation/CoreFoundation.h> #include <Foundation/Foundation.h> #ifdef MACOSX diff --git a/vcl/osx/DataFlavorMapping.cxx b/vcl/osx/DataFlavorMapping.cxx index 33bd19b..429330c 100644 --- a/vcl/osx/DataFlavorMapping.cxx +++ b/vcl/osx/DataFlavorMapping.cxx @@ -36,6 +36,9 @@ #include <string.h> #include <premac.h> +#ifndef OBJC_EXPORT +#include <objc/objc-api.h> +#endif #include <Cocoa/Cocoa.h> #include <postmac.h> diff --git a/vcl/osx/DataFlavorMapping.hxx b/vcl/osx/DataFlavorMapping.hxx index a3cff1c..31f4eb5 100644 --- a/vcl/osx/DataFlavorMapping.hxx +++ b/vcl/osx/DataFlavorMapping.hxx @@ -26,6 +26,9 @@ #include <com/sun/star/lang/XMultiComponentFactory.hpp> #include <premac.h> +#ifndef OBJC_EXPORT +#include <objc/objc-api.h> +#endif #import <Cocoa/Cocoa.h> #include <postmac.h> diff --git a/vcl/osx/DragActionConversion.hxx b/vcl/osx/DragActionConversion.hxx index fbb5ea3..b77047d 100644 --- a/vcl/osx/DragActionConversion.hxx +++ b/vcl/osx/DragActionConversion.hxx @@ -23,6 +23,9 @@ #include <sal/types.h> #include <premac.h> +#ifndef OBJC_EXPORT +#include <objc/objc-api.h> +#endif #import <Cocoa/Cocoa.h> #include <postmac.h> diff --git a/vcl/osx/DragSource.hxx b/vcl/osx/DragSource.hxx index 491716d..403ed51 100644 --- a/vcl/osx/DragSource.hxx +++ b/vcl/osx/DragSource.hxx @@ -33,6 +33,9 @@ #include <boost/utility.hpp> #include <premac.h> +#ifndef OBJC_EXPORT +#include <objc/objc-api.h> +#endif #import <Cocoa/Cocoa.h> #include <postmac.h> diff --git a/vcl/osx/PictToBmpFlt.cxx b/vcl/osx/PictToBmpFlt.cxx index 77c67a6..097050e 100644 --- a/vcl/osx/PictToBmpFlt.cxx +++ b/vcl/osx/PictToBmpFlt.cxx @@ -18,6 +18,9 @@ */ #include <premac.h> +#ifndef OBJC_EXPORT +#include <objc/objc-api.h> +#endif #include <Carbon/Carbon.h> #include <QuickTime/QuickTime.h> #include <postmac.h> diff --git a/vcl/osx/salframe.cxx b/vcl/osx/salframe.cxx index eab873c..ce3e371 100644 --- a/vcl/osx/salframe.cxx +++ b/vcl/osx/salframe.cxx @@ -45,6 +45,9 @@ #include "salwtype.hxx" #include "premac.h" +#ifndef OBJC_EXPORT +#include <objc/objc-api.h> +#endif #include <objc/objc-runtime.h> // needed for theming // FIXME: move theming code to salnativewidgets.cxx commit 64658051a84d499e3ac87e46dc2f8a86ae60499c Author: Douglas Mencken <dougmenc...@gmail.com> Date: Wed Oct 8 10:38:28 2014 -0400 Use GNU objc ABI/runtime instead of NeXT ABI/runtime when compiler is GCC also, + fix "cannot find interface declaration for NXConstantString" + sal/osl/unx/system.h: include <objc/objc-api.h> when OBJC_EXPORT is not defined Change-Id: I5f0df322435be8244d372642dee1c21d783306f1 diff --git a/sal/osl/unx/system.h b/sal/osl/unx/system.h index d952518..143a1bd 100644 --- a/sal/osl/unx/system.h +++ b/sal/osl/unx/system.h @@ -215,6 +215,9 @@ #ifdef MACOSX #define __OPENTRANSPORTPROVIDERS__ // these are already defined #define TimeValue CFTimeValue // Do not conflict with TimeValue in sal/inc/osl/time.h +#ifndef OBJC_EXPORT +#include <objc/objc-api.h> +#endif #include <Carbon/Carbon.h> #undef TimeValue # ifndef ETIME diff --git a/solenv/gbuild/platform/macosx.mk b/solenv/gbuild/platform/macosx.mk index 41f1fb1..7ba21a9 100644 --- a/solenv/gbuild/platform/macosx.mk +++ b/solenv/gbuild/platform/macosx.mk @@ -59,9 +59,21 @@ gb_CXXFLAGS := \ # these are to get g++ to switch to Objective-C++ mode # (see toolkit module for a case where it is necessary to do it this way) -gb_OBJCXXFLAGS := -x objective-c++ -fobjc-exceptions - -gb_OBJCFLAGS := -x objective-c -fobjc-exceptions +gb_OBJCXXFLAGS := \ + -x objective-c++ \ + -fobjc-exceptions \ + $(if $(filter TRUE,$(COM_GCC_IS_CLANG)),,\ + -fgnu-runtime \ + -fconstant-string-class=NSConstantString \ + ) + +gb_OBJCFLAGS := \ + -x objective-c \ + -fobjc-exceptions \ + $(if $(filter TRUE,$(COM_GCC_IS_CLANG)),,\ + -fgnu-runtime \ + -fconstant-string-class=NSConstantString \ + ) # LinkTarget class commit a742036f30336471f2170e37628f1637b19edeac Author: Douglas Mencken <dougmenc...@gmail.com> Date: Fri Oct 31 13:40:18 2014 -0400 vlc: use OpenGL "2.1 legacy context" for OS X versions < 10.7 ``With Mac OS X 10.7 Lion OpenGL 3.2 support was added. Till then only OpenGL 2.1 was available.'' related commit: 8b384c946cb6725d691123152f5e7c6ac0692185 Change-Id: I90aa3fbffa8c67f67336f0036324dca584c28830 diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx index 79430ba..4e773da 100644 --- a/vcl/source/opengl/OpenGLContext.cxx +++ b/vcl/source/opengl/OpenGLContext.cxx @@ -36,7 +36,11 @@ OpenGLContext::OpenGLContext(): mpWindow(NULL), m_pChildWindow(NULL), mbInitialized(false), +#if defined(MACOSX) && MACOSX_SDK_VERSION < 1070 + mbRequestLegacyContext(true) +#else mbRequestLegacyContext(false) +#endif { } @@ -704,7 +708,11 @@ bool OpenGLContext::initWindow() { if( !m_pChildWindow ) { - SystemWindowData winData = generateWinData(mpWindow, false); +#if defined(MACOSX) && MACOSX_SDK_VERSION < 1070 + SystemWindowData winData = generateWinData(mpWindow, /* bLegacy */ true); +#else + SystemWindowData winData = generateWinData(mpWindow, /* bLegacy */ false); +#endif m_pChildWindow = new SystemChildWindow(mpWindow, 0, &winData, false); m_pChildWindowGC.reset(m_pChildWindow); } commit d79f16cbe95d249abe9b396f95e06410714ce033 Author: Douglas Mencken <dougmenc...@gmail.com> Date: Wed Oct 29 17:03:27 2014 -0400 disable OpenGL and OpenCL for OS X 10.5 Change-Id: I40def75aa83d9b780bbf7e7ec51096aa1f929457 diff --git a/configure.ac b/configure.ac index 24146f2..ac52c86 100644 --- a/configure.ac +++ b/configure.ac @@ -7229,6 +7229,11 @@ if test $_os = iOS; then with_ppds=no fi +if test "$_os" = "Darwin" -a "$with_macosx_sdk" = "10.5"; then + enable_opengl=no + enable_opencl=no +fi + ENABLE_LWP= if test "$enable_lotuswordpro" = "yes"; then ENABLE_LWP="TRUE" commit 9ac2dcf073fe7e41b8bf0873e9a5a019b559e201 Author: Douglas Mencken <dougmenc...@gmail.com> Date: Sat Oct 25 11:05:30 2014 -0400 Don't assume that /usr/bin/mktemp is always a BSD mktemp on OSX, add backup for GNU mktemp Change-Id: Ifb119dd13062593cba5aa3cb1dacc54194339544 diff --git a/solenv/gbuild/platform/macosx.mk b/solenv/gbuild/platform/macosx.mk index 185fb26..41f1fb1 100644 --- a/solenv/gbuild/platform/macosx.mk +++ b/solenv/gbuild/platform/macosx.mk @@ -24,8 +24,8 @@ gb_SDKDIR := $(MACOSX_SDK_PATH) include $(GBUILDDIR)/platform/com_GCC_defs.mk -# Darwin mktemp -t expects a prefix, not a pattern -gb_MKTEMP ?= /usr/bin/mktemp -t gbuild. +# Note that BSD mktemp -t expects a prefix, not a pattern; if it fails, assume GNU syntax +gb_MKTEMP ?= /usr/bin/mktemp -t gbuild. 2>/dev/null || mktemp -t gbuild.XXXXXX gb_OSDEFS := \ -D$(OS) \ commit 74e411cc5e94f064e5605ac65d416ce0845b003b Author: Douglas Mencken <dougmenc...@gmail.com> Date: Sun Oct 5 18:02:00 2014 -0400 vcl: restore other bits of pre-10.8 conditional code related commits: 4fa8282816cb39692678e9da6b6693e821a3039b ec147012340219c8bb5eaf8fe3d41be7836bc261 16996c6b91b53e3c7d316296833bdb8a9cb60c22 Change-Id: Ie8962f8d26f163eed91fdf6b137b0d9830183dd2 diff --git a/vcl/osx/salframe.cxx b/vcl/osx/salframe.cxx index b9a7ac1..eab873c 100644 --- a/vcl/osx/salframe.cxx +++ b/vcl/osx/salframe.cxx @@ -1246,7 +1246,12 @@ void AquaSalFrame::UpdateSettings( AllSettings& rSettings ) getAppleScrollBarVariant(aStyleSettings); // set scrollbar size +#if MACOSX_SDK_VERSION >= 1070 aStyleSettings.SetScrollBarSize( static_cast<long int>([NSScroller scrollerWidthForControlSize:NSRegularControlSize scrollerStyle:NSScrollerStyleLegacy]) ); +#else + aStyleSettings.SetScrollBarSize( static_cast<long int>([NSScroller scrollerWidth]) ); +#endif + // images in menus false for MacOSX aStyleSettings.SetPreferredUseImagesInMenus( false ); aStyleSettings.SetHideDisabledMenuItems( true ); diff --git a/vcl/osx/salmenu.cxx b/vcl/osx/salmenu.cxx index 6ca04aa..315c025 100644 --- a/vcl/osx/salmenu.cxx +++ b/vcl/osx/salmenu.cxx @@ -880,7 +880,12 @@ Rectangle AquaSalMenu::GetMenuBarButtonRectPixel( sal_uInt16 i_nItemId, SalFrame if( ! pNSWin ) return Rectangle(); +#if MACOSX_SDK_VERSION >= 1070 NSRect aRect = [pNSWin convertRectToScreen:[pNSWin frame]]; +#else + NSRect aRect = [pNSWin frame]; + aRect.origin = [pNSWin convertBaseToScreen: NSMakePoint( 0, 0 )]; +#endif // make coordinates relative to reference frame static_cast<AquaSalFrame*>(i_pReferenceFrame)->CocoaToVCL( aRect.origin ); diff --git a/vcl/quartz/CTRunData.hxx b/vcl/quartz/CTRunData.hxx index 40c2a0a..a0666e5 100644 --- a/vcl/quartz/CTRunData.hxx +++ b/vcl/quartz/CTRunData.hxx @@ -10,8 +10,20 @@ #define CTRunData_Included #include "premac.h" +#if defined(MACOSX) && MACOSX_SDK_VERSION < 1080 +#include <ApplicationServices/ApplicationServices.h> +#if MACOSX_SDK_VERSION < 1060 +// The following symbols are SPI (System Programming Interface) in 10.5 +extern "C" { + void CTRunGetAdvances(CTRunRef run, CFRange range, CGSize buffer[]); + const CGSize* CTRunGetAdvancesPtr(CTRunRef run); + extern const CFStringRef kCTTypesetterOptionForcedEmbeddingLevel; +} +#endif +#else #include <CoreGraphics/CoreGraphics.h> #include <CoreText/CoreText.h> +#endif #include "postmac.h" class CTRunData diff --git a/vcl/quartz/ctfonts.cxx b/vcl/quartz/ctfonts.cxx index 7a0be09..699dff7 100644 --- a/vcl/quartz/ctfonts.cxx +++ b/vcl/quartz/ctfonts.cxx @@ -249,7 +249,11 @@ int CoreTextFontData::GetFontTable( const char pTagName[5], unsigned char* pResu // get the raw table length CTFontDescriptorRef pFontDesc = reinterpret_cast<CTFontDescriptorRef>( GetFontId()); CTFontRef rCTFont = CTFontCreateWithFontDescriptor( pFontDesc, 0.0, NULL); +#if defined(MACOSX) && MACOSX_SDK_VERSION < 1080 + const uint32_t opts( kCTFontTableOptionExcludeSynthetic ); +#else const uint32_t opts( kCTFontTableOptionNoOptions ); +#endif CFDataRef pDataRef = CTFontCopyTable( rCTFont, nTagCode, opts); CFRelease( rCTFont); if( !pDataRef) commit 375b4a0196e24765ed0cde7b3d5d04338b469b15 Author: Douglas Mencken <dougmenc...@gmail.com> Date: Sat Oct 25 03:58:37 2014 -0400 resurrect conditional code for OSX SDKs < 10.8 from "mass purge" plus, change MAC_OS_X_VERSION_MAX_ALLOWED/MAC_OS_X_VERSION_MIN_REQUIRED to MACOSX_SDK_VERSION reverted commits: b02e958fa0bf7d062a5b8aff03d22325e3068feb fe25090e992eefd0c43ca73b656632a650793b1a Modified: 24 files (19 from b02e958f + 6 from fe25090e - 1 common) Change-Id: Ib6e63e664dc073a8d751306f613e8be4918c406a diff --git a/external/curl/ExternalProject_curl.mk b/external/curl/ExternalProject_curl.mk index 1a0a0a3..f292437 100644 --- a/external/curl/ExternalProject_curl.mk +++ b/external/curl/ExternalProject_curl.mk @@ -45,7 +45,7 @@ $(call gb_ExternalProject_get_state_target,curl,build): $(if $(filter IOS MACOSX,$(OS)),,--with-nss$(if $(SYSTEM_NSS),,="$(call gb_UnpackedTarball_get_dir,nss)/dist/out")) \ $(if $(filter IOS,$(OS)),--with-darwinssl) \ $(if $(filter MACOSX,$(OS)),\ - --with-darwinssl) \ + $(if $(filter 1050,$(MACOSX_SDK_VERSION)),,--with-darwinssl)) \ --without-ssl \ --without-libidn --enable-ftp --enable-ipv6 --enable-http --disable-gopher \ --disable-file --disable-ldap --disable-telnet --disable-dict --without-libssh2 \ diff --git a/external/nss/ExternalPackage_nss.mk b/external/nss/ExternalPackage_nss.mk index c6d8953fd..986565e 100644 --- a/external/nss/ExternalPackage_nss.mk +++ b/external/nss/ExternalPackage_nss.mk @@ -26,6 +26,7 @@ $(eval $(call gb_ExternalPackage_add_files,nss,$(LIBO_LIB_FOLDER),\ dist/out/lib/libsmime3.dylib \ dist/out/lib/libsoftokn3.dylib \ dist/out/lib/libssl3.dylib \ + $(if $(filter 1050,$(MACOSX_SDK_VERSION)),dist/out/lib/libsqlite3.dylib) \ )) else ifeq ($(OS),WNT) $(eval $(call gb_ExternalPackage_add_files,nss,$(LIBO_LIB_FOLDER),\ diff --git a/external/nss/ExternalProject_nss.mk b/external/nss/ExternalProject_nss.mk index 17ea6f1..0706a39 100644 --- a/external/nss/ExternalProject_nss.mk +++ b/external/nss/ExternalProject_nss.mk @@ -65,7 +65,7 @@ $(call gb_ExternalProject_get_state_target,nss,build): $(call gb_ExternalProject $(if $(filter arm64,$(CC)),USE_64=1)) \ $(if $(filter MACOSX,$(OS)),\ $(if $(filter-out POWERPC,$(CPUNAME)),MACOS_SDK_DIR=$(MACOSX_SDK_PATH)) \ - NSS_USE_SYSTEM_SQLITE=1) \ + $(if $(filter-out 1050,$(MACOSX_SDK_VERSION)),NSS_USE_SYSTEM_SQLITE=1)) \ $(if $(filter SOLARIS,$(OS)),NS_USE_GCC=1) \ $(if $(CROSS_COMPILING),\ $(if $(filter MACOSXPOWERPC,$(OS)$(CPUNAME)),CPU_ARCH=ppc) \ diff --git a/external/python3/ExternalProject_python3.mk b/external/python3/ExternalProject_python3.mk index 045892e..54a9ad1 100644 --- a/external/python3/ExternalProject_python3.mk +++ b/external/python3/ExternalProject_python3.mk @@ -69,8 +69,8 @@ $(call gb_ExternalProject_get_state_target,python3,build) : $(if $(filter WNT-GCC,$(OS)-$(COM)),--with-threads ac_cv_printf_zd_format=no) \ $(if $(filter MACOSX,$(OS)), \ $(if $(filter INTEL,$(CPUNAME)),--enable-universalsdk=$(MACOSX_SDK_PATH) \ - --with-universal-archs=intel \ - ) \ + $(if $(filter 1050,$(MACOSX_SDK_VERSION)),--with-universal-archs=32-bit,--with-universal-archs=intel) \ + ) \ --enable-framework=/@__________________________________________________OOO --with-framework-name=LibreOfficePython, \ --enable-shared \ ) \ diff --git a/fpicker/source/aqua/FilterHelper.mm b/fpicker/source/aqua/FilterHelper.mm index cef9074..e078fb6 100644 --- a/fpicker/source/aqua/FilterHelper.mm +++ b/fpicker/source/aqua/FilterHelper.mm @@ -385,7 +385,11 @@ bool FilterHelper::filenameMatchesFilter(NSString* sFilename) } NSFileManager *manager = [NSFileManager defaultManager]; +#if MACOSX_SDK_VERSION < 1060 + NSDictionary* pAttribs = [manager fileAttributesAtPath: sFilename traverseLink: NO]; +#else NSDictionary* pAttribs = [manager attributesOfItemAtPath: sFilename error: nil]; +#endif if( pAttribs ) { NSObject* pType = [pAttribs objectForKey: NSFileType]; diff --git a/fpicker/source/aqua/NSURL_OOoAdditions.mm b/fpicker/source/aqua/NSURL_OOoAdditions.mm index 858eb27..8de8b7e 100644 --- a/fpicker/source/aqua/NSURL_OOoAdditions.mm +++ b/fpicker/source/aqua/NSURL_OOoAdditions.mm @@ -83,6 +83,25 @@ NSString* resolveAlias( NSString* i_pSystemPath ) kCFURLPOSIXPathStyle, false); if( rUrl != NULL ) { +#if MACOSX_SDK_VERSION < 1060 + FSRef rFS; + if( CFURLGetFSRef( rUrl, &rFS ) ) + { + Boolean bIsFolder = false; + Boolean bAlias = false; + OSErr err = FSResolveAliasFile( &rFS, true, &bIsFolder, &bAlias); + if( (err == noErr) && bAlias ) + { + CFURLRef rResolvedUrl = CFURLCreateFromFSRef( kCFAllocatorDefault, &rFS ); + if( rResolvedUrl != NULL ) + { + pResolvedPath = (NSString*)CFURLCopyFileSystemPath( rResolvedUrl, kCFURLPOSIXPathStyle ); + CFRelease( rResolvedUrl ); + } + } + } + CFRelease( rUrl ); +#else CFErrorRef rError; CFDataRef rBookmark = CFURLCreateBookmarkDataFromFile( NULL, rUrl, &rError ); CFRelease( rUrl ); @@ -102,6 +121,7 @@ NSString* resolveAlias( NSString* i_pSystemPath ) CFRelease( rResolvedUrl ); } } +#endif } return pResolvedPath; diff --git a/fpicker/source/aqua/SalAquaFilePicker.mm b/fpicker/source/aqua/SalAquaFilePicker.mm index 11e5ee6..86d1da3 100644 --- a/fpicker/source/aqua/SalAquaFilePicker.mm +++ b/fpicker/source/aqua/SalAquaFilePicker.mm @@ -307,7 +307,7 @@ uno::Sequence<rtl::OUString> SAL_CALL SalAquaFilePicker::getFiles() throw( uno:: SolarMutexGuard aGuard; -#if HAVE_FEATURE_MACOSX_SANDBOX +#if MACOSX_SDK_VERSION >= 1070 && HAVE_FEATURE_MACOSX_SANDBOX static NSUserDefaults *userDefaults; static bool triedUserDefaults = false; @@ -341,7 +341,7 @@ uno::Sequence<rtl::OUString> SAL_CALL SalAquaFilePicker::getFiles() throw( uno:: { NSURL *url = [files objectAtIndex:nIndex]; -#if HAVE_FEATURE_MACOSX_SANDBOX +#if MACOSX_SDK_VERSION >= 1070 && HAVE_FEATURE_MACOSX_SANDBOX if (userDefaults != NULL && [url respondsToSelector:@selector(bookmarkDataWithOptions:includingResourceValuesForKeys:relativeToURL:error:)]) { @@ -769,7 +769,11 @@ void SalAquaFilePicker::updateSaveFileNameExtension() { rtl::OUString suffix = (*(aStringList.begin())).copy(1); NSString *requiredFileType = [NSString stringWithOUString:suffix]; +#if MACOSX_SDK_VERSION < 1060 + [m_pDialog setRequiredFileType:requiredFileType]; +#else [m_pDialog setAllowedFileTypes:[NSArray arrayWithObjects:requiredFileType, nil]]; +#endif OSL_TRACE("disallowing other file types"); [m_pDialog setAllowsOtherFileTypes:NO]; diff --git a/fpicker/source/aqua/SalAquaPicker.mm b/fpicker/source/aqua/SalAquaPicker.mm index 125c34f..6d682f4 100644 --- a/fpicker/source/aqua/SalAquaPicker.mm +++ b/fpicker/source/aqua/SalAquaPicker.mm @@ -164,6 +164,19 @@ int SalAquaPicker::run() int retVal = 0; +#if MACOSX_SDK_VERSION < 1060 + NSString *startDirectory; + if (m_sDisplayDirectory.getLength() > 0) { + NSString *temp = [NSString stringWithOUString:m_sDisplayDirectory]; + NSURL *url = [NSURL URLWithString:temp]; + startDirectory = [url path]; + + OSL_TRACE("start dir: %s", [startDirectory UTF8String]); + } + else { + startDirectory = NSHomeDirectory(); + } +#else NSURL *startDirectory; if (m_sDisplayDirectory.getLength() > 0) { NSString *temp = [NSString stringWithOUString:m_sDisplayDirectory]; @@ -174,17 +187,26 @@ int SalAquaPicker::run() else { startDirectory = [NSURL fileURLWithPath:NSHomeDirectory() isDirectory:YES]; } +#endif switch(m_nDialogType) { case NAVIGATIONSERVICES_DIRECTORY: case NAVIGATIONSERVICES_OPEN: +#if MACOSX_SDK_VERSION < 1060 + retVal = [(NSOpenPanel*)m_pDialog runModalForDirectory:startDirectory file:nil types:nil]; +#else [m_pDialog setDirectoryURL:startDirectory]; retVal = [(NSOpenPanel*)m_pDialog runModal]; +#endif break; case NAVIGATIONSERVICES_SAVE: +#if MACOSX_SDK_VERSION < 1060 + retVal = [m_pDialog runModalForDirectory:startDirectory file:[NSString stringWithOUString:((SalAquaFilePicker*)this)->getSaveFileName()]]; +#else [m_pDialog setDirectoryURL:startDirectory]; [m_pDialog setNameFieldStringValue:[NSString stringWithOUString:((SalAquaFilePicker*)this)->getSaveFileName()]]; retVal = [m_pDialog runModal]; +#endif break; // [m_pDialog beginSheetForDirectory:startDirectory file:[m_pDialog saveFilename] modalForWindow:[NSApp keyWindow] modalDelegate:((SalAquaFilePicker*)this)->getDelegate() didEndSelector:@selector(savePanelDidEnd:returnCode:contextInfo:) contextInfo:nil]; default: @@ -192,10 +214,17 @@ int SalAquaPicker::run() } if (retVal == NSFileHandlingPanelOKButton) { +#if MACOSX_SDK_VERSION < 1060 + NSString* pDir = [m_pDialog directory]; + if (pDir) { + implsetDisplayDirectory([[NSURL fileURLWithPath:pDir] OUStringForInfo:FULLPATH]); + } +#else NSURL* pDir = [m_pDialog directoryURL]; if (pDir) { implsetDisplayDirectory([pDir OUStringForInfo:FULLPATH]); } +#endif } DBG_PRINT_EXIT(CLASS_NAME, __func__, retVal); diff --git a/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm b/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm index aa06d13..25f8f0d 100644 --- a/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm +++ b/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm @@ -350,7 +350,11 @@ Reference< XSpellAlternatives > aLang = [aLang stringByAppendingString:aTaggedCountry]; } [macSpell setLanguage:aLang]; +#if MACOSX_SDK_VERSION < 1060 + NSArray *guesses = [macSpell guessesForWord:aNSStr]; +#else NSArray *guesses = [macSpell guessesForWordRange:NSMakeRange(0, [aNSStr length]) inString:aNSStr language:aLang inSpellDocumentWithTag:0]; +#endif count = [guesses count]; if (count) { diff --git a/sal/osl/unx/memory.c b/sal/osl/unx/memory.c index e9fb9a8..f31c28c 100644 --- a/sal/osl/unx/memory.c +++ b/sal/osl/unx/memory.c @@ -24,6 +24,13 @@ void* osl_aligned_alloc( sal_Size align, sal_Size size ) { #if defined __ANDROID__ return memalign(align, size); +#elif defined MAC_OS_X_VERSION_MAX_ALLOWED && MAC_OS_X_VERSION_MAX_ALLOWED < 1060 + void* ptr = malloc(size + (align - 1) + sizeof(void*)); + if (!ptr) return NULL; + char* aptr = ((char*)ptr) + sizeof(void*); + aptr += (align - ((size_t)aptr & (align - 1))) & (align - 1); + ((void**)aptr)[-1] = ptr; + return aptr; #else void* ptr; int err = posix_memalign(&ptr, align, size); @@ -34,7 +41,11 @@ void* osl_aligned_alloc( sal_Size align, sal_Size size ) void osl_aligned_free( void* p ) { +#if defined MAC_OS_X_VERSION_MAX_ALLOWED && MAC_OS_X_VERSION_MAX_ALLOWED < 1060 + free(((void**)p)[-1]); +#else free(p); +#endif } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/unx/system.c b/sal/osl/unx/system.c index cb5734d..696e97f 100644 --- a/sal/osl/unx/system.c +++ b/sal/osl/unx/system.c @@ -157,10 +157,17 @@ int macxp_resolveAlias(char *path, int buflen) (void) buflen; return 0; #else +#if MACOSX_SDK_VERSION < 1060 + FSRef aFSRef; + OSStatus nErr; + Boolean bFolder; + Boolean bAliased; +#else CFStringRef cfpath; CFURLRef cfurl; CFErrorRef cferror; CFDataRef cfbookmark; +#endif char *unprocessedPath = path; @@ -174,6 +181,49 @@ int macxp_resolveAlias(char *path, int buflen) if ( unprocessedPath ) *unprocessedPath = '\0'; +#if MACOSX_SDK_VERSION < 1060 + nErr = noErr; + bFolder = FALSE; + bAliased = FALSE; + + if ( FSPathMakeRef( (const UInt8 *)path, &aFSRef, 0 ) == noErr ) + { + nErr = FSResolveAliasFileWithMountFlags( &aFSRef, TRUE, &bFolder, &bAliased, kResolveAliasFileNoUI ); + if ( nErr == nsvErr ) + { + errno = ENOENT; + nRet = -1; + } + else if ( nErr == noErr && bAliased ) + { + char tmpPath[ PATH_MAX ]; + if ( FSRefMakePath( &aFSRef, (UInt8 *)tmpPath, PATH_MAX ) == noErr ) + { + int nLen = strlen( tmpPath ) + ( unprocessedPath ? strlen( unprocessedPath + 1 ) + 1 : 0 ); + if ( nLen < buflen && nLen < PATH_MAX ) + { + if ( unprocessedPath ) + { + int nTmpPathLen = strlen( tmpPath ); + strcat( tmpPath, "/" ); + strcat( tmpPath, unprocessedPath + 1 ); + strcpy( path, tmpPath); + unprocessedPath = path + nTmpPathLen; + } + else if ( !unprocessedPath ) + { + strcpy( path, tmpPath); + } + } + else + { + errno = ENAMETOOLONG; + nRet = -1; + } + } + } + } +#else cfpath = CFStringCreateWithCString( NULL, path, kCFStringEncodingUTF8 ); cfurl = CFURLCreateWithFileSystemPath( NULL, cfpath, kCFURLPOSIXPathStyle, false ); CFRelease( cfpath ); @@ -233,6 +283,7 @@ int macxp_resolveAlias(char *path, int buflen) } } } +#endif if ( unprocessedPath ) *unprocessedPath++ = '/'; diff --git a/sal/osl/unx/uunxapi.cxx b/sal/osl/unx/uunxapi.cxx index 995b936..dd0d3f1 100644 --- a/sal/osl/unx/uunxapi.cxx +++ b/sal/osl/unx/uunxapi.cxx @@ -35,7 +35,7 @@ inline rtl::OString OUStringToOString(const rtl_uString* s) osl_getThreadTextEncoding()); } -#if HAVE_FEATURE_MACOSX_SANDBOX +#if defined(MACOSX) && MACOSX_SDK_VERSION >= 1070 && HAVE_FEATURE_MACOSX_SANDBOX #include <Foundation/Foundation.h> #include <Security/Security.h> @@ -289,7 +289,7 @@ int open_c(const char *cpPath, int oflag, int mode) int result = open(cpPath, oflag, mode); -#if HAVE_FEATURE_MACOSX_SANDBOX +#if defined(MACOSX) && MACOSX_SDK_VERSION >= 1070 && HAVE_FEATURE_MACOSX_SANDBOX if (isSandboxed && result != -1 && (oflag & O_CREAT) && (oflag & O_EXCL)) { // A new file was created. Check if it is outside the sandbox. diff --git a/vcl/inc/osx/salframe.h b/vcl/inc/osx/salframe.h index 7611b6d..47c1c91 100644 --- a/vcl/inc/osx/salframe.h +++ b/vcl/inc/osx/salframe.h @@ -93,7 +93,11 @@ public: sal_uLong mnICOptions; // To prevent display sleep during presentation +#if MACOSX_SDK_VERSION < 1060 + boost::shared_ptr< Timer > mpActivityTimer; +#else IOPMAssertionID mnAssertionID; +#endif public: /** Constructor diff --git a/vcl/inc/osx/salframeview.h b/vcl/inc/osx/salframeview.h index 93f8b8f..d125743 100644 --- a/vcl/inc/osx/salframeview.h +++ b/vcl/inc/osx/salframeview.h @@ -22,7 +22,11 @@ #include "osx/a11ywrapper.h" +#if MACOSX_SDK_VERSION < 1060 +@interface SalFrameWindow : NSWindow +#else @interface SalFrameWindow : NSWindow<NSWindowDelegate> +#endif { AquaSalFrame* mpFrame; id mDraggingDestinationHandler; @@ -59,7 +63,11 @@ -(void)unregisterDraggingDestinationHandler:(id)theHandler; @end +#if MACOSX_SDK_VERSION < 1060 +@interface SalFrameView : AquaA11yWrapper <NSTextInput> +#else @interface SalFrameView : AquaA11yWrapper <NSTextInputClient> +#endif { AquaSalFrame* mpFrame; @@ -113,7 +121,11 @@ /* text action methods */ +#if MACOSX_SDK_VERSION < 1060 +-(void)insertText:(id)aString; +#else -(void)insertText:(id)aString replacementRange:(NSRange)replacementRange; +#endif -(void)insertTab: (id)aSender; -(void)insertBacktab: (id)aSender; -(void)moveLeft: (id)aSender; diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h index 23d3bb3..1e823e5 100644 --- a/vcl/inc/quartz/salgdi.h +++ b/vcl/inc/quartz/salgdi.h @@ -29,6 +29,15 @@ #include <ApplicationServices/ApplicationServices.h> #include "osx/osxvcltypes.h" #include "osx/salframe.h" + +#if MACOSX_SDK_VERSION < 1060 +// The following symbols are SPI (System Programming Interface) in 10.5. +extern "C" { + void CTRunGetAdvances(CTRunRef run, CFRange range, CGSize buffer[]); + const CGSize* CTRunGetAdvancesPtr(CTRunRef run); + extern const CFStringRef kCTTypesetterOptionForcedEmbeddingLevel; +} +#endif #else #include <CoreGraphics/CoreGraphics.h> #include <CoreText/CoreText.h> diff --git a/vcl/osx/DropTarget.cxx b/vcl/osx/DropTarget.cxx index 7ee0f5b..2147cb9 100644 --- a/vcl/osx/DropTarget.cxx +++ b/vcl/osx/DropTarget.cxx @@ -264,9 +264,17 @@ NSDragOperation DropTarget::draggingUpdated(id sender) } if (dragOp == NSDragOperationNone) +#if MACOSX_SDK_VERSION < 1060 + SetThemeCursor(kThemeNotAllowedCursor); +#else [[NSCursor operationNotAllowedCursor] set]; +#endif else if (dragOp == NSDragOperationCopy) +#if MACOSX_SDK_VERSION < 1060 + SetThemeCursor(kThemeCopyArrowCursor); +#else [[NSCursor dragCopyCursor] set]; +#endif else [[NSCursor arrowCursor] set]; diff --git a/vcl/osx/salframe.cxx b/vcl/osx/salframe.cxx index f205caf..b9a7ac1 100644 --- a/vcl/osx/salframe.cxx +++ b/vcl/osx/salframe.cxx @@ -37,6 +37,11 @@ #include "osx/a11yfactory.h" #include "quartz/utils.h" +#if MACOSX_SDK_VERSION < 1060 +#include "vcl/timer.hxx" +#include "osx/saltimer.h" +#endif + #include "salwtype.hxx" #include "premac.h" @@ -193,7 +198,11 @@ void AquaSalFrame::initWindowAndView() [mpNSWindow setAcceptsMouseMovedEvents: YES]; [mpNSWindow setHasShadow: YES]; +#if MACOSX_SDK_VERSION < 1060 + objc_msgSend(mpNSWindow, @selector(setDelegate:), mpNSWindow); +#else [mpNSWindow setDelegate: static_cast<id<NSWindowDelegate> >(mpNSWindow)]; +#endif if( [mpNSWindow respondsToSelector: @selector(setRestorable:)]) { @@ -750,6 +759,27 @@ void AquaSalFrame::ShowFullScreen( bool bFullScreen, sal_Int32 nDisplay ) SendPaintEvent(); } +#if MACOSX_SDK_VERSION < 1060 +class PreventSleepTimer : public AutoTimer +{ +public: + PreventSleepTimer() + { + SetTimeout( 30000 ); + Start(); + } + + virtual ~PreventSleepTimer() + { + } + + virtual void Timeout() SAL_OVERRIDE + { + UpdateSystemActivity(OverallAct); + } +}; +#endif + void AquaSalFrame::StartPresentation( bool bStart ) { if ( !mpNSWindow ) @@ -761,10 +791,14 @@ void AquaSalFrame::StartPresentation( bool bStart ) if( bStart ) { GetSalData()->maPresentationFrames.push_back( this ); +#if MACOSX_SDK_VERSION < 1060 + mpActivityTimer.reset( new PreventSleepTimer() ); +#else /* OS X 10.6 and above */ IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, CFSTR("LibreOffice presentation running"), &mnAssertionID); +#endif [mpNSWindow setLevel: NSPopUpMenuWindowLevel]; if( mbShown ) [mpNSWindow makeMainWindow]; @@ -772,7 +806,11 @@ void AquaSalFrame::StartPresentation( bool bStart ) else { GetSalData()->maPresentationFrames.remove( this ); +#if MACOSX_SDK_VERSION < 1060 + mpActivityTimer.reset(); +#else IOPMAssertionRelease(mnAssertionID); +#endif [mpNSWindow setLevel: NSNormalWindowLevel]; } } diff --git a/vcl/osx/salframeview.mm b/vcl/osx/salframeview.mm index 98f3dad..2cf0136 100644 --- a/vcl/osx/salframeview.mm +++ b/vcl/osx/salframeview.mm @@ -34,6 +34,14 @@ #define WHEEL_EVENT_FACTOR 1.5 +// for allowing fullscreen support on deployment targets < OSX 10.7 +#if !defined(MAC_OS_X_VERSION_10_7) + #define NSWindowCollectionBehaviorFullScreenPrimary (1 << 7) + #define NSWindowCollectionBehaviorFullScreenAuxiliary (1 << 8) +// #define NSFullScreenWindowMask (1 << 14) +#endif + + static sal_uInt16 ImplGetModifierMask( unsigned int nMask ) { sal_uInt16 nRet = 0; @@ -158,6 +166,18 @@ static const struct ExceptionalKey static AquaSalFrame* getMouseContainerFrame() { AquaSalFrame* pDispatchFrame = NULL; +#if MACOSX_SDK_VERSION < 1060 + NSInteger nWindows = 0; + NSCountWindows( &nWindows ); + NSInteger* pWindows = (NSInteger*)alloca( nWindows * sizeof(NSInteger) ); + NSWindowList( nWindows, pWindows ); // NSWindowList is supposed to be in z-order front to back + for(int i = 0; i < nWindows && ! pDispatchFrame; i++ ) + { + NSWindow* pWin = [NSApp windowWithWindowNumber: pWindows[i]]; + if( pWin && [pWin isMemberOfClass: [SalFrameWindow class]] && [(SalFrameWindow*)pWin containsMouse] ) + pDispatchFrame = [(SalFrameWindow*)pWin getSalFrame]; + } +#else NSArray* aWindows = [NSWindow windowNumbersWithOptions:0]; for(NSUInteger i = 0; i < [aWindows count] && ! pDispatchFrame; i++ ) { @@ -165,6 +185,7 @@ static AquaSalFrame* getMouseContainerFrame() if( pWin && [pWin isMemberOfClass: [SalFrameWindow class]] && [(SalFrameWindow*)pWin containsMouse] ) pDispatchFrame = [(SalFrameWindow*)pWin getSalFrame]; } +#endif return pDispatchFrame; } @@ -755,11 +776,19 @@ private: if( bNewSeries ) mfMagnifyDeltaSum = 0.0; +#if MACOSX_SDK_VERSION < 1060 + mfMagnifyDeltaSum += [pEvent deltaZ]; +#else mfMagnifyDeltaSum += [pEvent magnification]; +#endif mfLastMagnifyTime = [pEvent timestamp]; // TODO: change to 0.1 when CommandWheelMode::ZOOM handlers allow finer zooming control +#if MACOSX_SDK_VERSION < 1060 + static const float fMagnifyFactor = 0.25; +#else static const float fMagnifyFactor = 0.25*500; // steps are 500 times smaller for -magnification +#endif static const float fMinMagnifyStep = 15.0 / fMagnifyFactor; if( fabs(mfMagnifyDeltaSum) <= fMinMagnifyStep ) return; @@ -1012,9 +1041,15 @@ private: } } +#if MACOSX_SDK_VERSION < 1060 +-(void)insertText:(id)aString +#else -(void)insertText:(id)aString replacementRange:(NSRange)replacementRange +#endif { +#if MACOSX_SDK_VERSION >= 1060 (void) replacementRange; // FIXME: surely it must be used +#endif YIELD_GUARD; @@ -1584,9 +1619,15 @@ private: return mSelectedRange; } +#if MACOSX_SDK_VERSION < 1060 +- (void)setMarkedText:(id)aString selectedRange:(NSRange)selRange +#else - (void)setMarkedText:(id)aString selectedRange:(NSRange)selRange replacementRange:(NSRange)replacementRange +#endif { +#if MACOSX_SDK_VERSION >= 1060 (void) replacementRange; // FIXME - use it! +#endif YIELD_GUARD; @@ -1656,10 +1697,16 @@ private: mSelectedRange = mMarkedRange = NSMakeRange(NSNotFound, 0); } +#if MACOSX_SDK_VERSION < 1060 +- (NSAttributedString *)attributedSubstringFromRange:(NSRange)aRange +#else - (NSAttributedString *)attributedSubstringForProposedRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange +#endif { (void) aRange; +#if MACOSX_SDK_VERSION >= 1060 (void) actualRange; +#endif // FIXME - Implement return nil; @@ -1703,11 +1750,17 @@ private: mpLastEvent = nil; } +#if MACOSX_SDK_VERSION < 1060 +- (NSRect)firstRectForCharacterRange:(NSRange)aRange +#else - (NSRect)firstRectForCharacterRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange +#endif { // FIXME - These should probably be used? (void) aRange; +#if MACOSX_SDK_VERSION >= 1060 (void) actualRange; +#endif YIELD_GUARD; diff --git a/vcl/osx/salinst.cxx b/vcl/osx/salinst.cxx index 71758b6..4336b4c 100644 --- a/vcl/osx/salinst.cxx +++ b/vcl/osx/salinst.cxx @@ -1046,7 +1046,12 @@ NSImage* CreateNSImage( const Image& rImage ) NSImage* pImage = [[NSImage alloc] initWithSize: NSMakeSize( aSize.Width(), aSize.Height() )]; if( pImage ) { +#if MACOSX_SDK_VERSION < 1060 + [pImage setFlipped:YES]; + [pImage lockFocus]; +#else [pImage lockFocusFlipped:YES]; +#endif NSGraphicsContext* pContext = [NSGraphicsContext currentContext]; CGContextRef rCGContext = reinterpret_cast<CGContextRef>([pContext graphicsPort]); diff --git a/vcl/osx/salmenu.cxx b/vcl/osx/salmenu.cxx index 6d13eed..6ca04aa 100644 --- a/vcl/osx/salmenu.cxx +++ b/vcl/osx/salmenu.cxx @@ -246,7 +246,11 @@ AquaSalMenu::AquaSalMenu( bool bMenuBar ) : if( ! mbMenuBar ) { mpMenu = [[SalNSMenu alloc] initWithMenu: this]; +#if MACOSX_SDK_VERSION < 1060 + objc_msgSend(mpMenu, @selector(setDelegate:), mpMenu); +#else [mpMenu setDelegate: (id<NSMenuDelegate>)mpMenu]; +#endif } else { diff --git a/vcl/osx/salprn.cxx b/vcl/osx/salprn.cxx index 9440bb3..c6f77c7 100644 --- a/vcl/osx/salprn.cxx +++ b/vcl/osx/salprn.cxx @@ -462,7 +462,11 @@ bool AquaSalInfoPrinter::StartJob( const OUString* i_pFileName, { [mpPrintInfo setJobDisposition: NSPrintSaveJob]; NSString* pPath = CreateNSString( *i_pFileName ); +#if MACOSX_SDK_VERSION < 1060 + [pPrintDict setObject:[NSURL fileURLWithPath:pPath] forKey:NSPrintSavePath]; +#else [pPrintDict setObject:[NSURL fileURLWithPath:pPath] forKey:NSPrintJobSavingURL]; +#endif [pPath release]; } diff --git a/vcl/quartz/ctfonts.cxx b/vcl/quartz/ctfonts.cxx index a11453c..7a0be09 100644 --- a/vcl/quartz/ctfonts.cxx +++ b/vcl/quartz/ctfonts.cxx @@ -83,9 +83,13 @@ CoreTextStyle::CoreTextStyle( const FontSelectPattern& rFSD ) ((mpFontData->GetWeight() < WEIGHT_SEMIBOLD) && (mpFontData->GetWeight() != WEIGHT_DONTKNOW)) ) { +#if MACOSX_SDK_VERSION >= 1060 int nStroke = -10.0; CFNumberRef rStroke = CFNumberCreate(NULL, kCFNumberSInt32Type, &nStroke); CFDictionarySetValue(mpStyleDict, kCTStrokeWidthAttributeName, rStroke); +#else /* kCTStrokeWidthAttributeName is not available */ + /* do we really need "fake" bold? */ +#endif } // fake italic @@ -315,8 +319,10 @@ ImplDevFontAttributes DevFontFromCTFontDescriptor( CTFontDescriptorRef pFD, bool // get font-enabled status if( bFontEnabled ) { int bEnabled = TRUE; // by default (and when we're on OS X < 10.6) it's "enabled" +#if MACOSX_SDK_VERSION >= 1060 CFNumberRef pEnabled = (CFNumberRef)CTFontDescriptorCopyAttribute( pFD, kCTFontEnabledAttribute ); CFNumberGetValue( pEnabled, kCFNumberIntType, &bEnabled ); +#endif *bFontEnabled = bEnabled; } diff --git a/vcl/quartz/ctlayout.cxx b/vcl/quartz/ctlayout.cxx index 3a42ebc..fd0db92 100644 --- a/vcl/quartz/ctlayout.cxx +++ b/vcl/quartz/ctlayout.cxx @@ -251,6 +251,11 @@ void CTLayout::AdjustLayout( ImplLayoutArgs& rArgs ) // - CoreText handles spaces specially (in particular at the text end) if( mnTrailingSpaceCount ) { +#if MACOSX_SDK_VERSION < 1070 + // don't recreate line layout here, because this can lead to problems + // (looks like internal issues inside early CoreText versions) + mfTrailingSpaceWidth = CTLineGetTrailingWhitespaceWidth( mpCTLine ); +#else if(mfTrailingSpaceWidth <= 0.0) { mfTrailingSpaceWidth = CTLineGetTrailingWhitespaceWidth( mpCTLine ); @@ -275,7 +280,7 @@ void CTLayout::AdjustLayout( ImplLayoutArgs& rArgs ) SAL_INFO( "vcl.ct", "CTLineCreateWithAttributedString(\"" << GetOUString(aCFText) << "\") = " << mpCTLine ); CFRelease( pAttrStr ); CFRelease( aCFText ); - +#endif // in RTL-layouts trailing spaces are leftmost // TODO: use BiDi-algorithm to thoroughly check this assumption if( rArgs.mnFlags & SAL_LAYOUT_BIDI_RTL) @@ -283,9 +288,12 @@ void CTLayout::AdjustLayout( ImplLayoutArgs& rArgs ) mfBaseAdv = mfTrailingSpaceWidth; } } +#if MACOSX_SDK_VERSION < 1070 + CTLineRef pNewCTLine = CTLineCreateJustifiedLine( mpCTLine, 1.0, nPixelWidth - mfTrailingSpaceWidth ); +#else CTLineRef pNewCTLine = CTLineCreateJustifiedLine( mpCTLine, 1.0, nPixelWidth); SAL_INFO( "vcl.ct", "CTLineCreateJustifiedLine(" << mpCTLine << ",1.0," << nPixelWidth << ") = " << pNewCTLine ); - +#endif if( !pNewCTLine ) { // CTLineCreateJustifiedLine can and does fail @@ -299,7 +307,11 @@ void CTLayout::AdjustLayout( ImplLayoutArgs& rArgs ) SAL_INFO( "vcl.ct", "CFRelease(" << mpCTLine << ")" ); CFRelease( mpCTLine ); mpCTLine = pNewCTLine; +#if MACOSX_SDK_VERSION < 1070 + mfCachedWidth = nPixelWidth; +#else mfCachedWidth = nPixelWidth + mfTrailingSpaceWidth; +#endif } } @@ -354,9 +366,13 @@ bool CTLayout::DrawTextSpecial( SalGraphics& rGraphics, sal_uInt32 flags ) const CFDictionaryGetCount(mpTextStyle->GetStyleDict()), mpTextStyle->GetStyleDict()); +#if MACOSX_SDK_VERSION < 1060 + /* just don't do 'kCTStrokeWidthAttributeName' */ +#else int nStroke = 2; CFNumberRef rStroke = CFNumberCreate(NULL, kCFNumberSInt32Type, &nStroke); CFDictionarySetValue(styledict, kCTStrokeWidthAttributeName, rStroke); +#endif CFAttributedStringRef pAttrStr = CFAttributedStringCreate( NULL, diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx index 2462ec0..f61d7ed 100644 --- a/vcl/quartz/salgdi.cxx +++ b/vcl/quartz/salgdi.cxx @@ -339,12 +339,28 @@ static bool AddTempDevFont(const OUString& rFontFileURL) bool success = false; +#if MACOSX_SDK_VERSION >= 1060 CFErrorRef error; success = CTFontManagerRegisterFontsForURL(rFontURL, kCTFontManagerScopeProcess, &error); if (!success) { CFRelease(error); } +#else /* CTFontManagerRegisterFontsForURL is not available on OS X <10.6 */ + CGDataProviderRef dataProvider = CGDataProviderCreateWithURL(rFontURL); + CGFontRef graphicsFont = CGFontCreateWithDataProvider(dataProvider); + if (graphicsFont) + { + CTFontRef coreTextFont = CTFontCreateWithGraphicsFont(graphicsFont, /*fontSize*/ 0, /*matrix*/ NULL, /*attributes*/ NULL); + if (coreTextFont) + { + success = true; + CFRelease(coreTextFont); + } + CGFontRelease(graphicsFont); + } + CGDataProviderRelease(dataProvider); +#endif return success; } commit f86b2dc36d777aef1c15cf09a5c00323f365f6ed Author: Douglas Mencken <dougmenc...@gmail.com> Date: Sun Oct 5 08:11:22 2014 -0400 avmediaMacAVF is not available on OS X 10.5/10.6 Related commit: 4fa8282816cb39692678e9da6b6693e821a3039b Change-Id: Ice433ac738096c4142cc78ce793f2b2f1e2a1708 diff --git a/avmedia/Module_avmedia.mk b/avmedia/Module_avmedia.mk index f0108e5..6a97e69 100644 --- a/avmedia/Module_avmedia.mk +++ b/avmedia/Module_avmedia.mk @@ -44,10 +44,14 @@ endif endif ifeq ($(OS),MACOSX) +ifneq (1050,$(MACOSX_SDK_VERSION)) +ifneq (1060,$(MACOSX_SDK_VERSION)) $(eval $(call gb_Module_add_targets,avmedia,\ Library_avmediaMacAVF \ )) endif +endif +endif ifneq ($(ENABLE_DIRECTX),) $(eval $(call gb_Module_add_targets,avmedia,\ diff --git a/postprocess/Rdb_services.mk b/postprocess/Rdb_services.mk index 220aeda..baedd09 100644 --- a/postprocess/Rdb_services.mk +++ b/postprocess/Rdb_services.mk @@ -124,7 +124,9 @@ $(eval $(call gb_Rdb_add_components,services,\ writerperfect/source/writer/wpftwriter \ writerperfect/source/calc/wpftcalc \ $(if $(filter MACOSX,$(OS)), \ - $(call gb_Helper_optional,AVMEDIA,avmedia/source/macavf/avmediaMacAVF) \ + $(if $(filter 1050 1060,$(MACOSX_SDK_VERSION)),, \ + $(call gb_Helper_optional,AVMEDIA,avmedia/source/macavf/avmediaMacAVF) \ + ) \ $(if $(filter TRUE,$(ENABLE_MACOSX_SANDBOX)),, \ $(call gb_Helper_optional,AVMEDIA,avmedia/source/quicktime/avmediaQuickTime) \ ) \ commit a9937326d0dfdab527d5e355a8c43ea69fd23afc Author: Douglas Mencken <dougmenc...@gmail.com> Date: Sun Oct 5 07:40:55 2014 -0400 Revert "PPC Mac support can go away now (again)" This reverts commit e29862bcc509916e7fe3e9b2f43b0672c49b7f6e. Change-Id: Ie6f7b94c2760b34f2b9e3ef7e619905ccb26892e diff --git a/bridges/Library_cpp_uno.mk b/bridges/Library_cpp_uno.mk index 5b7377a..ed76cca 100644 --- a/bridges/Library_cpp_uno.mk +++ b/bridges/Library_cpp_uno.mk @@ -150,6 +150,12 @@ bridge_noncallexception_noopt_objects := callvirtualmethod bridge_exception_objects := abi cpp2uno except uno2cpp endif +else ifeq ($(OS)-$(CPUNAME),MACOSX-POWERPC) + +bridges_SELECTED_BRIDGE := gcc3_macosx_powerpc +bridge_noopt_objects := uno2cpp +bridge_exception_objects := cpp2uno except + else ifeq ($(OS)-$(CPUNAME),SOLARIS-SPARC) bridges_SELECTED_BRIDGE := gcc3_solaris_sparc diff --git a/bridges/source/cpp_uno/gcc3_macosx_powerpc/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_macosx_powerpc/cpp2uno.cxx new file mode 100644 index 0000000..0cba20d --- /dev/null +++ b/bridges/source/cpp_uno/gcc3_macosx_powerpc/cpp2uno.cxx @@ -0,0 +1,732 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + + +#include <com/sun/star/uno/genfunc.hxx> +#include <uno/data.h> +#include <typelib/typedescription.hxx> + +#include "bridges/cpp_uno/shared/bridge.hxx" +#include "bridges/cpp_uno/shared/cppinterfaceproxy.hxx" +#include "bridges/cpp_uno/shared/types.hxx" +#include "bridges/cpp_uno/shared/vtablefactory.hxx" + +#include "share.hxx" + +using namespace ::com::sun::star::uno; + +namespace +{ + +static typelib_TypeClass cpp2uno_call( + bridges::cpp_uno::shared::CppInterfaceProxy * pThis, + const typelib_TypeDescription * pMemberTypeDescr, + typelib_TypeDescriptionReference * pReturnTypeRef, // 0 indicates void return + sal_Int32 nParams, typelib_MethodParameter * pParams, + void ** gpreg, void ** fpreg, void ** ovrflw, + sal_Int64 * pRegisterReturn /* space for register return */ ) +{ + int ng = 0; //number of gpr registers used + int nf = 0; //number of fpr regsiters used + + void ** pCppStack; //temporary stack pointer + + // gpreg: [ret *], this, [gpr params] + // fpreg: [fpr params] + // ovrflw: [gpr or fpr params (properly aligned)] + + // return + typelib_TypeDescription * pReturnTypeDescr = 0; + if (pReturnTypeRef) + TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef ); + + void * pUnoReturn = 0; + void * pCppReturn = 0; // complex return ptr: if != 0 && != pUnoReturn, reconversion need + + // handle optional return pointer + if (pReturnTypeDescr) + { + if (bridges::cpp_uno::shared::isSimpleType( pReturnTypeDescr )) + { + pUnoReturn = pRegisterReturn; // direct way for simple types + } + else // complex return via ptr (pCppReturn) + { + pCppReturn = *gpreg; + gpreg++; //ovrflw++; + ng++; + + pUnoReturn = (bridges::cpp_uno::shared::relatesToInterfaceType( pReturnTypeDescr ) + ? alloca( pReturnTypeDescr->nSize ) + : pCppReturn); // direct way + } + } + // pop "this" + gpreg++; //ovrflw++; + ng++; + + // stack space + OSL_ENSURE( sizeof(void *) == sizeof(sal_Int32), "### unexpected size!" ); + // parameters + void ** pUnoArgs = (void **)alloca( 4 * sizeof(void *) * nParams ); + void ** pCppArgs = pUnoArgs + nParams; + // indices of values this have to be converted (interface conversion cpp<=>uno) + sal_Int32 * pTempIndices = (sal_Int32 *)(pUnoArgs + (2 * nParams)); + // type descriptions for reconversions + typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pUnoArgs + (3 * nParams)); + + sal_Int32 nTempIndices = 0; + + for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos ) + { + const typelib_MethodParameter & rParam = pParams[nPos]; + typelib_TypeDescription * pParamTypeDescr = 0; + TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef ); + + if (!rParam.bOut && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr )) + // value + { + + switch (pParamTypeDescr->eTypeClass) + { + + case typelib_TypeClass_DOUBLE: + if (nf < 13) { + pCppArgs[nPos] = fpreg; + pUnoArgs[nPos] = fpreg; + nf++; + fpreg += 2; + } else { + if (((long)ovrflw) & 4) ovrflw++; + pCppArgs[nPos] = ovrflw; + pUnoArgs[nPos] = ovrflw; + ovrflw += 2; + } + break; + + case typelib_TypeClass_FLOAT: + // fpreg are all double values so need to + // modify fpreg to be a single word float value + if (nf < 13) { + float tmp = (float) (*((double *)fpreg)); + (*((float *) fpreg)) = tmp; + pCppArgs[nPos] = fpreg; + pUnoArgs[nPos] = fpreg; + nf++; + fpreg += 2; + } else { +#if 0 /* abi is not being followed correctly */ + if (((long)ovrflw) & 4) ovrflw++; + float tmp = (float) (*((double *)ovrflw)); + (*((float *) ovrflw)) = tmp; + pCppArgs[nPos] = ovrflw; + pUnoArgs[nPos] = ovrflw; + ovrflw += 2; +#else + pCppArgs[nPos] = ovrflw; + pUnoArgs[nPos] = ovrflw; + ovrflw += 1; +#endif + } + break; + + case typelib_TypeClass_HYPER: + case typelib_TypeClass_UNSIGNED_HYPER: + if (ng & 1) { + ng++; + gpreg++; + } + if (ng < 8) { + pCppArgs[nPos] = gpreg; + pUnoArgs[nPos] = gpreg; + ng += 2; + gpreg += 2; + } else { + if (((long)ovrflw) & 4) ovrflw++; + pCppArgs[nPos] = ovrflw; + pUnoArgs[nPos] = ovrflw; + ovrflw += 2; + } + break; + + case typelib_TypeClass_BYTE: + case typelib_TypeClass_BOOLEAN: + if (ng < 8) { + pCppArgs[nPos] = (((char *)gpreg) + 3); + pUnoArgs[nPos] = (((char *)gpreg) + 3); + ng++; + gpreg++; + } else { + pCppArgs[nPos] = (((char *)ovrflw) + 3); + pUnoArgs[nPos] = (((char *)ovrflw) + 3); + ovrflw++; + } + break; + + + case typelib_TypeClass_CHAR: + case typelib_TypeClass_SHORT: + case typelib_TypeClass_UNSIGNED_SHORT: + if (ng < 8) { + pCppArgs[nPos] = (((char *)gpreg)+ 2); + pUnoArgs[nPos] = (((char *)gpreg)+ 2); + ng++; + gpreg++; + } else { + pCppArgs[nPos] = (((char *)ovrflw) + 2); + pUnoArgs[nPos] = (((char *)ovrflw) + 2); + ovrflw++; + } + break; + + + default: + if (ng < 8) { + pCppArgs[nPos] = gpreg; + pUnoArgs[nPos] = gpreg; + ng++; + gpreg++; + } else { + pCppArgs[nPos] = ovrflw; + pUnoArgs[nPos] = ovrflw; + ovrflw++; + } + break; + + } + // no longer needed + TYPELIB_DANGER_RELEASE( pParamTypeDescr ); + } + else // ptr to complex value | ref + { + + if (ng < 8) { + pCppArgs[nPos] = *(void **)gpreg; + pCppStack = gpreg; + ng++; + gpreg++; + } else { + pCppArgs[nPos] = *(void **)ovrflw; + pCppStack = ovrflw; + ovrflw++; + } + + if (! rParam.bIn) // is pure out + { + // uno out is unconstructed mem! + pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize ); + pTempIndices[nTempIndices] = nPos; + // will be released at reconversion + ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr; + } + // is in/inout + else if (bridges::cpp_uno::shared::relatesToInterfaceType( pParamTypeDescr )) + { + uno_copyAndConvertData( pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize ), + *(void **)pCppStack, pParamTypeDescr, + pThis->getBridge()->getCpp2Uno() ); + pTempIndices[nTempIndices] = nPos; // has to be reconverted + // will be released at reconversion + ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr; + } + else // direct way + { + pUnoArgs[nPos] = *(void **)pCppStack; + // no longer needed + TYPELIB_DANGER_RELEASE( pParamTypeDescr ); + } + } + } + + // ExceptionHolder + uno_Any aUnoExc; // Any will be constructed by callee + uno_Any * pUnoExc = &aUnoExc; + + // invoke uno dispatch call + (*pThis->getUnoI()->pDispatcher)( pThis->getUnoI(), pMemberTypeDescr, pUnoReturn, pUnoArgs, &pUnoExc ); + + // in case an exception occurred... + if (pUnoExc) + { + // destruct temporary in/inout params + for ( ; nTempIndices--; ) + { + sal_Int32 nIndex = pTempIndices[nTempIndices]; + + if (pParams[nIndex].bIn) // is in/inout => was constructed + uno_destructData( pUnoArgs[nIndex], ppTempParamTypeDescr[nTempIndices], 0 ); + TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndices] ); + } + if (pReturnTypeDescr) + TYPELIB_DANGER_RELEASE( pReturnTypeDescr ); + + CPPU_CURRENT_NAMESPACE::raiseException( &aUnoExc, pThis->getBridge()->getUno2Cpp() ); + // has to destruct the any + // is here for dummy + return typelib_TypeClass_VOID; + } + else // else no exception occurred... + { + // temporary params + for ( ; nTempIndices--; ) + { + sal_Int32 nIndex = pTempIndices[nTempIndices]; + typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndices]; + + if (pParams[nIndex].bOut) // inout/out + { + // convert and assign + uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release ); + uno_copyAndConvertData( pCppArgs[nIndex], pUnoArgs[nIndex], pParamTypeDescr, + pThis->getBridge()->getUno2Cpp() ); + } + // destroy temp uno param + uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); + + TYPELIB_DANGER_RELEASE( pParamTypeDescr ); + } + // return + if (pCppReturn) // has complex return + { + if (pUnoReturn != pCppReturn) // needs reconversion + { + uno_copyAndConvertData( pCppReturn, pUnoReturn, pReturnTypeDescr, + pThis->getBridge()->getUno2Cpp() ); + // destroy temp uno return + uno_destructData( pUnoReturn, pReturnTypeDescr, 0 ); + } + // complex return ptr is set to return reg + *(void **)pRegisterReturn = pCppReturn; + } + if (pReturnTypeDescr) + { + typelib_TypeClass eRet = (typelib_TypeClass)pReturnTypeDescr->eTypeClass; + TYPELIB_DANGER_RELEASE( pReturnTypeDescr ); + return eRet; + } + else + return typelib_TypeClass_VOID; + } +} + + +static typelib_TypeClass cpp_mediate( + sal_Int32 nFunctionIndex, + sal_Int32 nVtableOffset, + void ** gpreg, void ** fpreg, void ** ovrflw, + sal_Int64 * pRegisterReturn /* space for register return */ ) +{ + OSL_ENSURE( sizeof(sal_Int32)==sizeof(void *), "### unexpected!" ); + + // gpreg: [ret *], this, [other gpr params] + // fpreg: [fpr params] + // ovrflw: [gpr or fpr params (properly aligned)] + + void * pThis; + if (nFunctionIndex & 0x80000000 ) + { + nFunctionIndex &= 0x7fffffff; + pThis = gpreg[1]; + } + else + { + pThis = gpreg[0]; + } + + pThis = static_cast< char * >(pThis) - nVtableOffset; + bridges::cpp_uno::shared::CppInterfaceProxy * pCppI + = bridges::cpp_uno::shared::CppInterfaceProxy::castInterfaceToProxy( + pThis); + + typelib_InterfaceTypeDescription * pTypeDescr = pCppI->getTypeDescr(); + + OSL_ENSURE( nFunctionIndex < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" ); + if (nFunctionIndex >= pTypeDescr->nMapFunctionIndexToMemberIndex) + { + throw RuntimeException( "illegal vtable index!", (XInterface *)pThis ); + } + + // determine called method + sal_Int32 nMemberPos = pTypeDescr->pMapFunctionIndexToMemberIndex[nFunctionIndex]; + OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### illegal member index!" ); + + TypeDescription aMemberDescr( pTypeDescr->ppAllMembers[nMemberPos] ); + + typelib_TypeClass eRet; + switch (aMemberDescr.get()->eTypeClass) + { + case typelib_TypeClass_INTERFACE_ATTRIBUTE: + { + if (pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos] == nFunctionIndex) + { + // is GET method + eRet = cpp2uno_call( + pCppI, aMemberDescr.get(), + ((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef, + 0, 0, // no params + gpreg, fpreg, ovrflw, pRegisterReturn ); + } + else + { + // is SET method + typelib_MethodParameter aParam; + aParam.pTypeRef = + ((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef; + aParam.bIn = sal_True; + aParam.bOut = sal_False; + + eRet = cpp2uno_call( + pCppI, aMemberDescr.get(), + 0, // indicates void return + 1, &aParam, + gpreg, fpreg, ovrflw, pRegisterReturn ); + } + break; + } + case typelib_TypeClass_INTERFACE_METHOD: + { + // is METHOD + switch (nFunctionIndex) + { + case 1: // acquire() + pCppI->acquireProxy(); // non virtual call! + eRet = typelib_TypeClass_VOID; + break; + case 2: // release() + pCppI->releaseProxy(); // non virtual call! + eRet = typelib_TypeClass_VOID; + break; + case 0: // queryInterface() opt + { + typelib_TypeDescription * pTD = 0; + TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( gpreg[2] )->getTypeLibType() ); + if (pTD) + { + XInterface * pInterface = 0; + (*pCppI->getBridge()->getCppEnv()->getRegisteredInterface)( + pCppI->getBridge()->getCppEnv(), + (void **)&pInterface, pCppI->getOid().pData, + (typelib_InterfaceTypeDescription *)pTD ); + + if (pInterface) + { + ::uno_any_construct( + reinterpret_cast< uno_Any * >( gpreg[0] ), + &pInterface, pTD, cpp_acquire ); + pInterface->release(); + TYPELIB_DANGER_RELEASE( pTD ); + *(void **)pRegisterReturn = gpreg[0]; + eRet = typelib_TypeClass_ANY; + break; + } + TYPELIB_DANGER_RELEASE( pTD ); + } + } // else perform queryInterface() + default: + eRet = cpp2uno_call( + pCppI, aMemberDescr.get(), + ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pReturnTypeRef, + ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->nParams, + ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pParams, + gpreg, fpreg, ovrflw, pRegisterReturn ); + } + break; + } + default: + { + throw RuntimeException( "no member description found!", (XInterface *)pThis ); + } + } + + return eRet; +} + +/** + * is called on incoming vtable calls + * (called by asm snippets) + */ +static void cpp_vtable_call( int nFunctionIndex, int nVtableOffset, void** gpregptr, void** fpregptr, void** ovrflw) +{ + sal_Int32 gpreg[8]; + memcpy(gpreg, gpregptr, 32); + + double fpreg[13]; + memcpy(fpreg, fpregptr, 13*8); + + volatile long nRegReturn[2]; + + // fprintf(stderr,"in cpp_vtable_call nFunctionIndex is %x\n",nFunctionIndex); + // fprintf(stderr,"in cpp_vtable_call nVtableOffset is %x\n",nVtableOffset); + // fflush(stderr); + + typelib_TypeClass aType = + cpp_mediate( nFunctionIndex, nVtableOffset, (void**)gpreg, + (void**)fpreg, + ovrflw, (sal_Int64*)nRegReturn ); + + switch( aType ) + { + // move return value into register space + // (will be loaded by machine code snippet) + + case typelib_TypeClass_BOOLEAN: + case typelib_TypeClass_BYTE: + __asm__( "lbz r3,%0" : : + "m"(nRegReturn[0]) ); + break; + + case typelib_TypeClass_CHAR: + case typelib_TypeClass_SHORT: + case typelib_TypeClass_UNSIGNED_SHORT: + __asm__( "lhz r3,%0" : : + "m"(nRegReturn[0]) ); + break; + + case typelib_TypeClass_FLOAT: + __asm__( "lfs f1,%0" : : + "m" (*((float*)nRegReturn)) ); + break; + + case typelib_TypeClass_DOUBLE: + __asm__( "lfd f1,%0" : : + "m" (*((double*)nRegReturn)) ); + break; + + case typelib_TypeClass_HYPER: + case typelib_TypeClass_UNSIGNED_HYPER: + __asm__( "lwz r4,%0" : : + "m"(nRegReturn[1]) ); + // no break, fall through + + default: + __asm__( "lwz r3,%0" : : + "m"(nRegReturn[0]) ); + break; + } +} + + +int const codeSnippetSize = 136; + +unsigned char * codeSnippet( unsigned char * code, sal_Int32 functionIndex, sal_Int32 vtableOffset, + bool simpleRetType) +{ + + // fprintf(stderr,"in codeSnippet functionIndex is %x\n", functionIndex); + // fprintf(stderr,"in codeSnippet vtableOffset is %x\n", vtableOffset); + // fflush(stderr); + + if (! simpleRetType ) + functionIndex |= 0x80000000; + + unsigned long * p = (unsigned long *) code; + + // OSL_ASSERT( sizeof (long) == 4 ); + OSL_ASSERT((((unsigned long)code) & 0x3) == 0 ); //aligned to 4 otherwise a mistake + + /* generate this code */ + // # so first save gpr 3 to gpr 10 (aligned to 4) + // stw r3,-2048(r1) + // stw r4,-2044(r1) + // stw r5,-2040(r1) + // stw r6,-2036(r1) + // stw r7,-2032(r1) + // stw r8,-2028(r1) + // stw r9,-2024(r1) + // stw r10,-2020(r1) + + + // # next save fpr 1 to fpr 13 (aligned to 8) + // if dedicated floating point registers are used + // stfd f1,-2016(r1) + // stfd f2,-2008(r1) + // stfd f3,-2000(r1) + // stfd f4,-1992(r1) + // stfd f5,-1984(r1) + // stfd f6,-1976(r1) + // stfd f7,-1968(r1) + // stfd f8,-1960(r1) + // stfd f9,-1952(r1) + // stfd f10,-1944(r1) + // stfd f11,-1936(r1) + // stfd f12,-1928(r1) + // stfd f13,-1920(r1) + + // # now here is where cpp_vtable_call must go + // lis r3,0xdead + // ori r3,r3,0xbeef + // mtctr r3 + + // # now load up the functionIndex + // lis r3,0xdead + // ori r3,r3,0xbeef + + // # now load up the vtableOffset + // lis r4,0xdead + // ori r4,r4,0xbeef + + // #now load up the pointer to the saved gpr registers + // addi r5,r1,-2048 + + // #now load up the pointer to the saved fpr registers + // addi r6,r1,-2016 + // if no dedicated floating point registers are used than we have NULL + // pointer there + // li r6, 0 + // + + // #now load up the pointer to the overflow call stack + // addi r7,r1,24 # frame pointer + 24 + // bctr + + * p++ = 0x9061f800; + * p++ = 0x9081f804; + * p++ = 0x90a1f808; + * p++ = 0x90c1f80c; + * p++ = 0x90e1f810; + * p++ = 0x9101f814; + * p++ = 0x9121f818; + * p++ = 0x9141f81c; + + * p++ = 0xd821f820; + * p++ = 0xd841f828; + * p++ = 0xd861f830; + * p++ = 0xd881f838; + * p++ = 0xd8a1f840; + * p++ = 0xd8c1f848; + * p++ = 0xd8e1f850; + * p++ = 0xd901f858; + * p++ = 0xd921f860; + * p++ = 0xd941f868; + * p++ = 0xd961f870; + * p++ = 0xd981f878; + * p++ = 0xd9a1f880; + + * p++ = 0x3c600000 | (((unsigned long)cpp_vtable_call) >> 16); + * p++ = 0x60630000 | (((unsigned long)cpp_vtable_call) & 0x0000FFFF); + * p++ = 0x7c6903a6; + * p++ = 0x3c600000 | (((unsigned long)functionIndex) >> 16); + * p++ = 0x60630000 | (((unsigned long)functionIndex) & 0x0000FFFF); + * p++ = 0x3c800000 | (((unsigned long)vtableOffset) >> 16); + * p++ = 0x60840000 | (((unsigned long)vtableOffset) & 0x0000FFFF); + * p++ = 0x38a1f800; + * p++ = 0x38c1f820; + * p++ = 0x38e10018; + * p++ = 0x4e800420; + return (code + codeSnippetSize); + +} + + +} + +void bridges::cpp_uno::shared::VtableFactory::flushCode(unsigned char const * bptr, unsigned char const * eptr) +{ + int const lineSize = 32; + for (unsigned char const * p = bptr; p < eptr + lineSize; p += lineSize) { + __asm__ volatile ("dcbst 0, %0" : : "r"(p) : "memory"); + } + __asm__ volatile ("sync" : : : "memory"); + for (unsigned char const * p = bptr; p < eptr + lineSize; p += lineSize) { + __asm__ volatile ("icbi 0, %0" : : "r"(p) : "memory"); + } + __asm__ volatile ("isync" : : : "memory"); +} + +struct bridges::cpp_uno::shared::VtableFactory::Slot { void * fn; }; + +bridges::cpp_uno::shared::VtableFactory::Slot * +bridges::cpp_uno::shared::VtableFactory::mapBlockToVtable(void * block) +{ + return static_cast< Slot * >(block) + 2; +} + +sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize( + sal_Int32 slotCount) +{ + return (slotCount + 2) * sizeof (Slot) + slotCount * codeSnippetSize; +} + +bridges::cpp_uno::shared::VtableFactory::Slot * +bridges::cpp_uno::shared::VtableFactory::initializeBlock( + void * block, sal_Int32 slotCount, sal_Int32, + typelib_InterfaceTypeDescription *) +{ + Slot * slots = mapBlockToVtable(block); + slots[-2].fn = 0; + slots[-1].fn = 0; + return slots + slotCount; +} + +unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions( + Slot ** slots, unsigned char * code, + typelib_InterfaceTypeDescription const * type, sal_Int32 functionOffset, + sal_Int32 functionCount, sal_Int32 vtableOffset) +{ + (*slots) -= functionCount; + Slot * s = *slots; + // fprintf(stderr, "in addLocalFunctions functionOffset is %x\n",functionOffset); + // fprintf(stderr, "in addLocalFunctions vtableOffset is %x\n",vtableOffset); + // fflush(stderr); + + for (sal_Int32 i = 0; i < type->nMembers; ++i) { + typelib_TypeDescription * member = 0; + TYPELIB_DANGER_GET(&member, type->ppMembers[i]); + OSL_ASSERT(member != 0); + switch (member->eTypeClass) { + case typelib_TypeClass_INTERFACE_ATTRIBUTE: + // Getter: + (s++)->fn = code; + code = codeSnippet( + code, functionOffset++, vtableOffset, + bridges::cpp_uno::shared::isSimpleType( + reinterpret_cast< + typelib_InterfaceAttributeTypeDescription * >( + member)->pAttributeTypeRef)); + + // Setter: + if (!reinterpret_cast< + typelib_InterfaceAttributeTypeDescription * >( + member)->bReadOnly) + { + (s++)->fn = code; + code = codeSnippet(code, functionOffset++, vtableOffset, true); + } + break; + + case typelib_TypeClass_INTERFACE_METHOD: + (s++)->fn = code; + code = codeSnippet( + code, functionOffset++, vtableOffset, + bridges::cpp_uno::shared::isSimpleType( + reinterpret_cast< + typelib_InterfaceMethodTypeDescription * >( + member)->pReturnTypeRef)); + break; + + default: + OSL_ASSERT(false); + break; + } + TYPELIB_DANGER_RELEASE(member); + } + return code; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/gcc3_macosx_powerpc/except.cxx b/bridges/source/cpp_uno/gcc3_macosx_powerpc/except.cxx new file mode 100644 index 0000000..585161f --- /dev/null +++ b/bridges/source/cpp_uno/gcc3_macosx_powerpc/except.cxx @@ -0,0 +1,273 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + + +#include <stdio.h> +#include <dlfcn.h> +#include <cxxabi.h> +#include <boost/unordered_map.hpp> + +#include <rtl/strbuf.hxx> +#include <rtl/ustrbuf.hxx> +#include <osl/diagnose.h> +#include <osl/mutex.hxx> + +#include <com/sun/star/uno/genfunc.hxx> +#include <typelib/typedescription.hxx> +#include <uno/any2.h> + +#include "share.hxx" + + +using namespace ::std; +using namespace ::osl; +using namespace ::rtl; +using namespace ::com::sun::star::uno; +using namespace ::__cxxabiv1; + + +namespace CPPU_CURRENT_NAMESPACE +{ + +void dummy_can_throw_anything( char const * ) +{ +} + +static OUString toUNOname( char const * p ) +{ +#if OSL_DEBUG_LEVEL > 1 + char const * start = p; +#endif + + // example: N3com3sun4star4lang24IllegalArgumentExceptionE + + OUStringBuffer buf( 64 ); + OSL_ASSERT( 'N' == *p ); + ++p; // skip N + + while ('E' != *p) + { + // read chars count + long n = (*p++ - '0'); + while ('0' <= *p && '9' >= *p) + { + n *= 10; + n += (*p++ - '0'); + } + buf.appendAscii( p, n ); + p += n; + if ('E' != *p) + buf.append( '.' ); + } + +#if OSL_DEBUG_LEVEL > 1 + OUString ret( buf.makeStringAndClear() ); + OString c_ret( OUStringToOString( ret, RTL_TEXTENCODING_ASCII_US ) ); + fprintf( stderr, "> toUNOname(): %s => %s\n", start, c_ret.getStr() ); + return ret; +#else + return buf.makeStringAndClear(); +#endif +} + +class RTTI +{ + typedef boost::unordered_map< OUString, type_info *, OUStringHash > t_rtti_map; + + Mutex m_mutex; + t_rtti_map m_rttis; + t_rtti_map m_generatedRttis; + + void * m_hApp; + +public: + RTTI(); + ~RTTI(); + + type_info * getRTTI( typelib_CompoundTypeDescription * ); +}; + +RTTI::RTTI() + : m_hApp( dlopen( 0, RTLD_LAZY ) ) +{ +} + +RTTI::~RTTI() +{ + dlclose( m_hApp ); +} + + +type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) +{ + type_info * rtti; + + OUString const & unoName = *(OUString const *)&pTypeDescr->aBase.pTypeName; + + MutexGuard guard( m_mutex ); + t_rtti_map::const_iterator iRttiFind( m_rttis.find( unoName ) ); + if (iRttiFind == m_rttis.end()) + { + // RTTI symbol + OStringBuffer buf( 64 ); + buf.append( "_ZTIN" ); + sal_Int32 index = 0; + do + { + OUString token( unoName.getToken( 0, '.', index ) ); + buf.append( token.getLength() ); + OString c_token( OUStringToOString( token, RTL_TEXTENCODING_ASCII_US ) ); + buf.append( c_token ); + } + while (index >= 0); + buf.append( 'E' ); + + OString symName( buf.makeStringAndClear() ); + rtti = (type_info *)dlsym( m_hApp, symName.getStr() ); + + if (rtti) + { + pair< t_rtti_map::iterator, bool > insertion( + m_rttis.insert( t_rtti_map::value_type( unoName, rtti ) ) ); + OSL_ENSURE( insertion.second, "### inserting new rtti failed?!" ); + } + else + { + // try to lookup the symbol in the generated rtti map + t_rtti_map::const_iterator iFind( m_generatedRttis.find( unoName ) ); + if (iFind == m_generatedRttis.end()) + { + // we must generate it ! + // symbol and rtti-name is nearly identical, + // the symbol is prefixed with _ZTI + char const * rttiName = symName.getStr() +4; +#if OSL_DEBUG_LEVEL > 1 + fprintf( stderr,"generated rtti for %s\n", rttiName ); +#endif + if (pTypeDescr->pBaseTypeDescription) + { + // ensure availability of base + type_info * base_rtti = getRTTI( + (typelib_CompoundTypeDescription *)pTypeDescr->pBaseTypeDescription ); + rtti = new __si_class_type_info( + strdup( rttiName ), (__class_type_info *)base_rtti ); + } + else + { + // this class has no base class + rtti = new __class_type_info( strdup( rttiName ) ); + } + + pair< t_rtti_map::iterator, bool > insertion( + m_generatedRttis.insert( t_rtti_map::value_type( unoName, rtti ) ) ); + OSL_ENSURE( insertion.second, "### inserting new generated rtti failed?!" ); + } + else // taking already generated rtti + { + rtti = iFind->second; + } + } + } + else + { + rtti = iRttiFind->second; + } + + return rtti; +} + + +static void deleteException( void * pExc ) +{ + __cxa_exception const * header = ((__cxa_exception const *)pExc - 1); + typelib_TypeDescription * pTD = 0; + OUString unoName( toUNOname( header->exceptionType->name() ) ); + ::typelib_typedescription_getByName( &pTD, unoName.pData ); + OSL_ENSURE( pTD, "### unknown exception type! leaving out destruction => leaking!!!" ); + if (pTD) + { + ::uno_destructData( pExc, pTD, cpp_release ); + ::typelib_typedescription_release( pTD ); + } +} + +void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ) +{ + void * pCppExc; + type_info * rtti; + + { + // construct cpp exception object + typelib_TypeDescription * pTypeDescr = 0; + TYPELIB_DANGER_GET( &pTypeDescr, pUnoExc->pType ); + OSL_ASSERT( pTypeDescr ); + if (! pTypeDescr) + terminate(); + + pCppExc = __cxa_allocate_exception( pTypeDescr->nSize ); + ::uno_copyAndConvertData( pCppExc, pUnoExc->pData, pTypeDescr, pUno2Cpp ); + + // destruct uno exception + ::uno_any_destruct( pUnoExc, 0 ); + // avoiding locked counts + static RTTI * s_rtti = 0; + if (! s_rtti) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + if (! s_rtti) + { +#ifdef LEAK_STATIC_DATA + s_rtti = new RTTI(); +#else + static RTTI rtti_data; + s_rtti = &rtti_data; +#endif + } + } + rtti = (type_info *)s_rtti->getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); + TYPELIB_DANGER_RELEASE( pTypeDescr ); + OSL_ENSURE( rtti, "### no rtti for throwing exception!" ); + if (! rtti) + terminate(); + } + + __cxa_throw( pCppExc, rtti, deleteException ); +} + +void fillUnoException( __cxa_exception * header, uno_Any * pExc, uno_Mapping * pCpp2Uno ) +{ + OSL_ENSURE( header, "### no exception header!!!" ); + if (! header) + terminate(); + + typelib_TypeDescription * pExcTypeDescr = 0; + OUString unoName( toUNOname( header->exceptionType->name() ) ); + ::typelib_typedescription_getByName( &pExcTypeDescr, unoName.pData ); + OSL_ENSURE( pExcTypeDescr, "### can not get type description for exception!!!" ); + if (! pExcTypeDescr) + terminate(); + + // construct uno exception any + ::uno_any_constructAndConvert( pExc, header->adjustedPtr, pExcTypeDescr, pCpp2Uno ); + ::typelib_typedescription_release( pExcTypeDescr ); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/gcc3_macosx_powerpc/share.hxx b/bridges/source/cpp_uno/gcc3_macosx_powerpc/share.hxx new file mode 100644 index 0000000..4b9fb96 --- /dev/null +++ b/bridges/source/cpp_uno/gcc3_macosx_powerpc/share.hxx @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_BRIDGES_SOURCE_CPP_UNO_GCC3_MACOSX_POWERPC_SHARE_HXX +#define INCLUDED_BRIDGES_SOURCE_CPP_UNO_GCC3_MACOSX_POWERPC_SHARE_HXX + +#include "uno/mapping.h" + +#include <typeinfo> +#include <exception> +#include <cstddef> + +namespace CPPU_CURRENT_NAMESPACE +{ + + void dummy_can_throw_anything( char const * ); + + +// ----- following decl from libstdc++-v3/libsupc++/unwind-cxx.h and unwind.h + +struct _Unwind_Exception +{ + unsigned exception_class __attribute__((__mode__(__DI__))); + void * exception_cleanup; + unsigned private_1 __attribute__((__mode__(__word__))); + unsigned private_2 __attribute__((__mode__(__word__))); +} __attribute__((__aligned__)); + +struct __cxa_exception +{ + ::std::type_info *exceptionType; + void (*exceptionDestructor)(void *); + + ::std::unexpected_handler unexpectedHandler; + ::std::terminate_handler terminateHandler; + + __cxa_exception *nextException; + + int handlerCount; + + int handlerSwitchValue; + const unsigned char *actionRecord; + const unsigned char *languageSpecificData; + void *catchTemp; + void *adjustedPtr; + + _Unwind_Exception unwindHeader; +}; + +extern "C" void *__cxa_allocate_exception( + std::size_t thrown_size ) throw(); +extern "C" void __cxa_throw ( + void *thrown_exception, std::type_info *tinfo, void (*dest) (void *) ) __attribute__((noreturn)); + +struct __cxa_eh_globals +{ + __cxa_exception *caughtExceptions; + unsigned int uncaughtExceptions; +}; +extern "C" __cxa_eh_globals *__cxa_get_globals () throw(); + + +void raiseException( + uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ); + +void fillUnoException( + __cxa_exception * header, uno_Any *, uno_Mapping * pCpp2Uno ); +} + +#endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/gcc3_macosx_powerpc/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_macosx_powerpc/uno2cpp.cxx new file mode 100644 index 0000000..10fd194 --- /dev/null +++ b/bridges/source/cpp_uno/gcc3_macosx_powerpc/uno2cpp.cxx @@ -0,0 +1,647 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + + +#include <sys/types.h> +#include <sys/malloc.h> + +#include <com/sun/star/uno/genfunc.hxx> +#include <uno/data.h> + +#include "bridges/cpp_uno/shared/bridge.hxx" +#include "bridges/cpp_uno/shared/types.hxx" +#include "bridges/cpp_uno/shared/unointerfaceproxy.hxx" +#include "bridges/cpp_uno/shared/vtables.hxx" + +#include "share.hxx" + + +using namespace ::rtl; +using namespace ::com::sun::star::uno; + +namespace +{ + + +static void callVirtualMethod( + void * pAdjustedThisPtr, + sal_Int32 nVtableIndex, + void * pRegisterReturn, + typelib_TypeClass eReturnType, + char * pPT, + sal_Int32 * pStackLongs, + sal_Int32 nStackLongs) +{ + + // parameter list is mixed list of * and values + // reference parameters are pointers + + // the basic idea here is to use gpr[8] as a storage area for + // the future values of registers r3 to r10 needed for the call, + // and similarly fpr[13] as a storage area for the future values + // of floating point registers f1 to f13 + + unsigned long * mfunc; // actual function to be invoked + int gpr[8]; // storage for gp registers, map to r3-r10 + int off; // offset used to find function + + double fpr[13]; // storage for fp registers, map to f1-f13 + int f; // number of fprs mapped so far + double dret; // temporary function return values + + int n; // number of gprs mapped so far + long *p; // pointer to parameter overflow area + int c; // character of parameter type being decoded + int iret, iret2; + + // Because of the Power PC calling conventions we could be passing + // parameters in both register types and on the stack. To create the + // stack parameter area we need we now simply allocate local + // variable storage param[] that is at least the size of the parameter stack + // (more than enough space) which we can overwrite the parameters into. + + // Note: This keeps us from having to decode the signature twice and + // prevents problems with later local variables. + + // Note: could require up to 2*nStackLongs words of parameter stack area + // if the call has many float parameters (i.e. floats take up only 1 + // word on the stack but double takes 2 words in parameter area in the + // stack frame . + + // Update! floats on the outgoing parameter stack only take up 1 word + // (stfs is used) which is not correct according to the ABI but we + // will match what the compiler does until this is figured out + + // this grows the current stack to the appropriate size + // and sets the outgoing stack pointer p to the right place + __asm__ __volatile__ ( + "rlwinm %0,%0,3,3,28\n\t" + "addi %0,%0,22\n\t" + "rlwinm %0,%0,0,4,28\n\t" + "lwz r0,0(r1)\n\t" + "subf r1,%0,r1\n\t" + "stw r0,0(r1)\n\t" + : : "r" (nStackLongs) : "0" ); + + __asm__ __volatile__ ( "addi %0,r1,24" : "=r" (p) : ); + + // never called + // if (! pAdjustedThisPtr ) dummy_can_throw_anything("xxx"); // address something + + + // now begin to load the C++ function arguments into storage + n = 0; + f = 0; + + // now we need to parse the entire signature string */ + // until we get the END indicator */ + + // treat complex return pointer like any other parameter + +#if OSL_DEBUG_LEVEL > 2 + /* Let's figure out what is really going on here*/ + fprintf(stderr,"callVirtualMethod parameters string is %s\n",pPT); + int k = nStackLongs; + long * q = (long *)pStackLongs; + while (k > 0) { + fprintf(stderr,"uno stack is: %x\n",*q); + k--; + q++; + } +#endif + + /* parse the argument list up to the ending ) */ + while (*pPT != 'X') { + c = *pPT; + switch (c) { + case 'D': /* type is double */ + if (f < 13) { + fpr[f++] = *((double *)pStackLongs); /* store in register */ + } else { + if (((long) p) & 4) + p++; + *p++ = *pStackLongs; /* or on the parameter stack */ + *p++ = *(pStackLongs + 1); + } + pStackLongs += 2; + break; + + case 'F': /* type is float */ + /* this assumes that floats are stored as 1 32 bit word on param + stack and that if passed in parameter stack to C, should be + as double word. + + Whoops: the abi is not actually followed by gcc, need to + store floats as a *single* word on outgoing parameter stack + to match what gcc actually does + */ + if (f < 13) { + fpr[f++] = *((float *)pStackLongs); + } else { +#if 0 /* if abi were followed */ ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits