From 24b0f67c2b0b97a4b79f9582e805785cb317daa0 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sat, 9 Dec 2017 04:40:20 +0100 Subject: src: remove `StreamResourc::Cast()` This is not necessary since C++ already has `static_cast` as a proper way to cast inside a class hierarchy. PR-URL: https://github.com/nodejs/node/pull/17564 Reviewed-By: Anatoli Papirovski Reviewed-By: James M Snell --- src/js_stream.cc | 5 ----- src/js_stream.h | 1 - src/node_http2.h | 3 +-- src/stream_base.h | 4 ---- src/stream_wrap.cc | 5 ----- src/stream_wrap.h | 1 - src/tls_wrap.cc | 7 +------ src/tls_wrap.h | 1 - 8 files changed, 2 insertions(+), 25 deletions(-) diff --git a/src/js_stream.cc b/src/js_stream.cc index 7d4ad7a4e9..da719c357d 100644 --- a/src/js_stream.cc +++ b/src/js_stream.cc @@ -74,11 +74,6 @@ void JSStream::OnReadImpl(ssize_t nread, } -void* JSStream::Cast() { - return static_cast(this); -} - - AsyncWrap* JSStream::GetAsyncWrap() { return static_cast(this); } diff --git a/src/js_stream.h b/src/js_stream.h index 44bf7a06df..c7caf79374 100644 --- a/src/js_stream.h +++ b/src/js_stream.h @@ -18,7 +18,6 @@ class JSStream : public AsyncWrap, public StreamBase { ~JSStream(); - void* Cast() override; bool IsAlive() override; bool IsClosing() override; int ReadStart() override; diff --git a/src/node_http2.h b/src/node_http2.h index c869d9a595..5a61e465a4 100644 --- a/src/node_http2.h +++ b/src/node_http2.h @@ -672,8 +672,7 @@ class Http2Stream : public AsyncWrap, return false; } - AsyncWrap* GetAsyncWrap() override { return static_cast(this); } - void* Cast() override { return reinterpret_cast(this); } + AsyncWrap* GetAsyncWrap() override { return this; } int DoWrite(WriteWrap* w, uv_buf_t* bufs, size_t count, uv_stream_t* send_handle) override; diff --git a/src/stream_base.h b/src/stream_base.h index 87c7b0bc63..3eeb71e4c7 100644 --- a/src/stream_base.h +++ b/src/stream_base.h @@ -231,7 +231,6 @@ class StreamBase : public StreamResource { v8::Local target, int flags = kFlagNone); - virtual void* Cast() = 0; virtual bool IsAlive() = 0; virtual bool IsClosing() = 0; virtual bool IsIPCPipe(); @@ -250,9 +249,6 @@ class StreamBase : public StreamResource { consumed_ = false; } - template - inline Outer* Cast() { return static_cast(Cast()); } - void EmitData(ssize_t nread, v8::Local buf, v8::Local handle); diff --git a/src/stream_wrap.cc b/src/stream_wrap.cc index a737ed67b0..7bd53c58af 100644 --- a/src/stream_wrap.cc +++ b/src/stream_wrap.cc @@ -126,11 +126,6 @@ bool LibuvStreamWrap::IsClosing() { } -void* LibuvStreamWrap::Cast() { - return reinterpret_cast(this); -} - - AsyncWrap* LibuvStreamWrap::GetAsyncWrap() { return static_cast(this); } diff --git a/src/stream_wrap.h b/src/stream_wrap.h index 43df504e81..91fe642cd9 100644 --- a/src/stream_wrap.h +++ b/src/stream_wrap.h @@ -40,7 +40,6 @@ class LibuvStreamWrap : public HandleWrap, public StreamBase { v8::Local context); int GetFD() override; - void* Cast() override; bool IsAlive() override; bool IsClosing() override; bool IsIPCPipe() override; diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index 3f5ed2c575..62d3fd06fe 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -347,7 +347,7 @@ void TLSWrap::EncOut() { void TLSWrap::EncOutCb(WriteWrap* req_wrap, int status) { - TLSWrap* wrap = req_wrap->wrap()->Cast(); + TLSWrap* wrap = static_cast(req_wrap->wrap()); req_wrap->Dispose(); // We should not be getting here after `DestroySSL`, because all queued writes @@ -534,11 +534,6 @@ bool TLSWrap::ClearIn() { } -void* TLSWrap::Cast() { - return reinterpret_cast(this); -} - - AsyncWrap* TLSWrap::GetAsyncWrap() { return static_cast(this); } diff --git a/src/tls_wrap.h b/src/tls_wrap.h index b782e7c3c2..edd21cf1cf 100644 --- a/src/tls_wrap.h +++ b/src/tls_wrap.h @@ -56,7 +56,6 @@ class TLSWrap : public AsyncWrap, v8::Local unused, v8::Local context); - void* Cast() override; int GetFD() override; bool IsAlive() override; bool IsClosing() override; -- cgit v1.2.3