OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 <stdlib.h> | 5 #include <stdlib.h> |
6 #include <stdio.h> | 6 #include <stdio.h> |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "include/dart_api.h" | 9 #include "include/dart_api.h" |
10 | 10 |
11 #include "platform/assert.h" | 11 #include "platform/assert.h" |
12 | 12 |
13 #include "bin/builtin.h" | 13 #include "bin/builtin.h" |
14 #include "bin/dartutils.h" | 14 #include "bin/dartutils.h" |
15 #include "bin/io_natives.h" | 15 #include "bin/io_natives.h" |
16 #include "bin/platform.h" | |
16 | 17 |
17 namespace dart { | 18 namespace dart { |
18 namespace bin { | 19 namespace bin { |
19 | 20 |
20 // Lists the native functions implementing basic functionality in | 21 // Lists the native functions implementing basic functionality in |
21 // standalone dart, such as printing, file I/O, and platform information. | 22 // standalone dart, such as printing, file I/O, and platform information. |
22 // Advanced I/O classes like sockets and process management are implemented | 23 // Advanced I/O classes like sockets and process management are implemented |
23 // using functions listed in io_natives.cc. | 24 // using functions listed in io_natives.cc. |
24 #define BUILTIN_NATIVE_LIST(V) \ | 25 #define BUILTIN_NATIVE_LIST(V) \ |
25 V(Directory_Exists, 1) \ | 26 V(Directory_Exists, 1) \ |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
101 void FUNCTION_NAME(Logger_PrintString)(Dart_NativeArguments args) { | 102 void FUNCTION_NAME(Logger_PrintString)(Dart_NativeArguments args) { |
102 intptr_t length = 0; | 103 intptr_t length = 0; |
103 uint8_t* chars = NULL; | 104 uint8_t* chars = NULL; |
104 Dart_Handle str = Dart_GetNativeArgument(args, 0); | 105 Dart_Handle str = Dart_GetNativeArgument(args, 0); |
105 Dart_Handle result = Dart_StringToUTF8(str, &chars, &length); | 106 Dart_Handle result = Dart_StringToUTF8(str, &chars, &length); |
106 if (Dart_IsError(result)) { | 107 if (Dart_IsError(result)) { |
107 // TODO(turnidge): Consider propagating some errors here. What if | 108 // TODO(turnidge): Consider propagating some errors here. What if |
108 // an isolate gets interrupted by the embedder in the middle of | 109 // an isolate gets interrupted by the embedder in the middle of |
109 // Dart_StringToUTF8? We need to make sure not to swallow the | 110 // Dart_StringToUTF8? We need to make sure not to swallow the |
110 // interrupt. | 111 // interrupt. |
111 fputs(Dart_GetError(result), stdout); | 112 Platform::PrintBlocking(stdout, "%s\n", Dart_GetError(result)); |
112 } else { | 113 } else { |
113 fwrite(chars, sizeof(*chars), length, stdout); | 114 Platform::PrintBlocking(stdout, "%.*s\n", length, chars); |
Søren Gjesse
2013/10/01 07:16:39
I was not aware of the * for precision.
Anders Johnsen
2013/10/01 09:05:21
Let's see if all the platforms supports it :)
| |
114 } | 115 } |
115 fputc('\n', stdout); | |
116 fflush(stdout); | |
117 } | 116 } |
118 | 117 |
119 } // namespace bin | 118 } // namespace bin |
120 } // namespace dart | 119 } // namespace dart |
OLD | NEW |