| 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 #include "include/dart_tools_api.h" | 10 #include "include/dart_tools_api.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 // Implementation of native functions which are used for some | 84 // Implementation of native functions which are used for some |
| 85 // test/debug functionality in standalone dart mode. | 85 // test/debug functionality in standalone dart mode. |
| 86 void FUNCTION_NAME(Builtin_PrintString)(Dart_NativeArguments args) { | 86 void FUNCTION_NAME(Builtin_PrintString)(Dart_NativeArguments args) { |
| 87 intptr_t length = 0; | 87 intptr_t length = 0; |
| 88 uint8_t* chars = NULL; | 88 uint8_t* chars = NULL; |
| 89 Dart_Handle str = Dart_GetNativeArgument(args, 0); | 89 Dart_Handle str = Dart_GetNativeArgument(args, 0); |
| 90 Dart_Handle result = Dart_StringToUTF8(str, &chars, &length); | 90 Dart_Handle result = Dart_StringToUTF8(str, &chars, &length); |
| 91 if (Dart_IsError(result)) Dart_PropagateError(result); | 91 if (Dart_IsError(result)) Dart_PropagateError(result); |
| 92 | 92 |
| 93 // Uses fwrite to support printing NUL bytes. | 93 // Uses fwrite to support printing NUL bytes. |
| 94 fwrite(chars, 1, length, stdout); | 94 intptr_t res = fwrite(chars, 1, length, stdout); |
| 95 ASSERT(res == length); |
| 95 fputs("\n", stdout); | 96 fputs("\n", stdout); |
| 96 fflush(stdout); | 97 fflush(stdout); |
| 97 if (ShouldCaptureStdout()) { | 98 if (ShouldCaptureStdout()) { |
| 98 // For now we report print output on the Stdout stream. | 99 // For now we report print output on the Stdout stream. |
| 99 uint8_t newline[] = { '\n' }; | 100 uint8_t newline[] = { '\n' }; |
| 100 Dart_ServiceSendDataEvent("Stdout", "WriteEvent", chars, length); | 101 Dart_ServiceSendDataEvent("Stdout", "WriteEvent", chars, length); |
| 101 Dart_ServiceSendDataEvent("Stdout", "WriteEvent", | 102 Dart_ServiceSendDataEvent("Stdout", "WriteEvent", |
| 102 newline, sizeof(newline)); | 103 newline, sizeof(newline)); |
| 103 } | 104 } |
| 104 } | 105 } |
| 105 | 106 |
| 106 } // namespace bin | 107 } // namespace bin |
| 107 } // namespace dart | 108 } // namespace dart |
| OLD | NEW |