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

Side by Side Diff: runtime/bin/builtin_natives.cc

Issue 1460863002: Redo the interface for capture stdio. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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 | « no previous file | runtime/bin/embedded_dart_io.h » ('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) 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"
11 11
12 #include "platform/assert.h" 12 #include "platform/assert.h"
13 13
14 #include "bin/builtin.h" 14 #include "bin/builtin.h"
15 #include "bin/dartutils.h" 15 #include "bin/dartutils.h"
16 #include "bin/embedded_dart_io.h"
16 #include "bin/file.h" 17 #include "bin/file.h"
17 #include "bin/io_natives.h" 18 #include "bin/io_natives.h"
18 #include "bin/platform.h" 19 #include "bin/platform.h"
19 20
20 namespace dart { 21 namespace dart {
21 namespace bin { 22 namespace bin {
22 23
23 // Lists the native functions implementing basic functionality in 24 // Lists the native functions implementing basic functionality in
24 // standalone dart, such as printing, file I/O, and platform information. 25 // standalone dart, such as printing, file I/O, and platform information.
25 // Advanced I/O classes like sockets and process management are implemented 26 // Advanced I/O classes like sockets and process management are implemented
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 intptr_t length = 0; 87 intptr_t length = 0;
87 uint8_t* chars = NULL; 88 uint8_t* chars = NULL;
88 Dart_Handle str = Dart_GetNativeArgument(args, 0); 89 Dart_Handle str = Dart_GetNativeArgument(args, 0);
89 Dart_Handle result = Dart_StringToUTF8(str, &chars, &length); 90 Dart_Handle result = Dart_StringToUTF8(str, &chars, &length);
90 if (Dart_IsError(result)) Dart_PropagateError(result); 91 if (Dart_IsError(result)) Dart_PropagateError(result);
91 92
92 // Uses fwrite to support printing NUL bytes. 93 // Uses fwrite to support printing NUL bytes.
93 fwrite(chars, 1, length, stdout); 94 fwrite(chars, 1, length, stdout);
94 fputs("\n", stdout); 95 fputs("\n", stdout);
95 fflush(stdout); 96 fflush(stdout);
96 if (File::capture_stdout()) { 97 if (ShouldCaptureStdout()) {
97 // For now we report print output on the Stdout stream. 98 // For now we report print output on the Stdout stream.
98 uint8_t newline[] = { '\n' }; 99 uint8_t newline[] = { '\n' };
99 Dart_ServiceSendDataEvent("Stdout", "WriteEvent", chars, length); 100 Dart_ServiceSendDataEvent("Stdout", "WriteEvent", chars, length);
100 Dart_ServiceSendDataEvent("Stdout", "WriteEvent", 101 Dart_ServiceSendDataEvent("Stdout", "WriteEvent",
101 newline, sizeof(newline)); 102 newline, sizeof(newline));
102 } 103 }
103 } 104 }
104 105
105 } // namespace bin 106 } // namespace bin
106 } // namespace dart 107 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/embedded_dart_io.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698