aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/compiler/node_generator.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/node_generator.cc')
-rw-r--r--src/compiler/node_generator.cc56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/compiler/node_generator.cc b/src/compiler/node_generator.cc
index c0fef9128f..ed835b4445 100644
--- a/src/compiler/node_generator.cc
+++ b/src/compiler/node_generator.cc
@@ -22,10 +22,10 @@
#include "src/compiler/generator_helpers.h"
#include "src/compiler/node_generator_helpers.h"
+using grpc::protobuf::Descriptor;
using grpc::protobuf::FileDescriptor;
-using grpc::protobuf::ServiceDescriptor;
using grpc::protobuf::MethodDescriptor;
-using grpc::protobuf::Descriptor;
+using grpc::protobuf::ServiceDescriptor;
using grpc::protobuf::io::Printer;
using grpc::protobuf::io::StringOutputStream;
using std::map;
@@ -53,15 +53,15 @@ grpc::string ModuleAlias(const grpc::string filename) {
// Given a filename like foo/bar/baz.proto, returns the corresponding JavaScript
// message file foo/bar/baz.js
-grpc::string GetJSMessageFilename(const grpc::string &filename) {
+grpc::string GetJSMessageFilename(const grpc::string& filename) {
grpc::string name = filename;
return grpc_generator::StripProto(name) + "_pb.js";
}
// Given a filename like foo/bar/baz.proto, returns the root directory
// path ../../
-grpc::string GetRootPath(const grpc::string &from_filename,
- const grpc::string &to_filename) {
+grpc::string GetRootPath(const grpc::string& from_filename,
+ const grpc::string& to_filename) {
if (to_filename.find("google/protobuf") == 0) {
// Well-known types (.proto files in the google/protobuf directory) are
// assumed to come from the 'google-protobuf' npm package. We may want to
@@ -82,24 +82,24 @@ grpc::string GetRootPath(const grpc::string &from_filename,
// Return the relative path to load to_file from the directory containing
// from_file, assuming that both paths are relative to the same directory
-grpc::string GetRelativePath(const grpc::string &from_file,
- const grpc::string &to_file) {
+grpc::string GetRelativePath(const grpc::string& from_file,
+ const grpc::string& to_file) {
return GetRootPath(from_file, to_file) + to_file;
}
/* Finds all message types used in all services in the file, and returns them
* as a map of fully qualified message type name to message descriptor */
-map<grpc::string, const Descriptor *> GetAllMessages(
- const FileDescriptor *file) {
- map<grpc::string, const Descriptor *> message_types;
+map<grpc::string, const Descriptor*> GetAllMessages(
+ const FileDescriptor* file) {
+ map<grpc::string, const Descriptor*> message_types;
for (int service_num = 0; service_num < file->service_count();
service_num++) {
- const ServiceDescriptor *service = file->service(service_num);
+ const ServiceDescriptor* service = file->service(service_num);
for (int method_num = 0; method_num < service->method_count();
method_num++) {
- const MethodDescriptor *method = service->method(method_num);
- const Descriptor *input_type = method->input_type();
- const Descriptor *output_type = method->output_type();
+ const MethodDescriptor* method = service->method(method_num);
+ const Descriptor* input_type = method->input_type();
+ const Descriptor* output_type = method->output_type();
message_types[input_type->full_name()] = input_type;
message_types[output_type->full_name()] = output_type;
}
@@ -107,11 +107,11 @@ map<grpc::string, const Descriptor *> GetAllMessages(
return message_types;
}
-grpc::string MessageIdentifierName(const grpc::string &name) {
+grpc::string MessageIdentifierName(const grpc::string& name) {
return grpc_generator::StringReplace(name, ".", "_");
}
-grpc::string NodeObjectPath(const Descriptor *descriptor) {
+grpc::string NodeObjectPath(const Descriptor* descriptor) {
grpc::string module_alias = ModuleAlias(descriptor->file()->name());
grpc::string name = descriptor->full_name();
grpc_generator::StripPrefix(&name, descriptor->file()->package() + ".");
@@ -119,7 +119,7 @@ grpc::string NodeObjectPath(const Descriptor *descriptor) {
}
// Prints out the message serializer and deserializer functions
-void PrintMessageTransformer(const Descriptor *descriptor, Printer *out) {
+void PrintMessageTransformer(const Descriptor* descriptor, Printer* out) {
map<grpc::string, grpc::string> template_vars;
grpc::string full_name = descriptor->full_name();
template_vars["identifier_name"] = MessageIdentifierName(full_name);
@@ -149,9 +149,9 @@ void PrintMessageTransformer(const Descriptor *descriptor, Printer *out) {
out->Print("}\n\n");
}
-void PrintMethod(const MethodDescriptor *method, Printer *out) {
- const Descriptor *input_type = method->input_type();
- const Descriptor *output_type = method->output_type();
+void PrintMethod(const MethodDescriptor* method, Printer* out) {
+ const Descriptor* input_type = method->input_type();
+ const Descriptor* output_type = method->output_type();
map<grpc::string, grpc::string> vars;
vars["service_name"] = method->service()->full_name();
vars["name"] = method->name();
@@ -177,7 +177,7 @@ void PrintMethod(const MethodDescriptor *method, Printer *out) {
}
// Prints out the service descriptor object
-void PrintService(const ServiceDescriptor *service, Printer *out) {
+void PrintService(const ServiceDescriptor* service, Printer* out) {
map<grpc::string, grpc::string> template_vars;
out->Print(GetNodeComments(service, true).c_str());
template_vars["name"] = service->name();
@@ -200,7 +200,7 @@ void PrintService(const ServiceDescriptor *service, Printer *out) {
out->Print(GetNodeComments(service, false).c_str());
}
-void PrintImports(const FileDescriptor *file, Printer *out) {
+void PrintImports(const FileDescriptor* file, Printer* out) {
out->Print("var grpc = require('grpc');\n");
if (file->message_type_count() > 0) {
grpc::string file_path =
@@ -219,9 +219,9 @@ void PrintImports(const FileDescriptor *file, Printer *out) {
out->Print("\n");
}
-void PrintTransformers(const FileDescriptor *file, Printer *out) {
- map<grpc::string, const Descriptor *> messages = GetAllMessages(file);
- for (std::map<grpc::string, const Descriptor *>::iterator it =
+void PrintTransformers(const FileDescriptor* file, Printer* out) {
+ map<grpc::string, const Descriptor*> messages = GetAllMessages(file);
+ for (std::map<grpc::string, const Descriptor*>::iterator it =
messages.begin();
it != messages.end(); it++) {
PrintMessageTransformer(it->second, out);
@@ -229,14 +229,14 @@ void PrintTransformers(const FileDescriptor *file, Printer *out) {
out->Print("\n");
}
-void PrintServices(const FileDescriptor *file, Printer *out) {
+void PrintServices(const FileDescriptor* file, Printer* out) {
for (int i = 0; i < file->service_count(); i++) {
PrintService(file->service(i), out);
}
}
-}
+} // namespace
-grpc::string GenerateFile(const FileDescriptor *file) {
+grpc::string GenerateFile(const FileDescriptor* file) {
grpc::string output;
{
StringOutputStream output_stream(&output);