Skip to content

Commit 2c023bd

Browse files
Flarnabnoordhuis
andauthored
use GetBackingStore() instead of GetContents() (#888)
* use GetBackingStore() instead of GetContents() Use GetBackingStore() instead of GetContents() for v8 >= 8.0 as GetContents() has been deprecated. Node.js 14 will use 8.1 It would be possible to use GetBackingStore() already with 7.9 but this would lead to issues with Node.js 13 as it uses 7.8 till 13.2.0. Additionally update testmatrix to use latest electron versions and add electron 8. Co-authored-by: Ben Noordhuis <info@bnoordhuis.nl>
1 parent 2c4ee8a commit 2c023bd

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

.travis.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ env:
2626
- TRAVIS_NODE_VERSION="lts/*" ELECTRON_VERSION="2.0.18"
2727
- TRAVIS_NODE_VERSION="lts/*" ELECTRON_VERSION="3.1.13"
2828
- TRAVIS_NODE_VERSION="lts/*" ELECTRON_VERSION="4.2.12"
29-
- TRAVIS_NODE_VERSION="lts/*" ELECTRON_VERSION="5.0.11"
30-
- TRAVIS_NODE_VERSION="lts/*" ELECTRON_VERSION="6.1.2"
31-
- TRAVIS_NODE_VERSION="lts/*" ELECTRON_VERSION="7.0.0"
29+
- TRAVIS_NODE_VERSION="lts/*" ELECTRON_VERSION="5.0.13"
30+
- TRAVIS_NODE_VERSION="lts/*" ELECTRON_VERSION="6.1.9"
31+
- TRAVIS_NODE_VERSION="lts/*" ELECTRON_VERSION="7.1.14"
32+
- TRAVIS_NODE_VERSION="lts/*" ELECTRON_VERSION="8.0.3"
3233
matrix:
3334
exclude:
3435
- os: osx

nan_typedarray_contents.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ class TypedArrayContents {
3131
v8::Local<v8::ArrayBuffer> buffer = array->Buffer();
3232

3333
length = byte_length / sizeof(T);
34-
data = static_cast<char*>(buffer->GetContents().Data()) + byte_offset;
34+
// Actually it's 7.9 here but this would lead to ABI issues with Node.js 13
35+
// using 7.8 till 13.2.0.
36+
#if (V8_MAJOR_VERSION >= 8)
37+
data = static_cast<char*>(buffer->GetBackingStore()->Data()) + byte_offset;
38+
#else
39+
data = static_cast<char*>(buffer->GetContents().Data()) + byte_offset;
40+
#endif
3541
}
3642

3743
#else

0 commit comments

Comments
 (0)