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

Side by Side Diff: lib/protobuf/plugin/CodeGenerator.dart

Issue 10595002: Protocol Buffer runtime library and 'protoc' plugin (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Work around http://code.google.com/p/dart/issues/detail?id=3806 Created 8 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « lib/fixnum/int64.dart ('k') | lib/protobuf/plugin/DartFile.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) 2011, the Dart 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 file.
4
5 interface ProtobufContainer {
6 String get fqname();
7 String get classname();
8 GoogleProtobuf_FileOptions_OptimizeMode get optimizeFor();
9 }
10
11 class CodeGenerator implements ProtobufContainer {
12 CodeGenerator(ProtocGenDartConfig this._config, InputStream this._streamIn,
13 OutputStream this._streamOut, OutputStream this._streamErr);
14
15 void generate() {
16 PbInputStreamReader reader = new PbInputStreamReader(_streamIn);
17 Future<List<int>> futureBytes = reader.readBytes();
18 futureBytes.then(_(List<int> bytes) {
19 _streamIn.close();
20 GoogleProtobufCompiler_CodeGeneratorRequest request =
21 GoogleProtobufCompiler_CodeGeneratorRequest.parseFromBuffer(bytes);
22
23 GoogleProtobufCompiler_CodeGeneratorResponse_Builder responseBuilder =
24 new GoogleProtobufCompiler_CodeGeneratorResponse_Builder();
25
26 GenerationContext ctx =
27 new GenerationContext(new OutputStreamWriter(_streamErr));
28
29 List<FileGenerator> generators = new List<FileGenerator>();
30 for (GoogleProtobuf_FileDescriptorProto file in request.protoFile) {
31 FileGenerator generator = new FileGenerator(file, this, ctx);
32 if (request.fileToGenerate.indexOf(file.name) >= 0) {
33 generators.add(generator);
34 }
35 }
36
37 for (FileGenerator filegen in generators) {
38 GoogleProtobufCompiler_CodeGeneratorResponse_File file = filegen.generat e();
39 responseBuilder.file.add(file);
40 }
41
42 List<int> buffer = responseBuilder.build().writeToBuffer();
43 _streamOut.write(buffer);
44 });
45 }
46
47 ProtocGenDartConfig _config;
48 InputStream _streamIn;
49 OutputStream _streamOut;
50 OutputStream _streamErr;
51 GoogleProtobuf_FileOptions_OptimizeMode get optimizeFor() => null;
52 String get fqname() => "";
53 String get classname() => null;
54 }
OLDNEW
« no previous file with comments | « lib/fixnum/int64.dart ('k') | lib/protobuf/plugin/DartFile.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698