ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/SDL/SDLMain.m
(Generate patch)

Comparing BasiliskII/src/SDL/SDLMain.m (file contents):
Revision 1.3 by asvitkine, 2011-12-29T07:38:34Z vs.
Revision 1.4 by asvitkine, 2012-06-15T22:52:49Z

# Line 5 | Line 5
5      Feel free to customize this file to suit your needs
6   */
7  
8 < #import "SDL.h"
9 < #import "SDLMain.h"
10 < #import <sys/param.h> /* for MAXPATHLEN */
11 < #import <unistd.h>
8 > #include "SDL.h"
9 > #include "SDLMain.h"
10 > #include <sys/param.h> /* for MAXPATHLEN */
11 > #include <unistd.h>
12  
13   /* For some reaon, Apple removed setAppleMenu from the headers in 10.4,
14   but the method still is there and works. To avoid warnings, we declare
# Line 43 | Line 43 | static BOOL   gCalledAppMainline = FALSE
43  
44   static NSString *getApplicationName(void)
45   {
46 <    NSDictionary *dict;
46 >    const NSDictionary *dict;
47      NSString *appName = 0;
48  
49      /* Determine the application name */
50 <    dict = (NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
50 >    dict = (const NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
51      if (dict)
52          appName = [dict objectForKey: @"CFBundleName"];
53      
# Line 64 | Line 64 | static NSString *getApplicationName(void
64   @end
65   #endif
66  
67 < @interface SDLApplication : NSApplication
67 > @interface NSApplication (SDLApplication)
68   @end
69  
70 < @implementation SDLApplication
70 > @implementation NSApplication (SDLApplication)
71   /* Invoked from the Quit menu item */
72   - (void)terminate:(id)sender
73   {
# Line 87 | Line 87 | static NSString *getApplicationName(void
87      if (shouldChdir)
88      {
89          char parentdir[MAXPATHLEN];
90 <                CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
91 <                CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url);
92 <                if (CFURLGetFileSystemRepresentation(url2, true, (UInt8 *)parentdir, MAXPATHLEN)) {
93 <                assert ( chdir (parentdir) == 0 );   /* chdir to the binary app's parent */
94 <                }
95 <                CFRelease(url);
96 <                CFRelease(url2);
97 <        }
98 <
90 >        CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
91 >        CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url);
92 >        if (CFURLGetFileSystemRepresentation(url2, 1, (UInt8 *)parentdir, MAXPATHLEN)) {
93 >            chdir(parentdir);   /* chdir to the binary app's parent */
94 >        }
95 >        CFRelease(url);
96 >        CFRelease(url2);
97 >    }
98   }
99  
100   #if SDL_USE_NIB_FILE
# Line 120 | Line 119 | static NSString *getApplicationName(void
119          if ([menuItem hasSubmenu])
120              [self fixMenu:[menuItem submenu] withAppName:appName];
121      }
123    [ aMenu sizeToFit ];
122   }
123  
124   #else
# Line 203 | Line 201 | static void CustomApplicationMain (int a
201      SDLMain                             *sdlMain;
202  
203      /* Ensure the application object is initialised */
204 <    [SDLApplication sharedApplication];
204 >    [NSApplication sharedApplication];
205      
206   #ifdef SDL_USE_CPS
207      {
# Line 212 | Line 210 | static void CustomApplicationMain (int a
210          if (!CPSGetCurrentProcess(&PSN))
211              if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
212                  if (!CPSSetFrontProcess(&PSN))
213 <                    [SDLApplication sharedApplication];
213 >                    [NSApplication sharedApplication];
214      }
215   #endif /* SDL_USE_CPS */
216  
# Line 319 | Line 317 | static void CustomApplicationMain (int a
317      NSString *result;
318  
319      bufferSize = selfLen + aStringLen - aRange.length;
320 <    buffer = NSAllocateMemoryPages(bufferSize*sizeof(unichar));
320 >    buffer = (unichar *)NSAllocateMemoryPages(bufferSize*sizeof(unichar));
321      
322      /* Get first part into buffer */
323      localRange.location = 0;
# Line 347 | Line 345 | static void CustomApplicationMain (int a
345   @end
346  
347  
348 +
349   #ifdef main
350   #  undef main
351   #endif
# Line 373 | Line 372 | int main (int argc, char **argv)
372      }
373  
374   #if SDL_USE_NIB_FILE
376    [SDLApplication poseAsClass:[NSApplication class]];
375      NSApplicationMain (argc, argv);
376   #else
377      CustomApplicationMain (argc, argv);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines