projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[ 1509599 ] 'Split pickers page in widgets sample' with more icons and rebaking.
[wxWidgets.git]
/
src
/
cocoa
/
utilsexc.mm
diff --git
a/src/cocoa/utilsexc.mm
b/src/cocoa/utilsexc.mm
index 7d01c682fca935725c7802c9f7a20ec165b5a5ff..348c1c1060eb16cc091427de61882d71d0902808 100644
(file)
--- a/
src/cocoa/utilsexc.mm
+++ b/
src/cocoa/utilsexc.mm
@@
-1,39
+1,57
@@
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
-// Name: utilsexec.mm
+// Name:
src/cocoa/
utilsexec.mm
// Purpose: Execution-related utilities for wxCocoa
// Author: Ryan Norton
// Modified by:
// Created: 2004-10-05
// RCS-ID: $Id$
// Copyright: (c) Ryan Norton
// Purpose: Execution-related utilities for wxCocoa
// Author: Ryan Norton
// Modified by:
// 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.
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
-#ifdef __GNUG__
-#pragma implementation
+#include "wx/wxprec.h"
+
+#ifndef WX_PRECOMP
+ #include "wx/utils.h"
#endif
#endif
-#include "wx/utils.h"
+#include "wx/unix/execute.h"
+
+#if 0
+
+#ifndef WX_PRECOMP
+ #if wxUSE_STREAMS
+ #include "wx/stream.h"
+ #endif // wxUSE_STREAMS
+#endif //WX_PRECOMP
#include "wx/process.h"
#include "wx/process.h"
-#include "wx/stream.h"
#include "wx/cocoa/string.h"
#import <Foundation/Foundation.h>
#import <AppKit/NSWorkspace.h>
#include "wx/cocoa/string.h"
#import <Foundation/Foundation.h>
#import <AppKit/NSWorkspace.h>
+//
+// RN: This is a prelimenary implementation - simple
+// launching and process redirection works,
+// but with the piping tests in the exec sample
+// SIGPIPE is triggered...
+//
+
class wxPipeInputStream : public wxInputStream
{
public:
class wxPipeInputStream : public wxInputStream
{
public:
- wxPipeInputStream(NSPipe* thePipe) :
+ wxPipeInputStream(NSPipe* thePipe) :
m_thePipe(thePipe),
m_theHandle([m_thePipe fileHandleForReading])
{
}
~wxPipeInputStream()
m_thePipe(thePipe),
m_theHandle([m_thePipe fileHandleForReading])
{
}
~wxPipeInputStream()
- {
+ {
[m_thePipe release];
}
[m_thePipe release];
}
@@
-44,23
+62,23
@@
protected:
memcpy(buffer, [theData bytes], [theData length]);
return [theData length];
}
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:
};
class wxPipeOutputStream : public wxOutputStream
{
public:
- wxPipeOutputStream(NSPipe* thePipe) :
+ wxPipeOutputStream(NSPipe* thePipe) :
m_thePipe(thePipe),
m_theHandle([m_thePipe fileHandleForWriting])
{
}
~wxPipeOutputStream()
m_thePipe(thePipe),
m_theHandle([m_thePipe fileHandleForWriting])
{
}
~wxPipeOutputStream()
- {
+ {
[m_thePipe release];
}
[m_thePipe release];
}
@@
-68,14
+86,14
@@
protected:
virtual size_t OnSysWrite(const void *buffer, size_t bufsize)
{
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;
}
length:bufsize];
[m_theHandle writeData:theData];
return bufsize;
}
-
- NSPipe*
m_thePipe;
- NSFileHandle*
m_theHandle;
+
+ NSPipe* m_thePipe;
+ NSFileHandle* m_theHandle;
};
@interface wxTaskHandler : NSObject
};
@interface wxTaskHandler : NSObject
@@
-89,87
+107,88
@@
protected:
@implementation wxTaskHandler : NSObject
@implementation wxTaskHandler : NSObject
--(id)init:(void*)handle processIdentifier:(long)pid
+-(id)init:(void*)handle processIdentifier:(long)pid
{
self = [super init];
{
self = [super init];
-
+
m_handle = handle;
m_pid = pid;
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;
}
object:nil];
return self;
}
-- (void)termHandler:(NSNotification *)aNotification
+- (void)termHandler:(NSNotification *)aNotification
{
NSTask* theTask = [aNotification object];
{
NSTask* theTask = [aNotification object];
-
+
if ([theTask processIdentifier] == m_pid)
{
if ([theTask processIdentifier] == m_pid)
{
- ((wxProcess*)m_handle)->OnTerminate([theTask processIdentifier],
+ ((wxProcess*)m_handle)->OnTerminate([theTask processIdentifier],
[theTask terminationStatus]);
[theTask terminationStatus]);
-
+
[self release];
}
}
@end
[self release];
}
}
@end
-long wxExecute(const wxString& command,
- int sync = wxEXEC_ASYNC,
-
wxProcess *handle = NULL
)
+long wxExecute(const wxString& command,
+ int sync,
+
wxProcess *handle
)
{
NSTask* theTask = [[NSTask alloc] init];
{
NSTask* theTask = [[NSTask alloc] init];
-
+
if (handle && handle->IsRedirected())
{
NSPipe* theStdinPipe = [[NSPipe alloc] init];
NSPipe* theStderrPipe = [[NSPipe alloc] init];
NSPipe* theStdoutPipe = [[NSPipe 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];
[theTask setStandardInput:theStdinPipe];
[theTask setStandardError:theStderrPipe];
[theTask setStandardOutput:theStdoutPipe];
-
+
handle->SetPipeStreams(new wxPipeInputStream(theStdoutPipe),
new wxPipeOutputStream(theStdinPipe),
new wxPipeInputStream(theStderrPipe) );
}
handle->SetPipeStreams(new wxPipeInputStream(theStdoutPipe),
new wxPipeOutputStream(theStdinPipe),
new wxPipeInputStream(theStderrPipe) );
}
-
- NSArray* theQuoteArguments =
+
+ NSArray* theQuoteArguments =
[wxNSStringWithWxString(command) componentsSeparatedByString:@"\""];
[wxNSStringWithWxString(command) componentsSeparatedByString:@"\""];
-
- NSMutableArray* theSep
eratedArguments =
+
+ NSMutableArray* theSep
aratedArguments =
[NSMutableArray arrayWithCapacity:10];
[NSMutableArray arrayWithCapacity:10];
-
+
for (unsigned i = 0; i < [theQuoteArguments count]; ++i)
{
for (unsigned i = 0; i < [theQuoteArguments count]; ++i)
{
- [theSep
e
ratedArguments addObjectsFromArray:
+ [theSep
a
ratedArguments addObjectsFromArray:
[[theQuoteArguments objectAtIndex:i] componentsSeparatedByString:@" "]
];
[[theQuoteArguments objectAtIndex:i] componentsSeparatedByString:@" "]
];
-
+
if(++i < [theQuoteArguments count])
if(++i < [theQuoteArguments count])
- [theSep
e
ratedArguments addObject:[theQuoteArguments objectAtIndex:i]];
+ [theSep
a
ratedArguments addObject:[theQuoteArguments objectAtIndex:i]];
}
}
-
- [theTask setLaunchPath:[theSep
e
ratedArguments objectAtIndex:0]];
- [theTask setArguments:theSep
e
ratedArguments];
+
+ [theTask setLaunchPath:[theSep
a
ratedArguments objectAtIndex:0]];
+ [theTask setArguments:theSep
a
ratedArguments];
[theTask launch];
[theTask launch];
-
+
if(sync & wxEXEC_ASYNC)
{
if(sync & wxEXEC_ASYNC)
{
- [[wxTaskHandler alloc]init:handle
+ [[wxTaskHandler alloc]init:handle
processIdentifier:[theTask processIdentifier]];
processIdentifier:[theTask processIdentifier]];
-
+
return 0;
}
else
{
[theTask waitUntilExit];
return 0;
}
else
{
[theTask waitUntilExit];
-
+
return [theTask terminationStatus];
return [theTask terminationStatus];
- }
-}
\ No newline at end of file
+ }
+}
+#endif //0