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

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

Issue 2762583003: Revert "Run dartfmt on all files under runtime." (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « runtime/bin/socket_patch.dart ('k') | runtime/bin/vmservice/server.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 5 @patch class _StdIOUtils {
6 class _StdIOUtils { 6 @patch static Stdin _getStdioInputStream() {
7 @patch
8 static Stdin _getStdioInputStream() {
9 switch (_getStdioHandleType(0)) { 7 switch (_getStdioHandleType(0)) {
10 case _STDIO_HANDLE_TYPE_TERMINAL: 8 case _STDIO_HANDLE_TYPE_TERMINAL:
11 case _STDIO_HANDLE_TYPE_PIPE: 9 case _STDIO_HANDLE_TYPE_PIPE:
12 case _STDIO_HANDLE_TYPE_SOCKET: 10 case _STDIO_HANDLE_TYPE_SOCKET:
13 return new Stdin._(new _Socket._readPipe(0)); 11 return new Stdin._(new _Socket._readPipe(0));
14 case _STDIO_HANDLE_TYPE_FILE: 12 case _STDIO_HANDLE_TYPE_FILE:
15 return new Stdin._(new _FileStream.forStdin()); 13 return new Stdin._(new _FileStream.forStdin());
16 default: 14 default:
17 throw new FileSystemException("Unsupported stdin type"); 15 throw new FileSystemException("Unsupported stdin type");
18 } 16 }
19 } 17 }
20 18
21 @patch 19 @patch static _getStdioOutputStream(int fd) {
22 static _getStdioOutputStream(int fd) {
23 assert(fd == 1 || fd == 2); 20 assert(fd == 1 || fd == 2);
24 switch (_getStdioHandleType(fd)) { 21 switch (_getStdioHandleType(fd)) {
25 case _STDIO_HANDLE_TYPE_TERMINAL: 22 case _STDIO_HANDLE_TYPE_TERMINAL:
26 case _STDIO_HANDLE_TYPE_PIPE: 23 case _STDIO_HANDLE_TYPE_PIPE:
27 case _STDIO_HANDLE_TYPE_SOCKET: 24 case _STDIO_HANDLE_TYPE_SOCKET:
28 case _STDIO_HANDLE_TYPE_FILE: 25 case _STDIO_HANDLE_TYPE_FILE:
29 return new Stdout._(new IOSink(new _StdConsumer(fd)), fd); 26 return new Stdout._(new IOSink(new _StdConsumer(fd)), fd);
30 default: 27 default:
31 throw new FileSystemException("Unsupported stdin type"); 28 throw new FileSystemException("Unsupported stdin type");
32 } 29 }
33 } 30 }
34 31
35 @patch 32 @patch static int _socketType(Socket socket) {
36 static int _socketType(Socket socket) {
37 if (socket is _Socket) return _nativeSocketType(socket._nativeSocket); 33 if (socket is _Socket) return _nativeSocketType(socket._nativeSocket);
38 return null; 34 return null;
39 } 35 }
40 36
41 static int _nativeSocketType(_NativeSocket nativeSocket) { 37 static int _nativeSocketType(_NativeSocket nativeSocket) {
42 var result = _getSocketType(nativeSocket); 38 var result = _getSocketType(nativeSocket);
43 if (result is OSError) { 39 if (result is OSError) {
44 throw new FileSystemException("Error retrieving socket type", "", result); 40 throw new FileSystemException(
41 "Error retrieving socket type", "", result);
45 } 42 }
46 return result; 43 return result;
47 } 44 }
48 45
49 @patch 46 @patch static _getStdioHandleType(int fd) native "File_GetStdioHandleType";
50 static _getStdioHandleType(int fd) native "File_GetStdioHandleType";
51 } 47 }
52 48
53 @patch 49 @patch class Stdin {
54 class Stdin { 50 @patch int readByteSync() {
55 @patch
56 int readByteSync() {
57 var result = _readByte(); 51 var result = _readByte();
58 if (result is OSError) { 52 if (result is OSError) {
59 throw new StdinException("Error reading byte from stdin", result); 53 throw new StdinException("Error reading byte from stdin", result);
60 } 54 }
61 return result; 55 return result;
62 } 56 }
63 57
64 @patch 58 @patch bool get echoMode {
65 bool get echoMode {
66 var result = _echoMode(); 59 var result = _echoMode();
67 if (result is OSError) { 60 if (result is OSError) {
68 throw new StdinException("Error getting terminal echo mode", result); 61 throw new StdinException("Error getting terminal echo mode", result);
69 } 62 }
70 return result; 63 return result;
71 } 64 }
72 65 @patch void set echoMode(bool enabled) {
73 @patch
74 void set echoMode(bool enabled) {
75 var result = _setEchoMode(enabled); 66 var result = _setEchoMode(enabled);
76 if (result is OSError) { 67 if (result is OSError) {
77 throw new StdinException("Error setting terminal echo mode", result); 68 throw new StdinException("Error setting terminal echo mode", result);
78 } 69 }
79 } 70 }
80 71
81 @patch 72 @patch bool get lineMode {
82 bool get lineMode {
83 var result = _lineMode(); 73 var result = _lineMode();
84 if (result is OSError) { 74 if (result is OSError) {
85 throw new StdinException("Error getting terminal line mode", result); 75 throw new StdinException("Error getting terminal line mode", result);
86 } 76 }
87 return result; 77 return result;
88 } 78 }
89 79 @patch void set lineMode(bool enabled) {
90 @patch
91 void set lineMode(bool enabled) {
92 var result = _setLineMode(enabled); 80 var result = _setLineMode(enabled);
93 if (result is OSError) { 81 if (result is OSError) {
94 throw new StdinException("Error setting terminal line mode", result); 82 throw new StdinException("Error setting terminal line mode", result);
95 } 83 }
96 } 84 }
97 85
98 @patch bool get supportsAnsiEscapes { 86 @patch bool get supportsAnsiEscapes {
99 var result = _supportsAnsiEscapes(); 87 var result = _supportsAnsiEscapes();
100 if (result is OSError) { 88 if (result is OSError) {
101 throw new StdinException("Error determining ANSI support", result); 89 throw new StdinException("Error determining ANSI support", result);
102 } 90 }
103 return result; 91 return result;
104 } 92 }
105 93
106 static _echoMode() native "Stdin_GetEchoMode"; 94 static _echoMode() native "Stdin_GetEchoMode";
107 static _setEchoMode(bool enabled) native "Stdin_SetEchoMode"; 95 static _setEchoMode(bool enabled) native "Stdin_SetEchoMode";
108 static _lineMode() native "Stdin_GetLineMode"; 96 static _lineMode() native "Stdin_GetLineMode";
109 static _setLineMode(bool enabled) native "Stdin_SetLineMode"; 97 static _setLineMode(bool enabled) native "Stdin_SetLineMode";
110 static _readByte() native "Stdin_ReadByte"; 98 static _readByte() native "Stdin_ReadByte";
111 static _supportsAnsiEscapes() native "Stdin_AnsiSupported"; 99 static _supportsAnsiEscapes() native "Stdin_AnsiSupported";
112 } 100 }
113 101
114 @patch 102 @patch class Stdout {
115 class Stdout { 103 @patch bool _hasTerminal(int fd) {
116 @patch
117 bool _hasTerminal(int fd) {
118 try { 104 try {
119 _terminalSize(fd); 105 _terminalSize(fd);
120 return true; 106 return true;
121 } catch (_) { 107 } catch (_) {
122 return false; 108 return false;
123 } 109 }
124 } 110 }
125 111
126 @patch 112 @patch int _terminalColumns(int fd) => _terminalSize(fd)[0];
127 int _terminalColumns(int fd) => _terminalSize(fd)[0]; 113 @patch int _terminalLines(int fd) => _terminalSize(fd)[1];
128 @patch
129 int _terminalLines(int fd) => _terminalSize(fd)[1];
130 114
131 static List _terminalSize(int fd) { 115 static List _terminalSize(int fd) {
132 var size = _getTerminalSize(fd); 116 var size = _getTerminalSize(fd);
133 if (size is! List) { 117 if (size is! List) {
134 throw new StdoutException("Could not get terminal size", size); 118 throw new StdoutException("Could not get terminal size", size);
135 } 119 }
136 return size; 120 return size;
137 } 121 }
138 122
139 static _getTerminalSize(int fd) native "Stdout_GetTerminalSize"; 123 static _getTerminalSize(int fd) native "Stdout_GetTerminalSize";
140 124
141 @patch static bool _supportsAnsiEscapes(int fd) { 125 @patch static bool _supportsAnsiEscapes(int fd) {
142 var result = _getAnsiSupported(fd); 126 var result = _getAnsiSupported(fd);
143 if (result is! bool) { 127 if (result is! bool) {
144 throw new StdoutException("Error determining ANSI support", result); 128 throw new StdoutException("Error determining ANSI support", result);
145 } 129 }
146 return result; 130 return result;
147 } 131 }
148 132
149 static _getAnsiSupported(int fd) native "Stdout_AnsiSupported"; 133 static _getAnsiSupported(int fd) native "Stdout_AnsiSupported";
150 } 134 }
151 135
136
152 _getStdioHandle(_NativeSocket socket, int num) native "Socket_GetStdioHandle"; 137 _getStdioHandle(_NativeSocket socket, int num) native "Socket_GetStdioHandle";
153 _getSocketType(_NativeSocket nativeSocket) native "Socket_GetType"; 138 _getSocketType(_NativeSocket nativeSocket) native "Socket_GetType";
OLDNEW
« no previous file with comments | « runtime/bin/socket_patch.dart ('k') | runtime/bin/vmservice/server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698