]> git.saurik.com Git - wxWidgets.git/blobdiff - src/cocoa/utilsexc.mm
allow using both char* and wchar_t* in wxFileConfig and wxConfigBase, too
[wxWidgets.git] / src / cocoa / utilsexc.mm
index 13400d029a9e7239b758c7d16656fe0e7ea4cbff..348c1c1060eb16cc091427de61882d71d0902808 100644 (file)
@@ -6,27 +6,28 @@
 // Created:     2004-10-05
 // RCS-ID:      $Id$
 // Copyright:   (c) Ryan Norton
-// Licence:    wxWindows licence
+// Licence:     wxWindows licence
 // Notes:       This code may be useful on platforms other than Darwin.
 //              On Darwin we share the CoreFoundation code with wxMac.
 /////////////////////////////////////////////////////////////////////////////
 
 #include "wx/wxprec.h"
+
 #ifndef WX_PRECOMP
+    #include "wx/utils.h"
 #endif
+
 #include "wx/unix/execute.h"
-#include "wx/utils.h"
 
 #if 0
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
-#include "wx/utils.h"
+#ifndef   WX_PRECOMP
+    #if wxUSE_STREAMS
+        #include  "wx/stream.h"
+    #endif // wxUSE_STREAMS
+#endif  //WX_PRECOMP
 
 #include "wx/process.h"
-#include "wx/stream.h"
 
 #include "wx/cocoa/string.h"
 
 class wxPipeInputStream : public wxInputStream
 {
 public:
-    wxPipeInputStream(NSPipe* thePipe) : 
+    wxPipeInputStream(NSPipe* thePipe) :
             m_thePipe(thePipe),
             m_theHandle([m_thePipe fileHandleForReading])
     {
     }
 
     ~wxPipeInputStream()
-    {  
+    {
         [m_thePipe release];
     }
 
@@ -61,23 +62,23 @@ protected:
         memcpy(buffer, [theData bytes], [theData length]);
         return [theData length];
     }
-    
-    
-    NSPipe*            m_thePipe;
-    NSFileHandle*      m_theHandle;
+
+
+    NSPipe* m_thePipe;
+    NSFileHandle* m_theHandle;
 };
 
 class wxPipeOutputStream : public wxOutputStream
 {
 public:
-    wxPipeOutputStream(NSPipe* thePipe) : 
+    wxPipeOutputStream(NSPipe* thePipe) :
             m_thePipe(thePipe),
             m_theHandle([m_thePipe fileHandleForWriting])
     {
     }
 
     ~wxPipeOutputStream()
-    {  
+    {
         [m_thePipe release];
     }
 
@@ -85,14 +86,14 @@ protected:
 
     virtual size_t OnSysWrite(const void *buffer, size_t bufsize)
     {
-        NSData* theData = [NSData dataWithBytesNoCopy:(void*)buffer 
+        NSData* theData = [NSData dataWithBytesNoCopy:(void*)buffer
                                   length:bufsize];
         [m_theHandle writeData:theData];
         return bufsize;
     }
-        
-    NSPipe*            m_thePipe;
-    NSFileHandle*      m_theHandle;
+
+    NSPipe* m_thePipe;
+    NSFileHandle* m_theHandle;
 };
 
 @interface wxTaskHandler : NSObject
@@ -106,89 +107,88 @@ protected:
 
 @implementation wxTaskHandler : NSObject
 
--(id)init:(void*)handle processIdentifier:(long)pid 
+-(id)init:(void*)handle processIdentifier:(long)pid
 {
     self = [super init];
-    
+
     m_handle = handle;
     m_pid = pid;
 
-    [[NSNotificationCenter defaultCenter] addObserver:self 
-            selector:@selector(termHandler:) 
-            name:NSTaskDidTerminateNotification 
+    [[NSNotificationCenter defaultCenter] addObserver:self
+            selector:@selector(termHandler:)
+            name:NSTaskDidTerminateNotification
             object:nil];
     return self;
 }
 
-- (void)termHandler:(NSNotification *)aNotification 
+- (void)termHandler:(NSNotification *)aNotification
 {
     NSTask* theTask = [aNotification object];
-    
+
     if ([theTask processIdentifier] == m_pid)
     {
-        ((wxProcess*)m_handle)->OnTerminate([theTask processIdentifier], 
+        ((wxProcess*)m_handle)->OnTerminate([theTask processIdentifier],
                           [theTask terminationStatus]);
-        
+
         [self release];
     }
 }
 
 @end
 
-long wxExecute(const wxString& command, 
-                int sync, 
-                wxProcess *handle)
+long wxExecute(const wxString& command,
+               int sync,
+               wxProcess *handle)
 {
     NSTask* theTask = [[NSTask alloc] init];
-    
+
     if (handle && handle->IsRedirected())
     {
         NSPipe* theStdinPipe = [[NSPipe alloc] init];
         NSPipe* theStderrPipe = [[NSPipe alloc] init];
         NSPipe* theStdoutPipe = [[NSPipe alloc] init];
-    
+
         [theTask setStandardInput:theStdinPipe];
         [theTask setStandardError:theStderrPipe];
         [theTask setStandardOutput:theStdoutPipe];
-        
+
         handle->SetPipeStreams(new wxPipeInputStream(theStdoutPipe),
                                new wxPipeOutputStream(theStdinPipe),
                                new wxPipeInputStream(theStderrPipe) );
     }
-    
-    NSArray* theQuoteArguments = 
+
+    NSArray* theQuoteArguments =
         [wxNSStringWithWxString(command) componentsSeparatedByString:@"\""];
-        
-    NSMutableArray* theSeperatedArguments = 
+
+    NSMutableArray* theSeparatedArguments =
         [NSMutableArray arrayWithCapacity:10];
-        
+
     for (unsigned i = 0; i < [theQuoteArguments count]; ++i)
     {
-        [theSeperatedArguments addObjectsFromArray:
+        [theSeparatedArguments addObjectsFromArray:
             [[theQuoteArguments objectAtIndex:i] componentsSeparatedByString:@" "]
         ];
-        
+
         if(++i < [theQuoteArguments count])
-            [theSeperatedArguments addObject:[theQuoteArguments objectAtIndex:i]];
+            [theSeparatedArguments addObject:[theQuoteArguments objectAtIndex:i]];
     }
-    
-    [theTask setLaunchPath:[theSeperatedArguments objectAtIndex:0]];
-    [theTask setArguments:theSeperatedArguments];
+
+    [theTask setLaunchPath:[theSeparatedArguments objectAtIndex:0]];
+    [theTask setArguments:theSeparatedArguments];
     [theTask launch];
-    
+
     if(sync & wxEXEC_ASYNC)
     {
-        [[wxTaskHandler alloc]init:handle 
+        [[wxTaskHandler alloc]init:handle
                               processIdentifier:[theTask processIdentifier]];
-                                
+
         return 0;
     }
     else
     {
         [theTask waitUntilExit];
-        
+
         return [theTask terminationStatus];
-    }                      
+    }
 }
 #endif //0
-