From dcf65b4d2764e5446d98bab83d6c4839651a6f43 Mon Sep 17 00:00:00 2001 From: asvitkine <> Date: Thu, 29 Dec 2011 07:39:56 +0000 Subject: [PATCH] move NSAutoReleasePool_wrap() into its own file --- BasiliskII/src/MacOSX/utils_macosx.h | 27 ++++++++++++++++++++++++ BasiliskII/src/MacOSX/utils_macosx.mm | 30 +++++++++++++++++++++++++++ BasiliskII/src/SDL/SDLMain.m | 7 ------- BasiliskII/src/SDL/video_sdl.cpp | 10 ++++----- BasiliskII/src/Unix/configure.ac | 2 ++ SheepShaver/Makefile | 3 ++- SheepShaver/src/Unix/configure.ac | 2 ++ 7 files changed, 67 insertions(+), 14 deletions(-) create mode 100644 BasiliskII/src/MacOSX/utils_macosx.h create mode 100644 BasiliskII/src/MacOSX/utils_macosx.mm diff --git a/BasiliskII/src/MacOSX/utils_macosx.h b/BasiliskII/src/MacOSX/utils_macosx.h new file mode 100644 index 00000000..fc2c83c6 --- /dev/null +++ b/BasiliskII/src/MacOSX/utils_macosx.h @@ -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 diff --git a/BasiliskII/src/MacOSX/utils_macosx.mm b/BasiliskII/src/MacOSX/utils_macosx.mm new file mode 100644 index 00000000..b653638d --- /dev/null +++ b/BasiliskII/src/MacOSX/utils_macosx.mm @@ -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 +#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]; +} diff --git a/BasiliskII/src/SDL/SDLMain.m b/BasiliskII/src/SDL/SDLMain.m index 1865aa10..6124a6f8 100644 --- a/BasiliskII/src/SDL/SDLMain.m +++ b/BasiliskII/src/SDL/SDLMain.m @@ -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 diff --git a/BasiliskII/src/SDL/video_sdl.cpp b/BasiliskII/src/SDL/video_sdl.cpp index 2f051b3e..07e6cddc 100644 --- a/BasiliskII/src/SDL/video_sdl.cpp +++ b/BasiliskII/src/SDL/video_sdl.cpp @@ -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 VideoModes; diff --git a/BasiliskII/src/Unix/configure.ac b/BasiliskII/src/Unix/configure.ac index 1725bf93..9cb04b31 100644 --- a/BasiliskII/src/Unix/configure.ac +++ b/BasiliskII/src/Unix/configure.ac @@ -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*) diff --git a/SheepShaver/Makefile b/SheepShaver/Makefile index 8f93f30f..dde47390 100644 --- a/SheepShaver/Makefile +++ b/SheepShaver/Makefile @@ -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 \ diff --git a/SheepShaver/src/Unix/configure.ac b/SheepShaver/src/Unix/configure.ac index 0867497e..3c7d55e3 100644 --- a/SheepShaver/src/Unix/configure.ac +++ b/SheepShaver/src/Unix/configure.ac @@ -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