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

Unified Diff: lib/file_generator.dart

Issue 1196293003: Initial support for generating client and server stubs for Dart. (Closed) Base URL: https://github.com/dart-lang/dart-protoc-plugin.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: lib/file_generator.dart
diff --git a/lib/file_generator.dart b/lib/file_generator.dart
index a53c46fd24571ca9ebd7752494bba1b5ff130f63..19e5faa59291437254795b7748b6e4e1b896c71f 100644
--- a/lib/file_generator.dart
+++ b/lib/file_generator.dart
@@ -25,6 +25,8 @@ class FileGenerator extends ProtobufContainer {
final List<EnumGenerator> enumGenerators = <EnumGenerator>[];
final List<MessageGenerator> messageGenerators = <MessageGenerator>[];
final List<ExtensionGenerator> extensionGenerators = <ExtensionGenerator>[];
+ final List<ClientApiGenerator> clientApiGenerators = <ClientApiGenerator>[];
+ final List<ServiceGenerator> serviceGenerators = <ServiceGenerator>[];
FileGenerator(this._fileDescriptor, this._parent, this._context) {
_context.register(this);
@@ -43,6 +45,10 @@ class FileGenerator extends ProtobufContainer {
extensionGenerators.add(
new ExtensionGenerator(extension, this, _context));
}
+ for (ServiceDescriptorProto service in _fileDescriptor.service) {
+ serviceGenerators.add(new ServiceGenerator(service, this, _context));
+ clientApiGenerators.add(new ClientApiGenerator(service, this, _context));
+ }
}
String get package => _fileDescriptor.package;
@@ -93,6 +99,8 @@ class FileGenerator extends ProtobufContainer {
'///\n'
'library $libraryName;\n'
'\n'
+ 'import \'dart:async\';\n'
Søren Gjesse 2015/06/23 12:08:31 Is there any way to only import this if needed? W
wibling 2015/06/23 13:26:34 I will take a look and see what I can come up with
+ '\n'
"import 'package:fixnum/fixnum.dart';\n"
"import 'package:protobuf/protobuf.dart';"
);
@@ -151,6 +159,13 @@ class FileGenerator extends ProtobufContainer {
out.println('}');
});
}
+
+ for (ClientApiGenerator c in clientApiGenerators) {
+ c.generate(out);
+ }
+ for (ServiceGenerator s in serviceGenerators) {
+ s.generate(out);
+ }
}
bool get needsMapMixinImport {

Powered by Google App Engine
This is Rietveld 408576698