Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: runtime/bin/stdio_patch.dart

Issue 154273003: Make std* blocking file-descriptors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update with bug. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/stdio_macos.cc ('k') | sdk/lib/_internal/lib/io_patch.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 patch class _StdIOUtils { 5 patch class _StdIOUtils {
6 static Stdin _getStdioInputStream() { 6 static Stdin _getStdioInputStream() {
7 switch (_getStdioHandleType(0)) { 7 switch (_getStdioHandleType(0)) {
8 case _STDIO_HANDLE_TYPE_TERMINAL: 8 case _STDIO_HANDLE_TYPE_TERMINAL:
9 case _STDIO_HANDLE_TYPE_PIPE: 9 case _STDIO_HANDLE_TYPE_PIPE:
10 case _STDIO_HANDLE_TYPE_SOCKET: 10 case _STDIO_HANDLE_TYPE_SOCKET:
(...skipping 11 matching lines...) Expand all
22 return new Stdout._(sink); 22 return new Stdout._(sink);
23 } else { 23 } else {
24 return new _StdSink(sink); 24 return new _StdSink(sink);
25 } 25 }
26 } 26 }
27 assert(fd == 1 || fd == 2); 27 assert(fd == 1 || fd == 2);
28 switch (_getStdioHandleType(fd)) { 28 switch (_getStdioHandleType(fd)) {
29 case _STDIO_HANDLE_TYPE_TERMINAL: 29 case _STDIO_HANDLE_TYPE_TERMINAL:
30 case _STDIO_HANDLE_TYPE_PIPE: 30 case _STDIO_HANDLE_TYPE_PIPE:
31 case _STDIO_HANDLE_TYPE_SOCKET: 31 case _STDIO_HANDLE_TYPE_SOCKET:
32 return wrap(new _Socket._writePipe(fd));
33 case _STDIO_HANDLE_TYPE_FILE: 32 case _STDIO_HANDLE_TYPE_FILE:
34 return wrap(new IOSink(new _FileStreamConsumer.fromStdio(fd))); 33 return wrap(new IOSink(new _FileStreamConsumer.fromStdio(fd)));
35 default: 34 default:
36 throw new FileSystemException("Unsupported stdin type"); 35 throw new FileSystemException("Unsupported stdin type");
37 } 36 }
38 } 37 }
39 38
40 static int _socketType(nativeSocket) { 39 static int _socketType(nativeSocket) {
41 var result = _getSocketType(nativeSocket); 40 var result = _getSocketType(nativeSocket);
42 if (result is OSError) { 41 if (result is OSError) {
43 throw new FileSystemException("Error retreiving socket type", result); 42 throw new FileSystemException("Error retreiving socket type", result);
44 } 43 }
45 return result; 44 return result;
46 } 45 }
46
47 static _getStdioHandleType(int fd) native "File_GetStdioHandleType";
47 } 48 }
48 49
49 patch class Stdin { 50 patch class Stdin {
50 /* patch */ int readByteSync() native "Stdin_ReadByte"; 51 /* patch */ int readByteSync() native "Stdin_ReadByte";
51 52
52 /* patch */ bool get echoMode => _echoMode; 53 /* patch */ bool get echoMode => _echoMode;
53 /* patch */ void set echoMode(bool enabled) { _echoMode = enabled; } 54 /* patch */ void set echoMode(bool enabled) { _echoMode = enabled; }
54 55
55 /* patch */ bool get lineMode => _lineMode; 56 /* patch */ bool get lineMode => _lineMode;
56 /* patch */ void set lineMode(bool enabled) { _lineMode = enabled; } 57 /* patch */ void set lineMode(bool enabled) { _lineMode = enabled; }
(...skipping 23 matching lines...) Expand all
80 throw new StdoutException("Could not get terminal size", size); 81 throw new StdoutException("Could not get terminal size", size);
81 } 82 }
82 return size; 83 return size;
83 } 84 }
84 85
85 static _getTerminalSize() native "Stdout_GetTerminalSize"; 86 static _getTerminalSize() native "Stdout_GetTerminalSize";
86 } 87 }
87 88
88 89
89 _getStdioHandle(_NativeSocket socket, int num) native "Socket_GetStdioHandle"; 90 _getStdioHandle(_NativeSocket socket, int num) native "Socket_GetStdioHandle";
90 _getStdioHandleType(int num) native "File_GetStdioHandleType";
91 _getSocketType(_NativeSocket nativeSocket) native "Socket_GetType"; 91 _getSocketType(_NativeSocket nativeSocket) native "Socket_GetType";
OLDNEW
« no previous file with comments | « runtime/bin/stdio_macos.cc ('k') | sdk/lib/_internal/lib/io_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698