Commit 0a7432f0 authored by zhujiashun's avatar zhujiashun

use descriptor of default_instance in base

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