On Sat, Aug 30, 2008 at 04:43:46PM +0300, Igor Stasenko wrote:
2008/8/30 David T. Lewis lewis@mail.msen.com:
On Fri, Aug 29, 2008 at 10:38:18PM +0200, Bert Freudenberg wrote:
Am 29.08.2008 um 22:18 schrieb Igor Stasenko:
i mean that its better to use file handles which is available on all platforms. and they actually should be open at the process startup
Maybe you misunderstood my patch then.
If the image tries to open a file named "/dev/stderr" then the VM now actually returns the pre-opened stderr rather than opening the named file. So this is independent of whether a file named "/dev/stderr" actually does exists or not, and it uses the proper file handles.
Yes this will work, but I agree with Igor.
<snip>
For example, here is the Windows implementation from OSPP:
Good, but maybe it can be more simplier? Just return a valid file handle on success, or fail primitive if not. Also, it can be a single prim (primitiveGetStdFileHandle) , with additional argument indicating which std stream to return e.g. 0 - for stdin 1 - for stdout 2 - for stderr
Here is an implementation that works on Unix, Mac OS X, and Windows. It's basically taken from OSProcessPlugin, with the Windows primitives cleaned up per your (sig) suggestion. I kept separate primitives for the three streams though, just because I personally prefer it that way (it's easy to change of course).
From the preambles:
'From Squeak3.9 of 7 November 2006 [latest update: #7067] on 7 September 2008 at 9:51:03 am'! "Change Set: FilePluginExtension-dtl Date: 7 September 2008 Author: David T. Lewis
FilePlugin extensions to support access to stdio streams, based on OSPP implementation. The added primitives are #primitiveGetStdOutHandle, #primitiveGetStdErrHandle, and #primitiveGetStdErrHandle. Unix, OS X, and Windows platforms are supported (or RiscOS, the default FilePlugin is used, and these primitives are not available).
The extensions are implemented in subclasses of FilePlugin. No external support code is required. If a recent version of VMMaker from SqueakSource is used, the VMMaker tool will automatically select the correct class for translation on Unix, Mac or Windows (otherwise the correct class must be selected manually in the VMMaker tool).
On Windows, the standard streams are associated with a console. Two additional primitives are provided for Windows to open and close the console. Some modification to the win32 support code will be required to allow registration of the standard input/output/error handles. For demonstration purposes, the registry may simply be disabled in the support code (sqWin32HandleTable.h)."!
'From Squeak3.9 of 7 November 2006 [latest update: #7067] on 3 September 2008 at 6:08:39 am'! "Change Set: StandardStream-dtl Date: 3 September 2008 Author: David T. Lewis
Provide access to stdin, stdout, stderr based on platform specific extensions to FilePlugin. The primitives are similar to those in OSProcessPlugin."!
- Dave