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

Side by Side Diff: pkg/fletchc/lib/vm_command_reader.dart

Issue 1659163007: Rename fletch -> dartino (Closed) Base URL: https://github.com/dartino/sdk.git@master
Patch Set: address comments Created 4 years, 10 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
« no previous file with comments | « pkg/fletchc/lib/src/zone_helper.dart ('k') | pkg/fletchc/lib/vm_commands.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file
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.md file.
4
5 part of fletch.vm_session;
6
7 class SessionCommandTransformerBuilder
8 extends CommandTransformerBuilder<VmCommand> {
9
10 VmCommand makeCommand(int code, ByteData payload) {
11 return new VmCommand.fromBuffer(
12 VmCommandCode.values[code], toUint8ListView(payload));
13 }
14 }
15
16 class VmCommandReader {
17 final StreamIterator<VmCommand> iterator;
18
19 VmCommandReader(
20 Stream<List<int>> stream,
21 Sink<List<int>> stdoutSink,
22 Sink<List<int>> stderrSink)
23 : iterator = new StreamIterator<VmCommand>(
24 filterCommandStream(stream, stdoutSink, stderrSink));
25
26 static Stream<VmCommand> filterCommandStream(
27 Stream<List<int>> stream,
28 Sink<List<int>> stdoutSink,
29 Sink<List<int>> stderrSink) async* {
30 // When done with the data on the socket, we do not close
31 // stdoutSink and stderrSink. They are usually stdout and stderr
32 // and the user will probably want to add more on those streams
33 // independently of the messages added here.
34 StreamTransformer<List<int>, VmCommand> transformer =
35 new SessionCommandTransformerBuilder().build();
36 await for (VmCommand command in stream.transform(transformer)) {
37 if (command is StdoutData) {
38 if (stdoutSink != null) stdoutSink.add(command.value);
39 } else if (command is StderrData) {
40 if (stderrSink != null) stderrSink.add(command.value);
41 } else {
42 yield command;
43 }
44 }
45 }
46 }
OLDNEW
« no previous file with comments | « pkg/fletchc/lib/src/zone_helper.dart ('k') | pkg/fletchc/lib/vm_commands.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698