Uh oh!
There was an error while loading. Please reload this page.
Linted code - #581
Conversation
bnoordhuis
commented
Jun 13, 2016
The explicitness vs. implicitness of constructors seems a bit random. What's the pattern? |
kkoopa
commented
Jun 13, 2016
V8 has MaybeLocal do conversion. I was a bit befuddled regarding Persistents, but tried to stick to that of V8 3.19 or so, which was the last one with single argument constructors. Some of them were explicit, others were not. On June 13, 2016 9:10:52 AM GMT+03:00, Ben Noordhuis notifications@github.com wrote:
|
bnoordhuis
commented
Jun 13, 2016
Most things are explicit now and personally I think that's better, particularly with persistent handles, because there is less opportunity for accidental memory leaks. Possibly less of an issue with v4 and newer than it is with v0.10 and v0.12 because v8::Persistent is by default non-copyable.
|
| inline Persistent(const v8::Persistent<S, M2> &that) : | ||
| inline | ||
| Persistent(const v8::Persistent<S, M2> &that) : // NOLINT(runtime/explicit) | ||
| v8::Persistent<T, M2>(v8::Isolate::GetCurrent(), that) {} |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
kkoopa
commented
Jun 14, 2016
There, turned out there were rather many wrong things which had been masked by implicit conversion. Now it should be sorted out. |
| inline Persistent() : v8::Persistent<T, M>() {} | ||
| template<typename S> inline Persistent(v8::Local<S> that) : | ||
| template<typename S> inline explicit Persistent(v8::Local<S> that) : |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
bnoordhuis
commented
Jun 15, 2016
I think I understand why the code is doing what it's doing but it's really skirting UB territory now, isn't it? |
kkoopa
commented
Jun 15, 2016
Skirting, but never crossing. Nothing is virtual and no child has added any data members. Additionally, the horrible things only occur for old versions, which will not change retroactively. |
kkoopa
commented
Jun 15, 2016
I changed the casts to |
| # else | ||
| inline MaybeLocal(v8::Local<S> that) : | ||
| inline MaybeLocal(v8::Local<S> that) : // NOLINT(runtime/explicit) | ||
| val_(*reinterpret_cast<v8::Local<T>*>(&that)) {} |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
bnoordhuis
commented
Jun 16, 2016
LGTM |
kkoopa
commented
Jun 16, 2016
Thanks for looking through this. I did find an edge case in that it is now not reasonably possible to actually copy a The best solution ought to be the normalization process from #492, which would set up the correct inheritance hierarchy, remove some code duplication and make everything better in the long run. I will open a new PR with these commits plus the additional ones. |
CI: https://travis-ci.org/nodejs/nan/builds/138059729