Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add java.io.FileDescriptor #124

Open
wants to merge 3 commits into
base: 4.7
Choose a base branch
from

Conversation

summer-alice
Copy link
Contributor

I want to get System.{in,out,err} to allow the SWTException and SWTError tests to be fully implemented. In particular, this would allow the .printStackTrace to use System.err_. I think it would also just be fun to have the streams working in general 😄

By default, each of the PrintStreams are File{Input,Output}Stream which use a FileDescriptor (ref).

Down the line this will allow FileOutputStream.this(FileDescriptor) to
work for STDIN, STDOUT, and STDERR

System.out and co. outline: https://stackoverflow.com/a/14435324
'const' from fFD and fHandle were removed to allow 'setting' in the
future.
Was used when in_, out_, and err were immutable but isn't required now.
@jacob-carlborg
Copy link
Member

Is this ported from the Java source code or is a reimplementation?

Comment on lines +33 to +42
package int getFD()
{
return fFD;
}

/// Windows file HANDLE
package void* getHandle()
{
return fHandle;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these be const as well? Otherwise they cannot be on the constants below.

version (Posix) {
return fFD >= 0;
} else version (Windows) {
return (fFD >= 0) && (fHandle !is null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is fFD ever used on Windows?

* Usually, this file descriptor is not used directly, but rather via the
* output stream known as `System.in`.
*/
public static const FileDescriptor in_;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if there are other static variables which are objects in the code base, but these are thread local storage, do we want that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants