OLD | NEW |
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 #include "bin/stdio.h" |
| 6 |
5 #include "bin/builtin.h" | 7 #include "bin/builtin.h" |
6 #include "bin/dartutils.h" | 8 #include "bin/dartutils.h" |
7 #include "bin/utils.h" | 9 #include "bin/utils.h" |
8 #include "bin/stdio.h" | |
9 | 10 |
10 #include "platform/globals.h" | 11 #include "platform/globals.h" |
11 #include "platform/utils.h" | 12 #include "platform/utils.h" |
12 | 13 |
13 #include "include/dart_api.h" | 14 #include "include/dart_api.h" |
14 | 15 |
15 | |
16 namespace dart { | 16 namespace dart { |
17 namespace bin { | 17 namespace bin { |
18 | 18 |
19 void FUNCTION_NAME(Stdin_ReadByte)(Dart_NativeArguments args) { | 19 void FUNCTION_NAME(Stdin_ReadByte)(Dart_NativeArguments args) { |
20 ScopedBlockingCall blocker; | 20 ScopedBlockingCall blocker; |
21 Dart_SetReturnValue(args, Dart_NewInteger(Stdin::ReadByte())); | 21 Dart_SetReturnValue(args, Dart_NewInteger(Stdin::ReadByte())); |
22 } | 22 } |
23 | 23 |
24 | 24 |
25 void FUNCTION_NAME(Stdin_GetEchoMode)(Dart_NativeArguments args) { | 25 void FUNCTION_NAME(Stdin_GetEchoMode)(Dart_NativeArguments args) { |
(...skipping 18 matching lines...) Expand all Loading... |
44 } | 44 } |
45 | 45 |
46 | 46 |
47 void FUNCTION_NAME(Stdout_GetTerminalSize)(Dart_NativeArguments args) { | 47 void FUNCTION_NAME(Stdout_GetTerminalSize)(Dart_NativeArguments args) { |
48 if (!Dart_IsInteger(Dart_GetNativeArgument(args, 0))) { | 48 if (!Dart_IsInteger(Dart_GetNativeArgument(args, 0))) { |
49 OSError os_error(-1, "Invalid argument", OSError::kUnknown); | 49 OSError os_error(-1, "Invalid argument", OSError::kUnknown); |
50 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error)); | 50 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error)); |
51 return; | 51 return; |
52 } | 52 } |
53 intptr_t fd = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 0)); | 53 intptr_t fd = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 0)); |
54 if (fd != 1 && fd != 2) { | 54 if ((fd != 1) && (fd != 2)) { |
55 Dart_SetReturnValue(args, Dart_NewApiError("Terminal fd must be 1 or 2")); | 55 Dart_SetReturnValue(args, Dart_NewApiError("Terminal fd must be 1 or 2")); |
56 return; | 56 return; |
57 } | 57 } |
58 | 58 |
59 int size[2]; | 59 int size[2]; |
60 if (Stdout::GetTerminalSize(fd, size)) { | 60 if (Stdout::GetTerminalSize(fd, size)) { |
61 Dart_Handle list = Dart_NewList(2); | 61 Dart_Handle list = Dart_NewList(2); |
62 Dart_ListSetAt(list, 0, Dart_NewInteger(size[0])); | 62 Dart_ListSetAt(list, 0, Dart_NewInteger(size[0])); |
63 Dart_ListSetAt(list, 1, Dart_NewInteger(size[1])); | 63 Dart_ListSetAt(list, 1, Dart_NewInteger(size[1])); |
64 Dart_SetReturnValue(args, list); | 64 Dart_SetReturnValue(args, list); |
65 } else { | 65 } else { |
66 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); | 66 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); |
67 } | 67 } |
68 } | 68 } |
69 | 69 |
70 } // namespace bin | 70 } // namespace bin |
71 } // namespace dart | 71 } // namespace dart |
OLD | NEW |