src: extracting OnConnection from pipe_wrap and tcp_wrap by danbev · Pull Request #7547 · nodejs/node
One of the issues in nodejs#4641 concerns OnConnection in pipe_wrap and tcp_wrap which are very similar with some minor difference in how they are coded. This commit extracts OnConnection so both these classes can share the same implementation.
added
c++
labels
Jul 5, 2016and removed build
Issues and PRs related to build files or the CI.labels
Jul 5, 2016I originally just wanted to move the handle_ member from tcp_wrap and
pipe_wrap without changing its name. But I ran into an issue which I
believe is because tcp_wrap and pipe_wrap now extend ConnectionWrap.
Both classes are derived from StreamWrap which has an inheritance
tree that looks like this:
class PipeWrap : public StreamWrap, ConnectionWrap<PipeWrap, uv_pipe_t>
class StreamWrap : public HandleWrap, public StreamBase
class HandleWrap : public AsyncWrap
class AsyncWrap : public BaseObject
BaseObject has the following private member:
v8::Persistent<v8::Object> handle_;
The compiler complains that 'handle_' is found in multiple base classes
of different types:
../src/pipe_wrap.cc:130:50: error:
member 'handle_' found in multiple base classes of different types
reinterpret_cast<uv_stream_t*>(&handle_),
^
../src/base-object.h:47:30: note:
member found by ambiguous name lookup
v8::Persistent<v8::Object> handle_;
It turns out that name lookup is performed before access rules are
considered. C++ standard section 3.4:
"The access rules (Clause 11) are considered only once name lookup
and function overload resolution (if applicable) have succeeded."
It is possible to be explicit about the type you want using the
resolution operator ::. So we could use ConnectionWrap::handle_
to tell the compiler which type we want.
But going down this route still caused changes to a number of files
and I think the code is somewhat clearer using a different name for
the handle, and there is no confusion with the handle_ member in
BaseObject.
Being fairly new to C++ and to the project there this is probably a
gap in my knowledge about the best way to solve this. Looking forward
to hear about other options/ideas for this.
addaleax pushed a commit that referenced this pull request
Jul 25, 2016One of the issues in #4641 concerns OnConnection in pipe_wrap and tcp_wrap which are very similar with some minor difference in how they are coded. This commit extracts OnConnection so both these classes can share the same implementation. PR-URL: #7547 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Trott added a commit to Trott/io.js that referenced this pull request
Jul 25, 201685af1a6 was added (squashed into another commit) without running through CI. Unfortunately, it breaks some of the CI builds, notably on three of the CentOS setups. Undoing that one small change to get builds green again. Refs: nodejs#7547 (comment) PR-URL: nodejs#7873
Trott added a commit to Trott/io.js that referenced this pull request
Jul 25, 201685af1a6 was added (squashed into another commit) without running through CI. Unfortunately, it breaks some of the CI builds, notably on three of the CentOS setups. Undoing that one small change to get builds green again. Refs: nodejs#7547 (comment) PR-URL: nodejs#7873 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anna Henningsen <anna@addaleax.net>
gibfahn pushed a commit to gibfahn/node that referenced this pull request
Aug 5, 2016One of the issues in nodejs#4641 concerns OnConnection in pipe_wrap and tcp_wrap which are very similar with some minor difference in how they are coded. This commit extracts OnConnection so both these classes can share the same implementation. PR-URL: nodejs#7547 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
cjihrig pushed a commit that referenced this pull request
Aug 10, 2016One of the issues in #4641 concerns OnConnection in pipe_wrap and tcp_wrap which are very similar with some minor difference in how they are coded. This commit extracts OnConnection so both these classes can share the same implementation. PR-URL: #7547 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
cjihrig pushed a commit that referenced this pull request
Aug 10, 201685af1a6 was added (squashed into another commit) without running through CI. Unfortunately, it breaks some of the CI builds, notably on three of the CentOS setups. Undoing that one small change to get builds green again. Refs: #7547 (comment) PR-URL: #7873 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anna Henningsen <anna@addaleax.net>
danbev
deleted the
extracting-onconnection
branch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters