Uh oh!
There was an error while loading. Please reload this page.
Native buf checks - #3080
Conversation
31366e1 to
ab00906Comparetrevnorris
commented
Sep 26, 2015
rvagg
commented
Sep 29, 2015
I'd say |
trevnorris
commented
Sep 29, 2015
Agreed. |
trevnorris
commented
Oct 6, 2015
@indutny mind giving this a review? Should I leave in the old function signatures for ABI compatibility? /cc @bnoordhuis |
There was a problem hiding this comment.
I'd use CHECK(val->IsUint8Array()) here like you do below.
bnoordhuis
commented
Oct 6, 2015
I'd keep the function signatures for now, else it's a semver-major change. |
Prefer using Object.setPrototypeOf() instead.
Native Buffer method calls do not require anything from the prototype.
So it is unnecessary to check if the Object's prototype is equal to
Buffer.prototype.
This fixes an issue that prevents Buffer from being inherited the ES5
way. Now the following will work:
function A(n) {
const b = new Buffer(n);
Object.setPrototypeOf(b, A.prototype);
return b;
}
Object.setPrototypeOf(A.prototype, Buffer.prototype);
Object.setPrototypeOf(A, Buffer);
console.log(new A(4));
Fix: nodejs#2882ab00906 to
b7eb4f1Comparetrevnorris
commented
Oct 6, 2015
@bnoordhuis Thanks. Comments addressed. |
bnoordhuis
commented
Oct 6, 2015
LGTM but can you do s/Only/only/ in the second commit log for consistency? EDIT: And while I'm being pedantic, s/cleanup/clean up/. |
Prefer using Object.setPrototypeOf() instead. PR-URL: #3080 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Native Buffer method calls do not require anything from the prototype.
So it is unnecessary to check if the Object's prototype is equal to
Buffer.prototype.
This fixes an issue that prevents Buffer from being inherited the ES5
way. Now the following will work:
function A(n) {
const b = new Buffer(n);
Object.setPrototypeOf(b, A.prototype);
return b;
}
Object.setPrototypeOf(A.prototype, Buffer.prototype);
Object.setPrototypeOf(A, Buffer);
console.log(new A(4));
Fix: #2882
PR-URL: #3080
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>trevnorris
commented
Oct 6, 2015
indutny
commented
Oct 6, 2015
Belated LGTM |
Prefer using Object.setPrototypeOf() instead. PR-URL: #3080 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Native Buffer method calls do not require anything from the prototype.
So it is unnecessary to check if the Object's prototype is equal to
Buffer.prototype.
This fixes an issue that prevents Buffer from being inherited the ES5
way. Now the following will work:
function A(n) {
const b = new Buffer(n);
Object.setPrototypeOf(b, A.prototype);
return b;
}
Object.setPrototypeOf(A.prototype, Buffer.prototype);
Object.setPrototypeOf(A, Buffer);
console.log(new A(4));
Fix: #2882
PR-URL: #3080
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>mikemorris
commented
Oct 12, 2015
I'm seeing an assertion failure (at https://github.com/nodejs/node/blob/master/src/node_buffer.cc#L151) that I think is related to this change while testing https://github.com/mapbox/mapbox-gl-native against Node.js v4.2.0 (was previously passing on v4.1.2). Compiled using nan 2.1.0, stack trace follows, can try to distill a simpler test case if there isn't a clear fix here. |
indutny
commented
Oct 12, 2015
Argh... I guess I know what's happening |
`CallbackInfo` is now bound to `ArrayBuffer` instance, not `Uint8Array`, therefore `SPREAD_ARG` will abort with: Assertion failed: ((object)->IsUint8Array()) Make changes necessary to migrate it to `ArrayBuffer`. See: nodejs#3080 (comment)
indutny
commented
Oct 12, 2015
@mikemorris I'm terribly sorry for this, it should be fixed by #3329 |
`CallbackInfo` is now bound to `ArrayBuffer` instance, not `Uint8Array`, therefore `SPREAD_ARG` will abort with: Assertion failed: ((object)->IsUint8Array()) Make changes necessary to migrate it to `ArrayBuffer`. See: #3080 (comment) Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> PR-URL: #3329
`CallbackInfo` is now bound to `ArrayBuffer` instance, not `Uint8Array`, therefore `SPREAD_ARG` will abort with: Assertion failed: ((object)->IsUint8Array()) Make changes necessary to migrate it to `ArrayBuffer`. See: #3080 (comment) Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> PR-URL: #3329
MylesBorins
commented
Nov 17, 2015
landed in v4.x-staging as e0fffca...651a5b5 |
Native Buffer method calls do not require anything from the prototype.
So it is unnecessary to check if the Object's prototype is equal to
Buffer.prototype.
This fixes an issue that prevents Buffer from being inherited the ES5
way. Now the following will work:
R=@bnoordhuis
Also, will those native buffer functions need to be re-added for this to land on v4?