Bug 786533 - On OSX, one of the system header files (exception_defines.h) defines 'try' and 'catch' as macros which breaks @try/@catch. We need to #undef those before using nsObjCExceptions.h. r=ehsan
authorMats Palmgren <matspal@gmail.com>
Tue, 15 Jan 2013 13:22:03 +0100
changeset 118884 04fb583963dc5f696bdb997a1a21f8a5fa198f47
parent 118883 b9d9fc98561becefc49f769a5587e659e87b5d88
child 118885 b59c92bc4059a07c71c05a01f6009175cb621f0f
push id24180
push useremorley@mozilla.com
push dateTue, 15 Jan 2013 22:58:27 +0000
treeherdermozilla-central@72e34ce7fd92 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs786533
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 786533 - On OSX, one of the system header files (exception_defines.h) defines 'try' and 'catch' as macros which breaks @try/@catch. We need to #undef those before using nsObjCExceptions.h. r=ehsan
accessible/src/mac/mozDocAccessible.mm
toolkit/xre/nsNativeAppSupportCocoa.mm
widget/cocoa/nsBidiKeyboard.mm
widget/cocoa/nsCocoaUtils.h
widget/cocoa/nsDeviceContextSpecX.mm
widget/cocoa/nsFilePicker.mm
widget/cocoa/nsLookAndFeel.mm
widget/cocoa/nsMacWebAppUtils.mm
xpcom/base/nsObjCExceptions.h
--- a/accessible/src/mac/mozDocAccessible.mm
+++ b/accessible/src/mac/mozDocAccessible.mm
@@ -1,20 +1,22 @@
 /* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
-#include "nsObjCExceptions.h"
 #include "RootAccessibleWrap.h"
 
 #import "mozDocAccessible.h"
 
 #import "mozView.h"
 
+// This must be included last:
+#include "nsObjCExceptions.h"
+
 using namespace mozilla::a11y;
 
 static id <mozAccessible, mozView> 
 getNativeViewFromRootAccessible(Accessible* aAccessible)
 {
   RootAccessibleWrap* root =
     static_cast<RootAccessibleWrap*>(aAccessible->AsRoot());
   id <mozAccessible, mozView> nativeView = nil;
--- a/toolkit/xre/nsNativeAppSupportCocoa.mm
+++ b/toolkit/xre/nsNativeAppSupportCocoa.mm
@@ -4,33 +4,35 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsString.h"
 
 #import <CoreServices/CoreServices.h>
 #import <Cocoa/Cocoa.h>
 
 #include "nsCOMPtr.h"
-#include "nsObjCExceptions.h"
 #include "nsNativeAppSupportBase.h"
 
 #include "nsIAppShellService.h"
 #include "nsIAppStartup.h"
 #include "nsIBaseWindow.h"
 #include "nsICommandLineRunner.h"
 #include "nsIDOMWindow.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIDocShellTreeOwner.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIObserver.h"
 #include "nsIServiceManager.h"
 #include "nsIWebNavigation.h"
 #include "nsIWidget.h"
 #include "nsIWindowMediator.h"
 
+// This must be included last:
+#include "nsObjCExceptions.h"
+
 nsresult
 GetNativeWindowPointerFromDOMWindow(nsIDOMWindow *a_window, NSWindow **a_nativeWindow)
 {
   *a_nativeWindow = nil;
   if (!a_window)
     return NS_ERROR_INVALID_ARG;
 
   nsCOMPtr<nsIWebNavigation> mruWebNav(do_GetInterface(a_window));
--- a/widget/cocoa/nsBidiKeyboard.mm
+++ b/widget/cocoa/nsBidiKeyboard.mm
@@ -1,19 +1,21 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  *
  * 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/. */
 
 #include "nsBidiKeyboard.h"
-#include "nsObjCExceptions.h"
 #include "nsCocoaUtils.h"
 #include "TextInputHandler.h"
 
+// This must be the last include:
+#include "nsObjCExceptions.h"
+
 using namespace mozilla::widget;
 
 NS_IMPL_ISUPPORTS1(nsBidiKeyboard, nsIBidiKeyboard)
 
 nsBidiKeyboard::nsBidiKeyboard() : nsIBidiKeyboard()
 {
 }
 
--- a/widget/cocoa/nsCocoaUtils.h
+++ b/widget/cocoa/nsCocoaUtils.h
@@ -4,21 +4,23 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsCocoaUtils_h_
 #define nsCocoaUtils_h_
 
 #import <Cocoa/Cocoa.h>
 
 #include "nsRect.h"
-#include "nsObjCExceptions.h"
 #include "imgIContainer.h"
 #include "nsEvent.h"
 #include "npapi.h"
 
+// This must be the last include:
+#include "nsObjCExceptions.h"
+
 // Declare the backingScaleFactor method that we want to call
 // on NSView/Window/Screen objects, if they recognize it.
 @interface NSObject (BackingScaleFactorCategory)
 - (CGFloat)backingScaleFactor;
 @end
 
 class nsIWidget;
 
