You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
extracting UVHandle() and handle_ to ConnectionWrap.
I 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.
0 commit comments