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

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

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