--- a/widget/cocoa/nsDeviceContextSpecX.mm
+++ b/widget/cocoa/nsDeviceContextSpecX.mm
@@ -1,26 +1,28 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* 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/. */
 
 #include "nsDeviceContextSpecX.h"
-#include "nsObjCExceptions.h"
 
 #include "nsCRT.h"
 #include <unistd.h>
 
 #include "nsIServiceManager.h"
 #include "nsIPrintOptions.h"
 #include "nsPrintSettingsX.h"
 
 #include "gfxQuartzSurface.h"
 #include "gfxImageSurface.h"
 
+// This must be the last include:
+#include "nsObjCExceptions.h"
+
 nsDeviceContextSpecX::nsDeviceContextSpecX()
 : mPrintSession(NULL)
 , mPageFormat(kPMNoPageFormat)
 , mPrintSettings(kPMNoPrintSettings)
 {
 }
 
 nsDeviceContextSpecX::~nsDeviceContextSpecX()
--- a/widget/cocoa/nsFilePicker.mm
+++ b/widget/cocoa/nsFilePicker.mm
@@ -1,30 +1,32 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
 #import <Cocoa/Cocoa.h>
 
 #include "nsFilePicker.h"
-#include "nsObjCExceptions.h"
 #include "nsCOMPtr.h"
 #include "nsReadableUtils.h"
 #include "nsNetUtil.h"
 #include "nsIComponentManager.h"
 #include "nsIFile.h"
 #include "nsILocalFileMac.h"
 #include "nsIURL.h"
 #include "nsArrayEnumerator.h"
 #include "nsIStringBundle.h"
 #include "nsCocoaFeatures.h"
 #include "nsCocoaUtils.h"
 #include "mozilla/Preferences.h"
 
+// This must be included last:
+#include "nsObjCExceptions.h"
+
 using namespace mozilla;
 
 const float kAccessoryViewPadding = 5;
 const int   kSaveTypeControlTag = 1;
 
 static bool gCallSecretHiddenFileAPI = false;
 const char kShowHiddenFilesPref[] = "filepicker.showHiddenFiles";
 
--- a/widget/cocoa/nsLookAndFeel.mm
+++ b/widget/cocoa/nsLookAndFeel.mm
@@ -1,23 +1,25 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* 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/. */
 
 #include "nsLookAndFeel.h"
 #include "nsCocoaFeatures.h"
-#include "nsObjCExceptions.h"
 #include "nsIServiceManager.h"
 #include "nsNativeThemeColors.h"
 #include "nsStyleConsts.h"
 #include "gfxFont.h"
 
 #import <Cocoa/Cocoa.h>
 
+// This must be included last:
+#include "nsObjCExceptions.h"
+
 nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel()
 {
 }
 
 nsLookAndFeel::~nsLookAndFeel()
 {
 }
 
--- a/widget/cocoa/nsMacWebAppUtils.mm
+++ b/widget/cocoa/nsMacWebAppUtils.mm
@@ -1,20 +1,22 @@
 /* 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/. */
 
 #import <Cocoa/Cocoa.h>
 
 #include "nsMacWebAppUtils.h"
-#include "nsObjCExceptions.h"
 #include "nsCOMPtr.h"
 #include "nsCocoaUtils.h"
 #include "nsString.h"
 
+// This must be included last:
+#include "nsObjCExceptions.h"
+
 // Find the path to the app with the given bundleIdentifier, if any.
 // Note that the OS will return the path to the newest binary, if there is more than one.
 // The determination of 'newest' is complex and beyond the scope of this comment.
 
 NS_IMPL_ISUPPORTS1(nsMacWebAppUtils, nsIMacWebAppUtils)
 
 NS_IMETHODIMP nsMacWebAppUtils::PathForAppWithIdentifier(const nsAString& bundleIdentifier, nsAString& outPath) {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
--- a/xpcom/base/nsObjCExceptions.h
+++ b/xpcom/base/nsObjCExceptions.h
@@ -1,13 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
+// Undo the damage that exception_defines.h does.
+#undef try
+#undef catch
+
 #ifndef nsObjCExceptions_h_
 #define nsObjCExceptions_h_
 
 #import <Foundation/Foundation.h>
 
 #ifdef DEBUG
 #import <ExceptionHandling/NSExceptionHandler.h>
 #endif
@@ -17,16 +21,20 @@
 #include "nsCOMPtr.h"
 #include "nsServiceManagerUtils.h"
 #endif
 
 #include <unistd.h>
 #include <signal.h>
 #include "nsError.h"
 
+// Undo the damage that exception_defines.h does.
+#undef try
+#undef catch
+
 /* NOTE: Macros that claim to abort no longer abort, see bug 486574.
  * If you actually want to log and abort, call "nsObjCExceptionLogAbort"
  * from an exception handler. At some point we will fix this by replacing
  * all macros in the tree with appropriately-named macros.
  */
 
 // See Mozilla bug 163260.
 // This file can only be included in an Objective-C context.