From 9f5800ab81dd33da792477e5451ec4c83b1cc0fb Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 22 Oct 2014 04:26:25 +0200 Subject: src: mark virtual functions with override keyword Add `override` keywords where appropriate. Makes maintenance easier because the compiler will shout at you when a base class changes in an incompatible way. --- src/cares_wrap.cc | 46 +++++++++++++++++++++++----------------------- src/fs_event_wrap.cc | 2 +- src/handle_wrap.h | 2 +- src/node.cc | 6 +++--- src/node_stat_watcher.h | 2 +- src/node_v8_platform.h | 2 +- src/smalloc.cc | 10 +++++----- src/tls_wrap.h | 14 +++++++------- src/udp_wrap.h | 2 +- 9 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index 987bbd7e88..d86f0e833f 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -231,7 +231,7 @@ class QueryWrap : public AsyncWrap { : AsyncWrap(env, req_wrap_obj, AsyncWrap::PROVIDER_CARES) { } - virtual ~QueryWrap() { + virtual ~QueryWrap() override { CHECK_EQ(false, persistent().IsEmpty()); persistent().Reset(); } @@ -358,7 +358,7 @@ class QueryAWrap: public QueryWrap { : QueryWrap(env, req_wrap_obj) { } - int Send(const char* name) { + int Send(const char* name) override { ares_query(env()->cares_channel(), name, ns_c_in, @@ -369,7 +369,7 @@ class QueryAWrap: public QueryWrap { } protected: - void Parse(unsigned char* buf, int len) { + void Parse(unsigned char* buf, int len) override { HandleScope handle_scope(env()->isolate()); Context::Scope context_scope(env()->context()); @@ -395,7 +395,7 @@ class QueryAaaaWrap: public QueryWrap { : QueryWrap(env, req_wrap_obj) { } - int Send(const char* name) { + int Send(const char* name) override { ares_query(env()->cares_channel(), name, ns_c_in, @@ -406,7 +406,7 @@ class QueryAaaaWrap: public QueryWrap { } protected: - void Parse(unsigned char* buf, int len) { + void Parse(unsigned char* buf, int len) override { HandleScope handle_scope(env()->isolate()); Context::Scope context_scope(env()->context()); @@ -432,7 +432,7 @@ class QueryCnameWrap: public QueryWrap { : QueryWrap(env, req_wrap_obj) { } - int Send(const char* name) { + int Send(const char* name) override { ares_query(env()->cares_channel(), name, ns_c_in, @@ -443,7 +443,7 @@ class QueryCnameWrap: public QueryWrap { } protected: - void Parse(unsigned char* buf, int len) { + void Parse(unsigned char* buf, int len) override { HandleScope handle_scope(env()->isolate()); Context::Scope context_scope(env()->context()); struct hostent* host; @@ -471,7 +471,7 @@ class QueryMxWrap: public QueryWrap { : QueryWrap(env, req_wrap_obj) { } - int Send(const char* name) { + int Send(const char* name) override { ares_query(env()->cares_channel(), name, ns_c_in, @@ -482,7 +482,7 @@ class QueryMxWrap: public QueryWrap { } protected: - void Parse(unsigned char* buf, int len) { + void Parse(unsigned char* buf, int len) override { HandleScope handle_scope(env()->isolate()); Context::Scope context_scope(env()->context()); @@ -520,7 +520,7 @@ class QueryNsWrap: public QueryWrap { : QueryWrap(env, req_wrap_obj) { } - int Send(const char* name) { + int Send(const char* name) override { ares_query(env()->cares_channel(), name, ns_c_in, @@ -531,7 +531,7 @@ class QueryNsWrap: public QueryWrap { } protected: - void Parse(unsigned char* buf, int len) { + void Parse(unsigned char* buf, int len) override { HandleScope handle_scope(env()->isolate()); Context::Scope context_scope(env()->context()); struct hostent* host; @@ -556,7 +556,7 @@ class QueryTxtWrap: public QueryWrap { : QueryWrap(env, req_wrap_obj) { } - int Send(const char* name) { + int Send(const char* name) override { ares_query(env()->cares_channel(), name, ns_c_in, @@ -567,7 +567,7 @@ class QueryTxtWrap: public QueryWrap { } protected: - void Parse(unsigned char* buf, int len) { + void Parse(unsigned char* buf, int len) override { HandleScope handle_scope(env()->isolate()); Context::Scope context_scope(env()->context()); struct ares_txt_reply* txt_out; @@ -610,7 +610,7 @@ class QuerySrvWrap: public QueryWrap { : QueryWrap(env, req_wrap_obj) { } - int Send(const char* name) { + int Send(const char* name) override { ares_query(env()->cares_channel(), name, ns_c_in, @@ -621,7 +621,7 @@ class QuerySrvWrap: public QueryWrap { } protected: - void Parse(unsigned char* buf, int len) { + void Parse(unsigned char* buf, int len) override { HandleScope handle_scope(env()->isolate()); Context::Scope context_scope(env()->context()); @@ -664,7 +664,7 @@ class QueryNaptrWrap: public QueryWrap { : QueryWrap(env, req_wrap_obj) { } - int Send(const char* name) { + int Send(const char* name) override { ares_query(env()->cares_channel(), name, ns_c_in, @@ -675,7 +675,7 @@ class QueryNaptrWrap: public QueryWrap { } protected: - void Parse(unsigned char* buf, int len) { + void Parse(unsigned char* buf, int len) override { HandleScope handle_scope(env()->isolate()); Context::Scope context_scope(env()->context()); @@ -726,7 +726,7 @@ class QuerySoaWrap: public QueryWrap { : QueryWrap(env, req_wrap_obj) { } - int Send(const char* name) { + int Send(const char* name) override { ares_query(env()->cares_channel(), name, ns_c_in, @@ -737,7 +737,7 @@ class QuerySoaWrap: public QueryWrap { } protected: - void Parse(unsigned char* buf, int len) { + void Parse(unsigned char* buf, int len) override { HandleScope handle_scope(env()->isolate()); Context::Scope context_scope(env()->context()); @@ -779,7 +779,7 @@ class GetHostByAddrWrap: public QueryWrap { : QueryWrap(env, req_wrap_obj) { } - int Send(const char* name) { + int Send(const char* name) override { int length, family; char address_buffer[sizeof(struct in6_addr)]; @@ -803,7 +803,7 @@ class GetHostByAddrWrap: public QueryWrap { } protected: - void Parse(struct hostent* host) { + void Parse(struct hostent* host) override { HandleScope handle_scope(env()->isolate()); Context::Scope context_scope(env()->context()); this->CallOnComplete(HostentToNames(env(), host)); @@ -817,7 +817,7 @@ class GetHostByNameWrap: public QueryWrap { : QueryWrap(env, req_wrap_obj) { } - int Send(const char* name, int family) { + int Send(const char* name, int family) override { ares_gethostbyname(env()->cares_channel(), name, family, @@ -827,7 +827,7 @@ class GetHostByNameWrap: public QueryWrap { } protected: - void Parse(struct hostent* host) { + void Parse(struct hostent* host) override { HandleScope scope(env()->isolate()); Local addresses = HostentToAddresses(env(), host); diff --git a/src/fs_event_wrap.cc b/src/fs_event_wrap.cc index 8f381b40a7..57d07272ec 100644 --- a/src/fs_event_wrap.cc +++ b/src/fs_event_wrap.cc @@ -54,7 +54,7 @@ class FSEventWrap: public HandleWrap { private: FSEventWrap(Environment* env, Handle object); - virtual ~FSEventWrap(); + virtual ~FSEventWrap() override; static void OnEvent(uv_fs_event_t* handle, const char* filename, int events, int status); diff --git a/src/handle_wrap.h b/src/handle_wrap.h index 4f6f6e0323..40ee75cd81 100644 --- a/src/handle_wrap.h +++ b/src/handle_wrap.h @@ -64,7 +64,7 @@ class HandleWrap : public AsyncWrap { v8::Handle object, uv_handle_t* handle, AsyncWrap::ProviderType provider); - virtual ~HandleWrap(); + virtual ~HandleWrap() override; private: friend void GetActiveHandles(const v8::FunctionCallbackInfo&); diff --git a/src/node.cc b/src/node.cc index 6ae55f0db9..eaf2277579 100644 --- a/src/node.cc +++ b/src/node.cc @@ -160,9 +160,9 @@ class ArrayBufferAllocator : public ArrayBuffer::Allocator { static const size_t kMaxLength = 0x3fffffff; static ArrayBufferAllocator the_singleton; virtual ~ArrayBufferAllocator() {} - virtual void* Allocate(size_t length); - virtual void* AllocateUninitialized(size_t length); - virtual void Free(void* data, size_t length); + virtual void* Allocate(size_t length) override; + virtual void* AllocateUninitialized(size_t length) override; + virtual void Free(void* data, size_t length) override; private: ArrayBufferAllocator() {} ArrayBufferAllocator(const ArrayBufferAllocator&); diff --git a/src/node_stat_watcher.h b/src/node_stat_watcher.h index fb6d5ad3e7..ce4b0142a7 100644 --- a/src/node_stat_watcher.h +++ b/src/node_stat_watcher.h @@ -32,7 +32,7 @@ namespace node { class StatWatcher : public AsyncWrap { public: - virtual ~StatWatcher(); + virtual ~StatWatcher() override; static void Initialize(Environment* env, v8::Handle target); diff --git a/src/node_v8_platform.h b/src/node_v8_platform.h index d8bc7378cc..59bcdaeb02 100644 --- a/src/node_v8_platform.h +++ b/src/node_v8_platform.h @@ -51,7 +51,7 @@ class TaskQueue { class Platform : public v8::Platform { public: explicit Platform(unsigned int worker_count); - ~Platform(); + virtual ~Platform() override; void CallOnBackgroundThread(v8::Task* task, ExpectedRuntime expected_runtime); diff --git a/src/smalloc.cc b/src/smalloc.cc index 517492818f..dd750537a4 100644 --- a/src/smalloc.cc +++ b/src/smalloc.cc @@ -473,11 +473,11 @@ class RetainedAllocInfo: public RetainedObjectInfo { public: explicit RetainedAllocInfo(Handle wrapper); - virtual void Dispose(); - virtual bool IsEquivalent(RetainedObjectInfo* other); - virtual intptr_t GetHash(); - virtual const char* GetLabel(); - virtual intptr_t GetSizeInBytes(); + virtual void Dispose() override; + virtual bool IsEquivalent(RetainedObjectInfo* other) override; + virtual intptr_t GetHash() override; + virtual const char* GetLabel() override; + virtual intptr_t GetSizeInBytes() override; private: static const char label_[]; diff --git a/src/tls_wrap.h b/src/tls_wrap.h index 598288c621..b409e54011 100644 --- a/src/tls_wrap.h +++ b/src/tls_wrap.h @@ -52,22 +52,22 @@ class TLSCallbacks : public crypto::SSLWrap, v8::Handle unused, v8::Handle context); - const char* Error(); - int TryWrite(uv_buf_t** bufs, size_t* count); + const char* Error() override; + int TryWrite(uv_buf_t** bufs, size_t* count) override; int DoWrite(WriteWrap* w, uv_buf_t* bufs, size_t count, uv_stream_t* send_handle, - uv_write_cb cb); - void AfterWrite(WriteWrap* w); + uv_write_cb cb) override; + void AfterWrite(WriteWrap* w) override; void DoAlloc(uv_handle_t* handle, size_t suggested_size, - uv_buf_t* buf); + uv_buf_t* buf) override; void DoRead(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf, - uv_handle_type pending); - int DoShutdown(ShutdownWrap* req_wrap, uv_shutdown_cb cb); + uv_handle_type pending) override; + int DoShutdown(ShutdownWrap* req_wrap, uv_shutdown_cb cb) override; void NewSessionDoneCb(); diff --git a/src/udp_wrap.h b/src/udp_wrap.h index ab0d6fa8e6..5d9cbef746 100644 --- a/src/udp_wrap.h +++ b/src/udp_wrap.h @@ -58,7 +58,7 @@ class UDPWrap: public HandleWrap { private: UDPWrap(Environment* env, v8::Handle object); - virtual ~UDPWrap(); + virtual ~UDPWrap() override; static void DoBind(const v8::FunctionCallbackInfo& args, int family); -- cgit v1.2.3