mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
macOS: Add support for building clients with ARC enabled (fixes issue #2623).
Under ARC (Automatic Reference Counting), assigning to an Objective-C pointer has different semantics than assigning to a void* pointer. This makes it dangerous to treat the same memory address as an Objective-C pointer in some cases and as a "regular C pointer" in other cases. This change removes the conditional type defines and instead uses void* everywhere. Explicit type casting in combination with ARC annotations makes it safe to get typed Objective-C pointers from the void* pointers. This change enables ARC by default in the CEF binary distribution CMake configuration for the cefclient and cefsimple sample applications. It can be disabled by adding `-DOPTION_USE_ARC=Off` to the CMake command line. ARC is not supported when building Chromium due to the substantial number of changes that would be required in the Chromium code base.
This commit is contained in:
committed by
Marshall Greenblatt
parent
491253fa03
commit
019611c764
@@ -37,29 +37,37 @@
|
||||
#include "include/internal/cef_string.h"
|
||||
|
||||
// Handle types.
|
||||
#ifdef __cplusplus
|
||||
#ifdef __OBJC__
|
||||
@class NSCursor;
|
||||
@class NSEvent;
|
||||
@class NSView;
|
||||
#else
|
||||
class NSCursor;
|
||||
class NSEvent;
|
||||
struct NSView;
|
||||
#endif
|
||||
#define cef_cursor_handle_t NSCursor*
|
||||
#define cef_event_handle_t NSEvent*
|
||||
#define cef_window_handle_t NSView*
|
||||
#else
|
||||
// Actually NSCursor*
|
||||
#define cef_cursor_handle_t void*
|
||||
// Acutally NSEvent*
|
||||
#define cef_event_handle_t void*
|
||||
// Actually NSView*
|
||||
#define cef_window_handle_t void*
|
||||
#endif
|
||||
|
||||
#define kNullCursorHandle NULL
|
||||
#define kNullEventHandle NULL
|
||||
#define kNullWindowHandle NULL
|
||||
|
||||
#ifdef __OBJC__
|
||||
#if __has_feature(objc_arc)
|
||||
#define CAST_CEF_CURSOR_HANDLE_TO_NSCURSOR(handle) ((__bridge NSCursor*)handle)
|
||||
#define CAST_CEF_EVENT_HANDLE_TO_NSEVENT(handle) ((__bridge NSEvent*)handle)
|
||||
#define CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(handle) ((__bridge NSView*)handle)
|
||||
|
||||
#define CAST_NSCURSOR_TO_CEF_CURSOR_HANDLE(cursor) ((__bridge void*)cursor)
|
||||
#define CAST_NSEVENT_TO_CEF_EVENT_HANDLE(event) ((__bridge void*)event)
|
||||
#define CAST_NSVIEW_TO_CEF_WINDOW_HANDLE(view) ((__bridge void*)view)
|
||||
#else // __has_feature(objc_arc)
|
||||
#define CAST_CEF_CURSOR_HANDLE_TO_NSCURSOR(handle) ((NSCursor*)handle)
|
||||
#define CAST_CEF_EVENT_HANDLE_TO_NSEVENT(handle) ((NSEvent*)handle)
|
||||
#define CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(handle) ((NSView*)handle)
|
||||
|
||||
#define CAST_NSCURSOR_TO_CEF_CURSOR_HANDLE(cursor) ((void*)cursor)
|
||||
#define CAST_NSEVENT_TO_CEF_EVENT_HANDLE(event) ((void*)event)
|
||||
#define CAST_NSVIEW_TO_CEF_WINDOW_HANDLE(view) ((void*)view)
|
||||
#endif // __has_feature(objc_arc)
|
||||
#endif // __OBJC__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user