Commit 0a7432f0 authored by zhujiashun's avatar zhujiashun

use descriptor of default_instance in base

parent dd3fb73f
......@@ -14,13 +14,11 @@
#include "esp_message.h"
#include <google/protobuf/reflection_ops.h> // ReflectionOps::Merge
#include <google/protobuf/reflection_ops.h> // ReflectionOps::Merge
#include <google/protobuf/wire_format.h> // WireFormatLite::GetTagWireType
namespace brpc {
EspMessageBase EspMessage::_base;
EspMessage::EspMessage()
: ::google::protobuf::Message() {
SharedCtor();
......@@ -44,12 +42,7 @@ void EspMessage::SharedDtor() {
}
const ::google::protobuf::Descriptor* EspMessage::descriptor() {
return _base.GetDescriptor();
}
const EspMessage& EspMessage::default_instance() {
static EspMessage req;
return req;
return EspMessageBase::descriptor();
}
EspMessage* EspMessage::New() const {
......@@ -138,8 +131,8 @@ void EspMessage::Swap(EspMessage* other) {
::google::protobuf::Metadata EspMessage::GetMetadata() const {
::google::protobuf::Metadata metadata;
metadata.descriptor = _base.GetDescriptor();
metadata.reflection = _base.GetReflection();
metadata.descriptor = EspMessage::descriptor();
metadata.reflection = NULL;
return metadata;
}
......
......@@ -73,11 +73,8 @@ protected:
private:
void SharedCtor();
void SharedDtor();
static EspMessageBase _base;
};
} // namespace brpc
#endif // PROTOBUF_esp_5fmessage_2eproto__INCLUDED
#endif // BRPC_ESP_MESSAGE_H
......@@ -26,8 +26,6 @@
namespace brpc {
MemcacheRequestBase MemcacheRequest::_base;
MemcacheRequest::MemcacheRequest()
: ::google::protobuf::Message() {
SharedCtor();
......@@ -56,12 +54,7 @@ void MemcacheRequest::SetCachedSize(int size) const {
}
const ::google::protobuf::Descriptor* MemcacheRequest::descriptor() {
return _base.GetDescriptor();
}
const MemcacheRequest& MemcacheRequest::default_instance() {
static MemcacheRequest req;
return req;
return MemcacheRequestBase::descriptor();
}
MemcacheRequest* MemcacheRequest::New() const {
......@@ -174,13 +167,11 @@ void MemcacheRequest::Swap(MemcacheRequest* other) {
::google::protobuf::Metadata MemcacheRequest::GetMetadata() const {
::google::protobuf::Metadata metadata;
metadata.descriptor = _base.GetDescriptor();
metadata.reflection = _base.GetReflection();
metadata.descriptor = MemcacheRequest::descriptor();
metadata.reflection = NULL;
return metadata;
}
MemcacheResponseBase MemcacheResponse::_base;
MemcacheResponse::MemcacheResponse()
: ::google::protobuf::Message() {
SharedCtor();
......@@ -207,12 +198,7 @@ void MemcacheResponse::SetCachedSize(int size) const {
_cached_size_ = size;
}
const ::google::protobuf::Descriptor* MemcacheResponse::descriptor() {
return _base.GetDescriptor();
}
const MemcacheResponse& MemcacheResponse::default_instance() {
static MemcacheResponse res;
return res;
return MemcacheResponseBase::descriptor();
}
MemcacheResponse* MemcacheResponse::New() const {
......@@ -303,8 +289,8 @@ void MemcacheResponse::Swap(MemcacheResponse* other) {
::google::protobuf::Metadata MemcacheResponse::GetMetadata() const {
::google::protobuf::Metadata metadata;
metadata.descriptor = _base.GetDescriptor();
metadata.reflection = _base.GetReflection();
metadata.descriptor = MemcacheResponse::descriptor();
metadata.reflection = NULL;
return metadata;
}
......
......@@ -104,7 +104,6 @@ public:
int GetCachedSize() const { return _cached_size_; }
static const ::google::protobuf::Descriptor* descriptor();
static const MemcacheRequest& default_instance();
protected:
::google::protobuf::Metadata GetMetadata() const override;
......@@ -125,7 +124,6 @@ private:
int _pipelined_count;
butil::IOBuf _buf;
mutable int _cached_size_;
static MemcacheRequestBase _base;
};
// Response from Memcache.
......@@ -216,7 +214,6 @@ public:
int GetCachedSize() const { return _cached_size_; }
static const ::google::protobuf::Descriptor* descriptor();
static const MemcacheResponse& default_instance();
protected:
::google::protobuf::Metadata GetMetadata() const;
......@@ -232,8 +229,6 @@ private:
std::string _err;
butil::IOBuf _buf;
mutable int _cached_size_;
static MemcacheResponseBase _base;
};
} // namespace brpc
......
......@@ -22,8 +22,6 @@
namespace brpc {
NsheadMessageBase NsheadMessage::_base;
NsheadMessage::NsheadMessage()
: ::google::protobuf::Message() {
SharedCtor();
......@@ -47,12 +45,7 @@ void NsheadMessage::SharedDtor() {
}
const ::google::protobuf::Descriptor* NsheadMessage::descriptor() {
return _base.GetDescriptor();
}
const NsheadMessage& NsheadMessage::default_instance() {
static NsheadMessage message;
return message;
return NsheadMessageBase::descriptor();
}
NsheadMessage* NsheadMessage::New() const {
......@@ -136,8 +129,8 @@ void NsheadMessage::Swap(NsheadMessage* other) {
::google::protobuf::Metadata NsheadMessage::GetMetadata() const {
::google::protobuf::Metadata metadata;
metadata.descriptor = _base.GetDescriptor();
metadata.reflection = _base.GetReflection();
metadata.descriptor = NsheadMessage::descriptor();
metadata.reflection = NULL;
return metadata;
}
......
......@@ -42,7 +42,6 @@ public:
}
static const ::google::protobuf::Descriptor* descriptor();
static const NsheadMessage& default_instance();
void Swap(NsheadMessage* other);
......@@ -65,13 +64,11 @@ public:
int GetCachedSize() const { return ByteSize(); }
protected:
::google::protobuf::Metadata GetMetadata() const;
::google::protobuf::Metadata GetMetadata() const override;
private:
void SharedCtor();
void SharedDtor();
static NsheadMessageBase _base;
};
} // namespace brpc
......
......@@ -24,8 +24,6 @@ namespace brpc {
DEFINE_bool(redis_verbose_crlf2space, false, "[DEBUG] Show \\r\\n as a space");
RedisRequestBase RedisRequest::_base;
RedisRequest::RedisRequest()
: ::google::protobuf::Message() {
SharedCtor();
......@@ -202,18 +200,13 @@ bool RedisRequest::SerializeTo(butil::IOBuf* buf) const {
}
const ::google::protobuf::Descriptor* RedisRequest::descriptor() {
return _base.GetDescriptor();
}
const RedisRequest& RedisRequest::default_instance() {
static RedisRequest req;
return req;
return RedisRequestBase::descriptor();
}
::google::protobuf::Metadata RedisRequest::GetMetadata() const {
::google::protobuf::Metadata metadata;
metadata.descriptor = _base.GetDescriptor();
metadata.reflection = _base.GetReflection();
metadata.descriptor = RedisRequest::descriptor();
metadata.reflection = NULL;
return metadata;
}
......@@ -242,8 +235,6 @@ std::ostream& operator<<(std::ostream& os, const RedisRequest& r) {
return os;
}
RedisResponseBase RedisResponse::_base;
RedisResponse::RedisResponse()
: ::google::protobuf::Message() {
SharedCtor();
......@@ -374,18 +365,13 @@ void RedisResponse::Swap(RedisResponse* other) {
}
const ::google::protobuf::Descriptor* RedisResponse::descriptor() {
return _base.GetDescriptor();
}
const RedisResponse& RedisResponse::default_instance() {
static RedisResponse res;
return res;
return RedisResponseBase::descriptor();
}
::google::protobuf::Metadata RedisResponse::GetMetadata() const {
::google::protobuf::Metadata metadata;
metadata.descriptor = _base.GetDescriptor();
metadata.reflection = _base.GetReflection();
metadata.descriptor = RedisResponseBase::descriptor();
metadata.reflection = NULL;
return metadata;
}
......
......@@ -117,7 +117,6 @@ public:
int GetCachedSize() const { return _cached_size_; }
static const ::google::protobuf::Descriptor* descriptor();
static const RedisRequest& default_instance();
void Print(std::ostream&) const;
......@@ -134,7 +133,6 @@ private:
bool _has_error; // previous AddCommand had error
butil::IOBuf _buf; // the serialized request.
mutable int _cached_size_; // ByteSize
static RedisRequestBase _base;
};
// Response from Redis.
......@@ -189,7 +187,6 @@ public:
int GetCachedSize() const { return _cached_size_; }
static const ::google::protobuf::Descriptor* descriptor();
static const RedisResponse& default_instance();
protected:
::google::protobuf::Metadata GetMetadata() const override;
......@@ -204,7 +201,6 @@ private:
butil::Arena _arena;
int _nreply;
mutable int _cached_size_;
static RedisResponseBase _base;
};
std::ostream& operator<<(std::ostream& os, const RedisRequest&);
......
......@@ -19,8 +19,6 @@
namespace brpc {
SerializedRequestBase SerializedRequest::_base;
SerializedRequest::SerializedRequest()
: ::google::protobuf::Message() {
SharedCtor();
......@@ -46,12 +44,7 @@ void SerializedRequest::SetCachedSize(int /*size*/) const {
CHECK(false) << "You're not supposed to call " << __FUNCTION__;
}
const ::google::protobuf::Descriptor* SerializedRequest::descriptor() {
return _base.GetDescriptor();
}
const SerializedRequest& SerializedRequest::default_instance() {
static SerializedRequest req;
return req;
return SerializedRequestBase::descriptor();
}
SerializedRequest* SerializedRequest::New() const {
......@@ -119,8 +112,8 @@ void SerializedRequest::Swap(SerializedRequest* other) {
::google::protobuf::Metadata SerializedRequest::GetMetadata() const {
::google::protobuf::Metadata metadata;
metadata.descriptor = _base.GetDescriptor();
metadata.reflection = _base.GetReflection();
metadata.descriptor = SerializedRequest::descriptor();
metadata.reflection = NULL;
return metadata;
}
......
......@@ -36,7 +36,6 @@ public:
}
static const ::google::protobuf::Descriptor* descriptor();
static const SerializedRequest& default_instance();
void Swap(SerializedRequest* other);
......@@ -70,7 +69,6 @@ private:
private:
butil::IOBuf _serialized;
static SerializedRequestBase _base;
};
} // namespace brpc
......
......@@ -29,8 +29,6 @@
namespace brpc {
ThriftFramedMessageBase ThriftFramedMessage::_base;
ThriftFramedMessage::ThriftFramedMessage()
: ::google::protobuf::Message() {
SharedCtor();
......@@ -53,12 +51,7 @@ void ThriftFramedMessage::SharedDtor() {
}
const ::google::protobuf::Descriptor* ThriftFramedMessage::descriptor() {
return _base.GetDescriptor();
}
const ThriftFramedMessage& ThriftFramedMessage::default_instance() {
static ThriftFramedMessage message;
return message;
return ThriftFramedMessageBase::descriptor();
}
ThriftFramedMessage* ThriftFramedMessage::New() const {
......@@ -140,8 +133,8 @@ void ThriftFramedMessage::Swap(ThriftFramedMessage* other) {
::google::protobuf::Metadata ThriftFramedMessage::GetMetadata() const {
::google::protobuf::Metadata metadata;
metadata.descriptor = _base.GetDescriptor();
metadata.reflection = _base.GetReflection();
metadata.descriptor = ThriftFramedMessage::descriptor();
metadata.reflection = NULL;
return metadata;
}
......
......@@ -76,7 +76,6 @@ public:
ThriftFramedMessage& operator=(const ThriftFramedMessage& from) = delete;
static const ::google::protobuf::Descriptor* descriptor();
static const ThriftFramedMessage& default_instance();
void Swap(ThriftFramedMessage* other);
......@@ -104,7 +103,6 @@ protected:
private:
void SharedCtor();
void SharedDtor();
static ThriftFramedMessageBase _base;
};
class ThriftStub {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment