move NSAutoReleasePool_wrap() into its own file

This commit is contained in:
asvitkine 2011-12-29 07:39:56 +00:00
parent c78c3046db
commit dcf65b4d27
7 changed files with 67 additions and 14 deletions

View File

@ -0,0 +1,27 @@
/*
* utils_macosx.h - Mac OS X utility functions.
*
* Copyright (C) 2011 Alexei Svitkine
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef UTILS_MACOSX_H
#define UTILS_MACOSX_H
// Invokes the specified function with an NSAutoReleasePool in place.
void NSAutoReleasePool_wrap(void (*fn)(void));
#endif

View File

@ -0,0 +1,30 @@
/*
* utils_macosx.mm - Mac OS X utility functions.
*
* Copyright (C) 2011 Alexei Svitkine
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <Cocoa/Cocoa.h>
#include "utils_macosx.h"
// This is used from video_sdl.cpp.
void NSAutoReleasePool_wrap(void (*fn)(void))
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
fn();
[pool release];
}

View File

@ -346,13 +346,6 @@ static void CustomApplicationMain (int argc, char **argv)
@end
// This is used from video_sdl.cpp.
void NSAutoReleasePool_wrap(void (*fn)(void))
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
fn();
[pool release];
}
#ifdef main
# undef main

View File

@ -63,15 +63,13 @@
#include "video_blit.h"
#include "vm_alloc.h"
#if (defined(__APPLE__) && defined(__MACH__))
#include "utils_macosx.h"
#endif
#define DEBUG 0
#include "debug.h"
#if (defined(__APPLE__) && defined(__MACH__))
extern "C" {
void NSAutoReleasePool_wrap(void (*fn)(void));
}
#endif
// Supported video modes
using std::vector;
static vector<VIDEO_MODE> VideoModes;

View File

@ -711,6 +711,8 @@ if [[ "x$WANT_SDL_VIDEO" = "xyes" ]]; then
KEYCODES="../SDL/keycodes"
if [[ "x$ac_cv_framework_Carbon" = "xyes" ]]; then
EXTRASYSSRCS="$EXTRASYSSRCS ../MacOSX/clip_macosx.cpp"
EXTRASYSSRCS="$EXTRASYSSRCS ../MacOSX/utils_macosx.mm"
CPPFLAGS="$CPPFLAGS -I../MacOSX"
else
case "$target_os" in
cygwin*)

View File

@ -60,7 +60,7 @@ links:
BeOS/serial_beos.cpp BeOS/sys_beos.cpp BeOS/timer_beos.cpp \
BeOS/xpram_beos.cpp BeOS/SheepDriver BeOS/SheepNet \
Unix/audio_oss_esd.cpp Unix/bincue_unix.cpp Unix/bincue_unix.h \
Unix/vhd_unix.cpp Unix/vhd_unix.h \
Unix/vhd_unix.cpp Unix/vhd_unix.h \
Unix/extfs_unix.cpp Unix/serial_unix.cpp \
Unix/sshpty.h Unix/sshpty.c Unix/strlcpy.h Unix/strlcpy.c \
Unix/sys_unix.cpp Unix/timer_unix.cpp Unix/xpram_unix.cpp \
@ -79,6 +79,7 @@ links:
MacOSX/MacOSX_sound_if.cpp MacOSX/MacOSX_sound_if.h \
MacOSX/AudioBackEnd.cpp MacOSX/AudioBackEnd.h \
MacOSX/AudioDevice.cpp MacOSX/AudioDevice.h MacOSX/audio_macosx.cpp \
MacOSX/utils_macosx.mm MacOSX/utils_macosx.h \
Windows/cd_defs.h Windows/cdenable Windows/extfs_windows.cpp \
Windows/posix_emu.cpp Windows/posix_emu.h Windows/sys_windows.cpp \
Windows/timer_windows.cpp Windows/util_windows.cpp \

View File

@ -708,6 +708,8 @@ if [[ "x$WANT_SDL_VIDEO" = "xyes" ]]; then
KEYCODES="../SDL/keycodes"
if [[ "x$ac_cv_framework_Carbon" = "xyes" ]]; then
EXTRASYSSRCS="$EXTRASYSSRCS ../MacOSX/clip_macosx.cpp"
EXTRASYSSRCS="$EXTRASYSSRCS ../MacOSX/utils_macosx.mm"
CPPFLAGS="$CPPFLAGS -I../MacOSX"
else
EXTRASYSSRCS="$EXTRASYSSRCS ../dummy/clip_dummy.cpp"
fi