Move protobuf dependencies to config_protobuf.h

pull/6438/head
Yuchen Zeng 9 years ago
parent ea09adc84b
commit 3623dc5cdd
  1. 27
      extensions/reflection/proto_server_reflection.cc
  2. 6
      extensions/reflection/proto_server_reflection.h
  3. 22
      include/grpc++/impl/codegen/config_protobuf.h
  4. 18
      src/compiler/config.h

@ -37,21 +37,12 @@
#include <unordered_set>
#include <vector>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/descriptor.pb.h>
#include <grpc++/grpc++.h>
#include "reflection/proto_server_reflection.h"
using grpc::Status;
using grpc::StatusCode;
using google::protobuf::MethodDescriptor;
using google::protobuf::ServiceDescriptor;
using google::protobuf::Descriptor;
using google::protobuf::FileDescriptor;
using google::protobuf::FieldDescriptor;
using google::protobuf::DescriptorPool;
using google::protobuf::FileDescriptorProto;
using grpc::reflection::v1alpha::ServerReflectionRequest;
using grpc::reflection::v1alpha::ExtensionRequest;
using grpc::reflection::v1alpha::ServerReflectionResponse;
@ -64,7 +55,7 @@ using grpc::reflection::v1alpha::FileDescriptorResponse;
namespace grpc {
ProtoServerReflection::ProtoServerReflection()
: descriptor_pool_(DescriptorPool::generated_pool()) {}
: descriptor_pool_(protobuf::DescriptorPool::generated_pool()) {}
void ProtoServerReflection::SetServiceList(
const std::vector<grpc::string>* services) {
@ -143,7 +134,7 @@ Status ProtoServerReflection::GetFileByName(
return Status::CANCELLED;
}
const FileDescriptor* file_desc = descriptor_pool_->FindFileByName(filename);
const protobuf::FileDescriptor* file_desc = descriptor_pool_->FindFileByName(filename);
if (file_desc == nullptr) {
return Status(StatusCode::NOT_FOUND, "File not found.");
}
@ -159,7 +150,7 @@ Status ProtoServerReflection::GetFileContainingSymbol(
return Status::CANCELLED;
}
const FileDescriptor* file_desc =
const protobuf::FileDescriptor* file_desc =
descriptor_pool_->FindFileContainingSymbol(symbol);
if (file_desc == nullptr) {
return Status(StatusCode::NOT_FOUND, "Symbol not found.");
@ -176,13 +167,13 @@ Status ProtoServerReflection::GetFileContainingExtension(
return Status::CANCELLED;
}
const Descriptor* desc =
const protobuf::Descriptor* desc =
descriptor_pool_->FindMessageTypeByName(request->containing_type());
if (desc == nullptr) {
return Status(StatusCode::NOT_FOUND, "Type not found.");
}
const FieldDescriptor* field_desc = descriptor_pool_->FindExtensionByNumber(
const protobuf::FieldDescriptor* field_desc = descriptor_pool_->FindExtensionByNumber(
desc, request->extension_number());
if (field_desc == nullptr) {
return Status(StatusCode::NOT_FOUND, "Extension not found.");
@ -199,12 +190,12 @@ Status ProtoServerReflection::GetAllExtensionNumbers(
return Status::CANCELLED;
}
const Descriptor* desc = descriptor_pool_->FindMessageTypeByName(type);
const protobuf::Descriptor* desc = descriptor_pool_->FindMessageTypeByName(type);
if (desc == nullptr) {
return Status(StatusCode::NOT_FOUND, "Type not found.");
}
std::vector<const FieldDescriptor*> extensions;
std::vector<const protobuf::FieldDescriptor*> extensions;
descriptor_pool_->FindAllExtensions(desc, &extensions);
for (auto extension : extensions) {
response->add_extension_number(extension->number());
@ -214,14 +205,14 @@ Status ProtoServerReflection::GetAllExtensionNumbers(
}
void ProtoServerReflection::FillFileDescriptorResponse(
const FileDescriptor* file_desc, ServerReflectionResponse* response,
const protobuf::FileDescriptor* file_desc, ServerReflectionResponse* response,
std::unordered_set<grpc::string>* seen_files) {
if (seen_files->find(file_desc->name()) != seen_files->end()) {
return;
}
seen_files->insert(file_desc->name());
FileDescriptorProto file_desc_proto;
protobuf::FileDescriptorProto file_desc_proto;
grpc::string data;
file_desc->CopyTo(&file_desc_proto);
file_desc_proto.SerializeToString(&data);

@ -40,8 +40,6 @@
#include <unordered_set>
#include <vector>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/descriptor.pb.h>
#include <grpc++/grpc++.h>
#include <grpc++/impl/reflection.grpc.pb.h>
@ -83,14 +81,14 @@ class ProtoServerReflection GRPC_FINAL
reflection::v1alpha::ExtensionNumberResponse* response);
void FillFileDescriptorResponse(
const google::protobuf::FileDescriptor* file_desc,
const protobuf::FileDescriptor* file_desc,
reflection::v1alpha::ServerReflectionResponse* response,
std::unordered_set<grpc::string>* seen_files);
void FillErrorResponse(const Status& status,
reflection::v1alpha::ErrorResponse* error_response);
const google::protobuf::DescriptorPool* descriptor_pool_;
const protobuf::DescriptorPool* descriptor_pool_;
const std::vector<string>* services_;
};

@ -44,6 +44,19 @@
#define GRPC_CUSTOM_MESSAGE ::google::protobuf::Message
#endif
#ifndef GRPC_CUSTOM_DESCRIPTOR
#include <google/protobuf/descriptor.h>
#include <google/protobuf/descriptor.pb.h>
#define GRPC_CUSTOM_DESCRIPTOR ::google::protobuf::Descriptor
#define GRPC_CUSTOM_DESCRIPTORPOOL ::google::protobuf::DescriptorPool
#define GPRC_CUSTOM_FIELDDESCRIPTOR ::google::protobuf::FieldDescriptor
#define GRPC_CUSTOM_FILEDESCRIPTOR ::google::protobuf::FileDescriptor
#define GRPC_CUSTOM_FILEDESCRIPTORPROTO ::google::protobuf::FileDescriptorProto
#define GRPC_CUSTOM_METHODDESCRIPTOR ::google::protobuf::MethodDescriptor
#define GRPC_CUSTOM_SERVICEDESCRIPTOR ::google::protobuf::ServiceDescriptor
#define GRPC_CUSTOM_SOURCELOCATION ::google::protobuf::SourceLocation
#endif
#ifndef GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream.h>
@ -60,6 +73,15 @@ namespace protobuf {
typedef GRPC_CUSTOM_MESSAGE Message;
typedef GRPC_CUSTOM_PROTOBUF_INT64 int64;
typedef GRPC_CUSTOM_DESCRIPTOR Descriptor;
typedef GRPC_CUSTOM_DESCRIPTORPOOL DescriptorPool;
typedef GPRC_CUSTOM_FIELDDESCRIPTOR FieldDescriptor;
typedef GRPC_CUSTOM_FILEDESCRIPTOR FileDescriptor;
typedef GRPC_CUSTOM_FILEDESCRIPTORPROTO FileDescriptorProto;
typedef GRPC_CUSTOM_METHODDESCRIPTOR MethodDescriptor;
typedef GRPC_CUSTOM_SERVICEDESCRIPTOR ServiceDescriptor;
typedef GRPC_CUSTOM_SOURCELOCATION SourceLocation;
namespace io {
typedef GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM ZeroCopyOutputStream;
typedef GRPC_CUSTOM_ZEROCOPYINPUTSTREAM ZeroCopyInputStream;

@ -37,17 +37,6 @@
#include <grpc++/support/config.h>
#include <grpc++/support/config_protobuf.h>
#ifndef GRPC_CUSTOM_DESCRIPTOR
#include <google/protobuf/descriptor.h>
#include <google/protobuf/descriptor.pb.h>
#define GRPC_CUSTOM_DESCRIPTOR ::google::protobuf::Descriptor
#define GRPC_CUSTOM_FILEDESCRIPTOR ::google::protobuf::FileDescriptor
#define GRPC_CUSTOM_FILEDESCRIPTORPROTO ::google::protobuf::FileDescriptorProto
#define GRPC_CUSTOM_METHODDESCRIPTOR ::google::protobuf::MethodDescriptor
#define GRPC_CUSTOM_SERVICEDESCRIPTOR ::google::protobuf::ServiceDescriptor
#define GRPC_CUSTOM_SOURCELOCATION ::google::protobuf::SourceLocation
#endif
#ifndef GRPC_CUSTOM_CODEGENERATOR
#include <google/protobuf/compiler/code_generator.h>
#define GRPC_CUSTOM_CODEGENERATOR ::google::protobuf::compiler::CodeGenerator
@ -77,12 +66,7 @@
namespace grpc {
namespace protobuf {
typedef GRPC_CUSTOM_DESCRIPTOR Descriptor;
typedef GRPC_CUSTOM_FILEDESCRIPTOR FileDescriptor;
typedef GRPC_CUSTOM_FILEDESCRIPTORPROTO FileDescriptorProto;
typedef GRPC_CUSTOM_METHODDESCRIPTOR MethodDescriptor;
typedef GRPC_CUSTOM_SERVICEDESCRIPTOR ServiceDescriptor;
typedef GRPC_CUSTOM_SOURCELOCATION SourceLocation;
namespace compiler {
typedef GRPC_CUSTOM_CODEGENERATOR CodeGenerator;
typedef GRPC_CUSTOM_GENERATORCONTEXT GeneratorContext;

Loading…
Cancel
Save