From 1bbd4e29a5d3ec0c713531d5cfe4c980cc0cc770 Mon Sep 17 00:00:00 2001 From: George Petrov Date: Sat, 20 Nov 2021 20:36:03 +0100 Subject: [PATCH] make V8 version dependent --- src/conversions.cc | 6 ++++++ src/node.cc | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/conversions.cc b/src/conversions.cc index 7f81930c..5f97d0f7 100644 --- a/src/conversions.cc +++ b/src/conversions.cc @@ -28,8 +28,14 @@ void InitConversions(Local exports) { end_position_key.Reset(Nan::Persistent(Nan::New("endPosition").ToLocalChecked())); point_transfer_buffer = static_cast(malloc(2 * sizeof(uint32_t))); + + #if V8_MAJOR_VERSION >= 8 auto backing_store = ArrayBuffer::NewBackingStore(point_transfer_buffer, 2 * sizeof(uint32_t), BackingStore::EmptyDeleter, nullptr); auto js_point_transfer_buffer = ArrayBuffer::New(Isolate::GetCurrent(), std::move(backing_store)); + #else + auto js_point_transfer_buffer = ArrayBuffer::New(Isolate::GetCurrent(), point_transfer_buffer, 2 * sizeof(uint32_t)); + #endif + Nan::Set(exports, Nan::New("pointTransferArray").ToLocalChecked(), Uint32Array::New(js_point_transfer_buffer, 0, 2)); } diff --git a/src/node.cc b/src/node.cc index 8a1e21fc..322a32f0 100644 --- a/src/node.cc +++ b/src/node.cc @@ -29,8 +29,14 @@ static inline void setup_transfer_buffer(uint32_t node_count) { } transfer_buffer_length = new_length; transfer_buffer = static_cast(malloc(transfer_buffer_length * sizeof(uint32_t))); + + #if V8_MAJOR_VERSION >= 8 auto backing_store = ArrayBuffer::NewBackingStore(transfer_buffer, transfer_buffer_length * sizeof(uint32_t), BackingStore::EmptyDeleter, nullptr); auto js_transfer_buffer = ArrayBuffer::New(Isolate::GetCurrent(), std::move(backing_store)); + #else + auto js_transfer_buffer = ArrayBuffer::New(Isolate::GetCurrent(), transfer_buffer, transfer_buffer_length * sizeof(uint32_t)); + #endif + Nan::Set( Nan::New(module_exports), Nan::New("nodeTransferArray").ToLocalChecked(),