Updated Objective-C implementation to use ARC; removed i386 support
This commit is contained in:
parent
ac28902b57
commit
0d47056132
@ -101,6 +101,12 @@ if(SFML_OS_MACOSX)
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Objective-C ARC requires a 64 bit runtime.
|
||||
if(NOT CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64")
|
||||
message(FATAL_ERROR "CMAKE_OSX_ARCHITECTURES should be 'x86_64' to support ARC")
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(SFML_OS_LINUX OR SFML_OS_FREEBSD)
|
||||
|
@ -61,6 +61,11 @@ macro(sfml_add_library target)
|
||||
set_target_properties(${target} PROPERTIES COMPILE_FLAGS -fvisibility=hidden)
|
||||
endif()
|
||||
|
||||
# On OS X, use Objective-C ARC
|
||||
if(SFML_OS_MACOSX)
|
||||
set_target_properties(${target} PROPERTIES COMPILE_FLAGS -fobjc-arc)
|
||||
endif()
|
||||
|
||||
# link the target to its SFML dependencies
|
||||
if(THIS_DEPENDS)
|
||||
target_link_libraries(${target} ${THIS_DEPENDS})
|
||||
|
@ -114,8 +114,6 @@ elseif(SFML_OS_MACOSX)
|
||||
${SRCROOT}/OSX/WindowImplCocoa.hpp
|
||||
${SRCROOT}/OSX/WindowImplCocoa.mm
|
||||
${SRCROOT}/OSX/WindowImplDelegateProtocol.h
|
||||
${SRCROOT}/OSX/AutoreleasePoolWrapper.h
|
||||
${SRCROOT}/OSX/AutoreleasePoolWrapper.mm
|
||||
)
|
||||
source_group("mac" FILES ${PLATFORM_SRC})
|
||||
endif()
|
||||
|
@ -57,7 +57,7 @@ namespace priv
|
||||
////////////////////////////////////////////////////////////
|
||||
SFOpenGLView* getSFOpenGLViewFromSFMLWindow(const Window& window)
|
||||
{
|
||||
id nsHandle = (id)window.getSystemHandle();
|
||||
id nsHandle = (__bridge id)window.getSystemHandle();
|
||||
|
||||
// Get our SFOpenGLView from ...
|
||||
SFOpenGLView* view = nil;
|
||||
|
@ -63,17 +63,17 @@
|
||||
|
||||
// Application Menu (aka Apple Menu)
|
||||
NSMenuItem* appleItem = [mainMenu addItemWithTitle:@"" action:nil keyEquivalent:@""];
|
||||
NSMenu* appleMenu = [[SFApplication createAppleMenu] autorelease];
|
||||
NSMenu* appleMenu = [SFApplication createAppleMenu];
|
||||
[appleItem setSubmenu:appleMenu];
|
||||
|
||||
// File Menu
|
||||
NSMenuItem* fileItem = [mainMenu addItemWithTitle:@"" action:nil keyEquivalent:@""];
|
||||
NSMenu* fileMenu = [[SFApplication createFileMenu] autorelease];
|
||||
NSMenu* fileMenu = [SFApplication createFileMenu];
|
||||
[fileItem setSubmenu:fileMenu];
|
||||
|
||||
// Window menu
|
||||
NSMenuItem* windowItem = [mainMenu addItemWithTitle:@"" action:nil keyEquivalent:@""];
|
||||
NSMenu* windowMenu = [[SFApplication createWindowMenu] autorelease];
|
||||
NSMenu* windowMenu = [SFApplication createWindowMenu];
|
||||
[windowItem setSubmenu:windowMenu];
|
||||
[NSApp setWindowsMenu:windowMenu];
|
||||
}
|
||||
@ -120,7 +120,7 @@
|
||||
[appleMenu addItem:[NSMenuItem separatorItem]];
|
||||
|
||||
// SERVICES
|
||||
NSMenu* serviceMenu = [[[NSMenu alloc] initWithTitle:@""] autorelease];
|
||||
NSMenu* serviceMenu = [[NSMenu alloc] initWithTitle:@""];
|
||||
NSMenuItem* serviceItem = [appleMenu addItemWithTitle:@"Services"
|
||||
action:nil
|
||||
keyEquivalent:@""];
|
||||
@ -174,7 +174,6 @@
|
||||
action:@selector(performClose:)
|
||||
keyEquivalent:@"w"];
|
||||
[fileMenu addItem:closeItem];
|
||||
[closeItem release];
|
||||
|
||||
return fileMenu;
|
||||
}
|
||||
@ -199,7 +198,6 @@
|
||||
action:@selector(performMiniaturize:)
|
||||
keyEquivalent:@"m"];
|
||||
[windowMenu addItem:minimizeItem];
|
||||
[minimizeItem release];
|
||||
|
||||
// ZOOM
|
||||
[windowMenu addItemWithTitle:@"Zoom"
|
||||
|
@ -30,8 +30,6 @@
|
||||
#include <SFML/Window/OSX/WindowImplCocoa.hpp>
|
||||
#include <SFML/System/Err.hpp>
|
||||
|
||||
#import <SFML/Window/OSX/AutoreleasePoolWrapper.h>
|
||||
|
||||
namespace sf
|
||||
{
|
||||
namespace priv
|
||||
@ -43,9 +41,6 @@ SFContext::SFContext(SFContext* shared) :
|
||||
m_view(0),
|
||||
m_window(0)
|
||||
{
|
||||
// Ask for a pool.
|
||||
retainPool();
|
||||
|
||||
// Create the context
|
||||
createContext(shared,
|
||||
VideoMode::getDesktopMode().bitsPerPixel,
|
||||
@ -59,9 +54,6 @@ SFContext::SFContext(SFContext* shared, const ContextSettings& settings,
|
||||
m_view(0),
|
||||
m_window(0)
|
||||
{
|
||||
// Ask for a pool.
|
||||
retainPool();
|
||||
|
||||
// Create the context.
|
||||
createContext(shared, bitsPerPixel, settings);
|
||||
|
||||
@ -80,9 +72,6 @@ m_window(0)
|
||||
// Ensure the process is setup in order to create a valid window.
|
||||
WindowImplCocoa::setUpProcess();
|
||||
|
||||
// Ask for a pool.
|
||||
retainPool();
|
||||
|
||||
// Create the context.
|
||||
createContext(shared, VideoMode::getDesktopMode().bitsPerPixel, settings);
|
||||
|
||||
@ -102,12 +91,6 @@ m_window(0)
|
||||
SFContext::~SFContext()
|
||||
{
|
||||
[m_context clearDrawable];
|
||||
[m_context release];
|
||||
|
||||
[m_view release]; // Might be nil but we don't care.
|
||||
[m_window release]; // Idem.
|
||||
|
||||
releasePool();
|
||||
}
|
||||
|
||||
|
||||
@ -210,9 +193,6 @@ void SFContext::createContext(SFContext* shared,
|
||||
if (m_context == nil)
|
||||
sf::err() << "Error. Unable to create the context." << std::endl;
|
||||
|
||||
// Free up.
|
||||
[pixFmt release];
|
||||
|
||||
// Save the settings. (OpenGL version is updated elsewhere.)
|
||||
m_settings = settings;
|
||||
}
|
||||
|
@ -292,14 +292,7 @@ BOOL isValidTextUnicode(NSEvent* event);
|
||||
// Unregister
|
||||
[self removeTrackingArea:m_trackingArea];
|
||||
|
||||
// Release attributes
|
||||
[m_hiddenTextView release];
|
||||
[m_silentResponder release];
|
||||
[m_trackingArea release];
|
||||
|
||||
[self setRequesterTo:0];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,7 +44,7 @@
|
||||
m_requester = 0;
|
||||
|
||||
// Retain the view for our own use.
|
||||
m_view = [view retain];
|
||||
m_view = view;
|
||||
|
||||
if (m_view == nil)
|
||||
{
|
||||
@ -81,11 +81,6 @@
|
||||
-(void)dealloc
|
||||
{
|
||||
[self closeWindow];
|
||||
|
||||
[m_view release];
|
||||
[m_oglView release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
||||
@ -101,7 +96,7 @@
|
||||
////////////////////////////////////////////////////////
|
||||
-(sf::WindowHandle)getSystemHandle
|
||||
{
|
||||
return m_view;
|
||||
return (__bridge sf::WindowHandle)m_view;
|
||||
}
|
||||
|
||||
|
||||
|
@ -77,7 +77,7 @@
|
||||
m_fullscreenMode = new sf::VideoMode();
|
||||
|
||||
// Retain the window for our own use.
|
||||
m_window = [window retain];
|
||||
m_window = window;
|
||||
|
||||
if (m_window == nil)
|
||||
{
|
||||
@ -254,12 +254,7 @@
|
||||
[self closeWindow];
|
||||
[NSMenu setMenuBarVisible:YES];
|
||||
|
||||
[m_window release];
|
||||
[m_oglView release];
|
||||
|
||||
delete m_fullscreenMode;
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
||||
@ -279,7 +274,7 @@
|
||||
////////////////////////////////////////////////////////
|
||||
-(sf::WindowHandle)getSystemHandle
|
||||
{
|
||||
return m_window;
|
||||
return (__bridge sf::WindowHandle)m_window;
|
||||
}
|
||||
|
||||
|
||||
@ -446,10 +441,6 @@
|
||||
|
||||
// Set app icon.
|
||||
[[SFApplication sharedApplication] setApplicationIconImage:icon];
|
||||
|
||||
// Free up.
|
||||
[icon release];
|
||||
[bitmap release];
|
||||
}
|
||||
|
||||
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include <SFML/System/Err.hpp>
|
||||
#include <SFML/System/String.hpp>
|
||||
|
||||
#import <SFML/Window/OSX/AutoreleasePoolWrapper.h>
|
||||
#import <SFML/Window/OSX/cpp_objc_conversion.h>
|
||||
#import <SFML/Window/OSX/SFApplication.h>
|
||||
#import <SFML/Window/OSX/SFApplicationDelegate.h>
|
||||
@ -50,11 +49,8 @@ namespace priv
|
||||
WindowImplCocoa::WindowImplCocoa(WindowHandle handle) :
|
||||
m_showCursor(true)
|
||||
{
|
||||
// Ask for a pool.
|
||||
retainPool();
|
||||
|
||||
// Treat the handle as it real type
|
||||
id nsHandle = (id)handle;
|
||||
id nsHandle = (__bridge id)handle;
|
||||
if ([nsHandle isKindOfClass:[NSWindow class]])
|
||||
{
|
||||
// We have a window.
|
||||
@ -95,9 +91,6 @@ m_showCursor(true)
|
||||
// Transform the app process.
|
||||
setUpProcess();
|
||||
|
||||
// Ask for a pool.
|
||||
retainPool();
|
||||
|
||||
m_delegate = [[SFWindowController alloc] initWithMode:mode andStyle:style];
|
||||
[m_delegate changeTitle:sfStringToNSString(title)];
|
||||
[m_delegate setRequesterTo:this];
|
||||
@ -112,18 +105,10 @@ WindowImplCocoa::~WindowImplCocoa()
|
||||
{
|
||||
[m_delegate closeWindow];
|
||||
|
||||
[m_delegate release];
|
||||
|
||||
// Put the next window in front, if any.
|
||||
NSArray* windows = [NSApp orderedWindows];
|
||||
if ([windows count] > 0)
|
||||
[[windows objectAtIndex:0] makeKeyAndOrderFront:nil];
|
||||
|
||||
releasePool();
|
||||
|
||||
drainPool(); // Make sure everything was freed
|
||||
// This solve some issue when sf::Window::Create is called for the
|
||||
// second time (nothing was render until the function was called again)
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user