From c122cb2fa328eca88100bd848fb609fdfb98429e Mon Sep 17 00:00:00 2001 From: "weinig@apple.com" Date: Tue, 17 Jan 2012 23:46:16 +0000 Subject: [PATCH] Add helper macro for forward declaring objective-c classes https://bugs.webkit.org/show_bug.cgi?id=76485 Reviewed by Anders Carlsson. Source/JavaScriptCore: * wtf/Compiler.h: Add OBJC_CLASS macro which helps reduce code when forward declaring an objective-c class in a header which can be included from both Objective-C and non-Objective-C files. Source/WebCore: * accessibility/AccessibilityObject.h: * bindings/js/ScriptController.h: * bridge/objc/objc_utility.h: * page/DragClient.h: * page/EditorClient.h: * platform/AutodrainedPool.h: * platform/ContextMenuItem.h: * platform/Cursor.h: * platform/DragData.h: * platform/DragImage.h: * platform/KURL.h: * platform/Pasteboard.h: * platform/PlatformKeyboardEvent.h: * platform/PlatformMenuDescription.h: * platform/PlatformScreen.h: * platform/SharedBuffer.h: * platform/Widget.h: * platform/cf/SchedulePair.h: * platform/graphics/BitmapImage.h: * platform/graphics/FontPlatformData.h: * platform/graphics/GraphicsContext3D.h: * platform/graphics/GraphicsLayer.h: * platform/graphics/Icon.h: * platform/graphics/Image.h: * platform/graphics/MediaPlayer.h: * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h: * platform/graphics/ca/PlatformCAAnimation.h: * platform/graphics/ca/mac/TileCache.h: * platform/graphics/mac/ColorMac.h: * platform/graphics/mac/MediaPlayerPrivateQTKit.h: * platform/graphics/mac/MediaPlayerProxy.h: * platform/mac/ClipboardMac.h: * platform/mac/LocalCurrentGraphicsContext.h: * platform/mac/PasteboardHelper.h: * platform/mac/PopupMenuMac.h: * platform/mac/ScrollAnimatorMac.h: * platform/mac/WebCoreSystemInterface.h: * platform/network/ResourceHandle.h: * platform/network/ResourceHandleClient.h: * platform/network/ResourceHandleInternal.h: * platform/network/cf/AuthenticationChallenge.h: * platform/network/cf/ResourceError.h: * platform/network/cf/ResourceRequest.h: * platform/network/cf/ResourceResponse.h: * rendering/RenderThemeMac.h: Deploy OBJC_CLASS for a little code reduction. Source/WebKit2: * WebProcess/WebCoreSupport/WebDragClient.h: Deploy OBJC_CLASS for a little code reduction. * config.h: Remove duplicate copy of OBJC_CLASS. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105203 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/JavaScriptCore/ChangeLog | 12 ++++ Source/JavaScriptCore/wtf/Compiler.h | 12 +++- Source/WebCore/ChangeLog | 54 ++++++++++++++++ Source/WebCore/accessibility/AccessibilityObject.h | 39 +++++------- Source/WebCore/bindings/js/ScriptController.h | 7 +-- Source/WebCore/bridge/objc/objc_utility.h | 6 +- Source/WebCore/page/DragClient.h | 15 ++--- Source/WebCore/page/EditorClient.h | 15 ++--- Source/WebCore/platform/AutodrainedPool.h | 6 +- Source/WebCore/platform/ContextMenuItem.h | 7 +-- Source/WebCore/platform/Cursor.h | 6 +- Source/WebCore/platform/DragData.h | 6 +- Source/WebCore/platform/DragImage.h | 6 +- Source/WebCore/platform/KURL.h | 6 +- Source/WebCore/platform/Pasteboard.h | 12 +--- Source/WebCore/platform/PlatformKeyboardEvent.h | 6 +- Source/WebCore/platform/PlatformMenuDescription.h | 6 +- Source/WebCore/platform/PlatformScreen.h | 9 +-- Source/WebCore/platform/SharedBuffer.h | 8 +-- Source/WebCore/platform/Widget.h | 9 +-- Source/WebCore/platform/cf/SchedulePair.h | 6 +- Source/WebCore/platform/graphics/BitmapImage.h | 6 +- .../WebCore/platform/graphics/FontPlatformData.h | 6 +- .../WebCore/platform/graphics/GraphicsContext3D.h | 9 +-- Source/WebCore/platform/graphics/GraphicsLayer.h | 6 +- Source/WebCore/platform/graphics/Icon.h | 6 +- Source/WebCore/platform/graphics/Image.h | 6 +- Source/WebCore/platform/graphics/MediaPlayer.h | 10 +-- .../objc/MediaPlayerPrivateAVFoundationObjC.h | 22 +++---- .../platform/graphics/ca/PlatformCAAnimation.h | 6 +- .../WebCore/platform/graphics/ca/mac/TileCache.h | 12 +--- Source/WebCore/platform/graphics/mac/ColorMac.h | 6 +- .../graphics/mac/MediaPlayerPrivateQTKit.h | 20 +++--- .../platform/graphics/mac/MediaPlayerProxy.h | 6 +- Source/WebCore/platform/mac/ClipboardMac.h | 9 +-- .../platform/mac/LocalCurrentGraphicsContext.h | 6 +- Source/WebCore/platform/mac/PasteboardHelper.h | 6 +- Source/WebCore/platform/mac/PopupMenuMac.h | 6 +- Source/WebCore/platform/mac/ScrollAnimatorMac.h | 12 +--- .../WebCore/platform/mac/WebCoreSystemInterface.h | 73 +++++++--------------- Source/WebCore/platform/network/ResourceHandle.h | 15 ++--- .../platform/network/ResourceHandleClient.h | 6 +- .../platform/network/ResourceHandleInternal.h | 9 +-- .../platform/network/cf/AuthenticationChallenge.h | 9 ++- Source/WebCore/platform/network/cf/ResourceError.h | 6 +- .../WebCore/platform/network/cf/ResourceRequest.h | 6 +- .../WebCore/platform/network/cf/ResourceResponse.h | 6 +- Source/WebCore/rendering/RenderThemeMac.h | 8 +-- Source/WebKit2/ChangeLog | 13 ++++ .../WebProcess/WebCoreSupport/WebDragClient.h | 9 +-- Source/WebKit2/config.h | 6 -- 51 files changed, 220 insertions(+), 359 deletions(-) diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog index 27a7b79..eb5f466 100644 --- a/Source/JavaScriptCore/ChangeLog +++ b/Source/JavaScriptCore/ChangeLog @@ -1,3 +1,15 @@ +2012-01-17 Sam Weinig + + Add helper macro for forward declaring objective-c classes + https://bugs.webkit.org/show_bug.cgi?id=76485 + + Reviewed by Anders Carlsson. + + * wtf/Compiler.h: + Add OBJC_CLASS macro which helps reduce code when forward declaring an + objective-c class in a header which can be included from both Objective-C + and non-Objective-C files. + 2012-01-17 Filip Pizlo DFG should be able to do JS and custom getter caching diff --git a/Source/JavaScriptCore/wtf/Compiler.h b/Source/JavaScriptCore/wtf/Compiler.h index 93d3316..96ad6e4 100644 --- a/Source/JavaScriptCore/wtf/Compiler.h +++ b/Source/JavaScriptCore/wtf/Compiler.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Apple Inc. All rights reserved. + * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -239,4 +239,14 @@ #define FINAL #endif +/* OBJC_CLASS */ + +#ifndef OBJC_CLASS +#ifdef __OBJC__ +#define OBJC_CLASS @class +#else +#define OBJC_CLASS class +#endif +#endif + #endif /* WTF_Compiler_h */ diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 95dd985..45692a8 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,57 @@ +2012-01-17 Sam Weinig + + Add helper macro for forward declaring objective-c classes + https://bugs.webkit.org/show_bug.cgi?id=76485 + + Reviewed by Anders Carlsson. + + * accessibility/AccessibilityObject.h: + * bindings/js/ScriptController.h: + * bridge/objc/objc_utility.h: + * page/DragClient.h: + * page/EditorClient.h: + * platform/AutodrainedPool.h: + * platform/ContextMenuItem.h: + * platform/Cursor.h: + * platform/DragData.h: + * platform/DragImage.h: + * platform/KURL.h: + * platform/Pasteboard.h: + * platform/PlatformKeyboardEvent.h: + * platform/PlatformMenuDescription.h: + * platform/PlatformScreen.h: + * platform/SharedBuffer.h: + * platform/Widget.h: + * platform/cf/SchedulePair.h: + * platform/graphics/BitmapImage.h: + * platform/graphics/FontPlatformData.h: + * platform/graphics/GraphicsContext3D.h: + * platform/graphics/GraphicsLayer.h: + * platform/graphics/Icon.h: + * platform/graphics/Image.h: + * platform/graphics/MediaPlayer.h: + * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h: + * platform/graphics/ca/PlatformCAAnimation.h: + * platform/graphics/ca/mac/TileCache.h: + * platform/graphics/mac/ColorMac.h: + * platform/graphics/mac/MediaPlayerPrivateQTKit.h: + * platform/graphics/mac/MediaPlayerProxy.h: + * platform/mac/ClipboardMac.h: + * platform/mac/LocalCurrentGraphicsContext.h: + * platform/mac/PasteboardHelper.h: + * platform/mac/PopupMenuMac.h: + * platform/mac/ScrollAnimatorMac.h: + * platform/mac/WebCoreSystemInterface.h: + * platform/network/ResourceHandle.h: + * platform/network/ResourceHandleClient.h: + * platform/network/ResourceHandleInternal.h: + * platform/network/cf/AuthenticationChallenge.h: + * platform/network/cf/ResourceError.h: + * platform/network/cf/ResourceRequest.h: + * platform/network/cf/ResourceResponse.h: + * rendering/RenderThemeMac.h: + Deploy OBJC_CLASS for a little code reduction. + 2012-01-17 Andreas Kling SpaceSplitString: Share equivalent string piece vectors. diff --git a/Source/WebCore/accessibility/AccessibilityObject.h b/Source/WebCore/accessibility/AccessibilityObject.h index 428324d..737e2dff 100644 --- a/Source/WebCore/accessibility/AccessibilityObject.h +++ b/Source/WebCore/accessibility/AccessibilityObject.h @@ -47,38 +47,27 @@ #include "AccessibilityObjectWrapper.h" #endif +#if PLATFORM(MAC) + typedef struct _NSRange NSRange; -#ifdef __OBJC__ -@class NSArray; -@class NSAttributedString; -@class NSData; -@class NSMutableAttributedString; -@class NSString; -@class NSValue; -@class NSView; -@class WebAccessibilityObjectWrapper; -#else -class NSArray; -class NSAttributedString; -class NSData; -class NSMutableAttributedString; -class NSString; -class NSValue; -class NSView; -#if PLATFORM(GTK) +OBJC_CLASS NSArray; +OBJC_CLASS NSAttributedString; +OBJC_CLASS NSData; +OBJC_CLASS NSMutableAttributedString; +OBJC_CLASS NSString; +OBJC_CLASS NSValue; +OBJC_CLASS NSView; +OBJC_CLASS WebAccessibilityObjectWrapper; + +typedef WebAccessibilityObjectWrapper AccessibilityObjectWrapper; + +#elif PLATFORM(GTK) typedef struct _AtkObject AtkObject; typedef struct _AtkObject AccessibilityObjectWrapper; -#elif PLATFORM(MAC) -class WebAccessibilityObjectWrapper; #else class AccessibilityObjectWrapper; #endif -#endif - -#if PLATFORM(MAC) -typedef WebAccessibilityObjectWrapper AccessibilityObjectWrapper; -#endif namespace WebCore { diff --git a/Source/WebCore/bindings/js/ScriptController.h b/Source/WebCore/bindings/js/ScriptController.h index d672f42..6b662da 100644 --- a/Source/WebCore/bindings/js/ScriptController.h +++ b/Source/WebCore/bindings/js/ScriptController.h @@ -33,12 +33,7 @@ #if PLATFORM(MAC) #include - -#ifdef __OBJC__ -@class WebScriptObject; -#else -class WebScriptObject; -#endif +OBJC_CLASS WebScriptObject; #endif struct NPObject; diff --git a/Source/WebCore/bridge/objc/objc_utility.h b/Source/WebCore/bridge/objc/objc_utility.h index 4810752..533c11e 100644 --- a/Source/WebCore/bridge/objc/objc_utility.h +++ b/Source/WebCore/bridge/objc/objc_utility.h @@ -32,11 +32,7 @@ #include #include -#ifdef __OBJC__ -@class NSString; -#else -class NSString; -#endif +OBJC_CLASS NSString; namespace JSC { namespace Bindings { diff --git a/Source/WebCore/page/DragClient.h b/Source/WebCore/page/DragClient.h index ea70c5e..090c29d 100644 --- a/Source/WebCore/page/DragClient.h +++ b/Source/WebCore/page/DragClient.h @@ -32,17 +32,10 @@ #include "IntPoint.h" #if PLATFORM(MAC) -#ifdef __OBJC__ -@class DOMElement; -@class NSURL; -@class NSString; -@class NSPasteboard; -#else -class DOMElement; -class NSURL; -class NSString; -class NSPasteboard; -#endif +OBJC_CLASS DOMElement; +OBJC_CLASS NSURL; +OBJC_CLASS NSString; +OBJC_CLASS NSPasteboard; #endif namespace WebCore { diff --git a/Source/WebCore/page/EditorClient.h b/Source/WebCore/page/EditorClient.h index 5a4be2c..4d33e9f 100644 --- a/Source/WebCore/page/EditorClient.h +++ b/Source/WebCore/page/EditorClient.h @@ -36,17 +36,10 @@ #include #if PLATFORM(MAC) -#ifdef __OBJC__ -@class NSAttributedString; -@class NSPasteboard; -@class NSString; -@class NSURL; -#else -class NSAttributedString; -class NSPasteboard; -class NSString; -class NSURL; -#endif +OBJC_CLASS NSAttributedString; +OBJC_CLASS NSPasteboard; +OBJC_CLASS NSString; +OBJC_CLASS NSURL; #endif namespace WebCore { diff --git a/Source/WebCore/platform/AutodrainedPool.h b/Source/WebCore/platform/AutodrainedPool.h index f03ec81..207aadc 100644 --- a/Source/WebCore/platform/AutodrainedPool.h +++ b/Source/WebCore/platform/AutodrainedPool.h @@ -31,11 +31,7 @@ #include -#ifdef __OBJC__ -@class NSAutoreleasePool; -#else -class NSAutoreleasePool; -#endif +OBJC_CLASS NSAutoreleasePool; namespace WebCore { diff --git a/Source/WebCore/platform/ContextMenuItem.h b/Source/WebCore/platform/ContextMenuItem.h index c1c1825..2520c64 100644 --- a/Source/WebCore/platform/ContextMenuItem.h +++ b/Source/WebCore/platform/ContextMenuItem.h @@ -33,12 +33,7 @@ #if PLATFORM(MAC) #include - -#ifdef __OBJC__ -@class NSMenuItem; -#else -class NSMenuItem; -#endif +OBJC_CLASS NSMenuItem; #elif PLATFORM(WIN) typedef struct tagMENUITEMINFOW MENUITEMINFO; #elif PLATFORM(GTK) diff --git a/Source/WebCore/platform/Cursor.h b/Source/WebCore/platform/Cursor.h index c324ef0..bc51840 100644 --- a/Source/WebCore/platform/Cursor.h +++ b/Source/WebCore/platform/Cursor.h @@ -46,11 +46,7 @@ typedef HICON HCURSOR; #endif #if PLATFORM(MAC) && !PLATFORM(IOS) -#ifdef __OBJC__ -@class NSCursor; -#else -class NSCursor; -#endif +OBJC_CLASS NSCursor; #endif #if PLATFORM(WX) diff --git a/Source/WebCore/platform/DragData.h b/Source/WebCore/platform/DragData.h index bb242f9..17abd44 100644 --- a/Source/WebCore/platform/DragData.h +++ b/Source/WebCore/platform/DragData.h @@ -36,15 +36,17 @@ #if PLATFORM(MAC) #include + #ifdef __OBJC__ #import #import typedef id DragDataRef; -@class NSPasteboard; #else typedef void* DragDataRef; -class NSPasteboard; #endif + +OBJC_CLASS NSPasteboard; + #elif PLATFORM(QT) QT_BEGIN_NAMESPACE class QMimeData; diff --git a/Source/WebCore/platform/DragImage.h b/Source/WebCore/platform/DragImage.h index 811fa56..a22db6a 100644 --- a/Source/WebCore/platform/DragImage.h +++ b/Source/WebCore/platform/DragImage.h @@ -32,11 +32,7 @@ #if PLATFORM(MAC) #include -#ifdef __OBJC__ -@class NSImage; -#else -class NSImage; -#endif +OBJC_CLASS NSImage; #elif PLATFORM(QT) QT_BEGIN_NAMESPACE class QPixmap; diff --git a/Source/WebCore/platform/KURL.h b/Source/WebCore/platform/KURL.h index 49cd951..8dec81f 100644 --- a/Source/WebCore/platform/KURL.h +++ b/Source/WebCore/platform/KURL.h @@ -35,11 +35,7 @@ typedef const struct __CFURL* CFURLRef; #endif #if PLATFORM(MAC) || (PLATFORM(QT) && USE(QTKIT)) -#ifdef __OBJC__ -@class NSURL; -#else -class NSURL; -#endif +OBJC_CLASS NSURL; #endif #if PLATFORM(QT) diff --git a/Source/WebCore/platform/Pasteboard.h b/Source/WebCore/platform/Pasteboard.h index 866e7e5..8791d39 100644 --- a/Source/WebCore/platform/Pasteboard.h +++ b/Source/WebCore/platform/Pasteboard.h @@ -43,15 +43,9 @@ // knowledge of the frame and editor or moved into the editing directory. #if PLATFORM(MAC) -#ifdef __OBJC__ -@class NSFileWrapper; -@class NSPasteboard; -@class NSArray; -#else -class NSFileWrapper; -class NSPasteboard; -class NSArray; -#endif +OBJC_CLASS NSFileWrapper; +OBJC_CLASS NSPasteboard; +OBJC_CLASS NSArray; #endif #if PLATFORM(WIN) diff --git a/Source/WebCore/platform/PlatformKeyboardEvent.h b/Source/WebCore/platform/PlatformKeyboardEvent.h index f154966..5990098 100644 --- a/Source/WebCore/platform/PlatformKeyboardEvent.h +++ b/Source/WebCore/platform/PlatformKeyboardEvent.h @@ -32,11 +32,7 @@ #if PLATFORM(MAC) #include -#ifdef __OBJC__ -@class NSEvent; -#else -class NSEvent; -#endif +OBJC_CLASS NSEvent; #endif #if PLATFORM(WIN) diff --git a/Source/WebCore/platform/PlatformMenuDescription.h b/Source/WebCore/platform/PlatformMenuDescription.h index 08845cb..459d0a5 100644 --- a/Source/WebCore/platform/PlatformMenuDescription.h +++ b/Source/WebCore/platform/PlatformMenuDescription.h @@ -27,11 +27,7 @@ #define PlatformMenuDescription_h #if PLATFORM(MAC) -#ifdef __OBJC__ -@class NSMutableArray; -#else -class NSMutableArray; -#endif +OBJC_CLASS NSMutableArray; #elif PLATFORM(QT) #include #elif PLATFORM(GTK) diff --git a/Source/WebCore/platform/PlatformScreen.h b/Source/WebCore/platform/PlatformScreen.h index a9acb5d..b4c78a5 100644 --- a/Source/WebCore/platform/PlatformScreen.h +++ b/Source/WebCore/platform/PlatformScreen.h @@ -31,13 +31,8 @@ #include #if PLATFORM(MAC) -#ifdef __OBJC__ - @class NSScreen; - @class NSWindow; -#else - class NSScreen; - class NSWindow; -#endif +OBJC_CLASS NSScreen; +OBJC_CLASS NSWindow; #endif typedef uint32_t PlatformDisplayID; diff --git a/Source/WebCore/platform/SharedBuffer.h b/Source/WebCore/platform/SharedBuffer.h index d85abba..57cfc29 100644 --- a/Source/WebCore/platform/SharedBuffer.h +++ b/Source/WebCore/platform/SharedBuffer.h @@ -23,6 +23,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + #ifndef SharedBuffer_h #define SharedBuffer_h @@ -37,12 +38,7 @@ #endif #if PLATFORM(MAC) || (PLATFORM(QT) && USE(QTKIT)) -#ifdef __OBJC__ -@class NSData; -#else -class NSData; -#endif - +OBJC_CLASS NSData; #endif namespace WebCore { diff --git a/Source/WebCore/platform/Widget.h b/Source/WebCore/platform/Widget.h index 9fddf70..3f19b61 100644 --- a/Source/WebCore/platform/Widget.h +++ b/Source/WebCore/platform/Widget.h @@ -45,13 +45,8 @@ #endif #if PLATFORM(MAC) -#ifdef __OBJC__ -@class NSView; -@class NSWindow; -#else -class NSView; -class NSWindow; -#endif +OBJC_CLASS NSView; +OBJC_CLASS NSWindow; typedef NSView *PlatformWidget; #endif diff --git a/Source/WebCore/platform/cf/SchedulePair.h b/Source/WebCore/platform/cf/SchedulePair.h index 5172436..764c29f 100644 --- a/Source/WebCore/platform/cf/SchedulePair.h +++ b/Source/WebCore/platform/cf/SchedulePair.h @@ -35,11 +35,7 @@ #include #if PLATFORM(MAC) -#ifdef __OBJC__ -@class NSRunLoop; -#else -class NSRunLoop; -#endif +OBJC_CLASS NSRunLoop; #endif namespace WebCore { diff --git a/Source/WebCore/platform/graphics/BitmapImage.h b/Source/WebCore/platform/graphics/BitmapImage.h index f4d50ce..00802f6 100644 --- a/Source/WebCore/platform/graphics/BitmapImage.h +++ b/Source/WebCore/platform/graphics/BitmapImage.h @@ -34,11 +34,7 @@ #if PLATFORM(MAC) #include -#ifdef __OBJC__ -@class NSImage; -#else -class NSImage; -#endif +OBJC_CLASS NSImage; #endif #if PLATFORM(WIN) diff --git a/Source/WebCore/platform/graphics/FontPlatformData.h b/Source/WebCore/platform/graphics/FontPlatformData.h index 1fcba31..705c588 100644 --- a/Source/WebCore/platform/graphics/FontPlatformData.h +++ b/Source/WebCore/platform/graphics/FontPlatformData.h @@ -55,11 +55,7 @@ #endif #if OS(DARWIN) -#ifdef __OBJC__ -@class NSFont; -#else -class NSFont; -#endif +OBJC_CLASS NSFont; typedef struct CGFont* CGFontRef; typedef const struct __CTFont* CTFontRef; diff --git a/Source/WebCore/platform/graphics/GraphicsContext3D.h b/Source/WebCore/platform/graphics/GraphicsContext3D.h index e4f69d8..dfebbba 100644 --- a/Source/WebCore/platform/graphics/GraphicsContext3D.h +++ b/Source/WebCore/platform/graphics/GraphicsContext3D.h @@ -50,13 +50,8 @@ #if PLATFORM(MAC) #include #include -#ifdef __OBJC__ -@class CALayer; -@class WebGLLayer; -#else -class CALayer; -class WebGLLayer; -#endif +OBJC_CLASS CALayer; +OBJC_CLASS WebGLLayer; #elif PLATFORM(QT) QT_BEGIN_NAMESPACE class QPainter; diff --git a/Source/WebCore/platform/graphics/GraphicsLayer.h b/Source/WebCore/platform/graphics/GraphicsLayer.h index 14750c6..a6936c2 100644 --- a/Source/WebCore/platform/graphics/GraphicsLayer.h +++ b/Source/WebCore/platform/graphics/GraphicsLayer.h @@ -44,11 +44,7 @@ #include #if PLATFORM(MAC) -#ifdef __OBJC__ -@class CALayer; -#else -class CALayer; -#endif +OBJC_CLASS CALayer; typedef CALayer PlatformLayer; #elif PLATFORM(WIN) typedef struct _CACFLayer PlatformLayer; diff --git a/Source/WebCore/platform/graphics/Icon.h b/Source/WebCore/platform/graphics/Icon.h index 2797133..781a08c 100644 --- a/Source/WebCore/platform/graphics/Icon.h +++ b/Source/WebCore/platform/graphics/Icon.h @@ -28,11 +28,7 @@ #if PLATFORM(MAC) #include -#ifdef __OBJC__ -@class NSImage; -#else -class NSImage; -#endif +OBJC_CLASS NSImage; #elif PLATFORM(WIN) typedef struct HICON__* HICON; #elif PLATFORM(QT) diff --git a/Source/WebCore/platform/graphics/Image.h b/Source/WebCore/platform/graphics/Image.h index 21b37d3..b78fc7d 100644 --- a/Source/WebCore/platform/graphics/Image.h +++ b/Source/WebCore/platform/graphics/Image.h @@ -39,11 +39,7 @@ #include #if PLATFORM(MAC) -#ifdef __OBJC__ -@class NSImage; -#else -class NSImage; -#endif +OBJC_CLASS NSImage; #endif #if USE(CG) diff --git a/Source/WebCore/platform/graphics/MediaPlayer.h b/Source/WebCore/platform/graphics/MediaPlayer.h index da53de1..bde35cd 100644 --- a/Source/WebCore/platform/graphics/MediaPlayer.h +++ b/Source/WebCore/platform/graphics/MediaPlayer.h @@ -46,13 +46,9 @@ #include "GraphicsLayer.h" #endif -#ifdef __OBJC__ -@class AVPlayer; -@class QTMovie; -#else -class AVPlayer; -class QTMovie; -#endif +OBJC_CLASS AVPlayer; +OBJC_CLASS QTMovie; + class AVCFPlayer; class QTMovieGWorld; class QTMovieVisualContext; diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h index 7fd2465..dcc046d 100644 --- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h +++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h @@ -30,20 +30,14 @@ #include "MediaPlayerPrivateAVFoundation.h" -#ifdef __OBJC__ -@class AVAsset; -@class AVPlayer; -@class AVPlayerItem; -@class AVPlayerLayer; -@class AVAssetImageGenerator; -@class WebCoreAVFMovieObserver; -#else -class AVAsset; -class AVPlayer; -class AVPlayerItem; -class AVPlayerLayer; -class AVAssetImageGenerator; -class WebCoreAVFMovieObserver; +OBJC_CLASS AVAsset; +OBJC_CLASS AVPlayer; +OBJC_CLASS AVPlayerItem; +OBJC_CLASS AVPlayerLayer; +OBJC_CLASS AVAssetImageGenerator; +OBJC_CLASS WebCoreAVFMovieObserver; + +#ifndef __OBJC__ typedef struct objc_object *id; #endif diff --git a/Source/WebCore/platform/graphics/ca/PlatformCAAnimation.h b/Source/WebCore/platform/graphics/ca/PlatformCAAnimation.h index bfd76c8..b2d3259 100644 --- a/Source/WebCore/platform/graphics/ca/PlatformCAAnimation.h +++ b/Source/WebCore/platform/graphics/ca/PlatformCAAnimation.h @@ -36,11 +36,7 @@ #include #if PLATFORM(MAC) -#ifdef __OBJC__ -@class CAPropertyAnimation; -#else -class CAPropertyAnimation; -#endif +OBJC_CLASS CAPropertyAnimation; typedef CAPropertyAnimation* PlatformAnimationRef; #elif PLATFORM(WIN) typedef struct _CACFAnimation* CACFAnimationRef; diff --git a/Source/WebCore/platform/graphics/ca/mac/TileCache.h b/Source/WebCore/platform/graphics/ca/mac/TileCache.h index bb60c48..0fc25de 100644 --- a/Source/WebCore/platform/graphics/ca/mac/TileCache.h +++ b/Source/WebCore/platform/graphics/ca/mac/TileCache.h @@ -31,15 +31,9 @@ #include #include -#ifdef __OBJC__ -@class CALayer; -@class WebTileCacheLayer; -@class WebTileLayer; -#else -class CALayer; -class WebTileCacheLayer; -class WebTileLayer; -#endif +OBJC_CLASS CALayer; +OBJC_CLASS WebTileCacheLayer; +OBJC_CLASS WebTileLayer; namespace WebCore { diff --git a/Source/WebCore/platform/graphics/mac/ColorMac.h b/Source/WebCore/platform/graphics/mac/ColorMac.h index b68b157..2482b59 100644 --- a/Source/WebCore/platform/graphics/mac/ColorMac.h +++ b/Source/WebCore/platform/graphics/mac/ColorMac.h @@ -31,11 +31,7 @@ #include "Color.h" -#ifdef __OBJC__ -@class NSColor; -#else -class NSColor; -#endif +OBJC_CLASS NSColor; namespace WebCore { diff --git a/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h b/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h index 951dfff..3089ae2 100644 --- a/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h +++ b/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h @@ -35,22 +35,18 @@ #ifdef __OBJC__ #import -@class QTMovie; -@class QTMovieView; -@class QTMovieLayer; -@class QTVideoRendererWebKitOnly; -@class WebCoreMovieObserver; #else -class NSDictionary; -class NSMutableDictionary; -class QTMovie; -class QTMovieView; class QTTime; -class QTMovieLayer; -class QTVideoRendererWebKitOnly; -class WebCoreMovieObserver; #endif +OBJC_CLASS NSDictionary; +OBJC_CLASS NSMutableDictionary; +OBJC_CLASS QTMovie; +OBJC_CLASS QTMovieView; +OBJC_CLASS QTMovieLayer; +OBJC_CLASS QTVideoRendererWebKitOnly; +OBJC_CLASS WebCoreMovieObserver; + #ifndef DRAW_FRAME_RATE #define DRAW_FRAME_RATE 0 #endif diff --git a/Source/WebCore/platform/graphics/mac/MediaPlayerProxy.h b/Source/WebCore/platform/graphics/mac/MediaPlayerProxy.h index cc7ec95..c586fb8 100644 --- a/Source/WebCore/platform/graphics/mac/MediaPlayerProxy.h +++ b/Source/WebCore/platform/graphics/mac/MediaPlayerProxy.h @@ -26,11 +26,7 @@ #ifndef MediaPlayerProxy_h #define MediaPlayerProxy_h -#ifdef __OBJC__ -@class WebMediaPlayerProxy; -#else -class WebMediaPlayerProxy; -#endif +OBJC_CLASS WebMediaPlayerProxy; enum MediaPlayerProxyNotificationType { diff --git a/Source/WebCore/platform/mac/ClipboardMac.h b/Source/WebCore/platform/mac/ClipboardMac.h index 6c93ed5b92..24e9b80 100644 --- a/Source/WebCore/platform/mac/ClipboardMac.h +++ b/Source/WebCore/platform/mac/ClipboardMac.h @@ -30,13 +30,8 @@ #include "Clipboard.h" #include -#ifdef __OBJC__ -@class NSImage; -@class NSPasteboard; -#else -class NSImage; -class NSPasteboard; -#endif +OBJC_CLASS NSImage; +OBJC_CLASS NSPasteboard; namespace WebCore { diff --git a/Source/WebCore/platform/mac/LocalCurrentGraphicsContext.h b/Source/WebCore/platform/mac/LocalCurrentGraphicsContext.h index 0907fac..d4df7e6 100644 --- a/Source/WebCore/platform/mac/LocalCurrentGraphicsContext.h +++ b/Source/WebCore/platform/mac/LocalCurrentGraphicsContext.h @@ -24,11 +24,7 @@ #include "skia/ext/skia_utils_mac.h" #endif -#ifdef __OBJC__ -@class NSGraphicsContext; -#else -class NSGraphicsContext; -#endif +OBJC_CLASS NSGraphicsContext; namespace WebCore { diff --git a/Source/WebCore/platform/mac/PasteboardHelper.h b/Source/WebCore/platform/mac/PasteboardHelper.h index 7bd62e5..6c1e844 100644 --- a/Source/WebCore/platform/mac/PasteboardHelper.h +++ b/Source/WebCore/platform/mac/PasteboardHelper.h @@ -34,11 +34,7 @@ #import -#ifdef __OBJC__ -@class DOMDocumentFragment; -#else -class DOMDocumentFragment; -#endif +OBJC_CLASS DOMDocumentFragment; namespace WebCore { diff --git a/Source/WebCore/platform/mac/PopupMenuMac.h b/Source/WebCore/platform/mac/PopupMenuMac.h index 8e21913..8dd6aff 100644 --- a/Source/WebCore/platform/mac/PopupMenuMac.h +++ b/Source/WebCore/platform/mac/PopupMenuMac.h @@ -26,11 +26,7 @@ #include #include -#ifdef __OBJC__ -@class NSPopUpButtonCell; -#else -class NSPopUpButtonCell; -#endif +OBJC_CLASS NSPopUpButtonCell; namespace WebCore { diff --git a/Source/WebCore/platform/mac/ScrollAnimatorMac.h b/Source/WebCore/platform/mac/ScrollAnimatorMac.h index a38883b..48ddf7d 100644 --- a/Source/WebCore/platform/mac/ScrollAnimatorMac.h +++ b/Source/WebCore/platform/mac/ScrollAnimatorMac.h @@ -36,15 +36,9 @@ #include "Timer.h" #include -#ifdef __OBJC__ -@class WebScrollAnimationHelperDelegate; -@class WebScrollbarPainterControllerDelegate; -@class WebScrollbarPainterDelegate; -#else -class WebScrollAnimationHelperDelegate; -class WebScrollbarPainterControllerDelegate; -class WebScrollbarPainterDelegate; -#endif +OBJC_CLASS WebScrollAnimationHelperDelegate; +OBJC_CLASS WebScrollbarPainterControllerDelegate; +OBJC_CLASS WebScrollbarPainterDelegate; typedef id ScrollbarPainterController; diff --git a/Source/WebCore/platform/mac/WebCoreSystemInterface.h b/Source/WebCore/platform/mac/WebCoreSystemInterface.h index beb36ca..d988669 100644 --- a/Source/WebCore/platform/mac/WebCoreSystemInterface.h +++ b/Source/WebCore/platform/mac/WebCoreSystemInterface.h @@ -77,56 +77,29 @@ typedef struct _CFURLRequest* CFMutableURLRequestRef; typedef const struct _CFURLRequest* CFURLRequestRef; #endif -#ifdef __OBJC__ -@class AVAsset; -@class NSArray; -@class NSButtonCell; -@class NSControl; -@class NSCursor; -@class NSData; -@class NSDate; -@class NSEvent; -@class NSFont; -@class NSHTTPCookie; -@class NSImage; -@class NSMenu; -@class NSMutableURLRequest; -@class NSString; -@class NSTextFieldCell; -@class NSURL; -@class NSURLConnection; -@class NSURLRequest; -@class NSURLResponse; -@class NSView; -@class NSWindow; -@class QTMovie; -@class QTMovieView; -#else -class AVAsset; -class NSArray; -class NSButtonCell; -class NSControl; -class NSCursor; -class NSData; -class NSDate; -class NSEvent; -class NSFont; -class NSHTTPCookie; -class NSImage; -class NSMenu; -class NSMutableArray; -class NSMutableURLRequest; -class NSURL; -class NSURLRequest; -class NSString; -class NSTextFieldCell; -class NSURLConnection; -class NSURLResponse; -class NSView; -class NSWindow; -class QTMovie; -class QTMovieView; -#endif +OBJC_CLASS AVAsset; +OBJC_CLASS NSArray; +OBJC_CLASS NSButtonCell; +OBJC_CLASS NSControl; +OBJC_CLASS NSCursor; +OBJC_CLASS NSData; +OBJC_CLASS NSDate; +OBJC_CLASS NSEvent; +OBJC_CLASS NSFont; +OBJC_CLASS NSHTTPCookie; +OBJC_CLASS NSImage; +OBJC_CLASS NSMenu; +OBJC_CLASS NSMutableURLRequest; +OBJC_CLASS NSString; +OBJC_CLASS NSTextFieldCell; +OBJC_CLASS NSURL; +OBJC_CLASS NSURLConnection; +OBJC_CLASS NSURLRequest; +OBJC_CLASS NSURLResponse; +OBJC_CLASS NSView; +OBJC_CLASS NSWindow; +OBJC_CLASS QTMovie; +OBJC_CLASS QTMovieView; extern "C" { diff --git a/Source/WebCore/platform/network/ResourceHandle.h b/Source/WebCore/platform/network/ResourceHandle.h index a3633b2..1b1eacc 100644 --- a/Source/WebCore/platform/network/ResourceHandle.h +++ b/Source/WebCore/platform/network/ResourceHandle.h @@ -52,16 +52,11 @@ typedef LPVOID HINTERNET; #endif #if PLATFORM(MAC) -#ifdef __OBJC__ -@class NSData; -@class NSError; -@class NSURLConnection; -@class WebCoreResourceHandleAsDelegate; -#else -class NSData; -class NSError; -class NSURLConnection; -class WebCoreResourceHandleAsDelegate; +OBJC_CLASS NSData; +OBJC_CLASS NSError; +OBJC_CLASS NSURLConnection; +OBJC_CLASS WebCoreResourceHandleAsDelegate; +#ifndef __OBJC__ typedef struct objc_object *id; #endif #endif diff --git a/Source/WebCore/platform/network/ResourceHandleClient.h b/Source/WebCore/platform/network/ResourceHandleClient.h index a458b5d..befbccf 100644 --- a/Source/WebCore/platform/network/ResourceHandleClient.h +++ b/Source/WebCore/platform/network/ResourceHandleClient.h @@ -40,11 +40,7 @@ #endif #if PLATFORM(MAC) -#ifdef __OBJC__ -@class NSCachedURLResponse; -#else -class NSCachedURLResponse; -#endif +OBJC_CLASS NSCachedURLResponse; #endif namespace WebCore { diff --git a/Source/WebCore/platform/network/ResourceHandleInternal.h b/Source/WebCore/platform/network/ResourceHandleInternal.h index cad3834..8779979 100644 --- a/Source/WebCore/platform/network/ResourceHandleInternal.h +++ b/Source/WebCore/platform/network/ResourceHandleInternal.h @@ -61,13 +61,8 @@ class QNetworkReplyHandler; #endif #if PLATFORM(MAC) -#ifdef __OBJC__ -@class NSURLAuthenticationChallenge; -@class NSURLConnection; -#else -class NSURLAuthenticationChallenge; -class NSURLConnection; -#endif +OBJC_CLASS NSURLAuthenticationChallenge; +OBJC_CLASS NSURLConnection; #endif // The allocations and releases in ResourceHandleInternal are diff --git a/Source/WebCore/platform/network/cf/AuthenticationChallenge.h b/Source/WebCore/platform/network/cf/AuthenticationChallenge.h index ca4a06c..109ede8 100644 --- a/Source/WebCore/platform/network/cf/AuthenticationChallenge.h +++ b/Source/WebCore/platform/network/cf/AuthenticationChallenge.h @@ -31,14 +31,17 @@ #include #if USE(CFNETWORK) + typedef struct _CFURLAuthChallenge* CFURLAuthChallengeRef; + #else + #ifndef __OBJC__ typedef struct objc_object *id; -class NSURLAuthenticationChallenge; -#else -@class NSURLAuthenticationChallenge; #endif + +OBJC_CLASS NSURLAuthenticationChallenge; + #endif namespace WebCore { diff --git a/Source/WebCore/platform/network/cf/ResourceError.h b/Source/WebCore/platform/network/cf/ResourceError.h index 27c63ff..30e0a5e 100644 --- a/Source/WebCore/platform/network/cf/ResourceError.h +++ b/Source/WebCore/platform/network/cf/ResourceError.h @@ -37,10 +37,8 @@ #include // windows.h must be included before wincrypt.h. #endif -#ifdef __OBJC__ -@class NSError; -#else -class NSError; +#if PLATFORM(MAC) +OBJC_CLASS NSError; #endif namespace WebCore { diff --git a/Source/WebCore/platform/network/cf/ResourceRequest.h b/Source/WebCore/platform/network/cf/ResourceRequest.h index 47b155b..72522d9 100644 --- a/Source/WebCore/platform/network/cf/ResourceRequest.h +++ b/Source/WebCore/platform/network/cf/ResourceRequest.h @@ -34,11 +34,7 @@ typedef const struct _CFURLRequest* CFURLRequestRef; #endif -#ifdef __OBJC__ -@class NSURLRequest; -#else -class NSURLRequest; -#endif +OBJC_CLASS NSURLRequest; #if USE(CFURLSTORAGESESSIONS) && (defined(BUILDING_ON_SNOW_LEOPARD) || defined(BUILDING_ON_LEOPARD)) typedef struct __CFURLStorageSession* CFURLStorageSessionRef; diff --git a/Source/WebCore/platform/network/cf/ResourceResponse.h b/Source/WebCore/platform/network/cf/ResourceResponse.h index 946eee0..d83a661 100644 --- a/Source/WebCore/platform/network/cf/ResourceResponse.h +++ b/Source/WebCore/platform/network/cf/ResourceResponse.h @@ -33,11 +33,7 @@ typedef struct _CFURLResponse* CFURLResponseRef; #endif -#ifdef __OBJC__ -@class NSURLResponse; -#else -class NSURLResponse; -#endif +OBJC_CLASS NSURLResponse; namespace WebCore { diff --git a/Source/WebCore/rendering/RenderThemeMac.h b/Source/WebCore/rendering/RenderThemeMac.h index 42fe3e3..a6fc5b3 100644 --- a/Source/WebCore/rendering/RenderThemeMac.h +++ b/Source/WebCore/rendering/RenderThemeMac.h @@ -27,16 +27,12 @@ #import #import -class RenderProgress; -#ifdef __OBJC__ -@class WebCoreRenderThemeNotificationObserver; -#else -class WebCoreRenderThemeNotificationObserver; -#endif +OBJC_CLASS WebCoreRenderThemeNotificationObserver; namespace WebCore { +class RenderProgress; class RenderStyle; class RenderThemeMac : public RenderTheme { diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog index 7fe6366..c3b72a0 100644 --- a/Source/WebKit2/ChangeLog +++ b/Source/WebKit2/ChangeLog @@ -1,3 +1,16 @@ +2012-01-17 Sam Weinig + + Add helper macro for forward declaring objective-c classes + https://bugs.webkit.org/show_bug.cgi?id=76485 + + Reviewed by Anders Carlsson. + + * WebProcess/WebCoreSupport/WebDragClient.h: + Deploy OBJC_CLASS for a little code reduction. + + * config.h: + Remove duplicate copy of OBJC_CLASS. + 2012-01-17 Martin Robinson [GTK] [WK2] WebKitPrivate should include the entire WebKit2 C API diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h index f0109fd..913eb6e 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h @@ -29,13 +29,8 @@ #include #if PLATFORM(MAC) -#ifdef __OBJC__ -@class WKPasteboardFilePromiseOwner; -@class WKPasteboardOwner; -#else -class WKPasteboardFilePromiseOwner; -class WKPasteboardOwner; -#endif +OBJC_CLASS WKPasteboardFilePromiseOwner; +OBJC_CLASS WKPasteboardOwner; #endif namespace WebKit { diff --git a/Source/WebKit2/config.h b/Source/WebKit2/config.h index b8e8a77..7db76c0 100644 --- a/Source/WebKit2/config.h +++ b/Source/WebKit2/config.h @@ -61,12 +61,6 @@ static const type& name() \ #if PLATFORM(MAC) -#ifdef __OBJC__ -#define OBJC_CLASS @class -#else -#define OBJC_CLASS class -#endif - #if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) #define ENABLE_WEB_PROCESS_SANDBOX 1 #endif -- 2.7.4