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

Side by Side Diff: sdk/lib/io/stdio.dart

Issue 1904553006: Fix strong mode errors in dart:io. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comment.~ Created 4 years, 7 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
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 part of dart.io; 5 part of dart.io;
6 6
7 const int _STDIO_HANDLE_TYPE_TERMINAL = 0; 7 const int _STDIO_HANDLE_TYPE_TERMINAL = 0;
8 const int _STDIO_HANDLE_TYPE_PIPE = 1; 8 const int _STDIO_HANDLE_TYPE_PIPE = 1;
9 const int _STDIO_HANDLE_TYPE_FILE = 2; 9 const int _STDIO_HANDLE_TYPE_FILE = 2;
10 const int _STDIO_HANDLE_TYPE_SOCKET = 3; 10 const int _STDIO_HANDLE_TYPE_SOCKET = 3;
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 switch (_StdIOUtils._getStdioHandleType(object == stdout ? 1 : 2)) { 321 switch (_StdIOUtils._getStdioHandleType(object == stdout ? 1 : 2)) {
322 case _STDIO_HANDLE_TYPE_TERMINAL: return StdioType.TERMINAL; 322 case _STDIO_HANDLE_TYPE_TERMINAL: return StdioType.TERMINAL;
323 case _STDIO_HANDLE_TYPE_PIPE: return StdioType.PIPE; 323 case _STDIO_HANDLE_TYPE_PIPE: return StdioType.PIPE;
324 case _STDIO_HANDLE_TYPE_FILE: return StdioType.FILE; 324 case _STDIO_HANDLE_TYPE_FILE: return StdioType.FILE;
325 } 325 }
326 } 326 }
327 if (object is _FileStream) { 327 if (object is _FileStream) {
328 return StdioType.FILE; 328 return StdioType.FILE;
329 } 329 }
330 if (object is Socket) { 330 if (object is Socket) {
331 switch (_StdIOUtils._socketType(object._nativeSocket)) { 331 int socketType = _StdIOUtils._socketType(object);
332 case _STDIO_HANDLE_TYPE_TERMINAL: return StdioType.TERMINAL; 332 if (socketType != null) {
Florian Schneider 2016/05/09 09:05:15 Why is this null-check necessary?
floitsch 2016/05/09 12:48:01 Because it returns `null` if the object is not a `
Florian Schneider 2016/05/09 13:39:43 Ok, but in case of null the switch would be skippe
floitsch 2016/05/09 14:21:32 Changed it so that it directly returns StdioType.O
333 case _STDIO_HANDLE_TYPE_PIPE: return StdioType.PIPE; 333 switch (socketType) {
334 case _STDIO_HANDLE_TYPE_FILE: return StdioType.FILE; 334 case _STDIO_HANDLE_TYPE_TERMINAL:
335 return StdioType.TERMINAL;
336 case _STDIO_HANDLE_TYPE_PIPE:
337 return StdioType.PIPE;
338 case _STDIO_HANDLE_TYPE_FILE:
339 return StdioType.FILE;
340 }
335 } 341 }
336 } 342 }
337 if (object is IOSink) { 343 if (object is _IOSinkImpl) {
338 try { 344 try {
339 if (object._target is _FileStreamConsumer) { 345 if (object._target is _FileStreamConsumer) {
340 return StdioType.FILE; 346 return StdioType.FILE;
341 } 347 }
342 } catch (e) { 348 } catch (e) {
343 // Only the interface implemented, _sink not available. 349 // Only the interface implemented, _sink not available.
344 } 350 }
345 } 351 }
346 return StdioType.OTHER; 352 return StdioType.OTHER;
347 } 353 }
348 354
349 355
350 class _StdIOUtils { 356 class _StdIOUtils {
351 external static _getStdioOutputStream(int fd); 357 external static _getStdioOutputStream(int fd);
352 external static Stdin _getStdioInputStream(); 358 external static Stdin _getStdioInputStream();
353 external static int _socketType(nativeSocket); 359 external static int _socketType(Socket socket);
354 external static _getStdioHandleType(int fd); 360 external static _getStdioHandleType(int fd);
355 } 361 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698